Skip to contentSkip to conversation

pci: constify domain parameter of pci_get_pdev_by_domain

PATCH In review Roger Pau Monne 4 participants 10 messages Sep 8, 2017 – Sep 11, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pci: constify domain parameter of pci_get_pdev_by_domain

While there fix the indentation.

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Tim Deegan <[email protected]>
Cc: Wei Liu <[email protected]>

---
 xen/drivers/passthrough/pci.c | 4 ++--
 xen/include/xen/pci.h         | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
xen/drivers/passthrough/pci.c +2 -2
index 74829e5748..469dfc6c3d 100644
@@ -532,8 +532,8 @@ struct pci_dev *pci_get_real_pdev(int seg, int bus, int devfn)
     return pdev;
 }
 
-struct pci_dev *pci_get_pdev_by_domain(
-    struct domain *d, int seg, int bus, int devfn)
+struct pci_dev *pci_get_pdev_by_domain(const struct domain *d, int seg,
+                                       int bus, int devfn)
 {
     struct pci_seg *pseg = get_pseg(seg);
     struct pci_dev *pdev = NULL;
xen/include/xen/pci.h +2 -2
index da1bd22223..43f21251a5 100644
@@ -129,8 +129,8 @@ int pci_ro_device(int seg, int bus, int devfn);
 int pci_hide_device(int bus, int devfn);
 struct pci_dev *pci_get_pdev(int seg, int bus, int devfn);
 struct pci_dev *pci_get_real_pdev(int seg, int bus, int devfn);
-struct pci_dev *pci_get_pdev_by_domain(
-    struct domain *, int seg, int bus, int devfn);
+struct pci_dev *pci_get_pdev_by_domain(const struct domain *, int seg,
+                                       int bus, int devfn);
 void pci_check_disable_device(u16 seg, u8 bus, u8 devfn);
 
 uint8_t pci_conf_read8(
Signature · 7 lines
2.11.0 (Apple Git-81)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#2 lore raw
In reply to Roger Pau Monne
Quoted 22 lines · Roger Pau Monne

While there fix the indentation.

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Tim Deegan <[email protected]>
Cc: Wei Liu <[email protected]>

---
 xen/drivers/passthrough/pci.c | 4 ++--
 xen/include/xen/pci.h         | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
xen/drivers/passthrough/pci.c +0 -0
index 74829e5748..469dfc6c3d 100644

xen/drivers/passthrough/pci.c struct pci_dev *pci_get_real_pdev(int seg, int bus, int devfn) · line 536

Quoted 7 lines
xen/drivers/passthrough/pci.c +2 -2
@@ -532,8 +532,8 @@ struct pci_dev *pci_get_real_pdev(int seg, int bus, int devfn)
     return pdev;
 }
 
-struct pci_dev *pci_get_pdev_by_domain(
-    struct domain *d, int seg, int bus, int devfn)
+struct pci_dev *pci_get_pdev_by_domain(const struct domain *d, int seg,
+                                       int bus, int devfn)

I know this isn't strictly related to the patch, but having 3 register parameters (and load of places elsewhere) here is extremely wasteful for register scheduling. Could we introduce:

typedef union {
    uint32_t sbdf;
    struct {
        uint16_t  f : 3,  /* Function */
                  d : 5,  /* Device   */
                  b : 8;  /* Bus      */
        uint16_t s; /* Segment  */
    };
} pci_sbdf_t;

and try to start using it?

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#3 lore raw
Quoted 45 lines · Andrew Cooper
Quoted 22 lines · Roger Pau Monne

While there fix the indentation.

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Tim Deegan <[email protected]>
Cc: Wei Liu <[email protected]>

---
 xen/drivers/passthrough/pci.c | 4 ++--
 xen/include/xen/pci.h         | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
xen/drivers/passthrough/pci.c +0 -0
index 74829e5748..469dfc6c3d 100644

xen/drivers/passthrough/pci.c struct pci_dev *pci_get_real_pdev(int seg, int bus, int devfn) · line 536

Quoted 7 lines
xen/drivers/passthrough/pci.c +2 -2
@@ -532,8 +532,8 @@ struct pci_dev *pci_get_real_pdev(int seg, int bus, int devfn)
     return pdev;
 }
 
-struct pci_dev *pci_get_pdev_by_domain(
-    struct domain *d, int seg, int bus, int devfn)
+struct pci_dev *pci_get_pdev_by_domain(const struct domain *d, int seg,
+                                       int bus, int devfn)

I know this isn't strictly related to the patch, but having 3 register parameters (and load of places elsewhere) here is extremely wasteful for register scheduling. Could we introduce:

typedef union {
    uint32_t sbdf;
    struct {
        uint16_t  f : 3,  /* Function */
                  d : 5,  /* Device   */
                  b : 8;  /* Bus      */
        uint16_t s; /* Segment  */
    };
} pci_sbdf_t;
Quoted 1 line

and try to start using it?

This is going to be kind of awkward to use with extended functions...

It's not like what we have now (devfn) is much better, but if we switch to something else I would like to be able to get the correct function value for both normal and extended function devices from the same field.

Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#4 lore raw
Quoted 50 lines
Quoted 1 line
Quoted 1 line · On 08.09.17 at 16:30, <[email protected]> wrote:
Quoted 18 lines · Andrew Cooper
Quoted 17 lines · Roger Pau Monne

While there fix the indentation.

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Tim Deegan <[email protected]>
Cc: Wei Liu <[email protected]>

---
 xen/drivers/passthrough/pci.c | 4 ++--
 xen/include/xen/pci.h         | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
Quoted 5 lines

xen/drivers/passthrough/pci.c struct pci_dev *pci_get_real_pdev(int seg, int bus, int

Quoted 5 lines
xen/drivers/passthrough/pci.c +0 -0
index 74829e5748..469dfc6c3d 100644
@@ -532,8 +532,8 @@ struct pci_dev *pci_get_real_pdev(int seg, int bus, int 

devfn)

Quoted 22 lines

xen/drivers/passthrough/pci.c struct pci_dev *pci_get_real_pdev(int seg, int bus, int devfn) · line 536

Quoted 7 lines
xen/drivers/passthrough/pci.c +2 -2
     return pdev;
 }
 
-struct pci_dev *pci_get_pdev_by_domain(
-    struct domain *d, int seg, int bus, int devfn)
+struct pci_dev *pci_get_pdev_by_domain(const struct domain *d, int seg,
+                                       int bus, int devfn)

I know this isn't strictly related to the patch, but having 3 register parameters (and load of places elsewhere) here is extremely wasteful for register scheduling. Could we introduce:

typedef union {
    uint32_t sbdf;
    struct {
        uint16_t  f : 3,  /* Function */
                  d : 5,  /* Device   */
                  b : 8;  /* Bus      */
        uint16_t s; /* Segment  */
    };
} pci_sbdf_t;
Quoted 1 line

and try to start using it?

Quoted 7 lines

This is going to be kind of awkward to use with extended functions...

It's not like what we have now (devfn) is much better, but if we switch to something else I would like to be able to get the correct function value for both normal and extended function devices from the same field.

Why not unionize f and d with a uint8_t extfn (I'd also prefer the other two to be named func and dev)?

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#5 lore raw
Quoted 53 lines · Jan Beulich
Quoted 53 lines
Quoted 1 line
Quoted 1 line · On 08.09.17 at 16:30, <[email protected]> wrote:
Quoted 18 lines · Andrew Cooper
Quoted 17 lines · Roger Pau Monne

While there fix the indentation.

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Tim Deegan <[email protected]>
Cc: Wei Liu <[email protected]>

---
 xen/drivers/passthrough/pci.c | 4 ++--
 xen/include/xen/pci.h         | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
Quoted 5 lines

xen/drivers/passthrough/pci.c struct pci_dev *pci_get_real_pdev(int seg, int bus, int

Quoted 5 lines
xen/drivers/passthrough/pci.c +0 -0
index 74829e5748..469dfc6c3d 100644
@@ -532,8 +532,8 @@ struct pci_dev *pci_get_real_pdev(int seg, int bus, int 

devfn)

Quoted 22 lines

xen/drivers/passthrough/pci.c struct pci_dev *pci_get_real_pdev(int seg, int bus, int devfn) · line 536

Quoted 7 lines
xen/drivers/passthrough/pci.c +2 -2
     return pdev;
 }
 
-struct pci_dev *pci_get_pdev_by_domain(
-    struct domain *d, int seg, int bus, int devfn)
+struct pci_dev *pci_get_pdev_by_domain(const struct domain *d, int seg,
+                                       int bus, int devfn)

I know this isn't strictly related to the patch, but having 3 register parameters (and load of places elsewhere) here is extremely wasteful for register scheduling. Could we introduce:

typedef union {
    uint32_t sbdf;
    struct {
        uint16_t  f : 3,  /* Function */
                  d : 5,  /* Device   */
                  b : 8;  /* Bus      */
        uint16_t s; /* Segment  */
    };
} pci_sbdf_t;
Quoted 1 line

and try to start using it?

This is going to be kind of awkward to use with extended functions...

Quoted 7 lines
Quoted 4 lines

It's not like what we have now (devfn) is much better, but if we switch to something else I would like to be able to get the correct function value for both normal and extended function devices from the same field.

Why not unionize f and d with a uint8_t extfn (I'd also prefer the other two to be named func and dev)?

So something like:

typedef union {
    uint32_t sbdf;
    struct {
        union {
            struct {
                uint8_t  func : 3, /* Function */
                         slot : 5; /* Device   */
            };
            uint8_t      extfunc;  /* Extended function */
        };
        uint8_t          bus;      /* Bus      */
        uint16_t         seg;      /* Segment  */
    };
} pci_sbdf_t;

Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#6 lore raw
Quoted 52 lines · Roger Pau Monné
Quoted 51 lines · Jan Beulich
Quoted 51 lines
Quoted 1 line
Quoted 1 line · On 08.09.17 at 16:30, <[email protected]> wrote:
Quoted 18 lines · Andrew Cooper
Quoted 17 lines · Roger Pau Monne

While there fix the indentation.

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Tim Deegan <[email protected]>
Cc: Wei Liu <[email protected]>

---
 xen/drivers/passthrough/pci.c | 4 ++--
 xen/include/xen/pci.h         | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
Quoted 5 lines

xen/drivers/passthrough/pci.c struct pci_dev *pci_get_real_pdev(int seg, int bus, int

Quoted 5 lines
xen/drivers/passthrough/pci.c +0 -0
index 74829e5748..469dfc6c3d 100644
@@ -532,8 +532,8 @@ struct pci_dev *pci_get_real_pdev(int seg, int bus, int 

devfn)

Quoted 21 lines

xen/drivers/passthrough/pci.c struct pci_dev *pci_get_real_pdev(int seg, int bus, int devfn) · line 536

Quoted 7 lines
xen/drivers/passthrough/pci.c +2 -2
     return pdev;
 }
 
-struct pci_dev *pci_get_pdev_by_domain(
-    struct domain *d, int seg, int bus, int devfn)
+struct pci_dev *pci_get_pdev_by_domain(const struct domain *d, int seg,
+                                       int bus, int devfn)

I know this isn't strictly related to the patch, but having 3 register parameters (and load of places elsewhere) here is extremely wasteful for register scheduling. Could we introduce:

typedef union {
    uint32_t sbdf;
    struct {
        uint16_t  f : 3,  /* Function */
                  d : 5,  /* Device   */
                  b : 8;  /* Bus      */
        uint16_t s; /* Segment  */
    };
} pci_sbdf_t;
Quoted 1 line

and try to start using it?

This is going to be kind of awkward to use with extended functions...

Quoted 7 lines
Quoted 6 lines
Quoted 4 lines

It's not like what we have now (devfn) is much better, but if we switch to something else I would like to be able to get the correct function value for both normal and extended function devices from the same field.

Why not unionize f and d with a uint8_t extfn (I'd also prefer the other two to be named func and dev)?

So something like:

As as bdf is also quite a common unit, how about:

Quoted 4 lines
typedef union {
    uint32_t sbdf;
    struct {
union {
    uint16_t bdf;
    struct {
Quoted 4 lines
        union {
            struct {
                uint8_t  func : 3, /* Function */
                         slot : 5; /* Device   */

dev or device, surely?

Quoted 4 lines

};
uint8_t extfunc; /* Extended function */
};
uint8_t bus; /* Bus */

    };
};
Quoted 3 lines

uint16_t seg; /* Segment */
};
} pci_sbdf_t;

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#7 lore raw
Quoted 65 lines
Quoted 1 line
Quoted 1 line · On 08.09.17 at 20:08, <[email protected]> wrote:
Quoted 52 lines · Roger Pau Monné
Quoted 51 lines · Jan Beulich
Quoted 51 lines
Quoted 1 line
Quoted 1 line · On 08.09.17 at 16:30, <[email protected]> wrote:
Quoted 18 lines · Andrew Cooper
Quoted 17 lines · Roger Pau Monne

While there fix the indentation.

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Tim Deegan <[email protected]>
Cc: Wei Liu <[email protected]>

---
 xen/drivers/passthrough/pci.c | 4 ++--
 xen/include/xen/pci.h         | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
Quoted 5 lines

xen/drivers/passthrough/pci.c struct pci_dev *pci_get_real_pdev(int seg, int bus, int

Quoted 5 lines
xen/drivers/passthrough/pci.c +0 -0
index 74829e5748..469dfc6c3d 100644
@@ -532,8 +532,8 @@ struct pci_dev *pci_get_real_pdev(int seg, int bus, int 

devfn)

Quoted 21 lines

xen/drivers/passthrough/pci.c struct pci_dev *pci_get_real_pdev(int seg, int bus, int devfn) · line 536

Quoted 7 lines
xen/drivers/passthrough/pci.c +2 -2
     return pdev;
 }
 
-struct pci_dev *pci_get_pdev_by_domain(
-    struct domain *d, int seg, int bus, int devfn)
+struct pci_dev *pci_get_pdev_by_domain(const struct domain *d, int seg,
+                                       int bus, int devfn)

I know this isn't strictly related to the patch, but having 3 register parameters (and load of places elsewhere) here is extremely wasteful for register scheduling. Could we introduce:

typedef union {
    uint32_t sbdf;
    struct {
        uint16_t  f : 3,  /* Function */
                  d : 5,  /* Device   */
                  b : 8;  /* Bus      */
        uint16_t s; /* Segment  */
    };
} pci_sbdf_t;
Quoted 1 line

and try to start using it?

This is going to be kind of awkward to use with extended functions...

Quoted 7 lines
Quoted 6 lines
Quoted 4 lines

It's not like what we have now (devfn) is much better, but if we switch to something else I would like to be able to get the correct function value for both normal and extended function devices from the same field.

Why not unionize f and d with a uint8_t extfn (I'd also prefer the other two to be named func and dev)?

So something like:

As as bdf is also quite a common unit, how about:

Quoted 1 line
Quoted 7 lines
Quoted 3 lines
typedef union {
    uint32_t sbdf;
    struct {
union {
    uint16_t bdf;
    struct {

Yes.

Quoted 6 lines
Quoted 4 lines
        union {
            struct {
                uint8_t  func : 3, /* Function */
                         slot : 5; /* Device   */

dev or device, surely?

Yeah, comment and field name would better match (or the comments could perhaps go away altogether). While "slot" is a common term here, with this being inside something called "sbdf" I agree "device" or "dev" (in the former case it should also be "function", but I prefer the shorter variants) should be used here.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#8 lore raw
Quoted 19 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 08.09.17 at 20:08, <[email protected]> wrote:

As as bdf is also quite a common unit, how about:

Quoted 4 lines
typedef union {
    uint32_t sbdf;
    struct {
union {
    uint16_t bdf;
    struct {

Yes.

Quoted 5 lines
Quoted 4 lines
        union {
            struct {
                uint8_t  func : 3, /* Function */
                         slot : 5; /* Device   */
Quoted 7 lines
Quoted 1 line

dev or device, surely?

Yeah, comment and field name would better match (or the comments could perhaps go away altogether). While "slot" is a common term here, with this being inside something called "sbdf" I agree "device" or "dev" (in the former case it should also be "function", but I prefer the shorter variants) should be used here.

I've used "slot" because I thought it was more common in the pci code, we already have kind of weird naming, for example we usually use PCI_SLOT(devfn). I don't have an opinion here, so I will switch to 'dev'.

I'm not sure what's the best way to introduce this, would you like it to be part of my PCI emulation series?

I certainly don't plan to switch existing callers unless I need to modify them anyway.

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#9 lore raw
Quoted 29 lines
Quoted 1 line
Quoted 1 line · On 11.09.17 at 11:22, <[email protected]> wrote:
Quoted 19 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 08.09.17 at 20:08, <[email protected]> wrote:

As as bdf is also quite a common unit, how about:

Quoted 4 lines
typedef union {
    uint32_t sbdf;
    struct {
union {
    uint16_t bdf;
    struct {

Yes.

Quoted 5 lines
Quoted 4 lines
        union {
            struct {
                uint8_t  func : 3, /* Function */
                         slot : 5; /* Device   */
Quoted 7 lines
Quoted 1 line

dev or device, surely?

Yeah, comment and field name would better match (or the comments could perhaps go away altogether). While "slot" is a common term here, with this being inside something called "sbdf" I agree "device" or "dev" (in the former case it should also be "function", but I prefer the shorter variants) should be used here.

Quoted 7 lines

I've used "slot" because I thought it was more common in the pci code, we already have kind of weird naming, for example we usually use PCI_SLOT(devfn). I don't have an opinion here, so I will switch to 'dev'.

I'm not sure what's the best way to introduce this, would you like it to be part of my PCI emulation series?

That would be fine, as would be an independent prereq patch.

Quoted 2 lines

I certainly don't plan to switch existing callers unless I need to modify them anyway.

Indeed. New code would be appreciated to use the new struct, but existing code will better be switched over time.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel