* [PATCH 04/18] xen/usb: switch xen-hcd to use INVALID_GRANT_REF
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:34 ` Greg Kroah-Hartman
2022-04-20 15:09 ` [PATCH 16/18] xen/usbfront: use xenbus_setup_ring() and xenbus_teardown_ring() Juergen Gross
1 sibling, 1 reply; 5+ messages in thread
From: Juergen Gross @ 2022-04-20 15:09 UTC (permalink / raw)
To: xen-devel, linux-usb, linux-kernel; +Cc: Juergen Gross, Greg Kroah-Hartman
Instead of using a private macro for an invalid grant reference use
the common one.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
drivers/usb/host/xen-hcd.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/usb/host/xen-hcd.c b/drivers/usb/host/xen-hcd.c
index 3e487baf8422..9cbc7c2dab02 100644
--- a/drivers/usb/host/xen-hcd.c
+++ b/drivers/usb/host/xen-hcd.c
@@ -87,8 +87,6 @@ struct xenhcd_info {
bool error;
};
-#define GRANT_INVALID_REF 0
-
#define XENHCD_RING_JIFFIES (HZ/200)
#define XENHCD_SCAN_JIFFIES 1
@@ -1100,17 +1098,17 @@ static void xenhcd_destroy_rings(struct xenhcd_info *info)
unbind_from_irqhandler(info->irq, info);
info->irq = 0;
- if (info->urb_ring_ref != GRANT_INVALID_REF) {
+ 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 = GRANT_INVALID_REF;
+ info->urb_ring_ref = INVALID_GRANT_REF;
}
info->urb_ring.sring = NULL;
- if (info->conn_ring_ref != GRANT_INVALID_REF) {
+ 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 = GRANT_INVALID_REF;
+ info->conn_ring_ref = INVALID_GRANT_REF;
}
info->conn_ring.sring = NULL;
}
@@ -1123,8 +1121,8 @@ static int xenhcd_setup_rings(struct xenbus_device *dev,
grant_ref_t gref;
int err;
- info->urb_ring_ref = GRANT_INVALID_REF;
- info->conn_ring_ref = GRANT_INVALID_REF;
+ 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);
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 16/18] xen/usbfront: use xenbus_setup_ring() and xenbus_teardown_ring()
2022-04-20 15:09 [PATCH 00/18] xen: simplify frontend side ring setup 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:09 ` Juergen Gross
2022-04-20 15:35 ` Greg Kroah-Hartman
1 sibling, 1 reply; 5+ messages in thread
From: Juergen Gross @ 2022-04-20 15:09 UTC (permalink / raw)
To: xen-devel, linux-usb, linux-kernel; +Cc: Juergen Gross, Greg Kroah-Hartman
Simplify xen-hcd's ring creation and removal via xenbus_setup_ring()
and xenbus_teardown_ring().
Signed-off-by: Juergen Gross <jgross@suse.com>
---
drivers/usb/host/xen-hcd.c | 55 +++++++++-----------------------------
1 file changed, 13 insertions(+), 42 deletions(-)
diff --git a/drivers/usb/host/xen-hcd.c b/drivers/usb/host/xen-hcd.c
index 9cbc7c2dab02..0acb68eb37ee 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,47 +1109,27 @@ 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;
+ 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(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;
+ 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;
}
SHARED_RING_INIT(conn_sring);
FRONT_RING_INIT(&info->conn_ring, conn_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;
- goto fail;
- }
- info->conn_ring_ref = gref;
-
err = xenbus_alloc_evtchn(dev, &info->evtchn);
if (err) {
xenbus_dev_fatal(dev, err, "xenbus_alloc_evtchn");
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread