Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp6136501rwl; Mon, 9 Jan 2023 04:47:43 -0800 (PST) X-Google-Smtp-Source: AMrXdXv4khQ/TKaMJBdU6ssivsTf66omeTNHFNCoW+sa3SDXT35Y0HxQyEH1HWDv12HugXqlW2Ph X-Received: by 2002:a05:6a21:3996:b0:9d:efbf:7876 with SMTP id ad22-20020a056a21399600b0009defbf7876mr80133720pzc.43.1673268463397; Mon, 09 Jan 2023 04:47:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673268463; cv=none; d=google.com; s=arc-20160816; b=H21MceQs0T1PPhrZPS25a7iYiimbshaODGrojfwq+h+o1sAEe7nbvRawqcQ5n5mr5V bacyrY9OeUg0/BrQCfVpboMV9KiCV0LkKnmVOlnxDsh2pyIuvfe5tD6GUaXnvhH0nXC/ eXWUs8TztcJ/cgS507HZXmsI+88t5/4xWRQzl5wzNZsNq74aDjELMS82c7leOH+BoHux ovJr+Cxfj3y8l452mo/JoUdFXIRQIcOvEzGGAIkwDfykmAoek4V4vYpJOLSPmcJW86cz fh3bTqqUfVMeLpn5O8n3NqxXFKZnisrmpkPXXJOWrTw41fQyrxEpHCU7BcLuAqPkztCo V1ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=93kvtRN3hsbULNenqEi6mGV6sXrNNUJ5CLc7KmtjSUY=; b=C1n7OBWR9thGFLw0yZ+MIvj/6hSWWcxV618JsA2nAZb0CTsARMPwDCgTY7B3V9mlaK bO3hgZTZLxFobHokp3HeH2nBnZ2VoNFN3u1gNnDE2+Y5Rxzfi5ZzJBAPQOfFsyKup1e2 vxxTDCmZkvEUSSR5YPserx+xD39ayjTj8bjCowu5jMvxiWQNMps6eQOuTn7LjFrRLGdM dsJvFYadQfy8KIG5qZUVUj+EdL6uKURfWP3/N0RNPNAKvrqwR8a8iPruZTr58bzncVIl BXw0pqc0UWQm8ONRHH4vALWw1pZTGCJL9dsEbaOLfzA8bNLR+EOuFi4uoSBL1VDt2snG o/lA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 28-20020a630f5c000000b004769f0faab8si9076903pgp.740.2023.01.09.04.47.36; Mon, 09 Jan 2023 04:47:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234257AbjAIM0z (ORCPT + 54 others); Mon, 9 Jan 2023 07:26:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234210AbjAIM0w (ORCPT ); Mon, 9 Jan 2023 07:26:52 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E34521400A for ; Mon, 9 Jan 2023 04:26:49 -0800 (PST) Received: from dggpemm500016.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NrCk33JDLzqTvy; Mon, 9 Jan 2023 20:22:03 +0800 (CST) Received: from [10.67.111.115] (10.67.111.115) 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; Mon, 9 Jan 2023 20:26:47 +0800 Message-ID: <89553b60-c5dc-76ad-67a4-594858ebedee@huawei.com> Date: Mon, 9 Jan 2023 20:26:35 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: Re: [RFC PATCH] irqchip/gic-v3: wait irq done to set affinity Content-Language: en-US To: Marc Zyngier CC: , , , , , References: <20230106082136.68501-1-zouyipeng@huawei.com> <86pmbrop11.wl-maz@kernel.org> From: Yipeng Zou In-Reply-To: <86pmbrop11.wl-maz@kernel.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.111.115] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm500016.china.huawei.com (7.185.36.25) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2023/1/6 19:55, Marc Zyngier 写道: > 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. Yes, agree, There is no possible in SPI case. >> 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. Hi , Thanks for reply very much. I have rechecked our test. Actually, that was a LPI in out test case. It cause the problem since its_send_movi command. I made a mistake when i modified the code.  It should be as follow. Sorry for misleading you. diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 973ede0197e3..fad08ccb7fd9 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -1667,6 +1667,9 @@ static int its_set_affinity(struct irq_data *d, const struct cpumask *mask_val,         /* don't set the affinity when the target cpu is same as current one */         if (cpu != prev_cpu) { + +               // wait irq done on all cpus +                 target_col = &its_dev->its->collections[cpu];                 its_send_movi(its_dev, target_col, id);                 its_dev->event_map.col_map[id] = cpu > I'm afraid to say that what you describe seem like a bug of some sort, > either HW or SW. > > Thanks, > > M. -- Regards, Yipeng Zou