From nobody Thu Apr 9 15:26:15 2026 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 9B47CC4332F for ; Mon, 7 Nov 2022 05:22:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230263AbiKGFWR (ORCPT ); Mon, 7 Nov 2022 00:22:17 -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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Seri= al 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) =20 reinit_completion(&rsb->complete); =20 - writel(RSB_INTS_LOAD_BSY | RSB_INTS_TRANS_ERR | RSB_INTS_TRANS_OVER, + int_mask =3D 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); =20 - if (!wait_for_completion_io_timeout(&rsb->complete, - msecs_to_jiffies(100))) { + if (irqs_disabled()) { + timeout =3D readl_poll_timeout_atomic(rsb->regs + RSB_INTS, + status, (status & int_mask), + 10, 100000); + } else { + timeout =3D !wait_for_completion_io_timeout(&rsb->complete, + msecs_to_jiffies(100)); + status =3D rsb->status; + } + + if (timeout) { dev_dbg(rsb->dev, "RSB timeout\n"); =20 /* abort the transfer */ @@ -292,18 +305,18 @@ static int _sunxi_rsb_run_xfer(struct sunxi_rsb *rsb) return -ETIMEDOUT; } =20 - if (rsb->status & RSB_INTS_LOAD_BSY) { + if (status & RSB_INTS_LOAD_BSY) { dev_dbg(rsb->dev, "RSB busy\n"); return -EBUSY; } =20 - 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; } =20 - 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; } --=20 2.37.3