Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1295236pxu; Fri, 16 Oct 2020 08:33:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwy9Zx3/wugv14rxivwq3B+t2gu4vL3eef/92X/6d8zufrClVjCzBD90jKjXgkANqRiWqj1 X-Received: by 2002:a17:906:1957:: with SMTP id b23mr4254184eje.312.1602862420404; Fri, 16 Oct 2020 08:33:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602862420; cv=none; d=google.com; s=arc-20160816; b=g9P5l0zqROqYQy58vNY+CLTnehwlD5t864B/2GG1nIKN87y72xIp92OWUTaUoWXLrn clpXbVuAaVNREfwPkQb3e5w/H4DldPXlbJK0g+FmAStPIbgJvxMqEhPq5SAXxC4m9rqD RJxXpCHWzUJBeVtL+IuSNSJkcSeavsWTY0k08PlDxwWwo5iEUM5wVDS2IJQZPHlKnQyg bk2IaV0yOcnEgb+48nfQ6kDVOpvBr8DIa2IY1Jc61yhwIJ4lveYRya1PFhKsNYsl+NbF DzAk4HHwhlown4QSPJKGJ78Lo/C1YzH9RmXI398taV7/kUuYivkzeTvKHN/wzRUYlCCT OBBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=3qZ3wBDxLlc4y2LdirJcgerLsIDb2RZnNo4XttMjq30=; b=NUY/5hOmi3zmhmqjYuf3/ZuYfEYbC/ggeoPD0OlkBw/XYAv0Yq30JLEfVL59A3Ntf3 jRpZ4NdY+EWxo6qveUtU/89X091WZntUPErawsXYRB9z3SSVFpSsvvq6rrduSCeQx+l5 af7LY9ShFRBx6Li39wLKAoCLTB1UWNuerVDTMFHHTyWqs9hXYl64bjm9Qlyt2GxV16XY ARn3J1P/xELatViRGAoI1ahJtBQ2qCztxryEwYJsJD7AYi2AhAjABFRmaJ6CzhTj1RIi HQIWmIdrMKE24Yyo7ciHK2xZ0G4i7SMZQhi94dyXshfM8GGHbyApPU7gfsfx337cJ5ZE t43Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=LJz8u0pL; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=p6ALofZG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dp6si1955849ejc.610.2020.10.16.08.33.18; Fri, 16 Oct 2020 08:33:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=LJz8u0pL; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=p6ALofZG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2408346AbgJPNmc (ORCPT + 99 others); Fri, 16 Oct 2020 09:42:32 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:44696 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2407058AbgJPNm3 (ORCPT ); Fri, 16 Oct 2020 09:42:29 -0400 From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1602855747; 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=3qZ3wBDxLlc4y2LdirJcgerLsIDb2RZnNo4XttMjq30=; b=LJz8u0pLozePlNZYgZvvpyj/qhL5C+MTWzbqD1eu+aQX3xvB+nIhmh51tGKAbVFdSMSXXn bgOI8oFYUBzoQV2R+l6uLsM9+2lhxK6DweO9H6eQGNE7z5ectfb0823f66a9pezbNcg2zO enw/POzOO9vGilP73TJDT0qmYRyID39Q0DeUpXBnADcGpy+rnJg6Yoye+HPQbOb/NaLP/Q cHlwZKPmNQVKIZfJlA/5XDTOC9Y6Fz86kLHgzEhFatJ70/ZzqEeSjO6FOBmow5gvGXsXbB 9G7vek0DpCNRR1WoZ3IQk67AHjNsdE8YTrr/1rKFVFQh7COU+hNuvn5Ug2trCg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1602855747; 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=3qZ3wBDxLlc4y2LdirJcgerLsIDb2RZnNo4XttMjq30=; b=p6ALofZGtMZBBzMf1J4rWNqTtXAgvjanZlwcjpEBhrQUzIw/w2upgOl64RezJ32xRpQ8Tn 9sxasXqA3HsrFyAQ== To: Marc Zyngier , Greentime Hu Cc: jason@lakedaemon.net, palmer@dabbelt.com, paul.walmsley@sifive.com, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Subject: Re: [PATCH 2/2] irqchip/sifive-plic: Fix the interrupt was enabled accidentally issue. In-Reply-To: <5bedfbc723665c979eb73eefadb21970@kernel.org> References: <20201012135724.110579-1-greentime.hu@sifive.com> <20201012135724.110579-2-greentime.hu@sifive.com> <5bedfbc723665c979eb73eefadb21970@kernel.org> Date: Fri, 16 Oct 2020 15:42:27 +0200 Message-ID: <87ft6ethh8.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 15 2020 at 22:23, Marc Zyngier wrote: > On 2020-10-12 14:57, Greentime Hu wrote: >> In commit 2ca0b460bbcb ("genirq/affinity: Make affinity setting if >> activated opt-in"), This commit sha does not exist in mainline. Referencing a random stable kernel tree is useless. >> it added irqd_affinity_on_activate() checking in the function >> irq_set_affinity_deactivated() so it will return false here. >> In that case, it will call irq_try_set_affinity() -> plic_irq_toggle() >> which will enable the interrupt to cause the CPU hang. >> @@ -183,10 +183,14 @@ static int plic_irqdomain_map(struct irq_domain >> *d, unsigned int irq, >> irq_hw_number_t hwirq) >> { >> struct plic_priv *priv = d->host_data; >> + struct irq_data *irqd; >> >> irq_domain_set_info(d, irq, hwirq, &plic_chip, d->host_data, >> handle_fasteoi_irq, NULL, NULL); >> irq_set_noprobe(irq); >> + irqd = irq_get_irq_data(irq); >> + irqd_set_single_target(irqd); >> + irqd_set_affinity_on_activate(irqd); >> irq_set_affinity(irq, &priv->lmask); >> return 0; >> } > > How does this fix anything? The plic driver doesn't have an activate > callback, so how does it make any difference? I get the feeling this > papers over another issue. The existence of the activate callback is not really the interesting part. And of course the analysis is completely bogus. The referenced commit is a follow up to: baedb87d1b53 ("genirq/affinity: Handle affinity setting on inactive interrupts correctly") which was added on Jul 17 and the fix was added on Jul 24: f0c7baca1800 ("genirq/affinity: Make affinity setting if activated opt-in") The latter restored the original behaviour within 7 days, except for x86. And the original behaviour was that the core did not care about the activated state at all. It just invoked irqchip->irq_set_affinity() unconditionally, which is still does except when the interrupt is marked with irqd_set_affinity_on_activate(). So the plic code had this problem before that change already: irq_set_noprobe(irq); irq_set_affinity(irq, &priv->lmask); Mapping happens way before anything else, so Hu is definitely barking up the wrong tree. What the patch works around is the irq_set_affinity() callback which is completely bogus and still broken even after that duct tape which" fixes" the boot fail. irq_set_affinity() can be called on masked interrupts so this: plic_irq_toggle(&priv->lmask, d, 0); plic_irq_toggle(cpumask_of(cpu), d, 1); will always unconditionally unmask the interrupt when affinity is changed. plic_irq_toggle(cpumask_of(cpu), d, !irqd_irq_masked(d)); is all it needs to work everywhere. Obvious, right? The changelog wants to be "...: Fix broken irq_set_affinity() callback" and the Fixes: tag referencing the commit which introduced that unconditional unmask. Oh well. Thanks, tglx