Skip to content

[RFC] Use virtual bus implementation in SOF - #1841

Closed
ranj063 wants to merge 5 commits into
thesofproject:topic/sof-devfrom
ranj063:virtual-bus-sof
Closed

[RFC] Use virtual bus implementation in SOF#1841
ranj063 wants to merge 5 commits into
thesofproject:topic/sof-devfrom
ranj063:virtual-bus-sof

Conversation

@ranj063

@ranj063ranj063 commented Feb 28, 2020

Copy link
Copy Markdown
Collaborator

This PR just shows the use virtual bus devices in SOF. The virtbus dev is encapsulated within a sof_client_dev to enable extending the ops supported by the virtbus_dev to include SOF client specific ops and data. This PR is now updated with the complete implementation for the dummy IPC client.

Please note that the first patch is still under review here:
http://patchwork.ozlabs.org/patch/1247882/

@plbossartplbossart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a good start to me. Thanks @ranj063

Comment threadsound/soc/sof/core.c Outdated
Comment threadsound/soc/sof/Makefile Outdated
Comment threadsound/soc/sof/sof-ipc-test.c Outdated
Comment threadsound/soc/sof/sof-ipc-test.c Outdated
Comment threadsound/soc/sof/core.c Outdated
Comment threadsound/soc/sof/core.c Outdated
Comment threadsound/soc/sof/core.c Outdated

@lgirdwoodlgirdwood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do need to read the virtio bus patches, but some questions that may impact the client PM.

Comment threadsound/soc/sof/core.c Outdated

@kv2019ikv2019i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok so far. Biggest thing seems to be how we manage the sof_virtbus_dev objects as part of sdev and how we link back.

@ranj063

Copy link
Copy Markdown
CollaboratorAuthor

@plbossart@lgirdwood@lyakh@kv2019i this PR is now updated to include the second step ir registering a client drv and probing client devices after FW boot is done. The client device probe still does nothing atm but once we agree upon the registration model, I will add that to this PR.

Comment threadsound/soc/sof/sof-client.c Outdated
Comment threadsound/soc/sof/sof-client.c Outdated

mutex_lock(&sof_client_mutex);
list_for_each_entry_safe(cdev, _cdev, &client_list, list) {
if (cdev->drv == drv) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your client_list is global, and as far as I understand we can in theory at some point get multiple DSPs. Would they then possibly use the same driver? Then this matching would break?

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lyakh I'm not sure about this case. But my guess would be that if there are multiple DSP, they possibly should not share the same driver. @lgirdwood could you please chime in?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the same driver can be used for multiple devices, but each would need to have its own context and not a shared variable.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@plbossart How would that work though? If you look at sof_client_drv_register() today, we create a client device for each client drv that is registered. If multiple devices share the same driver, then we probably need some kind of id table just like the virtbus driver, right?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can create a new global context (which can hold lists etc) per detected DSP device, i.e. on PCI/ACPI probe.

Comment threadsound/soc/sof/sof-ipc-test.c Outdated
Comment threadsound/soc/sof/core.c Outdated
@ranj063
ranj063force-pushed the virtual-bus-sof branch 6 times, most recently from 145d738 to c0251feCompareMarch 6, 2020 18:33
@plbossart

Copy link
Copy Markdown
Member

@ranj063 I must be missing something here.

If I look at the IPC, there is first layer that probes/removed the virtbus driver. And then the probe registers an SOF client, which results in a second level probe.

Is this really necessary? seems to me you are bolting a bus on top of a bus?

@ranj063

Copy link
Copy Markdown
CollaboratorAuthor

@ranj063 I must be missing something here.

If I look at the IPC, there is first layer that probes/removed the virtbus driver. And then the probe registers an SOF client, which results in a second level probe.

Is this really necessary? seems to me you are bolting a bus on top of a bus?

@plbossart the virtbus devices are actually only virtual devices. They need to be probed first before they can register with SOF for IPC. And we can probe the client devices only after the SOF core device has finished booting the DSP. So I cant imagine how we can avoid the 2-level probe that we have here.
Besides, for a non-virtbus device, we will be calling just the client_drv_register() when it is probed and then handle all client device initialization in the client_dev_probe().

@plbossart

plbossart commented Mar 10, 2020

Copy link
Copy Markdown
Member

@ranj063 I must be missing something here.
If I look at the IPC, there is first layer that probes/removed the virtbus driver. And then the probe registers an SOF client, which results in a second level probe.
Is this really necessary? seems to me you are bolting a bus on top of a bus?

@plbossart the virtbus devices are actually only virtual devices. They need to be probed first before they can register with SOF for IPC. And we can probe the client devices only after the SOF core device has finished booting the DSP. So I cant imagine how we can avoid the 2-level probe that we have here.
Besides, for a non-virtbus device, we will be calling just the client_drv_register() when it is probed and then handle all client device initialization in the client_dev_probe().

It was my understanding that all clients would be represented with a device that's a child of the PCI/ACPI/DT parent, which would by construction guarantee that the parent remains active as long as any of its children is active.
Your last sentence 'for a non-virtbus device' suggests otherwise?

@ranj063

Copy link
Copy Markdown
CollaboratorAuthor

@lgirdwood@plbossart I've updated this PR based on our discussions last week. The last 3 patches are the ones relevant for SOF. Please let me know what you think

@plbossartplbossart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ranj063 I must be missing a bit of context on the need for a list and the pointer v. structure nesting.

Comment threadsound/soc/sof/sof-client.c Outdated
Comment threadsound/soc/sof/sof-client.c
Comment threadsound/soc/sof/sof-client.h Outdated
Comment threadsound/soc/sof/sof-client.h Outdated
@ranj063
ranj063force-pushed the virtual-bus-sof branch 2 times, most recently from 48cd91f to d120705CompareMarch 23, 2020 23:13
@ranj063

Copy link
Copy Markdown
CollaboratorAuthor

@plbossart@kv2019i I'm goin to hold off on this PR for a week. The virtbus authors are working on a new version and I want to take that in.

@plbossart

Copy link
Copy Markdown
Member

@plbossart@kv2019i I'm goin to hold off on this PR for a week. The virtbus authors are working on a new version and I want to take that in.

ack, also busy on my side.

@lyakh

Copy link
Copy Markdown
Collaborator

@ranj063 I see you haven't yet changed the SOF_CLIENT_IPC enum, are you still in the process of making changes on this PR or is it just a single comment that you missed?

@fredoh9

Copy link
Copy Markdown
Collaborator

@lyakh This is not final yet. virtual bus commit was updated in a few days ago and they are working again to address some comments. I need to rebase again when they update it. I will address your comment also.

@plbossartplbossart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple of comments below @ranj063

Comment threaddrivers/bus/Kconfig Outdated
Comment threaddrivers/bus/Kconfig Outdated
Comment threadscripts/mod/file2alias.c
Comment threadsound/soc/sof/Makefile Outdated
Comment threadsound/soc/sof/sof-client.c Outdated
Comment threadsound/soc/sof/sof-client.c Outdated
Comment threadsound/soc/sof/Makefile
Comment threadsound/soc/sof/sof-ipc-test-client.c Outdated
Comment threadsound/soc/sof/sof-ipc-test-client.c
Comment threadsound/soc/sof/Kconfig Outdated
Comment threadsound/soc/sof/sof-client.h Outdated

@plbossartplbossart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor comments on alignment, for renames I don't know if we really want virtualbus everywhere. virtbus sounds good enough to me, not sure if there is really any risk of confusion with virtualization as @andy-shev was asking.

Comment threaddrivers/bus/Kconfig Outdated
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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alignment seems off.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm this looks fine on my editor. Is it maybe a github display issue?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ranj063 No, it's TABs vs. spaces

Comment threaddrivers/bus/virtual_bus.c Outdated
struct virtbus_device_id *virtbus_match_id(const struct virtbus_device_id *id,
struct virtbus_device *vdev)
static const struct virtualbus_device_id *
virtbus_match_id(const struct virtualbus_device_id *id,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then also rename the virtbus_ functions

Comment threaddrivers/bus/virtual_bus.c Outdated
struct virtbus_device *vdev = to_virtbus_dev(dev);

if (add_uevent_var(env, "MODALIAS=%s%s", VIRTBUS_MODULE_PREFIX,
if (add_uevent_var(env, "MODALIAS=%s%s", VIRTUALBUS_MODULE_PREFIX,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you rename on line 45 this should also be virtualbus_device = to_virtualbus_dev

Comment threadsound/soc/sof/Kconfig
@ranj063

Copy link
Copy Markdown
CollaboratorAuthor

minor comments on alignment, for renames I don't know if we really want virtualbus everywhere. virtbus sounds good enough to me, not sure if there is really any risk of confusion with virtualization as @andy-shev was asking.

OK then, maybe I drop that commit to rename.

@plbossart

plbossart commented May 28, 2020

Copy link
Copy Markdown
Member

minor comments on alignment, for renames I don't know if we really want virtualbus everywhere. virtbus sounds good enough to me, not sure if there is really any risk of confusion with virtualization as @andy-shev was asking.

OK then, maybe I drop that commit to rename.

best to see what @andy-shev thinks of these really long virtual_bus_device names.

@andy-shev

Copy link
Copy Markdown

minor comments on alignment, for renames I don't know if we really want virtualbus everywhere. virtbus sounds good enough to me, not sure if there is really any risk of confusion with virtualization as @andy-shev was asking.

OK then, maybe I drop that commit to rename.

best to see what @andy-shev thinks of these really long virtual_bus_device names.

Can you elaborate a bit? Any example where these long names appear and how do they look like?

Comment threaddrivers/bus/virtual_bus.c
Comment threaddrivers/bus/virtual_bus.c Outdated
Comment threaddrivers/bus/virtual_bus.c
Comment threadsound/soc/sof/Makefile Outdated
Comment threadsound/soc/sof/sof-ipc-test-client.c
kv2019i
kv2019i previously approved these changes Jun 1, 2020

@kv2019ikv2019i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me now.

lyakh
lyakh previously approved these changes Jun 2, 2020

@lyakhlyakh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prvided a couple of comments, but none of them are critical IMHO, I leave it to the author and other reviewers to decide whether a new iteration is needed

Comment threaddrivers/bus/virtual_bus.c
Comment threaddrivers/bus/virtual_bus.c Outdated
{
int ret;

if (WARN_ON(!vdev->release))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure this kind of an error deserves a full blown stack dump and stuff, wouldn't a dev_err() or similar be enough?

.name = "sof-ipc-test-client-drv",
.virtbus_drv = {
.driver = {
.name = "sof-ipc-test-virtbus-drv",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both driver names seem a bit too verbose to me, at least the "-drv" part seems unnecessary?

Comment threadDocumentation/driver-api/virtual_bus.rst Outdated

@kv2019ikv2019i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good @ranj063 . Really the only thing in the documentation was use of MFD versus PCI multifunction. Otherwise seems good.

Comment threadDocumentation/driver-api/virtual_bus.rst Outdated
Comment threadDocumentation/driver-api/virtual_bus.rst Outdated

@plbossartplbossart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for chiming in late, the PCI part is just completely wrong.

Comment threadDocumentation/driver-api/virtual_bus.rst Outdated
Comment threadDocumentation/driver-api/virtual_bus.rst Outdated
Comment threadDocumentation/driver-api/virtual_bus.rst Outdated
Comment threadDocumentation/driver-api/virtual_bus.rst Outdated
Comment threadDocumentation/driver-api/virtual_bus.rst Outdated

Virtual bus devices are created and registered by a multi-function PCI device.
Therefore, they are typically encapsulated within a structure defined by
parent PCI device which contains the virtual bus device and any associated

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defined by the device or driver?

void *data;
};

The parent PCI device would then register the virtual bus device by calling

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'core' driver does the registration...

Comment threadDocumentation/driver-api/virtual_bus.rst Outdated
Comment threadDocumentation/driver-api/virtual_bus.rst Outdated
Comment threadDocumentation/driver-api/virtual_bus.rst
Comment threadDocumentation/driver-api/virtual_bus.rst Outdated
Comment threadDocumentation/driver-api/virtual_bus.rst Outdated
Comment threadDocumentation/driver-api/virtual_bus.rst Outdated
Comment threadDocumentation/driver-api/virtual_bus.rst Outdated
Comment threadDocumentation/driver-api/virtual_bus.rst Outdated
Comment threadDocumentation/driver-api/virtual_bus.rst Outdated

@kv2019ikv2019i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor notes on doc, but looks good. At least this now explicitly discussed the platform bus and MFD and why virtbus is added.

Comment threadDocumentation/driver-api/virtual_bus.rst
Comment threadDocumentation/driver-api/virtual_bus.rst Outdated
Comment threadDocumentation/driver-api/virtual_bus.rst Outdated

@plbossartplbossart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvement on the documentation @ranj063
a couple of comments below to make it even nicer

Comment threadDocumentation/driver-api/index.rst
Comment threadDocumentation/driver-api/virtual_bus.rst Outdated
Comment threadDocumentation/driver-api/virtual_bus.rst Outdated
Comment threadDocumentation/driver-api/virtual_bus.rst Outdated
Comment threadDocumentation/driver-api/virtual_bus.rst Outdated
dmertmanand others added 5 commits June 4, 2020 13:03
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 splitting the
functionality of a subsystem's core device into orthogonal
parts. This bus is also meant to be generic and be available
to be used by any type of parent device (PCI/ACPI/DT).
Signed-off-by: Dave Ertman <david.m.ertman@intel.com>
Signed-off-by: Kiran Patil <kiran.patil@intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
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 <ranjani.sridharan@linux.intel.com>
Signed-off-by: Fred Oh <fred.oh@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
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 <ranjani.sridharan@linux.intel.com>
Signed-off-by: Fred Oh <fred.oh@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
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 <ranjani.sridharan@linux.intel.com>
Signed-off-by: Fred Oh <fred.oh@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Remove the IPC flood test support in the SOF core as it is
now added in the IPC flood test client.
Signed-off-by: Fred Oh <fred.oh@linux.intel.com>
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>

@lyakhlyakh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you decide to fix the presumable '?' typo, this would be a perfect case for a "fixup" patch.


Virtbus drivers register themselves with the bus by calling
virtbus_register_driver(). The id_table contains the names of virtbus devices
that a driver can bind with?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why a question mark? A typo?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was my suggestion with a question mark that was copied verbatim...

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, sorry about that. The documentation is so verbose now that I missed it :(

@kv2019i

Copy link
Copy Markdown
Collaborator

@ranj063 Can we close this, seems obsolete now...?

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

13 participants

@ranj063@plbossart@kv2019i@wenqingfu@xiulipan@fredoh9@aiChaoSONG@lyakh@andy-shev@bardliao@lgirdwood@shirazsaleem@dmertman