This is the linux part of the work to use the PCI hotplug framework to
control an opencapi card so that it can be reset and re-read after
flashing a new FPGA image. I had posted it earlier as an RFC and this
version is mostly similar, with just some minor editing.
It needs support in skiboot:
http://patchwork.ozlabs.org/project/skiboot/list/?series=129724
On an old skiboot, it will do nothing.
A virtual PCI slot is created for the opencapi adapter, and its state
can be controlled through the pnv-php hotplug driver:
echo 0|1 > /sys/bus/pci/slots/OPENCAPI-<...>/power
Note that the power to the card is not really turned off, as the card
needs to stay on to be flashed with a new image. Instead the card is
in reset.
The first part of the series mostly deals with the pci/ioda state, as
the opencapi devices can now go away and the state needs to be cleaned
up.
The second part is modifications to the PCI hotplug driver on powernv,
so that a virtual slot is created for the opencapi adapters found in
the device tree.
Frederic Barrat (11):
powerpc/powernv/ioda: Fix ref count for devices with their own PE
powerpc/powernv/ioda: Protect PE list
powerpc/powernv/ioda: set up PE on opencapi device when enabling
powerpc/powernv/ioda: Release opencapi device
powerpc/powernv/ioda: Find opencapi slot for a device node
pci/hotplug/pnv-php: Remove erroneous warning
pci/hotplug/pnv-php: Improve error msg on power state change failure
pci/hotplug/pnv-php: Register opencapi slots
pci/hotplug/pnv-php: Relax check when disabling slot
pci/hotplug/pnv-php: Wrap warnings in macro
ocxl: Add PCI hotplug dependency to Kconfig
arch/powerpc/include/asm/pnv-pci.h | 1 +
arch/powerpc/platforms/powernv/pci-ioda.c | 107 ++++++++++++++--------
arch/powerpc/platforms/powernv/pci.c | 10 +-
drivers/misc/ocxl/Kconfig | 1 +
drivers/pci/hotplug/pnv_php.c | 82 ++++++++++-------
5 files changed, 125 insertions(+), 76 deletions(-)
--
2.21.0
Taking a reference on the pci_dev structure was required with initial
commit 184cd4a3b962 ("powerpc/powernv: PCI support for p7IOC under
OPAL v2"), where we were storing the pci_dev in the pci_dn structure.
However, the pci_dev was later removed from the pci_dn structure, but
the reference was kept. See commit 902bdc57451c ("powerpc/powernv/idoa:
Remove unnecessary pcidev from pci_dn").
The pnv_ioda_pe structure life cycle is the same as the pci_dev
structure, the PE is freed when the device is released. So we don't
need a reference for the pci_dev stored in the PE, otherwise the
pci_dev will never be released. Which is not really a surprise as the
comment (removed here as no longer needed) was stating as much.
Fixes: 902bdc57451c ("powerpc/powernv/idoa: Remove unnecessary pcidev from pci_dn")
Signed-off-by: Frederic Barrat <redacted>
---
arch/powerpc/platforms/powernv/pci-ioda.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
@@ -1062,14 +1062,6 @@ static struct pnv_ioda_pe *pnv_ioda_setup_dev_PE(struct pci_dev *dev)returnNULL;}-/* NOTE: We get only one ref to the pci_dev for the pdn, not for the-*pointerinthePEdatastructure,bothshouldbedestroyedatthe-*sametime.However,thisneedstobelookedatmorecloselyagain-*onceweactuallystartremovingthings(Hotplug,SR-IOV,...)-*-*AtsomepointwewanttoremovethePDNcompletelyanyways-*/-pci_dev_get(dev);pdn->pe_number=pe->pe_number;pe->flags=PNV_IODA_PE_DEV;pe->pdev=dev;
@@ -1228,7 +1219,7 @@ static struct pnv_ioda_pe *pnv_ioda_setup_npu_PE(struct pci_dev *npu_pdev)*/dev_info(&npu_pdev->dev,"Associating to existing PE %x\n",pe_num);-pci_dev_get(npu_pdev);+pci_dev_get(npu_pdev);// still needed after 902bdc57451c ?npu_pdn=pci_get_pdn(npu_pdev);rid=npu_pdev->bus->number<<8|npu_pdn->devfn;npu_pdn->pe_number=pe_num;
On Mon, 2019-09-09 at 17:45 +0200, Frederic Barrat wrote:
quoted hunk
Taking a reference on the pci_dev structure was required with initial
commit 184cd4a3b962 ("powerpc/powernv: PCI support for p7IOC under
OPAL v2"), where we were storing the pci_dev in the pci_dn structure.
However, the pci_dev was later removed from the pci_dn structure, but
the reference was kept. See commit 902bdc57451c
("powerpc/powernv/idoa:
Remove unnecessary pcidev from pci_dn").
The pnv_ioda_pe structure life cycle is the same as the pci_dev
structure, the PE is freed when the device is released. So we don't
need a reference for the pci_dev stored in the PE, otherwise the
pci_dev will never be released. Which is not really a surprise as the
comment (removed here as no longer needed) was stating as much.
Fixes: 902bdc57451c ("powerpc/powernv/idoa: Remove unnecessary pcidev
from pci_dn")
Signed-off-by: Frederic Barrat <redacted>
---
arch/powerpc/platforms/powernv/pci-ioda.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
*pnv_ioda_setup_dev_PE(struct pci_dev *dev)
return NULL;
}
- /* NOTE: We get only one ref to the pci_dev for the pdn, not
for the
- * pointer in the PE data structure, both should be destroyed
at the
- * same time. However, this needs to be looked at more closely
again
- * once we actually start removing things (Hotplug, SR-IOV,
...)
- *
- * At some point we want to remove the PDN completely anyways
- */
- pci_dev_get(dev);
pdn->pe_number = pe->pe_number;
pe->flags = PNV_IODA_PE_DEV;
pe->pdev = dev;
From: Andrew Donnellan <hidden> Date: 2019-09-26 16:47:33
On 9/9/19 5:45 pm, Frederic Barrat wrote:
quoted hunk
Taking a reference on the pci_dev structure was required with initial
commit 184cd4a3b962 ("powerpc/powernv: PCI support for p7IOC under
OPAL v2"), where we were storing the pci_dev in the pci_dn structure.
However, the pci_dev was later removed from the pci_dn structure, but
the reference was kept. See commit 902bdc57451c ("powerpc/powernv/idoa:
Remove unnecessary pcidev from pci_dn").
The pnv_ioda_pe structure life cycle is the same as the pci_dev
structure, the PE is freed when the device is released. So we don't
need a reference for the pci_dev stored in the PE, otherwise the
pci_dev will never be released. Which is not really a surprise as the
comment (removed here as no longer needed) was stating as much.
Fixes: 902bdc57451c ("powerpc/powernv/idoa: Remove unnecessary pcidev from pci_dn")
Signed-off-by: Frederic Barrat <redacted>
---
arch/powerpc/platforms/powernv/pci-ioda.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
@@ -1062,14 +1062,6 @@ static struct pnv_ioda_pe *pnv_ioda_setup_dev_PE(struct pci_dev *dev)returnNULL;}-/* NOTE: We get only one ref to the pci_dev for the pdn, not for the-*pointerinthePEdatastructure,bothshouldbedestroyedatthe-*sametime.However,thisneedstobelookedatmorecloselyagain-*onceweactuallystartremovingthings(Hotplug,SR-IOV,...)-*-*AtsomepointwewanttoremovethePDNcompletelyanyways-*/-pci_dev_get(dev);pdn->pe_number=pe->pe_number;pe->flags=PNV_IODA_PE_DEV;pe->pdev=dev;
@@ -1228,7 +1219,7 @@ static struct pnv_ioda_pe *pnv_ioda_setup_npu_PE(struct pci_dev *npu_pdev)*/dev_info(&npu_pdev->dev,"Associating to existing PE %x\n",pe_num);-pci_dev_get(npu_pdev);+pci_dev_get(npu_pdev);// still needed after 902bdc57451c ?
Taking a reference on the pci_dev structure was required with initial
commit 184cd4a3b962 ("powerpc/powernv: PCI support for p7IOC under
OPAL v2"), where we were storing the pci_dev in the pci_dn structure.
However, the pci_dev was later removed from the pci_dn structure, but
the reference was kept. See commit 902bdc57451c ("powerpc/powernv/idoa:
Remove unnecessary pcidev from pci_dn").
The pnv_ioda_pe structure life cycle is the same as the pci_dev
structure, the PE is freed when the device is released. So we don't
need a reference for the pci_dev stored in the PE, otherwise the
pci_dev will never be released. Which is not really a surprise as the
comment (removed here as no longer needed) was stating as much.
Fixes: 902bdc57451c ("powerpc/powernv/idoa: Remove unnecessary pcidev
from pci_dn")
Signed-off-by: Frederic Barrat <redacted>
---
arch/powerpc/platforms/powernv/pci-ioda.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
*pnv_ioda_setup_dev_PE(struct pci_dev *dev)
return NULL;
}
- /* NOTE: We get only one ref to the pci_dev for the pdn, not for the
- * pointer in the PE data structure, both should be destroyed at the
- * same time. However, this needs to be looked at more closely again
- * once we actually start removing things (Hotplug, SR-IOV, ...)
- *
- * At some point we want to remove the PDN completely anyways
- */
- pci_dev_get(dev);
pdn->pe_number = pe->pe_number;
pe->flags = PNV_IODA_PE_DEV;
pe->pdev = dev;
Taking a reference on the pci_dev structure was required with initial
commit 184cd4a3b962 ("powerpc/powernv: PCI support for p7IOC under
OPAL v2"), where we were storing the pci_dev in the pci_dn structure.
However, the pci_dev was later removed from the pci_dn structure, but
the reference was kept. See commit 902bdc57451c ("powerpc/powernv/idoa:
Remove unnecessary pcidev from pci_dn").
The pnv_ioda_pe structure life cycle is the same as the pci_dev
structure, the PE is freed when the device is released. So we don't
need a reference for the pci_dev stored in the PE, otherwise the
pci_dev will never be released. Which is not really a surprise as the
comment (removed here as no longer needed) was stating as much.
Fixes: 902bdc57451c ("powerpc/powernv/idoa: Remove unnecessary pcidev from pci_dn")
Signed-off-by: Frederic Barrat <redacted>
---
arch/powerpc/platforms/powernv/pci-ioda.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
return NULL;
}
- /* NOTE: We get only one ref to the pci_dev for the pdn, not for the
- * pointer in the PE data structure, both should be destroyed at the
- * same time. However, this needs to be looked at more closely again
- * once we actually start removing things (Hotplug, SR-IOV, ...)
- *
- * At some point we want to remove the PDN completely anyways
- */
- pci_dev_get(dev);
pdn->pe_number = pe->pe_number;
pe->flags = PNV_IODA_PE_DEV;
pe->pdev = dev;
*/
dev_info(&npu_pdev->dev,
"Associating to existing PE %x\n", pe_num);
- pci_dev_get(npu_pdev);
+ pci_dev_get(npu_pdev); // still needed after 902bdc57451c ?
Did you mean to leave that comment in?
Yes, I assumed the series wouldn't get in on the first try and a nvlink-minded developer would weigh in :)
I am looking at it and I am still not so sure what exactly guarantees that lifetime(@dev) == lifetime(@pe). For example,
sriov_disable() removes VFs first, and only then releases PEs so there is a window when we may have a stale pdev. Not sure.
Le 27/09/2019 à 08:54, Alexey Kardashevskiy a écrit :
On 27/09/2019 03:15, Frederic Barrat wrote:
quoted
Le 26/09/2019 à 18:44, Andrew Donnellan a écrit :
quoted
On 9/9/19 5:45 pm, Frederic Barrat wrote:
quoted
Taking a reference on the pci_dev structure was required with initial
commit 184cd4a3b962 ("powerpc/powernv: PCI support for p7IOC under
OPAL v2"), where we were storing the pci_dev in the pci_dn structure.
However, the pci_dev was later removed from the pci_dn structure, but
the reference was kept. See commit 902bdc57451c ("powerpc/powernv/idoa:
Remove unnecessary pcidev from pci_dn").
The pnv_ioda_pe structure life cycle is the same as the pci_dev
structure, the PE is freed when the device is released. So we don't
need a reference for the pci_dev stored in the PE, otherwise the
pci_dev will never be released. Which is not really a surprise as the
comment (removed here as no longer needed) was stating as much.
Fixes: 902bdc57451c ("powerpc/powernv/idoa: Remove unnecessary pcidev from pci_dn")
Signed-off-by: Frederic Barrat <redacted>
---
arch/powerpc/platforms/powernv/pci-ioda.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
@@ -1062,14 +1062,6 @@ static struct pnv_ioda_pe *pnv_ioda_setup_dev_PE(struct pci_dev *dev)returnNULL;}-/* NOTE: We get only one ref to the pci_dev for the pdn, not for the-*pointerinthePEdatastructure,bothshouldbedestroyedatthe-*sametime.However,thisneedstobelookedatmorecloselyagain-*onceweactuallystartremovingthings(Hotplug,SR-IOV,...)-*-*AtsomepointwewanttoremovethePDNcompletelyanyways-*/-pci_dev_get(dev);pdn->pe_number=pe->pe_number;pe->flags=PNV_IODA_PE_DEV;pe->pdev=dev;
@@ -1228,7 +1219,7 @@ static struct pnv_ioda_pe *pnv_ioda_setup_npu_PE(struct pci_dev *npu_pdev)*/dev_info(&npu_pdev->dev,"Associating to existing PE %x\n",pe_num);-pci_dev_get(npu_pdev);+pci_dev_get(npu_pdev);// still needed after 902bdc57451c ?
Did you mean to leave that comment in?
Yes, I assumed the series wouldn't get in on the first try and a nvlink-minded developer would weigh in :)
I am looking at it and I am still not so sure what exactly guarantees that lifetime(@dev) == lifetime(@pe). For example,
sriov_disable() removes VFs first, and only then releases PEs so there is a window when we may have a stale pdev. Not sure.
Indeed, for SRIOV, PE life-cycle is handled differently. And hopefully
correctly, but I don’t think this patch alters it.
I was discussing with Greg about it, as he had to look in that area in
the past. My understanding is that this patch is ok as it follows the
initial comment in pnv_ioda_setup_dev_PE() that we don’t need to get a
reference for the PE, it makes sense and I could trace the origin of the
pci_dev_get() and it seemed like it should have been removed in a
previous patch (902bdc57451c).
However, one question is whether this patch breaks nvlink and if nvlink
assumes the devices won’t go away because we explicitly take a reference
forever. In npu_dma.c, there are 2 functions which allow to find the GPU
associated to a npu device, and vice-versa. Both functions return a
pointer to a struct pci_dev, but they don’t take a reference on the
device being returned. So that seems dangerous. I’m probably missing
something.
Alexey, Alistair: what, if anything, guarantees, that the npu or gpu
devices stay valid. Is it because we simply don’t provide any means to
get rid of them ? Otherwise, don’t we need the callers of
pnv_pci_get_gpu_dev() and pnv_pci_get_npu_dev() to worry about reference
counting ? I’ve started looking into it and the changes are scary, which
explains Greg’s related commit 02c5f5394918b.
Fred
On Wednesday, 13 November 2019 4:38:21 AM AEDT Frederic Barrat wrote:
Le 27/09/2019 à 08:54, Alexey Kardashevskiy a écrit :
quoted
On 27/09/2019 03:15, Frederic Barrat wrote:
quoted
Le 26/09/2019 à 18:44, Andrew Donnellan a écrit :
quoted
On 9/9/19 5:45 pm, Frederic Barrat wrote:
quoted
Taking a reference on the pci_dev structure was required with initial
commit 184cd4a3b962 ("powerpc/powernv: PCI support for p7IOC under
OPAL v2"), where we were storing the pci_dev in the pci_dn structure.
However, the pci_dev was later removed from the pci_dn structure, but
the reference was kept. See commit 902bdc57451c ("powerpc/powernv/idoa:
Remove unnecessary pcidev from pci_dn").
The pnv_ioda_pe structure life cycle is the same as the pci_dev
structure, the PE is freed when the device is released. So we don't
need a reference for the pci_dev stored in the PE, otherwise the
pci_dev will never be released. Which is not really a surprise as the
comment (removed here as no longer needed) was stating as much.
Fixes: 902bdc57451c ("powerpc/powernv/idoa: Remove unnecessary pcidev
return NULL;
}
- /* NOTE: We get only one ref to the pci_dev for the pdn, not for
the
quoted
quoted
quoted
quoted
- * pointer in the PE data structure, both should be destroyed at
the
quoted
quoted
quoted
quoted
- * same time. However, this needs to be looked at more closely
again
quoted
quoted
quoted
quoted
- * once we actually start removing things (Hotplug, SR-IOV, ...)
- *
- * At some point we want to remove the PDN completely anyways
- */
- pci_dev_get(dev);
pdn->pe_number = pe->pe_number;
pe->flags = PNV_IODA_PE_DEV;
pe->pdev = dev;
*/
dev_info(&npu_pdev->dev,
"Associating to existing PE %x\n", pe_num);
- pci_dev_get(npu_pdev);
+ pci_dev_get(npu_pdev); // still needed after 902bdc57451c
?
quoted
quoted
quoted
Did you mean to leave that comment in?
Yes, I assumed the series wouldn't get in on the first try and a nvlink-
minded developer would weigh in :)
quoted
I am looking at it and I am still not so sure what exactly guarantees that
lifetime(@dev) == lifetime(@pe). For example,
quoted
sriov_disable() removes VFs first, and only then releases PEs so there is a
window when we may have a stale pdev. Not sure.
Indeed, for SRIOV, PE life-cycle is handled differently. And hopefully
correctly, but I don’t think this patch alters it.
I was discussing with Greg about it, as he had to look in that area in
the past. My understanding is that this patch is ok as it follows the
initial comment in pnv_ioda_setup_dev_PE() that we don’t need to get a
reference for the PE, it makes sense and I could trace the origin of the
pci_dev_get() and it seemed like it should have been removed in a
previous patch (902bdc57451c).
However, one question is whether this patch breaks nvlink and if nvlink
assumes the devices won’t go away because we explicitly take a reference
forever. In npu_dma.c, there are 2 functions which allow to find the GPU
associated to a npu device, and vice-versa. Both functions return a
pointer to a struct pci_dev, but they don’t take a reference on the
device being returned. So that seems dangerous. I’m probably missing
something.
Alexey, Alistair: what, if anything, guarantees, that the npu or gpu
devices stay valid. Is it because we simply don’t provide any means to
get rid of them ? Otherwise, don’t we need the callers of
pnv_pci_get_gpu_dev() and pnv_pci_get_npu_dev() to worry about reference
counting ? I’ve started looking into it and the changes are scary, which
explains Greg’s related commit 02c5f5394918b.
To be honest the reference counting looks like it has evolved into something
quite suspect and I don't think you're missing anything. In practice though we
likely haven't hit any issues because the original callers didn't store
references to the pdev which would make the window quite small (although the
pass through work may have changed that). And as you say there simply wasn't
any means to get rid of them anyway (EEH, hotplug, etc. has never been
implemented or supported for GPUs and all sorts of terrible things happen if
you try).
The best solution would likely be to review the reference counting and to
teach callers of get_*_dev() to call pci_put_dev(), etc.
- Alistair
On Mon, Nov 18, 2019 at 12:06 PM Alistair Popple [off-list ref] wrote:
On Wednesday, 13 November 2019 4:38:21 AM AEDT Frederic Barrat wrote:
quoted
However, one question is whether this patch breaks nvlink and if nvlink
assumes the devices won’t go away because we explicitly take a reference
forever. In npu_dma.c, there are 2 functions which allow to find the GPU
associated to a npu device, and vice-versa. Both functions return a
pointer to a struct pci_dev, but they don’t take a reference on the
device being returned. So that seems dangerous. I’m probably missing
something.
Alexey, Alistair: what, if anything, guarantees, that the npu or gpu
devices stay valid. Is it because we simply don’t provide any means to
get rid of them ? Otherwise, don’t we need the callers of
pnv_pci_get_gpu_dev() and pnv_pci_get_npu_dev() to worry about reference
counting ? I’ve started looking into it and the changes are scary, which
explains Greg’s related commit 02c5f5394918b.
To be honest the reference counting looks like it has evolved into something
quite suspect and I don't think you're missing anything. In practice though we
likely haven't hit any issues because the original callers didn't store
references to the pdev which would make the window quite small (although the
pass through work may have changed that). And as you say there simply wasn't
any means to get rid of them anyway (EEH, hotplug, etc. has never been
implemented or supported for GPUs and all sorts of terrible things happen if
you try).
In other words: leaking a ref is the only safe thing to do.
The best solution would likely be to review the reference counting and to
teach callers of get_*_dev() to call pci_put_dev(), etc.
The issue is that the two callers of get_pci_dev() are non-GPL
exported symbols so we don't know what's calling them or what their
expectations are. We be doing whatever makes sense for OpenCAPI and if
that happens to cause a problem for someone else, then they can deal
with it.
Oliver
On Monday, 18 November 2019 12:24:24 PM AEDT Oliver O'Halloran wrote:
On Mon, Nov 18, 2019 at 12:06 PM Alistair Popple [off-list ref]
wrote:
quoted
On Wednesday, 13 November 2019 4:38:21 AM AEDT Frederic Barrat wrote:
quoted
However, one question is whether this patch breaks nvlink and if nvlink
assumes the devices won’t go away because we explicitly take a reference
forever. In npu_dma.c, there are 2 functions which allow to find the GPU
associated to a npu device, and vice-versa. Both functions return a
pointer to a struct pci_dev, but they don’t take a reference on the
device being returned. So that seems dangerous. I’m probably missing
something.
Alexey, Alistair: what, if anything, guarantees, that the npu or gpu
devices stay valid. Is it because we simply don’t provide any means to
get rid of them ? Otherwise, don’t we need the callers of
pnv_pci_get_gpu_dev() and pnv_pci_get_npu_dev() to worry about reference
counting ? I’ve started looking into it and the changes are scary, which
explains Greg’s related commit 02c5f5394918b.
To be honest the reference counting looks like it has evolved into
something
quoted
quite suspect and I don't think you're missing anything. In practice
though we
quoted
likely haven't hit any issues because the original callers didn't store
references to the pdev which would make the window quite small (although
the
quoted
pass through work may have changed that). And as you say there simply
wasn't
quoted
any means to get rid of them anyway (EEH, hotplug, etc. has never been
implemented or supported for GPUs and all sorts of terrible things happen
if
quoted
you try).
In other words: leaking a ref is the only safe thing to do.
Correct.
quoted
The best solution would likely be to review the reference counting and to
teach callers of get_*_dev() to call pci_put_dev(), etc.
The issue is that the two callers of get_pci_dev() are non-GPL
exported symbols so we don't know what's calling them or what their
expectations are. We be doing whatever makes sense for OpenCAPI and if
that happens to cause a problem for someone else, then they can deal
with it.
The issue isn't that it's exported non-GPL vs. GPL, rather that there are
probably out-of-tree modules like the NVIDIA driver using it. However as you
say supporting out-of-tree modules is not generally a concern for kernel
developers so we certainly shouldn't let that prevent us doing a fix.
- Alistair
On Monday, 18 November 2019 12:24:24 PM AEDT Oliver O'Halloran wrote:
quoted
On Mon, Nov 18, 2019 at 12:06 PM Alistair Popple [off-list ref]
wrote:
quoted
quoted
On Wednesday, 13 November 2019 4:38:21 AM AEDT Frederic Barrat wrote:
quoted
However, one question is whether this patch breaks nvlink and if nvlink
assumes the devices won’t go away because we explicitly take a reference
forever. In npu_dma.c, there are 2 functions which allow to find the GPU
associated to a npu device, and vice-versa. Both functions return a
pointer to a struct pci_dev, but they don’t take a reference on the
device being returned. So that seems dangerous. I’m probably missing
something.
Alexey, Alistair: what, if anything, guarantees, that the npu or gpu
devices stay valid. Is it because we simply don’t provide any means to
get rid of them ? Otherwise, don’t we need the callers of
pnv_pci_get_gpu_dev() and pnv_pci_get_npu_dev() to worry about reference
counting ? I’ve started looking into it and the changes are scary, which
explains Greg’s related commit 02c5f5394918b.
To be honest the reference counting looks like it has evolved into
something
quoted
quoted
quite suspect and I don't think you're missing anything. In practice
though we
quoted
quoted
likely haven't hit any issues because the original callers didn't store
references to the pdev which would make the window quite small (although
the
quoted
quoted
pass through work may have changed that). And as you say there simply
wasn't
quoted
quoted
any means to get rid of them anyway (EEH, hotplug, etc. has never been
implemented or supported for GPUs and all sorts of terrible things happen
if
quoted
quoted
you try).
In other words: leaking a ref is the only safe thing to do.
Correct.
quoted
quoted
The best solution would likely be to review the reference counting and to
teach callers of get_*_dev() to call pci_put_dev(), etc.
The issue is that the two callers of get_pci_dev() are non-GPL
exported symbols so we don't know what's calling them or what their
expectations are. We be doing whatever makes sense for OpenCAPI and if
that happens to cause a problem for someone else, then they can deal
with it.
The issue isn't that it's exported non-GPL vs. GPL, rather that there are
probably out-of-tree modules like the NVIDIA driver using it. However as you
say supporting out-of-tree modules is not generally a concern for kernel
developers so we certainly shouldn't let that prevent us doing a fix.
Thanks Alistair and Oliver. I'll bite the bullet and try do the right
thing wrt ref counting in npu-dma.c
Fred
The PE for an opencapi device was set as part of a late PHB fixup
operation, when creating the PHB. To use the PCI hotplug framework,
this is not going to work, as the PHB stays the same, it's only the
devices underneath which are updated. For regular PCI devices, it is
done as part of the reconfiguration of the bridge, but for opencapi
PHBs, we don't have an intermediate bridge. So let's define the PE
when the device is enabled. PEs are meaningless for opencapi, the NPU
doesn't define them and opal is not doing anything with them.
Signed-off-by: Frederic Barrat <redacted>
---
arch/powerpc/platforms/powernv/pci-ioda.c | 31 +++++++++++++++++------
1 file changed, 23 insertions(+), 8 deletions(-)
On Mon, 2019-09-09 at 17:45 +0200, Frederic Barrat wrote:
quoted hunk
The PE for an opencapi device was set as part of a late PHB fixup
operation, when creating the PHB. To use the PCI hotplug framework,
this is not going to work, as the PHB stays the same, it's only the
devices underneath which are updated. For regular PCI devices, it is
done as part of the reconfiguration of the bridge, but for opencapi
PHBs, we don't have an intermediate bridge. So let's define the PE
when the device is enabled. PEs are meaningless for opencapi, the NPU
doesn't define them and opal is not doing anything with them.
Signed-off-by: Frederic Barrat <redacted>
---
arch/powerpc/platforms/powernv/pci-ioda.c | 31 +++++++++++++++++--
----
1 file changed, 23 insertions(+), 8 deletions(-)
From: Andrew Donnellan <hidden> Date: 2019-09-27 16:45:55
On 9/9/19 5:45 pm, Frederic Barrat wrote:
The PE for an opencapi device was set as part of a late PHB fixup
operation, when creating the PHB. To use the PCI hotplug framework,
this is not going to work, as the PHB stays the same, it's only the
devices underneath which are updated. For regular PCI devices, it is
done as part of the reconfiguration of the bridge, but for opencapi
PHBs, we don't have an intermediate bridge. So let's define the PE
when the device is enabled. PEs are meaningless for opencapi, the NPU
doesn't define them and opal is not doing anything with them.
Signed-off-by: Frederic Barrat <redacted>
With hotplug, an opencapi device can now go away. It needs to be
released, mostly to clean up its PE state. We were previously not
defining any device callback. We can reuse the standard PCI release
callback, it does a bit too much for an opencapi device, but it's
harmless, and only needs minor tuning.
Also separate the undo of the PELT-V code in a separate function, it
is not needed for NPU devices and it improves a bit the readability of
the code.
Signed-off-by: Frederic Barrat <redacted>
---
arch/powerpc/platforms/powernv/pci-ioda.c | 59 +++++++++++++++--------
1 file changed, 39 insertions(+), 20 deletions(-)
@@ -188,7 +188,7 @@ static void pnv_ioda_free_pe(struct pnv_ioda_pe *pe)unsignedintpe_num=pe->pe_number;WARN_ON(pe->pdev);-WARN_ON(pe->npucomp);/* NPUs are not supposed to be freed */+WARN_ON(pe->npucomp);/* NPUs for nvlink are not supposed to be freed */kfree(pe->npucomp);memset(pe,0,sizeof(structpnv_ioda_pe));clear_bit(pe_num,phb->ioda.pe_alloc);
@@ -777,6 +777,34 @@ static int pnv_ioda_set_peltv(struct pnv_phb *phb,return0;}+staticvoidpnv_ioda_unset_peltv(structpnv_phb*phb,+structpnv_ioda_pe*pe,+structpci_dev*parent)+{+int64_trc;++while(parent){+structpci_dn*pdn=pci_get_pdn(parent);++if(pdn&&pdn->pe_number!=IODA_INVALID_PE){+rc=opal_pci_set_peltv(phb->opal_id,pdn->pe_number,+pe->pe_number,+OPAL_REMOVE_PE_FROM_DOMAIN);+/* XXX What to do in case of error ? */+}+parent=parent->bus->self;+}++opal_pci_eeh_freeze_clear(phb->opal_id,pe->pe_number,+OPAL_EEH_ACTION_CLEAR_FREEZE_ALL);++/* Disassociate PE in PELT */+rc=opal_pci_set_peltv(phb->opal_id,pe->pe_number,+pe->pe_number,OPAL_REMOVE_PE_FROM_DOMAIN);+if(rc)+pe_warn(pe,"OPAL error %lld remove self from PELTV\n",rc);+}+staticintpnv_ioda_deconfigure_pe(structpnv_phb*phb,structpnv_ioda_pe*pe){structpci_dev*parent;
@@ -827,25 +855,13 @@ static int pnv_ioda_deconfigure_pe(struct pnv_phb *phb, struct pnv_ioda_pe *pe)for(rid=pe->rid;rid<rid_end;rid++)phb->ioda.pe_rmap[rid]=IODA_INVALID_PE;-/* Release from all parents PELT-V */-while(parent){-structpci_dn*pdn=pci_get_pdn(parent);-if(pdn&&pdn->pe_number!=IODA_INVALID_PE){-rc=opal_pci_set_peltv(phb->opal_id,pdn->pe_number,-pe->pe_number,OPAL_REMOVE_PE_FROM_DOMAIN);-/* XXX What to do in case of error ? */-}-parent=parent->bus->self;-}--opal_pci_eeh_freeze_clear(phb->opal_id,pe->pe_number,-OPAL_EEH_ACTION_CLEAR_FREEZE_ALL);+/*+*ReleasefromallparentsPELT-V.NPUsdon'thaveaPELTV+*table+*/+if(phb->type!=PNV_PHB_NPU_NVLINK&&phb->type!=PNV_PHB_NPU_OCAPI)+pnv_ioda_unset_peltv(phb,pe,parent);-/* Disassociate PE in PELT */-rc=opal_pci_set_peltv(phb->opal_id,pe->pe_number,-pe->pe_number,OPAL_REMOVE_PE_FROM_DOMAIN);-if(rc)-pe_warn(pe,"OPAL error %lld remove self from PELTV\n",rc);rc=opal_pci_set_pe(phb->opal_id,pe->pe_number,pe->rid,bcomp,dcomp,fcomp,OPAL_UNMAP_PE);if(rc)
On Mon, 2019-09-09 at 17:45 +0200, Frederic Barrat wrote:
quoted hunk
With hotplug, an opencapi device can now go away. It needs to be
released, mostly to clean up its PE state. We were previously not
defining any device callback. We can reuse the standard PCI release
callback, it does a bit too much for an opencapi device, but it's
harmless, and only needs minor tuning.
Also separate the undo of the PELT-V code in a separate function, it
is not needed for NPU devices and it improves a bit the readability
of
the code.
Signed-off-by: Frederic Barrat <redacted>
---
arch/powerpc/platforms/powernv/pci-ioda.c | 59 +++++++++++++++----
----
1 file changed, 39 insertions(+), 20 deletions(-)
*pe)
unsigned int pe_num = pe->pe_number;
WARN_ON(pe->pdev);
- WARN_ON(pe->npucomp); /* NPUs are not supposed to be freed */
+ WARN_ON(pe->npucomp); /* NPUs for nvlink are not supposed to be
freed */
kfree(pe->npucomp);
memset(pe, 0, sizeof(struct pnv_ioda_pe));
clear_bit(pe_num, phb->ioda.pe_alloc);
@@ -777,6 +777,34 @@ static int pnv_ioda_set_peltv(struct pnv_phb
On Mon, 2019-09-09 at 17:45 +0200, Frederic Barrat wrote:
quoted
With hotplug, an opencapi device can now go away. It needs to be
released, mostly to clean up its PE state. We were previously not
defining any device callback. We can reuse the standard PCI release
callback, it does a bit too much for an opencapi device, but it's
harmless, and only needs minor tuning.
Also separate the undo of the PELT-V code in a separate function, it
is not needed for NPU devices and it improves a bit the readability
of
the code.
Signed-off-by: Frederic Barrat <redacted>
---
arch/powerpc/platforms/powernv/pci-ioda.c | 59 +++++++++++++++----
----
1 file changed, 39 insertions(+), 20 deletions(-)
*pe)
unsigned int pe_num = pe->pe_number;
WARN_ON(pe->pdev);
- WARN_ON(pe->npucomp); /* NPUs are not supposed to be freed */
+ WARN_ON(pe->npucomp); /* NPUs for nvlink are not supposed to be
freed */
kfree(pe->npucomp);
memset(pe, 0, sizeof(struct pnv_ioda_pe));
clear_bit(pe_num, phb->ioda.pe_alloc);
@@ -777,6 +777,34 @@ static int pnv_ioda_set_peltv(struct pnv_phb
+ pe->pe_number,
+ OPAL_REMOVE_PE_FROM_DOM
AIN);
+ /* XXX What to do in case of error ? */
Can we take the opportunity to address this comment?
Probably like the original author, I'm not sure what we could do better
here. We already log a warning below if opal returns an error when
dissociating the PE (admittedly not the same thing as the parent). Note
that this code is not executed for an opencapi device, so I'm just
keeping thing as is.
Fred
From: Andrew Donnellan <hidden> Date: 2019-11-19 07:11:34
On 10/9/19 1:45 am, Frederic Barrat wrote:
With hotplug, an opencapi device can now go away. It needs to be
released, mostly to clean up its PE state. We were previously not
defining any device callback. We can reuse the standard PCI release
callback, it does a bit too much for an opencapi device, but it's
harmless, and only needs minor tuning.
Also separate the undo of the PELT-V code in a separate function, it
is not needed for NPU devices and it improves a bit the readability of
the code.
Signed-off-by: Frederic Barrat <redacted>
Reviewed-by: Andrew Donnellan <redacted>
--
Andrew Donnellan OzLabs, ADL Canberra
ajd@linux.ibm.com IBM Australia Limited
Protect the PHB's list of PE. Probably not needed as long as it was
populated during PHB creation, but it feels right and will become
required once we can add/remove opencapi devices on hotplug.
Signed-off-by: Frederic Barrat <redacted>
---
arch/powerpc/platforms/powernv/pci-ioda.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
@@ -1080,8 +1080,9 @@ static struct pnv_ioda_pe *pnv_ioda_setup_dev_PE(struct pci_dev *dev)}/* Put PE to the list */+mutex_lock(&phb->ioda.pe_list_mutex);list_add_tail(&pe->list,&phb->ioda.pe_list);-+mutex_unlock(&phb->ioda.pe_list_mutex);returnpe;}
On Mon, 2019-09-09 at 17:45 +0200, Frederic Barrat wrote:
quoted hunk
Protect the PHB's list of PE. Probably not needed as long as it was
populated during PHB creation, but it feels right and will become
required once we can add/remove opencapi devices on hotplug.
Signed-off-by: Frederic Barrat <redacted>
---
arch/powerpc/platforms/powernv/pci-ioda.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
*pnv_ioda_setup_dev_PE(struct pci_dev *dev)
}
/* Put PE to the list */
+ mutex_lock(&phb->ioda.pe_list_mutex);
list_add_tail(&pe->list, &phb->ioda.pe_list);
-
+ mutex_unlock(&phb->ioda.pe_list_mutex);
return pe;
}
Hmm, the ioda.pe_list_mutex muxtex exists, and is inited, but there are
no other users. It's position & naming in the struct suggests it
belongs to ioda.pe_list, rather than pnv_ioda_pe.list (as suggested by
the lock/unlock around the list del).
Do the other accessors of ioda.pe_list also need mutex protection?
pnv_ioda_setup_bus_PE()
pnv_pci_dma_bus_setup()
pnv_pci_init_ioda_phb()
pnv_pci_ioda_setup_PEs()
If not, perhaps the metux should be removed from ioda and replaced with
pe.list_mutex instead.
--
Alastair D'Silva
Open Source Developer
Linux Technology Centre, IBM Australia
mob: 0423 762 819
On Mon, 2019-09-09 at 17:45 +0200, Frederic Barrat wrote:
quoted
Protect the PHB's list of PE. Probably not needed as long as it was
populated during PHB creation, but it feels right and will become
required once we can add/remove opencapi devices on hotplug.
Signed-off-by: Frederic Barrat <redacted>
---
arch/powerpc/platforms/powernv/pci-ioda.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
*pnv_ioda_setup_dev_PE(struct pci_dev *dev)
}
/* Put PE to the list */
+ mutex_lock(&phb->ioda.pe_list_mutex);
list_add_tail(&pe->list, &phb->ioda.pe_list);
-
+ mutex_unlock(&phb->ioda.pe_list_mutex);
return pe;
}
Hmm, the ioda.pe_list_mutex muxtex exists, and is inited, but there are
no other users. It's position & naming in the struct suggests it
belongs to ioda.pe_list, rather than pnv_ioda_pe.list (as suggested by
the lock/unlock around the list del).
I don't quite understand the above. The mutex is already in use by the
functions handling virtual functions, pnv_ioda_setup_vf_PE() and
pnv_ioda_release_vf_PE(). The point of the list is to keep track of all
the PEs used by the PHB, so it makes sense to have the mutex at that level.
Do the other accessors of ioda.pe_list also need mutex protection?
pnv_ioda_setup_bus_PE()
pnv_pci_dma_bus_setup()
pnv_pci_init_ioda_phb()
pnv_pci_ioda_setup_PEs()
I think we could also use it there, it wouldn't hurt. Those functions
are called when the kernel is building part of the PCI topology, and
devices are not really active yet, so I don't think it's absolutely
required.
I'm actually not sure my patch is needed either. With hotplug, the
devices can come and go, whereas the PHB remains. So it feels right to
start protecting the list when adding/removing a device. But I don't
think we can really have concurrency and have 2 different operations
adding/removing devices at the same time under the same PHB, at least
for opencapi. Maybe for PCI, if we have multiple slots under the same
PHB. Not sure.
Fred
If not, perhaps the metux should be removed from ioda and replaced with
pe.list_mutex instead.
On Tue, Nov 19, 2019 at 11:57 PM Frederic Barrat [off-list ref] wrote:
quoted
Do the other accessors of ioda.pe_list also need mutex protection?
pnv_ioda_setup_bus_PE()
pnv_pci_dma_bus_setup()
pnv_pci_init_ioda_phb()
pnv_pci_ioda_setup_PEs()
I think we could also use it there, it wouldn't hurt. Those functions
are called when the kernel is building part of the PCI topology, and
devices are not really active yet, so I don't think it's absolutely
required.
I'm actually not sure my patch is needed either. With hotplug, the
devices can come and go, whereas the PHB remains. So it feels right to
start protecting the list when adding/removing a device. But I don't
think we can really have concurrency and have 2 different operations
adding/removing devices at the same time under the same PHB, at least
for opencapi. Maybe for PCI, if we have multiple slots under the same
PHB. Not sure.
Creation of new pci_dev's is serialised by the global pci rescan and
remove lock so on the creation side it's not an issue. However, we can
release IODA PEs in the pci_dev's release function which might be
called without that lock held. It's pretty hard to hit that case
though since it require something to be holding a ref to the pci_dev
even after the driver's ->remove() function has been called.
Le 19/11/2019 à 14:22, Oliver O'Halloran a écrit :
On Tue, Nov 19, 2019 at 11:57 PM Frederic Barrat [off-list ref] wrote:
quoted
quoted
Do the other accessors of ioda.pe_list also need mutex protection?
pnv_ioda_setup_bus_PE()
pnv_pci_dma_bus_setup()
pnv_pci_init_ioda_phb()
pnv_pci_ioda_setup_PEs()
I think we could also use it there, it wouldn't hurt. Those functions
are called when the kernel is building part of the PCI topology, and
devices are not really active yet, so I don't think it's absolutely
required.
I'm actually not sure my patch is needed either. With hotplug, the
devices can come and go, whereas the PHB remains. So it feels right to
start protecting the list when adding/removing a device. But I don't
think we can really have concurrency and have 2 different operations
adding/removing devices at the same time under the same PHB, at least
for opencapi. Maybe for PCI, if we have multiple slots under the same
PHB. Not sure.
Creation of new pci_dev's is serialised by the global pci rescan and
remove lock so on the creation side it's not an issue. However, we can
release IODA PEs in the pci_dev's release function which might be
called without that lock held. It's pretty hard to hit that case
though since it require something to be holding a ref to the pci_dev
even after the driver's ->remove() function has been called.
Thanks for clarifying it! Indeed, the pci_rescan_remove_lock in hotplug
helps for the PCI case. I guess we can keep this patch for that hard to
hit case, just in case it doesn't blow up somewhere else.
Fred
From: Andrew Donnellan <hidden> Date: 2019-11-19 05:59:06
On 10/9/19 1:45 am, Frederic Barrat wrote:
Protect the PHB's list of PE. Probably not needed as long as it was
populated during PHB creation, but it feels right and will become
required once we can add/remove opencapi devices on hotplug.
Signed-off-by: Frederic Barrat <redacted>
Reviewed-by: Andrew Donnellan <redacted>
--
Andrew Donnellan OzLabs, ADL Canberra
ajd@linux.ibm.com IBM Australia Limited
Unlike real PCI slots, opencapi slots are directly associated to
the (virtual) opencapi PHB, there's no intermediate bridge. So when
looking for a slot ID, we must start the search from the device node
itself and not its parent.
Also, the slot ID is not attached to a specific bdfn, so let's build
it from the PHB ID, like skiboot.
Signed-off-by: Frederic Barrat <redacted>
---
arch/powerpc/include/asm/pnv-pci.h | 1 +
arch/powerpc/platforms/powernv/pci.c | 10 +++++++---
2 files changed, 8 insertions(+), 3 deletions(-)
On Mon, 2019-09-09 at 17:45 +0200, Frederic Barrat wrote:
quoted hunk
Unlike real PCI slots, opencapi slots are directly associated to
the (virtual) opencapi PHB, there's no intermediate bridge. So when
looking for a slot ID, we must start the search from the device node
itself and not its parent.
Also, the slot ID is not attached to a specific bdfn, so let's build
it from the PHB ID, like skiboot.
Signed-off-by: Frederic Barrat <redacted>
---
arch/powerpc/include/asm/pnv-pci.h | 1 +
arch/powerpc/platforms/powernv/pci.c | 10 +++++++---
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/include/asm/pnv-pci.h
b/arch/powerpc/include/asm/pnv-pci.h
index edcb1fc50aeb..d0ee0ede5767 100644
@@ -48,13 +48,14 @@ int pnv_pci_get_slot_id(struct device_node *np, uint64_t *id)return-ENXIO;bdfn=((bdfn&0x00ffff00)>>8);-while((parent=of_get_parent(parent))){+for(parent=np;parent;parent=of_get_parent(parent)){
I think we should rename this pointer from "parent" as it no longer
means that.
--
Andrew Donnellan OzLabs, ADL Canberra
ajd@linux.ibm.com IBM Australia Limited
The PCI hotplug framework is used to update the devices when a new
image is written to the FPGA.
Signed-off-by: Frederic Barrat <redacted>
---
drivers/misc/ocxl/Kconfig | 1 +
1 file changed, 1 insertion(+)
On Mon, 2019-09-09 at 17:46 +0200, Frederic Barrat wrote:
quoted hunk
The PCI hotplug framework is used to update the devices when a new
image is written to the FPGA.
Signed-off-by: Frederic Barrat <redacted>
---
drivers/misc/ocxl/Kconfig | 1 +
1 file changed, 1 insertion(+)
When changing the slot state, if opal hits an error and tells as such
in the asynchronous reply, the warning "Wrong msg" is logged, which is
rather confusing. Instead we can reuse the better message which is
already used when we couldn't submit the asynchronous opal request
initially.
Signed-off-by: Frederic Barrat <redacted>
---
drivers/pci/hotplug/pnv_php.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
On Mon, 2019-09-09 at 17:45 +0200, Frederic Barrat wrote:
quoted hunk
When changing the slot state, if opal hits an error and tells as such
in the asynchronous reply, the warning "Wrong msg" is logged, which
is
rather confusing. Instead we can reuse the better message which is
already used when we couldn't submit the asynchronous opal request
initially.
Signed-off-by: Frederic Barrat <redacted>
---
drivers/pci/hotplug/pnv_php.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/pci/hotplug/pnv_php.c
b/drivers/pci/hotplug/pnv_php.c
index 5b5cbf1e636d..304bdbcdb77c 100644
From: Andrew Donnellan <hidden> Date: 2019-11-19 02:25:10
On 10/9/19 1:45 am, Frederic Barrat wrote:
When changing the slot state, if opal hits an error and tells as such
in the asynchronous reply, the warning "Wrong msg" is logged, which is
rather confusing. Instead we can reuse the better message which is
already used when we couldn't submit the asynchronous opal request
initially.
Signed-off-by: Frederic Barrat <redacted>
Reviewed-by: Andrew Donnellan <redacted>
--
Andrew Donnellan OzLabs, ADL Canberra
ajd@linux.ibm.com IBM Australia Limited
The driver only allows to disable a slot in the POPULATED
state. However, if an error occurs while enabling the slot, say
because the link couldn't be trained, then the POPULATED state may not
be reached, yet the power state of the slot is on. So allow to disable
a slot in the REGISTERED state. Removing the devices will do nothing
since it's not populated, and we'll set the power state of the slot
back to off.
Signed-off-by: Frederic Barrat <redacted>
---
drivers/pci/hotplug/pnv_php.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
On Mon, 2019-09-09 at 17:45 +0200, Frederic Barrat wrote:
quoted hunk
The driver only allows to disable a slot in the POPULATED
state. However, if an error occurs while enabling the slot, say
because the link couldn't be trained, then the POPULATED state may
not
be reached, yet the power state of the slot is on. So allow to
disable
a slot in the REGISTERED state. Removing the devices will do nothing
since it's not populated, and we'll set the power state of the slot
back to off.
Signed-off-by: Frederic Barrat <redacted>
---
drivers/pci/hotplug/pnv_php.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/hotplug/pnv_php.c
b/drivers/pci/hotplug/pnv_php.c
index f0a7360154e7..5ca51d67db4b 100644
@@ -523,7 +523,13 @@ static int pnv_php_disable_slot(struct
hotplug_slot *slot)
struct pnv_php_slot *php_slot = to_pnv_php_slot(slot);
int ret;
- if (php_slot->state != PNV_PHP_STATE_POPULATED)
+ /*
+ * Allow to disable a slot already in the registered state to
+ * cover cases where the slot couldn't be enabled and never
+ * reached the populated state
+ */
+ if (php_slot->state != PNV_PHP_STATE_POPULATED &&
+ php_slot->state != PNV_PHP_STATE_REGISTERED)
return 0;
/* Remove all devices behind the slot */
Reviewed-by: Alastair D'Silva <redacted>
--
Alastair D'Silva
Open Source Developer
Linux Technology Centre, IBM Australia
mob: 0423 762 819
From: Andrew Donnellan <hidden> Date: 2019-09-27 15:59:06
On 9/9/19 5:45 pm, Frederic Barrat wrote:
The driver only allows to disable a slot in the POPULATED
state. However, if an error occurs while enabling the slot, say
because the link couldn't be trained, then the POPULATED state may not
be reached, yet the power state of the slot is on. So allow to disable
a slot in the REGISTERED state. Removing the devices will do nothing
since it's not populated, and we'll set the power state of the slot
back to off.
Signed-off-by: Frederic Barrat <redacted>
Makes sense
Reviewed-by: Andrew Donnellan <redacted>
Add the opencapi PHBs to the list of PHBs being scanned to look for
slots.
Signed-off-by: Frederic Barrat <redacted>
---
drivers/pci/hotplug/pnv_php.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
On Mon, 2019-09-09 at 17:45 +0200, Frederic Barrat wrote:
quoted hunk
Add the opencapi PHBs to the list of PHBs being scanned to look for
slots.
Signed-off-by: Frederic Barrat <redacted>
---
drivers/pci/hotplug/pnv_php.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/hotplug/pnv_php.c
b/drivers/pci/hotplug/pnv_php.c
index 304bdbcdb77c..f0a7360154e7 100644
From: Andrew Donnellan <hidden> Date: 2019-11-19 05:21:14
On 10/9/19 1:45 am, Frederic Barrat wrote:
quoted hunk
Add the opencapi PHBs to the list of PHBs being scanned to look for
slots.
Signed-off-by: Frederic Barrat <redacted>
---
drivers/pci/hotplug/pnv_php.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
Why do we use register_one to register and unregister rather than
unregister_one to unregister?
--
Andrew Donnellan OzLabs, ADL Canberra
ajd@linux.ibm.com IBM Australia Limited
Add the opencapi PHBs to the list of PHBs being scanned to look for
slots.
Signed-off-by: Frederic Barrat <redacted>
---
drivers/pci/hotplug/pnv_php.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/hotplug/pnv_php.c
b/drivers/pci/hotplug/pnv_php.c
index 304bdbcdb77c..f0a7360154e7 100644
Why do we use register_one to register and unregister rather than
unregister_one to unregister?
Good catch! With the above, the slot was not removed.
pnv_php_unregister() looks at the children only and was missing the
opencapi slot, since it's directly under the PHB.
Fred
An opencapi slot doesn't have an associated bridge device. It's not
needed for operation, but any warning is displayed through pci_warn()
which uses the pci_dev struct of the assocated bridge device. So wrap
those warning so that a different trace mechanism can be used if it's
an opencapi slot.
Signed-off-by: Frederic Barrat <redacted>
---
drivers/pci/hotplug/pnv_php.c | 51 +++++++++++++++++++----------------
1 file changed, 28 insertions(+), 23 deletions(-)
On Mon, 2019-09-09 at 17:45 +0200, Frederic Barrat wrote:
quoted hunk
An opencapi slot doesn't have an associated bridge device. It's not
needed for operation, but any warning is displayed through pci_warn()
which uses the pci_dev struct of the assocated bridge device. So wrap
those warning so that a different trace mechanism can be used if it's
an opencapi slot.
Signed-off-by: Frederic Barrat <redacted>
---
drivers/pci/hotplug/pnv_php.c | 51 +++++++++++++++++++------------
----
1 file changed, 28 insertions(+), 23 deletions(-)
diff --git a/drivers/pci/hotplug/pnv_php.c
b/drivers/pci/hotplug/pnv_php.c
index 5ca51d67db4b..d01a8595bc5c 100644
From: Andrew Donnellan <hidden> Date: 2019-09-26 17:20:35
On 9/9/19 5:45 pm, Frederic Barrat wrote:
An opencapi slot doesn't have an associated bridge device. It's not
needed for operation, but any warning is displayed through pci_warn()
which uses the pci_dev struct of the assocated bridge device. So wrap
those warning so that a different trace mechanism can be used if it's
an opencapi slot.
Signed-off-by: Frederic Barrat <redacted>
On powernv, when removing a device through hotplug, the following
warning is logged:
Invalid refcount <.> on <...>
It may be incorrect, the refcount may be set to a higher value than 1
and be valid. of_detach_node() can drop more than one reference. As it
doesn't seem trivial to assert the correct value, let's remove the
warning.
Signed-off-by: Frederic Barrat <redacted>
---
drivers/pci/hotplug/pnv_php.c | 6 ------
1 file changed, 6 deletions(-)
On Mon, 2019-09-09 at 17:45 +0200, Frederic Barrat wrote:
quoted hunk
On powernv, when removing a device through hotplug, the following
warning is logged:
Invalid refcount <.> on <...>
It may be incorrect, the refcount may be set to a higher value than 1
and be valid. of_detach_node() can drop more than one reference. As
it
doesn't seem trivial to assert the correct value, let's remove the
warning.
Signed-off-by: Frederic Barrat <redacted>
---
drivers/pci/hotplug/pnv_php.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/drivers/pci/hotplug/pnv_php.c
b/drivers/pci/hotplug/pnv_php.c
index 6758fd7c382e..5b5cbf1e636d 100644
From: Andrew Donnellan <hidden> Date: 2019-11-19 05:07:36
On 10/9/19 1:45 am, Frederic Barrat wrote:
On powernv, when removing a device through hotplug, the following
warning is logged:
Invalid refcount <.> on <...>
It may be incorrect, the refcount may be set to a higher value than 1
and be valid. of_detach_node() can drop more than one reference. As it
doesn't seem trivial to assert the correct value, let's remove the
warning.
Signed-off-by: Frederic Barrat <redacted>
Reviewed-by: Andrew Donnellan <redacted>
--
Andrew Donnellan OzLabs, ADL Canberra
ajd@linux.ibm.com IBM Australia Limited
Hi Fred,
what is this made against of? It does not apply on the master. Thanks,
On 10/09/2019 01:45, Frederic Barrat wrote:
This is the linux part of the work to use the PCI hotplug framework to
control an opencapi card so that it can be reset and re-read after
flashing a new FPGA image. I had posted it earlier as an RFC and this
version is mostly similar, with just some minor editing.
It needs support in skiboot:
http://patchwork.ozlabs.org/project/skiboot/list/?series=129724
On an old skiboot, it will do nothing.
A virtual PCI slot is created for the opencapi adapter, and its state
can be controlled through the pnv-php hotplug driver:
echo 0|1 > /sys/bus/pci/slots/OPENCAPI-<...>/power
Note that the power to the card is not really turned off, as the card
needs to stay on to be flashed with a new image. Instead the card is
in reset.
The first part of the series mostly deals with the pci/ioda state, as
the opencapi devices can now go away and the state needs to be cleaned
up.
The second part is modifications to the PCI hotplug driver on powernv,
so that a virtual slot is created for the opencapi adapters found in
the device tree.
Frederic Barrat (11):
powerpc/powernv/ioda: Fix ref count for devices with their own PE
powerpc/powernv/ioda: Protect PE list
powerpc/powernv/ioda: set up PE on opencapi device when enabling
powerpc/powernv/ioda: Release opencapi device
powerpc/powernv/ioda: Find opencapi slot for a device node
pci/hotplug/pnv-php: Remove erroneous warning
pci/hotplug/pnv-php: Improve error msg on power state change failure
pci/hotplug/pnv-php: Register opencapi slots
pci/hotplug/pnv-php: Relax check when disabling slot
pci/hotplug/pnv-php: Wrap warnings in macro
ocxl: Add PCI hotplug dependency to Kconfig
arch/powerpc/include/asm/pnv-pci.h | 1 +
arch/powerpc/platforms/powernv/pci-ioda.c | 107 ++++++++++++++--------
arch/powerpc/platforms/powernv/pci.c | 10 +-
drivers/misc/ocxl/Kconfig | 1 +
drivers/pci/hotplug/pnv_php.c | 82 ++++++++++-------
5 files changed, 125 insertions(+), 76 deletions(-)
Le 24/09/2019 à 06:24, Alexey Kardashevskiy a écrit :
Hi Fred,
what is this made against of? It does not apply on the master. Thanks,
It applies on v5.3. And I can see there's a conflict with the current
state in the merge window. I'll resubmit.
Fred
On 10/09/2019 01:45, Frederic Barrat wrote:
quoted
This is the linux part of the work to use the PCI hotplug framework to
control an opencapi card so that it can be reset and re-read after
flashing a new FPGA image. I had posted it earlier as an RFC and this
version is mostly similar, with just some minor editing.
It needs support in skiboot:
http://patchwork.ozlabs.org/project/skiboot/list/?series=129724
On an old skiboot, it will do nothing.
A virtual PCI slot is created for the opencapi adapter, and its state
can be controlled through the pnv-php hotplug driver:
echo 0|1 > /sys/bus/pci/slots/OPENCAPI-<...>/power
Note that the power to the card is not really turned off, as the card
needs to stay on to be flashed with a new image. Instead the card is
in reset.
The first part of the series mostly deals with the pci/ioda state, as
the opencapi devices can now go away and the state needs to be cleaned
up.
The second part is modifications to the PCI hotplug driver on powernv,
so that a virtual slot is created for the opencapi adapters found in
the device tree.
Frederic Barrat (11):
powerpc/powernv/ioda: Fix ref count for devices with their own PE
powerpc/powernv/ioda: Protect PE list
powerpc/powernv/ioda: set up PE on opencapi device when enabling
powerpc/powernv/ioda: Release opencapi device
powerpc/powernv/ioda: Find opencapi slot for a device node
pci/hotplug/pnv-php: Remove erroneous warning
pci/hotplug/pnv-php: Improve error msg on power state change failure
pci/hotplug/pnv-php: Register opencapi slots
pci/hotplug/pnv-php: Relax check when disabling slot
pci/hotplug/pnv-php: Wrap warnings in macro
ocxl: Add PCI hotplug dependency to Kconfig
arch/powerpc/include/asm/pnv-pci.h | 1 +
arch/powerpc/platforms/powernv/pci-ioda.c | 107 ++++++++++++++--------
arch/powerpc/platforms/powernv/pci.c | 10 +-
drivers/misc/ocxl/Kconfig | 1 +
drivers/pci/hotplug/pnv_php.c | 82 ++++++++++-------
5 files changed, 125 insertions(+), 76 deletions(-)
Le 24/09/2019 à 06:24, Alexey Kardashevskiy a écrit :
quoted
Hi Fred,
what is this made against of? It does not apply on the master. Thanks,
It applies on v5.3. And I can see there's a conflict with the current
state in the merge window. I'll resubmit.
Not really necessary, just mention the exact sha1 or tag in the cover
letter next time. Thanks,
Fred
quoted
On 10/09/2019 01:45, Frederic Barrat wrote:
quoted
This is the linux part of the work to use the PCI hotplug framework to
control an opencapi card so that it can be reset and re-read after
flashing a new FPGA image. I had posted it earlier as an RFC and this
version is mostly similar, with just some minor editing.
It needs support in skiboot:
http://patchwork.ozlabs.org/project/skiboot/list/?series=129724
On an old skiboot, it will do nothing.
A virtual PCI slot is created for the opencapi adapter, and its state
can be controlled through the pnv-php hotplug driver:
echo 0|1 > /sys/bus/pci/slots/OPENCAPI-<...>/power
Note that the power to the card is not really turned off, as the card
needs to stay on to be flashed with a new image. Instead the card is
in reset.
The first part of the series mostly deals with the pci/ioda state, as
the opencapi devices can now go away and the state needs to be cleaned
up.
The second part is modifications to the PCI hotplug driver on powernv,
so that a virtual slot is created for the opencapi adapters found in
the device tree.
Frederic Barrat (11):
powerpc/powernv/ioda: Fix ref count for devices with their own PE
powerpc/powernv/ioda: Protect PE list
powerpc/powernv/ioda: set up PE on opencapi device when enabling
powerpc/powernv/ioda: Release opencapi device
powerpc/powernv/ioda: Find opencapi slot for a device node
pci/hotplug/pnv-php: Remove erroneous warning
pci/hotplug/pnv-php: Improve error msg on power state change failure
pci/hotplug/pnv-php: Register opencapi slots
pci/hotplug/pnv-php: Relax check when disabling slot
pci/hotplug/pnv-php: Wrap warnings in macro
ocxl: Add PCI hotplug dependency to Kconfig
arch/powerpc/include/asm/pnv-pci.h | 1 +
arch/powerpc/platforms/powernv/pci-ioda.c | 107 ++++++++++++++--------
arch/powerpc/platforms/powernv/pci.c | 10 +-
drivers/misc/ocxl/Kconfig | 1 +
drivers/pci/hotplug/pnv_php.c | 82 ++++++++++-------
5 files changed, 125 insertions(+), 76 deletions(-)