From patchwork Sat Apr 16 01:35:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 8860921 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A29EB9F1E6 for ; Sat, 16 Apr 2016 01:37:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E13202017D for ; Sat, 16 Apr 2016 01:37:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E45222024D for ; Sat, 16 Apr 2016 01:37:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751537AbcDPBgD (ORCPT ); Fri, 15 Apr 2016 21:36:03 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:48881 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751668AbcDPBf5 (ORCPT ); Fri, 15 Apr 2016 21:35:57 -0400 Received: from [107.17.164.132] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.80.1 #2 (Red Hat Linux)) id 1arF9Q-00056F-R8; Sat, 16 Apr 2016 01:35:56 +0000 From: Christoph Hellwig To: tglx@linutronix.de, linux-block@vger.kernel.org, linux-pci@vger.kernel.org Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 7/8] pci: spread interrupt vectors in pci_alloc_irq_vectors Date: Fri, 15 Apr 2016 18:35:51 -0700 Message-Id: <1460770552-31260-8-git-send-email-hch@lst.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1460770552-31260-1-git-send-email-hch@lst.de> References: <1460770552-31260-1-git-send-email-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, SUSPICIOUS_RECIPS, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Set the affinity_mask before allocating vectors. And for now we also need a little hack after allocation, hopefully someone smarter than me can move this into the core code. Signed-off-by: Christoph Hellwig --- drivers/pci/irq.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/pci/irq.c b/drivers/pci/irq.c index b683465..d26df69 100644 --- a/drivers/pci/irq.c +++ b/drivers/pci/irq.c @@ -55,9 +55,14 @@ int pci_alloc_irq_vectors(struct pci_dev *pdev, int nr_vecs) nr_vecs = min(nr_vecs, pci_nr_irq_vectors(pdev)); + ret = irq_create_affinity_mask(&pdev->dev.irq_affinity, nr_vecs); + if (ret) + return ret; + + ret = -ENOMEM; irqs = kcalloc(nr_vecs, sizeof(u32), GFP_KERNEL); if (!irqs) - return -ENOMEM; + goto out_free_affinity; vecs = pci_enable_msix_range_wrapper(pdev, irqs, nr_vecs); if (vecs <= 0) { @@ -75,11 +80,20 @@ int pci_alloc_irq_vectors(struct pci_dev *pdev, int nr_vecs) irqs[i] = pdev->irq + i; } + /* XXX: this should really move into the core IRQ allocation code.. */ + if (vecs > 1) { + for (i = 0; i < vecs; i++) + irq_program_affinity(irqs[i]); + } + pdev->irqs = irqs; return vecs; out_free_irqs: kfree(irqs); +out_free_affinity: + kfree(pdev->dev.irq_affinity); + pdev->dev.irq_affinity = NULL; return ret; } EXPORT_SYMBOL(pci_alloc_irq_vectors);