[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200128105036.GO2841@vkoul-mobl>
Date: Tue, 28 Jan 2020 16:20:36 +0530
From: Vinod Koul <vkoul@...nel.org>
To: Pierre-Louis Bossart <pierre-louis.bossart@...ux.intel.com>
Cc: alsa-devel@...a-project.org, tiwai@...e.de,
gregkh@...uxfoundation.org, linux-kernel@...r.kernel.org,
Ranjani Sridharan <ranjani.sridharan@...ux.intel.com>,
broonie@...nel.org, srinivas.kandagatla@...aro.org,
jank@...ence.com, slawomir.blauciak@...el.com,
Sanyog Kale <sanyog.r.kale@...el.com>,
Bard liao <yung-chuan.liao@...ux.intel.com>,
Rander Wang <rander.wang@...ux.intel.com>
Subject: Re: [alsa-devel] [PATCH v5 09/17] soundwire: intel: remove platform
devices and use 'Master Devices' instead
Hi Pierre,
I took some time to look into the overall code and how this is fitting
into big picture and help recommend way forward.
On 21-01-20, 11:31, Pierre-Louis Bossart wrote:
>
>
> > A rename away from probe will certainly be very helpful as
> > you would also agree that terms 'probe' and 'remove' have a very
> > special meaning in kernel, so let us avoid these
>
> ok, so would the following be ok with you?
>
> /**
> * struct sdw_md_driver - SoundWire 'Master Device' driver
> *
> * @init: allocations and initializations (hardware may not be enabled yet)
> * @startup: initialization handled after the hardware is enabled, all
> * clock/power dependencies are available
> * @shutdown: cleanups before hardware is disabled (optional)
> * @exit: free all remaining resources
> * @autonomous_clock_stop_enable: enable/disable driver control while
> * in clock-stop mode, typically in always-on/D0ix modes. When the driver
> * yields control, another entity in the system (typically firmware
> * running on an always-on microprocessor) is responsible to tracking
> * Slave-initiated wakes
> */
> struct sdw_md_driver {
> int (*init)(struct sdw_master_device *md, void *link_ctx);
> int (*startup)(struct sdw_master_device *md);
> int (*shutdown)(struct sdw_master_device *md);
> int (*exit)(struct sdw_master_device *md);
> int (*autonomous_clock_stop_enable)(struct sdw_master_device *md,
> bool state);
> };
So this is a soundwire core driver structure, but the modelling and
explanation provided here suggests the reasoning to be based on hardware
sequencing. I am not sure if we should follow this approach. Solving
hardware sequencing is fine but that should IMO be restricted to intel
code as that is intel issue which may or may not be present on other
controllers.
If I look at the calling sequence of the code (looked up the sof code on
github, topic/sof-dev-rebase), the sof code sound/soc/sof/intel/hda.c
invokes the sdw_intel_startup() and sdw_intel_probe() based on hardware
sequencing and further you call .init and .probe/startup of sdw_md_driver.
I really do not see why we need a sdw_md_driver object to do that. You can
easily have a another function exported by sdw_intel driver and you call
these and do same functionality without having a sdw_md_driver in
between.
Now, I am going to step back one more step and ask you why should we
have a sdw_md_driver? I am not seeing the driver object achieving
anything here expect adding wrappers which we can avoid. But we still
need to add the sdw_master_device() as a new device object and use that
for both sysfs representation as well as representing the master device
and do all the things we want, but it *can* come without having
accompanying sdw_md_driver.
This way you can retain you calling sequence and add the master device.
Stretching this one more step I would ask that maybe it is even better
idea that we should hide sdw_master_device_add() calling for soundwire
drivers and move that internal to bus as part of bus registration as
well, I don't see sdw_master_device calling back into the driver so it
should not impact your sequences as well.
Do you see a reason for sdw_md_driver which is must have? I couldn't
find that by looking at the code, let me know if I have missed anything
here.
So to summarize, my recommendation would be to drop sdw_md_driver, keep
sdw_master_device object and make sdw_master_device_add() hidden to
driver and call it from sdw_add_bus_master() and keep intel specific
startup/init routine which do same steps as they have now.
Thanks
--
~Vinod
Powered by blists - more mailing lists