From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>
Cc: Richard Fitzgerald <rf@opensource.cirrus.com>, <vkoul@kernel.org>,
<peter.ujfalusi@linux.intel.com>,
<yung-chuan.liao@linux.intel.com>, <sanyog.r.kale@intel.com>,
<linux-sound@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<patches@opensource.cirrus.com>
Subject: Re: [PATCH] soundwire: intel_auxdevice: Don't disable IRQs before removing children
Date: Thu, 19 Dec 2024 10:27:53 +0000 [thread overview]
Message-ID: <Z2P1KVLFig0Kh1h2@opensource.cirrus.com> (raw)
In-Reply-To: <9b8ef4d2-e4bd-4336-8980-0fb59d672631@linux.dev>
On Wed, Dec 18, 2024 at 04:40:22PM -0500, Pierre-Louis Bossart wrote:
> I agree that the device should be reachable during the remove(),
> but I believe the scope of expected interaction should be limited
> to a strict minimum. To be clearer, so far not a single device had
> a requirement for any sort of interaction on remove. You would need
> to clarify which codec driver needs this.
Ok I can add that to the commit message.
> I don't see how the 'link_lock' and 'bus_lock' are at different
> levels of the stack, the 'master' device and the 'auxiliary' device
> are both quite thin and I don't quite see what's different between
> the two.
Not sure I follow that, like for example I assume I could just make
the code use the bus_lock instead of adding a lock but to me that
feels like a layer violation, you have a driver directly taking
framework locks. But I guess I don't totally object if everyone
else prefers that.
In terms of other solutions, I could look at redoing more of the
IRQ handling. If rather than using a hard coded linked list, the
IRQs were properly registered as IRQs with the IRQ framework then
we could simply add and remove them using the normal APIs, which
would be a lot cleaner. Of course, fundamentally that is pretty
equivalent but it will then just use a lock from the IRQ framework.
> Having looked at the code in more details, I think there are other issues,
> see e.g. this part of the code called from snd_bus_master_delete().
>
> static int sdw_delete_slave(struct device *dev, void *data)
> {
> struct sdw_slave *slave = dev_to_sdw_dev(dev);
> struct sdw_bus *bus = slave->bus;
>
> pm_runtime_disable(dev);
>
> sdw_slave_debugfs_exit(slave);
>
> mutex_lock(&bus->bus_lock);
>
> if (slave->dev_num) { /* clear dev_num if assigned */
> clear_bit(slave->dev_num, bus->assigned);
> if (bus->ops && bus->ops->put_device_num)
> bus->ops->put_device_num(bus, slave);
> }
>
> So at this point an interaction with the device is not longer possible, even
> if the Cadence interrupts are kept active, since there's no valid device
> number to use...
>
> list_del_init(&slave->node);
> mutex_unlock(&bus->bus_lock);
>
> ... but this is where the .remove() will take place.
>
> device_unregister(dev);
> return 0;
> }
>
> What am I missing?
Hmm... yes that is a good spot, I will investigate that further.
Certainly I do see these operations happening in the wrong order
but it doesn't seem to cause the register transactions to fail.
Most likely it is best to reverse these two, it makes sense
to not clear the device number until we are finished with the
device, but would be good to understand what is going on first.
Thanks,
Charles
next prev parent reply other threads:[~2024-12-19 10:28 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-12 11:02 [PATCH] soundwire: intel_auxdevice: Don't disable IRQs before removing children Charles Keepax
2024-12-16 17:35 ` Pierre-Louis Bossart
2024-12-17 10:24 ` Charles Keepax
2024-12-17 10:49 ` Richard Fitzgerald
2024-12-17 23:49 ` Pierre-Louis Bossart
2024-12-18 9:51 ` Charles Keepax
2024-12-18 20:45 ` Pierre-Louis Bossart
2024-12-18 21:40 ` Pierre-Louis Bossart
2024-12-19 10:27 ` Charles Keepax [this message]
2024-12-20 17:59 ` Charles Keepax
2025-01-02 22:14 ` Pierre-Louis Bossart
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=Z2P1KVLFig0Kh1h2@opensource.cirrus.com \
--to=ckeepax@opensource.cirrus.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=peter.ujfalusi@linux.intel.com \
--cc=pierre-louis.bossart@linux.dev \
--cc=rf@opensource.cirrus.com \
--cc=sanyog.r.kale@intel.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox