From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: Vinod Koul <vkoul@kernel.org>
Cc: alsa-devel@alsa-project.org, tiwai@suse.de,
gregkh@linuxfoundation.org, broonie@kernel.org,
srinivas.kandagatla@linaro.org,
Bard liao <yung-chuan.liao@linux.intel.com>,
Rander Wang <rander.wang@linux.intel.com>
Subject: Re: [RFC PATCH] soundwire: use driver callbacks directly with proper locking
Date: Thu, 14 Apr 2022 16:17:31 -0500 [thread overview]
Message-ID: <1b043f6e-e1d6-08a4-8a9d-54477d88973f@linux.intel.com> (raw)
In-Reply-To: <3759eab0-6f1e-e6cb-2528-e0d5f79d6ec1@linux.intel.com>
>>> @@ -846,12 +847,18 @@ static int sdw_slave_clk_stop_callback(struct sdw_slave *slave,
>>> enum sdw_clk_stop_mode mode,
>>> enum sdw_clk_stop_type type)
>>> {
>>> - int ret;
>>> + struct device *dev = &slave->dev;
>>> + struct sdw_driver *drv;
>>>
>>> - if (slave->ops && slave->ops->clk_stop) {
>>> - ret = slave->ops->clk_stop(slave, mode, type);
>>> - if (ret < 0)
>>> - return ret;
>>> + /*
>>> + * this function can only be called from a pm_runtime
>>> + * sequence where the device is already locked
>>> + */
>>
>> If this is guaranteed..
>>
>>> +
>>> + if (dev->driver) {
>>
>> do we need to check this? Did you find a case where this was not valid
>> while device is locked, maybe do this while holding the lock (kind of
>> moot to process the calls if driver is gone)
>
> Humm, good feedback. I will re-check for cases where the driver is 'blacklisted' and also cases there there's no power management supported.
I rechecked all this and it turns out I was mistaken. This function is part of a pm_runtime sequence indeed, but at the parent bus/manager device level. I confused levels and adding a deplock_assert showed very quickly that the peripheral device was never locked.
Thanks for pushing back on this!
In all other cases, I think it's valid and safe to take the lock and test dev->driver. It can happen that there is no driver enabled in the build, or that the driver is 'blacklisted', and in theory the user could muck with sysfs to trigger a peripheral driver binding sequence that would happen smack while the bus is suspended or resume.
I'll do more validation and send an update next week.
-Pierre
prev parent reply other threads:[~2022-04-14 21:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-07 22:39 [RFC PATCH] soundwire: use driver callbacks directly with proper locking Pierre-Louis Bossart
2022-04-12 10:53 ` Vinod Koul
2022-04-12 15:03 ` Pierre-Louis Bossart
2022-04-14 21:17 ` Pierre-Louis Bossart [this message]
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=1b043f6e-e1d6-08a4-8a9d-54477d88973f@linux.intel.com \
--to=pierre-louis.bossart@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=rander.wang@linux.intel.com \
--cc=srinivas.kandagatla@linaro.org \
--cc=tiwai@suse.de \
--cc=vkoul@kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.