From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755814AbcCOOdf (ORCPT ); Tue, 15 Mar 2016 10:33:35 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:36613 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934004AbcCOOdb (ORCPT ); Tue, 15 Mar 2016 10:33:31 -0400 X-IronPort-AV: E=Sophos;i="5.24,339,1454972400"; d="scan'208";a="207879881" Date: Tue, 15 Mar 2016 15:33:28 +0100 (CET) From: Julia Lawall X-X-Sender: jll@hadrien To: Alex Williamson cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Alexander Gordeev , Bjorn Helgaas Subject: Re: question about pci_enable_msix_range In-Reply-To: <20160315082941.11216f19@t450s.home> Message-ID: References: <20160315082941.11216f19@t450s.home> User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 15 Mar 2016, Alex Williamson wrote: > On Tue, 15 Mar 2016 11:26:50 +0100 (CET) > Julia Lawall wrote: > > > Hello, > > > > I was looking at the following code in the file > > drivers/vfio/pci/vfio_pci_intrs.c: > > > > ret = pci_enable_msix_range(pdev, vdev->msix, 1, nvec); > > if (ret < nvec) { > > if (ret > 0) > > pci_disable_msix(pdev); > > kfree(vdev->msix); > > kfree(vdev->ctx); > > return ret; > > } > > > > I was wondering what is the point of using a range of 1 .. nvec if there > > is going to be a failure if the number of allocated irqs is less than > > nvec? > > Hi Julia, > > The intention is that on failure we can indicate to the user a value > that might work. If we were to call with {nvec, nvec} we'd only get > back -ENOSPC and the user could only arbitrarily decrease the request > by some amount and try again. By using {1, nvec} we can hopefully > provide a useful next step. On the other hand, we haven't enabled the > number of vectors the user requested, so it doesn't seem to make sense > to leave any enabled. Thanks, Ah, OK I see now that the ret will be the value that works in this case, not a normal failure value. Thanks for the feedback, which has made things a lot clearer. julia