All of lore.kernel.org
 help / color / mirror / Atom feed
From: Juergen Gross <jgross@suse.com>
To: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org
Cc: Juergen Gross <jgross@suse.com>,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	Stefano Stabellini <sstabellini@kernel.org>
Subject: [PATCH 18/18] xen/xenbus: eliminate xenbus_grant_ring()
Date: Wed, 20 Apr 2022 17:09:42 +0200	[thread overview]
Message-ID: <20220420150942.31235-19-jgross@suse.com> (raw)
In-Reply-To: <20220420150942.31235-1-jgross@suse.com>

There is no external user of xenbus_grant_ring() left, so merge it into
the only caller xenbus_setup_ring().

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 drivers/xen/xenbus/xenbus_client.c | 64 +++++++++---------------------
 include/xen/xenbus.h               |  2 -
 2 files changed, 18 insertions(+), 48 deletions(-)

diff --git a/drivers/xen/xenbus/xenbus_client.c b/drivers/xen/xenbus/xenbus_client.c
index 1a2e0d94ccd1..7b1f7f86b6e5 100644
--- a/drivers/xen/xenbus/xenbus_client.c
+++ b/drivers/xen/xenbus/xenbus_client.c
@@ -363,50 +363,6 @@ static void xenbus_switch_fatal(struct xenbus_device *dev, int depth, int err,
 		__xenbus_switch_state(dev, XenbusStateClosing, 1);
 }
 
-/**
- * xenbus_grant_ring
- * @dev: xenbus device
- * @vaddr: starting virtual address of the ring
- * @nr_pages: number of pages to be granted
- * @grefs: grant reference array to be filled in
- *
- * Grant access to the given @vaddr to the peer of the given device.
- * Then fill in @grefs with grant references.  Return 0 on success, or
- * -errno on error.  On error, the device will switch to
- * XenbusStateClosing, and the error will be saved in the store.
- */
-int xenbus_grant_ring(struct xenbus_device *dev, void *vaddr,
-		      unsigned int nr_pages, grant_ref_t *grefs)
-{
-	int err;
-	unsigned int i;
-	grant_ref_t gref_head;
-
-	err = gnttab_alloc_grant_references(nr_pages, &gref_head);
-	if (err) {
-		xenbus_dev_fatal(dev, err, "granting access to ring page");
-		return err;
-	}
-
-	for (i = 0; i < nr_pages; i++) {
-		unsigned long gfn;
-
-		if (is_vmalloc_addr(vaddr))
-			gfn = pfn_to_gfn(vmalloc_to_pfn(vaddr));
-		else
-			gfn = virt_to_gfn(vaddr);
-
-		grefs[i] = gnttab_claim_grant_reference(&gref_head);
-		gnttab_grant_foreign_access_ref(grefs[i], dev->otherend_id,
-						gfn, 0);
-
-		vaddr = vaddr + XEN_PAGE_SIZE;
-	}
-
-	return 0;
-}
-EXPORT_SYMBOL_GPL(xenbus_grant_ring);
-
 /*
  * xenbus_setup_ring
  * @dev: xenbus device
@@ -424,6 +380,7 @@ int xenbus_setup_ring(struct xenbus_device *dev, gfp_t gfp, void **vaddr,
 		      unsigned int nr_pages, grant_ref_t *grefs)
 {
 	unsigned long ring_size = nr_pages * XEN_PAGE_SIZE;
+	grant_ref_t gref_head;
 	unsigned int i;
 	int ret;
 
@@ -433,9 +390,24 @@ int xenbus_setup_ring(struct xenbus_device *dev, gfp_t gfp, void **vaddr,
 		goto err;
 	}
 
-	ret = xenbus_grant_ring(dev, *vaddr, nr_pages, grefs);
-	if (ret)
+	ret = gnttab_alloc_grant_references(nr_pages, &gref_head);
+	if (ret) {
+		xenbus_dev_fatal(dev, ret, "granting access to ring page");
 		goto err;
+	}
+
+	for (i = 0; i < nr_pages; i++) {
+		unsigned long gfn;
+
+		if (is_vmalloc_addr(*vaddr))
+			gfn = pfn_to_gfn(vmalloc_to_pfn(vaddr[i]));
+		else
+			gfn = virt_to_gfn(vaddr[i]);
+
+		grefs[i] = gnttab_claim_grant_reference(&gref_head);
+		gnttab_grant_foreign_access_ref(grefs[i], dev->otherend_id,
+						gfn, 0);
+	}
 
 	return 0;
 
diff --git a/include/xen/xenbus.h b/include/xen/xenbus.h
index b533b4adc835..eaa932b99d8a 100644
--- a/include/xen/xenbus.h
+++ b/include/xen/xenbus.h
@@ -224,8 +224,6 @@ int xenbus_watch_pathfmt(struct xenbus_device *dev, struct xenbus_watch *watch,
 			 const char *pathfmt, ...);
 
 int xenbus_switch_state(struct xenbus_device *dev, enum xenbus_state new_state);
-int xenbus_grant_ring(struct xenbus_device *dev, void *vaddr,
-		      unsigned int nr_pages, grant_ref_t *grefs);
 int xenbus_setup_ring(struct xenbus_device *dev, gfp_t gfp, void **vaddr,
 		      unsigned int nr_pages, grant_ref_t *grefs);
 void xenbus_teardown_ring(void **vaddr, unsigned int nr_pages,
-- 
2.34.1


  parent reply	other threads:[~2022-04-20 15:11 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-20 15:09 [PATCH 00/18] xen: simplify frontend side ring setup Juergen Gross
2022-04-20 15:09 ` Juergen Gross
2022-04-20 15:09 ` Juergen Gross
2022-04-20 15:09 ` [PATCH 01/18] xen/blkfront: switch blkfront to use INVALID_GRANT_REF Juergen Gross
2022-04-20 15:09 ` [PATCH 02/18] xen/netfront: switch netfront " Juergen Gross
2022-04-20 15:09 ` [PATCH 03/18] xen/scsifront: remove unused GRANT_INVALID_REF definition Juergen Gross
2022-04-20 15:09 ` [PATCH 04/18] xen/usb: switch xen-hcd to use INVALID_GRANT_REF Juergen Gross
2022-04-20 15:34   ` Greg Kroah-Hartman
2022-04-20 15:09 ` [PATCH 05/18] xen/drm: switch xen_drm_front " Juergen Gross
2022-04-20 15:09   ` Juergen Gross
2022-04-20 15:09 ` [PATCH 06/18] xen/sound: switch xen_snd_front " Juergen Gross
2022-04-20 15:09   ` Juergen Gross
2022-04-20 15:09 ` [PATCH 07/18] xen/dmabuf: switch gntdev-dmabuf " Juergen Gross
2022-04-20 15:09 ` [PATCH 08/18] xen/shbuf: switch xen-front-pgdir-shbuf " Juergen Gross
2022-04-20 15:09 ` [PATCH 09/18] xen/xenbus: add xenbus_setup_ring() service function Juergen Gross
2022-04-20 18:44   ` Boris Ostrovsky
2022-04-21  7:57     ` Juergen Gross
2022-04-20 15:09 ` [PATCH 10/18] xen/blkfront: use xenbus_setup_ring() and xenbus_teardown_ring() Juergen Gross
2022-04-20 15:09 ` [PATCH 11/18] xen/netfront: " Juergen Gross
2022-04-20 15:09 ` [PATCH 12/18] xen/tpmfront: " Juergen Gross
2022-04-20 15:09 ` [PATCH 13/18] xen/drmfront: " Juergen Gross
2022-04-20 15:09   ` Juergen Gross
2022-04-20 15:09 ` [PATCH 14/18] xen/pcifront: " Juergen Gross
2022-04-20 15:09 ` [PATCH 15/18] xen/scsifront: " Juergen Gross
2022-04-20 15:09 ` [PATCH 16/18] xen/usbfront: " Juergen Gross
2022-04-20 15:35   ` Greg Kroah-Hartman
2022-04-20 15:09 ` [PATCH 17/18] xen/sndfront: " Juergen Gross
2022-04-20 15:09   ` Juergen Gross
2022-04-20 15:09 ` Juergen Gross [this message]
2022-04-20 15:22   ` [PATCH 18/18] xen/xenbus: eliminate xenbus_grant_ring() Andrew Cooper
2022-04-20 15:33     ` Juergen Gross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220420150942.31235-19-jgross@suse.com \
    --to=jgross@suse.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.