From patchwork Thu May 28 19:43:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ranjani Sridharan X-Patchwork-Id: 1300016 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49Xyn33YwYz9sSn for ; Fri, 29 May 2020 05:43:51 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 1312F872B3; Thu, 28 May 2020 19:43:49 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id S8DY7BJ6ZMxs; Thu, 28 May 2020 19:43:47 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 9372787267; Thu, 28 May 2020 19:43:47 +0000 (UTC) X-Original-To: intel-wired-lan@osuosl.org Delivered-To: intel-wired-lan@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id B628F1BF9BA for ; Thu, 28 May 2020 19:43:44 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id B2E8B872C2 for ; Thu, 28 May 2020 19:43:44 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id igAsQ9Hj1Du5 for ; Thu, 28 May 2020 19:43:43 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 639D587267 for ; Thu, 28 May 2020 19:43:43 +0000 (UTC) IronPort-SDR: ufghsPmqbQOmnabmQC72RApNGM+5mBZ0KaCAX0UMK3L/yhU+KRGDIUhT4M8Lj+mGd9kcwO44AH 7ol0NqYxjDNg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2020 12:43:42 -0700 IronPort-SDR: 52Njt42hm31rAwV0sG16nudDprTheFCxkZyWaKXq5ney1JLu5/9eixTNJFcb3+Uhf5srlUPAEJ mue0If4SBgPQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,446,1583222400"; d="scan'208";a="302585245" Received: from jkoshman-mobl.amr.corp.intel.com (HELO localhost.localdomain) ([10.251.154.131]) by fmsmga002.fm.intel.com with ESMTP; 28 May 2020 12:43:42 -0700 From: Ranjani Sridharan To: intel-wired-lan@osuosl.org Date: Thu, 28 May 2020 12:43:29 -0700 Message-Id: <20200528194342.3495-2-ranjani.sridharan@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200528194342.3495-1-ranjani.sridharan@linux.intel.com> References: <20200528194342.3495-1-ranjani.sridharan@linux.intel.com> Subject: [Intel-wired-lan] [PATCH 01/14] Implementation of Virtual Bus X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pierre-louis.bossart@linux.intel.com, fred.oh@linux.intel.com, shiraz.saleem@intel.com MIME-Version: 1.0 Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Dave Ertman 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. Signed-off-by: Dave Ertman Signed-off-by: Kiran Patil Reviewed-by: Pierre-Louis Bossart Tested-by: Andrew Bowers Signed-off-by: Jeff Kirsher --- Documentation/driver-api/index.rst | 1 + Documentation/driver-api/virtual_bus.rst | 93 ++++++++++ drivers/bus/Kconfig | 10 ++ drivers/bus/Makefile | 2 + drivers/bus/virtual_bus.c | 215 +++++++++++++++++++++++ include/linux/mod_devicetable.h | 8 + include/linux/virtual_bus.h | 62 +++++++ scripts/mod/devicetable-offsets.c | 3 + scripts/mod/file2alias.c | 7 + 9 files changed, 401 insertions(+) create mode 100644 Documentation/driver-api/virtual_bus.rst create mode 100644 drivers/bus/virtual_bus.c create mode 100644 include/linux/virtual_bus.h diff --git a/Documentation/driver-api/index.rst b/Documentation/driver-api/index.rst index d4e78cb3ef4d..4e628a6b8408 100644 --- a/Documentation/driver-api/index.rst +++ b/Documentation/driver-api/index.rst @@ -101,6 +101,7 @@ available subsections can be seen below. sync_file vfio-mediated-device vfio + virtual_bus xilinx/index xillybus zorro diff --git a/Documentation/driver-api/virtual_bus.rst b/Documentation/driver-api/virtual_bus.rst new file mode 100644 index 000000000000..c01fb2f079d5 --- /dev/null +++ b/Documentation/driver-api/virtual_bus.rst @@ -0,0 +1,93 @@ +=============================== +Virtual Bus Devices and Drivers +=============================== + +See for the models for virtbus_device and virtbus_driver. + +This bus is meant to be a minimalist software-based bus used for +connecting devices (that may not physically exist) to be able to +communicate with each other. + + +Memory Allocation Lifespan and Model +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The memory for a virtbus_device or virtbus_driver needs to be +allocated before registering them on the virtual bus. + +The memory for the virtual_device is expected to remain viable until the +device's mandatory .release() callback which is invoked when the device +is unregistered by calling virtbus_unregister_device(). + +Memory associated with a virtbus_driver is expected to remain viable +until the driver's .remove() or .shutdown() callbacks are invoked +during module insertion or removal. + +Device Enumeration +~~~~~~~~~~~~~~~~~~ + +The virtbus device is enumerated when it is attached to the bus. The +device is assigned a unique ID that will be appended to its name +making it unique. If two virtbus_devices both named "foo" are +registered onto the bus, they will have a sub-device names of "foo.x" +and "foo.y" where x and y are unique integers. + +Common Usage and Structure Design +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The virtbus_device and virtbus_driver need to have a common header +file. + +In the common header file outside of the virtual_bus infrastructure, +define struct virtbus_object: + +.. code-block:: c + + struct virtbus_object { + virtbus_device vdev; + struct my_private_struct *my_stuff; + } + +When the virtbus_device vdev is passed to the virtbus_driver's probe +callback, it can then get access to the struct my_stuff. + +An example of the driver encapsulation: + +.. code-block:: c + + struct custom_driver { + struct virtbus_driver virtbus_drv; + const struct custom_driver_ops ops; + } + +An example of this usage would be : + +.. code-block:: c + + struct custom_driver custom_drv = { + .virtbus_drv = { + .driver = { + .name = "sof-ipc-test-virtbus-drv", + }, + .id_table = custom_virtbus_id_table, + .probe = custom_probe, + .remove = custom_remove, + .shutdown = custom_shutdown, + }, + .ops = custom_ops, + }; + +Mandatory Elements +~~~~~~~~~~~~~~~~~~ + +virtbus_device: + +- .release() callback must not be NULL and is expected to perform memory cleanup. +- .match_name must be populated to be able to match with a driver + +virtbus_driver: + +- .probe() callback must not be NULL +- .remove() callback must not be NULL +- .shutdown() callback must not be NULL +- .id_table must not be NULL, used to perform matching diff --git a/drivers/bus/Kconfig b/drivers/bus/Kconfig index 6d4e4497b59b..00553c78510c 100644 --- a/drivers/bus/Kconfig +++ b/drivers/bus/Kconfig @@ -203,4 +203,14 @@ config DA8XX_MSTPRI source "drivers/bus/fsl-mc/Kconfig" source "drivers/bus/mhi/Kconfig" +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 probe routine. + One example is the irdma driver needing to connect with various + PCI LAN drivers to request resources (queues) to be able to perform + its function. + endmenu diff --git a/drivers/bus/Makefile b/drivers/bus/Makefile index 05f32cd694a4..d30828a4768c 100644 --- a/drivers/bus/Makefile +++ b/drivers/bus/Makefile @@ -37,3 +37,5 @@ obj-$(CONFIG_DA8XX_MSTPRI) += da8xx-mstpri.o # MHI obj-$(CONFIG_MHI_BUS) += mhi/ + +obj-$(CONFIG_VIRTUAL_BUS) += virtual_bus.o diff --git a/drivers/bus/virtual_bus.c b/drivers/bus/virtual_bus.c new file mode 100644 index 000000000000..b70023d5b58a --- /dev/null +++ b/drivers/bus/virtual_bus.c @@ -0,0 +1,215 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * virtual_bus.c - lightweight software based bus for virtual devices + * + * Copyright (c) 2019-2020 Intel Corporation + * + * Please see Documentation/driver-api/virtual_bus.rst for + * more information + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +MODULE_LICENSE("GPL v2"); +MODULE_DESCRIPTION("Virtual Bus"); +MODULE_AUTHOR("David Ertman "); +MODULE_AUTHOR("Kiran Patil "); + +static DEFINE_IDA(virtbus_dev_ida); +#define VIRTBUS_INVALID_ID 0xFFFFFFFF + +static const +struct virtbus_dev_id *virtbus_match_id(const struct virtbus_dev_id *id, + struct virtbus_device *vdev) +{ + while (id->name[0]) { + if (!strcmp(vdev->match_name, id->name)) + return id; + id++; + } + return NULL; +} + +static int virtbus_match(struct device *dev, struct device_driver *drv) +{ + struct virtbus_driver *vdrv = to_virtbus_drv(drv); + struct virtbus_device *vdev = to_virtbus_dev(dev); + + return virtbus_match_id(vdrv->id_table, vdev) != NULL; +} + +static int virtbus_uevent(struct device *dev, struct kobj_uevent_env *env) +{ + struct virtbus_device *vdev = to_virtbus_dev(dev); + + if (add_uevent_var(env, "MODALIAS=%s%s", "virtbus:", vdev->match_name)) + return -ENOMEM; + + return 0; +} + +static const struct dev_pm_ops virtbus_dev_pm_ops = { + SET_RUNTIME_PM_OPS(pm_generic_runtime_suspend, + pm_generic_runtime_resume, NULL) +#ifdef CONFIG_PM_SLEEP + SET_SYSTEM_SLEEP_PM_OPS(pm_generic_suspend, pm_generic_resume) +#endif +}; + +struct bus_type virtual_bus_type = { + .name = "virtbus", + .match = virtbus_match, + .uevent = virtbus_uevent, + .pm = &virtbus_dev_pm_ops, +}; + +/** + * virtbus_release_device - Destroy a virtbus device + * @_dev: device to release + */ +static void virtbus_release_device(struct device *_dev) +{ + struct virtbus_device *vdev = to_virtbus_dev(_dev); + u32 ida = vdev->id; + + vdev->release(vdev); + if (ida != VIRTBUS_INVALID_ID) + ida_simple_remove(&virtbus_dev_ida, ida); +} + +/** + * virtbus_register_device - add a virtual bus device + * @vdev: virtual bus device to add + */ +int virtbus_register_device(struct virtbus_device *vdev) +{ + int ret; + + if (WARN_ON(!vdev->release)) + return -EINVAL; + + /* All error paths out of this function after the device_initialize + * must perform a put_device() so that the .release() callback is + * called for an error condition. + */ + device_initialize(&vdev->dev); + + vdev->dev.bus = &virtual_bus_type; + vdev->dev.release = virtbus_release_device; + + /* All device IDs are automatically allocated */ + ret = ida_simple_get(&virtbus_dev_ida, 0, 0, GFP_KERNEL); + + if (ret < 0) { + vdev->id = VIRTBUS_INVALID_ID; + dev_err(&vdev->dev, "get IDA idx for virtbus device failed!\n"); + goto device_add_err; + } + + vdev->id = ret; + + ret = dev_set_name(&vdev->dev, "%s.%d", vdev->match_name, vdev->id); + if (ret) { + dev_err(&vdev->dev, "dev_set_name failed for device\n"); + goto device_add_err; + } + + 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: + dev_err(&vdev->dev, "Add device to virtbus failed!: %d\n", ret); + put_device(&vdev->dev); + + return ret; +} +EXPORT_SYMBOL_GPL(virtbus_register_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 attach to PM Domain : %d\n", ret); + return ret; + } + + ret = vdrv->probe(vdev); + if (ret) { + dev_err(&vdev->dev, "Probe returned error\n"); + dev_pm_domain_detach(_dev, true); + } + + return ret; +} + +static int virtbus_remove_driver(struct device *_dev) +{ + struct virtbus_driver *vdrv = to_virtbus_drv(_dev->driver); + struct virtbus_device *vdev = to_virtbus_dev(_dev); + int ret = 0; + + ret = vdrv->remove(vdev); + dev_pm_domain_detach(_dev, true); + + return ret; +} + +static void virtbus_shutdown_driver(struct device *_dev) +{ + struct virtbus_driver *vdrv = to_virtbus_drv(_dev->driver); + struct virtbus_device *vdev = to_virtbus_dev(_dev); + + vdrv->shutdown(vdev); +} + +/** + * __virtbus_register_driver - register a driver for virtual bus devices + * @vdrv: virtbus_driver structure + * @owner: owning module/driver + */ +int __virtbus_register_driver(struct virtbus_driver *vdrv, struct module *owner) +{ + if (!vdrv->probe || !vdrv->remove || !vdrv->shutdown || !vdrv->id_table) + return -EINVAL; + + vdrv->driver.owner = owner; + vdrv->driver.bus = &virtual_bus_type; + vdrv->driver.probe = virtbus_probe_driver; + vdrv->driver.remove = virtbus_remove_driver; + vdrv->driver.shutdown = virtbus_shutdown_driver; + + return driver_register(&vdrv->driver); +} +EXPORT_SYMBOL_GPL(__virtbus_register_driver); + +static int __init virtual_bus_init(void) +{ + return bus_register(&virtual_bus_type); +} + +static void __exit virtual_bus_exit(void) +{ + bus_unregister(&virtual_bus_type); + ida_destroy(&virtbus_dev_ida); +} + +module_init(virtual_bus_init); +module_exit(virtual_bus_exit); diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index 4c2ddd0941a7..60bcfe75fb94 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h @@ -832,4 +832,12 @@ struct mhi_device_id { kernel_ulong_t driver_data; }; +#define VIRTBUS_NAME_SIZE 20 +#define VIRTBUS_MODULE_PREFIX "virtbus:" + +struct virtbus_dev_id { + char name[VIRTBUS_NAME_SIZE]; + kernel_ulong_t driver_data; +}; + #endif /* LINUX_MOD_DEVICETABLE_H */ diff --git a/include/linux/virtual_bus.h b/include/linux/virtual_bus.h new file mode 100644 index 000000000000..4872fd5a9218 --- /dev/null +++ b/include/linux/virtual_bus.h @@ -0,0 +1,62 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * virtual_bus.h - lightweight software bus + * + * Copyright (c) 2019-2020 Intel Corporation + * + * Please see Documentation/driver-api/virtual_bus.rst for more information + */ + +#ifndef _VIRTUAL_BUS_H_ +#define _VIRTUAL_BUS_H_ + +#include + +struct virtbus_device { + struct device dev; + const char *match_name; + void (*release)(struct virtbus_device *); + u32 id; +}; + +struct virtbus_driver { + int (*probe)(struct virtbus_device *); + int (*remove)(struct virtbus_device *); + void (*shutdown)(struct virtbus_device *); + int (*suspend)(struct virtbus_device *, pm_message_t); + int (*resume)(struct virtbus_device *); + struct device_driver driver; + const struct virtbus_dev_id *id_table; +}; + +static inline +struct virtbus_device *to_virtbus_dev(struct device *dev) +{ + return container_of(dev, struct virtbus_device, dev); +} + +static inline +struct virtbus_driver *to_virtbus_drv(struct device_driver *drv) +{ + return container_of(drv, struct virtbus_driver, driver); +} + +int virtbus_register_device(struct virtbus_device *vdev); + +int +__virtbus_register_driver(struct virtbus_driver *vdrv, struct module *owner); + +#define virtbus_register_driver(vdrv) \ + __virtbus_register_driver(vdrv, THIS_MODULE) + +static inline void virtbus_unregister_device(struct virtbus_device *vdev) +{ + device_unregister(&vdev->dev); +} + +static inline void virtbus_unregister_driver(struct virtbus_driver *vdrv) +{ + driver_unregister(&vdrv->driver); +} + +#endif /* _VIRTUAL_BUS_H_ */ diff --git a/scripts/mod/devicetable-offsets.c b/scripts/mod/devicetable-offsets.c index 010be8ba2116..0c8e0e3a7c84 100644 --- a/scripts/mod/devicetable-offsets.c +++ b/scripts/mod/devicetable-offsets.c @@ -241,5 +241,8 @@ int main(void) DEVID(mhi_device_id); DEVID_FIELD(mhi_device_id, chan); + DEVID(virtbus_dev_id); + DEVID_FIELD(virtbus_dev_id, name); + return 0; } diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 02d5d79da284..7d78fa3fba34 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -1358,7 +1358,13 @@ static int do_mhi_entry(const char *filename, void *symval, char *alias) { DEF_FIELD_ADDR(symval, mhi_device_id, chan); sprintf(alias, MHI_DEVICE_MODALIAS_FMT, *chan); + return 1; +} +static int do_virtbus_entry(const char *filename, void *symval, char *alias) +{ + DEF_FIELD_ADDR(symval, virtbus_dev_id, name); + sprintf(alias, VIRTBUS_MODULE_PREFIX "%s", *name); return 1; } @@ -1436,6 +1442,7 @@ static const struct devtable devtable[] = { {"tee", SIZE_tee_client_device_id, do_tee_entry}, {"wmi", SIZE_wmi_device_id, do_wmi_entry}, {"mhi", SIZE_mhi_device_id, do_mhi_entry}, + {"virtbus", SIZE_virtbus_dev_id, do_virtbus_entry}, }; /* Create MODULE_ALIAS() statements. From patchwork Thu May 28 19:43:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ranjani Sridharan X-Patchwork-Id: 1300024 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49Xyn908N6z9sPF for ; Fri, 29 May 2020 05:43:57 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 9708C89157; Thu, 28 May 2020 19:43:55 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bjLK92eqPOj5; Thu, 28 May 2020 19:43:54 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 8AC9B89216; Thu, 28 May 2020 19:43:53 +0000 (UTC) X-Original-To: intel-wired-lan@osuosl.org Delivered-To: intel-wired-lan@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 9DE6F1BF2B5 for ; Thu, 28 May 2020 19:43:46 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 9A7AB87251 for ; Thu, 28 May 2020 19:43:46 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FSRWXAmE28O7 for ; Thu, 28 May 2020 19:43:43 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 7E0E287281 for ; Thu, 28 May 2020 19:43:43 +0000 (UTC) IronPort-SDR: MX9jk8LmbqscIfvNytBtlP1pNYqXrkAPOf3iBq4lzN3Ti9O2lpFR58hwimk31PHF2UdTmZw7PE hUJXRaud1WnA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2020 12:43:42 -0700 IronPort-SDR: HGmA9506xdqfioGOd8i7EEESzo6C7UDDSKY3EHGcZS1OMC39bP28Mm0X4ZiIBTr+H6N693S4HX kS7E8+ogxq8w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,446,1583222400"; d="scan'208";a="302585247" Received: from jkoshman-mobl.amr.corp.intel.com (HELO localhost.localdomain) ([10.251.154.131]) by fmsmga002.fm.intel.com with ESMTP; 28 May 2020 12:43:42 -0700 From: Ranjani Sridharan To: intel-wired-lan@osuosl.org Date: Thu, 28 May 2020 12:43:30 -0700 Message-Id: <20200528194342.3495-3-ranjani.sridharan@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200528194342.3495-1-ranjani.sridharan@linux.intel.com> References: <20200528194342.3495-1-ranjani.sridharan@linux.intel.com> Subject: [Intel-wired-lan] [PATCH 02/14] virtual-bus: rename struct virtbus_dev_id X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pierre-louis.bossart@linux.intel.com, fred.oh@linux.intel.com, shiraz.saleem@intel.com MIME-Version: 1.0 Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Rename struct virtbus_dev_id to struct virtbus_device_id. This is needed for auto loading of virtbus driver modules to work with MODULE_DEVICE_TABLE(). Signed-off-by: Ranjani Sridharan --- drivers/bus/virtual_bus.c | 7 ++++--- include/linux/mod_devicetable.h | 2 +- include/linux/virtual_bus.h | 2 +- scripts/mod/devicetable-offsets.c | 4 ++-- scripts/mod/file2alias.c | 4 ++-- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/bus/virtual_bus.c b/drivers/bus/virtual_bus.c index b70023d5b58a..90d2ad19b5cb 100644 --- a/drivers/bus/virtual_bus.c +++ b/drivers/bus/virtual_bus.c @@ -27,8 +27,8 @@ static DEFINE_IDA(virtbus_dev_ida); #define VIRTBUS_INVALID_ID 0xFFFFFFFF static const -struct virtbus_dev_id *virtbus_match_id(const struct virtbus_dev_id *id, - struct virtbus_device *vdev) +struct virtbus_device_id *virtbus_match_id(const struct virtbus_device_id *id, + struct virtbus_device *vdev) { while (id->name[0]) { if (!strcmp(vdev->match_name, id->name)) @@ -50,7 +50,8 @@ static int virtbus_uevent(struct device *dev, struct kobj_uevent_env *env) { struct virtbus_device *vdev = to_virtbus_dev(dev); - if (add_uevent_var(env, "MODALIAS=%s%s", "virtbus:", vdev->match_name)) + if (add_uevent_var(env, "MODALIAS=%s%s", VIRTBUS_MODULE_PREFIX, + vdev->match_name)) return -ENOMEM; return 0; diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index 60bcfe75fb94..1378bc165c07 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h @@ -835,7 +835,7 @@ struct mhi_device_id { #define VIRTBUS_NAME_SIZE 20 #define VIRTBUS_MODULE_PREFIX "virtbus:" -struct virtbus_dev_id { +struct virtbus_device_id { char name[VIRTBUS_NAME_SIZE]; kernel_ulong_t driver_data; }; diff --git a/include/linux/virtual_bus.h b/include/linux/virtual_bus.h index 4872fd5a9218..aeac7144b220 100644 --- a/include/linux/virtual_bus.h +++ b/include/linux/virtual_bus.h @@ -26,7 +26,7 @@ struct virtbus_driver { int (*suspend)(struct virtbus_device *, pm_message_t); int (*resume)(struct virtbus_device *); struct device_driver driver; - const struct virtbus_dev_id *id_table; + const struct virtbus_device_id *id_table; }; static inline diff --git a/scripts/mod/devicetable-offsets.c b/scripts/mod/devicetable-offsets.c index 0c8e0e3a7c84..2848926ed223 100644 --- a/scripts/mod/devicetable-offsets.c +++ b/scripts/mod/devicetable-offsets.c @@ -241,8 +241,8 @@ int main(void) DEVID(mhi_device_id); DEVID_FIELD(mhi_device_id, chan); - DEVID(virtbus_dev_id); - DEVID_FIELD(virtbus_dev_id, name); + DEVID(virtbus_device_id); + DEVID_FIELD(virtbus_device_id, name); return 0; } diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 7d78fa3fba34..fd3908ed922d 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -1363,7 +1363,7 @@ static int do_mhi_entry(const char *filename, void *symval, char *alias) static int do_virtbus_entry(const char *filename, void *symval, char *alias) { - DEF_FIELD_ADDR(symval, virtbus_dev_id, name); + DEF_FIELD_ADDR(symval, virtbus_device_id, name); sprintf(alias, VIRTBUS_MODULE_PREFIX "%s", *name); return 1; } @@ -1442,7 +1442,7 @@ static const struct devtable devtable[] = { {"tee", SIZE_tee_client_device_id, do_tee_entry}, {"wmi", SIZE_wmi_device_id, do_wmi_entry}, {"mhi", SIZE_mhi_device_id, do_mhi_entry}, - {"virtbus", SIZE_virtbus_dev_id, do_virtbus_entry}, + {"virtbus", SIZE_virtbus_device_id, do_virtbus_entry}, }; /* Create MODULE_ALIAS() statements. From patchwork Thu May 28 19:43:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ranjani Sridharan X-Patchwork-Id: 1300018 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49Xyn61kBXz9sPF for ; Fri, 29 May 2020 05:43:54 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id EE36B2154B; Thu, 28 May 2020 19:43:51 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3RqZ4Fj8L8TY; Thu, 28 May 2020 19:43:48 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 51CDB21537; Thu, 28 May 2020 19:43:46 +0000 (UTC) X-Original-To: intel-wired-lan@osuosl.org Delivered-To: intel-wired-lan@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 191F51BF9B9 for ; Thu, 28 May 2020 19:43:44 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 15253872C7 for ; Thu, 28 May 2020 19:43:44 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id djJMIiRUNboi for ; Thu, 28 May 2020 19:43:43 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 95F258729F for ; Thu, 28 May 2020 19:43:43 +0000 (UTC) IronPort-SDR: lGkjGkNaqtjsxrcr0UdcViJsOhXCwuReGrSEh6Uxt1lndbHIqj9ZBw4+ryKuRxHbUuLesxV/hr JMyHab94Imcw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2020 12:43:43 -0700 IronPort-SDR: t4hXKX0UYawVXQxRho2UbpjExyGzs3/3jJrKU1c2D1fsu2EtQsivj0QCXJwSYptOMCL6mq6s1a tG3/s+Isakuw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,446,1583222400"; d="scan'208";a="302585250" Received: from jkoshman-mobl.amr.corp.intel.com (HELO localhost.localdomain) ([10.251.154.131]) by fmsmga002.fm.intel.com with ESMTP; 28 May 2020 12:43:43 -0700 From: Ranjani Sridharan To: intel-wired-lan@osuosl.org Date: Thu, 28 May 2020 12:43:31 -0700 Message-Id: <20200528194342.3495-4-ranjani.sridharan@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200528194342.3495-1-ranjani.sridharan@linux.intel.com> References: <20200528194342.3495-1-ranjani.sridharan@linux.intel.com> Subject: [Intel-wired-lan] [PATCH 03/14] virtual-bus: reword Kconfig help X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pierre-louis.bossart@linux.intel.com, fred.oh@linux.intel.com, shiraz.saleem@intel.com MIME-Version: 1.0 Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Signed-off-by: Ranjani Sridharan --- drivers/bus/Kconfig | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/bus/Kconfig b/drivers/bus/Kconfig index 00553c78510c..b3f59bdf5c51 100644 --- a/drivers/bus/Kconfig +++ b/drivers/bus/Kconfig @@ -206,11 +206,12 @@ source "drivers/bus/mhi/Kconfig" 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 probe routine. - One example is the irdma driver needing to connect with various - PCI LAN drivers to request resources (queues) to be able to perform - its function. + Provides a software bus for virtual bus drivers to register and + attach virtual bus devices. It matches driver and device based on a + unique string and calls the driver's probe routine. One example is + SOF (Sound Open Firmware) clients such as audio cards or test + tools needing to connect with the SOF core. Another example is + the irdma driver needing to connect with various PCI LAN drivers + to request resources (queues) to be able to perform its function. endmenu From patchwork Thu May 28 19:43:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ranjani Sridharan X-Patchwork-Id: 1300019 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49Xyn62cPxz9sSF for ; Fri, 29 May 2020 05:43:54 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 23BA525BDA; Thu, 28 May 2020 19:43:52 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 36HHeNfxHH5B; Thu, 28 May 2020 19:43:49 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 2BF30221CC; Thu, 28 May 2020 19:43:48 +0000 (UTC) X-Original-To: intel-wired-lan@osuosl.org Delivered-To: intel-wired-lan@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 1E67B1BF2B5 for ; Thu, 28 May 2020 19:43:45 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 1B4CE8729F for ; Thu, 28 May 2020 19:43:45 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pE4WEofRe35w for ; Thu, 28 May 2020 19:43:43 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by fraxinus.osuosl.org (Postfix) with ESMTPS id B1D14872B3 for ; Thu, 28 May 2020 19:43:43 +0000 (UTC) IronPort-SDR: R5G0NdmYnGNL0mIfNwFS9IGN8DWD6NMC34czhCy82jd57XsUpxYX3Yc0JFcOwxv5AVXVPYXSTJ nF6MdAq8B98g== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2020 12:43:43 -0700 IronPort-SDR: brYVMV4HAghue9UzPrxxGFQ3qL4sr4yMKWy7sTm8k+Zmo30Z+I8FaaivRqZqgs6Iwc1SYIJkUg v+Vld5ZjwfOg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,446,1583222400"; d="scan'208";a="302585253" Received: from jkoshman-mobl.amr.corp.intel.com (HELO localhost.localdomain) ([10.251.154.131]) by fmsmga002.fm.intel.com with ESMTP; 28 May 2020 12:43:43 -0700 From: Ranjani Sridharan To: intel-wired-lan@osuosl.org Date: Thu, 28 May 2020 12:43:32 -0700 Message-Id: <20200528194342.3495-5-ranjani.sridharan@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200528194342.3495-1-ranjani.sridharan@linux.intel.com> References: <20200528194342.3495-1-ranjani.sridharan@linux.intel.com> Subject: [Intel-wired-lan] [PATCH 04/14] virtual-bus: add comment for virtbus entry X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pierre-louis.bossart@linux.intel.com, fred.oh@linux.intel.com, shiraz.saleem@intel.com MIME-Version: 1.0 Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Signed-off-by: Ranjani Sridharan --- scripts/mod/file2alias.c | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index fd3908ed922d..929fc152e404 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -1361,6 +1361,7 @@ static int do_mhi_entry(const char *filename, void *symval, char *alias) return 1; } +/* Looks like: virtbus:S */ static int do_virtbus_entry(const char *filename, void *symval, char *alias) { DEF_FIELD_ADDR(symval, virtbus_device_id, name); From patchwork Thu May 28 19:43:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ranjani Sridharan X-Patchwork-Id: 1300013 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49Xyn263XDz9sSm for ; Fri, 29 May 2020 05:43:50 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id BEC5589188; Thu, 28 May 2020 19:43:48 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZdRdJT1CQYBO; Thu, 28 May 2020 19:43:46 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id D3F0889157; Thu, 28 May 2020 19:43:46 +0000 (UTC) X-Original-To: intel-wired-lan@osuosl.org Delivered-To: intel-wired-lan@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 65C181BF2B5 for ; Thu, 28 May 2020 19:43:44 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 5EE5E872CC for ; Thu, 28 May 2020 19:43:44 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2ghW3Iz9YI0f for ; Thu, 28 May 2020 19:43:44 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by fraxinus.osuosl.org (Postfix) with ESMTPS id C9926872B5 for ; Thu, 28 May 2020 19:43:43 +0000 (UTC) IronPort-SDR: S90TQx77SBneUTD7JNUHPUP2weRZ1lRWtBOS1IXtbbDw/dvnwmn6vl8RUOrfEsQiq4zxxIhBrj pM++dbRmXFng== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2020 12:43:43 -0700 IronPort-SDR: LRASpHDjCglNb4PxrFn+ZZWyikM82SL8Jg/0F8zkybgNPvh1s4oCGGX0vg3NymsLXYDSzyYWgR GYVzOx7AzJ2w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,446,1583222400"; d="scan'208";a="302585256" Received: from jkoshman-mobl.amr.corp.intel.com (HELO localhost.localdomain) ([10.251.154.131]) by fmsmga002.fm.intel.com with ESMTP; 28 May 2020 12:43:43 -0700 From: Ranjani Sridharan To: intel-wired-lan@osuosl.org Date: Thu, 28 May 2020 12:43:33 -0700 Message-Id: <20200528194342.3495-6-ranjani.sridharan@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200528194342.3495-1-ranjani.sridharan@linux.intel.com> References: <20200528194342.3495-1-ranjani.sridharan@linux.intel.com> Subject: [Intel-wired-lan] [PATCH 05/14] virtual-bus: move MODULE macros to the end of the file X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pierre-louis.bossart@linux.intel.com, fred.oh@linux.intel.com, shiraz.saleem@intel.com MIME-Version: 1.0 Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Signed-off-by: Ranjani Sridharan --- drivers/bus/virtual_bus.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/bus/virtual_bus.c b/drivers/bus/virtual_bus.c index 90d2ad19b5cb..25f85672b70d 100644 --- a/drivers/bus/virtual_bus.c +++ b/drivers/bus/virtual_bus.c @@ -18,11 +18,6 @@ #include #include -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("Virtual Bus"); -MODULE_AUTHOR("David Ertman "); -MODULE_AUTHOR("Kiran Patil "); - static DEFINE_IDA(virtbus_dev_ida); #define VIRTBUS_INVALID_ID 0xFFFFFFFF @@ -214,3 +209,8 @@ static void __exit virtual_bus_exit(void) module_init(virtual_bus_init); module_exit(virtual_bus_exit); + +MODULE_LICENSE("GPL v2"); +MODULE_DESCRIPTION("Virtual Bus"); +MODULE_AUTHOR("David Ertman "); +MODULE_AUTHOR("Kiran Patil "); From patchwork Thu May 28 19:43:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ranjani Sridharan X-Patchwork-Id: 1300015 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49Xyn16WXNz9sSF for ; Fri, 29 May 2020 05:43:49 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 50D4D88331; Thu, 28 May 2020 19:43:48 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id niL5tEmOsa3E; Thu, 28 May 2020 19:43:47 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 3E1F78819D; Thu, 28 May 2020 19:43:47 +0000 (UTC) X-Original-To: intel-wired-lan@osuosl.org Delivered-To: intel-wired-lan@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 75A3C1BF9B9 for ; Thu, 28 May 2020 19:43:44 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 71383872B5 for ; Thu, 28 May 2020 19:43:44 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id e1teCrA5sIYa for ; Thu, 28 May 2020 19:43:44 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by fraxinus.osuosl.org (Postfix) with ESMTPS id E2FE3872C2 for ; Thu, 28 May 2020 19:43:43 +0000 (UTC) IronPort-SDR: ZqQoRHI/hBeQJc5NBDNpPPRxS6zm/xl52vNlT+x7Ggy8O6gMvCvZ1SXTt+qx+ToUPm9vpPIRUO BgZvgTWj6eiQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2020 12:43:43 -0700 IronPort-SDR: 11OYA1Gp2eCZzV076lUaCNov8fR83pIDH1NP+lYHcaLzJED+wiXuEocDNIjFySAyp6d7S5nkSP 3x+iRaOnHvkQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,446,1583222400"; d="scan'208";a="302585259" Received: from jkoshman-mobl.amr.corp.intel.com (HELO localhost.localdomain) ([10.251.154.131]) by fmsmga002.fm.intel.com with ESMTP; 28 May 2020 12:43:43 -0700 From: Ranjani Sridharan To: intel-wired-lan@osuosl.org Date: Thu, 28 May 2020 12:43:34 -0700 Message-Id: <20200528194342.3495-7-ranjani.sridharan@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200528194342.3495-1-ranjani.sridharan@linux.intel.com> References: <20200528194342.3495-1-ranjani.sridharan@linux.intel.com> Subject: [Intel-wired-lan] [PATCH 06/14] virtual-bus: remove INVALID_ID and fix error path X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pierre-louis.bossart@linux.intel.com, fred.oh@linux.intel.com, shiraz.saleem@intel.com MIME-Version: 1.0 Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" INVALID_ID is not really needed, so remove it and fix error path to remove auto ID in case of errors. Signed-off-by: Ranjani Sridharan --- drivers/bus/virtual_bus.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/bus/virtual_bus.c b/drivers/bus/virtual_bus.c index 25f85672b70d..7518c6c8eaea 100644 --- a/drivers/bus/virtual_bus.c +++ b/drivers/bus/virtual_bus.c @@ -19,7 +19,6 @@ #include static DEFINE_IDA(virtbus_dev_ida); -#define VIRTBUS_INVALID_ID 0xFFFFFFFF static const struct virtbus_device_id *virtbus_match_id(const struct virtbus_device_id *id, @@ -77,8 +76,7 @@ static void virtbus_release_device(struct device *_dev) u32 ida = vdev->id; vdev->release(vdev); - if (ida != VIRTBUS_INVALID_ID) - ida_simple_remove(&virtbus_dev_ida, ida); + ida_simple_remove(&virtbus_dev_ida, ida); } /** @@ -103,9 +101,7 @@ int virtbus_register_device(struct virtbus_device *vdev) /* All device IDs are automatically allocated */ ret = ida_simple_get(&virtbus_dev_ida, 0, 0, GFP_KERNEL); - if (ret < 0) { - vdev->id = VIRTBUS_INVALID_ID; dev_err(&vdev->dev, "get IDA idx for virtbus device failed!\n"); goto device_add_err; } @@ -122,13 +118,12 @@ int virtbus_register_device(struct virtbus_device *vdev) dev_name(&vdev->dev)); ret = device_add(&vdev->dev); - if (ret) - goto device_add_err; + if (!ret) + return ret; - return 0; + dev_err(&vdev->dev, "Add device to virtbus failed!: %d\n", ret); device_add_err: - dev_err(&vdev->dev, "Add device to virtbus failed!: %d\n", ret); put_device(&vdev->dev); return ret; From patchwork Thu May 28 19:43:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ranjani Sridharan X-Patchwork-Id: 1300020 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49Xyn72fSCz9sPF for ; Fri, 29 May 2020 05:43:55 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id B676C872CE; Thu, 28 May 2020 19:43:53 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AZm1Jvj1mcZ9; Thu, 28 May 2020 19:43:52 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id DCBDD872B5; Thu, 28 May 2020 19:43:52 +0000 (UTC) X-Original-To: intel-wired-lan@osuosl.org Delivered-To: intel-wired-lan@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id EA9B01BF9BA for ; Thu, 28 May 2020 19:43:45 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id E75A587267 for ; Thu, 28 May 2020 19:43:45 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sE60rVFhMBen for ; Thu, 28 May 2020 19:43:44 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 0A2BE87251 for ; Thu, 28 May 2020 19:43:44 +0000 (UTC) IronPort-SDR: F2ebWrDjycccZ2aIKISapn/i3s6Z4USB+W/yFCf1BR/m2XdD3u1WXSRi6/EXglKehYauPmXOzx 3FmRrXt3EwhA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2020 12:43:43 -0700 IronPort-SDR: oz+McxBBkbs/d5JV2pEGjSJRrlHkoUtCw220vtc+VZMbPz3vNwqIDb7sTQtHa1tF8OpCKV4Eeu Io5cJ5x7vmSw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,446,1583222400"; d="scan'208";a="302585263" Received: from jkoshman-mobl.amr.corp.intel.com (HELO localhost.localdomain) ([10.251.154.131]) by fmsmga002.fm.intel.com with ESMTP; 28 May 2020 12:43:43 -0700 From: Ranjani Sridharan To: intel-wired-lan@osuosl.org Date: Thu, 28 May 2020 12:43:35 -0700 Message-Id: <20200528194342.3495-8-ranjani.sridharan@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200528194342.3495-1-ranjani.sridharan@linux.intel.com> References: <20200528194342.3495-1-ranjani.sridharan@linux.intel.com> Subject: [Intel-wired-lan] [PATCH 07/14] virtual-bus: remove #ifdef for PM ops X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pierre-louis.bossart@linux.intel.com, fred.oh@linux.intel.com, shiraz.saleem@intel.com MIME-Version: 1.0 Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" not really needed. Signed-off-by: Ranjani Sridharan --- drivers/bus/virtual_bus.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/bus/virtual_bus.c b/drivers/bus/virtual_bus.c index 7518c6c8eaea..519b578a347f 100644 --- a/drivers/bus/virtual_bus.c +++ b/drivers/bus/virtual_bus.c @@ -54,9 +54,7 @@ static int virtbus_uevent(struct device *dev, struct kobj_uevent_env *env) static const struct dev_pm_ops virtbus_dev_pm_ops = { SET_RUNTIME_PM_OPS(pm_generic_runtime_suspend, pm_generic_runtime_resume, NULL) -#ifdef CONFIG_PM_SLEEP SET_SYSTEM_SLEEP_PM_OPS(pm_generic_suspend, pm_generic_resume) -#endif }; struct bus_type virtual_bus_type = { From patchwork Thu May 28 19:43:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ranjani Sridharan X-Patchwork-Id: 1300017 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49Xyn35vBkz9sSp for ; Fri, 29 May 2020 05:43:51 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id D20EE882F3; Thu, 28 May 2020 19:43:49 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id s2AJijOW+R54; Thu, 28 May 2020 19:43:48 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id DFDE2882FD; Thu, 28 May 2020 19:43:47 +0000 (UTC) X-Original-To: intel-wired-lan@osuosl.org Delivered-To: intel-wired-lan@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id D453C1BF2B5 for ; Thu, 28 May 2020 19:43:44 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id D0EC587267 for ; Thu, 28 May 2020 19:43:44 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aL9No-fNKwG1 for ; Thu, 28 May 2020 19:43:44 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 2343E8729F for ; Thu, 28 May 2020 19:43:44 +0000 (UTC) IronPort-SDR: UQRlzs1UYUkfkuzrkkp9q1ipj868N4Ih2AgS0Wn6NDOpR5YfeyXa5dsgVXPkSMC0A3KgukQA6g QR3idhHZb/lw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2020 12:43:43 -0700 IronPort-SDR: STMmSJ0N59FrAj3ddtMUXAbrc5w3lYlWr0glsoqgzz24ZRE9j43+7Mo2MkADX3aJmz55w6gOcZ 06n8hk0k8inQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,446,1583222400"; d="scan'208";a="302585267" Received: from jkoshman-mobl.amr.corp.intel.com (HELO localhost.localdomain) ([10.251.154.131]) by fmsmga002.fm.intel.com with ESMTP; 28 May 2020 12:43:43 -0700 From: Ranjani Sridharan To: intel-wired-lan@osuosl.org Date: Thu, 28 May 2020 12:43:36 -0700 Message-Id: <20200528194342.3495-9-ranjani.sridharan@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200528194342.3495-1-ranjani.sridharan@linux.intel.com> References: <20200528194342.3495-1-ranjani.sridharan@linux.intel.com> Subject: [Intel-wired-lan] [PATCH 08/14] virtual-bus: remove superfluous assignment X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pierre-louis.bossart@linux.intel.com, fred.oh@linux.intel.com, shiraz.saleem@intel.com MIME-Version: 1.0 Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Signed-off-by: Ranjani Sridharan --- drivers/bus/virtual_bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/bus/virtual_bus.c b/drivers/bus/virtual_bus.c index 519b578a347f..2b0007932517 100644 --- a/drivers/bus/virtual_bus.c +++ b/drivers/bus/virtual_bus.c @@ -153,7 +153,7 @@ static int virtbus_remove_driver(struct device *_dev) { struct virtbus_driver *vdrv = to_virtbus_drv(_dev->driver); struct virtbus_device *vdev = to_virtbus_dev(_dev); - int ret = 0; + int ret; ret = vdrv->remove(vdev); dev_pm_domain_detach(_dev, true); From patchwork Thu May 28 19:43:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ranjani Sridharan X-Patchwork-Id: 1300023 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49Xyn81D5mz9sSm for ; Fri, 29 May 2020 05:43:56 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id B27D2882FD; Thu, 28 May 2020 19:43:54 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8Fkv87sF6+-R; Thu, 28 May 2020 19:43:53 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 3CFE4882EC; Thu, 28 May 2020 19:43:53 +0000 (UTC) X-Original-To: intel-wired-lan@osuosl.org Delivered-To: intel-wired-lan@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 2B5091BF2B5 for ; Thu, 28 May 2020 19:43:46 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 281FD87251 for ; Thu, 28 May 2020 19:43:46 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PDE32yEqHn0q for ; Thu, 28 May 2020 19:43:44 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 3E136872C7 for ; Thu, 28 May 2020 19:43:44 +0000 (UTC) IronPort-SDR: BnbL2adnXnVKaO0uinuzoe3t5z+JbYbMBWa53fAr3+KZsxE2Lb9sXZEImgfUSD2YpWDUzZqNur cGSQ2yA42aRQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2020 12:43:43 -0700 IronPort-SDR: ZNyMaovCLhCz3VyKuRxeGugjm9iIVJApClU0/W7Lz7yTZvWrsHROSqqHWuQgmFW/KeQKjT5nfF 2aQxhPTYnFNw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,446,1583222400"; d="scan'208";a="302585271" Received: from jkoshman-mobl.amr.corp.intel.com (HELO localhost.localdomain) ([10.251.154.131]) by fmsmga002.fm.intel.com with ESMTP; 28 May 2020 12:43:43 -0700 From: Ranjani Sridharan To: intel-wired-lan@osuosl.org Date: Thu, 28 May 2020 12:43:37 -0700 Message-Id: <20200528194342.3495-10-ranjani.sridharan@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200528194342.3495-1-ranjani.sridharan@linux.intel.com> References: <20200528194342.3495-1-ranjani.sridharan@linux.intel.com> Subject: [Intel-wired-lan] [PATCH 09/14] virtual-bus: fix return value for match function X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pierre-louis.bossart@linux.intel.com, fred.oh@linux.intel.com, shiraz.saleem@intel.com MIME-Version: 1.0 Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Signed-off-by: Ranjani Sridharan --- drivers/bus/virtual_bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/bus/virtual_bus.c b/drivers/bus/virtual_bus.c index 2b0007932517..27db2d3463a3 100644 --- a/drivers/bus/virtual_bus.c +++ b/drivers/bus/virtual_bus.c @@ -37,7 +37,7 @@ static int virtbus_match(struct device *dev, struct device_driver *drv) struct virtbus_driver *vdrv = to_virtbus_drv(drv); struct virtbus_device *vdev = to_virtbus_dev(dev); - return virtbus_match_id(vdrv->id_table, vdev) != NULL; + return !!virtbus_match_id(vdrv->id_table, vdev); } static int virtbus_uevent(struct device *dev, struct kobj_uevent_env *env) From patchwork Thu May 28 19:43:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ranjani Sridharan X-Patchwork-Id: 1300026 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49Xyn935dFz9sSp for ; Fri, 29 May 2020 05:43:57 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id CC96D872D0; Thu, 28 May 2020 19:43:55 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SNNy8ZHvehGE; Thu, 28 May 2020 19:43:54 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 9606F872C2; Thu, 28 May 2020 19:43:54 +0000 (UTC) X-Original-To: intel-wired-lan@osuosl.org Delivered-To: intel-wired-lan@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id D29E71BF2B5 for ; Thu, 28 May 2020 19:43:46 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id CE35E87251 for ; Thu, 28 May 2020 19:43:46 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id M2rlmC_BzCsq for ; Thu, 28 May 2020 19:43:44 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 5F777872CE for ; Thu, 28 May 2020 19:43:44 +0000 (UTC) IronPort-SDR: U+3hkFX81t+WFw6xBGSkzzf169o1JoWWuw+3BxO32Jv+kq/GvrHLHo9cnobYcXuSABNA4E2QTp p1RT+cDl9gYQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2020 12:43:44 -0700 IronPort-SDR: o8euWbqxW8sJRpxYFqn2l6D9OwMIX2BrrXsPfeLHmi8LYu0yEZVGpcf3R0gce1iJfhwZgUrX7z YgI+kLLxX5YQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,446,1583222400"; d="scan'208";a="302585275" Received: from jkoshman-mobl.amr.corp.intel.com (HELO localhost.localdomain) ([10.251.154.131]) by fmsmga002.fm.intel.com with ESMTP; 28 May 2020 12:43:43 -0700 From: Ranjani Sridharan To: intel-wired-lan@osuosl.org Date: Thu, 28 May 2020 12:43:38 -0700 Message-Id: <20200528194342.3495-11-ranjani.sridharan@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200528194342.3495-1-ranjani.sridharan@linux.intel.com> References: <20200528194342.3495-1-ranjani.sridharan@linux.intel.com> Subject: [Intel-wired-lan] [PATCH 10/14] virtual-bus: reorder header includes X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pierre-louis.bossart@linux.intel.com, fred.oh@linux.intel.com, shiraz.saleem@intel.com MIME-Version: 1.0 Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Signed-off-by: Ranjani Sridharan --- drivers/bus/virtual_bus.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/bus/virtual_bus.c b/drivers/bus/virtual_bus.c index 27db2d3463a3..613445640cd0 100644 --- a/drivers/bus/virtual_bus.c +++ b/drivers/bus/virtual_bus.c @@ -8,15 +8,15 @@ * more information */ -#include -#include -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include +#include +#include static DEFINE_IDA(virtbus_dev_ida); From patchwork Thu May 28 19:43:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ranjani Sridharan X-Patchwork-Id: 1300022 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49Xyn81fCPz9sSn for ; Fri, 29 May 2020 05:43:56 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id B72C0203E2; Thu, 28 May 2020 19:43:54 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2nGKc3H+Hl95; Thu, 28 May 2020 19:43:51 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id E485225AE2; Thu, 28 May 2020 19:43:48 +0000 (UTC) X-Original-To: intel-wired-lan@osuosl.org Delivered-To: intel-wired-lan@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 2EE5C1BF9B9 for ; Thu, 28 May 2020 19:43:45 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 28BAF881BF for ; Thu, 28 May 2020 19:43:45 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id P1OLOYFb0-kx for ; Thu, 28 May 2020 19:43:44 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by whitealder.osuosl.org (Postfix) with ESMTPS id 747418803D for ; Thu, 28 May 2020 19:43:44 +0000 (UTC) IronPort-SDR: l3GJWPpeVnJUzP7t0sJGzTpPdIJ382RlDBtSTVp7qbEGT1jNz8GNRmd3KQjyYnKzZXd9X3BSvn P7nWcNB53f4w== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2020 12:43:44 -0700 IronPort-SDR: DskAaoyAlc/60i7OAH1fwkDS8fYCFx3tema4r/H0/frswNXtl9mhg4qdqZuaAhmqcSDS/TCvuW PDi43AUOS6pQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,446,1583222400"; d="scan'208";a="302585278" Received: from jkoshman-mobl.amr.corp.intel.com (HELO localhost.localdomain) ([10.251.154.131]) by fmsmga002.fm.intel.com with ESMTP; 28 May 2020 12:43:44 -0700 From: Ranjani Sridharan To: intel-wired-lan@osuosl.org Date: Thu, 28 May 2020 12:43:39 -0700 Message-Id: <20200528194342.3495-12-ranjani.sridharan@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200528194342.3495-1-ranjani.sridharan@linux.intel.com> References: <20200528194342.3495-1-ranjani.sridharan@linux.intel.com> Subject: [Intel-wired-lan] [PATCH 11/14] virtual-bus: remove filename from header X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pierre-louis.bossart@linux.intel.com, fred.oh@linux.intel.com, shiraz.saleem@intel.com MIME-Version: 1.0 Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Signed-off-by: Ranjani Sridharan --- drivers/bus/virtual_bus.c | 2 +- include/linux/virtual_bus.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/bus/virtual_bus.c b/drivers/bus/virtual_bus.c index 613445640cd0..64d7e588fe7d 100644 --- a/drivers/bus/virtual_bus.c +++ b/drivers/bus/virtual_bus.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * virtual_bus.c - lightweight software based bus for virtual devices + * Lightweight software based bus for virtual devices * * Copyright (c) 2019-2020 Intel Corporation * diff --git a/include/linux/virtual_bus.h b/include/linux/virtual_bus.h index aeac7144b220..a34e060ded56 100644 --- a/include/linux/virtual_bus.h +++ b/include/linux/virtual_bus.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * virtual_bus.h - lightweight software bus + * Lightweight software bus * * Copyright (c) 2019-2020 Intel Corporation * From patchwork Thu May 28 19:43:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ranjani Sridharan X-Patchwork-Id: 1300027 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49XynD6nnNz9sPF for ; Fri, 29 May 2020 05:44:00 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 7656821537; Thu, 28 May 2020 19:43:59 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DP69xAD3JSqa; Thu, 28 May 2020 19:43:52 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 807FE2152F; Thu, 28 May 2020 19:43:51 +0000 (UTC) X-Original-To: intel-wired-lan@osuosl.org Delivered-To: intel-wired-lan@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id A8E3A1BF2B5 for ; Thu, 28 May 2020 19:43:45 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id A5B878729F for ; Thu, 28 May 2020 19:43:45 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 22M1v6LfvbTt for ; Thu, 28 May 2020 19:43:44 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 80F9C872B5 for ; Thu, 28 May 2020 19:43:44 +0000 (UTC) IronPort-SDR: 4LGAxHnbzF+jmG4Bk8uz/u0V34uWOthAY2Y0eMJIbw43xVRgSHZnFNNDImy7UMGdteiMBuYKSZ g/6VTf2j8WQA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2020 12:43:44 -0700 IronPort-SDR: GAxuLOdgYsa3p0Y5Ca3Olx7xrFFrNFJicykN2cVsiedGz66EJdB/GrCUkRDOJX3GNQhh2vfvnC B4lP/vBBKgpQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,446,1583222400"; d="scan'208";a="302585282" Received: from jkoshman-mobl.amr.corp.intel.com (HELO localhost.localdomain) ([10.251.154.131]) by fmsmga002.fm.intel.com with ESMTP; 28 May 2020 12:43:44 -0700 From: Ranjani Sridharan To: intel-wired-lan@osuosl.org Date: Thu, 28 May 2020 12:43:40 -0700 Message-Id: <20200528194342.3495-13-ranjani.sridharan@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200528194342.3495-1-ranjani.sridharan@linux.intel.com> References: <20200528194342.3495-1-ranjani.sridharan@linux.intel.com> Subject: [Intel-wired-lan] [PATCH 12/14] ASoC: SOF: Introduce descriptors for SOF client X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pierre-louis.bossart@linux.intel.com, fred.oh@linux.intel.com, shiraz.saleem@intel.com MIME-Version: 1.0 Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" A client in the SOF (Sound Open Firmware) context is a device that needs to communicate with the DSP via IPC messages. The SOF core is responsible for serializing the IPC messages to the DSP from the different clients. One example of an SOF client would be an IPC test client that floods the DSP with test IPC messages to validate if the serialization works as expected. Multi-client support will also add the ability to split the existing audio cards into multiple ones, so as to e.g. to deal with HDMI with a dedicated client instead of adding HDMI to all cards. This patch introduces descriptors for SOF client driver and SOF client device along with APIs for registering and unregistering a SOF client driver, sending IPCs from a client device and accessing the SOF core debugfs root entry. Along with this, add a couple of new members to struct snd_sof_dev that will be used for maintaining the list of clients. Signed-off-by: Ranjani Sridharan Signed-off-by: Fred Oh Reviewed-by: Pierre-Louis Bossart --- sound/soc/sof/Kconfig | 19 ++++++++ sound/soc/sof/Makefile | 1 + sound/soc/sof/core.c | 2 + sound/soc/sof/sof-client.c | 89 ++++++++++++++++++++++++++++++++++++++ sound/soc/sof/sof-client.h | 79 +++++++++++++++++++++++++++++++++ sound/soc/sof/sof-priv.h | 6 +++ 6 files changed, 196 insertions(+) create mode 100644 sound/soc/sof/sof-client.c create mode 100644 sound/soc/sof/sof-client.h diff --git a/sound/soc/sof/Kconfig b/sound/soc/sof/Kconfig index 4dda4b62509f..664af8cbacea 100644 --- a/sound/soc/sof/Kconfig +++ b/sound/soc/sof/Kconfig @@ -50,6 +50,24 @@ config SND_SOC_SOF_DEBUG_PROBES Say Y if you want to enable probes. If unsure, select "N". +config SND_SOC_SOF_CLIENT + tristate + select VIRTUAL_BUS + help + This option is not user-selectable but automagically handled by + 'select' statements at a higher level + +config SND_SOC_SOF_CLIENT_SUPPORT + bool "SOF enable clients" + depends on SND_SOC_SOF + help + This adds support for virtual client devices to separate out the debug + functionality for IPC tests, probes etc. into separate devices. This + option would also allow adding client devices based on DSP FW + capabilities and ACPI/OF device information. + Say Y if you want to enable clients with SOF. + If unsure select "N". + config SND_SOC_SOF_DEVELOPER_SUPPORT bool "SOF developer options support" depends on EXPERT @@ -186,6 +204,7 @@ endif ## SND_SOC_SOF_DEVELOPER_SUPPORT config SND_SOC_SOF tristate + select SND_SOC_SOF_CLIENT if SND_SOC_SOF_CLIENT_SUPPORT select SND_SOC_TOPOLOGY select SND_SOC_SOF_NOCODEC if SND_SOC_SOF_NOCODEC_SUPPORT help diff --git a/sound/soc/sof/Makefile b/sound/soc/sof/Makefile index 05718dfe6cd2..35d6803caf38 100644 --- a/sound/soc/sof/Makefile +++ b/sound/soc/sof/Makefile @@ -2,6 +2,7 @@ snd-sof-objs := core.o ops.o loader.o ipc.o pcm.o pm.o debug.o topology.o\ control.o trace.o utils.o sof-audio.o +snd-sof-$(CONFIG_SND_SOC_SOF_CLIENT) := sof-client.o snd-sof-$(CONFIG_SND_SOC_SOF_DEBUG_PROBES) += probe.o compress.o snd-sof-pci-objs := sof-pci-dev.o diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c index 339c4930b0c0..3a7ea7be70fa 100644 --- a/sound/soc/sof/core.c +++ b/sound/soc/sof/core.c @@ -314,8 +314,10 @@ int snd_sof_device_probe(struct device *dev, struct snd_sof_pdata *plat_data) INIT_LIST_HEAD(&sdev->widget_list); INIT_LIST_HEAD(&sdev->dai_list); INIT_LIST_HEAD(&sdev->route_list); + INIT_LIST_HEAD(&sdev->client_list); spin_lock_init(&sdev->ipc_lock); spin_lock_init(&sdev->hw_lock); + mutex_init(&sdev->client_mutex); if (IS_ENABLED(CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE)) INIT_WORK(&sdev->probe_work, sof_probe_work); diff --git a/sound/soc/sof/sof-client.c b/sound/soc/sof/sof-client.c new file mode 100644 index 000000000000..e0230075ccfb --- /dev/null +++ b/sound/soc/sof/sof-client.c @@ -0,0 +1,89 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// Copyright(c) 2020 Intel Corporation. All rights reserved. +// +// Author: Ranjani Sridharan +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "sof-client.h" +#include "sof-priv.h" + +static void sof_client_connect(struct virtbus_device *vdev) +{ + struct sof_client_dev *cdev = virtbus_dev_to_sof_client_dev(vdev); + struct snd_sof_dev *sdev = cdev->sdev; + + /* add to list of SOF client devices */ + mutex_lock(&sdev->client_mutex); + list_add(&cdev->list, &sdev->client_list); + mutex_unlock(&sdev->client_mutex); +} + +static void sof_client_disconnect(struct virtbus_device *vdev) +{ + struct sof_client_dev *cdev = virtbus_dev_to_sof_client_dev(vdev); + struct snd_sof_dev *sdev = cdev->sdev; + + /* remove from list of SOF client devices */ + mutex_lock(&sdev->client_mutex); + list_del(&cdev->list); + mutex_unlock(&sdev->client_mutex); +} + +static void sof_client_virtdev_release(struct virtbus_device *vdev) +{ + struct sof_client_dev *cdev = virtbus_dev_to_sof_client_dev(vdev); + + kfree(cdev); +} + +int sof_client_dev_register(struct snd_sof_dev *sdev, + const char *name) +{ + struct sof_client_dev *cdev; + struct virtbus_device *vdev; + + cdev = kzalloc(sizeof(*cdev), GFP_KERNEL); + if (!cdev) + return -ENOMEM; + + cdev->sdev = sdev; + cdev->connect = sof_client_connect; + cdev->disconnect = sof_client_disconnect; + vdev = &cdev->vdev; + vdev->match_name = name; + vdev->dev.parent = sdev->dev; + vdev->release = sof_client_virtdev_release; + + /* + * Register virtbus device for the client. + * The error path in virtbus_register_device() calls put_device(), + * which will free cdev in the release callback. + */ + return virtbus_register_device(vdev); +} +EXPORT_SYMBOL_NS_GPL(sof_client_dev_register, SND_SOC_SOF_CLIENT); + +int sof_client_ipc_tx_message(struct sof_client_dev *cdev, u32 header, + void *msg_data, size_t msg_bytes, + void *reply_data, size_t reply_bytes) +{ + return sof_ipc_tx_message(cdev->sdev->ipc, header, msg_data, msg_bytes, + reply_data, reply_bytes); +} +EXPORT_SYMBOL_NS_GPL(sof_client_ipc_tx_message, SND_SOC_SOF_CLIENT); + +struct dentry *sof_client_get_debugfs_root(struct sof_client_dev *cdev) +{ + return cdev->sdev->debugfs_root; +} +EXPORT_SYMBOL_NS_GPL(sof_client_get_debugfs_root, SND_SOC_SOF_CLIENT); diff --git a/sound/soc/sof/sof-client.h b/sound/soc/sof/sof-client.h new file mode 100644 index 000000000000..b390c0d0a698 --- /dev/null +++ b/sound/soc/sof/sof-client.h @@ -0,0 +1,79 @@ +/* SPDX-License-Identifier: (GPL-2.0-only) */ + +#ifndef __SOUND_SOC_SOF_CLIENT_H +#define __SOUND_SOC_SOF_CLIENT_H + +#include +#include +#include +#include +#include +#include +#include + +#define SOF_CLIENT_PROBE_TIMEOUT_MS 2000 + +struct snd_sof_dev; + +/* SOF client device */ +struct sof_client_dev { + struct virtbus_device vdev; + struct snd_sof_dev *sdev; + struct list_head list; /* item in SOF core client drv list */ + void (*connect)(struct virtbus_device *vdev); + void (*disconnect)(struct virtbus_device *vdev); + void *data; +}; + +/* client-specific ops, all optional */ +struct sof_client_ops { + int (*client_ipc_rx)(struct sof_client_dev *cdev, u32 msg_cmd); +}; + +struct sof_client_drv { + const char *name; + const struct sof_client_ops ops; + struct virtbus_driver virtbus_drv; +}; + +#define virtbus_dev_to_sof_client_dev(virtbus_dev) \ + container_of(virtbus_dev, struct sof_client_dev, vdev) + +static inline int sof_client_drv_register(struct sof_client_drv *drv) +{ + return virtbus_register_driver(&drv->virtbus_drv); +} + +static inline void sof_client_drv_unregister(struct sof_client_drv *drv) +{ + virtbus_unregister_driver(&drv->virtbus_drv); +} + +int sof_client_dev_register(struct snd_sof_dev *sdev, + const char *name); + +static inline void sof_client_dev_unregister(struct sof_client_dev *cdev) +{ + virtbus_unregister_device(&cdev->vdev); +} + +int sof_client_ipc_tx_message(struct sof_client_dev *cdev, u32 header, + void *msg_data, size_t msg_bytes, + void *reply_data, size_t reply_bytes); + +struct dentry *sof_client_get_debugfs_root(struct sof_client_dev *cdev); + +/** + * module_sof_client_driver() - Helper macro for registering an SOF Client + * driver + * @__sof_client_driver: SOF client driver struct + * + * Helper macro for SOF client drivers which do not do anything special in + * module init/exit. This eliminates a lot of boilerplate. Each module may only + * use this macro once, and calling it replaces module_init() and module_exit() + */ +#define module_sof_client_driver(__sof_client_driver) \ + module_driver(__sof_client_driver, sof_client_drv_register, \ + sof_client_drv_unregister) + +#endif diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h index 9bee2aab750d..2233370a0339 100644 --- a/sound/soc/sof/sof-priv.h +++ b/sound/soc/sof/sof-priv.h @@ -441,6 +441,12 @@ struct snd_sof_dev { bool msi_enabled; + /* list of client devices */ + struct list_head client_list; + + /* mutex to protect client list */ + struct mutex client_mutex; + void *private; /* core does not touch this */ }; From patchwork Thu May 28 19:43:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ranjani Sridharan X-Patchwork-Id: 1300021 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49Xyn807K5z9sSF for ; Fri, 29 May 2020 05:43:56 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 22E0089188; Thu, 28 May 2020 19:43:54 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2ANlY5xC0Cg0; Thu, 28 May 2020 19:43:52 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 1B45089157; Thu, 28 May 2020 19:43:52 +0000 (UTC) X-Original-To: intel-wired-lan@osuosl.org Delivered-To: intel-wired-lan@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id CDAD61BF9B9 for ; Thu, 28 May 2020 19:43:45 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id C918E8803D for ; Thu, 28 May 2020 19:43:45 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xtNWYyJFM0i3 for ; Thu, 28 May 2020 19:43:44 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by whitealder.osuosl.org (Postfix) with ESMTPS id 9BFBF8819D for ; Thu, 28 May 2020 19:43:44 +0000 (UTC) IronPort-SDR: 0NESE8pUe0WRbp+AoevSeoZO5rNdnHpbBel1Uty2wK4zJaBXXxuim3D7XIoRkaenBFMPcd//wO mtNPvDi01f6g== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2020 12:43:44 -0700 IronPort-SDR: cef37uIOJJavIlJj+BdT8m+wOOffXXhWQ0ruyftcvkEp67Sh3cB1XQfYJsWUk9/aRpRG+Kfl9R kwDOhySw7CMA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,446,1583222400"; d="scan'208";a="302585286" Received: from jkoshman-mobl.amr.corp.intel.com (HELO localhost.localdomain) ([10.251.154.131]) by fmsmga002.fm.intel.com with ESMTP; 28 May 2020 12:43:44 -0700 From: Ranjani Sridharan To: intel-wired-lan@osuosl.org Date: Thu, 28 May 2020 12:43:41 -0700 Message-Id: <20200528194342.3495-14-ranjani.sridharan@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200528194342.3495-1-ranjani.sridharan@linux.intel.com> References: <20200528194342.3495-1-ranjani.sridharan@linux.intel.com> Subject: [Intel-wired-lan] [PATCH 13/14] ASoC: SOF: Create client driver for IPC test X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pierre-louis.bossart@linux.intel.com, fred.oh@linux.intel.com, shiraz.saleem@intel.com MIME-Version: 1.0 Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Create an SOF client driver for IPC flood test. This driver is used to set up the debugfs entries and the read/write ops for initiating the IPC flood test that would be used to measure the min/max/avg response times for sending IPCs to the DSP. Signed-off-by: Ranjani Sridharan Signed-off-by: Fred Oh Reviewed-by: Pierre-Louis Bossart --- sound/soc/sof/Kconfig | 10 + sound/soc/sof/Makefile | 6 +- sound/soc/sof/sof-ipc-test-client.c | 348 ++++++++++++++++++++++++++++ 3 files changed, 363 insertions(+), 1 deletion(-) create mode 100644 sound/soc/sof/sof-ipc-test-client.c diff --git a/sound/soc/sof/Kconfig b/sound/soc/sof/Kconfig index 664af8cbacea..9cc76951cfc6 100644 --- a/sound/soc/sof/Kconfig +++ b/sound/soc/sof/Kconfig @@ -190,6 +190,16 @@ config SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST Say Y if you want to enable IPC flood test. If unsure, select "N". +config SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST_CLIENT + tristate "SOF enable IPC flood test client" + depends on SND_SOC_SOF_CLIENT + help + This option enables a separate client device for IPC flood test + which can be used to flood the DSP with test IPCs and gather stats + about response times. + Say Y if you want to enable IPC flood test. + If unsure, select "N". + config SND_SOC_SOF_DEBUG_RETAIN_DSP_CONTEXT bool "SOF retain DSP context on any FW exceptions" help diff --git a/sound/soc/sof/Makefile b/sound/soc/sof/Makefile index 35d6803caf38..bff97ff421b1 100644 --- a/sound/soc/sof/Makefile +++ b/sound/soc/sof/Makefile @@ -9,16 +9,20 @@ snd-sof-pci-objs := sof-pci-dev.o snd-sof-acpi-objs := sof-acpi-dev.o snd-sof-of-objs := sof-of-dev.o +snd-sof-ipc-test-objs := sof-ipc-test-client.o + snd-sof-nocodec-objs := nocodec.o + obj-$(CONFIG_SND_SOC_SOF) += snd-sof.o obj-$(CONFIG_SND_SOC_SOF_NOCODEC) += snd-sof-nocodec.o - obj-$(CONFIG_SND_SOC_SOF_ACPI) += snd-sof-acpi.o obj-$(CONFIG_SND_SOC_SOF_OF) += snd-sof-of.o obj-$(CONFIG_SND_SOC_SOF_PCI) += snd-sof-pci.o +obj-$(CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST_CLIENT) += snd-sof-ipc-test.o + obj-$(CONFIG_SND_SOC_SOF_INTEL_TOPLEVEL) += intel/ obj-$(CONFIG_SND_SOC_SOF_IMX_TOPLEVEL) += imx/ obj-$(CONFIG_SND_SOC_SOF_XTENSA) += xtensa/ diff --git a/sound/soc/sof/sof-ipc-test-client.c b/sound/soc/sof/sof-ipc-test-client.c new file mode 100644 index 000000000000..3b757ba504aa --- /dev/null +++ b/sound/soc/sof/sof-ipc-test-client.c @@ -0,0 +1,348 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// Copyright(c) 2020 Intel Corporation. All rights reserved. +// +// Author: Ranjani Sridharan +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "sof-client.h" + +#define MAX_IPC_FLOOD_DURATION_MS 1000 +#define MAX_IPC_FLOOD_COUNT 10000 +#define IPC_FLOOD_TEST_RESULT_LEN 512 +#define SOF_IPC_CLIENT_SUSPEND_DELAY_MS 3000 + +struct sof_ipc_client_data { + struct dentry *dfs_root; + char *buf; +}; + +/* helper function to perform the flood test */ +static int sof_debug_ipc_flood_test(struct sof_client_dev *cdev, + bool flood_duration_test, + unsigned long ipc_duration_ms, + unsigned long ipc_count) +{ + struct sof_ipc_client_data *ipc_client_data = cdev->data; + struct device *dev = &cdev->vdev.dev; + struct sof_ipc_cmd_hdr hdr; + struct sof_ipc_reply reply; + u64 min_response_time = U64_MAX; + u64 avg_response_time = 0; + u64 max_response_time = 0; + ktime_t cur = ktime_get(); + ktime_t test_end; + int i = 0; + int ret = 0; + + /* configure test IPC */ + hdr.cmd = SOF_IPC_GLB_TEST_MSG | SOF_IPC_TEST_IPC_FLOOD; + hdr.size = sizeof(hdr); + + /* set test end time for duration flood test */ + test_end = ktime_get_ns() + ipc_duration_ms * NSEC_PER_MSEC; + + /* send test IPC's */ + for (i = 0; + flood_duration_test ? ktime_to_ns(cur) < test_end : i < ipc_count; + i++) { + ktime_t start; + u64 ipc_response_time; + + start = ktime_get(); + ret = sof_client_ipc_tx_message(cdev, hdr.cmd, + &hdr, hdr.size, &reply, + sizeof(reply)); + if (ret < 0) + break; + cur = ktime_get(); + + /* compute min and max response times */ + ipc_response_time = ktime_to_ns(ktime_sub(cur, start)); + min_response_time = min(min_response_time, ipc_response_time); + max_response_time = max(max_response_time, ipc_response_time); + + /* sum up response times */ + avg_response_time += ipc_response_time; + } + + if (ret < 0) + dev_err(dev, "error: ipc flood test failed at %d iterations\n", + i); + + /* return if the first IPC fails */ + if (!i) + return ret; + + /* compute average response time */ + DIV_ROUND_CLOSEST(avg_response_time, i); + + /* clear previous test output */ + memset(ipc_client_data->buf, 0, IPC_FLOOD_TEST_RESULT_LEN); + + if (flood_duration_test) { + dev_dbg(dev, "IPC Flood test duration: %lums\n", + ipc_duration_ms); + snprintf(ipc_client_data->buf, IPC_FLOOD_TEST_RESULT_LEN, + "IPC Flood test duration: %lums\n", ipc_duration_ms); + } + + dev_dbg(dev, + "IPC Flood count: %d, Avg response time: %lluns\n", + i, avg_response_time); + dev_dbg(dev, "Max response time: %lluns\n", + max_response_time); + dev_dbg(dev, "Min response time: %lluns\n", + min_response_time); + + /* format output string and save test results */ + snprintf(ipc_client_data->buf + strlen(ipc_client_data->buf), + IPC_FLOOD_TEST_RESULT_LEN - strlen(ipc_client_data->buf), + "IPC Flood count: %d\nAvg response time: %lluns\n", + i, avg_response_time); + + snprintf(ipc_client_data->buf + strlen(ipc_client_data->buf), + IPC_FLOOD_TEST_RESULT_LEN - strlen(ipc_client_data->buf), + "Max response time: %lluns\nMin response time: %lluns\n", + max_response_time, min_response_time); + + return ret; +} + +/* + * Writing to the debugfs entry initiates the IPC flood test based on + * the IPC count or the duration specified by the user. + */ +static ssize_t sof_ipc_dfsentry_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *ppos) +{ + struct dentry *dentry = file->f_path.dentry; + struct sof_client_dev *cdev = file->private_data; + struct device *dev = &cdev->vdev.dev; + unsigned long ipc_duration_ms = 0; + bool flood_duration_test; + unsigned long ipc_count = 0; + char *string; + size_t size; + int err; + int ret; + + string = kzalloc(count, GFP_KERNEL); + if (!string) + return -ENOMEM; + + size = simple_write_to_buffer(string, count, ppos, buffer, count); + + flood_duration_test = !strcmp(dentry->d_name.name, + "ipc_flood_duration_ms"); + + /* set test completion criterion */ + ret = flood_duration_test ? kstrtoul(string, 0, &ipc_duration_ms) : + kstrtoul(string, 0, &ipc_count); + if (ret < 0) + goto out; + + /* limit max duration/ipc count for flood test */ + if (flood_duration_test) { + if (!ipc_duration_ms) { + ret = size; + goto out; + } + + ipc_duration_ms = min_t(unsigned long, ipc_duration_ms, + MAX_IPC_FLOOD_DURATION_MS); + } else { + if (!ipc_count) { + ret = size; + goto out; + } + + ipc_count = min_t(unsigned long, ipc_count, + MAX_IPC_FLOOD_COUNT); + } + + ret = pm_runtime_get_sync(dev); + if (ret < 0) { + dev_err_ratelimited(dev, + "error: debugfs write failed to resume %d\n", + ret); + pm_runtime_put_noidle(dev); + goto out; + } + + /* flood test */ + ret = sof_debug_ipc_flood_test(cdev, flood_duration_test, + ipc_duration_ms, ipc_count); + + pm_runtime_mark_last_busy(dev); + err = pm_runtime_put_autosuspend(dev); + if (err < 0) + dev_err_ratelimited(dev, + "error: debugfs write failed to idle %d\n", + err); + + /* return size if test is successful */ + if (ret >= 0) + ret = size; +out: + kfree(string); + return ret; +} + +/* return the result of the last IPC flood test */ +static ssize_t sof_ipc_dfsentry_read(struct file *file, char __user *buffer, + size_t count, loff_t *ppos) +{ + struct sof_client_dev *cdev = file->private_data; + struct sof_ipc_client_data *ipc_client_data = cdev->data; + size_t size_ret; + + if (*ppos) + return 0; + + /* return results of the last IPC test */ + count = strlen(ipc_client_data->buf); + size_ret = copy_to_user(buffer, ipc_client_data->buf, count); + if (size_ret) + return -EFAULT; + + *ppos += count; + return count; +} + +static const struct file_operations sof_ipc_dfs_fops = { + .open = simple_open, + .read = sof_ipc_dfsentry_read, + .llseek = default_llseek, + .write = sof_ipc_dfsentry_write, +}; + +/* + * The IPC test client creates a couple of debugfs entries that will be used + * flood tests. Users can write to these entries to execute the IPC flood test + * by specifying either the number of IPCs to flood the DSP with or the duration + * (in ms) for which the DSP should be flooded with test IPCs. At the + * end of each test, the average, min and max response times are reported back. + * The results of the last flood test can be accessed by reading the debugfs + * entries. + */ +static int sof_ipc_test_probe(struct virtbus_device *vdev) +{ + struct sof_client_dev *cdev = virtbus_dev_to_sof_client_dev(vdev); + struct sof_ipc_client_data *ipc_client_data; + + /* + * The virtbus device has a usage count of 0 even before runtime PM + * is enabled. So, increment the usage count to let the device + * suspend after probe is complete. + */ + pm_runtime_get_noresume(&vdev->dev); + + /* allocate memory for client data */ + ipc_client_data = devm_kzalloc(&vdev->dev, sizeof(*ipc_client_data), + GFP_KERNEL); + if (!ipc_client_data) + return -ENOMEM; + + ipc_client_data->buf = devm_kzalloc(&vdev->dev, + IPC_FLOOD_TEST_RESULT_LEN, + GFP_KERNEL); + if (!ipc_client_data->buf) + return -ENOMEM; + + cdev->data = ipc_client_data; + + /* create debugfs root folder with device name under parent SOF dir */ + ipc_client_data->dfs_root = + debugfs_create_dir(dev_name(&vdev->dev), + sof_client_get_debugfs_root(cdev)); + + /* create read-write ipc_flood_count debugfs entry */ + debugfs_create_file("ipc_flood_count", 0644, ipc_client_data->dfs_root, + cdev, &sof_ipc_dfs_fops); + + /* create read-write ipc_flood_duration_ms debugfs entry */ + debugfs_create_file("ipc_flood_duration_ms", 0644, + ipc_client_data->dfs_root, + cdev, &sof_ipc_dfs_fops); + + /* enable runtime PM */ + pm_runtime_set_autosuspend_delay(&vdev->dev, + SOF_IPC_CLIENT_SUSPEND_DELAY_MS); + pm_runtime_use_autosuspend(&vdev->dev); + pm_runtime_set_active(&vdev->dev); + pm_runtime_enable(&vdev->dev); + pm_runtime_mark_last_busy(&vdev->dev); + pm_runtime_put_autosuspend(&vdev->dev); + + /* connect client dev with SOF core */ + cdev->connect(vdev); + + return 0; +} + +static int sof_ipc_test_cleanup(struct virtbus_device *vdev) +{ + struct sof_client_dev *cdev = virtbus_dev_to_sof_client_dev(vdev); + struct sof_ipc_client_data *ipc_client_data = cdev->data; + + pm_runtime_disable(&vdev->dev); + + /* disconnect client dev from SOF core */ + cdev->disconnect(vdev); + + debugfs_remove_recursive(ipc_client_data->dfs_root); + + return 0; +} + +static int sof_ipc_test_remove(struct virtbus_device *vdev) +{ + return sof_ipc_test_cleanup(vdev); +} + +static void sof_ipc_test_shutdown(struct virtbus_device *vdev) +{ + sof_ipc_test_cleanup(vdev); +} + +static const struct virtbus_device_id sof_ipc_virtbus_id_table[] = { + {.name = "sof-ipc-test"}, + { }, +}; +MODULE_DEVICE_TABLE(virtbus, sof_ipc_virtbus_id_table); + +/* + * No need for driver pm_ops as the generic pm callbacks in the virtual bus + * type are enough to ensure that the parent SOF device resumes to bring + * the DSP back to D0. + */ +static struct sof_client_drv sof_ipc_test_client_drv = { + .name = "sof-ipc-test-client-drv", + .virtbus_drv = { + .driver = { + .name = "sof-ipc-test-virtbus-drv", + }, + .id_table = sof_ipc_virtbus_id_table, + .probe = sof_ipc_test_probe, + .remove = sof_ipc_test_remove, + .shutdown = sof_ipc_test_shutdown, + }, +}; + +module_sof_client_driver(sof_ipc_test_client_drv); + +MODULE_DESCRIPTION("SOF IPC Test Client Driver"); +MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(SND_SOC_SOF_CLIENT); From patchwork Thu May 28 19:43:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ranjani Sridharan X-Patchwork-Id: 1300025 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49Xyn92Ztmz9sSF for ; Fri, 29 May 2020 05:43:57 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id E710489216; Thu, 28 May 2020 19:43:55 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id R2rNJJTu5AOb; Thu, 28 May 2020 19:43:53 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 7DF7C89211; Thu, 28 May 2020 19:43:52 +0000 (UTC) X-Original-To: intel-wired-lan@osuosl.org Delivered-To: intel-wired-lan@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id D78E81BF2B5 for ; Thu, 28 May 2020 19:43:45 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id D40AB8729F for ; Thu, 28 May 2020 19:43:45 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ralZnAlU6s1N for ; Thu, 28 May 2020 19:43:45 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by fraxinus.osuosl.org (Postfix) with ESMTPS id E552087267 for ; Thu, 28 May 2020 19:43:44 +0000 (UTC) IronPort-SDR: p3qAQDnSBeIQ1HA3v5GovK//EYlJvHAMXTYDyZd0iBnEUSE0esV72GupL9z9e7fvIKj8zyIoT6 fgI6SpozNK7w== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2020 12:43:44 -0700 IronPort-SDR: A6kPXvwtOFRH4vH91VXn3TqXCYI06OggWzKbEhxICTP53fAmVejWI1jIgg4MSO3dQ0xCu/OlKo ujsAC/RbaWmA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,446,1583222400"; d="scan'208";a="302585291" Received: from jkoshman-mobl.amr.corp.intel.com (HELO localhost.localdomain) ([10.251.154.131]) by fmsmga002.fm.intel.com with ESMTP; 28 May 2020 12:43:44 -0700 From: Ranjani Sridharan To: intel-wired-lan@osuosl.org Date: Thu, 28 May 2020 12:43:42 -0700 Message-Id: <20200528194342.3495-15-ranjani.sridharan@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200528194342.3495-1-ranjani.sridharan@linux.intel.com> References: <20200528194342.3495-1-ranjani.sridharan@linux.intel.com> Subject: [Intel-wired-lan] [PATCH 14/14] ASoC: SOF: ops: Add new op for client registration X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pierre-louis.bossart@linux.intel.com, fred.oh@linux.intel.com, shiraz.saleem@intel.com MIME-Version: 1.0 Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Add a new op for registering clients. The clients to be registered depend on the DSP capabilities and the ACPI/DT information. For now, we only add 2 IPC test clients that will be used for run tandem IPC flood tests for all Intel platforms. For ACPI platforms, change the Kconfig to select SND_SOC_SOF_PROBE_WORK_QUEUE to allow the virtbus driver to probe when the client is registered. Signed-off-by: Ranjani Sridharan Signed-off-by: Fred Oh Reviewed-by: Pierre-Louis Bossart --- sound/soc/sof/core.c | 8 ++++++++ sound/soc/sof/intel/Kconfig | 1 + sound/soc/sof/intel/apl.c | 19 +++++++++++++++++++ sound/soc/sof/intel/bdw.c | 19 +++++++++++++++++++ sound/soc/sof/intel/byt.c | 22 ++++++++++++++++++++++ sound/soc/sof/intel/cnl.c | 19 +++++++++++++++++++ sound/soc/sof/ops.h | 20 ++++++++++++++++++++ sound/soc/sof/sof-priv.h | 3 +++ 8 files changed, 111 insertions(+) diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c index 3a7ea7be70fa..ce7d87c8f34c 100644 --- a/sound/soc/sof/core.c +++ b/sound/soc/sof/core.c @@ -246,6 +246,12 @@ static int sof_probe_continue(struct snd_sof_dev *sdev) if (plat_data->sof_probe_complete) plat_data->sof_probe_complete(sdev->dev); + /* + * Register client devices. This can fail but errors cannot be + * propagated. + */ + snd_sof_register_clients(sdev); + return 0; fw_trace_err: @@ -356,6 +362,7 @@ int snd_sof_device_remove(struct device *dev) cancel_work_sync(&sdev->probe_work); if (sdev->fw_state > SOF_FW_BOOT_NOT_STARTED) { + snd_sof_unregister_clients(sdev); snd_sof_fw_unload(sdev); snd_sof_ipc_free(sdev); snd_sof_free_debug(sdev); @@ -389,4 +396,5 @@ EXPORT_SYMBOL(snd_sof_device_remove); MODULE_AUTHOR("Liam Girdwood"); MODULE_DESCRIPTION("Sound Open Firmware (SOF) Core"); MODULE_LICENSE("Dual BSD/GPL"); +MODULE_IMPORT_NS(SND_SOC_SOF_CLIENT); MODULE_ALIAS("platform:sof-audio"); diff --git a/sound/soc/sof/intel/Kconfig b/sound/soc/sof/intel/Kconfig index 9b3c01072dd8..46e3a17b9bc6 100644 --- a/sound/soc/sof/intel/Kconfig +++ b/sound/soc/sof/intel/Kconfig @@ -13,6 +13,7 @@ config SND_SOC_SOF_INTEL_ACPI def_tristate SND_SOC_SOF_ACPI select SND_SOC_SOF_BAYTRAIL if SND_SOC_SOF_BAYTRAIL_SUPPORT select SND_SOC_SOF_BROADWELL if SND_SOC_SOF_BROADWELL_SUPPORT + select SND_SOC_SOF_PROBE_WORK_QUEUE if SND_SOC_SOF_CLIENT help This option is not user-selectable but automagically handled by 'select' statements at a higher level diff --git a/sound/soc/sof/intel/apl.c b/sound/soc/sof/intel/apl.c index 9e29d4fd393a..d6f42794f0b7 100644 --- a/sound/soc/sof/intel/apl.c +++ b/sound/soc/sof/intel/apl.c @@ -18,6 +18,7 @@ #include "../sof-priv.h" #include "hda.h" #include "../sof-audio.h" +#include "../sof-client.h" static const struct snd_sof_debugfs_map apl_dsp_debugfs[] = { {"hda", HDA_DSP_HDA_BAR, 0, 0x4000, SOF_DEBUGFS_ACCESS_ALWAYS}, @@ -25,6 +26,20 @@ static const struct snd_sof_debugfs_map apl_dsp_debugfs[] = { {"dsp", HDA_DSP_BAR, 0, 0x10000, SOF_DEBUGFS_ACCESS_ALWAYS}, }; +static void apl_register_clients(struct snd_sof_dev *sdev) +{ +#if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST_CLIENT) + /* + * Register 2 IPC clients to facilitate tandem flood test. + * The device name below is appended with the device ID assigned + * automatically when the virtbus device is registered making + * them unique. + */ + sof_client_dev_register(sdev, "sof-ipc-test"); + sof_client_dev_register(sdev, "sof-ipc-test"); +#endif +} + /* apollolake ops */ const struct snd_sof_dsp_ops sof_apl_ops = { /* probe and remove */ @@ -101,6 +116,9 @@ const struct snd_sof_dsp_ops sof_apl_ops = { .trace_release = hda_dsp_trace_release, .trace_trigger = hda_dsp_trace_trigger, + /* client register */ + .register_clients = apl_register_clients, + /* DAI drivers */ .drv = skl_dai, .num_drv = SOF_SKL_NUM_DAIS, @@ -140,3 +158,4 @@ const struct sof_intel_dsp_desc apl_chip_info = { .ssp_base_offset = APL_SSP_BASE_OFFSET, }; EXPORT_SYMBOL_NS(apl_chip_info, SND_SOC_SOF_INTEL_HDA_COMMON); +MODULE_IMPORT_NS(SND_SOC_SOF_CLIENT); diff --git a/sound/soc/sof/intel/bdw.c b/sound/soc/sof/intel/bdw.c index 99fd0bd7276e..1909c93fecba 100644 --- a/sound/soc/sof/intel/bdw.c +++ b/sound/soc/sof/intel/bdw.c @@ -18,6 +18,7 @@ #include "../ops.h" #include "shim.h" #include "../sof-audio.h" +#include "../sof-client.h" /* BARs */ #define BDW_DSP_BAR 0 @@ -563,6 +564,20 @@ static void bdw_set_mach_params(const struct snd_soc_acpi_mach *mach, mach_params->platform = dev_name(dev); } +static void bdw_register_clients(struct snd_sof_dev *sdev) +{ +#if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST_CLIENT) + /* + * Register 2 IPC clients to facilitate tandem flood test. + * The device name below is appended with the device ID assigned + * automatically when the virtbus device is registered making + * them unique. + */ + sof_client_dev_register(sdev, "sof-ipc-test"); + sof_client_dev_register(sdev, "sof-ipc-test"); +#endif +} + /* Broadwell DAIs */ static struct snd_soc_dai_driver bdw_dai[] = { { @@ -638,6 +653,9 @@ const struct snd_sof_dsp_ops sof_bdw_ops = { /*Firmware loading */ .load_firmware = snd_sof_load_firmware_memcpy, + /* client register */ + .register_clients = bdw_register_clients, + /* DAI drivers */ .drv = bdw_dai, .num_drv = ARRAY_SIZE(bdw_dai), @@ -662,3 +680,4 @@ EXPORT_SYMBOL_NS(bdw_chip_info, SND_SOC_SOF_BROADWELL); MODULE_LICENSE("Dual BSD/GPL"); MODULE_IMPORT_NS(SND_SOC_SOF_INTEL_HIFI_EP_IPC); MODULE_IMPORT_NS(SND_SOC_SOF_XTENSA); +MODULE_IMPORT_NS(SND_SOC_SOF_CLIENT); diff --git a/sound/soc/sof/intel/byt.c b/sound/soc/sof/intel/byt.c index e6ba8382b1de..e70fd96f3045 100644 --- a/sound/soc/sof/intel/byt.c +++ b/sound/soc/sof/intel/byt.c @@ -19,6 +19,7 @@ #include "shim.h" #include "../sof-audio.h" #include "../../intel/common/soc-intel-quirks.h" +#include "../sof-client.h" /* DSP memories */ #define IRAM_OFFSET 0x0C0000 @@ -821,6 +822,20 @@ static int byt_acpi_probe(struct snd_sof_dev *sdev) return ret; } +static void byt_register_clients(struct snd_sof_dev *sdev) +{ +#if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST_CLIENT) + /* + * Register 2 IPC clients to facilitate tandem flood test. + * The device name below is appended with the device ID assigned + * automatically when the virtbus device is registered making + * them unique. + */ + sof_client_dev_register(sdev, "sof-ipc-test"); + sof_client_dev_register(sdev, "sof-ipc-test"); +#endif +} + /* baytrail ops */ const struct snd_sof_dsp_ops sof_byt_ops = { /* device init */ @@ -879,6 +894,9 @@ const struct snd_sof_dsp_ops sof_byt_ops = { .suspend = byt_suspend, .resume = byt_resume, + /* client register */ + .register_clients = byt_register_clients, + /* DAI drivers */ .drv = byt_dai, .num_drv = 3, /* we have only 3 SSPs on byt*/ @@ -958,6 +976,9 @@ const struct snd_sof_dsp_ops sof_cht_ops = { .suspend = byt_suspend, .resume = byt_resume, + /* client register */ + .register_clients = byt_register_clients, + /* DAI drivers */ .drv = byt_dai, /* all 6 SSPs may be available for cherrytrail */ @@ -985,3 +1006,4 @@ EXPORT_SYMBOL_NS(cht_chip_info, SND_SOC_SOF_BAYTRAIL); MODULE_LICENSE("Dual BSD/GPL"); MODULE_IMPORT_NS(SND_SOC_SOF_INTEL_HIFI_EP_IPC); MODULE_IMPORT_NS(SND_SOC_SOF_XTENSA); +MODULE_IMPORT_NS(SND_SOC_SOF_CLIENT); diff --git a/sound/soc/sof/intel/cnl.c b/sound/soc/sof/intel/cnl.c index 16db0f50d139..322764b6f9b4 100644 --- a/sound/soc/sof/intel/cnl.c +++ b/sound/soc/sof/intel/cnl.c @@ -19,6 +19,7 @@ #include "hda.h" #include "hda-ipc.h" #include "../sof-audio.h" +#include "../sof-client.h" static const struct snd_sof_debugfs_map cnl_dsp_debugfs[] = { {"hda", HDA_DSP_HDA_BAR, 0, 0x4000, SOF_DEBUGFS_ACCESS_ALWAYS}, @@ -231,6 +232,20 @@ static void cnl_ipc_dump(struct snd_sof_dev *sdev) hipcida, hipctdr, hipcctl); } +static void cnl_register_clients(struct snd_sof_dev *sdev) +{ +#if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST_CLIENT) + /* + * Register 2 IPC clients to facilitate tandem flood test. + * The device name below is appended with the device ID assigned + * automatically when the virtbus device is registered making + * them unique. + */ + sof_client_dev_register(sdev, "sof-ipc-test"); + sof_client_dev_register(sdev, "sof-ipc-test"); +#endif +} + /* cannonlake ops */ const struct snd_sof_dsp_ops sof_cnl_ops = { /* probe and remove */ @@ -307,6 +322,9 @@ const struct snd_sof_dsp_ops sof_cnl_ops = { .trace_release = hda_dsp_trace_release, .trace_trigger = hda_dsp_trace_trigger, + /* client register */ + .register_clients = cnl_register_clients, + /* DAI drivers */ .drv = skl_dai, .num_drv = SOF_SKL_NUM_DAIS, @@ -417,3 +435,4 @@ const struct sof_intel_dsp_desc jsl_chip_info = { .ssp_base_offset = CNL_SSP_BASE_OFFSET, }; EXPORT_SYMBOL_NS(jsl_chip_info, SND_SOC_SOF_INTEL_HDA_COMMON); +MODULE_IMPORT_NS(SND_SOC_SOF_CLIENT); diff --git a/sound/soc/sof/ops.h b/sound/soc/sof/ops.h index b21632f5511a..6fa8b6736dce 100644 --- a/sound/soc/sof/ops.h +++ b/sound/soc/sof/ops.h @@ -14,9 +14,12 @@ #include #include #include +#include +#include #include #include #include "sof-priv.h" +#include "sof-client.h" #define sof_ops(sdev) \ ((sdev)->pdata->desc->ops) @@ -470,6 +473,23 @@ snd_sof_set_mach_params(const struct snd_soc_acpi_mach *mach, sof_ops(sdev)->set_mach_params(mach, dev); } +static inline void +snd_sof_register_clients(struct snd_sof_dev *sdev) +{ + if (sof_ops(sdev) && sof_ops(sdev)->register_clients) + sof_ops(sdev)->register_clients(sdev); +} + +static inline void +snd_sof_unregister_clients(struct snd_sof_dev *sdev) +{ + struct sof_client_dev *cdev, *_cdev; + + /* unregister client devices */ + list_for_each_entry_safe(cdev, _cdev, &sdev->client_list, list) + sof_client_dev_unregister(cdev); +} + static inline const struct snd_sof_dsp_ops *sof_get_ops(const struct sof_dev_desc *d, const struct sof_ops_table mach_ops[], int asize) diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h index 2233370a0339..932eea7d441e 100644 --- a/sound/soc/sof/sof-priv.h +++ b/sound/soc/sof/sof-priv.h @@ -252,6 +252,9 @@ struct snd_sof_dsp_ops { void (*set_mach_params)(const struct snd_soc_acpi_mach *mach, struct device *dev); /* optional */ + /* client ops */ + void (*register_clients)(struct snd_sof_dev *sdev); /* optional */ + /* DAI ops */ struct snd_soc_dai_driver *drv; int num_drv;