powerpc/pseries/eeh: Fix get PE state translation
Subsystems (2)
PATCH 1/1 powerpc/pseries/eeh: Fix get PE state translation
The PE Reset State "0" obtained from RTAS calls ibm_read_slot_reset_[state|state2] indicates that the Reset is deactivated and the PE is not in the MMIO Stopped or DMA Stopped state.
With PE Reset State "0", the MMIO and DMA is allowed for the PE. The function pseries_eeh_get_state() is currently not indicating that to the caller because of which the drivers are unable to resume the MMIO and DMA activity. The patch fixes that by reflecting what is actually allowed.
--- arch/powerpc/platforms/pseries/eeh_pseries.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/powerpc/platforms/pseries/eeh_pseries.c +4 -2
@@ -580,8 +580,10 @@ static int pseries_eeh_get_state(struct eeh_pe *pe, int *delay)switch (rets[0 ]) {case 0 : - result =EEH_STATE_MMIO_ACTIVE | -EEH_STATE_DMA_ACTIVE ; + result =EEH_STATE_MMIO_ACTIVE | +EEH_STATE_DMA_ACTIVE | +EEH_STATE_MMIO_ENABLED | +EEH_STATE_DMA_ENABLED ;break ;case 1 : result = EEH_STATE_RESET_ACTIVE |
Signature · 1 line
2.45.2
Ritesh Harjani (IBM)
reviewerQuoted 7 lines · Narayana Murty N
The PE Reset State "0" obtained from RTAS calls ibm_read_slot_reset_[state|state2] indicates that the Reset is deactivated and the PE is not in the MMIO Stopped or DMA Stopped state.
With PE Reset State "0", the MMIO and DMA is allowed for the PE.
Looking at the PAPR spec - I do agree that it states the same. i.e. The "0" Initial PE state means the "Not Reset", "Load/Store allowed" & "DMA allowed" (Normal Operations).
Quoted 3 lines
The function
pseries_eeh_get_state()is currently not indicating that to the caller because of which the drivers are unable to resume the MMIO and DMA activity.
It's new to me, but could you help explain the user visible effect of what gets broken. Since this looks like pseries_eeh_get_state() has always been like this when it got first implemented.
Is there also a unit test somewhere which you are testing?
IIUC eeh_pe_get_state() was implemented[1] for supporting EEH for VFIO PCI devices. i.e. the VFIO_EEH_PE_GET_STATE operation of VFIO EEH PE ioctl op uses pseries_eeh_get_state() helper to query PE state on pseries LPAR. So are you suggesting that EEH functionality for VFIO PCI device was never enabled/tested before on pseries?
[1]: https://lore.kernel.org/all/[email protected]/
Checking the powernv side of implementation I do see that it does enables the EEH_STATE_[MMIO|DMA]_ENABLED flags in the result mask for the callers. So doing the same for pseries eeh get state implementation does look like the right thing to do here IMO.
Quoted 1 line
The patch fixes that by reflecting what is actually allowed.
You say this is "fixes" so I am also assuming you are also looking for stable backports of this? If yes - could you please also add the "Fixes" tag and cc stable?
-ritesh
Quoted 25 lines
Signed-off-by Narayana Murty N <[email protected]>--- arch/powerpc/platforms/pseries/eeh_pseries.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)arch/powerpc/platforms/pseries/eeh_pseries.c +4
-2@@ -580,8 +580,10 @@ static int pseries_eeh_get_state(struct eeh_pe *pe, int *delay)switch (rets[0 ]) {case 0 : - result =EEH_STATE_MMIO_ACTIVE | -EEH_STATE_DMA_ACTIVE ; + result =EEH_STATE_MMIO_ACTIVE | +EEH_STATE_DMA_ACTIVE | +EEH_STATE_MMIO_ENABLED | +EEH_STATE_DMA_ENABLED ;break ;case 1 : result = EEH_STATE_RESET_ACTIVE |Signature · 1 line
2.45.2
Hi Ritesh,
Thanks for looking into this patch. My responses on behalf of Narayana below:
Quoted 14 lines · Ritesh Harjani (IBM)
Quoted 7 lines · Narayana Murty N
The PE Reset State "0" obtained from RTAS calls ibm_read_slot_reset_[state|state2] indicates that the Reset is deactivated and the PE is not in the MMIO Stopped or DMA Stopped state.
With PE Reset State "0", the MMIO and DMA is allowed for the PE.
Looking at the PAPR spec - I do agree that it states the same. i.e. The "0" Initial PE state means the "Not Reset", "Load/Store allowed" & "DMA allowed" (Normal Operations).
Quoted 8 lines
Quoted 3 lines
The function
pseries_eeh_get_state()is currently not indicating that to the caller because of which the drivers are unable to resume the MMIO and DMA activity.It's new to me, but could you help explain the user visible effect of what gets broken. Since this looks like
pseries_eeh_get_state()has always been like this when it got first implemented.
Is there also a unit test somewhere which you are testing?
Without this patch a userspace process performing VFIO EEH-Recovery wont get the correct indication that EEH recovery is completed. Test code at
[2] has an example test case that uses VFIO to inject an EEH error on to a pci-device and then waits on it to reach 'EEH_PE_STATE_NORMAL' state . That state is never reached without this patch.
[2] :
https://github.com/nnmwebmin/vfio-ppc-tests/commit/006d8fdc41a4
Quoted 6 lines
IIUC
eeh_pe_get_state()was implemented[1] for supporting EEH for VFIO PCI devices. i.e. theVFIO_EEH_PE_GET_STATEoperation of VFIO EEH PE ioctl op usespseries_eeh_get_state()helper to query PE state on pseries LPAR. So are you suggesting that EEH functionality for VFIO PCI device was never enabled/tested before on pseries?
VFIO-EEH had been broken for pseries for a quite some time and was recently fixed in kernel. So this issue was probably not discovered until recently when we started testing with userspace VFIO.
Quoted 8 lines
[1]: https://lore.kernel.org/all/[email protected]/
Checking the powernv side of implementation I do see that it does enables the EEH_STATE_[MMIO|DMA]_ENABLED flags in the result mask for the callers. So doing the same for pseries eeh get state implementation does look like the right thing to do here IMO.
Quoted 5 lines
Quoted 1 line
The patch fixes that by reflecting what is actually allowed.
You say this is "fixes" so I am also assuming you are also looking for stable backports of this? If yes - could you please also add the "Fixes" tag and cc stable?
Yes, agree will re-send adding the fixes tag.
Quoted 29 lines
-ritesh
Quoted 25 lines
Signed-off-by Narayana Murty N <[email protected]>--- arch/powerpc/platforms/pseries/eeh_pseries.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)arch/powerpc/platforms/pseries/eeh_pseries.c +4
-2@@ -580,8 +580,10 @@ static int pseries_eeh_get_state(struct eeh_pe *pe, int *delay)switch (rets[0 ]) {case 0 : - result =EEH_STATE_MMIO_ACTIVE | -EEH_STATE_DMA_ACTIVE ; + result =EEH_STATE_MMIO_ACTIVE | +EEH_STATE_DMA_ACTIVE | +EEH_STATE_MMIO_ENABLED | +EEH_STATE_DMA_ENABLED ;break ;case 1 : result = EEH_STATE_RESET_ACTIVE |Signature · 1 line
2.45.2
Signature · 2 lines
Cheers ~ Vaibhav
Ritesh Harjani (IBM)
reviewerQuoted 29 lines · Vaibhav Jain
Hi Ritesh,
Thanks for looking into this patch. My responses on behalf of Narayana below:
Quoted 14 lines · Ritesh Harjani (IBM)
Quoted 7 lines · Narayana Murty N
The PE Reset State "0" obtained from RTAS calls ibm_read_slot_reset_[state|state2] indicates that the Reset is deactivated and the PE is not in the MMIO Stopped or DMA Stopped state.
With PE Reset State "0", the MMIO and DMA is allowed for the PE.
Looking at the PAPR spec - I do agree that it states the same. i.e. The "0" Initial PE state means the "Not Reset", "Load/Store allowed" & "DMA allowed" (Normal Operations).
Quoted 8 lines
Quoted 3 lines
The function
pseries_eeh_get_state()is currently not indicating that to the caller because of which the drivers are unable to resume the MMIO and DMA activity.It's new to me, but could you help explain the user visible effect of what gets broken. Since this looks like
pseries_eeh_get_state()has always been like this when it got first implemented.
Is there also a unit test somewhere which you are testing?
Quoted 9 lines
Without this patch a userspace process performing VFIO EEH-Recovery wont get the correct indication that EEH recovery is completed. Test code at
[2] has an example test case that uses VFIO to inject an EEH error on to a pci-device and then waits on it to reach 'EEH_PE_STATE_NORMAL' state . That state is never reached without this patch.[2] :
https://github.com/nnmwebmin/vfio-ppc-tests/commit/006d8fdc41a4
Right. Thanks for helping with that test code. It's much clearer now. So after the error inject and/or the PE hot reset, the PE is never reaching it's normal state. That is due to this kernel bug in the pseries EEH handling, where it fails to advertise the MMIO & DMA enabled capability flag back to the caller. This therefore can cause the userspace VFIO driver to incorrectly assume that MMIO/DMA operations cannot be done.
Quoted 10 lines
Quoted 6 lines
IIUC
eeh_pe_get_state()was implemented[1] for supporting EEH for VFIO PCI devices. i.e. theVFIO_EEH_PE_GET_STATEoperation of VFIO EEH PE ioctl op usespseries_eeh_get_state()helper to query PE state on pseries LPAR. So are you suggesting that EEH functionality for VFIO PCI device was never enabled/tested before on pseries?VFIO-EEH had been broken for pseries for a quite some time and was recently fixed in kernel. So this issue was probably not discovered until recently when we started testing with userspace VFIO.
ohk right, then maybe we might have started testing it after the eeh error inject op was implemented for pseries here [1].
[1]: https://lore.kernel.org/linuxppc-dev/[email protected]/#t
Quoted 8 lines
Quoted 8 lines
[1]: https://lore.kernel.org/all/[email protected]/
Checking the powernv side of implementation I do see that it does enables the EEH_STATE_[MMIO|DMA]_ENABLED flags in the result mask for the callers. So doing the same for pseries eeh get state implementation does look like the right thing to do here IMO.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
The patch fixes that by reflecting what is actually allowed.
You say this is "fixes" so I am also assuming you are also looking for stable backports of this? If yes - could you please also add the "Fixes" tag and cc stable?
Yes, agree will re-send adding the fixes tag.
Yes and maybe let's also add some more context & information to the commit message from this discussion.
-ritesh
Quoted 33 lines
Quoted 29 lines
-ritesh
Quoted 25 lines
Signed-off-by Narayana Murty N <[email protected]>--- arch/powerpc/platforms/pseries/eeh_pseries.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)arch/powerpc/platforms/pseries/eeh_pseries.c +4
-2@@ -580,8 +580,10 @@ static int pseries_eeh_get_state(struct eeh_pe *pe, int *delay)switch (rets[0 ]) {case 0 : - result =EEH_STATE_MMIO_ACTIVE | -EEH_STATE_DMA_ACTIVE ; + result =EEH_STATE_MMIO_ACTIVE | +EEH_STATE_DMA_ACTIVE | +EEH_STATE_MMIO_ENABLED | +EEH_STATE_DMA_ENABLED ;break ;case 1 : result = EEH_STATE_RESET_ACTIVE |Signature · 1 line
2.45.2Signature · 2 lines
Cheers ~ Vaibhav
Quoted 70 lines · Ritesh Harjani (IBM)
Quoted 27 lines · Vaibhav Jain
Hi Ritesh,
Thanks for looking into this patch. My responses on behalf of Narayana below:
Quoted 13 lines · Ritesh Harjani (IBM)
Quoted 7 lines · Narayana Murty N
The PE Reset State "0" obtained from RTAS calls ibm_read_slot_reset_[state|state2] indicates that the Reset is deactivated and the PE is not in the MMIO Stopped or DMA Stopped state.
With PE Reset State "0", the MMIO and DMA is allowed for the PE.
Looking at the PAPR spec - I do agree that it states the same. i.e. The "0" Initial PE state means the "Not Reset", "Load/Store allowed" & "DMA allowed" (Normal Operations).
Quoted 7 lines
Quoted 3 lines
The function
pseries_eeh_get_state()is currently not indicating that to the caller because of which the drivers are unable to resume the MMIO and DMA activity.It's new to me, but could you help explain the user visible effect of what gets broken. Since this looks like
pseries_eeh_get_state()has always been like this when it got first implemented.
Is there also a unit test somewhere which you are testing?Quoted 9 lines
Without this patch a userspace process performing VFIO EEH-Recovery wont get the correct indication that EEH recovery is completed. Test code at
[2] has an example test case that uses VFIO to inject an EEH error on to a pci-device and then waits on it to reach 'EEH_PE_STATE_NORMAL' state . That state is never reached without this patch.[2] :
https://github.com/nnmwebmin/vfio-ppc-tests/commit/006d8fdc41a4Right. Thanks for helping with that test code. It's much clearer now. So after the error inject and/or the PE hot reset, the PE is never reaching it's normal state. That is due to this kernel bug in the pseries EEH handling, where it fails to advertise the MMIO & DMA enabled capability flag back to the caller. This therefore can cause the userspace VFIO driver to incorrectly assume that MMIO/DMA operations cannot be done.
Quoted 9 lines
Quoted 5 lines
IIUC
eeh_pe_get_state()was implemented[1] for supporting EEH for VFIO PCI devices. i.e. theVFIO_EEH_PE_GET_STATEoperation of VFIO EEH PE ioctl op usespseries_eeh_get_state()helper to query PE state on pseries LPAR. So are you suggesting that EEH functionality for VFIO PCI device was never enabled/tested before on pseries?VFIO-EEH had been broken for pseries for a quite some time and was recently fixed in kernel. So this issue was probably not discovered until recently when we started testing with userspace VFIO.
ohk right, then maybe we might have started testing it after the eeh error inject op was implemented for pseries here [1].
[1]: https://lore.kernel.org/linuxppc-dev/[email protected]/#t
Quoted 11 lines
Quoted 11 lines
[1]: https://lore.kernel.org/all/[email protected]/
Checking the powernv side of implementation I do see that it does enables the EEH_STATE_[MMIO|DMA]_ENABLED flags in the result mask for the callers. So doing the same for pseries eeh get state implementation does look like the right thing to do here IMO.
Quoted 1 line
The patch fixes that by reflecting what is actually allowed.
You say this is "fixes" so I am also assuming you are also looking for stable backports of this? If yes - could you please also add the "Fixes" tag and cc stable?
Quoted 6 lines
Quoted 2 lines
Yes, agree will re-send adding the fixes tag.
Yes and maybe let's also add some more context & information to the commit message from this discussion.
-ritesh
yes Ritesh, added fixes tag and send it to the stable branch also.
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
-ritesh
Quoted 11 lines
Signed-off-by Narayana Murty N <[email protected]>--- arch/powerpc/platforms/pseries/eeh_pseries.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)arch/powerpc/platforms/pseries/eeh_pseries.c +0
-0@@ -580,8 +580,10 @@ static int pseries_eeh_get_state(struct eeh_pe *pe, int *delay)
Quoted 16 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
arch/powerpc/platforms/pseries/eeh_pseries.c +1
-2switch (rets[0 ]) {case 0 : - result =EEH_STATE_MMIO_ACTIVE | -EEH_STATE_DMA_ACTIVE ; + result = EEH_STATE_MMIO_ACTIVE |Quoted 11 lines
Quoted 8 lines
Quoted 8 lines
arch/powerpc/platforms/pseries/eeh_pseries.c +3
-0+EEH_STATE_DMA_ACTIVE | +EEH_STATE_MMIO_ENABLED | +EEH_STATE_DMA_ENABLED ;break ;case 1 : result = EEH_STATE_RESET_ACTIVE |Signature · 1 line
2.45.2Signature · 2 lines
Cheers ~ Vaibhav
Thank you Ritesh and Vaibhav for reviewing the patch. Please find the
changes addressed in https://lore.kernel.org/all/[email protected]/.
Regards,
Narayana Murty N