[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 05/18] pnv_phb4.c: check if root port exists in rc_config func
From: |
Daniel Henrique Barboza |
Subject: |
[PATCH v2 05/18] pnv_phb4.c: check if root port exists in rc_config functions |
Date: |
Wed, 5 Jan 2022 18:23:25 -0300 |
pnv_phb4_rc_config_read() and pnv_phb4_rc_config_write() are asserting
the existence of the root port. The root port is now optional, and there
will be cases where a pnv-phb4 device won't have a root port attached.
Instead of asserting, check if the root port exists before read/writing
into it.
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
hw/pci-host/pnv_phb4.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c
index 14827f8464..83dedc878a 100644
--- a/hw/pci-host/pnv_phb4.c
+++ b/hw/pci-host/pnv_phb4.c
@@ -152,7 +152,10 @@ static void pnv_phb4_rc_config_write(PnvPHB4 *phb,
unsigned off,
}
pdev = pci_find_device(pci->bus, 0, 0);
- assert(pdev);
+ if (!pdev) {
+ phb_error(phb, "rc_config_write device not found\n");
+ return;
+ }
pci_host_config_write_common(pdev, off, PHB_RC_CONFIG_SIZE,
bswap32(val), 4);
@@ -171,7 +174,10 @@ static uint64_t pnv_phb4_rc_config_read(PnvPHB4 *phb,
unsigned off,
}
pdev = pci_find_device(pci->bus, 0, 0);
- assert(pdev);
+ if (!pdev) {
+ phb_error(phb, "rc_config_read device not found\n");
+ return ~0ull;
+ }
val = pci_host_config_read_common(pdev, off, PHB_RC_CONFIG_SIZE, 4);
return bswap32(val);
--
2.33.1
- [PATCH v2 00/18] user creatable pnv-phb3/pnv-phb4 devices, Daniel Henrique Barboza, 2022/01/05
- [PATCH v2 01/18] pnv_phb3.c: add unique chassis and slot for pnv_phb3_root_port, Daniel Henrique Barboza, 2022/01/05
- [PATCH v2 02/18] pnv_phb4.c: add unique chassis and slot for pnv_phb4_root_port, Daniel Henrique Barboza, 2022/01/05
- [PATCH v2 03/18] ppc/pnv: Attach PHB3 root port device when defaults are enabled, Daniel Henrique Barboza, 2022/01/05
- [PATCH v2 04/18] pnv_phb4.c: make pnv-phb4-root-port user creatable, Daniel Henrique Barboza, 2022/01/05
- [PATCH v2 05/18] pnv_phb4.c: check if root port exists in rc_config functions,
Daniel Henrique Barboza <=
- [PATCH v2 06/18] ppc/pnv: Introduce support for user created PHB3 devices, Daniel Henrique Barboza, 2022/01/05
- [PATCH v2 07/18] ppc/pnv: Reparent user created PHB3 devices to the PnvChip, Daniel Henrique Barboza, 2022/01/05
- [PATCH v2 08/18] ppc/pnv: Complete user created PHB3 devices, Daniel Henrique Barboza, 2022/01/05
- [PATCH v2 09/18] ppc/pnv: Move num_phbs under Pnv8Chip, Daniel Henrique Barboza, 2022/01/05
- [PATCH v2 10/18] pnv_phb3.h: change TYPE_PNV_PHB3_ROOT_BUS name, Daniel Henrique Barboza, 2022/01/05
- [PATCH v2 11/18] pnv_phb4.c: introduce pnv_phb4_set_stack_phb_props(), Daniel Henrique Barboza, 2022/01/05
- [PATCH v2 12/18] pnv_phb4_pec.c: move pnv_pec_phb_offset() to pnv_phb4.c, Daniel Henrique Barboza, 2022/01/05