From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3DF9FC77B73 for ; Tue, 30 May 2023 13:36:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232501AbjE3Ngl (ORCPT ); Tue, 30 May 2023 09:36:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232467AbjE3Ngk (ORCPT ); Tue, 30 May 2023 09:36:40 -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 DBCADA1 for ; Tue, 30 May 2023 06:36:39 -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 1q3zWV-0007td-W5; Tue, 30 May 2023 15:36:28 +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 1q3zWV-003t9S-0a; Tue, 30 May 2023 15:36:27 +0200 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1q3zWU-009W3q-Cp; Tue, 30 May 2023 15:36:26 +0200 Date: Tue, 30 May 2023 15:36:23 +0200 From: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= To: Mark Brown , Matthias Brugger Cc: AngeloGioacchino Del Regno , linux-mediatek@lists.infradead.org, kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org, linux-spi@vger.kernel.org Subject: Re: [PATCH v2 1/3] spi: mt65xx: Properly handle failures in .remove() Message-ID: <20230530133623.w5icilpjef22d4ks@pengutronix.de> References: <20230530081648.2199419-1-u.kleine-koenig@pengutronix.de> <20230530081648.2199419-2-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="bwoxo3tg2d22j34r" Content-Disposition: inline In-Reply-To: <20230530081648.2199419-2-u.kleine-koenig@pengutronix.de> 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-spi@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org --bwoxo3tg2d22j34r Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello, On Tue, May 30, 2023 at 10:16:46AM +0200, Uwe Kleine-K=F6nig wrote: > Returning an error code in a platform driver's remove function is wrong > most of the time and there is an effort to make the callback return > void. To prepare this rework the function not to exit early. >=20 > There wasn't a real problem because if pm runtime resume failed the only > step missing was pm_runtime_disable() which isn't an issue. >=20 > Signed-off-by: Uwe Kleine-K=F6nig I just noticed there is a patch in next that conflicts with that one. My merge resolution looks as follows: diff --cc drivers/spi/spi-mt65xx.c index 17162c8661b4,9333a0e8204d..000000000000 --- a/drivers/spi/spi-mt65xx.c +++ b/drivers/spi/spi-mt65xx.c @@@ -1276,18 -1275,21 +1276,24 @@@ static int mtk_spi_remove(struct platfo struct mtk_spi *mdata =3D spi_master_get_devdata(master); int ret; =20 + if (mdata->use_spimem && !completion_done(&mdata->spimem_done)) + complete(&mdata->spimem_done); + - ret =3D pm_runtime_resume_and_get(&pdev->dev); - if (ret < 0) - return ret; + ret =3D pm_runtime_get_sync(&pdev->dev); + if (ret < 0) { + dev_warn(&pdev->dev, "Failed to resume hardware (%pe)\n", ERR_PTR(ret)); + } else { + /* + * If pm runtime resume failed, clks are disabled and + * unprepared. So don't access the hardware and skip clk + * unpreparing. + */ + mtk_spi_reset(mdata); =20 - mtk_spi_reset(mdata); -=20 - if (mdata->dev_comp->no_need_unprepare) { - clk_unprepare(mdata->spi_clk); - clk_unprepare(mdata->spi_hclk); + if (mdata->dev_comp->no_need_unprepare) { + clk_unprepare(mdata->spi_clk); + clk_unprepare(mdata->spi_hclk); + } } =20 pm_runtime_put_noidle(&pdev->dev); If it's too complicated to apply, I can resend a rebased version. After that the other two patches apply just fine. Best regards Uwe --=20 Pengutronix e.K. | Uwe Kleine-K=F6nig | Industrial Linux Solutions | https://www.pengutronix.de/ | --bwoxo3tg2d22j34r Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEP4GsaTp6HlmJrf7Tj4D7WH0S/k4FAmR1+9YACgkQj4D7WH0S /k4xswgAqR9LBvO5+sHk8YAxf68ZmSMUmt0HsbjXSpNc75gb9KXMn9Rw6NEobbAH ZOQJT0KxdchxeApsGJCHs4RCL7GsNemNmcmovVyUhXEUjn+UB9+AX9W4twqLTL8v qAypJ5WOHUhJT00kF0TDYSuYUeU/US7niuIYdE7B+PD/b8wWp0AI/8x5ZqlrayPn HBTPuB8310FaLtD5D4AfWZ4KuqX6Swl6UBC98hsGEU6oMgNKME5y3SR6FN0SB7/T P9eyIAP85vd6R7IzQhcquiLhZ/MlnQCjNLviA1jHfEtBxhAs5hP+Qd6FNmmsL4O4 /a1uq+ITwM9y9dXbps7YQ05jAZWCrQ== =L/Gt -----END PGP SIGNATURE----- --bwoxo3tg2d22j34r-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 73AB3C77B7A for ; Tue, 30 May 2023 13:37:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: In-Reply-To:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Reply-To:Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=SMbdqfbJld35v6W4Oa4428Dag7PpGTlXOvR0BX2FgWQ=; b=N1yFZqJ9l+aH2kZmaLzoFjZPkj rynpreO36sboFPsEuYljMOlCjP86NJlgdPD2HCW7CH+GfE/8nIJYtlHEgZggtfW2DdcY1GRRCyV56 HGhNl4viXrbe+lar7NQBkMEaXtLbX4aTJtlEYeRB0FlooZGpk9mQMcrXl0BXWNwZ5jtl3SZG1JH4H zx5JQorLkPH7K/DylaSNGJSozBd5EY2GmIPs91l+Cz54dnwtHsnLwrGvc6mYbfVy5ZwrpPsAuAs4Z Mac4nIJDxg1YUnyIwLt1flwJXGFuCtOhbJjZlrMRH2t0EbNmrsdyWwoRH5/t3aot/eapH9Rz9R3yv U5I7d4HQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q3zWi-00E45V-25; Tue, 30 May 2023 13:36:40 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q3zWe-00E44C-2t for linux-arm-kernel@lists.infradead.org; Tue, 30 May 2023 13:36:38 +0000 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 1q3zWV-0007td-W5; Tue, 30 May 2023 15:36:28 +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 1q3zWV-003t9S-0a; Tue, 30 May 2023 15:36:27 +0200 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1q3zWU-009W3q-Cp; Tue, 30 May 2023 15:36:26 +0200 Date: Tue, 30 May 2023 15:36:23 +0200 From: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= To: Mark Brown , Matthias Brugger Cc: AngeloGioacchino Del Regno , linux-mediatek@lists.infradead.org, kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org, linux-spi@vger.kernel.org Subject: Re: [PATCH v2 1/3] spi: mt65xx: Properly handle failures in .remove() Message-ID: <20230530133623.w5icilpjef22d4ks@pengutronix.de> References: <20230530081648.2199419-1-u.kleine-koenig@pengutronix.de> <20230530081648.2199419-2-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 In-Reply-To: <20230530081648.2199419-2-u.kleine-koenig@pengutronix.de> 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-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230530_063636_962361_B7ECD4B6 X-CRM114-Status: GOOD ( 22.26 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============1271524844233586366==" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org --===============1271524844233586366== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="bwoxo3tg2d22j34r" Content-Disposition: inline --bwoxo3tg2d22j34r Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello, On Tue, May 30, 2023 at 10:16:46AM +0200, Uwe Kleine-K=F6nig wrote: > Returning an error code in a platform driver's remove function is wrong > most of the time and there is an effort to make the callback return > void. To prepare this rework the function not to exit early. >=20 > There wasn't a real problem because if pm runtime resume failed the only > step missing was pm_runtime_disable() which isn't an issue. >=20 > Signed-off-by: Uwe Kleine-K=F6nig I just noticed there is a patch in next that conflicts with that one. My merge resolution looks as follows: diff --cc drivers/spi/spi-mt65xx.c index 17162c8661b4,9333a0e8204d..000000000000 --- a/drivers/spi/spi-mt65xx.c +++ b/drivers/spi/spi-mt65xx.c @@@ -1276,18 -1275,21 +1276,24 @@@ static int mtk_spi_remove(struct platfo struct mtk_spi *mdata =3D spi_master_get_devdata(master); int ret; =20 + if (mdata->use_spimem && !completion_done(&mdata->spimem_done)) + complete(&mdata->spimem_done); + - ret =3D pm_runtime_resume_and_get(&pdev->dev); - if (ret < 0) - return ret; + ret =3D pm_runtime_get_sync(&pdev->dev); + if (ret < 0) { + dev_warn(&pdev->dev, "Failed to resume hardware (%pe)\n", ERR_PTR(ret)); + } else { + /* + * If pm runtime resume failed, clks are disabled and + * unprepared. So don't access the hardware and skip clk + * unpreparing. + */ + mtk_spi_reset(mdata); =20 - mtk_spi_reset(mdata); -=20 - if (mdata->dev_comp->no_need_unprepare) { - clk_unprepare(mdata->spi_clk); - clk_unprepare(mdata->spi_hclk); + if (mdata->dev_comp->no_need_unprepare) { + clk_unprepare(mdata->spi_clk); + clk_unprepare(mdata->spi_hclk); + } } =20 pm_runtime_put_noidle(&pdev->dev); If it's too complicated to apply, I can resend a rebased version. After that the other two patches apply just fine. Best regards Uwe --=20 Pengutronix e.K. | Uwe Kleine-K=F6nig | Industrial Linux Solutions | https://www.pengutronix.de/ | --bwoxo3tg2d22j34r Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEP4GsaTp6HlmJrf7Tj4D7WH0S/k4FAmR1+9YACgkQj4D7WH0S /k4xswgAqR9LBvO5+sHk8YAxf68ZmSMUmt0HsbjXSpNc75gb9KXMn9Rw6NEobbAH ZOQJT0KxdchxeApsGJCHs4RCL7GsNemNmcmovVyUhXEUjn+UB9+AX9W4twqLTL8v qAypJ5WOHUhJT00kF0TDYSuYUeU/US7niuIYdE7B+PD/b8wWp0AI/8x5ZqlrayPn HBTPuB8310FaLtD5D4AfWZ4KuqX6Swl6UBC98hsGEU6oMgNKME5y3SR6FN0SB7/T P9eyIAP85vd6R7IzQhcquiLhZ/MlnQCjNLviA1jHfEtBxhAs5hP+Qd6FNmmsL4O4 /a1uq+ITwM9y9dXbps7YQ05jAZWCrQ== =L/Gt -----END PGP SIGNATURE----- --bwoxo3tg2d22j34r-- --===============1271524844233586366== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --===============1271524844233586366==--