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 D6174C4332F for ; Mon, 14 Nov 2022 21:01:13 +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:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=n9m8LMP4zOdbe8OYdFaSDjgQ3Khwd7c49pRYUzkiJUQ=; b=HoHOY95BEfzdGo n6Cx6HA0cqsuYDkufd/KVt3PKDSOJAHtvMC/2JTtjAbVfjdC/QOkwkwp3xdfj+w3ComxfiJwxJp3H oWM9eafHir7wi9caxmt3ZP6w4gP5duhw6/tkxaYbTiQMh060IGQW77GzNntqxtDpbykBjRCKqX45u TBmLCJu5lRPjkwKwHNp8ugXSkzYxXpGmBVKK/fBwjiyBkFkiqFtfHrGlZSTNsingxew6Vw/af/zKP mrBBqaQ9UJRUZRP2AjORbYCaEeIGYmz7+iLIV5aiQSB8j7cEAzyDFoLriNwXIKDAXt7BwNxAraqUz YA9APqLfq8zeYUC7Nnxg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ougZ0-0051ai-5U; Mon, 14 Nov 2022 21:00:18 +0000 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ougYv-0051Yf-SR for linux-arm-kernel@lists.infradead.org; Mon, 14 Nov 2022 21:00:15 +0000 Received: by mail-ed1-x531.google.com with SMTP id e13so10143641edj.7 for ; Mon, 14 Nov 2022 13:00:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=40S/F5BELCFB3y9d/ai9+Kw1YT1iYA4dyds8YjgYhaY=; b=Xw5Wf5b7B/XodNUpFS/B6Ov4czpPP8CjSWwIVohdOnh3SKVillyHvAllg5+8ECplGF n9lo0tIQqE6XEVUignZBgYlhd6MluozJKU64iwAsu1y0OmB+TE1uck7m/XujJPgQDC/6 B6uZdE55WIUqCXlRbCJCG7To74VkzcDaYN8B73XyYaeoQps8qMdaInj/+bFm61XUubav fi+p3m0NWbVKskCSuw+s8StvrNSh40vQ3F6P1b9o2FCALPAoNmCEFSwZomqjTTa8y8HE Dy9zoCioYuk/gJRhFJOoRkmQGxYurCA0e2M2zetIV0lLsoXjqjs1/VNWm4/Tm0z5oAo9 Ziww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=40S/F5BELCFB3y9d/ai9+Kw1YT1iYA4dyds8YjgYhaY=; b=IuMzdcRNSyoPthJ2Zp0LKdL6YScGSkGQifPkvo+QVbpm2b/94k0yYwyK9J4xjOhsk7 x1fZdBz6IWH99G9JeQuxborBnQMGsUPSnwfvPtdsMgId8q6pEzEe0AQG+ZVeN5UUwEkl xjFqbrrBPucfc5m85K2u8woccCU+GFCFKK0HXOn2JqlbbbaaH29uCLX6Ux4h2MSwYkn7 kx/JHuHLXm4d4SFKyZ2jNEccmyb0OVYwvIf1SKom1Wppq1zY6EJKOsvkr3i5rksTOV6g 1eQ56WJLOsRh/LNADncsBv5akdTJ2TxDPE4RSifXfvwwdOvMvqoPb2pyD3wLlHN7kbYr T1XA== X-Gm-Message-State: ANoB5pmJb8ZtzYk40xhyq14hP1j23ubVKBC4a8pGRH7o6VCVprMbLz00 CQ4qkcjBYsAmuq20a2Cyuyw= X-Google-Smtp-Source: AA0mqf6G5js9yVA+Wu3EQp7CP6PyKNGeW/0xYFHxWYs1E7lEod9nMTctxOBnOzt/UHlB+0vW018ZPg== X-Received: by 2002:a05:6402:1cc4:b0:462:df63:5ec5 with SMTP id ds4-20020a0564021cc400b00462df635ec5mr12618430edb.147.1668459608543; Mon, 14 Nov 2022 13:00:08 -0800 (PST) Received: from jernej-laptop.localnet (82-149-19-102.dynamic.telemach.net. [82.149.19.102]) by smtp.gmail.com with ESMTPSA id kw26-20020a170907771a00b00781d411a63csm4585087ejc.151.2022.11.14.13.00.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Nov 2022 13:00:08 -0800 (PST) From: Jernej =?utf-8?B?xaBrcmFiZWM=?= To: Chen-Yu Tsai , Samuel Holland Cc: Ivaylo Dimitrov , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev, Andre Przywara , Samuel Holland Subject: Re: [PATCH v3 3/3] bus: sunxi-rsb: Clear interrupt status before each transfer Date: Mon, 14 Nov 2022 22:00:06 +0100 Message-ID: <2170633.72vocr9iq0@jernej-laptop> In-Reply-To: <20221114015749.28490-4-samuel@sholland.org> References: <20221114015749.28490-1-samuel@sholland.org> <20221114015749.28490-4-samuel@sholland.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221114_130013_973276_81D3EE10 X-CRM114-Status: GOOD ( 25.19 ) 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 Hi Samuel, Dne ponedeljek, 14. november 2022 ob 02:57:49 CET je Samuel Holland napisal(a): > 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. where is this bit cleared? > 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); Wouldn't be better to clear status before enabling interrupts? Unless global interrupt flag is cleared beforehand, but I don't see that anywhere. Best regards, Jernej > 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; > } _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel