All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Andrew Cooper <Andrew.Cooper3@citrix.com>
Cc: Paul Durrant <paul@xen.org>,
	Roger Pau Monne <roger.pau@citrix.com>,
	Rahul Singh <Rahul.Singh@arm.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH v2 1/3] PCI: simplify (and thus correct) pci_get_pdev{,_by_domain}()
Date: Thu, 11 Aug 2022 15:21:31 +0200	[thread overview]
Message-ID: <b4f39c5f-d197-67c5-8781-e22ad0c0d827@suse.com> (raw)
In-Reply-To: <45cf7907-3ff3-49bd-e700-4333c0e45177@citrix.com>

On 11.08.2022 15:11, Andrew Cooper wrote:
> On 11/08/2022 11:51, Jan Beulich wrote:
>> The last "wildcard" use of either function went away with f591755823a7
>> ("IOMMU/PCI: don't let domain cleanup continue when device de-assignment
>> failed"). Don't allow them to be called this way anymore. Besides
>> simplifying the code this also fixes two bugs:
>>
>> 1) When seg != -1, the outer loops should have been terminated after the
>>    first iteration, or else a device with the same BDF but on another
>>    segment could be found / returned.
>>
>> Reported-by: Rahul Singh <rahul.singh@arm.com>
>>
>> 2) When seg == -1 calling get_pseg() is bogus. The function (taking a
>>    u16) would look for segment 0xffff, which might exist. If it exists,
>>    we might then find / return a wrong device.
>>
>> In pci_get_pdev_by_domain() also switch from using the per-segment list
>> to using the per-domain one, with the exception of the hardware domain
>> (see the code comment there).
>>
>> While there also constify "pseg" and drop "pdev"'s already previously
>> unnecessary initializer.
>>
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> 
> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

Thanks.

> I'm not totally convinced that special casing hwdom is right, because
> quarantine devices are domio not hwdom.  But I also can't identify a
> case where it's definitely wrong either.
> 
>> --- a/xen/include/xen/pci.h
>> +++ b/xen/include/xen/pci.h
>> @@ -177,10 +177,10 @@ int pci_add_device(u16 seg, u8 bus, u8 d
>>  int pci_remove_device(u16 seg, u8 bus, u8 devfn);
>>  int pci_ro_device(int seg, int bus, int devfn);
>>  int pci_hide_device(unsigned int seg, unsigned int bus, unsigned int devfn);
>> -struct pci_dev *pci_get_pdev(int seg, int bus, int devfn);
>> +struct pci_dev *pci_get_pdev(uint16_t seg, uint8_t bus, uint8_t devfn);
> 
> I was going to make a request, but I can't quite get it to compile...
> 
> Passing sbdf as 3 parameters is a waste, and it would be great if we
> could take this opportunity to improve.
> 
> Sadly,
> 
> -struct pci_dev *pci_get_pdev(uint16_t seg, uint8_t bus, uint8_t devfn);
> +struct pci_dev *pci_get_pdev(pci_sbdf_t sbdf);
> +
> +#define pci_get_pdev(...)                               \
> +    ({                                                  \
> +        count_args(__VA_ARGS__) == 1                    \
> +            ? pci_get_pdev(__VA_ARGS__)                 \
> +            : pci_get_pdev(PCI_SBDF(__VA_ARGS__));      \
> +    })
> 
> this doesn't quite compile as a transition plan, and I'm stuck for
> further ideas.

Just look at patch 2.

Jan


  reply	other threads:[~2022-08-11 13:21 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-11 10:50 [PATCH v2 0/3] PCI: re-work pci_get_pdev() and friends Jan Beulich
2022-08-11 10:51 ` [PATCH v2 1/3] PCI: simplify (and thus correct) pci_get_pdev{,_by_domain}() Jan Beulich
2022-08-11 13:11   ` Andrew Cooper
2022-08-11 13:21     ` Jan Beulich [this message]
2022-08-11 16:15   ` Rahul Singh
2022-08-11 10:52 ` [PATCH v2 2/3] PCI: fold pci_get_pdev{,_by_domain}() Jan Beulich
2022-08-11 13:21   ` Andrew Cooper
2022-08-11 13:26     ` Jan Beulich
2022-08-11 15:09       ` Andrew Cooper
2022-08-11 15:41         ` Jan Beulich
2022-08-11 16:17   ` Rahul Singh
2022-08-11 10:52 ` [PATCH v2 3/3] PCI: bring pci_get_real_pdev() in line with pci_get_pdev() Jan Beulich
2022-08-11 13:28   ` Andrew Cooper
2022-08-11 16:16   ` Rahul Singh
2022-08-11 16:37 ` [PATCH] x86/msi: Switch msi_info to using pci_sbdf_t Andrew Cooper
2022-08-12  6:45   ` Jan Beulich
2022-08-12 10:22     ` Andrew Cooper

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=b4f39c5f-d197-67c5-8781-e22ad0c0d827@suse.com \
    --to=jbeulich@suse.com \
    --cc=Andrew.Cooper3@citrix.com \
    --cc=Rahul.Singh@arm.com \
    --cc=paul@xen.org \
    --cc=roger.pau@citrix.com \
    --cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.