]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
xenbus: add xenbus_device parameter to xenbus_read_driver_state()
authorJuergen Gross <jgross@suse.com>
Wed, 18 Feb 2026 09:52:04 +0000 (10:52 +0100)
committerJuergen Gross <jgross@suse.com>
Wed, 4 Mar 2026 14:31:40 +0000 (15:31 +0100)
In order to prepare checking the xenbus device status in
xenbus_read_driver_state(), add the pointer to struct xenbus_device
as a parameter.

Tested-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: "Martin K. Petersen" <martin.petersen@oracle.com> # SCSI
Acked-by: Jakub Kicinski <kuba@kernel.org>
Acked-by: Bjorn Helgaas <bhelgaas@google.com> # drivers/pci/xen-pcifront.c
Signed-off-by: Juergen Gross <jgross@suse.com>
Message-ID: <20260218095205.453657-2-jgross@suse.com>

drivers/net/xen-netfront.c
drivers/pci/xen-pcifront.c
drivers/scsi/xen-scsifront.c
drivers/xen/xen-pciback/xenbus.c
drivers/xen/xenbus/xenbus_client.c
drivers/xen/xenbus/xenbus_probe.c
drivers/xen/xenbus/xenbus_probe_frontend.c
include/xen/xenbus.h

index 7c2220366623eb547f2e7625a2f4fc3b0d46c0f9..e2da977c9c50a2b8f5993e1eedbbf2338d08e1df 100644 (file)
@@ -1646,7 +1646,7 @@ static int xennet_xdp_set(struct net_device *dev, struct bpf_prog *prog,
 
        /* avoid the race with XDP headroom adjustment */
        wait_event(module_wq,
-                  xenbus_read_driver_state(np->xbdev->otherend) ==
+                  xenbus_read_driver_state(np->xbdev, np->xbdev->otherend) ==
                   XenbusStateReconfigured);
        np->netfront_xdp_enabled = true;
 
@@ -1764,9 +1764,9 @@ static struct net_device *xennet_create_dev(struct xenbus_device *dev)
        do {
                xenbus_switch_state(dev, XenbusStateInitialising);
                err = wait_event_timeout(module_wq,
-                                xenbus_read_driver_state(dev->otherend) !=
+                                xenbus_read_driver_state(dev, dev->otherend) !=
                                 XenbusStateClosed &&
-                                xenbus_read_driver_state(dev->otherend) !=
+                                xenbus_read_driver_state(dev, dev->otherend) !=
                                 XenbusStateUnknown, XENNET_TIMEOUT);
        } while (!err);
 
@@ -2627,31 +2627,31 @@ static void xennet_bus_close(struct xenbus_device *dev)
 {
        int ret;
 
-       if (xenbus_read_driver_state(dev->otherend) == XenbusStateClosed)
+       if (xenbus_read_driver_state(dev, dev->otherend) == XenbusStateClosed)
                return;
        do {
                xenbus_switch_state(dev, XenbusStateClosing);
                ret = wait_event_timeout(module_wq,
-                                  xenbus_read_driver_state(dev->otherend) ==
-                                  XenbusStateClosing ||
-                                  xenbus_read_driver_state(dev->otherend) ==
-                                  XenbusStateClosed ||
-                                  xenbus_read_driver_state(dev->otherend) ==
-                                  XenbusStateUnknown,
-                                  XENNET_TIMEOUT);
+                               xenbus_read_driver_state(dev, dev->otherend) ==
+                               XenbusStateClosing ||
+                               xenbus_read_driver_state(dev, dev->otherend) ==
+                               XenbusStateClosed ||
+                               xenbus_read_driver_state(dev, dev->otherend) ==
+                               XenbusStateUnknown,
+                               XENNET_TIMEOUT);
        } while (!ret);
 
-       if (xenbus_read_driver_state(dev->otherend) == XenbusStateClosed)
+       if (xenbus_read_driver_state(dev, dev->otherend) == XenbusStateClosed)
                return;
 
        do {
                xenbus_switch_state(dev, XenbusStateClosed);
                ret = wait_event_timeout(module_wq,
-                                  xenbus_read_driver_state(dev->otherend) ==
-                                  XenbusStateClosed ||
-                                  xenbus_read_driver_state(dev->otherend) ==
-                                  XenbusStateUnknown,
-                                  XENNET_TIMEOUT);
+                               xenbus_read_driver_state(dev, dev->otherend) ==
+                               XenbusStateClosed ||
+                               xenbus_read_driver_state(dev, dev->otherend) ==
+                               XenbusStateUnknown,
+                               XENNET_TIMEOUT);
        } while (!ret);
 }
 
index 11636634ae512f917fc79dea52e33ed1c4a371d5..cd22bf9840249c350b3aa3e87f37a199978de71c 100644 (file)
@@ -856,7 +856,7 @@ static void pcifront_try_connect(struct pcifront_device *pdev)
        int err;
 
        /* Only connect once */
-       if (xenbus_read_driver_state(pdev->xdev->nodename) !=
+       if (xenbus_read_driver_state(pdev->xdev, pdev->xdev->nodename) !=
            XenbusStateInitialised)
                return;
 
@@ -876,7 +876,7 @@ static int pcifront_try_disconnect(struct pcifront_device *pdev)
        enum xenbus_state prev_state;
 
 
-       prev_state = xenbus_read_driver_state(pdev->xdev->nodename);
+       prev_state = xenbus_read_driver_state(pdev->xdev, pdev->xdev->nodename);
 
        if (prev_state >= XenbusStateClosing)
                goto out;
@@ -895,7 +895,7 @@ out:
 
 static void pcifront_attach_devices(struct pcifront_device *pdev)
 {
-       if (xenbus_read_driver_state(pdev->xdev->nodename) ==
+       if (xenbus_read_driver_state(pdev->xdev, pdev->xdev->nodename) ==
            XenbusStateReconfiguring)
                pcifront_connect(pdev);
 }
@@ -909,7 +909,7 @@ static int pcifront_detach_devices(struct pcifront_device *pdev)
        struct pci_dev *pci_dev;
        char str[64];
 
-       state = xenbus_read_driver_state(pdev->xdev->nodename);
+       state = xenbus_read_driver_state(pdev->xdev, pdev->xdev->nodename);
        if (state == XenbusStateInitialised) {
                dev_dbg(&pdev->xdev->dev, "Handle skipped connect.\n");
                /* We missed Connected and need to initialize. */
index 924025305753334b4f35b322a8a0bfa60dd88ffd..ef74d4da5ab0702c5258ff438f6947506e020662 100644 (file)
@@ -1175,7 +1175,7 @@ static void scsifront_backend_changed(struct xenbus_device *dev,
                        return;
                }
 
-               if (xenbus_read_driver_state(dev->nodename) ==
+               if (xenbus_read_driver_state(dev, dev->nodename) ==
                    XenbusStateInitialised)
                        scsifront_do_lun_hotplug(info, VSCSIFRONT_OP_ADD_LUN);
 
index b11e401f1b1ee92f753b86ad8532f6910aef4da0..4bd1c7a8957e91d6a16e0dbc4471a5c7ad0bed38 100644 (file)
@@ -149,12 +149,12 @@ static int xen_pcibk_attach(struct xen_pcibk_device *pdev)
 
        mutex_lock(&pdev->dev_lock);
        /* Make sure we only do this setup once */
-       if (xenbus_read_driver_state(pdev->xdev->nodename) !=
+       if (xenbus_read_driver_state(pdev->xdev, pdev->xdev->nodename) !=
            XenbusStateInitialised)
                goto out;
 
        /* Wait for frontend to state that it has published the configuration */
-       if (xenbus_read_driver_state(pdev->xdev->otherend) !=
+       if (xenbus_read_driver_state(pdev->xdev, pdev->xdev->otherend) !=
            XenbusStateInitialised)
                goto out;
 
@@ -374,7 +374,7 @@ static int xen_pcibk_reconfigure(struct xen_pcibk_device *pdev,
        dev_dbg(&pdev->xdev->dev, "Reconfiguring device ...\n");
 
        mutex_lock(&pdev->dev_lock);
-       if (xenbus_read_driver_state(pdev->xdev->nodename) != state)
+       if (xenbus_read_driver_state(pdev->xdev, pdev->xdev->nodename) != state)
                goto out;
 
        err = xenbus_scanf(XBT_NIL, pdev->xdev->nodename, "num_devs", "%d",
@@ -572,7 +572,7 @@ static int xen_pcibk_setup_backend(struct xen_pcibk_device *pdev)
        /* It's possible we could get the call to setup twice, so make sure
         * we're not already connected.
         */
-       if (xenbus_read_driver_state(pdev->xdev->nodename) !=
+       if (xenbus_read_driver_state(pdev->xdev, pdev->xdev->nodename) !=
            XenbusStateInitWait)
                goto out;
 
@@ -662,7 +662,7 @@ static void xen_pcibk_be_watch(struct xenbus_watch *watch,
        struct xen_pcibk_device *pdev =
            container_of(watch, struct xen_pcibk_device, be_watch);
 
-       switch (xenbus_read_driver_state(pdev->xdev->nodename)) {
+       switch (xenbus_read_driver_state(pdev->xdev, pdev->xdev->nodename)) {
        case XenbusStateInitWait:
                xen_pcibk_setup_backend(pdev);
                break;
index 2dc874fb550665048ff7dbec54f563bbffd1f7b7..e502435145aebd00dc288a38c408bb8f68fb104e 100644 (file)
@@ -931,12 +931,14 @@ static int xenbus_unmap_ring_hvm(struct xenbus_device *dev, void *vaddr)
 
 /**
  * xenbus_read_driver_state - read state from a store path
+ * @dev: xenbus device pointer
  * @path: path for driver
  *
  * Returns: the state of the driver rooted at the given store path, or
  * XenbusStateUnknown if no state can be read.
  */
-enum xenbus_state xenbus_read_driver_state(const char *path)
+enum xenbus_state xenbus_read_driver_state(const struct xenbus_device *dev,
+                                          const char *path)
 {
        enum xenbus_state result;
        int err = xenbus_gather(XBT_NIL, path, "state", "%d", &result, NULL);
index 9f9011cd7447ca04ed1b778f01dfeecb2450ed60..2eed06ba5d38a097aca49980bdff22fe42aa32ab 100644 (file)
@@ -191,7 +191,7 @@ void xenbus_otherend_changed(struct xenbus_watch *watch,
                return;
        }
 
-       state = xenbus_read_driver_state(dev->otherend);
+       state = xenbus_read_driver_state(dev, dev->otherend);
 
        dev_dbg(&dev->dev, "state is %d, (%s), %s, %s\n",
                state, xenbus_strstate(state), dev->otherend_watch.node, path);
@@ -364,7 +364,7 @@ void xenbus_dev_remove(struct device *_dev)
         * closed.
         */
        if (!drv->allow_rebind ||
-           xenbus_read_driver_state(dev->nodename) == XenbusStateClosing)
+           xenbus_read_driver_state(dev, dev->nodename) == XenbusStateClosing)
                xenbus_switch_state(dev, XenbusStateClosed);
 }
 EXPORT_SYMBOL_GPL(xenbus_dev_remove);
@@ -514,7 +514,7 @@ int xenbus_probe_node(struct xen_bus_type *bus,
        size_t stringlen;
        char *tmpstring;
 
-       enum xenbus_state state = xenbus_read_driver_state(nodename);
+       enum xenbus_state state = xenbus_read_driver_state(NULL, nodename);
 
        if (state != XenbusStateInitialising) {
                /* Device is not new, so ignore it.  This can happen if a
index f04707d1f66774d466fc225f4eabec9d69dff115..ca04609730dfbe62d0893b9f1de9e6b9430f4053 100644 (file)
@@ -253,7 +253,7 @@ static int print_device_status(struct device *dev, void *data)
        } else if (xendev->state < XenbusStateConnected) {
                enum xenbus_state rstate = XenbusStateUnknown;
                if (xendev->otherend)
-                       rstate = xenbus_read_driver_state(xendev->otherend);
+                       rstate = xenbus_read_driver_state(xendev, xendev->otherend);
                pr_warn("Timeout connecting to device: %s (local state %d, remote state %d)\n",
                        xendev->nodename, xendev->state, rstate);
        }
index c94caf852aea1cf91ace42ba4ebd82193d94c845..15319da65b7f4b1aff49131de7add01441950928 100644 (file)
@@ -228,7 +228,8 @@ int xenbus_unmap_ring_vfree(struct xenbus_device *dev, void *vaddr);
 int xenbus_alloc_evtchn(struct xenbus_device *dev, evtchn_port_t *port);
 int xenbus_free_evtchn(struct xenbus_device *dev, evtchn_port_t port);
 
-enum xenbus_state xenbus_read_driver_state(const char *path);
+enum xenbus_state xenbus_read_driver_state(const struct xenbus_device *dev,
+                                          const char *path);
 
 __printf(3, 4)
 void xenbus_dev_error(struct xenbus_device *dev, int err, const char *fmt, ...);