mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>
To: Jiawen Liu <1298662399@qq.com>, Vinod Koul <vkoul@kernel.org>,
	Bard Liao <yung-chuan.liao@linux.intel.com>,
	Jizhou Tong <fqwqf@fqwqf.xyz>,
	Charles Keepax <ckeepax@opensource.cirrus.com>
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] soundwire: fail slave probe if IRQ cleanup cannot be registered
Date: Mon, 30 Nov 2026 11:18:42 +0100	[thread overview]
Message-ID: <fdf0167e-4068-49c4-afbf-2130267ec61d@linux.dev> (raw)
In-Reply-To: <tencent_768BC420EF74999D8200877ECD2A1BEB0B09@qq.com>

On 11/29/26 13:48, Jiawen Liu wrote:
> sdw_irq_create_mapping() publishes the new virtual IRQ in slave->irq
> before registering its devres cleanup action. If action registration
> fails, the reset helper disposes the mapping but the cached IRQ remains
> nonzero, so the peripheral driver probe receives an invalid IRQ number.
> 
> Keep the mapping local until cleanup registration succeeds, clear the
> cached IRQ when the mapping is disposed, and return registration failures
> to the bus probe path before invoking the peripheral driver.
> 
> Fixes: a5fef9baa87f ("soundwire: bus: Move irq mapping cleanup into devres")
> Signed-off-by: Jiawen Liu <1298662399@qq.com>

The changes look ok to me, so here's a

Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>

The only problem is that there was already a similar submission in "[RFC
PATCH] soundwire: protect the slave IRQ mapping during alert dispatch",
with additional locking suggested but no answer provided to my feedback.
Adding the initial contributor and Charles in the To: list, not sure all
the interrupt handling problems are solved.

> ---
>  drivers/soundwire/bus_type.c |  4 +++-
>  drivers/soundwire/irq.c      | 22 ++++++++++++++++++----
>  drivers/soundwire/irq.h      |  5 +++--
>  3 files changed, 24 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/soundwire/bus_type.c b/drivers/soundwire/bus_type.c
> index fea15107cd9b9..f832065745981 100644
> --- a/drivers/soundwire/bus_type.c
> +++ b/drivers/soundwire/bus_type.c
> @@ -116,7 +116,9 @@ static int sdw_bus_probe(struct device *dev)
>  		return ret;
>  
>  	/* Create IRQ mapping now so the driver can get it in probe() */
> -	sdw_irq_create_mapping(slave);
> +	ret = sdw_irq_create_mapping(slave);
> +	if (ret)
> +		return ret;
>  
>  	ret = drv->probe(slave, id);
>  	if (ret)
> diff --git a/drivers/soundwire/irq.c b/drivers/soundwire/irq.c
> index f18be37efef8e..9618c10ddacca 100644
> --- a/drivers/soundwire/irq.c
> +++ b/drivers/soundwire/irq.c
> @@ -51,13 +51,27 @@ static void sdw_irq_dispose_mapping(void *data)
>  	struct sdw_slave *slave = data;
>  
>  	irq_dispose_mapping(slave->irq);
> +	slave->irq = 0;
>  }
>  
> -void sdw_irq_create_mapping(struct sdw_slave *slave)
> +int sdw_irq_create_mapping(struct sdw_slave *slave)
>  {
> -	slave->irq = irq_create_mapping(slave->bus->domain, slave->index);
> -	if (!slave->irq)
> +	unsigned int irq;
> +	int ret;
> +
> +	irq = irq_create_mapping(slave->bus->domain, slave->index);
> +	if (!irq) {
>  		dev_warn(&slave->dev, "Failed to map IRQ\n");
> +		return 0;
> +	}
> +
> +	ret = devm_add_action(&slave->dev, sdw_irq_dispose_mapping, slave);
> +	if (ret) {
> +		irq_dispose_mapping(irq);
> +		return ret;
> +	}
> +
> +	slave->irq = irq;
>  
> -	devm_add_action_or_reset(&slave->dev, sdw_irq_dispose_mapping, slave);
> +	return 0;
>  }
> diff --git a/drivers/soundwire/irq.h b/drivers/soundwire/irq.h
> index 86e2318409dab..224c5aad22817 100644
> --- a/drivers/soundwire/irq.h
> +++ b/drivers/soundwire/irq.h
> @@ -15,7 +15,7 @@
>  int sdw_irq_create(struct sdw_bus *bus,
>  		   struct fwnode_handle *fwnode);
>  void sdw_irq_delete(struct sdw_bus *bus);
> -void sdw_irq_create_mapping(struct sdw_slave *slave);
> +int sdw_irq_create_mapping(struct sdw_slave *slave);
>  
>  #else /* CONFIG_IRQ_DOMAIN */
>  
> @@ -29,8 +29,9 @@ static inline void sdw_irq_delete(struct sdw_bus *bus)
>  {
>  }
>  
> -static inline void sdw_irq_create_mapping(struct sdw_slave *slave)
> +static inline int sdw_irq_create_mapping(struct sdw_slave *slave)
>  {
> +	return 0;
>  }
>  
>  #endif /* CONFIG_IRQ_DOMAIN */


  reply	other threads:[~2026-11-30 14:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29 12:48 Jiawen Liu
2026-11-30 10:18 ` Pierre-Louis Bossart [this message]
2026-11-30 15:50   ` Charles Keepax
2026-11-30 19:54     ` Jiawen Liu

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=fdf0167e-4068-49c4-afbf-2130267ec61d@linux.dev \
    --to=pierre-louis.bossart@linux.dev \
    --cc=1298662399@qq.com \
    --cc=ckeepax@opensource.cirrus.com \
    --cc=fqwqf@fqwqf.xyz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --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®