Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp5392753rwb; Tue, 1 Aug 2023 01:34:10 -0700 (PDT) X-Google-Smtp-Source: APBJJlGUnur0Hs2YXjDQkm5y2bz+E9Igj0QuSzCRIXhR6DJlWk+mgHVkdE8ShL9Iy2AM9h+SJlSN X-Received: by 2002:a17:906:30d7:b0:994:55ce:1630 with SMTP id b23-20020a17090630d700b0099455ce1630mr1681894ejb.42.1690878850024; Tue, 01 Aug 2023 01:34:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690878850; cv=none; d=google.com; s=arc-20160816; b=jN4V6LNMXts7PLrjhK7hAzAKxxAbi6KAeLnH5dzy5lXvas7lC4r/hqB8Dwy1ldJkuX YCgtrupPYogEJkMsYzYZoZRxfUMASvKJAmSt7H240C5A0iNx+qf56LLHday/ZizXQGES /Ht6UGfnZPkcadMe7G+gHSiVkem1Q+hPrfk2nn+oee0HiQEWjdVeF2EVZlW7llB+qATf /OCT4NiZuywiiQCXVn77Q+4Pb4juSR6ZfxQTsPkkgVGvZgyI8+crKJUneMalbnHwhtAY 9VDLwL1keKcLeSxmfmumM7p8nBdxE/BEaWDLxspJAQcMyFv28A69DmhkwokKfRzosn7U DOcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=ou38wRyGp/pvAg+Rh/8C8Gl5rKL/bAcr9EFmhUDgd9g=; fh=Y5zt6SB0QUlRs06Pi4J/tPu7T4K60hLP7fCoD/URMMY=; b=zUjpQhG8gpkvwSePaVdL+gE0T7vMLMVKekEXHLV2smYSV1vmEJxPSNAeZvRR1S0YLB X9ke9l0SJXz0xj0Pjg7ba9os6eofKrs4QqfCBE7P7UwFol0u+PsG/ygEqPLIfYkqyrnW QH0TFgWkwt9wKLpTAV3bgD8NMBmIvStHwBGzyusDll/3UHV9luGQD1toxYWJnTaUKxG4 LIzsOKQ+YdsHSN4sW6qrWyuaDyULUNshtk+HctKQOsdD+HK6D/8W3zyEomfAyNmE3yPO zxoLmlk9CuvVUNfI8cKzvPmzyBmFfTmA+Lq0Uzx+d++fGWnPwsmL0Wm8ClGeoLImpeEX wEVQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-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 qt10-20020a170906ecea00b00992b75d594csi8640962ejb.317.2023.08.01.01.33.41; Tue, 01 Aug 2023 01:34:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231893AbjHAIOm (ORCPT + 99 others); Tue, 1 Aug 2023 04:14:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232163AbjHAIOc (ORCPT ); Tue, 1 Aug 2023 04:14:32 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE5B5268F for ; Tue, 1 Aug 2023 01:14:18 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qQkWC-0006Al-Jf; Tue, 01 Aug 2023 10:14:12 +0200 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1qQkWA-000L8P-BY; Tue, 01 Aug 2023 10:14:10 +0200 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1qQkW9-009Zxh-CS; Tue, 01 Aug 2023 10:14:09 +0200 Date: Tue, 1 Aug 2023 10:14:08 +0200 From: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= To: Gaurav Jain Cc: Horia Geanta , Pankaj Gupta , Herbert Xu , "David S. Miller" , "linux-crypto@vger.kernel.org" , "kernel@pengutronix.de" Subject: Re: [EXT] [PATCH] crypto: caam/jr - Convert to platform remove callback returning void Message-ID: <20230801081408.nbu6j7srg5mt7sbj@pengutronix.de> References: <20230726075938.448673-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="bungxktlem4uxc2u" Content-Disposition: inline In-Reply-To: X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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-crypto@vger.kernel.org --bungxktlem4uxc2u Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello Gaurav, On Mon, Jul 31, 2023 at 09:56:22AM +0000, Gaurav Jain wrote: > > -----Original Message----- > > From: Uwe Kleine-K=F6nig > > Sent: Wednesday, July 26, 2023 1:30 PM > > To: Horia Geanta ; Pankaj Gupta > > ; Gaurav Jain ; Herbert Xu > > ; David S. Miller > > Cc: linux-crypto@vger.kernel.org; kernel@pengutronix.de > > Subject: [EXT] [PATCH] crypto: caam/jr - Convert to platform remove cal= lback > > returning void > >=20 > > Caution: This is an external email. Please take care when clicking link= s or > > opening attachments. When in doubt, report the message using the 'Repor= t this > > email' button > >=20 > >=20 > > The .remove() callback for a platform driver returns an int which makes= many > > driver authors wrongly assume it's possible to do error handling by ret= urning an > > error code. However the value returned is (mostly) ignored and this typ= ically > > results in resource leaks. To improve here there is a quest to make the= remove > > callback return void. In the first step of this quest all drivers are c= onverted > > to .remove_new() which already returns void. > >=20 > > The driver adapted here suffers from this wrong assumption. Returning -= EBUSY > > if there are still users results in resource leaks and probably a crash= =2E Also further > > down passing the error code of caam_jr_shutdown() to the caller only re= sults in > > another error message and has no further consequences compared to retur= ning > > zero. > >=20 > > Still convert the driver to return no value in the remove callback. Thi= s also allows > > to drop caam_jr_platform_shutdown() as the only function called by it n= ow has > > the same prototype. > >=20 > > Signed-off-by: Uwe Kleine-K=F6nig > > --- > > Hello, > >=20 > > note that the problems described above and in the extended comment isn't > > introduced by this patch. It's as old as > > 313ea293e9c4d1eabcaddd2c0800f083b03c2a2e at least. > >=20 > > Also orthogonal to this patch I wonder about the use of a shutdown call= back. > > What makes this driver special to require extra handling at shutdown ti= me? > >=20 > > Best regards > > Uwe > >=20 > > drivers/crypto/caam/jr.c | 22 +++++++++------------- > > 1 file changed, 9 insertions(+), 13 deletions(-) > >=20 > > diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c index > > 96dea5304d22..66b1eb3eb4a4 100644 > > --- a/drivers/crypto/caam/jr.c > > +++ b/drivers/crypto/caam/jr.c > > @@ -162,7 +162,7 @@ static int caam_jr_shutdown(struct device *dev) > > return ret; > > } > >=20 > > -static int caam_jr_remove(struct platform_device *pdev) > > +static void caam_jr_remove(struct platform_device *pdev) > > { > > int ret; > > struct device *jrdev; > > @@ -175,11 +175,14 @@ static int caam_jr_remove(struct platform_device > > *pdev) > > caam_rng_exit(jrdev->parent); > >=20 > > /* > > - * Return EBUSY if job ring already allocated. > > + * If a job ring is still allocated there is trouble ahead. Once > > + * caam_jr_remove() returned, jrpriv will be freed and the regi= sters > > + * will get unmapped. So any user of such a job ring will proba= bly > > + * crash. > > */ > > if (atomic_read(&jrpriv->tfm_count)) { > > - dev_err(jrdev, "Device is busy\n"); > > - return -EBUSY; > > + dev_warn(jrdev, "Device is busy, fasten your seat belts= , a crash is ahead.\n"); > > Changes are ok. Can you improve the error message or keep it same. What do you imagine here? "Device is busy" lacks urgency in my eyes and is hard to rate by a log reader. Mentioning that something bad is about to happen would be good. Do you want it expressed in a more serious way? Something like: Device is busy; consumers might start to crash ? Best regards Uwe --=20 Pengutronix e.K. | Uwe Kleine-K=F6nig | Industrial Linux Solutions | https://www.pengutronix.de/ | --bungxktlem4uxc2u Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEP4GsaTp6HlmJrf7Tj4D7WH0S/k4FAmTIvtAACgkQj4D7WH0S /k7sgAgAmpIC9rqvyLJDE+0R3GRTWXB8CEjbQOoZBQ/h/F/k5qsebXz2oE4VVo+N XzNQzVbHOCNGJltpPsbr3pNRwjS/llfk3GZGE4Mb/qZvRfM6OWG67qv1dnf8Eu9o kwUz1QaccDsU6yqDVoM0s5s5RIBFnBjT3hyAKUaqf6RbzbW4kDgz6xXnuySdWKfw 9VZ1yJ4nr3/GMktWELhID+W5356L5c9ElmcPl/4wux1msDmPHAjkkMN9tOy31pCg tIFLqppxy9LYbkShdYEUrrujb6vgqxlQwGR683sqVmFDgkMFQcrrcGh9NDHV4JmN bgAw7uuWbsy7WAWgDos1cLF29Gvwxg== =Pz5c -----END PGP SIGNATURE----- --bungxktlem4uxc2u--