drivers/xen/xenbus/xenbus_probe_frontend.c
Source file repositories/reference/linux-study-clean/drivers/xen/xenbus/xenbus_probe_frontend.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/xen/xenbus/xenbus_probe_frontend.c- Extension
.c- Size
- 13371 bytes
- Lines
- 516
- Domain
- Driver Families
- Bucket
- drivers/xen
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/err.hlinux/string.hlinux/ctype.hlinux/fcntl.hlinux/mm.hlinux/proc_fs.hlinux/notifier.hlinux/kthread.hlinux/mutex.hlinux/io.hlinux/module.hasm/page.hasm/xen/hypervisor.hxen/xenbus.hxen/events.hxen/page.hxen/xen.hxen/platform_pci.hxenbus.h
Detected Declarations
function frontend_bus_idfunction xenbus_probe_frontendfunction xenbus_uevent_frontendfunction backend_changedfunction xenbus_frontend_delayed_restorefunction xenbus_frontend_dev_restorefunction xenbus_frontend_dev_probefunction xenbus_frontend_dev_shutdownfunction frontend_changedfunction read_backend_detailsfunction is_device_connectingfunction essential_device_connectingfunction non_essential_device_connectingfunction exists_essential_connecting_devicefunction exists_non_essential_connecting_devicefunction print_device_statusfunction wait_loopfunction wait_for_devicesfunction __xenbus_register_frontendfunction xenbus_reset_backend_state_changedfunction xenbus_reset_wait_for_backendfunction xenbus_reset_frontendfunction xenbus_check_frontendfunction xenbus_reset_statefunction frontend_probe_and_watchfunction xenbus_probe_frontend_initfunction boot_wait_for_devicesmodule init xenbus_probe_frontend_initexport __xenbus_register_frontend
Annotated Snippet
struct device_driver *drv = data;
struct xenbus_driver *xendrv;
/*
* A device with no driver will never connect. We care only about
* devices which should currently be in the process of connecting.
*/
if (!dev->driver)
return 0;
/* Is this search limited to a particular driver? */
if (drv && (dev->driver != drv))
return 0;
xendrv = to_xenbus_driver(dev->driver);
if (ignore_nonessential && xendrv->not_essential)
return 0;
return (xendev->state < XenbusStateConnected ||
(xendev->state == XenbusStateConnected &&
xendrv->is_ready && !xendrv->is_ready(xendev)));
}
static int essential_device_connecting(struct device *dev, void *data)
{
return is_device_connecting(dev, data, true /* ignore PV[KBB+FB] */);
}
static int non_essential_device_connecting(struct device *dev, void *data)
{
return is_device_connecting(dev, data, false);
}
static int exists_essential_connecting_device(struct device_driver *drv)
{
return bus_for_each_dev(&xenbus_frontend.bus, NULL, drv,
essential_device_connecting);
}
static int exists_non_essential_connecting_device(struct device_driver *drv)
{
return bus_for_each_dev(&xenbus_frontend.bus, NULL, drv,
non_essential_device_connecting);
}
static int print_device_status(struct device *dev, void *data)
{
struct xenbus_device *xendev = to_xenbus_device(dev);
struct device_driver *drv = data;
/* Is this operation limited to a particular driver? */
if (drv && (dev->driver != drv))
return 0;
if (!dev->driver) {
/* Information only: is this too noisy? */
pr_info("Device with no driver: %s\n", xendev->nodename);
} else if (xendev->state < XenbusStateConnected) {
enum xenbus_state rstate = XenbusStateUnknown;
if (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);
}
return 0;
}
/* We only wait for device setup after most initcalls have run. */
static int ready_to_wait_for_devices;
static bool wait_loop(unsigned long start, unsigned int max_delay,
unsigned int *seconds_waited)
{
if (time_after(jiffies, start + (*seconds_waited+5)*HZ)) {
if (!*seconds_waited)
pr_warn("Waiting for devices to initialise: ");
*seconds_waited += 5;
pr_cont("%us...", max_delay - *seconds_waited);
if (*seconds_waited == max_delay) {
pr_cont("\n");
return true;
}
}
schedule_timeout_interruptible(HZ/10);
return false;
}
/*
* On a 5-minute timeout, wait for all devices currently configured. We need
* to do this to guarantee that the filesystems and / or network devices
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/err.h`, `linux/string.h`, `linux/ctype.h`, `linux/fcntl.h`, `linux/mm.h`, `linux/proc_fs.h`, `linux/notifier.h`.
- Detected declarations: `function frontend_bus_id`, `function xenbus_probe_frontend`, `function xenbus_uevent_frontend`, `function backend_changed`, `function xenbus_frontend_delayed_restore`, `function xenbus_frontend_dev_restore`, `function xenbus_frontend_dev_probe`, `function xenbus_frontend_dev_shutdown`, `function frontend_changed`, `function read_backend_details`.
- Atlas domain: Driver Families / drivers/xen.
- Implementation status: pattern implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.