From patchwork Sat Nov 5 19:19:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 16014 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1138038wru; Sat, 5 Nov 2022 12:25:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6MEmj+MCureG1B5fMb91KRNvOreHoyOq0BwT+py86OdlZGUNqJq/vqkk0AVrh2+q6+0jl+ X-Received: by 2002:a17:906:7cc8:b0:7ad:d051:538f with SMTP id h8-20020a1709067cc800b007add051538fmr515920ejp.401.1667676323753; Sat, 05 Nov 2022 12:25:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667676323; cv=none; d=google.com; s=arc-20160816; b=vD3CBnt5qHCrxrz4edrI6jhBfBx4OBkalDwi/EroBDRg1cYdBCWvwj1LtrvbAUFa5w Bi6FCg1oRyGEVYlEulnyvSsaXcY/DOCYequ8TJi0rDFbT/B5HpOpm/sAwR0mBOqMSA4z E47d51BDfvrduFgjrn/chcV63hapNj3vhui5UaF8NSHhkSzC1rK4gwoq7zVjlcSKJ3Cr y3Kcu4oqvHYF47JzfKZZCQ0/XDiVzk1FVe8r6I6gPUGlIRbMYspy/oapxNawtKur1OFh FDymCjPDLOT7CuRm6rf6a/0eEiYqn7dgdylrWc+weDrnLdzcCXqexnkB6qNb3PAe0i9y q4PQ== 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=63c2H+dRQD1BzJZi0cy8b0iFyafq5iwHTt7UuUibAIE=; b=uSIb/uiX0odvEux4HtX9y8J/FmsjBe+TwKfzmxxPlmVeIlZ9o4AF7nnt4UJ9zGm10z CbacDpOsjk5AB4Fdw7h1vHRWZ8mRRAw3u1dtpyEe0ZJ7LcUQwuivmGfyZcc9OdSYjq2D 7RvPMIZNEpxyzde97EJamdBZh5eUgDwUp45JZVkY64Uzo0b8QVPBZv+S7ZLrNiUYQXTs /sK+y+FbzViOOS6mNOvoby7LPZD9h9wZg2nSVtlnh9UgngQaTqNinHqS66pBbl0MNu3K mZUP1OtedfXQumlUqOFyLeP8bUejXIq8y6tYcDsC1n7Oz+6MgGtPOp6pFocte2rkbZL4 rqXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sholland.org header.s=fm1 header.b=H+JQcl35; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=co9pExtO; 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 gs8-20020a1709072d0800b007ae0e8f5993si3712473ejc.252.2022.11.05.12.25.00; Sat, 05 Nov 2022 12:25:23 -0700 (PDT) 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=fm1 header.b=H+JQcl35; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=co9pExtO; 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 S229916AbiKETUC (ORCPT + 99 others); Sat, 5 Nov 2022 15:20:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229900AbiKETT7 (ORCPT ); Sat, 5 Nov 2022 15:19:59 -0400 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2BCFB844 for ; Sat, 5 Nov 2022 12:19:58 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 161B23200392; Sat, 5 Nov 2022 15:19:58 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Sat, 05 Nov 2022 15:19:58 -0400 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=fm1; t=1667675997; x=1667762397; bh=63 c2H+dRQD1BzJZi0cy8b0iFyafq5iwHTt7UuUibAIE=; b=H+JQcl35za7+ROjxck sQmB6zB+1wboxkVRTI9TantFMWG1GBuOOIz5mL4qSF5LVfY8xnlKORAwAlQFulf3 d1lSIAMox3vNRn2aqLlmdCMDfQWAO5NFhNyXJWPc6DH/UIOfddSejzRcKvXCKQpr u3ojWPFYFOQvHaWcbQ2/XUdawhecgirWsx6dN2+KRlRmwh2HKXZqmeo7c1LcYXjI fPIvF7WdCveT7j0UvL5YNTQNT2AnfyYHaetBzM0vLzREA5RhVGKSfVFCxD1RVp7D ZRnDESQM7HS2h4AQlo/IBxePUP1DeTgcKfq7fRMwgKlMjC3ex5X6CV22wfScEM3Y j1IA== 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=fm3; t=1667675997; x=1667762397; bh=63c2H+dRQD1Bz JZi0cy8b0iFyafq5iwHTt7UuUibAIE=; b=co9pExtOgnJxK9hFOBL56VSD7zb2V 1Hcb72pT0OGFQF0at4s8S7ENA+phcrwviGDlY58UMepUNnGK3RngaOxVc+Duz6X2 /ycph15zLNDtj+AC4wxGRzkoKz+vQozdef1g5qJgj1kHSbNfudRU/6cEsiu7nZbn dtUG33fWywr6XfrLs1C0yrhtzYpl2fW1SHxhXja7RgeVNgwES5dTefGFRGuMrW3z 7+QrxTkz43Xvu4K6Viba1XPdOtWhQG+PTt7ux5551ZNhKgJa9KWE4emkEEheRSwH Q6sdlLYqAGTxkKc7E1AK1d4zw/fOh1tgs9fOFPPJ/A+PR2iXAIVFvlqnQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrvdeggddtjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtf frrghtthgvrhhnpedukeetueduhedtleetvefguddvvdejhfefudelgfduveeggeehgfdu feeitdevteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 5 Nov 2022 15:19:57 -0400 (EDT) From: Samuel Holland To: Chen-Yu Tsai , Jernej Skrabec Cc: Ivaylo Dimitrov , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, Samuel Holland Subject: [PATCH 1/2] bus: sunxi-rsb: Remove shutdown callback Date: Sat, 5 Nov 2022 14:19:52 -0500 Message-Id: <20221105191954.14360-2-samuel@sholland.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221105191954.14360-1-samuel@sholland.org> References: <20221105191954.14360-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,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?1748685368879731732?= X-GMAIL-MSGID: =?utf-8?q?1748685368879731732?= Shutting down the RSB controller prevents communicating with a PMIC inside pm_power_off(), so it breaks system poweroff on some boards. Reported-by: Ivaylo Dimitrov Fixes: 843107498f91 ("bus: sunxi-rsb: Implement suspend/resume/shutdown callbacks") Signed-off-by: Samuel Holland Acked-by: Jernej Skrabec Tested-by: Ivaylo Dimitrov --- 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 Sat Nov 5 19:19:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 16015 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1140521wru; Sat, 5 Nov 2022 12:32:04 -0700 (PDT) X-Google-Smtp-Source: AA0mqf7UvTpZAvWb/wWJtrnCtp3SpUMX67GiL7FU5gbPy5aJq8g0SzU2kDL1KRpsMywFkr0IGvyA X-Received: by 2002:a17:907:3f9d:b0:7ae:587e:73aa with SMTP id hr29-20020a1709073f9d00b007ae587e73aamr2138104ejc.289.1667676724199; Sat, 05 Nov 2022 12:32:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667676724; cv=none; d=google.com; s=arc-20160816; b=g6VNT9Cfyq2HnVu/+di5qYXyYu4k1pthi5BG5DTaSJvtFiFns3zBVVljCa05tfUUb/ jDes2EjMXC7Ac6oUGJj/oWqEYOrKytPtlhqiehNkOfq6gdgrmfDSja2hWr+Rbt5Dqx64 9cPu4IPvJRzI6eRfvmbpCtftoDF7ENhUiLIjEQmpOHE80Sn2PxRrb76gqPRMQ1I+uw7c EveixTng4XBZ/N8FIDhUb6b/lLGWpBhbORfNIgb+chxBzO0cNTaGTUAS0MfIYE/G2r7C stvlR5RtmSBCdLg/GSVR8GZFUjUVfvDXQtLOHC1QRS7E1O4iBlMKJPo1r1yNE1IhDRe/ /Z8w== 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=Tpwv+c2F2PU8VoJszCGDvaTbihLFPEmYX1Wb7G6Djbg=; b=dAp8egCGjkvUkDzHYSYq+OGAu6+olbhlMkOKw0yo/e6KnbJbeOxPNX85ZCcU5/NJct FoyDZgD2NHo6RBzgeimk+6awex+1jAGteX6HNao1jDkiZjJXCh3tLNbp4KwamSbCyR5L sYYwK+Fhs5W6sta/vClicNL0C6PyM02U+VDqaJaizQmKmFpQyt8qJa5jCW527dYieI7J SyuFWxxkcFhpZF5t7Ov8EFGTv63/umiMa/XPMcCLh8R1c6bihrC0gUh4glPKMxGaP+IT +dKZe5tBncu6npPAZnsJSQni4UtxBKIqelj1QYKaoTnDJ4A9YwCZLLSEorh+F/5OwOr3 rlDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sholland.org header.s=fm1 header.b=Y6fGLWrm; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=otS9uMte; 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 mp3-20020a1709071b0300b007ad8bd5b636si3572689ejc.377.2022.11.05.12.31.38; Sat, 05 Nov 2022 12:32:04 -0700 (PDT) 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=fm1 header.b=Y6fGLWrm; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=otS9uMte; 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 S229900AbiKETUE (ORCPT + 99 others); Sat, 5 Nov 2022 15:20:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229913AbiKETUB (ORCPT ); Sat, 5 Nov 2022 15:20:01 -0400 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F4030B861 for ; Sat, 5 Nov 2022 12:20:00 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 0DBA432005C1; Sat, 5 Nov 2022 15:19:59 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Sat, 05 Nov 2022 15:20:00 -0400 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=fm1; t=1667675999; x=1667762399; bh=Tp wv+c2F2PU8VoJszCGDvaTbihLFPEmYX1Wb7G6Djbg=; b=Y6fGLWrmfRddnjem6R Smpi3ED14bBqTQQpAKwrbY1YIc1X1eXN+Mixmjm+zD+/1W3A9uFbkme5LH/R4H0Y szwKF364j/976o7TgvJ/7NE2hfh/EAOeA2+KCgulsVfIlduQH3m3wRi5LbqYwWHA U3vjRDtuaQWloa3Su1QwbYvw4XUERmjey58qr3/MXzmPDGIYdFuplOUSHkqYjg+y r7meIIgxsAvxrMPUMf75C75gIO7bi0LyCGKWMD7/zfY6gIpHbVTegZ0fIyuoHnre JXDz/mn/jjAUi7KFXnzw3aGjh9RMufkKJu2iahQ8RB7qC3ARp5/sSpoijHNmfmM1 3A9A== 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=fm3; t=1667675999; x=1667762399; bh=Tpwv+c2F2PU8V oJszCGDvaTbihLFPEmYX1Wb7G6Djbg=; b=otS9uMteT5hsdxH2QCGs+j+EvEdm7 fxoCVGiYhX8SqtNwZvQB0tSx/19y+lwkI5DdxfCoV2nUwuRK3co4LyJXP7U0O8pe R9Zo7DsVmQYAd4OVi6Qyyr8nMTW7+GqWS9R0RkN/tOth49apiZEqcN+JDEC76CUn tBwtJfuioAxaUPcuWOy9KsqS+d+AM5kLmBPYOFewIka7412zeFxa6GdaYTblc9Rj X+XoM5xyXrX+bnig4APlQ+zPhq0INJehvoXsE3rRAikTUYBU/n6HOwhcdP+ROw+N cuUIXnTNqOJN288m8KNjNnGApqBGgL7fc7Nu+Ju9By8Zn6u7ZawLSDg2w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrvdeggddtjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtf frrghtthgvrhhnpedukeetueduhedtleetvefguddvvdejhfefudelgfduveeggeehgfdu feeitdevteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 5 Nov 2022 15:19:59 -0400 (EDT) From: Samuel Holland To: Chen-Yu Tsai , Jernej Skrabec Cc: Ivaylo Dimitrov , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, Samuel Holland Subject: [PATCH 2/2] bus: sunxi-rsb: Support atomic transfers Date: Sat, 5 Nov 2022 14:19:53 -0500 Message-Id: <20221105191954.14360-3-samuel@sholland.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221105191954.14360-1-samuel@sholland.org> References: <20221105191954.14360-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,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?1748685788521642725?= X-GMAIL-MSGID: =?utf-8?q?1748685788521642725?= 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. Signed-off-by: Samuel Holland --- drivers/bus/sunxi-rsb.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/bus/sunxi-rsb.c b/drivers/bus/sunxi-rsb.c index 17343cd75338..0f0e498d4379 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) { + bool timeout; + u32 status; + if (readl(rsb->regs + RSB_CTRL) & RSB_CTRL_START_TRANS) { dev_dbg(rsb->dev, "RSB transfer still in progress\n"); return -EBUSY; @@ -279,8 +282,16 @@ static int _sunxi_rsb_run_xfer(struct sunxi_rsb *rsb) 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, 10, 100000); + } 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 +303,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; }