mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Wang <peter.wang@mediatek.com>
To: Xiangwu Lai <laixiangwu@cmss.chinamobile.com>,
	<chaotian.jing@mediatek.com>
Cc: <chu.stanley@gmail.com>, <alim.akhtar@samsung.com>,
	<bvanassche@acm.org>, <stanley.chu@mediatek.com>,
	<sashiko-bot@kernel.org>, <linux-scsi@vger.kernel.org>,
	<linux-mediatek@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 1/2] scsi: ufs-mediatek: use devm_regulator_get() for the va09 regulator
Date: Thu, 19 Nov 2026 11:54:29 +0800	[thread overview]
Message-ID: <403821fa1be0c7ec5c0b2c0235957bfa9818fd7e.camel@mediatek.com> (raw)
In-Reply-To: <20261118032015.974-2-laixiangwu@cmss.chinamobile.com>

On Wed, 2026-11-18 at 11:20 +0800, Xiangwu Lai wrote:
> ufs_mtk_init_va09_pwr_ctrl() obtains the va09 regulator with
> regulator_get() but the reference is never released with
> regulator_put(), neither on driver unbind nor on probe failure. The
> other regulators handled by this driver (dvfsrc-vcore) are already
> obtained with devm_regulator_get_optional().
> 
> Use devm_regulator_get() so that the reference is released
> automatically when the UFS device is detached.
> 
> This alone is not enough, though: ufs_mtk_init() powers the M-PHY on,
> which enables the va09 regulator, and nothing powers it off again on
> the way out -- the variant operations have no .exit callback and
> ufshcd_pltfrm_remove() only resumes the device.  The devm release
> would then hit WARN_ON(regulator->enable_count) in _regulator_put()
> and leak the enable reference.
> 
> Balance the use count by adding an .exit callback which powers the
> M-PHY off, in the same spirit as the .exit callbacks of ufs-exynos
> and ufs-qcom.  ufshcd_hba_exit() invokes it both on driver unbind and
> on ufshcd_init() failure after the variant init, so the enable count
> is always balanced by the time devm releases the regulator.  It
> relies on the state tracking in ufs_mtk_mphy_power_on() and is a
> no-op if the M-PHY was never powered on.
> 
> Fixes: cf137b3ea49a ("scsi: ufs-mediatek: Support VA09 regulator
> operations")
> Signed-off-by: Xiangwu Lai <laixiangwu@cmss.chinamobile.com>
> ---

Hi Xiangwu,

Thanks for fix this bug.
Reviewed-by: Peter Wang <peter.wang@mediatek.com>



  reply	other threads:[~2026-11-19  3:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18  3:20 [PATCH v2 0/2] scsi: ufs-mediatek: fix va09 regulator lifecycle Xiangwu Lai
2026-11-18  3:20 ` [PATCH v2 1/2] scsi: ufs-mediatek: use devm_regulator_get() for the va09 regulator Xiangwu Lai
2026-11-19  3:54   ` Peter Wang [this message]
2026-11-18  3:20 ` [PATCH v2 2/2] scsi: ufs-mediatek: keep mphy state in sync when va09 disable fails Xiangwu Lai

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=403821fa1be0c7ec5c0b2c0235957bfa9818fd7e.camel@mediatek.com \
    --to=peter.wang@mediatek.com \
    --cc=alim.akhtar@samsung.com \
    --cc=bvanassche@acm.org \
    --cc=chaotian.jing@mediatek.com \
    --cc=chu.stanley@gmail.com \
    --cc=laixiangwu@cmss.chinamobile.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=sashiko-bot@kernel.org \
    --cc=stanley.chu@mediatek.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®