[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c5197d2f-3840-d304-6b09-d334cae81294@linux.intel.com>
Date: Fri, 17 Apr 2020 14:14:00 -0500
From: Pierre-Louis Bossart <pierre-louis.bossart@...ux.intel.com>
To: Jeff Kirsher <jeffrey.t.kirsher@...el.com>, davem@...emloft.net,
gregkh@...uxfoundation.org
Cc: Dave Ertman <david.m.ertman@...el.com>, netdev@...r.kernel.org,
linux-rdma@...r.kernel.org, nhorman@...hat.com,
sassmann@...hat.com, jgg@...pe.ca, parav@...lanox.com,
galpress@...zon.com, selvin.xavier@...adcom.com,
sriharsha.basavapatna@...adcom.com, benve@...co.com,
bharat@...lsio.com, xavier.huwei@...wei.com, yishaih@...lanox.com,
leonro@...lanox.com, mkalderon@...vell.com, aditr@...are.com,
ranjani.sridharan@...ux.intel.com,
Kiran Patil <kiran.patil@...el.com>,
Andrew Bowers <andrewx.bowers@...el.com>
Subject: Re: [net-next 1/9] Implementation of Virtual Bus
On 4/17/20 12:10 PM, Jeff Kirsher wrote:
> From: Dave Ertman <david.m.ertman@...el.com>
>
> This is the initial implementation of the Virtual Bus,
> virtbus_device and virtbus_driver. The virtual bus is
> a software based bus intended to support registering
> virtbus_devices and virtbus_drivers and provide matching
> between them and probing of the registered drivers.
>
> The bus will support probe/remove shutdown and
> suspend/resume callbacks.
>
> Kconfig and Makefile alterations are included
>
> Signed-off-by: Dave Ertman <david.m.ertman@...el.com>
> Signed-off-by: Kiran Patil <kiran.patil@...el.com>
> Tested-by: Andrew Bowers <andrewx.bowers@...el.com>
> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@...el.com>
FWIW we are planning to use this Virtual Bus to support multiple clients
for the Sound Open Firmware driver, instead of using platform devices as
suggested by GregKH.
Minor nit-picks below, please feel free to add my tag for patch 1/9:
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@...ux.intel.com>
> +config VIRTUAL_BUS
> + tristate "Software based Virtual Bus"
> + help
> + Provides a software bus for virtbus_devices to be added to it
> + and virtbus_drivers to be registered on it. It matches driver
> + and device based on id and calls the driver's pobe routine.
typo: probe
[...]
> diff --git a/drivers/bus/virtual_bus.c b/drivers/bus/virtual_bus.c
> new file mode 100644
> index 000000000000..fb14cca40eea
> --- /dev/null
> +++ b/drivers/bus/virtual_bus.c
> @@ -0,0 +1,270 @@
> +// SPDX-License-Identifier: GPL-2.0
did you mean GPL-2.0-only, as done for virtual-bus.h?
> +/*
> + * virtual_bus.c - lightweight software based bus for virtual devices
> + *
> + * Copyright (c) 2019-20 Intel Corporation
I think the recommendation is to use 2019-2020 explicitly.
> + *
> + * Please see Documentation/driver-api/virtual_bus.rst for
> + * more information
> + */
> +
> +#include <linux/string.h>
> +#include <linux/virtual_bus.h>
> +#include <linux/of_irq.h>
is of_irq.h required?
> +#include <linux/module.h>
> +#include <linux/init.h>
> +#include <linux/pm_runtime.h>
> +#include <linux/pm_domain.h>
> +#include <linux/acpi.h>
is there any ACPI dependency?
> +#include <linux/device.h>
alphabetical order for the headers maybe?
[...]
> +int virtbus_register_device(struct virtbus_device *vdev)
> +{
> + int ret;
> +
> + /* Do this first so that all error paths perform a put_device */
> + device_initialize(&vdev->dev);
> +
> + if (!vdev->release) {
> + ret = -EINVAL;
> + dev_err(&vdev->dev, "virtbus_device MUST have a .release callback that does something.\n");
> + goto device_pre_err;
> + }
> +
> + /* All device IDs are automatically allocated */
> + ret = ida_simple_get(&virtbus_dev_ida, 0, 0, GFP_KERNEL);
> + if (ret < 0) {
> + dev_err(&vdev->dev, "get IDA idx for virtbus device failed!\n");
> + goto device_pre_err;
> + }
> +
> +
extra line
> + vdev->dev.bus = &virtual_bus_type;
> + vdev->dev.release = virtbus_release_device;
> +
> + vdev->id = ret;
> + dev_set_name(&vdev->dev, "%s.%d", vdev->name, vdev->id);
> +
> + dev_dbg(&vdev->dev, "Registering virtbus device '%s'\n",
> + dev_name(&vdev->dev));
> +
> + ret = device_add(&vdev->dev);
> + if (ret)
> + goto device_add_err;
> +
> + return 0;
> +
> +device_add_err:
> + ida_simple_remove(&virtbus_dev_ida, vdev->id);
> +
> +device_pre_err:
> + dev_err(&vdev->dev, "Add device to virtbus failed!: %d\n", ret);
> + put_device(&vdev->dev);
> +
> + return ret;
> +}
> +EXPORT_SYMBOL_GPL(virtbus_register_device);
> +
> +/**
> + * virtbus_unregister_device - remove a virtual bus device
> + * @vdev: virtual bus device we are removing
> + */
> +void virtbus_unregister_device(struct virtbus_device *vdev)
> +{
> + device_del(&vdev->dev);
> + put_device(&vdev->dev);
looks like device_unregister(&vdev->dev) ?
> +}
> +EXPORT_SYMBOL_GPL(virtbus_unregister_device);
> +
> +static int virtbus_probe_driver(struct device *_dev)
> +{
> + struct virtbus_driver *vdrv = to_virtbus_drv(_dev->driver);
> + struct virtbus_device *vdev = to_virtbus_dev(_dev);
> + int ret;
> +
> + ret = dev_pm_domain_attach(_dev, true);
> + if (ret) {
> + dev_warn(_dev, "Failed to attatch to PM Domain : %d\n", ret);
typo: attach
[...]
> diff --git a/include/linux/virtual_bus.h b/include/linux/virtual_bus.h
> new file mode 100644
> index 000000000000..4df06178e72f
> --- /dev/null
> +++ b/include/linux/virtual_bus.h
> @@ -0,0 +1,53 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/*
> + * virtual_bus.h - lightweight software bus
> + *
> + * Copyright (c) 2019-20 Intel Corporation
2019-2020?
Powered by blists - more mailing lists