Skip to contentSkip to conversation

Add support for ISP interrupts and disable prefetch

PATCH In review Pratap Nirujogi 2 participants 5 messages May 21, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Add support for ISP interrupts and disable prefetch

Add support for ISP interrupts and disable MMHUB prefetch for ISP v4.1.1

Pratap Nirujogi (3):
drm/amd/amdgpu: Map ISP interrupts as generic IRQs drm/amd/amdgpu: Add ISP4.1.0 and ISP4.1.1 modules drm/amd/amdgpu: Disable MMHUB prefetch for ISP v4.1.1

 drivers/gpu/drm/amd/amdgpu/Makefile           |   5 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c |   4 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c       |   3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_isp.c       | 144 +++++------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_isp.h       |  13 +-
 drivers/gpu/drm/amd/amdgpu/ih_v6_1.c          |   6 +
 drivers/gpu/drm/amd/amdgpu/isp_v4_1_0.c       | 149 ++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/isp_v4_1_0.h       |  46 ++++++
 drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c       | 149 ++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.h       |  46 ++++++
 .../amd/include/ivsrcid/isp/irqsrcs_isp_4_1.h |  62 ++++++++
 11 files changed, 517 insertions(+), 110 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/isp_v4_1_0.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/isp_v4_1_0.h
 create mode 100644 drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.h
 create mode 100644 drivers/gpu/drm/amd/include/ivsrcid/isp/irqsrcs_isp_4_1.h
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/3 drm/amd/amdgpu: Map ISP interrupts as generic IRQs

Map ISP IH interrupts to Linux generic IRQ for ISP driver to handle the interrupts using MFD IORESOURCE_IRQ resource.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c       |  3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_isp.c       | 31 ++++++++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_isp.h       |  2 +
 drivers/gpu/drm/amd/amdgpu/ih_v6_1.c          |  6 ++
 .../amd/include/ivsrcid/isp/irqsrcs_isp_4_1.h | 62 +++++++++++++++++++
 5 files changed, 99 insertions(+), 5 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/include/ivsrcid/isp/irqsrcs_isp_4_1.h
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +2 -1
index 665c63f55278..46fe85d3ed71 100644
@@ -466,7 +466,8 @@ void amdgpu_irq_dispatch(struct amdgpu_device *adev,
 	} else	if (src_id >= AMDGPU_MAX_IRQ_SRC_ID) {
 		DRM_DEBUG("Invalid src_id in IV: %d\n", src_id);
 
-	} else if ((client_id == AMDGPU_IRQ_CLIENTID_LEGACY) &&
+	} else if (((client_id == AMDGPU_IRQ_CLIENTID_LEGACY) ||
+		    (client_id == SOC15_IH_CLIENTID_ISP)) &&
 		   adev->irq.virq[src_id]) {
 		generic_handle_domain_irq(adev->irq.domain, src_id);
 
drivers/gpu/drm/amd/amdgpu/amdgpu_isp.c +27 -4
index 25e88661ac60..52e53d2b8748 100644
@@ -31,6 +31,8 @@
 #include "amdgpu.h"
 #include "amdgpu_isp.h"
 
+#include "ivsrcid/isp/irqsrcs_isp_4_1.h"
+
 #define mmDAGB0_WRCLI5_V4_1	0x6811C
 #define mmDAGB0_WRCLI9_V4_1	0x6812C
 #define mmDAGB0_WRCLI10_V4_1	0x68130
@@ -38,6 +40,17 @@
 #define mmDAGB0_WRCLI19_V4_1	0x68154
 #define mmDAGB0_WRCLI20_V4_1	0x68158
 
+static const unsigned int isp_int_srcid[MAX_ISP_INT_SRC] = {
+	ISP_4_1__SRCID__ISP_RINGBUFFER_WPT9,
+	ISP_4_1__SRCID__ISP_RINGBUFFER_WPT10,
+	ISP_4_1__SRCID__ISP_RINGBUFFER_WPT11,
+	ISP_4_1__SRCID__ISP_RINGBUFFER_WPT12,
+	ISP_4_1__SRCID__ISP_RINGBUFFER_WPT13,
+	ISP_4_1__SRCID__ISP_RINGBUFFER_WPT14,
+	ISP_4_1__SRCID__ISP_RINGBUFFER_WPT15,
+	ISP_4_1__SRCID__ISP_RINGBUFFER_WPT16
+};
+
 static int isp_sw_init(void *handle)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
@@ -69,11 +82,12 @@ static int isp_sw_fini(void *handle)
  */
 static int isp_hw_init(void *handle)
 {
-	int r;
-	u64 isp_base;
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 	const struct amdgpu_ip_block *ip_block =
 		amdgpu_device_ip_get_ip_block(adev, AMD_IP_BLOCK_TYPE_ISP);
+	u64 isp_base;
+	int int_idx;
+	int r;
 
 	if (!ip_block)
 		return -EINVAL;
@@ -90,7 +104,7 @@ static int isp_hw_init(void *handle)
 		goto failure;
 	}
 
-	adev->isp.isp_res = kcalloc(1, sizeof(struct resource), GFP_KERNEL);
+	adev->isp.isp_res = kcalloc(9, sizeof(struct resource), GFP_KERNEL);
 	if (!adev->isp.isp_res) {
 		r = -ENOMEM;
 		DRM_ERROR("%s: isp mfd res alloc failed\n", __func__);
@@ -114,8 +128,17 @@ static int isp_hw_init(void *handle)
 	adev->isp.isp_res[0].start = isp_base;
 	adev->isp.isp_res[0].end = isp_base + ISP_REGS_OFFSET_END;
 
+	for (int_idx = 0; int_idx < MAX_ISP_INT_SRC; int_idx++) {
+		adev->isp.isp_res[int_idx + 1].name = "isp_irq";
+		adev->isp.isp_res[int_idx + 1].flags = IORESOURCE_IRQ;
+		adev->isp.isp_res[int_idx + 1].start =
+			amdgpu_irq_create_mapping(adev, isp_int_srcid[int_idx]);
+		adev->isp.isp_res[int_idx + 1].end =
+			adev->isp.isp_res[int_idx + 1].start;
+	}
+
 	adev->isp.isp_cell[0].name = "amd_isp_capture";
-	adev->isp.isp_cell[0].num_resources = 1;
+	adev->isp.isp_cell[0].num_resources = 9;
 	adev->isp.isp_cell[0].resources = &adev->isp.isp_res[0];
 	adev->isp.isp_cell[0].platform_data = adev->isp.isp_pdata;
 	adev->isp.isp_cell[0].pdata_size = sizeof(struct isp_platform_data);
drivers/gpu/drm/amd/amdgpu/amdgpu_isp.h +2 -0
index a11ec0543b93..764d70beb9e9 100644
@@ -30,6 +30,8 @@
 
 #define ISP_REGS_OFFSET_END 0x629A4
 
+#define MAX_ISP_INT_SRC 8
+
 struct isp_platform_data {
 	void *adev;
 	u32 asic_type;
drivers/gpu/drm/amd/amdgpu/ih_v6_1.c +6 -0
index 0fbf5fa7b0f8..2e0469feca1e 100644
@@ -535,6 +535,12 @@ static void ih_v6_1_set_self_irq_funcs(struct amdgpu_device *adev)
 static int ih_v6_1_early_init(void *handle)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+	int ret;
+
+	ret = amdgpu_irq_add_domain(adev);
+	if (ret) {
+		return ret;
+	}
 
 	ih_v6_1_set_interrupt_funcs(adev);
 	ih_v6_1_set_self_irq_funcs(adev);
drivers/gpu/drm/amd/include/ivsrcid/isp/irqsrcs_isp_4_1.h new file +62 -0

62 lines not on this page · raw message

Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/3 drm/amd/amdgpu: Add ISP4.1.0 and ISP4.1.1 modules

In reply to Pratap Nirujogi

Add independent IP centric modules for ISP4.1.0 and ISP4.1.1 hw blocks.

---
 drivers/gpu/drm/amd/amdgpu/Makefile           |   5 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c |   4 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_isp.c       | 167 ++++--------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_isp.h       |  13 +-
 drivers/gpu/drm/amd/amdgpu/isp_v4_1_0.c       | 149 ++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/isp_v4_1_0.h       |  46 +++++
 drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c       | 137 ++++++++++++++
 drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.h       |  39 ++++
 8 files changed, 427 insertions(+), 133 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/isp_v4_1_0.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/isp_v4_1_0.h
 create mode 100644 drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.h
drivers/gpu/drm/amd/amdgpu/Makefile +4 -1
index c95ec19a3826..6e3d7f51616f 100644
@@ -326,7 +326,10 @@ endif
 
 # add isp block
 ifneq ($(CONFIG_DRM_AMD_ISP),)
-amdgpu-y += amdgpu_isp.o
+amdgpu-y += \
+	amdgpu_isp.o \
+	isp_v4_1_0.o \
+	isp_v4_1_1.o
 endif
 
 obj-$(CONFIG_DRM_AMDGPU)+= amdgpu.o
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +3 -1
index 0535596fa831..92172b9ceb1b 100644
@@ -2409,8 +2409,10 @@ static int amdgpu_discovery_set_isp_ip_blocks(struct amdgpu_device *adev)
 #if defined(CONFIG_DRM_AMD_ISP)
 	switch (amdgpu_ip_version(adev, ISP_HWIP, 0)) {
 	case IP_VERSION(4, 1, 0):
+		amdgpu_device_ip_block_add(adev, &isp_v4_1_0_ip_block);
+		break;
 	case IP_VERSION(4, 1, 1):
-		amdgpu_device_ip_block_add(adev, &isp_ip_block);
+		amdgpu_device_ip_block_add(adev, &isp_v4_1_1_ip_block);
 		break;
 	default:
 		break;
drivers/gpu/drm/amd/amdgpu/amdgpu_isp.c +39 -128

221 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/amdgpu_isp.h +10 -3
index 764d70beb9e9..44e2ea8c9728 100644
@@ -30,7 +30,7 @@
 
 #define ISP_REGS_OFFSET_END 0x629A4
 
-#define MAX_ISP_INT_SRC 8
+struct amdgpu_isp;
 
 struct isp_platform_data {
 	void *adev;
@@ -38,9 +38,15 @@ struct isp_platform_data {
 	resource_size_t base_rmmio_size;
 };
 
+struct isp_funcs {
+	int (*hw_init)(struct amdgpu_isp *isp);
+	int (*hw_fini)(struct amdgpu_isp *isp);
+};
+
 struct amdgpu_isp {
 	struct device *parent;
-	struct cgs_device *cgs_device;
+	struct amdgpu_device	*adev;
+	const struct isp_funcs	*funcs;
 	struct mfd_cell *isp_cell;
 	struct resource *isp_res;
 	struct isp_platform_data *isp_pdata;
@@ -48,6 +54,7 @@ struct amdgpu_isp {
 	const struct firmware	*fw;
 };
 
-extern const struct amdgpu_ip_block_version isp_ip_block;
+extern const struct amdgpu_ip_block_version isp_v4_1_0_ip_block;
+extern const struct amdgpu_ip_block_version isp_v4_1_1_ip_block;
 
 #endif /* __AMDGPU_ISP_H__ */
drivers/gpu/drm/amd/amdgpu/isp_v4_1_0.c new file +149 -0

149 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/isp_v4_1_0.h new file +46 -0

46 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c new file +137 -0

137 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.h new file +39 -0
new file mode 100644
index 000000000000..dfb9522c9d6a
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ */
+
+#ifndef __ISP_V4_1_1_H__
+#define __ISP_V4_1_1_H__
+
+#include "amdgpu_isp.h"
+
+#include "ivsrcid/isp/irqsrcs_isp_4_1.h"
+
+#define MAX_ISP411_INT_SRC 8
+
+void isp_v4_1_1_set_isp_funcs(struct amdgpu_isp *isp);
+
+#endif
Signature · 1 line
2.34.1
#3 lore raw

PATCH 3/3 drm/amd/amdgpu: Disable MMHUB prefetch for ISP v4.1.1

In reply to Pratap Nirujogi

Disable MMHUB prefetch for ISP v4.1.1 as a temporary WA until the GART supports MMHUB TLSi and SAW for ISP HW to access GART memory using the TLSi path.

---
 drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c | 12 ++++++++++++
 drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.h |  7 +++++++
 2 files changed, 19 insertions(+)
drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c +12 -0
index 4e17fa03f7b5..67f95f05ecca 100644
@@ -104,6 +104,18 @@ static int isp_v4_1_1_hw_init(struct amdgpu_isp *isp)
 		goto failure;
 	}
 
+	/*
+	 * Temporary WA added to disable MMHUB TLSi until the GART initialization
+	 * is ready to support MMHUB TLSi and SAW for ISP HW to access GART memory
+	 * using the TLSi path
+	 */
+	WREG32(mmDAGB1_WRCLI5_V4_1_1 >> 2, 0xFE5FEAA8);
+	WREG32(mmDAGB1_WRCLI9_V4_1_1 >> 2, 0xFE5FEAA8);
+	WREG32(mmDAGB1_WRCLI10_V4_1_1 >> 2, 0xFE5FEAA8);
+	WREG32(mmDAGB1_WRCLI14_V4_1_1 >> 2, 0xFE5FEAA8);
+	WREG32(mmDAGB1_WRCLI19_V4_1_1 >> 2, 0xFE5FEAA8);
+	WREG32(mmDAGB1_WRCLI20_V4_1_1 >> 2, 0xFE5FEAA8);
+
 	return 0;
 
 failure:
drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.h +7 -0
index dfb9522c9d6a..6bfb1de191a0 100644
@@ -32,6 +32,13 @@
 
 #include "ivsrcid/isp/irqsrcs_isp_4_1.h"
 
+#define mmDAGB1_WRCLI5_V4_1_1   0x68420
+#define mmDAGB1_WRCLI9_V4_1_1   0x68430
+#define mmDAGB1_WRCLI10_V4_1_1  0x68434
+#define mmDAGB1_WRCLI14_V4_1_1  0x68444
+#define mmDAGB1_WRCLI19_V4_1_1  0x68458
+#define mmDAGB1_WRCLI20_V4_1_1  0x6845C
+
 #define MAX_ISP411_INT_SRC 8
 
 void isp_v4_1_1_set_isp_funcs(struct amdgpu_isp *isp);
Signature · 1 line
2.34.1
Reviewed-by on the v1 series
#4 lore raw
In reply to Pratap Nirujogi
Quoted 19 lines · Pratap Nirujogi

Add support for ISP interrupts and disable MMHUB prefetch for ISP v4.1.1

Pratap Nirujogi (3):
drm/amd/amdgpu: Map ISP interrupts as generic IRQs drm/amd/amdgpu: Add ISP4.1.0 and ISP4.1.1 modules drm/amd/amdgpu: Disable MMHUB prefetch for ISP v4.1.1

  drivers/gpu/drm/amd/amdgpu/Makefile           |   5 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c |   4 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c       |   3 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_isp.c       | 144 +++++------------
  drivers/gpu/drm/amd/amdgpu/amdgpu_isp.h       |  13 +-
  drivers/gpu/drm/amd/amdgpu/ih_v6_1.c          |   6 +
  drivers/gpu/drm/amd/amdgpu/isp_v4_1_0.c       | 149 ++++++++++++++++++
  drivers/gpu/drm/amd/amdgpu/isp_v4_1_0.h       |  46 ++++++
  drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c       | 149 ++++++++++++++++++
  drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.h       |  46 ++++++
  .../amd/include/ivsrcid/isp/irqsrcs_isp_4_1.h |  62 ++++++++
  11 files changed, 517 insertions(+), 110 deletions(-)
Quoted 6 lines

create mode 100644 drivers/gpu/drm/amd/amdgpu/isp_v4_1_0.c create mode 100644 drivers/gpu/drm/amd/amdgpu/isp_v4_1_0.h create mode 100644 drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c create mode 100644 drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.h create mode 100644 drivers/gpu/drm/amd/include/ivsrcid/isp/irqsrcs_isp_4_1.h