mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Péter Ujfalusi" <peter.ujfalusi@gmail.com>
To: Nicolas Frayer <nfrayer@baylibre.com>, nm@ti.com, ssantosh@kernel.org
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, grygorii.strashko@ti.com,
	khilman@baylibre.com, mkorpershoek@baylibre.com
Subject: Re: [PATCH] soc: ti: k3-ringacc: Add try_module_get() to k3_dmaring_request_dual_ring()
Date: Sun, 25 Dec 2022 00:03:38 +0200	[thread overview]
Message-ID: <66ef2f70-9405-fe09-7927-143084286d1b@gmail.com> (raw)
In-Reply-To: <20221221200513.676744-1-nfrayer@baylibre.com>

Hi Nicolas,

On 21/12/2022 22:05, Nicolas Frayer wrote:
> When the k3 ring accelerator driver has been modified to add module build
> support, try_module_get() and module_put() have been added to update the
> module refcnt. One code path has not been updated and it has introduced
> an issue where the refcnt is decremented by module_put() in
> k3_ringacc_ring_free() without being incremented previously.
> Adding try_module_get() to k3_dmaring_request_dual_ring() ensures the
> refcnt is kept up to date.

Good catch!
I had never had my hands on a device with DMSS (BCDMA/PKDMA) and the
original module support was developed and tested on devices with UDMA.

can you add the fixes tag along with my reviewed by tag?

Fixes: c07f216a8b72 ("soc: ti: k3-ringacc: Allow the driver to be built as module")
Reviewed-by: Peter Ujfalusi <peter.ujfalusi@gmail.com>

> 
> Signed-off-by: Nicolas Frayer <nfrayer@baylibre.com>
> ---
>   drivers/soc/ti/k3-ringacc.c | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/soc/ti/k3-ringacc.c b/drivers/soc/ti/k3-ringacc.c
> index e01e4d815230a..8f131368a7586 100644
> --- a/drivers/soc/ti/k3-ringacc.c
> +++ b/drivers/soc/ti/k3-ringacc.c
> @@ -406,6 +406,11 @@ static int k3_dmaring_request_dual_ring(struct k3_ringacc *ringacc, int fwd_id,
>   
>   	mutex_lock(&ringacc->req_lock);
>   
> +	if (!try_module_get(ringacc->dev->driver->owner)) {
> +		ret = -EINVAL;
> +		goto err_module_get;
> +	}
> +
>   	if (test_bit(fwd_id, ringacc->rings_inuse)) {
>   		ret = -EBUSY;
>   		goto error;
> @@ -421,6 +426,8 @@ static int k3_dmaring_request_dual_ring(struct k3_ringacc *ringacc, int fwd_id,
>   	return 0;
>   
>   error:
> +	module_put(ringacc->dev->driver->owner);
> +err_module_get:
>   	mutex_unlock(&ringacc->req_lock);
>   	return ret;
>   }

-- 
Péter

  reply	other threads:[~2022-12-24 22:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-21 20:05 Nicolas Frayer
2022-12-24 22:03 ` Péter Ujfalusi [this message]
2022-12-30  0:04   ` Nicolas Frayer

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=66ef2f70-9405-fe09-7927-143084286d1b@gmail.com \
    --to=peter.ujfalusi@gmail.com \
    --cc=grygorii.strashko@ti.com \
    --cc=khilman@baylibre.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkorpershoek@baylibre.com \
    --cc=nfrayer@baylibre.com \
    --cc=nm@ti.com \
    --cc=ssantosh@kernel.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 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®