From: Juergen Gross <jgross@suse.com>
To: xen-devel@lists.xenproject.org, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: Juergen Gross <jgross@suse.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: [PATCH v3 19/21] xen/usbfront: use xenbus_setup_ring() and xenbus_teardown_ring()
Date: Thu, 5 May 2022 10:16:38 +0200 [thread overview]
Message-ID: <20220505081640.17425-20-jgross@suse.com> (raw)
In-Reply-To: <20220505081640.17425-1-jgross@suse.com>
Simplify xen-hcd's ring creation and removal via xenbus_setup_ring()
and xenbus_teardown_ring().
Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/usb/host/xen-hcd.c | 61 ++++++++++----------------------------
1 file changed, 15 insertions(+), 46 deletions(-)
diff --git a/drivers/usb/host/xen-hcd.c b/drivers/usb/host/xen-hcd.c
index 9cbc7c2dab02..de1b09158318 100644
--- a/drivers/usb/host/xen-hcd.c
+++ b/drivers/usb/host/xen-hcd.c
@@ -1098,19 +1098,10 @@ static void xenhcd_destroy_rings(struct xenhcd_info *info)
unbind_from_irqhandler(info->irq, info);
info->irq = 0;
- if (info->urb_ring_ref != INVALID_GRANT_REF) {
- gnttab_end_foreign_access(info->urb_ring_ref,
- (unsigned long)info->urb_ring.sring);
- info->urb_ring_ref = INVALID_GRANT_REF;
- }
- info->urb_ring.sring = NULL;
-
- if (info->conn_ring_ref != INVALID_GRANT_REF) {
- gnttab_end_foreign_access(info->conn_ring_ref,
- (unsigned long)info->conn_ring.sring);
- info->conn_ring_ref = INVALID_GRANT_REF;
- }
- info->conn_ring.sring = NULL;
+ xenbus_teardown_ring((void **)&info->urb_ring.sring, 1,
+ &info->urb_ring_ref);
+ xenbus_teardown_ring((void **)&info->conn_ring.sring, 1,
+ &info->conn_ring_ref);
}
static int xenhcd_setup_rings(struct xenbus_device *dev,
@@ -1118,46 +1109,24 @@ static int xenhcd_setup_rings(struct xenbus_device *dev,
{
struct xenusb_urb_sring *urb_sring;
struct xenusb_conn_sring *conn_sring;
- grant_ref_t gref;
int err;
- info->urb_ring_ref = INVALID_GRANT_REF;
info->conn_ring_ref = INVALID_GRANT_REF;
-
- urb_sring = (struct xenusb_urb_sring *)get_zeroed_page(
- GFP_NOIO | __GFP_HIGH);
- if (!urb_sring) {
- xenbus_dev_fatal(dev, -ENOMEM, "allocating urb ring");
- return -ENOMEM;
- }
- SHARED_RING_INIT(urb_sring);
- FRONT_RING_INIT(&info->urb_ring, urb_sring, PAGE_SIZE);
-
- err = xenbus_grant_ring(dev, urb_sring, 1, &gref);
- if (err < 0) {
- free_page((unsigned long)urb_sring);
- info->urb_ring.sring = NULL;
- goto fail;
- }
- info->urb_ring_ref = gref;
-
- conn_sring = (struct xenusb_conn_sring *)get_zeroed_page(
- GFP_NOIO | __GFP_HIGH);
- if (!conn_sring) {
- xenbus_dev_fatal(dev, -ENOMEM, "allocating conn ring");
- err = -ENOMEM;
- goto fail;
+ err = xenbus_setup_ring(dev, GFP_NOIO | __GFP_HIGH,
+ (void **)&urb_sring, 1, &info->urb_ring_ref);
+ if (err) {
+ xenbus_dev_fatal(dev, err, "allocating urb ring");
+ return err;
}
- SHARED_RING_INIT(conn_sring);
- FRONT_RING_INIT(&info->conn_ring, conn_sring, PAGE_SIZE);
+ XEN_FRONT_RING_INIT(&info->urb_ring, urb_sring, PAGE_SIZE);
- err = xenbus_grant_ring(dev, conn_sring, 1, &gref);
- if (err < 0) {
- free_page((unsigned long)conn_sring);
- info->conn_ring.sring = NULL;
+ err = xenbus_setup_ring(dev, GFP_NOIO | __GFP_HIGH,
+ (void **)&conn_sring, 1, &info->conn_ring_ref);
+ if (err) {
+ xenbus_dev_fatal(dev, err, "allocating conn ring");
goto fail;
}
- info->conn_ring_ref = gref;
+ XEN_FRONT_RING_INIT(&info->conn_ring, conn_sring, PAGE_SIZE);
err = xenbus_alloc_evtchn(dev, &info->evtchn);
if (err) {
--
2.35.3
next prev parent reply other threads:[~2022-05-05 8:19 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-05 8:16 [PATCH v3 00/21] xen: simplify frontend side ring setup Juergen Gross
2022-05-05 8:16 ` [PATCH v3 01/21] xen: update grant_table.h Juergen Gross
2022-05-05 8:16 ` [PATCH v3 02/21] xen/grant-table: never put a reserved grant on the free list Juergen Gross
2022-05-05 8:16 ` [PATCH v3 03/21] xen/blkfront: switch blkfront to use INVALID_GRANT_REF Juergen Gross
2022-05-09 8:20 ` Roger Pau Monné
2022-05-05 8:16 ` [PATCH v3 04/21] xen/netfront: switch netfront " Juergen Gross
2022-05-05 8:16 ` [PATCH v3 05/21] xen/scsifront: remove unused GRANT_INVALID_REF definition Juergen Gross
2022-05-05 8:16 ` [PATCH v3 06/21] xen/usb: switch xen-hcd to use INVALID_GRANT_REF Juergen Gross
2022-05-05 8:16 ` [PATCH v3 07/21] xen/drm: switch xen_drm_front " Juergen Gross
2022-05-05 8:16 ` [PATCH v3 08/21] xen/sound: switch xen_snd_front " Juergen Gross
2022-05-05 8:16 ` [PATCH v3 09/21] xen/dmabuf: switch gntdev-dmabuf " Juergen Gross
2022-05-05 8:16 ` [PATCH v3 10/21] xen/shbuf: switch xen-front-pgdir-shbuf " Juergen Gross
2022-05-09 8:47 ` Oleksandr
2022-05-05 8:16 ` [PATCH v3 11/21] xen: update ring.h Juergen Gross
2022-05-05 8:16 ` [PATCH v3 12/21] xen/xenbus: add xenbus_setup_ring() service function Juergen Gross
2022-05-05 8:16 ` [PATCH v3 13/21] xen/blkfront: use xenbus_setup_ring() and xenbus_teardown_ring() Juergen Gross
2022-05-09 8:42 ` Roger Pau Monné
2022-05-05 8:16 ` [PATCH v3 14/21] xen/netfront: " Juergen Gross
2022-05-05 8:16 ` [PATCH v3 15/21] xen/tpmfront: " Juergen Gross
2022-05-06 22:32 ` Jarkko Sakkinen
2022-05-18 9:41 ` Juergen Gross
2022-05-18 14:57 ` Jarkko Sakkinen
2022-05-05 8:16 ` [PATCH v3 16/21] xen/drmfront: " Juergen Gross
2022-05-05 8:16 ` [PATCH v3 17/21] xen/pcifront: " Juergen Gross
2022-05-05 8:16 ` [PATCH v3 18/21] xen/scsifront: " Juergen Gross
2022-05-05 8:16 ` Juergen Gross [this message]
2022-05-05 8:16 ` [PATCH v3 20/21] xen/sndfront: " Juergen Gross
2022-05-05 8:16 ` [PATCH v3 21/21] xen/xenbus: eliminate xenbus_grant_ring() Juergen Gross
2022-05-06 0:12 ` [PATCH v3 00/21] xen: simplify frontend side ring setup Boris Ostrovsky
2022-05-09 13:23 ` Oleksandr
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=20220505081640.17425-20-jgross@suse.com \
--to=jgross@suse.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox