Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp6598149rwl; Thu, 29 Dec 2022 16:19:14 -0800 (PST) X-Google-Smtp-Source: AMrXdXtlalk4nlFUG7Yvkwru00+Ue48MAz1vssqIvDO+sBErF/Lo7H3MC6OD3yqypFHdfXuoqgMd X-Received: by 2002:a17:907:c242:b0:7c1:9e6:d38e with SMTP id tj2-20020a170907c24200b007c109e6d38emr30463255ejc.67.1672359554525; Thu, 29 Dec 2022 16:19:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672359554; cv=none; d=google.com; s=arc-20160816; b=BAZ91bVEM3k97h6ebGLgg0mqhohYZYD7WAciVef0Flwt9j6SAMsZKUsJKqnC2jg9x2 rVx0uPQ1KTC4uxk7QY7VgOLfUZr5rBTFziGHLWOLp2HqW9mkFx1DXMr6CaiteOFMn336 VlSt8KCkDp3n1AprWa6bxLZqyleXZovXSJPkcWR24VKcuCD2kZn6x/TPTvdDm5thCoLv u7paCF8PaiffX7Kh5OTo3zm3oWAT5d4U3kPhuihl1NNOk1qjkOHk5xNjCIxJ1PBIts6g Y3nWvAMwS0GngG9Uc83vhbhwpRjy+794q+iEvMKWHywS+M3VtWbuDY6s6b/OoquDdxD0 bNtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=MY80IPGOHseZwU3jy+X7Hc+4WbY+tpWCLdGp5MHIF9A=; b=qfxWITgle4T3GzpQrH3cr8oV/r9dEDtmbKTOY3l3KIOeErms/GmN+24x0Mpchcr4p4 BeVoaEVnyiHndKQPyuu8NA0Ua56H0JkCaqcak0JtHubsRhZk7DRH8OeyruFYXdYDAIYO RrTuEJkEMd83GcgKbJg/80HNtUIQEqh3ps9NTrK7MDAj+dOaRaRkZBB+YmdxGCnrJdpW igOekbGdvxMmGDOGnRGMnWi62oRXjAHJBi3kn9B4XcZ9M6kE9lC29dEDjjWbOgd+o3wZ zuDcCq6cmOPsD5YOfgUFzxfF8xsmejj/UFj5VY0fnMA5zUtElhSaVEzefit+zRMdCcDO C+yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=aIOb2r56; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hu9-20020a170907a08900b007c18ffbf16esi16388600ejc.433.2022.12.29.16.18.54; Thu, 29 Dec 2022 16:19:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=aIOb2r56; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234141AbiL3AFM (ORCPT + 62 others); Thu, 29 Dec 2022 19:05:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229712AbiL3AFK (ORCPT ); Thu, 29 Dec 2022 19:05:10 -0500 Received: from mail-yb1-xb31.google.com (mail-yb1-xb31.google.com [IPv6:2607:f8b0:4864:20::b31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C79F717422 for ; Thu, 29 Dec 2022 16:05:08 -0800 (PST) Received: by mail-yb1-xb31.google.com with SMTP id 186so22124963ybe.8 for ; Thu, 29 Dec 2022 16:05:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=MY80IPGOHseZwU3jy+X7Hc+4WbY+tpWCLdGp5MHIF9A=; b=aIOb2r56Q9IgfEdqFJ4U45V4/U5Cztm9EvswQML3beHvxgG1s62Cp6vzoIHvGs9JBT mFPVdCMKxTm/IgNdsLIFVS34mK5r5NhVVZAU5B6WuSMQSvjQst3chNrtTIH08QiECsGS 7ETUxJoEh5gPAIGzzOCOMYg9umV5rKvnwAcP2NjlMMYb19NygfafJ+4NTt/t0JCc/E6w VjzBRlZWPT0CiXVAW1sf2mOhCPzCwT6gvFpikugKp1a6Xayd2HpZrfSvqW2o8IdCKBhS Bz8Z4rn9YU07UXrf3e4jGlMyyC5IKRcS6oeMpeNoBWrGpiIKYADkrcNbNSllusDZvjEt qHkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MY80IPGOHseZwU3jy+X7Hc+4WbY+tpWCLdGp5MHIF9A=; b=l68Qe1Yz1CWUTyoospPQeEC4rlbp37CIpPTakJ9Ei5EEWp/XNjOIkVU0pzmLes89hJ 7DTLckBJcDwoTTsVx/giHlNubsI4NxGVPux7teqNEAWQcM7jIrrp7IbvymWAPx2lNGl1 JA7aLmIkWq6K33d2ylB92gQ/jpFlotOiqOIjCtA52pa+LoiSxbKk0yAL7DywbaQ9Hx5h 0vX6eyTL+3WNR0aWojKat8+w1knralH7DV1xdC2ZWgm+Hu2i1gDPXsSqB1kfbpwvAG3L NazthASqb9V5aMfE9EGuTaCNhLy/esxCFo5a3Ni9vaIOT1TmxrKDLWImmwKbQYcWzQRJ gRUw== X-Gm-Message-State: AFqh2kqt9TLzLiR3zUsQ846WVsijh7v48U32jLsXA1xOPcKLXrtmIEHy KbFKRQwZ49BbMRsf435c8WUftgaoIVW0GYSx8Yffeg== X-Received: by 2002:a05:6902:13cc:b0:75f:65da:a046 with SMTP id y12-20020a05690213cc00b0075f65daa046mr3289405ybu.357.1672358707981; Thu, 29 Dec 2022 16:05:07 -0800 (PST) MIME-Version: 1.0 References: <20221221200513.676744-1-nfrayer@baylibre.com> <66ef2f70-9405-fe09-7927-143084286d1b@gmail.com> In-Reply-To: <66ef2f70-9405-fe09-7927-143084286d1b@gmail.com> From: Nicolas Frayer Date: Fri, 30 Dec 2022 01:04:57 +0100 Message-ID: Subject: Re: [PATCH] soc: ti: k3-ringacc: Add try_module_get() to k3_dmaring_request_dual_ring() To: =?UTF-8?Q?P=C3=A9ter_Ujfalusi?= Cc: nm@ti.com, ssantosh@kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, grygorii.strashko@ti.com, khilman@baylibre.com, mkorpershoek@baylibre.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le sam. 24 d=C3=A9c. 2022 =C3=A0 23:01, P=C3=A9ter Ujfalusi a =C3=A9crit : > > Hi Nicolas, > > On 21/12/2022 22:05, Nicolas Frayer wrote: > > When the k3 ring accelerator driver has been modified to add module bui= ld > > support, try_module_get() and module_put() have been added to update th= e > > 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 a= s module") > Reviewed-by: Peter Ujfalusi > > > > > Signed-off-by: Nicolas Frayer > > --- > > 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 =3D -EINVAL; > > + goto err_module_get; > > + } > > + > > if (test_bit(fwd_id, ringacc->rings_inuse)) { > > ret =3D -EBUSY; > > goto error; > > @@ -421,6 +426,8 @@ static int k3_dmaring_request_dual_ring(struct k3_r= ingacc *ringacc, int fwd_id, > > return 0; > > > > error: > > + module_put(ringacc->dev->driver->owner); > > +err_module_get: > > mutex_unlock(&ringacc->req_lock); > > return ret; > > } > > -- > P=C3=A9ter Thanks Peter, I'll send a v2 with the tags.