All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: manivannan.sadhasivam@oss.qualcomm.com
Cc: Bjorn Andersson <andersson@kernel.org>,
	Konrad Dybcio <konradybcio@kernel.org>,
	Abel Vesa <abel.vesa@linaro.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	Manivannan Sadhasivam <mani@kernel.org>,
	"James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-mmc@vger.kernel.org, linux-scsi@vger.kernel.org,
	Sumit Garg <sumit.garg@oss.qualcomm.com>,
	stable@vger.kernel.org, Abel Vesa <abel.vesa@oss.qualcomm.com>
Subject: Re: [PATCH v2 1/4] soc: qcom: ice: Remove platform_driver support and expose as a pure library
Date: Thu, 12 Feb 2026 17:02:53 -0800	[thread overview]
Message-ID: <20260213010253.GA6208@quark> (raw)
In-Reply-To: <20260210-qcom-ice-fix-v2-1-9c1ab5d6502c@oss.qualcomm.com>

On Tue, Feb 10, 2026 at 12:26:50PM +0530, Manivannan Sadhasivam via B4 Relay wrote:
>  drivers/soc/qcom/ice.c | 118 ++++++++++++++++++-------------------------------
>  1 file changed, 44 insertions(+), 74 deletions(-)

I don't yet know enough to be confident that this is the correct fix,
but there are a few things I noticed that look like bugs:

> +static DEFINE_MUTEX(ice_mutex);
> +struct qcom_ice *ice_handle;

ice_handle is used only in this file, so it should be static

> @@ -643,41 +645,42 @@ static struct qcom_ice *of_qcom_ice_get(struct device *dev)
[...]
> +	ice = qcom_ice_create(&pdev->dev, base);
> +	if (IS_ERR(ice)) {
>  		platform_device_put(pdev);
> -		ice = ERR_PTR(-EINVAL);
> +		return ice_handle;
>  	}

This error path returns NULL, where this patch seems to have been
intended to remove NULL as a possible return value.

> -static void qcom_ice_put(const struct qcom_ice *ice)
> +static void qcom_ice_put(struct kref *kref)
>  {
> -	struct platform_device *pdev = to_platform_device(ice->dev);
> -
> -	if (!platform_get_resource_byname(pdev, IORESOURCE_MEM, "ice"))
> -		platform_device_put(pdev);
> +	platform_device_put(to_platform_device(ice_handle->dev));
> +	ice_handle = NULL;
>  }

Elsewhere ice_handle is protected by ice_mutex, but this seems to modify
it without holding the mutex.

I'm also wondering what happens if all consumer devices are removed.
platform_device_put() gets executed on the ICE platform_device for each
one, but does that actually drop the last reference and cause the
resources allocated with devm_*() to be freed?  On do they stick around
until/unless the ICE device is actually removed as well?

>  static void devm_of_qcom_ice_put(struct device *dev, void *res)
>  {
> -	qcom_ice_put(*(struct qcom_ice **)res);
> +	const struct qcom_ice *ice = *(struct qcom_ice **)res;
> +	struct platform_device *pdev = to_platform_device(ice->dev);
> +
> +	if (!platform_get_resource_byname(pdev, IORESOURCE_MEM, "ice"))
> +		kref_put(&ice_handle->refcount, qcom_ice_put);
>  }

Above probably should use the ice local variable, not ice_handle.

- Eric

  parent reply	other threads:[~2026-02-13  1:02 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-10  6:56 [PATCH v2 0/4] soc: qcom: ice: Remove platform_driver support and expose as a pure library Manivannan Sadhasivam
2026-02-10  6:56 ` Manivannan Sadhasivam via B4 Relay
2026-02-10  6:56 ` [PATCH v2 1/4] " Manivannan Sadhasivam
2026-02-10  6:56   ` Manivannan Sadhasivam via B4 Relay
2026-02-10  9:39   ` Konrad Dybcio
2026-02-10 12:08     ` Abel Vesa
2026-02-10 12:19     ` Manivannan Sadhasivam
2026-02-12 12:05       ` Konrad Dybcio
2026-02-13  1:02   ` Eric Biggers [this message]
2026-02-13  2:17     ` Manivannan Sadhasivam
2026-02-10  6:56 ` [PATCH v2 2/4] soc: qcom: ice: Return proper error codes from devm_of_qcom_ice_get() instead of NULL Manivannan Sadhasivam
2026-02-10  6:56   ` Manivannan Sadhasivam via B4 Relay
2026-02-10  9:32   ` Konrad Dybcio
2026-02-10  6:56 ` [PATCH v2 3/4] mmc: sdhci-msm: Remove NULL check from devm_of_qcom_ice_get() Manivannan Sadhasivam
2026-02-10  6:56   ` Manivannan Sadhasivam via B4 Relay
2026-02-10  8:37   ` Adrian Hunter
2026-02-10  9:32   ` Konrad Dybcio
2026-02-10 15:23   ` Ulf Hansson
2026-02-10  6:56 ` [PATCH v2 4/4] scsi: ufs: ufs-qcom: " Manivannan Sadhasivam
2026-02-10  6:56   ` Manivannan Sadhasivam via B4 Relay
2026-02-10  9:32   ` Konrad Dybcio
2026-02-10 13:43 ` [PATCH v2 0/4] soc: qcom: ice: Remove platform_driver support and expose as a pure library Ulf Hansson
2026-02-10 13:54   ` Manivannan Sadhasivam

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=20260213010253.GA6208@quark \
    --to=ebiggers@kernel.org \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=abel.vesa@linaro.org \
    --cc=abel.vesa@oss.qualcomm.com \
    --cc=adrian.hunter@intel.com \
    --cc=andersson@kernel.org \
    --cc=konradybcio@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mani@kernel.org \
    --cc=manivannan.sadhasivam@oss.qualcomm.com \
    --cc=martin.petersen@oracle.com \
    --cc=stable@vger.kernel.org \
    --cc=sumit.garg@oss.qualcomm.com \
    --cc=ulf.hansson@linaro.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.