xen/pciif: Clarify what values go in op->err and op->result.
PATCH 1/1 xen/pciif: Clarify what values go in op->err and op->result.
The earlier comment says that errno values go in op->err. However all implementations (NetBSD, Linux) of the most common operations use XEN_PCI_ERR_* instead of -EXX values.
The exception is the xen-pciback in Linux code when doing XEN_PCI_OP_enable_msix can stash the -EXX in op->result and in op->err.
As such lets clarify what '->err' and '->result' are suppose to contain.
--- xen/include/public/io/pciif.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
xen/include/public/io/pciif.h +4 -2
@@ -71,7 +71,7 @@ struct xen_pci_op {/* IN: what action to perform: XEN_PCI_OP_* */ uint32_t cmd; -/* OUT: will contain an error number (if any) from errno.h */ +/* OUT: will contain an XEN_PCI_ERR_* value. */ int32_t err;/* IN: which device to touch */
@@ -83,7 +83,9 @@ struct xen_pci_op {int32_t offset;int32_t size; -/* IN/OUT: Contains the result after a READ or the value to WRITE */ +/* IN/OUT: Contains the result after a READ or the value to WRITE. +* If the err does not have XEN_PCI_ERR_success, depending on +* XEN_PCI_OP_* might have the errno value. */ uint32_t value;/* IN: Contains extra infor for this operation */ uint32_t info;
Signature · 1 line
2.1.0
Quoted 5 lines · Konrad Rzeszutek Wilk
The earlier comment says that errno values go in
op->err. However all implementations (NetBSD, Linux) of the most common operations use XEN_PCI_ERR_* instead of-EXXvalues.The exception is the xen-pciback in Linux code when doing
And also linux-2.6.18.hg.
Quoted 38 lines
XEN_PCI_OP_enable_msixcan stash the-EXXinop->resultand inop->err.As such lets clarify what '->err' and '->result' are suppose to contain.
Signed-off-by Konrad Rzeszutek Wilk <[email protected]>--- xen/include/public/io/pciif.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)xen/include/public/io/pciif.h +4
-2@@ -71,7 +71,7 @@ struct xen_pci_op {/* IN: what action to perform: XEN_PCI_OP_* */ uint32_t cmd; -/* OUT: will contain an error number (if any) from errno.h */ +/* OUT: will contain an XEN_PCI_ERR_* value. */ int32_t err;/* IN: which device to touch */ @@ -83,7 +83,9 @@ struct xen_pci_op {int32_t offset;int32_t size; -/* IN/OUT: Contains the result after a READ or the value to WRITE */ +/* IN/OUT: Contains the result after a READ or the value to WRITE. +* If the err does not have XEN_PCI_ERR_success, depending on +* XEN_PCI_OP_* might have the errno value. */ uint32_t value;/* IN: Contains extra infor for this operation */ uint32_t info;Signature · 1 line
2.1.0
Quoted 7 lines · Konrad Rzeszutek Wilk
The earlier comment says that errno values go in
op->err. However all implementations (NetBSD, Linux) of the most common operations use XEN_PCI_ERR_* instead of-EXXvalues.The exception is the xen-pciback in Linux code when doing
XEN_PCI_OP_enable_msixcan stash the-EXXinop->resultand inop->err.
i.e. both of them contain the same thing? How unhelpful!
What would be the impact of "correcting" ->result to do the right thing? (as documented below after this patch).
Quoted 23 lines
As such lets clarify what '->err' and '->result' are suppose to contain.
Signed-off-by Konrad Rzeszutek Wilk <[email protected]>--- xen/include/public/io/pciif.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)xen/include/public/io/pciif.h +1
-1@@ -71,7 +71,7 @@ struct xen_pci_op {/* IN: what action to perform: XEN_PCI_OP_* */ uint32_t cmd; -/* OUT: will contain an error number (if any) from errno.h */ +/* OUT: will contain an XEN_PCI_ERR_* value. */ int32_t err;/* IN: which device to touch */
xen/include/public/io/pciif.h struct xen_pci_op { · line 87
Quoted 6 lines
xen/include/public/io/pciif.h +2
-1@@ -83,7 +83,9 @@ struct xen_pci_op {int32_t offset;int32_t size; -/* IN/OUT: Contains the result after a READ or the value to WRITE */ +/* IN/OUT: Contains the result after a READ or the value to WRITE. +* If the err does not have XEN_PCI_ERR_success, depending on
s/the err does not have/err is not/
xen/include/public/io/pciif.h struct xen_pci_op { · line 88
Quoted 1 line
xen/include/public/io/pciif.h +1
-0+* XEN_PCI_OP_* might have the errno value. */
might under what circumstances? Can that be documented (perhaps as a default here and a small number of exceptions?)
Quoted 3 lines
xen/include/public/io/pciif.h +0
-0uint32_t value;/* IN: Contains extra infor for this operation */ uint32_t info;
Quoted 5 lines · Ian Campbell
Quoted 4 lines · Konrad Rzeszutek Wilk
The earlier comment says that errno values go in
op->err. However all implementations (NetBSD, Linux) of the most common operations use XEN_PCI_ERR_* instead of-EXXvalues.
Quoted 8 lines
Quoted 3 lines
The exception is the xen-pciback in Linux code when doing
XEN_PCI_OP_enable_msixcan stash the-EXXinop->resultand inop->err.i.e. both of them contain the same thing? How unhelpful!
What would be the impact of "correcting" ->result to do the right thing? (as documented below after this patch).
Ugh. The frontend (Linux) first checks op->err. If it is non-zero then it returns op->err back up. If op->err is zero
but op->result is non-zero, then it returns op->result up the stack.
The 'stack' differs depending on what XEN_PCI_OP it is.
For XEN_PCI_OP_conf_read and XEN_PCI_OP_conf_write
it expects 'err' to contain XEN_PCI_ERR* values. And it converts them.
In upstream Linux:
The XEN_PCI_OP_enable_msix it expects 'err' to contain-EXX values. Which means that whoever called 'pci_enable_msi_range' will get the 'err' value.
In Linux 2.6.18, if 'err' has any value it will convert all of them to '-EINVAL'.
For XEN_PCI_OP_enable_msi if 'err' has any value it will convert all of them to -EINVAL.
For XEN_PCI_OP_disable_msix and XEN_PCI_OP_disable_msi it just reports the value.
NetBSD only implements XEN_PCI_OP_conf_write and XEN_PCI_OP_conf_read.
It looks to me that the upstream Linux kernel frontend driver needs to do what the linux-2.6.18 does (return -EINVAL if there are any errors).
Quoted 43 lines
Quoted 24 lines
As such lets clarify what '->err' and '->result' are suppose to contain.
Signed-off-by Konrad Rzeszutek Wilk <[email protected]>--- xen/include/public/io/pciif.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)xen/include/public/io/pciif.h +1
-1@@ -71,7 +71,7 @@ struct xen_pci_op {/* IN: what action to perform: XEN_PCI_OP_* */ uint32_t cmd; -/* OUT: will contain an error number (if any) from errno.h */ +/* OUT: will contain an XEN_PCI_ERR_* value. */ int32_t err;/* IN: which device to touch */ xen/include/public/io/pciif.h struct xen_pci_op { · line 87
Quoted 6 lines
xen/include/public/io/pciif.h +2
-1@@ -83,7 +83,9 @@ struct xen_pci_op {int32_t offset;int32_t size; -/* IN/OUT: Contains the result after a READ or the value to WRITE */ +/* IN/OUT: Contains the result after a READ or the value to WRITE. +* If the err does not have XEN_PCI_ERR_success, depending on s/the err does not have/err is not/
xen/include/public/io/pciif.h struct xen_pci_op { · line 88
Quoted 1 line
xen/include/public/io/pciif.h +1
-0+* XEN_PCI_OP_* might have the errno value. */ might under what circumstances? Can that be documented (perhaps as a default here and a small number of exceptions?)
Quoted 3 lines
xen/include/public/io/pciif.h +0
-0uint32_t value;/* IN: Contains extra infor for this operation */ uint32_t info;
Quoted 36 lines · Konrad Rzeszutek Wilk
Quoted 5 lines · Ian Campbell
Quoted 4 lines · Konrad Rzeszutek Wilk
The earlier comment says that errno values go in
op->err. However all implementations (NetBSD, Linux) of the most common operations use XEN_PCI_ERR_* instead of-EXXvalues.Quoted 8 lines
Quoted 3 lines
The exception is the xen-pciback in Linux code when doing
XEN_PCI_OP_enable_msixcan stash the-EXXinop->resultand inop->err.i.e. both of them contain the same thing? How unhelpful!
What would be the impact of "correcting" ->result to do the right thing? (as documented below after this patch).
Ugh. The frontend (Linux) first checks
op->err. If it is non-zero then it returnsop->errback up. Ifop->erris zero
butop->resultis non-zero, then it returnsop->resultup the stack.The 'stack' differs depending on what
XEN_PCI_OPit is.For
XEN_PCI_OP_conf_readandXEN_PCI_OP_conf_write
it expects 'err' to contain XEN_PCI_ERR* values. And it converts them.In upstream Linux:
TheXEN_PCI_OP_enable_msixit expects 'err' to contain-EXXvalues. Which means that whoever called 'pci_enable_msi_range' will get the 'err' value.In Linux 2.6.18, if 'err' has any value it will convert all of them to '
-EINVAL'.For
XEN_PCI_OP_enable_msiif 'err' has any value it will convert all of them to-EINVAL.
Quoted 7 lines
For
XEN_PCI_OP_disable_msixandXEN_PCI_OP_disable_msiit just reports the value.NetBSD only implements
XEN_PCI_OP_conf_writeandXEN_PCI_OP_conf_read.It looks to me that the upstream Linux kernel frontend driver needs to do what the linux-2.6.18 does (return
-EINVALif there are any errors).
So what are the next steps? Patches to other things? What about this one, should I expect a new version, drop it or apply it?
Quoted 40 lines · Ian Campbell
Quoted 39 lines · Konrad Rzeszutek Wilk
Quoted 5 lines · Ian Campbell
Quoted 4 lines · Konrad Rzeszutek Wilk
The earlier comment says that errno values go in
op->err. However all implementations (NetBSD, Linux) of the most common operations use XEN_PCI_ERR_* instead of-EXXvalues.Quoted 8 lines
Quoted 3 lines
The exception is the xen-pciback in Linux code when doing
XEN_PCI_OP_enable_msixcan stash the-EXXinop->resultand inop->err.i.e. both of them contain the same thing? How unhelpful!
What would be the impact of "correcting" ->result to do the right thing? (as documented below after this patch).
Ugh. The frontend (Linux) first checks
op->err. If it is non-zero then it returnsop->errback up. Ifop->erris zero
butop->resultis non-zero, then it returnsop->resultup the stack.The 'stack' differs depending on what
XEN_PCI_OPit is.For
XEN_PCI_OP_conf_readandXEN_PCI_OP_conf_write
it expects 'err' to contain XEN_PCI_ERR* values. And it converts them.In upstream Linux:
TheXEN_PCI_OP_enable_msixit expects 'err' to contain-EXXvalues. Which means that whoever called 'pci_enable_msi_range' will get the 'err' value.In Linux 2.6.18, if 'err' has any value it will convert all of them to '
-EINVAL'.For
XEN_PCI_OP_enable_msiif 'err' has any value it will convert all of them to-EINVAL.For
XEN_PCI_OP_disable_msixandXEN_PCI_OP_disable_msiit just reports the value.
Quoted 7 lines
Quoted 4 lines
NetBSD only implements
XEN_PCI_OP_conf_writeandXEN_PCI_OP_conf_read.It looks to me that the upstream Linux kernel frontend driver needs to do what the linux-2.6.18 does (return
-EINVALif there are any errors).So what are the next steps? Patches to other things? What about this one, should I expect a new version, drop it or apply it?
I neglected to mention that the upstream frontend driver will end up converting an uint32_t to int, with the end result that the error is actually 0xffffffffa (or such).
Which means that it really does not matter what (-EXX or XEN_PCI_ERR_*) or where (op->err or op->result) the backend stashes it as the frontend screws it up.
Which makes me comfortable in proposing this patch that mandates op->err to use XEN_PCI_ERR_* and stick in op->result -EXX if the opcode wants it.
It won't affect how the frontend deals with it as with even that change it will still return 0xfffff.. on failures.
In short, I will repost this patch and include this long rant in it.