From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>
Cc: vkoul@kernel.org, yung-chuan.liao@linux.intel.com,
peter.ujfalusi@linux.intel.com, linux-sound@vger.kernel.org,
patches@opensource.cirrus.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] soundwire: intel_auxdevice: Don't disable IRQs before removing children
Date: Tue, 15 Sep 2026 14:00:22 +0100 [thread overview]
Message-ID: <aqlBZm+8pY03GI59@opensource.cirrus.com> (raw)
In-Reply-To: <071e3833-48af-4ca4-8eda-c6c825580def@linux.dev>
On Tue, Sep 15, 2026 at 02:22:03PM +0200, Pierre-Louis Bossart wrote:
>
> >>> It would appear the reason for the disabling of the IRQs is that
> >>> the IRQ handler iterates through a linked list of all the links,
> >>> once a link is removed the memory pointed at by this linked list
> >>> is freed, but not removed from the linked_list.
> >>
> >> That wasn't the reason, even if you have a single link we all thought it
> >> made more sense to disable peripheral interrupts on the host before
> >> calling sdw_bus_master_delete()
> >
> > What was the reason for deciding to do that, that is not in itself
> > a reason? A drivers remove callback should be able to access
> > registers on the device. The host here requires interrupts to
> > do so. This was the only functional reason in the code I could
> > find that things were done in this order.
>
> like I said it was thought to be simpler this way, we never thought
> about the need to do anything in remove().
> IOW this is a missed requirement that led to a simple solution, not a
> deliberate decision to cripple the remove() step.
Ok I will update to reflect this being more what we need to
update to add this and remove the apparent reason wording.
> >>> --- a/include/linux/soundwire/sdw_intel.h
> >>> +++ b/include/linux/soundwire/sdw_intel.h
> >>> @@ -307,6 +307,7 @@ struct sdw_intel_ctx {
> >>> acpi_handle handle;
> >>> struct sdw_intel_link_dev **ldev;
> >>> struct list_head link_list;
> >>> + struct mutex link_lock; /* lock protecting link_list */
> >>> struct mutex shim_lock; /* lock for access to shared SHIM registers */
> >>
> >> IIRC shim_lock was used to prevent access to common registers shared
> >> between links. How many locks do we need?
> >
> > I mean we could reuse the lock but in my experience locks having
> > a clearly defined purpose is less error prone, than having catch
> > all locks. The shim lock claims to protect the SHIM registers,
> > this one protects the list of links. But if you feel strongly I
> > am happy to try reuse the shim lock for this?
>
> I am not asking for you to share, just that we need to have a discussion
> on whether this new lock is redundant or not, and wording that describes
> why using existing locks isn't desired/needed.
>
> this shim_lock is a protection for very low-level access to registers,
> and completely tied to the way the IP registers were clustered together,
> it's indeed a different conceptual level you're after. So even if there
> is some redundancy or overlap, it's probably simpler to use a different
> lock for different things,
So a quick test appears to suggest using the shim_lock would
work. The original description is mostly focused on the low level
registers, which does feel like a different purpose. That said
though it does basically work the same its a lock linked to the
controller and the initial description does make reference to
protecting the shim_mask field as well so I guess it is already
protecting some state in the same struct.
Happy to go with you and Intel's preferred options here.
>
> > Ultimately, I am not super attached to this way of solving the
> > problem but we do need to come up with some solution to allow
> > drivers to access their device in driver remove. This causes
> > devices to take 1-2 minutes to remove the driver and fills the log
> > with loads of error messages. I am more than happy to entertain
> > other ways of making that happen if you have ideas you prefer?
>
> I don't have any objections with the requirement to let the codec do
> whatever it needs on remove(), this was a miss in the design and it
> needs to be addressed.
> I am just nervous about the interrupt part and possible race conditions.
> Maybe the last stage of the remove() should be to mask all interrupts on
> the codec side with a common helper shared by all codec drivers?
Yeah that is fair, it is a major reshuffling. But we can carry
on that discussion on the other branch.
> BTW we did have scripts to remove/insert in loops to try and find
> issues, not sure if you're aware of them and if they still work, see:
>
> https://github.com/thesofproject/sof-test/blob/main/tools/kmod/
Yeah I believe that causing problems is one of the main things
people have been complaining about.
Thanks,
Charles
prev parent reply other threads:[~2026-09-15 13:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-11 16:19 [PATCH 0/2] Allow SoundWire devices to communicate during remove Charles Keepax
2026-09-11 16:19 ` [PATCH 1/2] soundwire: bus: Don't unassign dev_num before unregistering device Charles Keepax
2026-09-14 18:21 ` Pierre-Louis Bossart
2026-09-15 9:15 ` Charles Keepax
2026-09-11 16:19 ` [PATCH 2/2] soundwire: intel_auxdevice: Don't disable IRQs before removing children Charles Keepax
2026-09-14 18:27 ` Pierre-Louis Bossart
2026-09-15 9:13 ` Charles Keepax
2026-09-15 12:17 ` Charles Keepax
2026-09-15 12:22 ` Pierre-Louis Bossart
2026-09-15 13:00 ` Charles Keepax [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=aqlBZm+8pY03GI59@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=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
all inboxes | Powered by JetHome®