- make readonly argument flags instead
- no need to repeat flags when ending a grant
Partially taken from 2.6.18-xen 312:037c44559e55
Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
drivers/block/xen-blkfront.c | 12 ++++++------
drivers/net/xen-netfront.c | 16 +++++++---------
drivers/xen/grant-table.c | 16 +++++++---------
include/xen/grant_table.h | 7 +++----
4 files changed, 23 insertions(+), 28 deletions(-)
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index 8f90508..f834e64 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -254,7 +254,7 @@ static int blkif_queue_request(struct request *req)
ref,
info->xbdev->otherend_id,
buffer_mfn,
- rq_data_dir(req) );
+ rq_data_dir(req) ? GTF_readonly : 0);
info->shadow[id].frame[i] = mfn_to_pfn(buffer_mfn);
ring_req->seg[i] =
@@ -511,7 +511,7 @@ static void blkif_free(struct blkfront_info *info, int
suspend)
/* Free resources associated with old device channel. */
if (info->ring_ref != GRANT_INVALID_REF) {
- gnttab_end_foreign_access(info->ring_ref, 0,
+ gnttab_end_foreign_access(info->ring_ref,
(unsigned long)info->ring.sring);
info->ring_ref = GRANT_INVALID_REF;
info->ring.sring = NULL;
@@ -526,7 +526,7 @@ static void blkif_completion(struct blk_shadow *s)
{
int i;
for (i = 0; i < s->req.nr_segments; i++)
- gnttab_end_foreign_access(s->req.seg[i].gref, 0, 0UL);
+ gnttab_end_foreign_access(s->req.seg[i].gref, 0UL);
}
static irqreturn_t blkif_interrupt(int irq, void *dev_id)
@@ -809,9 +809,9 @@ static int blkif_recover(struct blkfront_info *info)
req->seg[j].gref,
info->xbdev->otherend_id,
pfn_to_mfn(info->shadow[req->id].frame[j]),
- rq_data_dir(
- (struct request *)
- info->shadow[req->id].request));
+ rq_data_dir((struct request *)
+ info->shadow[req->id].request) ?
+ GTF_readonly : 0);
info->shadow[req->id].req = *req;
info->ring.req_prod_pvt++;
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index cd6184e..46833ae 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -366,8 +366,7 @@ static void xennet_tx_buf_gc(struct net_device *dev)
"domain.\n");
BUG();
}
- gnttab_end_foreign_access_ref(
- np->grant_tx_ref[id], GNTMAP_readonly);
+ gnttab_end_foreign_access_ref(np->grant_tx_ref[id]);
gnttab_release_grant_reference(
&np->gref_tx_head, np->grant_tx_ref[id]);
np->grant_tx_ref[id] = GRANT_INVALID_REF;
@@ -425,7 +424,7 @@ static void xennet_make_frags(struct sk_buff *skb, struct
net_device *dev,
mfn = virt_to_mfn(data);
gnttab_grant_foreign_access_ref(ref, np->xbdev->otherend_id,
- mfn, GNTMAP_readonly);
+ mfn, GTF_readonly);
tx->gref = np->grant_tx_ref[id] = ref;
tx->offset = offset;
@@ -448,7 +447,7 @@ static void xennet_make_frags(struct sk_buff *skb, struct
net_device *dev,
mfn = pfn_to_mfn(page_to_pfn(frag->page));
gnttab_grant_foreign_access_ref(ref, np->xbdev->otherend_id,
- mfn, GNTMAP_readonly);
+ mfn, GTF_readonly);
tx->gref = np->grant_tx_ref[id] = ref;
tx->offset = frag->page_offset;
@@ -503,7 +502,7 @@ static int xennet_start_xmit(struct sk_buff *skb, struct
net_device *dev)
BUG_ON((signed short)ref < 0);
mfn = virt_to_mfn(data);
gnttab_grant_foreign_access_ref(
- ref, np->xbdev->otherend_id, mfn, GNTMAP_readonly);
+ ref, np->xbdev->otherend_id, mfn, GTF_readonly);
tx->gref = np->grant_tx_ref[id] = ref;
tx->offset = offset;
tx->size = len;
@@ -675,7 +674,7 @@ static int xennet_get_responses(struct netfront_info *np,
goto next;
}
- ret = gnttab_end_foreign_access_ref(ref, 0);
+ ret = gnttab_end_foreign_access_ref(ref);
BUG_ON(!ret);
gnttab_release_grant_reference(&np->gref_rx_head, ref);
@@ -1010,8 +1009,7 @@ static void xennet_release_tx_bufs(struct netfront_info
*np)
continue;
skb = np->tx_skbs[i].skb;
- gnttab_end_foreign_access_ref(np->grant_tx_ref[i],
- GNTMAP_readonly);
+ gnttab_end_foreign_access_ref(np->grant_tx_ref[i]);
gnttab_release_grant_reference(&np->gref_tx_head,
np->grant_tx_ref[i]);
np->grant_tx_ref[i] = GRANT_INVALID_REF;
@@ -1241,7 +1239,7 @@ static void xennet_end_access(int ref, void *page)
{
/* This frees the page as a side-effect */
if (ref != GRANT_INVALID_REF)
- gnttab_end_foreign_access(ref, 0, (unsigned long)page);
+ gnttab_end_foreign_access(ref, (unsigned long)page);
}
static void xennet_disconnect_backend(struct netfront_info *info)
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index 58996c9..385187e 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -159,15 +159,14 @@ static void update_grant_entry(grant_ref_t ref, domid_t
domid,
* Public grant-issuing interface functions
*/
void gnttab_grant_foreign_access_ref(grant_ref_t ref, domid_t domid,
- unsigned long frame, int readonly)
+ unsigned long frame, int flags)
{
- update_grant_entry(ref, domid, frame,
- GTF_permit_access | (readonly ? GTF_readonly : 0));
+ update_grant_entry(ref, domid, frame, GTF_permit_access | flags);
}
EXPORT_SYMBOL_GPL(gnttab_grant_foreign_access_ref);
int gnttab_grant_foreign_access(domid_t domid, unsigned long frame,
- int readonly)
+ int flags)
{
int ref;
@@ -175,7 +174,7 @@ int gnttab_grant_foreign_access(domid_t domid, unsigned
long frame,
if (unlikely(ref < 0))
return -ENOSPC;
- gnttab_grant_foreign_access_ref(ref, domid, frame, readonly);
+ gnttab_grant_foreign_access_ref(ref, domid, frame, flags);
return ref;
}
@@ -191,7 +190,7 @@ int gnttab_query_foreign_access(grant_ref_t ref)
}
EXPORT_SYMBOL_GPL(gnttab_query_foreign_access);
-int gnttab_end_foreign_access_ref(grant_ref_t ref, int readonly)
+int gnttab_end_foreign_access_ref(grant_ref_t ref)
{
u16 flags, nflags;
@@ -208,10 +207,9 @@ int gnttab_end_foreign_access_ref(grant_ref_t ref, int
readonly)
}
EXPORT_SYMBOL_GPL(gnttab_end_foreign_access_ref);
-void gnttab_end_foreign_access(grant_ref_t ref, int readonly,
- unsigned long page)
+void gnttab_end_foreign_access(grant_ref_t ref, unsigned long page)
{
- if (gnttab_end_foreign_access_ref(ref, readonly)) {
+ if (gnttab_end_foreign_access_ref(ref)) {
put_free_entry(ref);
if (page != 0)
free_page(page);
diff --git a/include/xen/grant_table.h b/include/xen/grant_table.h
index b89ee8a..8493a83 100644
--- a/include/xen/grant_table.h
+++ b/include/xen/grant_table.h
@@ -63,14 +63,14 @@ int gnttab_suspend(void);
int gnttab_resume(void);
int gnttab_grant_foreign_access(domid_t domid, unsigned long frame,
- int readonly);
+ int flags);
/*
* End access through the given grant reference, iff the grant entry is no
* longer in use. Return 1 if the grant entry was freed, 0 if it is still in
* use.
*/
-int gnttab_end_foreign_access_ref(grant_ref_t ref, int readonly);
+int gnttab_end_foreign_access_ref(grant_ref_t ref);
/*
* Eventually end access through the given grant reference, and once that
@@ -78,8 +78,7 @@ int gnttab_end_foreign_access_ref(grant_ref_t ref, int
readonly);
* immediately iff the grant entry is not in use, otherwise it will happen
* some time later. page may be 0, in which case no freeing will occur.
*/
-void gnttab_end_foreign_access(grant_ref_t ref, int readonly,
- unsigned long page);
+void gnttab_end_foreign_access(grant_ref_t ref, unsigned long page);
int gnttab_grant_foreign_transfer(domid_t domid, unsigned long pfn);
--
1.5.6.5
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|