From patchwork Thu Feb 23 10:30:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 9588071 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 2EE1C60210 for ; Thu, 23 Feb 2017 10:34:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E1262780C for ; Thu, 23 Feb 2017 10:34:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1299B285D1; Thu, 23 Feb 2017 10:34:50 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 AA5F72780C for ; Thu, 23 Feb 2017 10:34:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751034AbdBWKba (ORCPT ); Thu, 23 Feb 2017 05:31:30 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:60572 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751289AbdBWKbI (ORCPT ); Thu, 23 Feb 2017 05:31:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=So0NshCWZXkd4qTRoTIKL27DNep7Guak+/bQX+AEte4=; b=XkBuR6HXzBnnJ+9mColUomYRi p9VQ4Y/iXvzlpKWMU4maXwBKnStjsFKtxqXUU+1A7S9snEi/BDQ6akWhnnVMkeEdYYHwHY7dv+PYN djqm7ODmWBo9rqMjrRFcP0pSe983QvgxTISr3XX9/Tk1ff8vyfFD8LjdyhW1cc7eR4aMixJlMExh7 e5S+wB77qZqbXVl2F+5OJmuwLes/E9hARfaOvszGzuD6bAxx9xUFmRm8MzxU4IVS9XPl3vGdx5+Wu iMZBXVBmfruKlI9Mha5UbqlLYIQx0Yk5VFK9fZAOKbaoNo1T9urEpESSFjizEUqk/fNW7ixWkWtrz ER9hvV20w==; Received: from hch by bombadil.infradead.org with local (Exim 4.87 #1 (Red Hat Linux)) id 1cgqfj-0000op-BO; Thu, 23 Feb 2017 10:30:51 +0000 Date: Thu, 23 Feb 2017 02:30:51 -0800 From: Christoph Hellwig To: Himanshu Madhani Cc: bhelgaas@google.com, linux-pci@vger.kernel.org Subject: Re: [PATCH] PCI/MSI: Only disable affinity settings if pre and post vector count is equal to max_vecs and not min_vecs Message-ID: <20170223103051.GA23982@infradead.org> References: <1487830355-16963-1-git-send-email-himanshu.madhani@cavium.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1487830355-16963-1-git-send-email-himanshu.madhani@cavium.com> User-Agent: Mutt/1.7.1 (2016-10-04) 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-Virus-Scanned: ClamAV using ClamSMTP On Wed, Feb 22, 2017 at 10:12:35PM -0800, Himanshu Madhani wrote: > From: Michael Hernandez > > min_vecs is the minimum amount of vectors needed to operate in MSI-X mode > which may just include the vectors that don't need affinity. > > Disabling affinity settings causes the qla2xxx driver scsi_add_host > to fail when blk_mq is enabled as the blk_mq_pci_map_queues expects > affinity masks on each vector. I don't think this is correct either. We'll need to move these checks into __pci_enable_msix_range instead I think so that they operate on the actual number of vectors not the min/max ones. Something like the untested patch below, which will also need a MSI version of the check, and possibly a bit of cleanup: diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index 7f73bacf13ed..6d11c4f620f3 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c @@ -1138,6 +1138,18 @@ static int __pci_enable_msix_range(struct pci_dev *dev, for (;;) { if (affd) { + if (affd->pre_vectors + affd->post_vectors > nvec) + return -EINVAL; + + /* + * If there aren't any vectors left after applying the + * pre/post vectors don't bother with assigning + * affinity. + */ + if (affd->pre_vectors + affd->post_vectors == nvec) + affd = NULL; + } + if (affd) { nvec = irq_calc_affinity_vectors(nvec, affd); if (nvec < minvec) return -ENOSPC; @@ -1206,16 +1218,6 @@ int pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs, if (flags & PCI_IRQ_AFFINITY) { if (!affd) affd = &msi_default_affd; - - if (affd->pre_vectors + affd->post_vectors > min_vecs) - return -EINVAL; - - /* - * If there aren't any vectors left after applying the pre/post - * vectors don't bother with assigning affinity. - */ - if (affd->pre_vectors + affd->post_vectors == min_vecs) - affd = NULL; } else { if (WARN_ON(affd)) affd = NULL;