linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: Christoph Hellwig <hch@infradead.org>,
	Alex Williamson <alex.williamson@redhat.com>,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	Leon Romanovsky <leon@kernel.org>, Jason Gunthorpe <jgg@ziepe.ca>
Subject: Re: Write to srvio_numvfs triggers kernel panic
Date: Thu, 12 May 2022 07:18:30 +0000	[thread overview]
Message-ID: <877d6rkym2.fsf@epam.com> (raw)
In-Reply-To: <20220510173733.GA688834@bhelgaas>


Hello Bjorn,

Bjorn Helgaas <helgaas@kernel.org> writes:

> On Mon, May 09, 2022 at 11:39:30PM -0700, Christoph Hellwig wrote:
>> On Mon, May 09, 2022 at 10:58:57AM -0600, Alex Williamson wrote:
>> > is_physfn = 0, is_virtfn = 0: A non-SR-IOV function
>> > is_physfn = 1, is_virtfn = 0: An SR-IOV PF
>> > is_physfn = 0, is_virtfn = 1: An SR-IOV VF
>> > 
>> > As implemented with bit fields this is 2 bits, which is more space
>> > efficient than an enum.  Thanks,
>> 
>> A two-bit bitfield with explicit constants for the values would probably
>> still much eaiser to understand.
>> 
>> And there is some code that seems to intepret is_physfn a bit odd, e.g.:
>> 
>> arch/powerpc/kernel/eeh_sysfs.c:        np = pci_device_to_OF_node(pdev->is_physfn ? pdev : pdev->physfn);
>> arch/powerpc/kernel/eeh_sysfs.c:        np = pci_device_to_OF_node(pdev->is_physfn ? pdev : pdev->physfn);
>
> "dev->sriov != NULL" and "dev->is_physfn" are basically the same and
> many of the dev->is_physfn uses in drivers/pci would end up being
> simpler if replaced with dev->sriov, e.g.,
>
>   int pci_iov_virtfn_bus(struct pci_dev *dev, int vf_id)
>   {
>     if (!dev->is_physfn)
>       return -EINVAL;
>     return dev->bus->number + ((dev->devfn + dev->sriov->offset +
> 				dev->sriov->stride * vf_id) >> 8);
>   }
>
> would be more obvious as:
>
>   if (dev->sriov)
>     return dev->bus->number + ((dev->devfn + dev->sriov->offset +
> 				dev->sriov->stride * vf_id) >> 8);
>   return -EINVAL;

I'm not sure that this will work because dev->sriov and dev->physfn are
stored in the same union. 


-- 
Volodymyr Babchuk at EPAM

      reply	other threads:[~2022-05-12  7:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-04 19:56 Write to srvio_numvfs triggers kernel panic Volodymyr Babchuk
2022-05-06 20:17 ` Bjorn Helgaas
2022-05-07  1:34   ` Jason Gunthorpe
2022-05-07 10:25     ` Volodymyr Babchuk
2022-05-08 11:19       ` Leon Romanovsky
2022-05-09 18:22         ` Keith Busch
2022-05-07 10:22   ` Volodymyr Babchuk
2022-05-07 15:41     ` Bjorn Helgaas
2022-05-08 11:07       ` Volodymyr Babchuk
2022-05-09 16:49         ` Bjorn Helgaas
2022-05-09 16:58           ` Alex Williamson
2022-05-10  6:39             ` Christoph Hellwig
2022-05-10 17:37               ` Bjorn Helgaas
2022-05-12  7:18                 ` Volodymyr Babchuk [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877d6rkym2.fsf@epam.com \
    --to=volodymyr_babchuk@epam.com \
    --cc=alex.williamson@redhat.com \
    --cc=hch@infradead.org \
    --cc=helgaas@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).