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 BD8F0C87FCF for ; Thu, 7 Aug 2025 12:55:56 +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:References :In-Reply-To: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=meFrZ6t1F/jhU30h78Tk3uubPL+fmVZQIYbThrgYvwM=; b=KCO69gf4iYQfya hSb1oUftPdRqk7BR5Lwvz5ymTTO/WYrOmoZes+8KgwycjreRk6hSkO7RMX47bBF0yj4FJ3TcpG3/c xtAGeYcJvXkeLL3Nnpeqvbw4hHQpbg0ZmhsFQ4GKBf/PxscfyLpiyCPFW/wMzybHYhBeOIiG/MIfe qwVodc8WxEWKIJ7wCz4GLC2CJKx/a0bloMgqyG7Gqaj6st2HZxHmCGbI30Pm5IyAfHfvtsxweh7BS ZBT18KHMc1ImiUz/by1dYVW9TDR5Dk+Hzeh3YQMSPW2/Iil/CXwXkiHLCGl54hnco5VFaU9R6cD1L TPLgPpR0WkAmWH8Pz0CQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uk09n-00000000c9L-0PXJ; Thu, 07 Aug 2025 12:55:43 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1ujzuS-00000000ZTd-2TBn for linux-riscv@lists.infradead.org; Thu, 07 Aug 2025 12:39:53 +0000 From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1754570389; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=H04ZIKmE6o/aPmfvgSEleptBdX7dH7MfiferMt7opCk=; b=NZsPU/PbjAmXPLlxHSsskQxfOtibTbwPmlJokCaaAPMOjTFYCn+2cJlZ7fYnA1fMTc3lCu n0XXake88wIY4bmJhFeTs0YjdBcQ2e1SBLlLp+95Tr12Txh/kpTFNMDGszDdWwvEhafK78 ZcCuuuiFX1sgn6lXLpC5USt9Phjr7hNi7HMsESOCvOOxk/jR3ozzijPU0QNVTwVYo/tkkB OxJ/Qp5WQlfJVuUlNAsSzu+fW/3EEKc7zKILYspOpYNjL8W6YICh7NGQIKNMlMq3z93hXR 4/zVbF0HGELzmQaUL4uX6YDNIbiU7ryyi+Ly15+B0OlEGmL+uG4np0BLfmnsnQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1754570389; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=H04ZIKmE6o/aPmfvgSEleptBdX7dH7MfiferMt7opCk=; b=TepyGY1Q/w6JTWISuc7uBnfYRybQDBGRbEiIniDXkeS7XOTOy9r4ek7IMPif/ZYZVvKDqQ 9W16cb2F6VkPC9Ag== To: Inochi Amaoto , Thomas Gleixner , Paul Walmsley , Samuel Holland Cc: Inochi Amaoto , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Yixun Lan , Longbin Li Subject: Re: [PATCH] irqchip/sifive-plic: Respect mask state when setting affinity In-Reply-To: <20250807111806.741706-1-inochiama@gmail.com> References: <20250807111806.741706-1-inochiama@gmail.com> Date: Thu, 07 Aug 2025 14:39:42 +0200 Message-ID: <87fre3mhkh.fsf@yellow.woof> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250807_053952_765038_E487C81F X-CRM114-Status: GOOD ( 15.05 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Inochi Amaoto writes: > The plic_set_affinity always call plic_irq_enable(), which clears up > the priority setting even the irq is only masked. This make the irq > unmasked unexpectly. > > Replace the plic_irq_enable/disable() with plic_irq_toggle() to > avoid changing priority setting. > > Suggested-by: Thomas Gleixner > Signed-off-by: Inochi Amaoto > --- > drivers/irqchip/irq-sifive-plic.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c > index bf69a4802b71..5bf5050996da 100644 > --- a/drivers/irqchip/irq-sifive-plic.c > +++ b/drivers/irqchip/irq-sifive-plic.c > @@ -148,6 +148,7 @@ static void plic_irq_enable(struct irq_data *d) > > static void plic_irq_disable(struct irq_data *d) > { > + plic_irq_mask(d); > plic_irq_toggle(irq_data_get_effective_affinity_mask(d), d, 0); > } This part is not required for the problem you are addressing, right? I do not oppose the change, I'm just curious if I miss something here. > > @@ -179,12 +180,14 @@ static int plic_set_affinity(struct irq_data *d, > if (cpu >= nr_cpu_ids) > return -EINVAL; > > - plic_irq_disable(d); > + /* Invalidate the original routing entry */ > + plic_irq_toggle(irq_data_get_effective_affinity_mask(d), d, 0); > > irq_data_update_effective_affinity(d, cpumask_of(cpu)); > > + /* Setting the new routing entry if irq is enabled */ > if (!irqd_irq_disabled(d)) > - plic_irq_enable(d); > + plic_irq_toggle(irq_data_get_effective_affinity_mask(d), d, 1); > > return IRQ_SET_MASK_OK_DONE; > } This part makes sense: Reviewed-by: Nam Cao Tested-by: Nam Cao # VisionFive 2 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8EF2824728B for ; Thu, 7 Aug 2025 12:39:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754570393; cv=none; b=ayw/xG0eyEeOrPwJIt6th9UgXM+x7+X4oYajs5zrjJTe3cSYjmdW7hSPL0ok8EYRIOHavVplz/dwCD1E8E5M9Vb9IWJ+1boO/PZsY6KogWdUSa+BVkAGKQ39wWYB7fZ80smWo2i7dw2PLF190rcuVXDkrrlqAzcDIqrSfzOjGts= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754570393; c=relaxed/simple; bh=IhNfL21psMTR3yWMWB9MAI03PjqKlLcbpYNauM4CdRQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=IK/oezuJDmYt5DpY6H5gLmgBnZXmcPkip4EW5NZ225o71XWqVH+GAOU2QgW6lLCcm9YFml2ATm8Y6C1KnCS4zGLVVJX4VhAYf1x1feN8EQYvTGKd+AS0hpH4brKBc0raGVfkU8lg94ieDia0Zw2VMFw06lnZ4fwMqKmybLEl1d4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=NZsPU/Pb; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=TepyGY1Q; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="NZsPU/Pb"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="TepyGY1Q" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1754570389; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=H04ZIKmE6o/aPmfvgSEleptBdX7dH7MfiferMt7opCk=; b=NZsPU/PbjAmXPLlxHSsskQxfOtibTbwPmlJokCaaAPMOjTFYCn+2cJlZ7fYnA1fMTc3lCu n0XXake88wIY4bmJhFeTs0YjdBcQ2e1SBLlLp+95Tr12Txh/kpTFNMDGszDdWwvEhafK78 ZcCuuuiFX1sgn6lXLpC5USt9Phjr7hNi7HMsESOCvOOxk/jR3ozzijPU0QNVTwVYo/tkkB OxJ/Qp5WQlfJVuUlNAsSzu+fW/3EEKc7zKILYspOpYNjL8W6YICh7NGQIKNMlMq3z93hXR 4/zVbF0HGELzmQaUL4uX6YDNIbiU7ryyi+Ly15+B0OlEGmL+uG4np0BLfmnsnQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1754570389; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=H04ZIKmE6o/aPmfvgSEleptBdX7dH7MfiferMt7opCk=; b=TepyGY1Q/w6JTWISuc7uBnfYRybQDBGRbEiIniDXkeS7XOTOy9r4ek7IMPif/ZYZVvKDqQ 9W16cb2F6VkPC9Ag== To: Inochi Amaoto , Thomas Gleixner , Paul Walmsley , Samuel Holland Cc: Inochi Amaoto , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Yixun Lan , Longbin Li Subject: Re: [PATCH] irqchip/sifive-plic: Respect mask state when setting affinity In-Reply-To: <20250807111806.741706-1-inochiama@gmail.com> References: <20250807111806.741706-1-inochiama@gmail.com> Date: Thu, 07 Aug 2025 14:39:42 +0200 Message-ID: <87fre3mhkh.fsf@yellow.woof> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Inochi Amaoto writes: > The plic_set_affinity always call plic_irq_enable(), which clears up > the priority setting even the irq is only masked. This make the irq > unmasked unexpectly. > > Replace the plic_irq_enable/disable() with plic_irq_toggle() to > avoid changing priority setting. > > Suggested-by: Thomas Gleixner > Signed-off-by: Inochi Amaoto > --- > drivers/irqchip/irq-sifive-plic.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c > index bf69a4802b71..5bf5050996da 100644 > --- a/drivers/irqchip/irq-sifive-plic.c > +++ b/drivers/irqchip/irq-sifive-plic.c > @@ -148,6 +148,7 @@ static void plic_irq_enable(struct irq_data *d) > > static void plic_irq_disable(struct irq_data *d) > { > + plic_irq_mask(d); > plic_irq_toggle(irq_data_get_effective_affinity_mask(d), d, 0); > } This part is not required for the problem you are addressing, right? I do not oppose the change, I'm just curious if I miss something here. > > @@ -179,12 +180,14 @@ static int plic_set_affinity(struct irq_data *d, > if (cpu >= nr_cpu_ids) > return -EINVAL; > > - plic_irq_disable(d); > + /* Invalidate the original routing entry */ > + plic_irq_toggle(irq_data_get_effective_affinity_mask(d), d, 0); > > irq_data_update_effective_affinity(d, cpumask_of(cpu)); > > + /* Setting the new routing entry if irq is enabled */ > if (!irqd_irq_disabled(d)) > - plic_irq_enable(d); > + plic_irq_toggle(irq_data_get_effective_affinity_mask(d), d, 1); > > return IRQ_SET_MASK_OK_DONE; > } This part makes sense: Reviewed-by: Nam Cao Tested-by: Nam Cao # VisionFive 2