From patchwork Mon Nov 7 05:21:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 16235 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1849242wru; Sun, 6 Nov 2022 21:33:12 -0800 (PST) X-Google-Smtp-Source: AA0mqf4c0Dnri1zVM3lrO5DW+oRBHSQ4hS8jNC+KljhTn/uKiVUvYKfC5ZejuC/BpKNGEgVaAq57 X-Received: by 2002:a17:902:9042:b0:188:6fc9:1da with SMTP id w2-20020a170902904200b001886fc901damr12430213plz.162.1667799191962; Sun, 06 Nov 2022 21:33:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667799191; cv=none; d=google.com; s=arc-20160816; b=LmY8MOV+iAUT6rUoaXShfvEKg61pYNJsGhnurpYVb0Ezh+1DFPfk2dq8goRibWuHLr QuTEDwNP9rt9L0L8dJ0SB+MKtr21FuE1GzC197QvImDKzczxqGu2xWM3P+8e8A1e4mcs +8JRwssorxc4GzvYr+IhGI6f8sVITJsDTIw5mYJ6OIfyL1eYlCuFpaXmsS4v/FxmeDdC 9OfdcbCNbFhV2OkF8jfzpp66VrzsG4uQGkvO1VeI1uVzcyLvnyzBy7k+SNQOTolAugYn J/SehOJD1zfNkWmy5bdYoc+6qwd9/zMeUkuTkFFn+asQlu60O/RQAkzYcBwVKhU/OVBS YMGQ== 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=XDA3FKsc76rlojguBycbOIx3Fn5VWhQv5XilLE+sJ+A=; b=fWm22MucFPHi0B+VWfYJRtg67KPgDXMW5mGwLAGLJAIwEmlhZBLeQsY1+OiSvPONfQ t3EnwqckXx7buFBtw5+tYHeLGySyDY8cWBmXlVvucq/StLOv1OGnWqhj//ARZ1SAotQw AuhXCkVJUsk48zIOdSKbPckokRFPoHvYeIbP4409LYGCaKleGOwos+pe1Dk4kkYDTVcq 8j62dMpMkglLft8W/2HdCj1aKzKAWCaQ+/xmNkDhMjoiLk971BT/YU2Wtg3JiPQ0J9wc zZwCDnY4XUN+ornqpEhtH0IdgWKYIki1NK9DeyGKoomJBgVp7aFzeG1RK8a0XrpefzcJ O4AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sholland.org header.s=fm1 header.b=PJJ03aom; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=LO2jjsdM; 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 h6-20020a170902f54600b00186bb4a081csi11482417plf.393.2022.11.06.21.32.59; Sun, 06 Nov 2022 21:33:11 -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=fm1 header.b=PJJ03aom; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=LO2jjsdM; 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 S229840AbiKGFWM (ORCPT + 99 others); Mon, 7 Nov 2022 00:22:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229447AbiKGFWI (ORCPT ); Mon, 7 Nov 2022 00:22:08 -0500 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5A0163C2 for ; Sun, 6 Nov 2022 21:22:05 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 465B75C00E4; Mon, 7 Nov 2022 00:22:04 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Mon, 07 Nov 2022 00:22:04 -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=fm1; t=1667798524; x=1667884924; bh=XD A3FKsc76rlojguBycbOIx3Fn5VWhQv5XilLE+sJ+A=; b=PJJ03aomEKNvG4K++e y1aLwfUnffFpdWsTfmTKJpxoXP7t59VqioldNaNEti2Cb7+rjVjmNgjsirdgfGOV UmMJw+hzGgjLmj4xwSqlJYwtRWofjcsRqENODjO2MCdFCQHKwhvHY/LDe97q0FQe wU82LfaqWvNotZKToK0iC9AhfhTF4zynFsAsxNIZZme3ztaSL0e5uFbmzmIOm77Y fMBeEqeCmxcXTC4VlyxVyUWJTpinvjLcEFfTbKIfz0AudlbCro2R69AeE/xOrO1q wfmAU3GfU9a9T5DM7VhTI06I/FoPFpiPHpH8ZPHNXU83AFoPt60Rfkv0/TM7EPsq xloQ== 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=1667798524; x=1667884924; bh=XDA3FKsc76rlo jguBycbOIx3Fn5VWhQv5XilLE+sJ+A=; b=LO2jjsdMv3AVo4I43Pu1T2H1FSvhI bgWREETf65iS8638m79Tnm6/qLCLDhBP+yab6F+QaUxIXiuQjhIv5b/tUVE3Uk2k TJ0bpgFsMm7QWG/qnn2CCYS06m6QnTMBQGBpcXTsHXOsVcGgG9YN+wASHeTArSC+ ErUFW+oh3BQgxBrRmoOrhgHh6rHgfaoSHjNv9DjTVQPquhSZDKAcjJ0zQbuYNgsB 1FgYX9Cbyor5yU2LY6bnbv2iDZyA0cyvMa8CGxNMBvBiMyvV81RBqlvrnigFS1LC NCNmDt2obSbmBgxYQ7xyDXlf3wKNp50MLf9xDEfKTxU7MRvz5nSa75VvA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrvdejgdekvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtf frrghtthgvrhhnpedukeetueduhedtleetvefguddvvdejhfefudelgfduveeggeehgfdu feeitdevteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 7 Nov 2022 00:22:03 -0500 (EST) From: Samuel Holland To: Chen-Yu Tsai , Jernej Skrabec Cc: linux-arm-kernel@lists.infradead.org, Ivaylo Dimitrov , linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev, Samuel Holland Subject: [PATCH v2 1/2] bus: sunxi-rsb: Remove shutdown callback Date: Sun, 6 Nov 2022 23:21:59 -0600 Message-Id: <20221107052201.65477-2-samuel@sholland.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221107052201.65477-1-samuel@sholland.org> References: <20221107052201.65477-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?1748814205283816974?= X-GMAIL-MSGID: =?utf-8?q?1748814205283816974?= 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 Tested-by: Ivaylo Dimitrov Acked-by: Jernej Skrabec Fixes: 843107498f91 ("bus: sunxi-rsb: Implement suspend/resume/shutdown callbacks") Signed-off-by: Samuel Holland --- (no changes since v1) 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 7 05:22:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 16236 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1849269wru; Sun, 6 Nov 2022 21:33:16 -0800 (PST) X-Google-Smtp-Source: AMsMyM4QqujXJpPIjuBRJoR2P3VLpjB/UcCz0kh5JUwwlzL1Iq06WpqFQ1xPdDBbqgWDyCyCov5p X-Received: by 2002:a17:90b:8c5:b0:213:de45:d126 with SMTP id ds5-20020a17090b08c500b00213de45d126mr41806657pjb.34.1667799196588; Sun, 06 Nov 2022 21:33:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667799196; cv=none; d=google.com; s=arc-20160816; b=B45mmjgu61a0ttDpfud/feP0gZtNL1A+amDs/35Azqv9He0EEyooJ5InCR5j8fPIrs qfiiINsV7hjJbyBKnr0nbQzp9ylIBHQEVgNHokpVALGMoju6Cb2zFLit34a1Xg4f2qK0 FVrfEB5a/C6u0orBhCQ9APGAoJqEBbIboJLTdnw0YsR5C5DUny5nA4SHWTMmJDXtPWaP LKpj1Ms8P9bBfPxSxYBYm9RelF5TJHDbbyXJ1EHlzhulsMd00qz2B9sW7ejymi2qdgRD L6VV1VDAsyGX4Qlyhz6Lz6F7owVERTk3e4O/iHLsO1eroipafI67wRWB0QuLJTpx+u8w 8dZw== 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=gyBTq0Ma+GLkWBSiLTWQDQZqxoZ0z5X/rfo9ICAimTw=; b=Awrevg33GORSJAU4Ycbvky0YDXixhbcnZaAIK0OcSs9DoKN5r7JZZ+VOW/tG/6Vgfy 1KgKMuu+1TcssAs1TqwH88u+sDjuN07riBn2zOuOF8C0MvH4FC1pDXue5CyiecAlHszu 5i60MyFbaGnrDmrR5MGZkJ+pUBFNZa+j1XG4fv3+3GjdWIpINa05w6jcqEHL+tkAZrVu yktbgtnuM0jad6oLNNJ4fQhM+8he8omHVcA/pd/NZKvvVQHRUN8BH17SK9h6B0T//T6F xVR281xRRx5pej2qAnqGBVm0sYV6VdsDFXU4kIUoXqqEOij3TDN8jZ9DL8sadSpVrXid oZNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sholland.org header.s=fm1 header.b=XyxbUEkp; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=D5VXd4bh; 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 p8-20020a63f448000000b0046fec9f9ed8si9433211pgk.704.2022.11.06.21.33.03; Sun, 06 Nov 2022 21:33:16 -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=fm1 header.b=XyxbUEkp; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=D5VXd4bh; 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 S230160AbiKGFWP (ORCPT + 99 others); Mon, 7 Nov 2022 00:22:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229705AbiKGFWJ (ORCPT ); Mon, 7 Nov 2022 00:22:09 -0500 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D06BBB4AD for ; Sun, 6 Nov 2022 21:22:05 -0800 (PST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 2BDB75C00F1; Mon, 7 Nov 2022 00:22:05 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Mon, 07 Nov 2022 00:22:05 -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=fm1; t=1667798525; x=1667884925; bh=gy BTq0Ma+GLkWBSiLTWQDQZqxoZ0z5X/rfo9ICAimTw=; b=XyxbUEkpXnskgkAOAR behrCDtU7Ew7aMxM2Kp2Mglueji47RiwJrlzAGNi5w9qeIRRl7qMpYrF7n2SiZmx 9FF1/37mgac7NXvl3ytu409Z9+m0xTi4tAZ9M0bjNZMZRvMxaMscffBLP+7K0nu/ quw0b/Q33zHzOG2h7PYg+OidbtF8Igy1gWpXuXTdxWkREgXOClxNK0MZHix4kk5i Vz45S1KZjeWXdVpQnx9Y8ACymyT6FFldCkIZunlR21zahuQDhpRKM0YODD6tUBjy 5oUE1i24Jrn5/F+TGhr5EfXB0KzwREA1hrLFcbjjq0yjUnPOekHVgUIPeTbBPFSx De2w== 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=1667798525; x=1667884925; bh=gyBTq0Ma+GLkW BSiLTWQDQZqxoZ0z5X/rfo9ICAimTw=; b=D5VXd4bh7p2i046046Vm1vikWqeDc ZG/RyLXHdQLAz0Zex1DPoIkbuHmh+MMznDKd1fg4pI950jEzH6U6I6z60xnvaR+V lWxhL0HTwZcyHBY26iS6fgU4kj3OxwzOrajcJZaB9U0rxKyf6IL87xIb1dj5bQrX iyRtV9D4BFNWlStOuRsLYMVuGyZ3+Du60aEXjublB5P37TeJ08IvzgoDqoW6kX2M US/js3eal7uZPyKdS+pgOYd7rRHp7r2iWOog01e1dikFp6g2lb99lbDEjvCsae0F p/2eidHX3YrDsZXJAVBZ3JoFiMVwlplu3nOieSmc5UgvJcbL4dDQF5JKQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrvdejgdekvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtf frrghtthgvrhhnpedukeetueduhedtleetvefguddvvdejhfefudelgfduveeggeehgfdu feeitdevteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 7 Nov 2022 00:22:04 -0500 (EST) From: Samuel Holland To: Chen-Yu Tsai , Jernej Skrabec Cc: linux-arm-kernel@lists.infradead.org, Ivaylo Dimitrov , linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev, Samuel Holland Subject: [PATCH v2 2/2] bus: sunxi-rsb: Support atomic transfers Date: Sun, 6 Nov 2022 23:22:00 -0600 Message-Id: <20221107052201.65477-3-samuel@sholland.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221107052201.65477-1-samuel@sholland.org> References: <20221107052201.65477-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?1748814210311979874?= X-GMAIL-MSGID: =?utf-8?q?1748814210311979874?= 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 --- Changes in v2: - Add Fixes tag to patch 2 - Only check for specific status bits when polling drivers/bus/sunxi-rsb.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/drivers/bus/sunxi-rsb.c b/drivers/bus/sunxi-rsb.c index 17343cd75338..012e82f9b7b0 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, + 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); + } 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; }