From patchwork Tue Aug 16 19:34:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 9284449 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CF83760839 for ; Tue, 16 Aug 2016 19:34:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFE91286BA for ; Tue, 16 Aug 2016 19:34:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B4B3E28852; Tue, 16 Aug 2016 19:34:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51E61286BA for ; Tue, 16 Aug 2016 19:34:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753013AbcHPTeY (ORCPT ); Tue, 16 Aug 2016 15:34:24 -0400 Received: from mail.kernel.org ([198.145.29.136]:46934 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752940AbcHPTeW (ORCPT ); Tue, 16 Aug 2016 15:34:22 -0400 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3BFBD201C7; Tue, 16 Aug 2016 19:34:21 +0000 (UTC) Received: from localhost (unknown [69.71.1.1]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E3B272017E; Tue, 16 Aug 2016 19:34:19 +0000 (UTC) Date: Tue, 16 Aug 2016 14:34:18 -0500 From: Bjorn Helgaas To: Christoph Hellwig Cc: linux-pci@vger.kernel.org, agordeev@redhat.com, linux-kernel@vger.kernel.org Subject: Re: two pci_alloc_irq_vectors improvements Message-ID: <20160816193418.GA10555@localhost> References: <1470924665-25860-1-git-send-email-hch@lst.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1470924665-25860-1-git-send-email-hch@lst.de> User-Agent: Mutt/1.5.21 (2010-09-15) X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Christoph, On Thu, Aug 11, 2016 at 07:11:03AM -0700, Christoph Hellwig wrote: > Hi Bjorn, hi Alex, > > below are two patches I'd love to see in 4.8 to improve the > pci_alloc_irq_vectors interface. I've realized we need these while > starting a mass conversion of the MSI-X users to the new interface, > and getting it into 4.8 before users show up should make life a lot > easier. > > The positive flags things comes out of the fact that a lot of driver > want MSI-X only without any fallback, or some elaborate differences > for the different interrupt schemes. For example while most modern > devices use one MSI-X vector per queue and scale nicely from the > MSI to the MSI-X scheme many older devices use a MSI-X vector per > functionality in the ISR, so they might wan to allocate them > differently. > > The second one ensures the legacy interrupt line is actually enabled > before using it, because some devices like MSI-X might actually have > it disable by default. I really like this change. It's much nicer to read if (flags & PCI_IRQ_AFFINITY) than it was to read if (!(flags & PCI_IRQ_NOAFFINITY)) Speaking of affinity, the original documentation said "By default this function will spread the interrupts around the available CPUs". After these patches, you have to pass PCI_IRQ_AFFINITY to get that behavior. Are you planning to have drivers use pci_alloc_irq_vectors(dev, 1, nvec, PCI_IRQ_ALL_TYPES | PCI_IRQ_AFFINITY) to explicitly ask for affinity? I applied these to for-linus with the intent of merging them for v4.8. I fixed a couple typos in the first one as shown below. Any objections, Alex? Bjorn --- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/Documentation/PCI/MSI-HOWTO.txt b/Documentation/PCI/MSI-HOWTO.txt index 8faf14a..cd9c9f6 100644 --- a/Documentation/PCI/MSI-HOWTO.txt +++ b/Documentation/PCI/MSI-HOWTO.txt @@ -96,9 +96,9 @@ if it can't meet the minimum number of vectors. The flags argument is used to specify which type of interrupt can be used by the device and the driver (PCI_IRQ_LEGACY, PCI_IRQ_MSI, PCI_IRQ_MSIX). -A conveniant short-hand (PCI_IRQ_ALL_TYPES) is also avaiable to ask for -any possible kind of interrupt. If the PCI_IRQ_NOAFFINITY flag is set, -pci_alloc_irq_vectors will spread the interrupts around the available CPUs. +A convenient short-hand (PCI_IRQ_ALL_TYPES) is also available to ask for +any possible kind of interrupt. If the PCI_IRQ_AFFINITY flag is set, +pci_alloc_irq_vectors() will spread the interrupts around the available CPUs. To get the Linux IRQ numbers passed to request_irq() and free_irq() and the vectors, use the following function: @@ -150,8 +150,7 @@ the single MSI mode for a device. It could be done by passing two 1s as goto out_err; Some devices might not support using legacy line interrupts, in which case -the PCI_IRQ_NOLEGACY flag can be used to fail the request if the platform -can't provide MSI or MSI-X interrupts: +the driver can specify that only MSI or MSI-X is acceptable: nvec = pci_alloc_irq_vectors(pdev, 1, nvec, PCI_IRQ_MSI | PCI_IRQ_MSIX); if (nvec < 0)