From patchwork Mon Nov 14 01:57:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 19508 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1915700wru; Sun, 13 Nov 2022 17:59:52 -0800 (PST) X-Google-Smtp-Source: AA0mqf4UTFecGPCmYQRL0sUo7RmCBk2xQE+EIC0DG7GkC5e8ctZ0JkZWvmU0353Unvrkuzlx/T/l X-Received: by 2002:aa7:d3da:0:b0:460:9994:1b9b with SMTP id o26-20020aa7d3da000000b0046099941b9bmr9207932edr.155.1668391192169; Sun, 13 Nov 2022 17:59:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668391192; cv=none; d=google.com; s=arc-20160816; b=lGXaFjsh8z/hT1XNzfqO32Mllp1Atu/z4JNP/6qTYX+T3UGEYpqUhHsIy84QUjWlLK B2aSd/LNolGZrYty29A3TFCODk3BbPvPsSIUA1btsSSxfhxD+adk4Wnwj0rgd3kLBLUs +wIiGdTkSVUA2w8zrz8/K1NxRCn+llEkKXdncq/5Mwq2EYUTydd2VMJzqaxIZef96BB5 0sB3jWRRQ3+YDS5vfl39VLS+s5rFPXCB8aoBX+U7Q5rYG6Z2Il0l3nDpsFPYsRJpOQnu ZDRRaW+akWSNqvb0+XCtEzDSO4DkLy1VqW5rv3fUWMSd0JaRpjQ88ud4E7NpwWfKUKWr KbKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=E9uIAIxUjiZh/NqdAFhxdQQd6pb0o+DNnALIZuHYHOs=; b=VmcUr1s7x1SUzx/Ne99CmxDDO2ibQ7tPUhIf6bPBfJOj91cPFxxihKmf//8QYFOUj8 f5k8hzQlGOiUzf/K3v30zkL8tGJokm4Nfis4+iuPz9yNXe9RzJ49+QCTBG5tONKNW8NY vayZLrMN7t66fZSF9uMgj0gHb241buJV2d5uFsRHiIKa8qptwJAvd8Fpg1cMRYJQS/Yh /MVYEs2GKV6SfbuO2YbZC2enZwVt5LHqHfXv/36mpXdplhCZT4+3x6eItHWd57deAo0u d+IG5yPIK9vlUnmorM6qk6FFPxzwmAIN0fxiOZjFDDP/uItzDcuPne+863GZhV6WWBK+ Ejbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sholland.org header.s=fm2 header.b="OfbZpT/d"; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=tKxDvCrO; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sholland.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o12-20020a170906860c00b007ae37a89b5bsi5633453ejx.601.2022.11.13.17.59.29; Sun, 13 Nov 2022 17:59:52 -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=@sholland.org header.s=fm2 header.b="OfbZpT/d"; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=tKxDvCrO; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sholland.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235431AbiKNB6K (ORCPT + 99 others); Sun, 13 Nov 2022 20:58:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235752AbiKNB57 (ORCPT ); Sun, 13 Nov 2022 20:57:59 -0500 Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 133DDDF7E for ; Sun, 13 Nov 2022 17:57:55 -0800 (PST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 982523200913; Sun, 13 Nov 2022 20:57:53 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Sun, 13 Nov 2022 20:57:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1668391073; x=1668477473; bh=E9 uIAIxUjiZh/NqdAFhxdQQd6pb0o+DNnALIZuHYHOs=; b=OfbZpT/d/nCucpY8If Ivz1X1vBDXH5hM0CnqfATv4F0RBYtu3ri+xhPjSNzqa6EVAS74FI5DGhJUnMeZtB prKBAR2MBPoqmVT0h+90mRc+Mu1HCp7lo+S4WWyP3Hhse8FXmWl0ZhSxLd1xiygS Kcw6lsupErjYf9B3lEZoF3wekUSWiO+qdPwoEPUzOxC/jaQPviZXpjIxJ3F3MBVl qdt0892WkXxgGonzlOIezXS6MtB5Na6rdMy4MhL7yPDRlkvEiPGNVeDOHoMbTDuR 43nLOPeS35A0oGcRhmY41jC5xCHygNqBuNOkZllpLGoiRWg/H1UrWsvyqqkqHMEw 9oCQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1668391073; x=1668477473; bh=E9uIAIxUjiZh/ NqdAFhxdQQd6pb0o+DNnALIZuHYHOs=; b=tKxDvCrOnkcyDpWUGhUNVe+DjapTA +CI67IjdnEL+FPgyZ+uw3EbJFtY/pOT+MinYhI+WcRatng9gUZE7vlKnux+wQ7Hs AbQy5u1cGG0s5lJ5ktUzKTYfDwgwaEJ7VUF0A0kLzCELBiZ2vNJVln3lnCRBfvn/ 5gJHzsxRzy86xshLtvXABOHKe0+VIe2NAMJU/VeMDwTFEj0PYYjbDvKo00M8o2tG Gof4nKZvZUn78y6SNqlcN/hRAUai/4lkRSIzQ2fk2TB3W6yt6anWZR5MRbO3DVqj mONBzyqyHlkLr8gIDvi6SUaxwCXBnPBvzaJpXnZRE0Mgc7WJJkfPHksuA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrgedugdegtdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtf frrghtthgvrhhnpedukeetueduhedtleetvefguddvvdejhfefudelgfduveeggeehgfdu feeitdevteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 13 Nov 2022 20:57:52 -0500 (EST) From: Samuel Holland To: Chen-Yu Tsai , Jernej Skrabec Cc: Ivaylo Dimitrov , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev, Andre Przywara , Samuel Holland Subject: [PATCH v3 1/3] bus: sunxi-rsb: Remove the shutdown callback Date: Sun, 13 Nov 2022 19:57:47 -0600 Message-Id: <20221114015749.28490-2-samuel@sholland.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221114015749.28490-1-samuel@sholland.org> References: <20221114015749.28490-1-samuel@sholland.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749434963007189238?= X-GMAIL-MSGID: =?utf-8?q?1749434963007189238?= Shutting down the RSB controller prevents communicating with a PMIC inside pm_power_off(), since that gets called after device_shutdown(), so it breaks system poweroff on some boards. Reported-by: Ivaylo Dimitrov Tested-by: Ivaylo Dimitrov Acked-by: Jernej Skrabec Fixes: 843107498f91 ("bus: sunxi-rsb: Implement suspend/resume/shutdown callbacks") Signed-off-by: Samuel Holland --- Changes in v3: - Adjust patch 1 commit message drivers/bus/sunxi-rsb.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/bus/sunxi-rsb.c b/drivers/bus/sunxi-rsb.c index 4cd2e127946e..17343cd75338 100644 --- a/drivers/bus/sunxi-rsb.c +++ b/drivers/bus/sunxi-rsb.c @@ -812,14 +812,6 @@ static int sunxi_rsb_remove(struct platform_device *pdev) return 0; } -static void sunxi_rsb_shutdown(struct platform_device *pdev) -{ - struct sunxi_rsb *rsb = platform_get_drvdata(pdev); - - pm_runtime_disable(&pdev->dev); - sunxi_rsb_hw_exit(rsb); -} - static const struct dev_pm_ops sunxi_rsb_dev_pm_ops = { SET_RUNTIME_PM_OPS(sunxi_rsb_runtime_suspend, sunxi_rsb_runtime_resume, NULL) @@ -835,7 +827,6 @@ MODULE_DEVICE_TABLE(of, sunxi_rsb_of_match_table); static struct platform_driver sunxi_rsb_driver = { .probe = sunxi_rsb_probe, .remove = sunxi_rsb_remove, - .shutdown = sunxi_rsb_shutdown, .driver = { .name = RSB_CTRL_NAME, .of_match_table = sunxi_rsb_of_match_table, From patchwork Mon Nov 14 01:57:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 19509 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1915828wru; Sun, 13 Nov 2022 18:00:08 -0800 (PST) X-Google-Smtp-Source: AA0mqf4WJqCrxyQf+y2UKWlENIILO+Dxe25cmCCrlNk9zFdwiYsxWV9FexMRqiZY5TrmfcxOdCPk X-Received: by 2002:aa7:d553:0:b0:458:f012:bacb with SMTP id u19-20020aa7d553000000b00458f012bacbmr9657513edr.345.1668391208628; Sun, 13 Nov 2022 18:00:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668391208; cv=none; d=google.com; s=arc-20160816; b=sPDpwOwFsfxi03DCfjDympfgWby7x7S0XKBdWpWzw8km0LbykwIGdaob4QazkyaWzY zmgnHrZ/YavOOPZ98RpB1gmDXvfvRlGs/WBcVPn3mnXGvxmLCIcmjmPue0lzQBG2dBxe v/g/mQ396wBWtfh21jV6N5wjVZcgHJHilV9dd5GgulIkKObySD1YDC6zQ9qcZct2AqWN MOt0ysWI/vjlEGwbHTe2rHS5TZDWnce9MI/NY9ZBRS9yahZWT6yJf9mSzRR+zsTfZ5Wl 9bx5DVDqJNE3uaLuDLdJKdoEjE/sMvNePGqQU4imXlu6HgYsEWtvGBgjvEVN791Isxay b9Cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=8v64se4ndLgqbFDAHIerqamapO8xDSwZD3YbrOF2gwU=; b=uc4Nhly/4SwmFuWOgz7PVqqJVWJc8pSFtJ2hLVnePVrOK9sAc/rEeGnu97h13LFoFU Bh2++TYZa9rNOqIAXf9lUEkLr+cjP+ftqoaxCdv74CFh36f+ntwpQcymXUQeKd4j7QNc q3ml3JwiYOM8n4pInnNV88ROIcCmjWTBsqz1JPx2nwWc8+Df7d1EdrLnLbtr7GMEV625 EsPdrqnHLS1q3fxebfirm+hMXjjRNe3P2x80Y/ExtXCTdJXHfjJk8MNoUvxNUL3hWmGu hdx7YHLQ1pnl+iD6fLeq0vAfJD11T5Sx9GrWDGZFPb85JU1InkZpxUX/KWwASX2iIrer HH2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sholland.org header.s=fm2 header.b="nW/Za3Em"; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=LR4qa+zq; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sholland.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j11-20020a05640211cb00b004615c5728e8si9089564edw.494.2022.11.13.17.59.44; Sun, 13 Nov 2022 18:00:08 -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=@sholland.org header.s=fm2 header.b="nW/Za3Em"; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=LR4qa+zq; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sholland.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235485AbiKNB6M (ORCPT + 99 others); Sun, 13 Nov 2022 20:58:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235753AbiKNB57 (ORCPT ); Sun, 13 Nov 2022 20:57:59 -0500 Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A79256385 for ; Sun, 13 Nov 2022 17:57:56 -0800 (PST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id AB4C13200918; Sun, 13 Nov 2022 20:57:55 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Sun, 13 Nov 2022 20:57:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1668391075; x=1668477475; bh=8v 64se4ndLgqbFDAHIerqamapO8xDSwZD3YbrOF2gwU=; b=nW/Za3EmB97fE3xQuz U6IjghrHUwvxKsNRYAo8tZ4gfTFvimat3kKsyL+VLjfRGPJ5zYlnB51PnMgHErdz Jgsdcq2Blkkn1IGrQ82ih1dfhaC3wX8rTcSjWHtrAmflQ14Al8CyaK/4PZytH8ub FBmKyvt74izhN6/cVv7dkRKszHISqk01Zi7jtxnpKCN5SATtcwEjjce6u+28HZFt Q9pbVdOKS/MaA/JD1aZpbebRw38r8Q2+hxewAkQM2X5XqSh/xEFK5b5DuJONAlJw CJ80JOXmUQ+u18v1BmERKTU8nryl8s1u1aOlM40aMHH6FOslFE2THipsR2BtZbA4 fiDw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1668391075; x=1668477475; bh=8v64se4ndLgqb FDAHIerqamapO8xDSwZD3YbrOF2gwU=; b=LR4qa+zqLoevQmTaWy4UOL7sr85kK PxsH3h3OkgY4sJXhswK2jBoXG+CxNsvMXsSgTeccvtLW2lKqADVrSHbT5vuo6uMA 0IMUXs8TF0t/T2ikJGGH3MDM9PnOEDUu8eEhsmkDIb2zcD5NqIebFIhOJu2hpj14 UhI0aMo73HNIoz4IDdwM+T4IKhyceGKvKFM/Ax5PpiqPgKAkURqdZHnN+4EfnvZL Hn9efLrK/Xr01xHE5KuMC4k3JY/n3ebtLoQfPElN3YqdIPDjozErKP28Wlrn/KpQ mmRL/JEYSgyLUYAdUzrG1D9y2yPCxX6tPd0BoPR7EeyJ93dsKSlWkS49A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrgedugdegtdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtf frrghtthgvrhhnpedukeetueduhedtleetvefguddvvdejhfefudelgfduveeggeehgfdu feeitdevteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 13 Nov 2022 20:57:54 -0500 (EST) From: Samuel Holland To: Chen-Yu Tsai , Jernej Skrabec Cc: Ivaylo Dimitrov , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev, Andre Przywara , Samuel Holland Subject: [PATCH v3 2/3] bus: sunxi-rsb: Support atomic transfers Date: Sun, 13 Nov 2022 19:57:48 -0600 Message-Id: <20221114015749.28490-3-samuel@sholland.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221114015749.28490-1-samuel@sholland.org> References: <20221114015749.28490-1-samuel@sholland.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749434979912795301?= X-GMAIL-MSGID: =?utf-8?q?1749434979912795301?= When communicating with a PMIC during system poweroff (pm_power_off()), IRQs are disabled and we are in a RCU read-side critical section, so we cannot use wait_for_completion_io_timeout(). Instead, poll the status register for transfer completion. Fixes: d787dcdb9c8f ("bus: sunxi-rsb: Add driver for Allwinner Reduced Serial Bus") Signed-off-by: Samuel Holland Reviewed-by: Jernej Skrabec --- Changes in v3: - Clear the interrupt status register after polling Changes in v2: - Add Fixes tag to patch 2 - Only check for specific status bits when polling drivers/bus/sunxi-rsb.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/drivers/bus/sunxi-rsb.c b/drivers/bus/sunxi-rsb.c index 17343cd75338..3aa91aed3bf7 100644 --- a/drivers/bus/sunxi-rsb.c +++ b/drivers/bus/sunxi-rsb.c @@ -267,6 +267,9 @@ EXPORT_SYMBOL_GPL(sunxi_rsb_driver_register); /* common code that starts a transfer */ static int _sunxi_rsb_run_xfer(struct sunxi_rsb *rsb) { + u32 int_mask, status; + bool timeout; + if (readl(rsb->regs + RSB_CTRL) & RSB_CTRL_START_TRANS) { dev_dbg(rsb->dev, "RSB transfer still in progress\n"); return -EBUSY; @@ -274,13 +277,23 @@ static int _sunxi_rsb_run_xfer(struct sunxi_rsb *rsb) reinit_completion(&rsb->complete); - writel(RSB_INTS_LOAD_BSY | RSB_INTS_TRANS_ERR | RSB_INTS_TRANS_OVER, - rsb->regs + RSB_INTE); + int_mask = RSB_INTS_LOAD_BSY | RSB_INTS_TRANS_ERR | RSB_INTS_TRANS_OVER; + writel(int_mask, rsb->regs + RSB_INTE); writel(RSB_CTRL_START_TRANS | RSB_CTRL_GLOBAL_INT_ENB, rsb->regs + RSB_CTRL); - if (!wait_for_completion_io_timeout(&rsb->complete, - msecs_to_jiffies(100))) { + if (irqs_disabled()) { + timeout = readl_poll_timeout_atomic(rsb->regs + RSB_INTS, + status, (status & int_mask), + 10, 100000); + writel(status, rsb->regs + RSB_INTS); + } else { + timeout = !wait_for_completion_io_timeout(&rsb->complete, + msecs_to_jiffies(100)); + status = rsb->status; + } + + if (timeout) { dev_dbg(rsb->dev, "RSB timeout\n"); /* abort the transfer */ @@ -292,18 +305,18 @@ static int _sunxi_rsb_run_xfer(struct sunxi_rsb *rsb) return -ETIMEDOUT; } - if (rsb->status & RSB_INTS_LOAD_BSY) { + if (status & RSB_INTS_LOAD_BSY) { dev_dbg(rsb->dev, "RSB busy\n"); return -EBUSY; } - if (rsb->status & RSB_INTS_TRANS_ERR) { - if (rsb->status & RSB_INTS_TRANS_ERR_ACK) { + if (status & RSB_INTS_TRANS_ERR) { + if (status & RSB_INTS_TRANS_ERR_ACK) { dev_dbg(rsb->dev, "RSB slave nack\n"); return -EINVAL; } - if (rsb->status & RSB_INTS_TRANS_ERR_DATA) { + if (status & RSB_INTS_TRANS_ERR_DATA) { dev_dbg(rsb->dev, "RSB transfer data error\n"); return -EIO; } From patchwork Mon Nov 14 01:57:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 19511 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1915994wru; Sun, 13 Nov 2022 18:00:27 -0800 (PST) X-Google-Smtp-Source: AA0mqf4NIKKxPCM2WFLZt+o+Rg/GXKTk/KJVBSS4rkt9bYSdfNY5wAAwnasTbxCsyF8sk0AMR8HA X-Received: by 2002:a17:906:b294:b0:7a0:b505:e8fb with SMTP id q20-20020a170906b29400b007a0b505e8fbmr8867853ejz.281.1668391227612; Sun, 13 Nov 2022 18:00:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668391227; cv=none; d=google.com; s=arc-20160816; b=nMessAVst8Rfv7IYco+ie75rqfZFt+dPEafXgZkAML9/ny3EjY/m2zJtPs0xtudv1c NTIkmfNCt8ZpU5Ff13xIG8eg60NgMTUZhFanR9F6qLCEAoNVbODr3y4GTXdlDfZ5m9PQ fjDtPpPeYmu2mXmySVYuOrgTHY2HKYxd3pY3qbxwjgV+aJ3ASwexs5qkNJApPZpZAosS xD81T7RZiwkt4P5KfXG8LbJHqy5fWk68+LTQBDzqgLpsxoAq+bo5hfO30RdLaNXESX5D RbdURSPMlUOzwaoSO72CcAq7QI0uRm7pkYgxsj5gal+lihIMRdwsOlC7AGsX6VFSl/JI OAJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=zX+HYuy4GvidniLAd+lpqew4/s4ii686Qj3H9Jd2qG0=; b=qfWDq3t2oiYGadoD+nweOEif0xOIemhjHY4qL0OjNAS7xabAHryZWvGgyq1SacLMxv oytPIE40jkru2FvREV19Gfit1ZkYT6isPxSUmnvBnngGippxTWs1T09lxmHgULSCOmBk sMk8n1BZKfuFwWqgypLERPxdhNgJArRtjNBQsUZLCV+qh76ee715VBJAWsOMUsH28qzh bfZhVpasGwQ25M46PcQC8QPNcn5BSMrStrGWkt8yI9a/iaod+9A1MvrwJ+oa6RO6PRe8 EXonB9OhAFJrrJbFtrFzYJZnNLT+UKaWssyWayrQszJXSAxrwx8wQ6tXeV0AFdEGYBbh RZMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sholland.org header.s=fm2 header.b=rXsRbMYF; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=MH1Dg8+T; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sholland.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xj10-20020a170906db0a00b00791910ecd0fsi8100860ejb.540.2022.11.13.18.00.03; Sun, 13 Nov 2022 18:00:27 -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=@sholland.org header.s=fm2 header.b=rXsRbMYF; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=MH1Dg8+T; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sholland.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235484AbiKNB6Q (ORCPT + 99 others); Sun, 13 Nov 2022 20:58:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235589AbiKNB57 (ORCPT ); Sun, 13 Nov 2022 20:57:59 -0500 Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA0ECB86F for ; Sun, 13 Nov 2022 17:57:58 -0800 (PST) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id ACDC8320091A; Sun, 13 Nov 2022 20:57:57 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Sun, 13 Nov 2022 20:57:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1668391077; x=1668477477; bh=zX +HYuy4GvidniLAd+lpqew4/s4ii686Qj3H9Jd2qG0=; b=rXsRbMYFTaUdR2U+Mk VNvxUrkjZXlEk44QuPfO3v95apqzkYDbTcuAIKi3cFSmP1R5I36syDaXMzUiRXV5 ZUG23SwDwoYqTOgIQt7vg0VHxW/GFVMDFVeoQSX5WU3iAAln+nsR8Q5Bni10xOaX B9M+OAK5vMjbNdi7pRHiBVwVvw7y1j0WyajuPvNXe7Zz4PPjTQEaLOnmvpLChWLW 5Qk/M3W2QI0t99TuVFL04WYT5ysYIs4q5r/B1QuF3lVUzgOjhm3yJoFDmy1aepYi jVupkZ6508nbFlesKkfDqFbbhzMzUE3O6HnCuo3dGPf7m1foGPbVFgxwxm4j0ana TIqw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1668391077; x=1668477477; bh=zX+HYuy4Gvidn iLAd+lpqew4/s4ii686Qj3H9Jd2qG0=; b=MH1Dg8+TQL2ERs5dtT00JLdXcQfB6 c2fJd7iyyNYKiV/keuHUtO6s2q1mAAs6HS9VQfpUKkBh/fzKgWvN3c3XMfGqpLoX IQqwXXVRlCKH08XEQswZG0lmo8pkgPjSYIa6qxzlanDSmxgWxSE1bVCDRvj0Ya/j NCtIEjGEjLozLrclr0QJIcrAPF9XoQjw+Z3YTnPiOmjimezhLNMWUalzf7c1jF/o G6jTQOKLHpk2TEMvbpSxskt+xPzUJbh5Ri0sfmfdMOmUSGyTQlbqSloJo1lL7MQ/ l6OFLXUZTm1jtwlWJwRzZFyvTgu19aeGBsM+ciohTPYAFEQrIpP6ClF1w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrgedugdegtdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtf frrghtthgvrhhnpedukeetueduhedtleetvefguddvvdejhfefudelgfduveeggeehgfdu feeitdevteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 13 Nov 2022 20:57:56 -0500 (EST) From: Samuel Holland To: Chen-Yu Tsai , Jernej Skrabec Cc: Ivaylo Dimitrov , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev, Andre Przywara , Samuel Holland Subject: [PATCH v3 3/3] bus: sunxi-rsb: Clear interrupt status before each transfer Date: Sun, 13 Nov 2022 19:57:49 -0600 Message-Id: <20221114015749.28490-4-samuel@sholland.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221114015749.28490-1-samuel@sholland.org> References: <20221114015749.28490-1-samuel@sholland.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749435000140145209?= X-GMAIL-MSGID: =?utf-8?q?1749435000140145209?= Currently, the driver clears the interrupt status bits after anything could have set them. However, this requires duplicating the same logic in several places. Instead of clearing the status flags in the interrupt handler, disable all further interrupts by clearing the RSB_CTRL_GLOBAL_INT_ENB bit. Then we can delay the status register write until the start of the next transfer, so it only has to be done in one place. Signed-off-by: Samuel Holland --- Changes in v3: - Add a patch refactoring how the status bits are cleared drivers/bus/sunxi-rsb.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/bus/sunxi-rsb.c b/drivers/bus/sunxi-rsb.c index 3aa91aed3bf7..cb622e60897b 100644 --- a/drivers/bus/sunxi-rsb.c +++ b/drivers/bus/sunxi-rsb.c @@ -279,6 +279,7 @@ static int _sunxi_rsb_run_xfer(struct sunxi_rsb *rsb) int_mask = RSB_INTS_LOAD_BSY | RSB_INTS_TRANS_ERR | RSB_INTS_TRANS_OVER; writel(int_mask, rsb->regs + RSB_INTE); + writel(int_mask, rsb->regs + RSB_INTS); writel(RSB_CTRL_START_TRANS | RSB_CTRL_GLOBAL_INT_ENB, rsb->regs + RSB_CTRL); @@ -286,7 +287,6 @@ static int _sunxi_rsb_run_xfer(struct sunxi_rsb *rsb) timeout = readl_poll_timeout_atomic(rsb->regs + RSB_INTS, status, (status & int_mask), 10, 100000); - writel(status, rsb->regs + RSB_INTS); } else { timeout = !wait_for_completion_io_timeout(&rsb->complete, msecs_to_jiffies(100)); @@ -296,12 +296,9 @@ static int _sunxi_rsb_run_xfer(struct sunxi_rsb *rsb) if (timeout) { dev_dbg(rsb->dev, "RSB timeout\n"); - /* abort the transfer */ + /* abort the transfer and disable interrupts */ writel(RSB_CTRL_ABORT_TRANS, rsb->regs + RSB_CTRL); - /* clear any interrupt flags */ - writel(readl(rsb->regs + RSB_INTS), rsb->regs + RSB_INTS); - return -ETIMEDOUT; } @@ -503,15 +500,11 @@ EXPORT_SYMBOL_GPL(__devm_regmap_init_sunxi_rsb); static irqreturn_t sunxi_rsb_irq(int irq, void *dev_id) { struct sunxi_rsb *rsb = dev_id; - u32 status; - status = readl(rsb->regs + RSB_INTS); - rsb->status = status; + /* disable interrupts */ + writel(0, rsb->regs + RSB_CTRL); - /* Clear interrupts */ - status &= (RSB_INTS_LOAD_BSY | RSB_INTS_TRANS_ERR | - RSB_INTS_TRANS_OVER); - writel(status, rsb->regs + RSB_INTS); + rsb->status = readl(rsb->regs + RSB_INTS); complete(&rsb->complete); @@ -532,9 +525,6 @@ static int sunxi_rsb_init_device_mode(struct sunxi_rsb *rsb) if (reg & RSB_DMCR_DEVICE_START) ret = -ETIMEDOUT; - /* clear interrupt status bits */ - writel(readl(rsb->regs + RSB_INTS), rsb->regs + RSB_INTS); - return ret; }