accel/ivpu: Rework HW IP generation detection and dispatch
cover accel/ivpu: Rework HW IP generation detection and dispatch
This series reworks how the driver determines the HW IP generation and buttress version, and how it dispatches on them.
Today ivpu_hw_ip_gen() and ivpu_hw_btrs_gen() run a switch over the PCI device ID on every call, and an unknown ID only triggers a WARN() while probe continues with an undefined generation. Patch 1 resolves both values once during device init and fails probe with -EINVAL on an unrecognized device ID.
With that guarantee in place, patch 2 changes the stored values and their accessors to the real enum types and drops the default: labels from the switches that dispatch on them, so -Wswitch flags a generation that is added later but not handled.
Patch 3 splits the remaining per-generation dispatch in ivpu_hw_ip_soc_cpu_boot() and pwr_island_delay_set() into helpers that return directly from each case, removing the locals that were left uninitialized on the path past the last case.
No functional change is intended beyond failing probe on an unknown PCI device ID and logging the SOC CPU boot mode even when the boot fails.
Andrzej Kacprowski (1):
accel/ivpu: Improve HW IP gen and buttress version checks
Dawid Osuchowski (1):
accel/ivpu: Convert hw_ip_gen/btrs_gen to enum types
Karol Wachowski (1):
accel/ivpu: Split HW IP generation dispatch into helpers
drivers/accel/ivpu/ivpu_drv.c | 69 +++++++++++++++++++------- drivers/accel/ivpu/ivpu_drv.h | 65 +++++++++---------------- drivers/accel/ivpu/ivpu_hw.h | 1 - drivers/accel/ivpu/ivpu_hw_ip.c | 86 ++++++++++++++++----------------- 4 files changed, 117 insertions(+), 104 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/3 accel/ivpu: Improve HW IP gen and buttress version checks
From: Andrzej Kacprowski <[email protected]>
Remove the per-call switch in ivpu_hw_ip_gen()/ivpu_hw_btrs_gen() and instead initialize the HW IP generation and buttress version once during device init.
Fail probe with -EINVAL when the PCI device ID does not match any known generation, instead of warning and continuing with both fields left at 0, so callers never proceed with an unrecognized generation.
Drop hw->dma_bits and compute it locally to remove the early dependency on vdev->hw_ip_gen.
Make pwr_island_delay_set() use ivpu_hw_ip_gen() instead of the PCI device ID directly.
Move MODULE_DEVICE_TABLE() to the top of the file to colocate it with the HW IP and buttress detection logic.
--- drivers/accel/ivpu/ivpu_drv.c | 69 +++++++++++++++++++++++++-------- drivers/accel/ivpu/ivpu_drv.h | 41 +++++--------------- drivers/accel/ivpu/ivpu_hw.h | 1 - drivers/accel/ivpu/ivpu_hw_ip.c | 18 +++------ 4 files changed, 67 insertions(+), 62 deletions(-)
drivers/accel/ivpu/ivpu_drv.c +52 -17
@@ -67,6 +67,48 @@ bool ivpu_force_snoop;module_param_named (force_snoop, ivpu_force_snoop, bool,0444 );MODULE_PARM_DESC (force_snoop,"Force snooping for NPU host memory access" ); +static struct pci_device_id ivpu_pci_ids[] = { + {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_MTL ) }, + {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_ARL ) }, + {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_LNL ) }, + {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_PTL ) }, + {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_WCL ) }, + {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_NVL ) }, + {} +}; +MODULE_DEVICE_TABLE (pci, ivpu_pci_ids); + +static int ivpu_ip_gen_init (struct ivpu_device *vdev) +{ + vdev->platform =IVPU_PLATFORM_INVALID ; + +switch (ivpu_device_id (vdev)) { +case PCI_DEVICE_ID_MTL : +case PCI_DEVICE_ID_ARL : + vdev->hw_ip_gen =IVPU_HW_IP_37XX ; + vdev->btrs_gen =IVPU_HW_BTRS_MTL ; +break ; +case PCI_DEVICE_ID_LNL : + vdev->hw_ip_gen =IVPU_HW_IP_40XX ; + vdev->btrs_gen =IVPU_HW_BTRS_LNL ; +break ; +case PCI_DEVICE_ID_PTL : +case PCI_DEVICE_ID_WCL : + vdev->hw_ip_gen =IVPU_HW_IP_50XX ; + vdev->btrs_gen =IVPU_HW_BTRS_LNL ; +break ; +case PCI_DEVICE_ID_NVL : + vdev->hw_ip_gen =IVPU_HW_IP_60XX ; + vdev->btrs_gen =IVPU_HW_BTRS_LNL ; +break ; +default : +ivpu_err (vdev,"Unknown PCI device [%04x:%04x]\n" ,ivpu_vendor_id (vdev), +ivpu_device_id (vdev)); +return -EINVAL ; + } +return 0 ; +} +static struct ivpu_user_limits *ivpu_user_limits_alloc (struct ivpu_device *vdev,uid_t uid) {struct ivpu_user_limits *limits;
@@ -649,6 +691,7 @@ static int ivpu_pci_init(struct ivpu_device *vdev)struct pci_dev *pdev =to_pci_dev (vdev->drm.dev);struct resource *bar0 = &pdev->resource[0 ];struct resource *bar4 = &pdev->resource[4 ]; +int dma_bits;int ret;ivpu_dbg (vdev,MISC ,"Mapping BAR0 (RegV) %pR\n" , bar0);
@@ -665,7 +708,12 @@ static int ivpu_pci_init(struct ivpu_device *vdev)return PTR_ERR (vdev->regb); } - ret =dma_set_mask_and_coherent (vdev->drm.dev,DMA_BIT_MASK (vdev->hw->dma_bits)); +if (ivpu_hw_ip_gen (vdev) >=IVPU_HW_IP_40XX ) + dma_bits =48 ; +else + dma_bits =38 ; + + ret =dma_set_mask_and_coherent (vdev->drm.dev,DMA_BIT_MASK (dma_bits));if (ret) {ivpu_err (vdev,"Failed to set DMA mask: %d\n" , ret);return ret;
@@ -713,12 +761,10 @@ static int ivpu_dev_init(struct ivpu_device *vdev)if (!vdev->pm)return -ENOMEM ; -if (ivpu_hw_ip_gen (vdev) >=IVPU_HW_IP_40XX ) - vdev->hw->dma_bits =48 ; -else - vdev->hw->dma_bits =38 ; + ret =ivpu_ip_gen_init (vdev); +if (ret) +return ret; - vdev->platform =IVPU_PLATFORM_INVALID ; vdev->context_xa_limit.min =IVPU_USER_CONTEXT_MIN_SSID ; vdev->context_xa_limit.max =IVPU_USER_CONTEXT_MAX_SSID ;atomic64_set (&vdev->unique_id_counter,0 );
@@ -851,17 +897,6 @@ static void ivpu_dev_fini(struct ivpu_device *vdev)xa_destroy (&vdev->context_xa); } -static struct pci_device_id ivpu_pci_ids[] = { - {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_MTL ) }, - {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_ARL ) }, - {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_LNL ) }, - {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_PTL_P ) }, - {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_WCL ) }, - {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_NVL ) }, - {} -}; -MODULE_DEVICE_TABLE (pci, ivpu_pci_ids); -static int ivpu_probe (struct pci_dev *pdev,const struct pci_device_id *id) {struct ivpu_device *vdev;
drivers/accel/ivpu/ivpu_drv.h +10 -31
69 lines not on this page · raw message
drivers/accel/ivpu/ivpu_hw.h +0 -1
@@ -49,7 +49,6 @@ struct ivpu_hw_info {u32 tile_fuse;u32 sku;u16 config; -int dma_bits;ktime_t d0i3_entry_host_ts;u64 d0i3_entry_vpu_ts;atomic_t firewall_irq_counter;
drivers/accel/ivpu/ivpu_hw_ip.c +5 -13
@@ -678,29 +678,21 @@ static void pwr_island_delay_set(struct ivpu_device *vdev)bool high = vdev->hw->pll.profiling_freq ==PLL_PROFILING_FREQ_HIGH ;u32 post, post1, post2, status; -if (ivpu_hw_ip_gen (vdev) <IVPU_HW_IP_50XX ) +switch (ivpu_hw_ip_gen (vdev)) { +case IVPU_HW_IP_37XX : +case IVPU_HW_IP_40XX :return ; - -switch (ivpu_device_id (vdev)) { -case PCI_DEVICE_ID_WCL : -case PCI_DEVICE_ID_PTL_P : +case IVPU_HW_IP_50XX : post = high ?18 :0 ; post1 =0 ; post2 =0 ; status = high ?46 :3 ;break ; - -case PCI_DEVICE_ID_NVL : +default : post = high ?198 :17 ; post1 =0 ; post2 = high ?198 :17 ; status =0 ; -break ; - -default : -dump_stack (); -ivpu_err (vdev,"Unknown device ID\n" ); -return ; }pwr_island_delay_set_50xx (vdev, post, post1, post2, status);
Signature · 1 line
2.43.0
Re: [PATCH 1/3] accel/ivpu: Improve HW IP gen and buttress version checks
Quoted 256 lines · Dawid Osuchowski
From: Andrzej Kacprowski <[email protected]>
Remove the per-call switch in ivpu_hw_ip_gen()/ivpu_hw_btrs_gen() and instead initialize the HW IP generation and buttress version once during device init.
Fail probe with
-EINVALwhen the PCI device ID does not match any known generation, instead of warning and continuing with both fields left at 0, so callers never proceed with an unrecognized generation.Drop
hw->dma_bitsand compute it locally to remove the early dependency onvdev->hw_ip_gen.Make
pwr_island_delay_set()useivpu_hw_ip_gen()instead of the PCI device ID directly.Move
MODULE_DEVICE_TABLE()to the top of the file to colocate it with the HW IP and buttress detection logic.Signed-off-by Andrzej Kacprowski <[email protected]>Co-developed-by Dawid Osuchowski <[email protected]>Signed-off-by Dawid Osuchowski <[email protected]>--- drivers/accel/ivpu/ivpu_drv.c | 69 +++++++++++++++++++++++++-------- drivers/accel/ivpu/ivpu_drv.h | 41 +++++--------------- drivers/accel/ivpu/ivpu_hw.h | 1 - drivers/accel/ivpu/ivpu_hw_ip.c | 18 +++------ 4 files changed, 67 insertions(+), 62 deletions(-)drivers/accel/ivpu/ivpu_drv.c +52
-17@@ -67,6 +67,48 @@ bool ivpu_force_snoop;module_param_named (force_snoop, ivpu_force_snoop, bool,0444 );MODULE_PARM_DESC (force_snoop,"Force snooping for NPU host memory access" ); +static struct pci_device_id ivpu_pci_ids[] = { + {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_MTL ) }, + {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_ARL ) }, + {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_LNL ) }, + {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_PTL ) }, + {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_WCL ) }, + {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_NVL ) }, + {} +}; +MODULE_DEVICE_TABLE (pci, ivpu_pci_ids); + +static int ivpu_ip_gen_init (struct ivpu_device *vdev) +{ + vdev->platform =IVPU_PLATFORM_INVALID ; + +switch (ivpu_device_id (vdev)) { +case PCI_DEVICE_ID_MTL : +case PCI_DEVICE_ID_ARL : + vdev->hw_ip_gen =IVPU_HW_IP_37XX ; + vdev->btrs_gen =IVPU_HW_BTRS_MTL ; +break ; +case PCI_DEVICE_ID_LNL : + vdev->hw_ip_gen =IVPU_HW_IP_40XX ; + vdev->btrs_gen =IVPU_HW_BTRS_LNL ; +break ; +case PCI_DEVICE_ID_PTL : +case PCI_DEVICE_ID_WCL : + vdev->hw_ip_gen =IVPU_HW_IP_50XX ; + vdev->btrs_gen =IVPU_HW_BTRS_LNL ; +break ; +case PCI_DEVICE_ID_NVL : + vdev->hw_ip_gen =IVPU_HW_IP_60XX ; + vdev->btrs_gen =IVPU_HW_BTRS_LNL ; +break ; +default : +ivpu_err (vdev,"Unknown PCI device [%04x:%04x]\n" ,ivpu_vendor_id (vdev), +ivpu_device_id (vdev)); +return -EINVAL ; + } +return 0 ; +} +static struct ivpu_user_limits *ivpu_user_limits_alloc (struct ivpu_device *vdev,uid_t uid) {struct ivpu_user_limits *limits;@@ -649,6 +691,7 @@ static int ivpu_pci_init(struct ivpu_device *vdev)struct pci_dev *pdev =to_pci_dev (vdev->drm.dev);struct resource *bar0 = &pdev->resource[0 ];struct resource *bar4 = &pdev->resource[4 ]; +int dma_bits;int ret;ivpu_dbg (vdev,MISC ,"Mapping BAR0 (RegV) %pR\n" , bar0);@@ -665,7 +708,12 @@ static int ivpu_pci_init(struct ivpu_device *vdev)return PTR_ERR (vdev->regb); } - ret =dma_set_mask_and_coherent (vdev->drm.dev,DMA_BIT_MASK (vdev->hw->dma_bits)); +if (ivpu_hw_ip_gen (vdev) >=IVPU_HW_IP_40XX ) + dma_bits =48 ; +else + dma_bits =38 ; + + ret =dma_set_mask_and_coherent (vdev->drm.dev,DMA_BIT_MASK (dma_bits));if (ret) {ivpu_err (vdev,"Failed to set DMA mask: %d\n" , ret);return ret;@@ -713,12 +761,10 @@ static int ivpu_dev_init(struct ivpu_device *vdev)if (!vdev->pm)return -ENOMEM ; -if (ivpu_hw_ip_gen (vdev) >=IVPU_HW_IP_40XX ) - vdev->hw->dma_bits =48 ; -else - vdev->hw->dma_bits =38 ; + ret =ivpu_ip_gen_init (vdev); +if (ret) +return ret; - vdev->platform =IVPU_PLATFORM_INVALID ; vdev->context_xa_limit.min =IVPU_USER_CONTEXT_MIN_SSID ; vdev->context_xa_limit.max =IVPU_USER_CONTEXT_MAX_SSID ;atomic64_set (&vdev->unique_id_counter,0 );@@ -851,17 +897,6 @@ static void ivpu_dev_fini(struct ivpu_device *vdev)xa_destroy (&vdev->context_xa); } -static struct pci_device_id ivpu_pci_ids[] = { - {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_MTL ) }, - {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_ARL ) }, - {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_LNL ) }, - {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_PTL_P ) }, - {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_WCL ) }, - {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_NVL ) }, - {} -}; -MODULE_DEVICE_TABLE (pci, ivpu_pci_ids); -static int ivpu_probe (struct pci_dev *pdev,const struct pci_device_id *id) {struct ivpu_device *vdev;drivers/accel/ivpu/ivpu_drv.h +10
-31@@ -27,7 +27,7 @@#define PCI_DEVICE_ID_MTL 0x7d1d#define PCI_DEVICE_ID_ARL 0xad1d#define PCI_DEVICE_ID_LNL 0x643e -#define PCI_DEVICE_ID_PTL_P 0xb03e +#define PCI_DEVICE_ID_PTL 0xb03e#define PCI_DEVICE_ID_WCL 0xfd3e#define PCI_DEVICE_ID_NVL 0xd71d@@ -136,6 +136,8 @@ struct ivpu_device {struct drm_device drm;void __iomem *regb;void __iomem *regv; +u32 hw_ip_gen; +u32 btrs_gen;u32 platform;u32 irq;@@ -247,6 +249,11 @@ static inline u8 ivpu_revision(struct ivpu_device *vdev)return to_pci_dev (vdev->drm.dev)->revision; } +static inline u16 ivpu_vendor_id (struct ivpu_device *vdev) +{ +return to_pci_dev (vdev->drm.dev)->vendor; +} +static inline u16 ivpu_device_id (struct ivpu_device *vdev) {return to_pci_dev (vdev->drm.dev)->device;@@ -254,40 +261,12 @@ static inline u16 ivpu_device_id(struct ivpu_device *vdev)static inline int ivpu_hw_ip_gen (struct ivpu_device *vdev) { -switch (ivpu_device_id (vdev)) { -case PCI_DEVICE_ID_MTL : -case PCI_DEVICE_ID_ARL : -return IVPU_HW_IP_37XX ; -case PCI_DEVICE_ID_LNL : -return IVPU_HW_IP_40XX ; -case PCI_DEVICE_ID_PTL_P : -case PCI_DEVICE_ID_WCL : -return IVPU_HW_IP_50XX ; -case PCI_DEVICE_ID_NVL : -return IVPU_HW_IP_60XX ; -default : -dump_stack (); -ivpu_err (vdev,"Unknown NPU IP generation\n" ); -return 0 ; - } +return vdev->hw_ip_gen; }static inline int ivpu_hw_btrs_gen (struct ivpu_device *vdev) { -switch (ivpu_device_id (vdev)) { -case PCI_DEVICE_ID_MTL : -case PCI_DEVICE_ID_ARL : -return IVPU_HW_BTRS_MTL ; -case PCI_DEVICE_ID_LNL : -case PCI_DEVICE_ID_PTL_P : -case PCI_DEVICE_ID_WCL : -case PCI_DEVICE_ID_NVL : -return IVPU_HW_BTRS_LNL ; -default : -dump_stack (); -ivpu_err (vdev,"Unknown buttress generation\n" ); -return 0 ; - } +return vdev->btrs_gen; }static inline struct ivpu_device *to_ivpu_device (struct drm_device *dev)drivers/accel/ivpu/ivpu_hw.h +0
-1@@ -49,7 +49,6 @@ struct ivpu_hw_info {u32 tile_fuse;u32 sku;u16 config; -int dma_bits;ktime_t d0i3_entry_host_ts;u64 d0i3_entry_vpu_ts;atomic_t firewall_irq_counter;drivers/accel/ivpu/ivpu_hw_ip.c +5
-7@@ -678,29 +678,21 @@ static void pwr_island_delay_set(struct ivpu_device *vdev)bool high = vdev->hw->pll.profiling_freq ==PLL_PROFILING_FREQ_HIGH ;u32 post, post1, post2, status; -if (ivpu_hw_ip_gen (vdev) <IVPU_HW_IP_50XX ) +switch (ivpu_hw_ip_gen (vdev)) { +case IVPU_HW_IP_37XX : +case IVPU_HW_IP_40XX :return ; - -switch (ivpu_device_id (vdev)) { -case PCI_DEVICE_ID_WCL : -case PCI_DEVICE_ID_PTL_P : +case IVPU_HW_IP_50XX : post = high ?18 :0 ; post1 =0 ; post2 =0 ; status = high ?46 :3 ;break ; - -case PCI_DEVICE_ID_NVL : +default : post = high ?198 :17 ; post1 =0 ; post2 = high ?198 :17 ;
drivers/accel/ivpu/ivpu_hw_ip.c static void pwr_island_delay_set(struct ivpu_device *vdev) · line 698
Quoted 10 lines
drivers/accel/ivpu/ivpu_hw_ip.c +0
-6status =0 ; -break ; - -default : -dump_stack (); -ivpu_err (vdev,"Unknown device ID\n" ); -return ; }pwr_island_delay_set_50xx (vdev, post, post1, post2, status);
Re: [PATCH 1/3] accel/ivpu: Improve HW IP gen and buttress version checks
In reply to Dawid OsuchowskiQuoted 16 lines · Dawid Osuchowski
From: Andrzej Kacprowski <[email protected]>
Remove the per-call switch in ivpu_hw_ip_gen()/ivpu_hw_btrs_gen() and instead initialize the HW IP generation and buttress version once during device init.
Fail probe with
-EINVALwhen the PCI device ID does not match any known generation, instead of warning and continuing with both fields left at 0, so callers never proceed with an unrecognized generation.Drop
hw->dma_bitsand compute it locally to remove the early dependency onvdev->hw_ip_gen.Make
pwr_island_delay_set()useivpu_hw_ip_gen()instead of the PCI device ID directly.
Quoted 6 lines
Move
MODULE_DEVICE_TABLE()to the top of the file to colocate it with the HW IP and buttress detection logic.Signed-off-by Andrzej Kacprowski <[email protected]>Co-developed-by Dawid Osuchowski <[email protected]>Signed-off-by Dawid Osuchowski <[email protected]>
PATCH 2/3 accel/ivpu: Convert hw_ip_gen/btrs_gen to enum types
In reply to Dawid OsuchowskiChange the hw_ip_gen and btrs_gen members of struct ivpu_device, and their accessors, from u32/int to enum vpu_hw_ip/enum vpu_hw_btrs, and drop the default: labels from the switch statements in ivpu_hw_ip.c that dispatch on them. Switching on the real enum types lets the compiler treat these switches as exhaustive at compile time, so a missing case for a new generation now warns instead of silently hitting default:.
This compile-time guarantee holds because ivpu_ip_gen_init() now fails probe on an unrecognized PCI device ID instead of leaving these fields at 0, so the switches never see an unhandled value.
--- drivers/accel/ivpu/ivpu_drv.h | 28 ++++++++++++++++------------ drivers/accel/ivpu/ivpu_hw_ip.c | 14 ++++++++++---- 2 files changed, 26 insertions(+), 16 deletions(-)
drivers/accel/ivpu/ivpu_drv.h +16 -12
@@ -31,17 +31,9 @@#define PCI_DEVICE_ID_WCL 0xfd3e#define PCI_DEVICE_ID_NVL 0xd71d -#define IVPU_HW_IP_37XX 37 -#define IVPU_HW_IP_40XX 40 -#define IVPU_HW_IP_50XX 50 -#define IVPU_HW_IP_60XX 60 -#define IVPU_HW_IP_REV_LNL_B0 4#define IVPU_HW_IP_REV_NVL_A0 0 -#define IVPU_HW_BTRS_MTL 1 -#define IVPU_HW_BTRS_LNL 2 -#define IVPU_GLOBAL_CONTEXT_MMU_SSID 0/* SSID 1 is used by the VPU to represent reserved context */ #define IVPU_RESERVED_CONTEXT_MMU_SSID 1
@@ -107,6 +99,18 @@ ivpu_dbg(vdev, MISC, "Using WA: " #wa_name "\n"); \ } while (0) +enum vpu_hw_ip { +IVPU_HW_IP_37XX =37 , +IVPU_HW_IP_40XX =40 , +IVPU_HW_IP_50XX =50 , +IVPU_HW_IP_60XX =60 , +}; + +enum vpu_hw_btrs { +IVPU_HW_BTRS_MTL =1 , +IVPU_HW_BTRS_LNL =2 , +}; +struct ivpu_wa_table {bool punit_disabled;bool clear_runtime_mem;
@@ -136,8 +140,8 @@ struct ivpu_device {struct drm_device drm;void __iomem *regb;void __iomem *regv; -u32 hw_ip_gen; -u32 btrs_gen; +enum vpu_hw_ip hw_ip_gen; +enum vpu_hw_btrs btrs_gen;u32 platform;u32 irq;
@@ -259,12 +263,12 @@ static inline u16 ivpu_device_id(struct ivpu_device *vdev)return to_pci_dev (vdev->drm.dev)->device; } -static inline int ivpu_hw_ip_gen (struct ivpu_device *vdev) +static inline enum vpu_hw_ip ivpu_hw_ip_gen (struct ivpu_device *vdev) {return vdev->hw_ip_gen; } -static inline int ivpu_hw_btrs_gen (struct ivpu_device *vdev) +static inline enum vpu_hw_btrs ivpu_hw_btrs_gen (struct ivpu_device *vdev) {return vdev->btrs_gen; }
drivers/accel/ivpu/ivpu_hw_ip.c +10 -4
@@ -688,7 +688,7 @@ static void pwr_island_delay_set(struct ivpu_device *vdev) post2 =0 ; status = high ?46 :3 ;break ; -default : +case IVPU_HW_IP_60XX : post = high ?198 :17 ; post1 =0 ; post2 = high ?198 :17 ;
@@ -801,10 +801,15 @@ static void ivpu_hw_ip_tbu_mmu_enable_40xx(struct ivpu_device *vdev)void ivpu_hw_ip_tbu_mmu_enable (struct ivpu_device *vdev) { -if (ivpu_hw_ip_gen (vdev) ==IVPU_HW_IP_37XX ) +switch (ivpu_hw_ip_gen (vdev)) { +case IVPU_HW_IP_37XX :return ivpu_hw_ip_tbu_mmu_enable_37xx (vdev); -else + +case IVPU_HW_IP_40XX : +case IVPU_HW_IP_50XX : +case IVPU_HW_IP_60XX :return ivpu_hw_ip_tbu_mmu_enable_40xx (vdev); + } }static inline u64 get_entry_point_addr (struct ivpu_device *vdev)
@@ -940,8 +945,9 @@ int ivpu_hw_ip_soc_cpu_boot(struct ivpu_device *vdev) ret =soc_cpu_boot_40xx (vdev);break ; -default : +case IVPU_HW_IP_60XX : ret =soc_cpu_boot_60xx (vdev); +break ; }if (ret)
Signature · 1 line
2.43.0
Re: [PATCH 2/3] accel/ivpu: Convert hw_ip_gen/btrs_gen to enum types
Quoted 117 lines · Dawid Osuchowski
Change the
hw_ip_genandbtrs_genmembers of structivpu_device, and their accessors, from u32/int to enum vpu_hw_ip/enumvpu_hw_btrs, and drop the default: labels from the switch statements inivpu_hw_ip.cthat dispatch on them. Switching on the real enum types lets the compiler treat these switches as exhaustive at compile time, so a missing case for a new generation now warns instead of silently hitting default:.This compile-time guarantee holds because
ivpu_ip_gen_init()now fails probe on an unrecognized PCI device ID instead of leaving these fields at 0, so the switches never see an unhandled value.Signed-off-by Dawid Osuchowski <[email protected]>--- drivers/accel/ivpu/ivpu_drv.h | 28 ++++++++++++++++------------ drivers/accel/ivpu/ivpu_hw_ip.c | 14 ++++++++++---- 2 files changed, 26 insertions(+), 16 deletions(-)drivers/accel/ivpu/ivpu_drv.h +16
-12@@ -31,17 +31,9 @@#define PCI_DEVICE_ID_WCL 0xfd3e#define PCI_DEVICE_ID_NVL 0xd71d -#define IVPU_HW_IP_37XX 37 -#define IVPU_HW_IP_40XX 40 -#define IVPU_HW_IP_50XX 50 -#define IVPU_HW_IP_60XX 60 -#define IVPU_HW_IP_REV_LNL_B0 4#define IVPU_HW_IP_REV_NVL_A0 0 -#define IVPU_HW_BTRS_MTL 1 -#define IVPU_HW_BTRS_LNL 2 -#define IVPU_GLOBAL_CONTEXT_MMU_SSID 0/* SSID 1 is used by the VPU to represent reserved context */ #define IVPU_RESERVED_CONTEXT_MMU_SSID 1@@ -107,6 +99,18 @@ ivpu_dbg(vdev, MISC, "Using WA: " #wa_name "\n"); \ } while (0) +enum vpu_hw_ip { +IVPU_HW_IP_37XX =37 , +IVPU_HW_IP_40XX =40 , +IVPU_HW_IP_50XX =50 , +IVPU_HW_IP_60XX =60 , +}; + +enum vpu_hw_btrs { +IVPU_HW_BTRS_MTL =1 , +IVPU_HW_BTRS_LNL =2 , +}; +struct ivpu_wa_table {bool punit_disabled;bool clear_runtime_mem;@@ -136,8 +140,8 @@ struct ivpu_device {struct drm_device drm;void __iomem *regb;void __iomem *regv; -u32 hw_ip_gen; -u32 btrs_gen; +enum vpu_hw_ip hw_ip_gen; +enum vpu_hw_btrs btrs_gen;u32 platform;u32 irq;@@ -259,12 +263,12 @@ static inline u16 ivpu_device_id(struct ivpu_device *vdev)return to_pci_dev (vdev->drm.dev)->device; } -static inline int ivpu_hw_ip_gen (struct ivpu_device *vdev) +static inline enum vpu_hw_ip ivpu_hw_ip_gen (struct ivpu_device *vdev) {return vdev->hw_ip_gen; } -static inline int ivpu_hw_btrs_gen (struct ivpu_device *vdev) +static inline enum vpu_hw_btrs ivpu_hw_btrs_gen (struct ivpu_device *vdev) {return vdev->btrs_gen; }drivers/accel/ivpu/ivpu_hw_ip.c +8
-3@@ -688,7 +688,7 @@ static void pwr_island_delay_set(struct ivpu_device *vdev) post2 =0 ; status = high ?46 :3 ;break ; -default : +case IVPU_HW_IP_60XX : post = high ?198 :17 ; post1 =0 ; post2 = high ?198 :17 ;@@ -801,10 +801,15 @@ static void ivpu_hw_ip_tbu_mmu_enable_40xx(struct ivpu_device *vdev)void ivpu_hw_ip_tbu_mmu_enable (struct ivpu_device *vdev) { -if (ivpu_hw_ip_gen (vdev) ==IVPU_HW_IP_37XX ) +switch (ivpu_hw_ip_gen (vdev)) { +case IVPU_HW_IP_37XX :return ivpu_hw_ip_tbu_mmu_enable_37xx (vdev); -else + +case IVPU_HW_IP_40XX : +case IVPU_HW_IP_50XX : +case IVPU_HW_IP_60XX :return ivpu_hw_ip_tbu_mmu_enable_40xx (vdev); + } }static inline u64 get_entry_point_addr (struct ivpu_device *vdev)
drivers/accel/ivpu/ivpu_hw_ip.c int ivpu_hw_ip_soc_cpu_boot(struct ivpu_device *vdev) · line 953
Quoted 10 lines
drivers/accel/ivpu/ivpu_hw_ip.c +2
-1@@ -940,8 +945,9 @@ int ivpu_hw_ip_soc_cpu_boot(struct ivpu_device *vdev) ret =soc_cpu_boot_40xx (vdev);break ; -default : +case IVPU_HW_IP_60XX : ret =soc_cpu_boot_60xx (vdev); +break ; }if (ret)
Re: [PATCH 2/3] accel/ivpu: Convert hw_ip_gen/btrs_gen to enum types
In reply to Dawid OsuchowskiQuoted 117 lines · Dawid Osuchowski
Change the
hw_ip_genandbtrs_genmembers of structivpu_device, and their accessors, from u32/int to enum vpu_hw_ip/enumvpu_hw_btrs, and drop the default: labels from the switch statements inivpu_hw_ip.cthat dispatch on them. Switching on the real enum types lets the compiler treat these switches as exhaustive at compile time, so a missing case for a new generation now warns instead of silently hitting default:.This compile-time guarantee holds because
ivpu_ip_gen_init()now fails probe on an unrecognized PCI device ID instead of leaving these fields at 0, so the switches never see an unhandled value.Signed-off-by Dawid Osuchowski <[email protected]>--- drivers/accel/ivpu/ivpu_drv.h | 28 ++++++++++++++++------------ drivers/accel/ivpu/ivpu_hw_ip.c | 14 ++++++++++---- 2 files changed, 26 insertions(+), 16 deletions(-)drivers/accel/ivpu/ivpu_drv.h +16
-12@@ -31,17 +31,9 @@#define PCI_DEVICE_ID_WCL 0xfd3e#define PCI_DEVICE_ID_NVL 0xd71d -#define IVPU_HW_IP_37XX 37 -#define IVPU_HW_IP_40XX 40 -#define IVPU_HW_IP_50XX 50 -#define IVPU_HW_IP_60XX 60 -#define IVPU_HW_IP_REV_LNL_B0 4#define IVPU_HW_IP_REV_NVL_A0 0 -#define IVPU_HW_BTRS_MTL 1 -#define IVPU_HW_BTRS_LNL 2 -#define IVPU_GLOBAL_CONTEXT_MMU_SSID 0/* SSID 1 is used by the VPU to represent reserved context */ #define IVPU_RESERVED_CONTEXT_MMU_SSID 1@@ -107,6 +99,18 @@ ivpu_dbg(vdev, MISC, "Using WA: " #wa_name "\n"); \ } while (0) +enum vpu_hw_ip { +IVPU_HW_IP_37XX =37 , +IVPU_HW_IP_40XX =40 , +IVPU_HW_IP_50XX =50 , +IVPU_HW_IP_60XX =60 , +}; + +enum vpu_hw_btrs { +IVPU_HW_BTRS_MTL =1 , +IVPU_HW_BTRS_LNL =2 , +}; +struct ivpu_wa_table {bool punit_disabled;bool clear_runtime_mem;@@ -136,8 +140,8 @@ struct ivpu_device {struct drm_device drm;void __iomem *regb;void __iomem *regv; -u32 hw_ip_gen; -u32 btrs_gen; +enum vpu_hw_ip hw_ip_gen; +enum vpu_hw_btrs btrs_gen;u32 platform;u32 irq;@@ -259,12 +263,12 @@ static inline u16 ivpu_device_id(struct ivpu_device *vdev)return to_pci_dev (vdev->drm.dev)->device; } -static inline int ivpu_hw_ip_gen (struct ivpu_device *vdev) +static inline enum vpu_hw_ip ivpu_hw_ip_gen (struct ivpu_device *vdev) {return vdev->hw_ip_gen; } -static inline int ivpu_hw_btrs_gen (struct ivpu_device *vdev) +static inline enum vpu_hw_btrs ivpu_hw_btrs_gen (struct ivpu_device *vdev) {return vdev->btrs_gen; }drivers/accel/ivpu/ivpu_hw_ip.c +8
-3@@ -688,7 +688,7 @@ static void pwr_island_delay_set(struct ivpu_device *vdev) post2 =0 ; status = high ?46 :3 ;break ; -default : +case IVPU_HW_IP_60XX : post = high ?198 :17 ; post1 =0 ; post2 = high ?198 :17 ;@@ -801,10 +801,15 @@ static void ivpu_hw_ip_tbu_mmu_enable_40xx(struct ivpu_device *vdev)void ivpu_hw_ip_tbu_mmu_enable (struct ivpu_device *vdev) { -if (ivpu_hw_ip_gen (vdev) ==IVPU_HW_IP_37XX ) +switch (ivpu_hw_ip_gen (vdev)) { +case IVPU_HW_IP_37XX :return ivpu_hw_ip_tbu_mmu_enable_37xx (vdev); -else + +case IVPU_HW_IP_40XX : +case IVPU_HW_IP_50XX : +case IVPU_HW_IP_60XX :return ivpu_hw_ip_tbu_mmu_enable_40xx (vdev); + } }static inline u64 get_entry_point_addr (struct ivpu_device *vdev)
drivers/accel/ivpu/ivpu_hw_ip.c int ivpu_hw_ip_soc_cpu_boot(struct ivpu_device *vdev) · line 953
Quoted 10 lines
drivers/accel/ivpu/ivpu_hw_ip.c +2
-1@@ -940,8 +945,9 @@ int ivpu_hw_ip_soc_cpu_boot(struct ivpu_device *vdev) ret =soc_cpu_boot_40xx (vdev);break ; -default : +case IVPU_HW_IP_60XX : ret =soc_cpu_boot_60xx (vdev); +break ; }if (ret)
Re: [PATCH 2/3] accel/ivpu: Convert hw_ip_gen/btrs_gen to enum types
In reply to Dawid OsuchowskiQuoted 8 lines · Dawid Osuchowski
Change the
hw_ip_genandbtrs_genmembers of structivpu_device, and their accessors, from u32/int to enum vpu_hw_ip/enumvpu_hw_btrs, and drop the default: labels from the switch statements inivpu_hw_ip.cthat dispatch on them. Switching on the real enum types lets the compiler treat these switches as exhaustive at compile time, so a missing case for a new generation now warns instead of silently hitting default:.
Quoted 5 lines
This compile-time guarantee holds because
ivpu_ip_gen_init()now fails probe on an unrecognized PCI device ID instead of leaving these fields at 0, so the switches never see an unhandled value.Signed-off-by Dawid Osuchowski <[email protected]>
PATCH 3/3 accel/ivpu: Split HW IP generation dispatch into helpers
In reply to Dawid OsuchowskiFrom: Karol Wachowski <[email protected]>
ivpu_hw_ip_soc_cpu_boot() and pwr_island_delay_set() keep the result of their per-generation switch in locals that are left uninitialized on the path past the last case. Building with -Wmaybe-uninitialized reports ret, post, post2 and status; Kbuild disables that warning for GCC, so it does not show up in a normal build.
Let every case return directly instead, so no local is needed. ivpu_hw_ip_soc_cpu_boot() now dispatches on its own, with the debug message moved ahead of the switch so that the boot mode is logged before the boot registers are written, and the power island delay values move into per-generation helpers. Neither switch has a default: label, so -Wswitch reports any enum vpu_hw_ip value added later that is not handled, and the path past the switch returns -EINVAL.
Build the power island delay values from zero instead of reading the registers first. POST_DLY, POST1_DLY and POST2_DLY together span every writable bit of PWR_ISLAND_EN_POST_DLY, and STATUS_DLY spans every writable bit of PWR_ISLAND_STATUS_DLY, so the read-modify-write only fetched bits that are immediately overwritten.
The boot mode is now logged even when the boot fails; no other functional changes.
--- drivers/accel/ivpu/ivpu_hw_ip.c | 64 ++++++++++++++++----------------- 1 file changed, 31 insertions(+), 33 deletions(-)
drivers/accel/ivpu/ivpu_hw_ip.c +31 -33
@@ -265,21 +265,35 @@ void ivpu_hw_ip_idle_gen_disable(struct ivpu_device *vdev) }static void -pwr_island_delay_set_50xx (struct ivpu_device *vdev,u32 post,u32 post1,u32 post2,u32 status) +pwr_island_delay_write (struct ivpu_device *vdev,u32 post,u32 post1,u32 post2,u32 status) {u32 val; - val =REGV_RD32 (VPU_50XX_HOST_SS_AON_PWR_ISLAND_EN_POST_DLY ); - val =REG_SET_FLD_NUM (VPU_50XX_HOST_SS_AON_PWR_ISLAND_EN_POST_DLY ,POST_DLY , post, val); + val =REG_SET_FLD_NUM (VPU_50XX_HOST_SS_AON_PWR_ISLAND_EN_POST_DLY ,POST_DLY , post,0 ); val =REG_SET_FLD_NUM (VPU_50XX_HOST_SS_AON_PWR_ISLAND_EN_POST_DLY ,POST1_DLY , post1, val); val =REG_SET_FLD_NUM (VPU_50XX_HOST_SS_AON_PWR_ISLAND_EN_POST_DLY ,POST2_DLY , post2, val);REGV_WR32 (VPU_50XX_HOST_SS_AON_PWR_ISLAND_EN_POST_DLY , val); - val =REGV_RD32 (VPU_50XX_HOST_SS_AON_PWR_ISLAND_STATUS_DLY ); - val =REG_SET_FLD_NUM (VPU_50XX_HOST_SS_AON_PWR_ISLAND_STATUS_DLY ,STATUS_DLY , status, val); + val =REG_SET_FLD_NUM (VPU_50XX_HOST_SS_AON_PWR_ISLAND_STATUS_DLY ,STATUS_DLY , status,0 );REGV_WR32 (VPU_50XX_HOST_SS_AON_PWR_ISLAND_STATUS_DLY , val); } +static void pwr_island_delay_set_50xx (struct ivpu_device *vdev) +{ +if (vdev->hw->pll.profiling_freq ==PLL_PROFILING_FREQ_HIGH ) +pwr_island_delay_write (vdev,18 ,0 ,0 ,46 ); +else +pwr_island_delay_write (vdev,0 ,0 ,0 ,3 ); +} + +static void pwr_island_delay_set_60xx (struct ivpu_device *vdev) +{ +if (vdev->hw->pll.profiling_freq ==PLL_PROFILING_FREQ_HIGH ) +pwr_island_delay_write (vdev,198 ,0 ,198 ,0 ); +else +pwr_island_delay_write (vdev,17 ,0 ,17 ,0 ); +} +static void pwr_island_trickle_drive_37xx (struct ivpu_device *vdev,bool enable) {u32 val =REGV_RD32 (VPU_37XX_HOST_SS_AON_PWR_ISLAND_TRICKLE_EN0 );
@@ -675,27 +689,19 @@ static void dpu_active_drive_37xx(struct ivpu_device *vdev, bool enable)static void pwr_island_delay_set (struct ivpu_device *vdev) { -bool high = vdev->hw->pll.profiling_freq ==PLL_PROFILING_FREQ_HIGH ; -u32 post, post1, post2, status; -switch (ivpu_hw_ip_gen (vdev)) {case IVPU_HW_IP_37XX :case IVPU_HW_IP_40XX :return ; +case IVPU_HW_IP_50XX : - post = high ?18 :0 ; - post1 =0 ; - post2 =0 ; - status = high ?46 :3 ; -break ; +pwr_island_delay_set_50xx (vdev); +return ; +case IVPU_HW_IP_60XX : - post = high ?198 :17 ; - post1 =0 ; - post2 = high ?198 :17 ; - status =0 ; +pwr_island_delay_set_60xx (vdev); +return ; } - -pwr_island_delay_set_50xx (vdev, post, post1, post2, status); }int ivpu_hw_ip_pwr_domain_enable (struct ivpu_device *vdev)
@@ -933,30 +939,22 @@ static int soc_cpu_boot_60xx(struct ivpu_device *vdev)int ivpu_hw_ip_soc_cpu_boot (struct ivpu_device *vdev) { -int ret; +ivpu_dbg (vdev,PM ,"Booting firmware, mode: %s\n" , +ivpu_fw_is_warm_boot (vdev) ?"warm boot" :"cold boot" );switch (ivpu_hw_ip_gen (vdev)) {case IVPU_HW_IP_37XX : - ret =soc_cpu_boot_37xx (vdev); -break ; +return soc_cpu_boot_37xx (vdev);case IVPU_HW_IP_40XX :case IVPU_HW_IP_50XX : - ret =soc_cpu_boot_40xx (vdev); -break ; +return soc_cpu_boot_40xx (vdev);case IVPU_HW_IP_60XX : - ret =soc_cpu_boot_60xx (vdev); -break ; +return soc_cpu_boot_60xx (vdev); } -if (ret) -return ret; - -ivpu_dbg (vdev,PM ,"Booting firmware, mode: %s\n" , -ivpu_fw_is_warm_boot (vdev) ?"warm boot" :"cold boot" ); - -return 0 ; +return -EINVAL ; }static void wdt_disable_37xx (struct ivpu_device *vdev)
Signature · 1 line
2.43.0
Re: [PATCH 3/3] accel/ivpu: Split HW IP generation dispatch into helpers
Quoted 137 lines · Dawid Osuchowski
From: Karol Wachowski <[email protected]>
ivpu_hw_ip_soc_cpu_boot()andpwr_island_delay_set()keep the result of their per-generation switch in locals that are left uninitialized on the path past the last case. Building with -Wmaybe-uninitialized reports ret, post, post2 and status;Kbuilddisables that warning for GCC, so it does not show up in a normal build.Let every case return directly instead, so no local is needed.
ivpu_hw_ip_soc_cpu_boot()now dispatches on its own, with the debug message moved ahead of the switch so that the boot mode is logged before the boot registers are written, and the power island delay values move into per-generation helpers. Neither switch has a default: label, so -Wswitch reports any enumvpu_hw_ipvalue added later that is not handled, and the path past the switch returns-EINVAL.Build the power island delay values from zero instead of reading the registers first.
POST_DLY,POST1_DLYandPOST2_DLYtogether span every writable bit ofPWR_ISLAND_EN_POST_DLY, andSTATUS_DLYspans every writable bit ofPWR_ISLAND_STATUS_DLY, so the read-modify-write only fetched bits that are immediately overwritten.The boot mode is now logged even when the boot fails; no other functional changes.
Signed-off-by Karol Wachowski <[email protected]>Signed-off-by Dawid Osuchowski <[email protected]>--- drivers/accel/ivpu/ivpu_hw_ip.c | 64 ++++++++++++++++----------------- 1 file changed, 31 insertions(+), 33 deletions(-)drivers/accel/ivpu/ivpu_hw_ip.c +30
-27@@ -265,21 +265,35 @@ void ivpu_hw_ip_idle_gen_disable(struct ivpu_device *vdev) }static void -pwr_island_delay_set_50xx (struct ivpu_device *vdev,u32 post,u32 post1,u32 post2,u32 status) +pwr_island_delay_write (struct ivpu_device *vdev,u32 post,u32 post1,u32 post2,u32 status) {u32 val; - val =REGV_RD32 (VPU_50XX_HOST_SS_AON_PWR_ISLAND_EN_POST_DLY ); - val =REG_SET_FLD_NUM (VPU_50XX_HOST_SS_AON_PWR_ISLAND_EN_POST_DLY ,POST_DLY , post, val); + val =REG_SET_FLD_NUM (VPU_50XX_HOST_SS_AON_PWR_ISLAND_EN_POST_DLY ,POST_DLY , post,0 ); val =REG_SET_FLD_NUM (VPU_50XX_HOST_SS_AON_PWR_ISLAND_EN_POST_DLY ,POST1_DLY , post1, val); val =REG_SET_FLD_NUM (VPU_50XX_HOST_SS_AON_PWR_ISLAND_EN_POST_DLY ,POST2_DLY , post2, val);REGV_WR32 (VPU_50XX_HOST_SS_AON_PWR_ISLAND_EN_POST_DLY , val); - val =REGV_RD32 (VPU_50XX_HOST_SS_AON_PWR_ISLAND_STATUS_DLY ); - val =REG_SET_FLD_NUM (VPU_50XX_HOST_SS_AON_PWR_ISLAND_STATUS_DLY ,STATUS_DLY , status, val); + val =REG_SET_FLD_NUM (VPU_50XX_HOST_SS_AON_PWR_ISLAND_STATUS_DLY ,STATUS_DLY , status,0 );REGV_WR32 (VPU_50XX_HOST_SS_AON_PWR_ISLAND_STATUS_DLY , val); } +static void pwr_island_delay_set_50xx (struct ivpu_device *vdev) +{ +if (vdev->hw->pll.profiling_freq ==PLL_PROFILING_FREQ_HIGH ) +pwr_island_delay_write (vdev,18 ,0 ,0 ,46 ); +else +pwr_island_delay_write (vdev,0 ,0 ,0 ,3 ); +} + +static void pwr_island_delay_set_60xx (struct ivpu_device *vdev) +{ +if (vdev->hw->pll.profiling_freq ==PLL_PROFILING_FREQ_HIGH ) +pwr_island_delay_write (vdev,198 ,0 ,198 ,0 ); +else +pwr_island_delay_write (vdev,17 ,0 ,17 ,0 ); +} +static void pwr_island_trickle_drive_37xx (struct ivpu_device *vdev,bool enable) {u32 val =REGV_RD32 (VPU_37XX_HOST_SS_AON_PWR_ISLAND_TRICKLE_EN0 );@@ -675,27 +689,19 @@ static void dpu_active_drive_37xx(struct ivpu_device *vdev, bool enable)static void pwr_island_delay_set (struct ivpu_device *vdev) { -bool high = vdev->hw->pll.profiling_freq ==PLL_PROFILING_FREQ_HIGH ; -u32 post, post1, post2, status; -switch (ivpu_hw_ip_gen (vdev)) {case IVPU_HW_IP_37XX :case IVPU_HW_IP_40XX :return ; +case IVPU_HW_IP_50XX : - post = high ?18 :0 ; - post1 =0 ; - post2 =0 ; - status = high ?46 :3 ; -break ; +pwr_island_delay_set_50xx (vdev); +return ; +case IVPU_HW_IP_60XX : - post = high ?198 :17 ; - post1 =0 ; - post2 = high ?198 :17 ; - status =0 ; +pwr_island_delay_set_60xx (vdev); +return ; } - -pwr_island_delay_set_50xx (vdev, post, post1, post2, status); }int ivpu_hw_ip_pwr_domain_enable (struct ivpu_device *vdev)@@ -933,30 +939,22 @@ static int soc_cpu_boot_60xx(struct ivpu_device *vdev)int ivpu_hw_ip_soc_cpu_boot (struct ivpu_device *vdev) { -int ret; +ivpu_dbg (vdev,PM ,"Booting firmware, mode: %s\n" , +ivpu_fw_is_warm_boot (vdev) ?"warm boot" :"cold boot" );switch (ivpu_hw_ip_gen (vdev)) {case IVPU_HW_IP_37XX : - ret =soc_cpu_boot_37xx (vdev); -break ; +return soc_cpu_boot_37xx (vdev);case IVPU_HW_IP_40XX :case IVPU_HW_IP_50XX : - ret =soc_cpu_boot_40xx (vdev); -break ; +return soc_cpu_boot_40xx (vdev);case IVPU_HW_IP_60XX : - ret =soc_cpu_boot_60xx (vdev); -break ; +return soc_cpu_boot_60xx (vdev); } -if (ret)
drivers/accel/ivpu/ivpu_hw_ip.c static int soc_cpu_boot_60xx(struct ivpu_device *vdev) · line 960
Quoted 10 lines
drivers/accel/ivpu/ivpu_hw_ip.c +1
-6-return ret; - -ivpu_dbg (vdev,PM ,"Booting firmware, mode: %s\n" , -ivpu_fw_is_warm_boot (vdev) ?"warm boot" :"cold boot" ); - -return 0 ; +return -EINVAL ; }static void wdt_disable_37xx (struct ivpu_device *vdev)
Re: [PATCH 3/3] accel/ivpu: Split HW IP generation dispatch into helpers
In reply to Dawid OsuchowskiQuoted 22 lines · Dawid Osuchowski
From: Karol Wachowski <[email protected]>
ivpu_hw_ip_soc_cpu_boot()andpwr_island_delay_set()keep the result of their per-generation switch in locals that are left uninitialized on the path past the last case. Building with -Wmaybe-uninitialized reports ret, post, post2 and status;Kbuilddisables that warning for GCC, so it does not show up in a normal build.Let every case return directly instead, so no local is needed.
ivpu_hw_ip_soc_cpu_boot()now dispatches on its own, with the debug message moved ahead of the switch so that the boot mode is logged before the boot registers are written, and the power island delay values move into per-generation helpers. Neither switch has a default: label, so -Wswitch reports any enumvpu_hw_ipvalue added later that is not handled, and the path past the switch returns-EINVAL.Build the power island delay values from zero instead of reading the registers first.
POST_DLY,POST1_DLYandPOST2_DLYtogether span every writable bit ofPWR_ISLAND_EN_POST_DLY, andSTATUS_DLYspans every writable bit ofPWR_ISLAND_STATUS_DLY, so the read-modify-write only fetched bits that are immediately overwritten.
Quoted 5 lines
The boot mode is now logged even when the boot fails; no other functional changes.
Signed-off-by Karol Wachowski <[email protected]>Signed-off-by Dawid Osuchowski <[email protected]>
Quoted 28 lines · Dawid Osuchowski
This series reworks how the driver determines the HW IP generation and buttress version, and how it dispatches on them.
Today
ivpu_hw_ip_gen()andivpu_hw_btrs_gen()run a switch over the PCI device ID on every call, and an unknown ID only triggers aWARN()while probe continues with an undefined generation. Patch 1 resolves both values once during device init and fails probe with-EINVALon an unrecognized device ID.With that guarantee in place, patch 2 changes the stored values and their accessors to the real enum types and drops the default: labels from the switches that dispatch on them, so -Wswitch flags a generation that is added later but not handled.
Patch 3 splits the remaining per-generation dispatch in
ivpu_hw_ip_soc_cpu_boot()andpwr_island_delay_set()into helpers that return directly from each case, removing the locals that were left uninitialized on the path past the last case.No functional change is intended beyond failing probe on an unknown PCI device ID and logging the SOC CPU boot mode even when the boot fails.
Andrzej Kacprowski (1):
accel/ivpu: Improve HW IP gen and buttress version checksDawid Osuchowski (1):
accel/ivpu: Convert hw_ip_gen/btrs_gen to enum types
Quoted 9 lines
Karol Wachowski (1):
accel/ivpu: Split HW IP generation dispatch into helpersdrivers/accel/ivpu/ivpu_drv.c | 69 +++++++++++++++++++------- drivers/accel/ivpu/ivpu_drv.h | 65 +++++++++---------------- drivers/accel/ivpu/ivpu_hw.h | 1 - drivers/accel/ivpu/ivpu_hw_ip.c | 86 ++++++++++++++++----------------- 4 files changed, 117 insertions(+), 104 deletions(-)
Applied to drm-misc-next.