From patchwork Fri Jan 6 08:21:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yipeng Zou X-Patchwork-Id: 13091060 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 81441C3DA7A for ; Fri, 6 Jan 2023 08:25:28 +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: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:In-Reply-To:References: List-Owner; bh=Ou0+sAcOVZCchwFHh5e/2Zd8rCHujydVlahIXjLBwFA=; b=Hoett3YLwgym1a fYZ0lfkw16CIEEnXY6y8J29X8DHQweo/mHBRq5tazhmpZ6elyUGXQYObVWymrjTmyw8PQDVyyiRtP qocBPiB9A1RdYp7kQ2E7OOAdAkQ9VigZFioWB9CRWEQHmQqQjcPEG2fwZZW5vPMytMGBwc3rJ9kTh FYy6Rh6kCx40LT7cFUKWMk8N+isF1/mwA9M44ANJe5Jh9BniykDSwM33PNd2y9edN3rnAKG1S9k74 2aRbm0PpvQ/+ltu46CTHK3pXmnGz5/7/I6TjTtWk0U7bmSfd//rkbccVCzp/T0uqSZG4KHmcHA3gT Z3jiNcQpuXclvRpPQMNg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pDi1g-006adY-VW; Fri, 06 Jan 2023 08:24:33 +0000 Received: from szxga01-in.huawei.com ([45.249.212.187]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pDi1b-006aXN-B8 for linux-arm-kernel@lists.infradead.org; Fri, 06 Jan 2023 08:24:29 +0000 Received: from dggpemm500016.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NpGYQ1PMGznV9b; Fri, 6 Jan 2023 16:22:50 +0800 (CST) Received: from huawei.com (10.67.175.41) by dggpemm500016.china.huawei.com (7.185.36.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 6 Jan 2023 16:24:18 +0800 From: Yipeng Zou To: , , , CC: , , , Subject: [RFC PATCH] irqchip/gic-v3: wait irq done to set affinity Date: Fri, 6 Jan 2023 16:21:36 +0800 Message-ID: <20230106082136.68501-1-zouyipeng@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.67.175.41] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500016.china.huawei.com (7.185.36.25) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230106_002427_591898_267D3C39 X-CRM114-Status: GOOD ( 16.64 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Recently we have some problem about gic set affinity in our test. This patch just aim to make some discuss about this problem. For now, the implementation of gic set affinity going to take effects immediately, and without check if any irq are being processed. So, This leads to some problem, think about this scenario: 1. First, we have an irq was generated by an device. 2. In the processing of this irq(after handle event, before clear IRQD_IRQ_INPROGRESS flag), we modify the route and the gic takes effect immediately,at the same time the new one was generated again. 3. The new irq will be processing in other cpu which different form the old one. 4. The new irq going to be discarded because of the flag IRQD_IRQ_INPROGRESS has been set. I notice that if we set IRQF_ONESHOT when register the irq, this problem will gone. But I'm also thinking about change the gic_set_affinity function, to wait current irq done on all cpus before gic_write_irouter. I'm not sure if that's appropriate. Is the best workaround to use IRQF_ONESHOT to prevent reentrancy? Please let me know, if have any other suggestions on this issue. Signed-off-by: Yipeng Zou --- drivers/irqchip/irq-gic-v3.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index 997104d4338e..e9b9f15f07f8 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -1348,6 +1348,8 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val, reg = gic_dist_base(d) + offset + (index * 8); val = gic_mpidr_to_affinity(cpu_logical_map(cpu)); + // wait irq done on all cpus + gic_write_irouter(val, reg); /*