From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E20C1221D94 for ; Tue, 3 Jun 2025 14:03:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748959411; cv=none; b=uLSRPvQE5+l9slYErkdw73prjs+QIfJM9xFQfRe6+oAXul3Icpz1in4Nlda2edtfl0YG6MnaZS7RTDyRh8Vgc1xNHYzZHS2uMahNAsjtl7ddBS5+8/qSf5j7ZTey+FXATRdxQ6fagx+m48zOVF9yufynKSOo2ae4gc43McbsKm0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748959411; c=relaxed/simple; bh=+k1KcLiR74h+DHCJUtU49fGLLq6L6csb6kt4etWsGGI=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=RWiPKqKkOqav+WBHxbVKZs7ENfmgo8qjWuPvZ3gmIH1ArqpjxNO4Admu3xmqh//zvwp2LqFinJOP6gsuwVQEZFYkXDSsOhHx1U4scOCANh4v3vvwjyk7l1RFYh78TrG2K1o02PHuGW9uv+pZuMgyql+A7AWov7HiRIdL9zYgexY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UiLDe3ke; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UiLDe3ke" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61A66C4CEED; Tue, 3 Jun 2025 14:03:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1748959410; bh=+k1KcLiR74h+DHCJUtU49fGLLq6L6csb6kt4etWsGGI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=UiLDe3keWK8+XX8y4Hm1BolFib/py85LKE4DwKZ5s9cOj2U0+EbHmny5Qp1g69zix XSepvpSfC2u9L6JA5sT5kWFTzdntV37shF+QrDYe4Oln4Ot31pfI0bo3Qb+lcg7yMu rNg/QBR2hESihmbUuKkCISH48eEK2eAbv6d9Qr8AyZxPsUON3MYjZcKIxSBJOflMi9 YX0sLC5qbffW5aAAzeuEpZDuYcXcB/zhBBqF1vpufGln7cocjErrJIU9kYF23SZWXr E+FbOS16LFDb2faBS6PYhHx/ZRnRS2ree/zdXwWtFZj/5jsoml9uVuL0rpEKpS7kB4 HA94D1sa1GUVw== Received: from [149.88.19.236] (helo=lobster-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 1uMSEh-002r8p-Sw; Tue, 03 Jun 2025 15:03:28 +0100 Date: Tue, 03 Jun 2025 15:03:26 +0100 Message-ID: <87h60wexch.wl-maz@kernel.org> From: Marc Zyngier To: Lorenzo Pieralisi Cc: Zenghui Yu , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Thomas Gleixner , Sascha Bischoff , Timothy Hayes Subject: Re: [PATCH v2 3/5] genirq/msi: Move prepare() call to per-device allocation In-Reply-To: References: <20250513163144.2215824-1-maz@kernel.org> <20250513163144.2215824-4-maz@kernel.org> <0b1d7aec-1eac-a9cd-502a-339e216e08a1@huawei.com> <87ldq9dm54.wl-maz@kernel.org> 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/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 149.88.19.236 X-SA-Exim-Rcpt-To: lpieralisi@kernel.org, yuzenghui@huawei.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, tglx@linutronix.de, sascha.bischoff@arm.com, timothy.hayes@arm.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Tue, 03 Jun 2025 14:29:58 +0100, Lorenzo Pieralisi wrote: > > On Tue, Jun 03, 2025 at 01:50:47PM +0100, Marc Zyngier wrote: > > Hi Zenghui, > > > > On Tue, 03 Jun 2025 09:22:47 +0100, > > Zenghui Yu wrote: > > > > > > > + domain->dev = dev; > > > > + dev->msi.data->__domains[domid].domain = domain; > > > > + > > > > + if (msi_domain_prepare_irqs(domain, dev, hwsize, &bundle->alloc_info)) { > > > > > > Does it work for MSI? hwsize is 1 in the MSI case, without taking > > > pci_msi_vec_count() into account. > > > > > > bool pci_setup_msi_device_domain(struct pci_dev *pdev) > > > { > > > [...] > > > > > > return pci_create_device_domain(pdev, &pci_msi_template, 1); > > > > Well spotted. > > > > This looks like a PCI bug ignoring Multi-MSI. Can you give the > > following a go and let people know whether that fixes your issue? > > > > Thanks, > > > > M. > > > > diff --git a/drivers/pci/msi/irqdomain.c b/drivers/pci/msi/irqdomain.c > > index d7ba8795d60f..89677a21d525 100644 > > --- a/drivers/pci/msi/irqdomain.c > > +++ b/drivers/pci/msi/irqdomain.c > > @@ -287,7 +287,7 @@ static bool pci_create_device_domain(struct pci_dev *pdev, const struct msi_doma > > * - The device is removed > > * - MSI is disabled and a MSI-X domain is created > > */ > > -bool pci_setup_msi_device_domain(struct pci_dev *pdev) > > +bool pci_setup_msi_device_domain(struct pci_dev *pdev, unsigned int hwsize) > > { > > if (WARN_ON_ONCE(pdev->msix_enabled)) > > return false; > > @@ -297,7 +297,7 @@ bool pci_setup_msi_device_domain(struct pci_dev *pdev) > > if (pci_match_device_domain(pdev, DOMAIN_BUS_PCI_DEVICE_MSIX)) > > msi_remove_device_irq_domain(&pdev->dev, MSI_DEFAULT_DOMAIN); > > > > - return pci_create_device_domain(pdev, &pci_msi_template, 1); > > + return pci_create_device_domain(pdev, &pci_msi_template, hwsize); > > } > > > > /** > > diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c > > index 8b8848788618..81891701840a 100644 > > --- a/drivers/pci/msi/msi.c > > +++ b/drivers/pci/msi/msi.c > > @@ -449,7 +449,7 @@ int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec, > > if (rc) > > return rc; > > > > - if (!pci_setup_msi_device_domain(dev)) > > + if (!pci_setup_msi_device_domain(dev, nvec)) > > If pci_msi_vec_count(dev) > maxvec we would cap nvec and size the > domain with the capped value. > > In __pci_enable_msix_range() we are sizing the device according to > pci_msix_vec_count(dev) regardless of maxvec, if I read the code correctly. > > While fixing it it would be good to make them consistent unless there is > a reason why they should not. This is indeed odd, but that'd be a separate fix. Something like: diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c index 2090eef64b14..6ede55a7c5e6 100644 --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -439,9 +439,6 @@ int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec, if (nvec < minvec) return -ENOSPC; - if (nvec > maxvec) - nvec = maxvec; - rc = pci_setup_msi_context(dev); if (rc) return rc; @@ -449,6 +446,9 @@ int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec, if (!pci_setup_msi_device_domain(dev, nvec)) return -ENODEV; + if (nvec > maxvec) + nvec = maxvec; + for (;;) { if (affd) { nvec = irq_calc_affinity_vectors(minvec, nvec, affd); -- Jazz isn't dead. It just smells funny.