Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1225387 > unrolled thread

Re: [PATCH] iov: initialize NumVFs register to 0 at the end of sriov_init()

Started byBjorn Helgaas <bhelgaas@google.com>
First post2015-09-15 18:20 +0200
Last post2015-09-16 03:10 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH] iov: initialize NumVFs register to 0 at the end of  sriov_init() Bjorn Helgaas <bhelgaas@google.com> - 2015-09-15 18:20 +0200
    Re: [PATCH] iov: initialize NumVFs register to 0 at the end of sriov_init() ethan zhao <ethan.zhao@oracle.com> - 2015-09-16 03:10 +0200

#1225387 — Re: [PATCH] iov: initialize NumVFs register to 0 at the end of sriov_init()

FromBjorn Helgaas <bhelgaas@google.com>
Date2015-09-15 18:20 +0200
SubjectRe: [PATCH] iov: initialize NumVFs register to 0 at the end of sriov_init()
Message-ID<q917z-1wr-13@gated-at.bofh.it>
On Fri, Aug 21, 2015 at 06:51:25PM +0900, Ethan Zhao wrote:
> After commit 4449f079722c ("PCI: Calculate maximum number of buses
> required for VFs"),the initial value of NumVFs register was set to
> non-zero after sriov_init() and no VFs was enabled in device driver.
> this changed the behaviour of kernel exported by lspci and sysfs etc.
> so this patch initialize the NumVFs register to zero after the
> calculation of max_VF_buses was done.
> 
> Tested on stable 4.1 and passed building on stable 4.2-rc7
> 
> Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
> Tested-by: Sriharsha Yadagudde <sriharsha.devdas@oracle.com>
> ---
>  drivers/pci/iov.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
> index ee0ebff..6969084 100644
> --- a/drivers/pci/iov.c
> +++ b/drivers/pci/iov.c
> @@ -476,6 +476,7 @@ found:
>  	dev->is_physfn = 1;
>  	iov->max_VF_buses = virtfn_max_buses(dev);
>  
> +	pci_iov_set_numvfs(dev, 0);

I think it would be better to put this in virtfn_max_buses(), where we
clobbered numVFs in the first place.  I'd also read the original value and
restore it, e.g.,

    pci_read_config_word(dev, iov->pos + PCI_SRIOV_NUM_VF, &numvfs);
    for (nr_virtfn = 1; nr_virtfn <= iov->total_VFs; nr_virtfn++) {
      ...
    }
    pci_iov_set_numvfs(dev, numvfs);
    return max;

I know sriov_init() sets numVFs to zero before it calls virtfn_max_buses(),
but why rely on that extra knowledge?

>  	return 0;
>  
>  failed:
> -- 
> 1.8.3.1
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1225648 — Re: [PATCH] iov: initialize NumVFs register to 0 at the end of sriov_init()

Fromethan zhao <ethan.zhao@oracle.com>
Date2015-09-16 03:10 +0200
SubjectRe: [PATCH] iov: initialize NumVFs register to 0 at the end of sriov_init()
Message-ID<q99ou-5Xi-5@gated-at.bofh.it>
In reply to#1225387
On 2015/9/16 0:10, Bjorn Helgaas wrote:
> On Fri, Aug 21, 2015 at 06:51:25PM +0900, Ethan Zhao wrote:
>> After commit 4449f079722c ("PCI: Calculate maximum number of buses
>> required for VFs"),the initial value of NumVFs register was set to
>> non-zero after sriov_init() and no VFs was enabled in device driver.
>> this changed the behaviour of kernel exported by lspci and sysfs etc.
>> so this patch initialize the NumVFs register to zero after the
>> calculation of max_VF_buses was done.
>>
>> Tested on stable 4.1 and passed building on stable 4.2-rc7
>>
>> Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
>> Tested-by: Sriharsha Yadagudde <sriharsha.devdas@oracle.com>
>> ---
>>   drivers/pci/iov.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
>> index ee0ebff..6969084 100644
>> --- a/drivers/pci/iov.c
>> +++ b/drivers/pci/iov.c
>> @@ -476,6 +476,7 @@ found:
>>   	dev->is_physfn = 1;
>>   	iov->max_VF_buses = virtfn_max_buses(dev);
>>   
>> +	pci_iov_set_numvfs(dev, 0);
> I think it would be better to put this in virtfn_max_buses(), where we
> clobbered numVFs in the first place.  I'd also read the original value and
> restore it, e.g.,
>
>      pci_read_config_word(dev, iov->pos + PCI_SRIOV_NUM_VF, &numvfs);
>      for (nr_virtfn = 1; nr_virtfn <= iov->total_VFs; nr_virtfn++) {
>        ...
>      }
>      pci_iov_set_numvfs(dev, numvfs);
>      return max;
>
> I know sriov_init() sets numVFs to zero before it calls virtfn_max_buses(),
> but why rely on that extra knowledge?
  Yes, I think also virtfn_max_buses() should restore the register 
before it returns.
  Will revise it and resend.

  Thanks,
  Ethan
>>   	return 0;
>>   
>>   failed:
>> -- 
>> 1.8.3.1
>>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web