diff mbox series

[v2,03/12] pci: make PCI_SBDF return a pci_sbdf_t

Message ID 20190606090146.77381-4-roger.pau@citrix.com (mailing list archive)
State Superseded
Headers show
Series pci: expand usage of pci_sbdf_t | expand

Commit Message

Roger Pau Monné June 6, 2019, 9:01 a.m. UTC
And fix it's only caller.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Cc: Kevin Tian <kevin.tian@intel.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Julien Grall <julien.grall@arm.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Tim Deegan <tim@xen.org>
Cc: Wei Liu <wl@xen.org>
---
Changes since v1:
 - New in this version.
---
 xen/drivers/passthrough/vtd/dmar.c | 3 ++-
 xen/include/xen/pci.h              | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

Comments

Paul Durrant June 6, 2019, 11:11 a.m. UTC | #1
> -----Original Message-----
> From: Xen-devel [mailto:xen-devel-bounces@lists.xenproject.org] On Behalf Of Roger Pau Monne
> Sent: 06 June 2019 10:02
> To: xen-devel@lists.xenproject.org
> Cc: Kevin Tian <kevin.tian@intel.com>; Stefano Stabellini <sstabellini@kernel.org>; Wei Liu
> <wl@xen.org>; Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>; George Dunlap
> <George.Dunlap@citrix.com>; Andrew Cooper <Andrew.Cooper3@citrix.com>; Ian Jackson
> <Ian.Jackson@citrix.com>; Tim (Xen.org) <tim@xen.org>; Julien Grall <julien.grall@arm.com>; Jan
> Beulich <jbeulich@suse.com>; Roger Pau Monne <roger.pau@citrix.com>
> Subject: [Xen-devel] [PATCH v2 03/12] pci: make PCI_SBDF return a pci_sbdf_t
> 
> And fix it's only caller.
> 
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>

Reviewed-by: Paul Durrant <paul.durrant@citrix.com>

> ---
> Cc: Kevin Tian <kevin.tian@intel.com>
> Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> Cc: George Dunlap <George.Dunlap@eu.citrix.com>
> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> Cc: Jan Beulich <jbeulich@suse.com>
> Cc: Julien Grall <julien.grall@arm.com>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> Cc: Stefano Stabellini <sstabellini@kernel.org>
> Cc: Tim Deegan <tim@xen.org>
> Cc: Wei Liu <wl@xen.org>
> ---
> Changes since v1:
>  - New in this version.
> ---
>  xen/drivers/passthrough/vtd/dmar.c | 3 ++-
>  xen/include/xen/pci.h              | 3 ++-
>  2 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/xen/drivers/passthrough/vtd/dmar.c b/xen/drivers/passthrough/vtd/dmar.c
> index 9cc8623e53..59a46cd1c6 100644
> --- a/xen/drivers/passthrough/vtd/dmar.c
> +++ b/xen/drivers/passthrough/vtd/dmar.c
> @@ -1115,7 +1115,8 @@ static int __init parse_rmrr_param(const char *str)
> 
>              /* Keep sbdf's even if they differ and later report an error. */
>              dev_count = user_rmrrs[nr_rmrr].dev_count;
> -            user_rmrrs[nr_rmrr].sbdf[dev_count] = PCI_SBDF(seg, bus, dev, func);
> +            user_rmrrs[nr_rmrr].sbdf[dev_count] =
> +               PCI_SBDF(seg, bus, dev, func).sbdf;
> 
>              user_rmrrs[nr_rmrr].dev_count++;
>              s = stmp;
> diff --git a/xen/include/xen/pci.h b/xen/include/xen/pci.h
> index f4908abd8b..9ea41789d0 100644
> --- a/xen/include/xen/pci.h
> +++ b/xen/include/xen/pci.h
> @@ -34,7 +34,8 @@
>  #define PCI_DEVFN2(bdf) ((bdf) & 0xff)
>  #define PCI_BDF(b,d,f)  ((((b) & 0xff) << 8) | PCI_DEVFN(d,f))
>  #define PCI_BDF2(b,df)  ((((b) & 0xff) << 8) | ((df) & 0xff))
> -#define PCI_SBDF(s,b,d,f) ((((s) & 0xffff) << 16) | PCI_BDF(b,d,f))
> +#define PCI_SBDF(s,b,d,f) \
> +    ((pci_sbdf_t) { .sbdf = (((s) & 0xffff) << 16) | PCI_BDF(b,d,f) })
>  #define PCI_SBDF2(s,bdf) ((((s) & 0xffff) << 16) | ((bdf) & 0xffff))
>  #define PCI_SBDF3(s,b,df) ((((s) & 0xffff) << 16) | PCI_BDF2(b, df))
> 
> --
> 2.20.1 (Apple Git-117)
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xenproject.org
> https://lists.xenproject.org/mailman/listinfo/xen-devel
Paul Durrant June 6, 2019, 11:19 a.m. UTC | #2
> -----Original Message-----
> From: Xen-devel [mailto:xen-devel-bounces@lists.xenproject.org] On Behalf Of Paul Durrant
> Sent: 06 June 2019 12:11
> To: Roger Pau Monne <roger.pau@citrix.com>; xen-devel@lists.xenproject.org
> Cc: Kevin Tian <kevin.tian@intel.com>; Stefano Stabellini <sstabellini@kernel.org>; Wei Liu
> <wl@xen.org>; Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>; Andrew Cooper
> <Andrew.Cooper3@citrix.com>; Tim (Xen.org) <tim@xen.org>; George Dunlap <George.Dunlap@citrix.com>;
> Julien Grall <julien.grall@arm.com>; Jan Beulich <jbeulich@suse.com>; Ian Jackson
> <Ian.Jackson@citrix.com>; Roger Pau Monne <roger.pau@citrix.com>
> Subject: Re: [Xen-devel] [PATCH v2 03/12] pci: make PCI_SBDF return a pci_sbdf_t
> 
> > -----Original Message-----
> > From: Xen-devel [mailto:xen-devel-bounces@lists.xenproject.org] On Behalf Of Roger Pau Monne
> > Sent: 06 June 2019 10:02
> > To: xen-devel@lists.xenproject.org
> > Cc: Kevin Tian <kevin.tian@intel.com>; Stefano Stabellini <sstabellini@kernel.org>; Wei Liu
> > <wl@xen.org>; Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>; George Dunlap
> > <George.Dunlap@citrix.com>; Andrew Cooper <Andrew.Cooper3@citrix.com>; Ian Jackson
> > <Ian.Jackson@citrix.com>; Tim (Xen.org) <tim@xen.org>; Julien Grall <julien.grall@arm.com>; Jan
> > Beulich <jbeulich@suse.com>; Roger Pau Monne <roger.pau@citrix.com>
> > Subject: [Xen-devel] [PATCH v2 03/12] pci: make PCI_SBDF return a pci_sbdf_t
> >
> > And fix it's only caller.
> >
> > Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> 
> Reviewed-by: Paul Durrant <paul.durrant@citrix.com>

Actually, on second thoughts...

> 
> > ---
> > Cc: Kevin Tian <kevin.tian@intel.com>
> > Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> > Cc: George Dunlap <George.Dunlap@eu.citrix.com>
> > Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> > Cc: Jan Beulich <jbeulich@suse.com>
> > Cc: Julien Grall <julien.grall@arm.com>
> > Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> > Cc: Stefano Stabellini <sstabellini@kernel.org>
> > Cc: Tim Deegan <tim@xen.org>
> > Cc: Wei Liu <wl@xen.org>
> > ---
> > Changes since v1:
> >  - New in this version.
> > ---
> >  xen/drivers/passthrough/vtd/dmar.c | 3 ++-
> >  xen/include/xen/pci.h              | 3 ++-
> >  2 files changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/xen/drivers/passthrough/vtd/dmar.c b/xen/drivers/passthrough/vtd/dmar.c
> > index 9cc8623e53..59a46cd1c6 100644
> > --- a/xen/drivers/passthrough/vtd/dmar.c
> > +++ b/xen/drivers/passthrough/vtd/dmar.c
> > @@ -1115,7 +1115,8 @@ static int __init parse_rmrr_param(const char *str)
> >
> >              /* Keep sbdf's even if they differ and later report an error. */
> >              dev_count = user_rmrrs[nr_rmrr].dev_count;
> > -            user_rmrrs[nr_rmrr].sbdf[dev_count] = PCI_SBDF(seg, bus, dev, func);
> > +            user_rmrrs[nr_rmrr].sbdf[dev_count] =
> > +               PCI_SBDF(seg, bus, dev, func).sbdf;
> >
> >              user_rmrrs[nr_rmrr].dev_count++;
> >              s = stmp;
> > diff --git a/xen/include/xen/pci.h b/xen/include/xen/pci.h
> > index f4908abd8b..9ea41789d0 100644
> > --- a/xen/include/xen/pci.h
> > +++ b/xen/include/xen/pci.h
> > @@ -34,7 +34,8 @@
> >  #define PCI_DEVFN2(bdf) ((bdf) & 0xff)
> >  #define PCI_BDF(b,d,f)  ((((b) & 0xff) << 8) | PCI_DEVFN(d,f))
> >  #define PCI_BDF2(b,df)  ((((b) & 0xff) << 8) | ((df) & 0xff))
> > -#define PCI_SBDF(s,b,d,f) ((((s) & 0xffff) << 16) | PCI_BDF(b,d,f))
> > +#define PCI_SBDF(s,b,d,f) \
> > +    ((pci_sbdf_t) { .sbdf = (((s) & 0xffff) << 16) | PCI_BDF(b,d,f) })

Wouldn't this be better coded along the lines of... 

    ((pci_sbdf_t) { .seg = s, .bus = b, .dev = d, .fn = f })

?

  Paul

> >  #define PCI_SBDF2(s,bdf) ((((s) & 0xffff) << 16) | ((bdf) & 0xffff))
> >  #define PCI_SBDF3(s,b,df) ((((s) & 0xffff) << 16) | PCI_BDF2(b, df))
> >
> > --
> > 2.20.1 (Apple Git-117)
> >
> >
> > _______________________________________________
> > Xen-devel mailing list
> > Xen-devel@lists.xenproject.org
> > https://lists.xenproject.org/mailman/listinfo/xen-devel
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xenproject.org
> https://lists.xenproject.org/mailman/listinfo/xen-devel
Jan Beulich June 6, 2019, 11:31 a.m. UTC | #3
>>> On 06.06.19 at 13:19, <Paul.Durrant@citrix.com> wrote:
>>  -----Original Message-----
>> From: Xen-devel [mailto:xen-devel-bounces@lists.xenproject.org] On Behalf Of Paul Durrant
>> Sent: 06 June 2019 12:11
>> 
>> > -----Original Message-----
>> > From: Xen-devel [mailto:xen-devel-bounces@lists.xenproject.org] On Behalf Of Roger Pau Monne
>> > Sent: 06 June 2019 10:02
>> > --- a/xen/include/xen/pci.h
>> > +++ b/xen/include/xen/pci.h
>> > @@ -34,7 +34,8 @@
>> >  #define PCI_DEVFN2(bdf) ((bdf) & 0xff)
>> >  #define PCI_BDF(b,d,f)  ((((b) & 0xff) << 8) | PCI_DEVFN(d,f))
>> >  #define PCI_BDF2(b,df)  ((((b) & 0xff) << 8) | ((df) & 0xff))
>> > -#define PCI_SBDF(s,b,d,f) ((((s) & 0xffff) << 16) | PCI_BDF(b,d,f))
>> > +#define PCI_SBDF(s,b,d,f) \
>> > +    ((pci_sbdf_t) { .sbdf = (((s) & 0xffff) << 16) | PCI_BDF(b,d,f) })
> 
> Wouldn't this be better coded along the lines of... 
> 
>     ((pci_sbdf_t) { .seg = s, .bus = b, .dev = d, .fn = f })

No, as per the prior version's discussion: Older gcc won't cope with this.

Jan
Paul Durrant June 6, 2019, 11:37 a.m. UTC | #4
> -----Original Message-----
> From: Jan Beulich [mailto:JBeulich@suse.com]
> Sent: 06 June 2019 12:31
> To: Paul Durrant <Paul.Durrant@citrix.com>
> Cc: Julien Grall <julien.grall@arm.com>; Andrew Cooper <Andrew.Cooper3@citrix.com>; George Dunlap
> <George.Dunlap@citrix.com>; Ian Jackson <Ian.Jackson@citrix.com>; Roger Pau Monne
> <roger.pau@citrix.com>; Kevin Tian <kevin.tian@intel.com>; Stefano Stabellini
> <sstabellini@kernel.org>; xen-devel <xen-devel@lists.xenproject.org>; Konrad Rzeszutek Wilk
> <konrad.wilk@oracle.com>; Tim (Xen.org) <tim@xen.org>; WeiLiu <wl@xen.org>
> Subject: RE: [Xen-devel] [PATCH v2 03/12] pci: make PCI_SBDF return a pci_sbdf_t
> 
> >>> On 06.06.19 at 13:19, <Paul.Durrant@citrix.com> wrote:
> >>  -----Original Message-----
> >> From: Xen-devel [mailto:xen-devel-bounces@lists.xenproject.org] On Behalf Of Paul Durrant
> >> Sent: 06 June 2019 12:11
> >>
> >> > -----Original Message-----
> >> > From: Xen-devel [mailto:xen-devel-bounces@lists.xenproject.org] On Behalf Of Roger Pau Monne
> >> > Sent: 06 June 2019 10:02
> >> > --- a/xen/include/xen/pci.h
> >> > +++ b/xen/include/xen/pci.h
> >> > @@ -34,7 +34,8 @@
> >> >  #define PCI_DEVFN2(bdf) ((bdf) & 0xff)
> >> >  #define PCI_BDF(b,d,f)  ((((b) & 0xff) << 8) | PCI_DEVFN(d,f))
> >> >  #define PCI_BDF2(b,df)  ((((b) & 0xff) << 8) | ((df) & 0xff))
> >> > -#define PCI_SBDF(s,b,d,f) ((((s) & 0xffff) << 16) | PCI_BDF(b,d,f))
> >> > +#define PCI_SBDF(s,b,d,f) \
> >> > +    ((pci_sbdf_t) { .sbdf = (((s) & 0xffff) << 16) | PCI_BDF(b,d,f) })
> >
> > Wouldn't this be better coded along the lines of...
> >
> >     ((pci_sbdf_t) { .seg = s, .bus = b, .dev = d, .fn = f })
> 
> No, as per the prior version's discussion: Older gcc won't cope with this.

Oh, ok. Fair enough then.

  Paul

> 
> Jan
>
diff mbox series

Patch

diff --git a/xen/drivers/passthrough/vtd/dmar.c b/xen/drivers/passthrough/vtd/dmar.c
index 9cc8623e53..59a46cd1c6 100644
--- a/xen/drivers/passthrough/vtd/dmar.c
+++ b/xen/drivers/passthrough/vtd/dmar.c
@@ -1115,7 +1115,8 @@  static int __init parse_rmrr_param(const char *str)
 
             /* Keep sbdf's even if they differ and later report an error. */
             dev_count = user_rmrrs[nr_rmrr].dev_count;
-            user_rmrrs[nr_rmrr].sbdf[dev_count] = PCI_SBDF(seg, bus, dev, func);
+            user_rmrrs[nr_rmrr].sbdf[dev_count] =
+               PCI_SBDF(seg, bus, dev, func).sbdf;
 
             user_rmrrs[nr_rmrr].dev_count++;
             s = stmp;
diff --git a/xen/include/xen/pci.h b/xen/include/xen/pci.h
index f4908abd8b..9ea41789d0 100644
--- a/xen/include/xen/pci.h
+++ b/xen/include/xen/pci.h
@@ -34,7 +34,8 @@ 
 #define PCI_DEVFN2(bdf) ((bdf) & 0xff)
 #define PCI_BDF(b,d,f)  ((((b) & 0xff) << 8) | PCI_DEVFN(d,f))
 #define PCI_BDF2(b,df)  ((((b) & 0xff) << 8) | ((df) & 0xff))
-#define PCI_SBDF(s,b,d,f) ((((s) & 0xffff) << 16) | PCI_BDF(b,d,f))
+#define PCI_SBDF(s,b,d,f) \
+    ((pci_sbdf_t) { .sbdf = (((s) & 0xffff) << 16) | PCI_BDF(b,d,f) })
 #define PCI_SBDF2(s,bdf) ((((s) & 0xffff) << 16) | ((bdf) & 0xffff))
 #define PCI_SBDF3(s,b,df) ((((s) & 0xffff) << 16) | PCI_BDF2(b, df))