Re: [PATCH 2/6] accel/ivpu: Use generation based function and registers names

2023-08-02 Thread Jeffrey Hugo

On 7/31/2023 10:12 AM, Stanislaw Gruszka wrote:

From: Jacek Lawrynowicz 

Given that VPU generation can be used by multiple platforms, driver should
use VPU IP generation names instead of a platform names.

Change naming for functions and registries.

Use 37XX format, where:
   3 - major VPU IP generation version
   7 - minor VPU IP generation version
   XX - postfix indicating this is a architecture and not marketing name

Signed-off-by: Jacek Lawrynowicz 
Reviewed-by: Stanislaw Gruszka 
Signed-off-by: Stanislaw Gruszka 


Same nits from patch 1 apply here

Reviewed-by: Jeffrey Hugo 


[PATCH 2/6] accel/ivpu: Use generation based function and registers names

2023-07-31 Thread Stanislaw Gruszka
From: Jacek Lawrynowicz 

Given that VPU generation can be used by multiple platforms, driver should
use VPU IP generation names instead of a platform names.

Change naming for functions and registries.

Use 37XX format, where:
  3 - major VPU IP generation version
  7 - minor VPU IP generation version
  XX - postfix indicating this is a architecture and not marketing name

Signed-off-by: Jacek Lawrynowicz 
Reviewed-by: Stanislaw Gruszka 
Signed-off-by: Stanislaw Gruszka 
---
 drivers/accel/ivpu/ivpu_drv.c |   6 +-
 drivers/accel/ivpu/ivpu_drv.h |  18 +-
 drivers/accel/ivpu/ivpu_hw.h  |   2 +-
 drivers/accel/ivpu/ivpu_hw_37xx.c | 476 +-
 drivers/accel/ivpu/ivpu_hw_37xx_reg.h | 392 ++---
 drivers/accel/ivpu/ivpu_mmu.c |  82 ++---
 6 files changed, 492 insertions(+), 484 deletions(-)

diff --git a/drivers/accel/ivpu/ivpu_drv.c b/drivers/accel/ivpu/ivpu_drv.c
index 815dd9b588e9..fad607dbb2c6 100644
--- a/drivers/accel/ivpu/ivpu_drv.c
+++ b/drivers/accel/ivpu/ivpu_drv.c
@@ -443,8 +443,8 @@ static int ivpu_pci_init(struct ivpu_device *vdev)
/* Clear any pending errors */
pcie_capability_clear_word(pdev, PCI_EXP_DEVSTA, 0x3f);
 
-   /* VPU MTL does not require PCI spec 10m D3hot delay */
-   if (ivpu_is_mtl(vdev))
+   /* VPU 37XX does not require 10m D3hot delay */
+   if (ivpu_hw_gen(vdev) == IVPU_HW_37XX)
pdev->d3hot_delay = 0;
 
ret = pcim_enable_device(pdev);
@@ -482,7 +482,7 @@ static int ivpu_dev_init(struct ivpu_device *vdev)
if (!vdev->pm)
return -ENOMEM;
 
-   vdev->hw->ops = &ivpu_hw_mtl_ops;
+   vdev->hw->ops = &ivpu_hw_37xx_ops;
vdev->hw->dma_bits = 38;
 
vdev->platform = IVPU_PLATFORM_INVALID;
diff --git a/drivers/accel/ivpu/ivpu_drv.h b/drivers/accel/ivpu/ivpu_drv.h
index 8fe8cda2e39d..5808a4e6bb6d 100644
--- a/drivers/accel/ivpu/ivpu_drv.h
+++ b/drivers/accel/ivpu/ivpu_drv.h
@@ -24,6 +24,8 @@
 
 #define PCI_DEVICE_ID_MTL   0x7d1d
 
+#define IVPU_HW_37XX   37
+
 #define IVPU_GLOBAL_CONTEXT_MMU_SSID 0
 /* SSID 1 is used by the VPU to represent invalid context */
 #define IVPU_USER_CONTEXT_MIN_SSID   2
@@ -146,11 +148,6 @@ void ivpu_file_priv_put(struct ivpu_file_priv **link);
 int ivpu_boot(struct ivpu_device *vdev);
 int ivpu_shutdown(struct ivpu_device *vdev);
 
-static inline bool ivpu_is_mtl(struct ivpu_device *vdev)
-{
-   return to_pci_dev(vdev->drm.dev)->device == PCI_DEVICE_ID_MTL;
-}
-
 static inline u8 ivpu_revision(struct ivpu_device *vdev)
 {
return to_pci_dev(vdev->drm.dev)->revision;
@@ -161,6 +158,17 @@ static inline u16 ivpu_device_id(struct ivpu_device *vdev)
return to_pci_dev(vdev->drm.dev)->device;
 }
 
+static inline int ivpu_hw_gen(struct ivpu_device *vdev)
+{
+   switch (ivpu_device_id(vdev)) {
+   case PCI_DEVICE_ID_MTL:
+   return IVPU_HW_37XX;
+   default:
+   ivpu_err(vdev, "Unknown VPU device\n");
+   return 0;
+   }
+}
+
 static inline struct ivpu_device *to_ivpu_device(struct drm_device *dev)
 {
return container_of(dev, struct ivpu_device, drm);
diff --git a/drivers/accel/ivpu/ivpu_hw.h b/drivers/accel/ivpu/ivpu_hw.h
index 0393901be492..335b7f707752 100644
--- a/drivers/accel/ivpu/ivpu_hw.h
+++ b/drivers/accel/ivpu/ivpu_hw.h
@@ -60,7 +60,7 @@ struct ivpu_hw_info {
int dma_bits;
 };
 
-extern const struct ivpu_hw_ops ivpu_hw_mtl_ops;
+extern const struct ivpu_hw_ops ivpu_hw_37xx_ops;
 
 static inline int ivpu_hw_info_init(struct ivpu_device *vdev)
 {
diff --git a/drivers/accel/ivpu/ivpu_hw_37xx.c 
b/drivers/accel/ivpu/ivpu_hw_37xx.c
index 495be81840ac..2cda8e4c4a3d 100644
--- a/drivers/accel/ivpu/ivpu_hw_37xx.c
+++ b/drivers/accel/ivpu/ivpu_hw_37xx.c
@@ -39,34 +39,34 @@
 #define PLL_TIMEOUT_US  (1500 * USEC_PER_MSEC)
 #define IDLE_TIMEOUT_US (500 * USEC_PER_MSEC)
 
-#define ICB_0_IRQ_MASK ((REG_FLD(MTL_VPU_HOST_SS_ICB_STATUS_0, 
HOST_IPC_FIFO_INT)) | \
-   (REG_FLD(MTL_VPU_HOST_SS_ICB_STATUS_0, MMU_IRQ_0_INT)) 
| \
-   (REG_FLD(MTL_VPU_HOST_SS_ICB_STATUS_0, MMU_IRQ_1_INT)) 
| \
-   (REG_FLD(MTL_VPU_HOST_SS_ICB_STATUS_0, MMU_IRQ_2_INT)) 
| \
-   (REG_FLD(MTL_VPU_HOST_SS_ICB_STATUS_0, 
NOC_FIREWALL_INT)) | \
-   (REG_FLD(MTL_VPU_HOST_SS_ICB_STATUS_0, 
CPU_INT_REDIRECT_0_INT)) | \
-   (REG_FLD(MTL_VPU_HOST_SS_ICB_STATUS_0, 
CPU_INT_REDIRECT_1_INT)))
-
-#define ICB_1_IRQ_MASK ((REG_FLD(MTL_VPU_HOST_SS_ICB_STATUS_1, 
CPU_INT_REDIRECT_2_INT)) | \
-   (REG_FLD(MTL_VPU_HOST_SS_ICB_STATUS_1, 
CPU_INT_REDIRECT_3_INT)) | \
-   (REG_FLD(MTL_VPU_HOST_SS_ICB_STATUS_1, 
CPU_INT_REDIRECT_4_INT)))
+#define ICB_0_IRQ_MASK ((REG_FLD(VPU_37XX_HOST_SS_ICB_STATUS_0, 
HOST_IPC_FIFO_INT)) | \
+   (REG_FLD(VPU_37XX_HOST_SS_IC