[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 07/17] pnv_phb4.c: check if root port exists in rc_config functio
From: |
Daniel Henrique Barboza |
Subject: |
[PATCH 07/17] pnv_phb4.c: check if root port exists in rc_config functions |
Date: |
Tue, 28 Dec 2021 16:37:56 -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 | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c
index daa468b812..6bd907f91a 100644
--- a/hw/pci-host/pnv_phb4.c
+++ b/hw/pci-host/pnv_phb4.c
@@ -152,7 +152,9 @@ static void pnv_phb4_rc_config_write(PnvPHB4 *phb, unsigned
off,
}
pdev = pci_find_device(pci->bus, 0, 0);
- assert(pdev);
+ if (!pdev) {
+ return;
+ }
pci_host_config_write_common(pdev, off, PHB_RC_CONFIG_SIZE,
bswap32(val), 4);
@@ -171,7 +173,9 @@ static uint64_t pnv_phb4_rc_config_read(PnvPHB4 *phb,
unsigned off,
}
pdev = pci_find_device(pci->bus, 0, 0);
- assert(pdev);
+ if (!pdev) {
+ return 0x0;
+ }
val = pci_host_config_read_common(pdev, off, PHB_RC_CONFIG_SIZE, 4);
return bswap32(val);
--
2.33.1
- [PATCH 00/17] ppc/pnv: enable pnv-phb4 user devices, Daniel Henrique Barboza, 2021/12/28
- [PATCH 01/17] pnv_phb3.c: add unique chassis and slot for pnv_phb3_root_port, Daniel Henrique Barboza, 2021/12/28
- [PATCH 02/17] pnv_phb3.c: do not set 'root-bus' as bus name, Daniel Henrique Barboza, 2021/12/28
- [PATCH 06/17] pnv_phb4.c: attach default root port in phb4 realize(), Daniel Henrique Barboza, 2021/12/28
- [PATCH 04/17] pnv_phb4.c: add unique chassis and slot for pnv_phb4_root_port, Daniel Henrique Barboza, 2021/12/28
- [PATCH 07/17] pnv_phb4.c: check if root port exists in rc_config functions,
Daniel Henrique Barboza <=
- [PATCH 03/17] pnv_phb3.h: change TYPE_PNV_PHB3_ROOT_BUS name, Daniel Henrique Barboza, 2021/12/28
- [PATCH 08/17] pnv_phb4.c: introduce pnv_phb4_set_stack_phb_props(), Daniel Henrique Barboza, 2021/12/28
- [PATCH 09/17] pnv_phb4_pec.c: move pnv_pec_phb_offset() to pnv_phb4.c, Daniel Henrique Barboza, 2021/12/28
- [PATCH 05/17] pnv.c: simplify pnv_phb_attach_root_port(), Daniel Henrique Barboza, 2021/12/28
- [PATCH 11/17] pnv_phb4_pec.c: use pnv_pec_get_phb_id() in pnv_pec_dt_xscom(), Daniel Henrique Barboza, 2021/12/28
- [PATCH 13/17] pnv_phb4.h: turn phb into a pointer in struct PnvPhb4PecStack, Daniel Henrique Barboza, 2021/12/28
- [PATCH 14/17] Revert "ppc/pnv: Introduce support for user created PHB4 devices", Daniel Henrique Barboza, 2021/12/28
- [PATCH 15/17] ppc/pnv: Introduce user creatable pnv-phb4 devices, Daniel Henrique Barboza, 2021/12/28
- [PATCH 10/17] pnv_phb4.c: introduce pnv_pec_init_stack_xscom(), Daniel Henrique Barboza, 2021/12/28
- [PATCH 12/17] pnv_phb4_pec.c: use 'default_enabled()' to init stack->phb, Daniel Henrique Barboza, 2021/12/28