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 A0A1BC433FE for ; Mon, 7 Nov 2022 11:31:39 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=b+WR+6Unu5qtwqTPZLyu8rWc9TlkL3pmzUJmAKrVdeM=; b=V//nAgn6NgUkXJ WJBANVJ70fvsuyGPQ4d3KTkaRuDC/rIBLCgiWr8kss9j7gVBCOkOiqFsqGT+fCziuXGGebxrlBNio kppWM10YgASDgQhRbMJdbCJ53u6Uk6pnu5qaFfUhEnTzvveWRqky8ntmy7QsdrljOPr3K1FRI9BFL kiOJTLh3voEERDZVfLGLOUdt+i6Io5G7zUm3TMRKWVS/IuAdaZWDjBORLnRvZXINBS1eMhSZIDloj MHhgANAgiltZvsgdJJAT8UPh+G8+xqYAsAw8ze+LJoDCyp/45toJKgi2lXoTJbqnCIIb35ARuONPM ZxR0tWNgvtBRL8mLZE3Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1os0Kw-00E9lr-On; Mon, 07 Nov 2022 11:30:42 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1os0Kt-00E9lA-IW for linux-arm-kernel@lists.infradead.org; Mon, 07 Nov 2022 11:30:41 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7858B1FB; Mon, 7 Nov 2022 03:30:44 -0800 (PST) Received: from donnerap.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4D99C3F73D; Mon, 7 Nov 2022 03:30:37 -0800 (PST) Date: Mon, 7 Nov 2022 11:30:29 +0000 From: Andre Przywara To: Samuel Holland Cc: Chen-Yu Tsai , Jernej Skrabec , linux-arm-kernel@lists.infradead.org, Ivaylo Dimitrov , linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev Subject: Re: [PATCH v2 2/2] bus: sunxi-rsb: Support atomic transfers Message-ID: <20221107112949.21f52e50@donnerap.cambridge.arm.com> In-Reply-To: <20221107052201.65477-3-samuel@sholland.org> References: <20221107052201.65477-1-samuel@sholland.org> <20221107052201.65477-3-samuel@sholland.org> Organization: ARM X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.32; aarch64-unknown-linux-gnu) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221107_033039_742130_A78B94CE X-CRM114-Status: GOOD ( 22.52 ) 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: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sun, 6 Nov 2022 23:22:00 -0600 Samuel Holland wrote: Hi, > 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); So if I understand correctly, this mimics the operation of sunxi_rsb_irq(), just replacing rsb->status with status. But wouldn't that also mean that we need to clear the interrupt bits in INTS, since we are about to handle them below? It probably doesn't matter in practise, since we call this during power down only, but looks like more robust to do, from a driver's perspective. Cheers, Andre > + } 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; > } _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel