Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3595119pxb; Mon, 25 Jan 2021 22:48:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJwC6POoXcaRcwXUrHS82c/KQPS+VPKQ7ISOe1W1YMuaQ61N0XUTTwXwpyijlkN4HTeyxJ7w X-Received: by 2002:a05:6402:1341:: with SMTP id y1mr3378199edw.273.1611643682113; Mon, 25 Jan 2021 22:48:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611643682; cv=none; d=google.com; s=arc-20160816; b=BMLCSHhsqOvZ9Hy2ef22fdQwXZru2+yE414rLj9fD4U27zsfafUb6E28A5gnZK/jUF XcZJaGwFXlJbalo9mlQnQ/pblC1cTTu/eIuaPEaxRrYWqjqObe2qlj+cQCTWYddPKjfE 3FDP8eMBq/3ETY8xCcuVcKN/8yOzyvtQ/UROlL261km78F0YXf+i059tZbd6ed4WXLaa 0dOb9dU+w1YAtIFJb/X2IuV5xf3diQEILDzEaF94KGxAfZHUKjpA6jzhI+En+bTmwBZK wGaXDWCjrlhJ90+v9nkBiHXs6TJbw6h7puDN/cxN3oKHeTPGgYbiGHcFPg2QPUSU/TkL /CPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:user-agent:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version; bh=YxiWwbfn2FQ00hbdJck8uNUUQ8FOe8svMoOjjN6MjYA=; b=cokMj3jmyglfoH1GqEaCyCjqlYKJRQNAEO9xW3Ch9lP/VtPrJQfzBJtLgTTTZtqLQY GlJrDfQuNmrnD0lsXDxiy5tOgoXslHbe0l7VspmNtQHpI0Xv3M80uIQMoCsRHVx8HbH8 azG7Lw17VoS0vNvZq54xaMtkSkcS189O0YUseQQwYyg5bpkQqt54X9eMPksqA9q3lvOy bW02/D+TBs5VFcuUEoBIpKnnwxv5OwYfnGJAhIzv+t4itTUfo3+9UeNN7cCWd22PIC02 f2Yapfj/qnA+dwfEeK+1sCrxi0We2ygg/hqi9WjKXA5ii85Lj8KvKLlLyLWkhowPSa3s yptA== ARC-Authentication-Results: i=1; mx.google.com; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h14si6547004ejt.198.2021.01.25.22.47.38; Mon, 25 Jan 2021 22:48:02 -0800 (PST) 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; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731490AbhAZGnX (ORCPT + 99 others); Tue, 26 Jan 2021 01:43:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:58416 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729790AbhAYOtY (ORCPT ); Mon, 25 Jan 2021 09:49:24 -0500 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B36A520848; Mon, 25 Jan 2021 14:48:40 +0000 (UTC) Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94) (envelope-from ) id 1l43AU-009tYm-Ut; Mon, 25 Jan 2021 14:48:39 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 25 Jan 2021 14:48:38 +0000 From: Marc Zyngier To: Shameerali Kolothum Thodi Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , Bjorn Helgaas , stable@vger.kernel.org Subject: Re: [PATCH] genirq/msi: Activate Multi-MSI early when MSI_FLAG_ACTIVATE_EARLY is set In-Reply-To: <19ddad1517f0495d92c2248d04cf0d5c@huawei.com> References: <20210123122759.1781359-1-maz@kernel.org> <19ddad1517f0495d92c2248d04cf0d5c@huawei.com> User-Agent: Roundcube Webmail/1.4.10 Message-ID: <4e7ea548f1667410dd6197509ab15ef4@kernel.org> X-Sender: maz@kernel.org X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: shameerali.kolothum.thodi@huawei.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, bhelgaas@google.com, stable@vger.kernel.org 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 2021-01-25 14:39, Shameerali Kolothum Thodi wrote: >> -----Original Message----- >> From: Marc Zyngier [mailto:maz@kernel.org] >> Sent: 23 January 2021 12:28 >> To: linux-kernel@vger.kernel.org >> Cc: Thomas Gleixner ; Bjorn Helgaas >> ; Shameerali Kolothum Thodi >> ; stable@vger.kernel.org >> Subject: [PATCH] genirq/msi: Activate Multi-MSI early when >> MSI_FLAG_ACTIVATE_EARLY is set >> >> When MSI_FLAG_ACTIVATE_EARLY is set (which is the case for PCI), >> we perform the activation of the interrupt (which in the case of >> PCI results in the endpoint being programmed) as soon as the >> interrupt is allocated. >> >> But it appears that this is only done for the first vector, >> introducing an inconsistent behaviour for PCI Multi-MSI. >> >> Fix it by iterating over the number of vectors allocated to >> each MSI descriptor. This is easily achieved by introducing >> a new "for_each_msi_vector" iterator, together with a tiny >> bit of refactoring. >> >> Fixes: f3b0946d629c ("genirq/msi: Make sure PCI MSIs are activated >> early") >> Reported-by: Shameer Kolothum >> Signed-off-by: Marc Zyngier >> Cc: stable@vger.kernel.org >> --- >> include/linux/msi.h | 6 ++++++ >> kernel/irq/msi.c | 44 ++++++++++++++++++++------------------------ >> 2 files changed, 26 insertions(+), 24 deletions(-) >> >> diff --git a/include/linux/msi.h b/include/linux/msi.h >> index 360a0a7e7341..aef35fd1cf11 100644 >> --- a/include/linux/msi.h >> +++ b/include/linux/msi.h >> @@ -178,6 +178,12 @@ struct msi_desc { >> list_for_each_entry((desc), dev_to_msi_list((dev)), list) >> #define for_each_msi_entry_safe(desc, tmp, dev) \ >> list_for_each_entry_safe((desc), (tmp), dev_to_msi_list((dev)), >> list) >> +#define for_each_msi_vector(desc, __irq, dev) \ >> + for_each_msi_entry((desc), (dev)) \ >> + if ((desc)->irq) \ >> + for (__irq = (desc)->irq; \ >> + __irq < ((desc)->irq + (desc)->nvec_used); \ >> + __irq++) >> >> #ifdef CONFIG_IRQ_MSI_IOMMU >> static inline const void *msi_desc_get_iommu_cookie(struct msi_desc >> *desc) >> diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c >> index 2c0c4d6d0f83..d924676c8781 100644 >> --- a/kernel/irq/msi.c >> +++ b/kernel/irq/msi.c >> @@ -436,22 +436,22 @@ int __msi_domain_alloc_irqs(struct irq_domain >> *domain, struct device *dev, >> >> can_reserve = msi_check_reservation_mode(domain, info, dev); >> >> - for_each_msi_entry(desc, dev) { >> - virq = desc->irq; >> - if (desc->nvec_used == 1) >> - dev_dbg(dev, "irq %d for MSI\n", virq); >> - else >> + /* >> + * This flag is set by the PCI layer as we need to activate >> + * the MSI entries before the PCI layer enables MSI in the >> + * card. Otherwise the card latches a random msi message. >> + */ >> + if (!(info->flags & MSI_FLAG_ACTIVATE_EARLY)) >> + goto skip_activate; > > This will change the dbg print behavior. From the commit f3b0946d629c, > it looks like the below dev_dbg() code was there for > !MSI_FLAG_ACTIVATE_EARLY > case as well. Not sure how much this matters though. I'm not sure this matters either. We may have relied on these statements some 6/7 years ago, as the whole hierarchy stuff was brand new, but we now have a much better debug infrastructure thanks to Thomas. I'd be totally in favour of dropping it. Thanks, M. -- Jazz is not dead. It just smells funny...