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: 731467 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3vTVwp1g8kz9s0m for ; Thu, 23 Feb 2017 21:34:50 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="XkBuR6HX"; dkim-atps=neutral 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 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;