From: Vinod Koul <vkoul@kernel.org>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: alsa-devel@alsa-project.org, tiwai@suse.de,
gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
Ranjani Sridharan <ranjani.sridharan@linux.intel.com>,
Hui Wang <hui.wang@canonical.com>,
broonie@kernel.org, srinivas.kandagatla@linaro.org,
jank@cadence.com, slawomir.blauciak@intel.com,
Sanyog Kale <sanyog.r.kale@intel.com>,
Bard liao <yung-chuan.liao@linux.intel.com>,
Rander Wang <rander.wang@linux.intel.com>
Subject: Re: [PATCH 1/8] soundwire: bus_type: add master_device/driver support
Date: Tue, 3 Mar 2020 11:11:36 +0530 [thread overview]
Message-ID: <20200303054136.GP4148@vkoul-mobl> (raw)
In-Reply-To: <20200227223206.5020-2-pierre-louis.bossart@linux.intel.com>
On 27-02-20, 16:31, Pierre-Louis Bossart wrote:
> In the existing SoundWire code, Master Devices are not explicitly
> represented - only SoundWire Slave Devices are exposed (the use of
> capital letters follows the SoundWire specification conventions).
>
> The SoundWire Master Device provides the clock, synchronization
> information and command/control channels. When multiple links are
> supported, a Controller may expose more than one Master Device; they
> are typically embedded inside a larger audio cluster (be it in an
> SOC/chipset or an external audio codec), and we need to describe it
> using the Linux device and driver model. This will allow for
> configuration functions to account for external dependencies such as
> power rails, clock sources or wake-up mechanisms. This transition will
I dont not see that as a soundwire issue. The external dependencies
should be handled as any device would do in Linux kernel with subsystem
specific things for soundwire mechanisms like wake-up
Intel has a big controller with HDA, DSP and Soundwire clubbed together,
I dont think we should burden the susbstem due to hw design
> also allow for better sysfs support without the reference count issues
> mentioned in the initial reviews.
>
> In this patch, we convert the existing code to use an explicit
> sdw_slave_type, then define new objects (sdw_master_device and
> sdw_master_driver).
Thanks for sdw_master_device, that is required and fully agreed upon.
What is not agreed is the sdw_master_driver. We do not need that.
As we have discussed your proposal with Greg and aligned (quoting that
here) on following device model for Intel and ARM:
> - For DT cases we will have:
> -> soundwire DT device (soundwire DT driver)
> -> soundwire master device
> -> soundwire slave device (slave drivers)
> - For Intel case, you would have:
> -> HDA PCI device (SOF driver + soundwire module)
> -> soundwire master device
> -> soundwire slave device (slave drivers)
But you have gone ahead and kept the sdw_master_driver which does not fit
into rest of the world except Intel.
I think I am okay with rest of proposal, except this one, so can you
remove this and we can make progress. This issue is lingering since Oct!
> A parent (such as the Intel audio controller or its equivalent on
> Qualcomm devices) would use sdw_master_device_add() to create the
> device, passing a driver name as a parameter. The master device would
> be released when device_unregister() is invoked by the parent.
We already have a DT driver for soundwire master! We dont need another
layer which does not add value!
> Note that since there is no standard for the Master host-facing
> interface, so the bus matching relies on a simple string matching (as
> previously done with platform devices).
>
> The 'Master Device' driver exposes callbacks for
> probe/startup/shutdown/remove/process_wake. The startup and process
> wake need to be called by the parent directly (using wrappers), while
> the probe/shutdown/remove are handled by the SoundWire bus core upon
> device creation and release.
these are added to handle intel DSP and sequencing issue, rest of the
world does not have these issues and does not needs them!
> Additional callbacks will be added in the future for e.g. autonomous
> clock stop modes.
Yes these would be required, these can be added in sdw_master_device
too, I dont see them requiring a dummy driver layer..
> @@ -113,8 +152,6 @@ static int sdw_drv_probe(struct device *dev)
> slave->probed = true;
> complete(&slave->probe_complete);
>
> - dev_dbg(dev, "probe complete\n");
> -
This does not seem to belong to this patch.
> +struct device_type sdw_master_type = {
> + .name = "soundwire_master",
> + .release = sdw_master_device_release,
> +};
> +
> +struct sdw_master_device
> +*sdw_master_device_add(const char *master_name,
> + struct device *parent,
> + struct fwnode_handle *fwnode,
> + int link_id,
> + void *pdata)
> +{
> + struct sdw_master_device *md;
> + int ret;
> +
> + md = kzalloc(sizeof(*md), GFP_KERNEL);
> + if (!md)
> + return ERR_PTR(-ENOMEM);
> +
> + md->link_id = link_id;
> + md->pdata = pdata;
> + md->master_name = master_name;
should we not allocate the memory here for master_name?
> +
> + init_completion(&md->probe_complete);
> +
> + md->dev.parent = parent;
> + md->dev.fwnode = fwnode;
> + md->dev.bus = &sdw_bus_type;
> + md->dev.type = &sdw_master_type;
> + md->dev.dma_mask = md->dev.parent->dma_mask;
> + dev_set_name(&md->dev, "sdw-master-%d", md->link_id);
why do we need master_name if we are setting this here?
> +
> + ret = device_register(&md->dev);
> + if (ret) {
> + dev_err(parent, "Failed to add master: ret %d\n", ret);
> + /*
> + * On err, don't free but drop ref as this will be freed
> + * when release method is invoked.
> + */
> + put_device(&md->dev);
> + return ERR_PTR(-ENOMEM);
ENOMEM?
> +int sdw_master_device_startup(struct sdw_master_device *md)
> +{
> + struct sdw_master_driver *mdrv;
> + struct device *dev;
> + int ret = 0;
> +
> + if (IS_ERR_OR_NULL(md))
> + return -EINVAL;
> +
> + dev = &md->dev;
> + mdrv = drv_to_sdw_master_driver(dev->driver);
> +
> + if (mdrv && mdrv->startup)
> + ret = mdrv->startup(md);
> +
> + return ret;
> +}
> +EXPORT_SYMBOL_GPL(sdw_master_device_startup);
who invokes this and when, can you add kernel-doc style documentation to
all APIs exported
> +int sdw_master_device_process_wake_event(struct sdw_master_device *md)
> +{
> + struct sdw_master_driver *mdrv;
> + struct device *dev;
> + int ret = 0;
> +
> + if (IS_ERR_OR_NULL(md))
> + return -EINVAL;
> +
> + dev = &md->dev;
> + mdrv = drv_to_sdw_master_driver(dev->driver);
> +
> + if (mdrv && mdrv->process_wake_event)
> + ret = mdrv->process_wake_event(md);
> +
> + return ret;
> +}
> +EXPORT_SYMBOL_GPL(sdw_master_device_process_wake_event);
Documentation required
> +/**
> + * struct sdw_master_device - SoundWire 'Master Device' representation
> + *
> + * @dev: Linux device for this Master
> + * @master_name: Linux driver name
> + * @driver: Linux driver for this Master (set by SoundWire core during probe)
> + * @probe_complete: used by parent if synchronous probe behavior is needed
> + * @link_id: link index as defined by MIPI DisCo specification
> + * @pm_runtime_suspended: flag to restore pm_runtime state after system resume
> + * @pdata: private data typically provided with sdw_master_device_add()
> + */
> +
> +struct sdw_master_device {
> + struct device dev;
> + const char *master_name;
> + struct sdw_master_driver *driver;
> + struct completion probe_complete;
> + int link_id;
> + bool pm_runtime_suspended;
why not use runtime_pm apis like pm_runtime_suspended()
> +/**
> + * sdw_master_device_add() - create a Linux Master Device representation.
> + *
> + * @master_name: Linux driver name
> + * @parent: the parent Linux device (e.g. a PCI device)
> + * @fwnode: the parent fwnode (e.g. an ACPI companion device to the parent)
> + * @link_id: link index as defined by MIPI DisCo specification
> + * @pdata: private data (e.g. register base, offsets, platform quirks, etc).
> + */
> +struct sdw_master_device
> +*sdw_master_device_add(const char *master_name,
> + struct device *parent,
> + struct fwnode_handle *fwnode,
> + int link_id,
> + void *pdata);
> +
> +/**
> + * sdw_master_device_startup() - startup hardware
> + *
> + * @md: Linux Soundwire master device
Please add more useful comments like when this API would be invoked and
what shall be expected outcome
> + */
> +int sdw_master_device_startup(struct sdw_master_device *md);
> +
> +/**
> + * sdw_master_device_process_wake_event() - handle external wake
> + * event, e.g. handled at the PCI level
> + *
> + * @md: Linux Soundwire master device
> + */
> +int sdw_master_device_process_wake_event(struct sdw_master_device *md);
> +
If you look at existing headers the documentation is in C files for
APIs, so can you move them over.
When adding stuff please look at the rest of the code as an example.
--
~Vinod
next prev parent reply other threads:[~2020-03-03 5:44 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-27 22:31 [PATCH 0/8] soundwire: remove platform devices, add SOF interfaces Pierre-Louis Bossart
2020-02-27 22:31 ` [PATCH 1/8] soundwire: bus_type: add master_device/driver support Pierre-Louis Bossart
2020-02-28 7:32 ` Greg KH
2020-02-28 15:53 ` Pierre-Louis Bossart
2020-03-03 5:41 ` Vinod Koul [this message]
2020-03-03 15:23 ` Pierre-Louis Bossart
2020-03-04 9:53 ` Vinod Koul
2020-03-04 15:17 ` Pierre-Louis Bossart
2020-03-04 16:28 ` Greg KH
2020-03-05 6:46 ` Vinod Koul
2020-03-05 6:36 ` Vinod Koul
2020-03-05 12:46 ` Pierre-Louis Bossart
2020-03-06 5:01 ` Vinod Koul
2020-03-06 15:40 ` Pierre-Louis Bossart
2020-03-11 6:36 ` Vinod Koul
2020-03-11 14:44 ` Pierre-Louis Bossart
2020-03-13 11:50 ` Vinod Koul
2020-03-13 16:54 ` Pierre-Louis Bossart
2020-03-14 9:49 ` Vinod Koul
2020-03-16 19:15 ` Pierre-Louis Bossart
2020-03-20 15:33 ` Vinod Koul
2020-03-20 16:36 ` Pierre-Louis Bossart
2020-03-23 12:16 ` Vinod Koul
2020-02-27 22:32 ` [PATCH 2/8] soundwire: intel: transition to sdw_master_device/driver support Pierre-Louis Bossart
2020-02-28 7:34 ` Greg KH
2020-02-28 16:01 ` Pierre-Louis Bossart
2020-03-03 6:05 ` Vinod Koul
2020-02-27 22:32 ` [PATCH 3/8] soundwire: intel_init: add implementation of sdw_intel_enable_irq() Pierre-Louis Bossart
2020-02-27 22:32 ` [PATCH 4/8] soundwire: intel_init: use EXPORT_SYMBOL_NS Pierre-Louis Bossart
2020-02-27 22:32 ` [PATCH 5/8] soundwire: intel/cadence: merge Soundwire interrupt handlers/threads Pierre-Louis Bossart
2020-02-27 22:32 ` [PATCH 6/8] soundwire: intel: add helpers for link power down and shim wake Pierre-Louis Bossart
2020-02-27 22:32 ` [PATCH 7/8] soundwire: intel: add wake interrupt support Pierre-Louis Bossart
2020-02-27 22:32 ` [PATCH 8/8] soundwire: intel_init: save Slave(s) _ADR info in sdw_intel_ctx Pierre-Louis Bossart
2020-02-28 7:32 ` [PATCH 0/8] soundwire: remove platform devices, add SOF interfaces Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200303054136.GP4148@vkoul-mobl \
--to=vkoul@kernel.org \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=hui.wang@canonical.com \
--cc=jank@cadence.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=rander.wang@linux.intel.com \
--cc=ranjani.sridharan@linux.intel.com \
--cc=sanyog.r.kale@intel.com \
--cc=slawomir.blauciak@intel.com \
--cc=srinivas.kandagatla@linaro.org \
--cc=tiwai@suse.de \
--cc=yung-chuan.liao@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox