Linux Sound subsystem development
 help / color / mirror / Atom feed
From: "Shuming [范書銘]" <shumingf@realtek.com>
To: Mark Brown <broonie@kernel.org>
Cc: "lgirdwood@gmail.com" <lgirdwood@gmail.com>,
	"linux-sound@vger.kernel.org" <linux-sound@vger.kernel.org>,
	"lars@metafoo.de" <lars@metafoo.de>,
	"Flove(HsinFu)" <flove@realtek.com>,
	"Oder Chiou" <oder_chiou@realtek.com>,
	"Jack Yu" <jack.yu@realtek.com>,
	"Derek [方德義]" <derek.fang@realtek.com>
Subject: RE: [PATCH] ASoC: rt712: add GPIOs for LED control
Date: Thu, 17 Sep 2026 06:24:06 +0000	[thread overview]
Message-ID: <6c0f94dee95c474d8fd7b5ad486f372a@realtek.com> (raw)
In-Reply-To: <3afc23b2-6072-4b65-b3e5-88cee7bf6997@sirena.org.uk>

> > +	dev_dbg(&rt712->slave->dev, "%s: gpio_pin=%d\n", __func__,
> > +gpio_pin);
> > +
> > +	ret = pm_runtime_resume(rt712->component->dev);
> > +	if (ret < 0 && ret != -EACCES)
> > +		return ret;
> 
> This pm_runtime_resume() usage can race with autosuspend, if the
> autosuspend timer is about to expire it could do so before we actually update
> the register values so the writes won't actually happen.  It's very unlikely to
> actually happen but the risk is there.

Thanks for review. 
I will use pm_runtime_resume_and_get() instead.

> > +	switch (gpio_pin) {
> > +	case 3:
> > +		break;
> > +	case 4:
> > +		rt712_sdca_index_update_bits(rt712, RT712_VENDOR_HDA_CTL,
> > +			RT712_HDA_LEGACY_CONFIG_CTL0, 0x000c, 0x0004);
> 
> This doesn't do any locking with other regmap users and gpiolib won't hold a
> lock for us - since rt712_sdca_index_update_bits() is a read/modify/write
> cycle this could lead to corruption.

Sure. May I add a lock in the callback instead of only locking rt712_sdca_index_update_bits()?
I will send v2 afterward.

> > +static void rt712_sdca_gpio_init(struct rt712_sdca_priv *rt712) {
> > +	int ret;
> > +
> > +	rt712->gpio_chip = rt712_sdca_template_chip;
> > +	rt712->gpio_chip.parent = &rt712->slave->dev;
> > +	rt712->gpio_chip.fwnode = dev_fwnode(&rt712->slave->dev);
> > +
> > +	ret = devm_gpiochip_add_data(&rt712->slave->dev, &rt712->gpio_chip,
> rt712);
> > +	if (ret != 0)
> > +		dev_err(&rt712->slave->dev, "Failed to add GPIOs: %d\n", ret); }
> 
> The gpiolib usage either needs to be conditional on gpiolib or we need the
> driver to depend on it.  Either is fine.

Add the 'IS_ENABLED(CONFIG_GPIOLIB)' check before calling rt712_sdca_gpio_init().

> >
> > +	/* initialize GPIOs */
> > +	rt712_sdca_gpio_init(rt712);
> > +
> >  	if (!rt712->first_hw_init)
> >  		return 0;
> >
> 
> This will happen every time the card binds and uses devm, I'd expect it to
> happen when the SoundWire device binds rather than during ASoC level
> initialisation.  We don't want to continually register and unregister the GPIOs.

Will move to sdw_driver.probe().

> > @@ -271,7 +276,6 @@ enum {
> >  	RT712_CLK_FREQ_22_5792MHZ = 4,
> >  };
> >
> > -
> >  int rt712_sdca_io_init(struct device *dev, struct sdw_slave *slave);
> > int rt712_sdca_init(struct device *dev, struct regmap *regmap,
> >  			struct regmap *mbq_regmap, struct sdw_slave *slave);
> 
> Unrelated whitespace change.

Wil fix

  reply	other threads:[~2026-09-17  6:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-16  9:05 [PATCH] ASoC: rt712: add GPIOs for LED control shumingf
2026-09-16 21:39 ` Mark Brown
2026-09-17  6:24   ` Shuming [范書銘] [this message]
2026-09-17 11:05     ` Mark Brown

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=6c0f94dee95c474d8fd7b5ad486f372a@realtek.com \
    --to=shumingf@realtek.com \
    --cc=broonie@kernel.org \
    --cc=derek.fang@realtek.com \
    --cc=flove@realtek.com \
    --cc=jack.yu@realtek.com \
    --cc=lars@metafoo.de \
    --cc=lgirdwood@gmail.com \
    --cc=linux-sound@vger.kernel.org \
    --cc=oder_chiou@realtek.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