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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F7EBC3DA7A for ; Fri, 6 Jan 2023 11:56:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229837AbjAFL4I (ORCPT ); Fri, 6 Jan 2023 06:56:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229478AbjAFL4E (ORCPT ); Fri, 6 Jan 2023 06:56:04 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4123019C1D for ; Fri, 6 Jan 2023 03:56:00 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D41B1B81C0B for ; Fri, 6 Jan 2023 11:55:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63228C433EF; Fri, 6 Jan 2023 11:55:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673006157; bh=QJdJJzHA84xosb3/5O3JTakwPPG3EeY41Ynnwj8ARTM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=DpDlHEHmINK9zh3eUPid8aimfLcqD7iJqhxZBHW/4qxrIS2tC0i/LoM9wnQUOq1p6 EgRUahaB5GEGI9kqdZlwcchwywHKVh5GtTDDR3IWPNnQ02NDJVtYTh+ww+GE96desz s3dgKNfQroNKJQbR0VHNU2pQYtlt6UHvwy40H/qoVbGunW3sPVi881TiJHOrz2ZOyV xQ+dClwSo+18hrE/K2IB8yCfqiUijEyQr4pi5lbdlag8AJeMgL1jJIx4LcXai4XJKE mfTvh8LXf1xoOq4EZHSSSHvXPcZYUftkfuwU7CHG63UGsk7zVlBF9InsgluXV5usha 8LBJW2fo8IzeQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pDlKF-00HGds-4S; Fri, 06 Jan 2023 11:55:55 +0000 Date: Fri, 06 Jan 2023 11:55:54 +0000 Message-ID: <86pmbrop11.wl-maz@kernel.org> From: Marc Zyngier To: Yipeng Zou Cc: , , , , , Subject: Re: [RFC PATCH] irqchip/gic-v3: wait irq done to set affinity In-Reply-To: <20230106082136.68501-1-zouyipeng@huawei.com> References: <20230106082136.68501-1-zouyipeng@huawei.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: zouyipeng@huawei.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, hewenliang4@huawei.com, chris.zjh@huawei.com, liaochang1@huawei.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 06 Jan 2023 08:21:36 +0000, Yipeng Zou wrote: > > 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. How is that possible? If it is affected by GICD_IROUTERn (as your patch suggests), then it is a SPI. If it is a SPI, it has an active state. Which means it cannot fire again without a deactivation (EOI if EOImode=0, EOI+DIR if EOImode=1) having taken place. So either something has deactivated the interrupt without masking it beforehand, or the active state is not honoured. Either way, this is wrong. > > 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. The base architecture should guarantee that this is not a problem, thanks to the active state. If that was a LPI (which do not have an active state), that'd be a different problem. But this doesn't seem to be the case here. I'm afraid to say that what you describe seem like a bug of some sort, either HW or SW. Thanks, M. -- Without deviation from the norm, progress is not possible. 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 3CB4AC4708D for ; Fri, 6 Jan 2023 11:56:55 +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: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=fFYMhrD37lzfDQfYErhGDMXExYO14wOgx0tNEG6Akz8=; b=2jQgDnS9rICu1x URDpXZPSW4kykiKBayD+uMTVwyUF1moM5oGCW3kmULTCRCnihMyUwIwhMmiau0ihKPfXbEUu8mkZr PpN6PXopIy+ic2irgfZbFOs3yEy/oOEjVkK78FwSlK+d2mL3l/cgdPohG6V+QLeZNXgwxJiwb5Fey 9gTn130Gitq4+Wiw8R1NLj9Sbtui+NViJ6YysMDjpF1iJf4IsUmn32bpLPhF3e0vgETlqCQ3H9zfq yOoeFXW8wvIs6QFDk6zCWv72TIfyK5yj6XteZIr71/VNd1phbKCkS85ycLIwJFuWSn8G66PUQu6xM h38uznT02oX+9dOl84gA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pDlKL-007qsR-O9; Fri, 06 Jan 2023 11:56:01 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pDlKJ-007qr1-CI for linux-arm-kernel@lists.infradead.org; Fri, 06 Jan 2023 11:56:00 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0273161DA4; Fri, 6 Jan 2023 11:55:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63228C433EF; Fri, 6 Jan 2023 11:55:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673006157; bh=QJdJJzHA84xosb3/5O3JTakwPPG3EeY41Ynnwj8ARTM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=DpDlHEHmINK9zh3eUPid8aimfLcqD7iJqhxZBHW/4qxrIS2tC0i/LoM9wnQUOq1p6 EgRUahaB5GEGI9kqdZlwcchwywHKVh5GtTDDR3IWPNnQ02NDJVtYTh+ww+GE96desz s3dgKNfQroNKJQbR0VHNU2pQYtlt6UHvwy40H/qoVbGunW3sPVi881TiJHOrz2ZOyV xQ+dClwSo+18hrE/K2IB8yCfqiUijEyQr4pi5lbdlag8AJeMgL1jJIx4LcXai4XJKE mfTvh8LXf1xoOq4EZHSSSHvXPcZYUftkfuwU7CHG63UGsk7zVlBF9InsgluXV5usha 8LBJW2fo8IzeQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pDlKF-00HGds-4S; Fri, 06 Jan 2023 11:55:55 +0000 Date: Fri, 06 Jan 2023 11:55:54 +0000 Message-ID: <86pmbrop11.wl-maz@kernel.org> From: Marc Zyngier To: Yipeng Zou Cc: , , , , , Subject: Re: [RFC PATCH] irqchip/gic-v3: wait irq done to set affinity In-Reply-To: <20230106082136.68501-1-zouyipeng@huawei.com> References: <20230106082136.68501-1-zouyipeng@huawei.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: zouyipeng@huawei.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, hewenliang4@huawei.com, chris.zjh@huawei.com, liaochang1@huawei.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230106_035559_533036_DB1CE0FF X-CRM114-Status: GOOD ( 29.89 ) 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 Fri, 06 Jan 2023 08:21:36 +0000, Yipeng Zou wrote: > > 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. How is that possible? If it is affected by GICD_IROUTERn (as your patch suggests), then it is a SPI. If it is a SPI, it has an active state. Which means it cannot fire again without a deactivation (EOI if EOImode=0, EOI+DIR if EOImode=1) having taken place. So either something has deactivated the interrupt without masking it beforehand, or the active state is not honoured. Either way, this is wrong. > > 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. The base architecture should guarantee that this is not a problem, thanks to the active state. If that was a LPI (which do not have an active state), that'd be a different problem. But this doesn't seem to be the case here. I'm afraid to say that what you describe seem like a bug of some sort, either HW or SW. Thanks, M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel