Skip to contentSkip to conversation

drm/amdgpu: implement UMC 64 bits REG operations

PATCH In review Tao Zhou 3 participants 5 messages Aug 9, 2019 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Tao Zhou

author
#0 lore raw

PATCH 1/2 drm/amdgpu: implement UMC 64 bits REG operations

implement 64 bits operations via 32 bits interface

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h |  9 +++++++++
 drivers/gpu/drm/amd/amdgpu/umc_v6_1.c   | 10 +++++-----
 2 files changed, 14 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +9 -0
index 9efdd66279e5..a617dcc9d257 100644
@@ -21,6 +21,15 @@
 #ifndef __AMDGPU_UMC_H__
 #define __AMDGPU_UMC_H__
 
+/* implement 64 bits REG operations via 32 bits interface */
+#define RREG64_UMC(reg)	(RREG32(reg) | \
+				((uint64_t)RREG32((reg) + 1) << 32))
+#define WREG64_UMC(reg, v)	\
+	do {	\
+		WREG32((reg), (uint32_t)((v) & 0xffffffff));	\
+		WREG32((reg) + 1, (uint32_t)((v) >> 32));	\
+	} while (0)
+
 /*
  * void (*func)(struct amdgpu_device *adev, struct ras_err_data *err_data,
  *				uint32_t umc_reg_offset, uint32_t channel_index)
drivers/gpu/drm/amd/amdgpu/umc_v6_1.c +5 -5
index 64df37b860dd..8502e736f721 100644
@@ -116,7 +116,7 @@ static void umc_v6_1_query_correctable_error_count(struct amdgpu_device *adev,
 
 	/* check for SRAM correctable error
 	  MCUMC_STATUS is a 64 bit register */
-	mc_umc_status = RREG64(mc_umc_status_addr + umc_reg_offset);
+	mc_umc_status = RREG64_UMC(mc_umc_status_addr + umc_reg_offset);
 	if (REG_GET_FIELD(mc_umc_status, MCA_UMC_UMC0_MCUMC_STATUST0, ErrorCodeExt) == 6 &&
 	    REG_GET_FIELD(mc_umc_status, MCA_UMC_UMC0_MCUMC_STATUST0, Val) == 1 &&
 	    REG_GET_FIELD(mc_umc_status, MCA_UMC_UMC0_MCUMC_STATUST0, CECC) == 1)
@@ -134,7 +134,7 @@ static void umc_v6_1_querry_uncorrectable_error_count(struct amdgpu_device *adev
                 SOC15_REG_OFFSET(UMC, 0, mmMCA_UMC_UMC0_MCUMC_STATUST0);
 
 	/* check the MCUMC_STATUS */
-	mc_umc_status = RREG64(mc_umc_status_addr + umc_reg_offset);
+	mc_umc_status = RREG64_UMC(mc_umc_status_addr + umc_reg_offset);
 	if ((REG_GET_FIELD(mc_umc_status, MCA_UMC_UMC0_MCUMC_STATUST0, Val) == 1) &&
 	    (REG_GET_FIELD(mc_umc_status, MCA_UMC_UMC0_MCUMC_STATUST0, Deferred) == 1 ||
 	    REG_GET_FIELD(mc_umc_status, MCA_UMC_UMC0_MCUMC_STATUST0, UECC) == 1 ||
@@ -173,11 +173,11 @@ static void umc_v6_1_query_error_address(struct amdgpu_device *adev,
 	/* skip error address process if -ENOMEM */
 	if (!err_data->err_addr) {
 		/* clear umc status */
-		WREG64(mc_umc_status_addr + umc_reg_offset, 0x0ULL);
+		WREG64_UMC(mc_umc_status_addr + umc_reg_offset, 0x0ULL);
 		return;
 	}
 
-	mc_umc_status = RREG64(mc_umc_status_addr + umc_reg_offset);
+	mc_umc_status = RREG64_UMC(mc_umc_status_addr + umc_reg_offset);
 
 	/* calculate error address if ue/ce error is detected */
 	if (REG_GET_FIELD(mc_umc_status, MCA_UMC_UMC0_MCUMC_STATUST0, Val) == 1 &&
@@ -200,7 +200,7 @@ static void umc_v6_1_query_error_address(struct amdgpu_device *adev,
 	}
 
 	/* clear umc status */
-	WREG64(mc_umc_status_addr + umc_reg_offset, 0x0ULL);
+	WREG64_UMC(mc_umc_status_addr + umc_reg_offset, 0x0ULL);
 }
 
 static void umc_v6_1_query_ras_error_address(struct amdgpu_device *adev,
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#2 lore raw

PATCH 2/2 drm/amdgpu: remove RREG64/WREG64

atomic 64 bits REG operations are useless currently

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  4 ---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 33 ----------------------
 2 files changed, 37 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -4
index ed1a217e86e4..f6ae5652b2e5 100644
@@ -1042,8 +1042,6 @@ void amdgpu_mm_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v,
 		    uint32_t acc_flags);
 void amdgpu_mm_wreg8(struct amdgpu_device *adev, uint32_t offset, uint8_t value);
 uint8_t amdgpu_mm_rreg8(struct amdgpu_device *adev, uint32_t offset);
-uint64_t amdgpu_mm_rreg64(struct amdgpu_device *adev, uint32_t reg);
-void amdgpu_mm_wreg64(struct amdgpu_device *adev, uint32_t reg, uint64_t v);
 
 u32 amdgpu_io_rreg(struct amdgpu_device *adev, u32 reg);
 void amdgpu_io_wreg(struct amdgpu_device *adev, u32 reg, u32 v);
@@ -1071,8 +1069,6 @@ int emu_soc_asic_init(struct amdgpu_device *adev);
 #define DREG32(reg) printk(KERN_INFO "REGISTER: " #reg " : 0x%08X\n", amdgpu_mm_rreg(adev, (reg), 0))
 #define WREG32(reg, v) amdgpu_mm_wreg(adev, (reg), (v), 0)
 #define WREG32_IDX(reg, v) amdgpu_mm_wreg(adev, (reg), (v), AMDGPU_REGS_IDX)
-#define RREG64(reg) amdgpu_mm_rreg64(adev, (reg))
-#define WREG64(reg, v) amdgpu_mm_wreg64(adev, (reg), (v))
 #define REG_SET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK)
 #define REG_GET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK)
 #define RREG32_PCIE(reg) adev->pcie_rreg(adev, (reg))
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -33
index 7eb9e0b9235a..2f43c58f5d03 100644
@@ -262,39 +262,6 @@ void amdgpu_mm_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v,
 	}
 }
 
-/**
- * amdgpu_mm_rreg64 - read a 64 bit memory mapped IO register
- *
- * @adev: amdgpu_device pointer
- * @reg: dword aligned register offset
- *
- * Returns the 64 bit value from the offset specified.
- */
-uint64_t amdgpu_mm_rreg64(struct amdgpu_device *adev, uint32_t reg)
-{
-	if ((reg * 4) < adev->rmmio_size)
-		return atomic64_read((atomic64_t *)(adev->rmmio + (reg * 4)));
-	else
-		BUG();
-}
-
-/**
- * amdgpu_mm_wreg64 - write to a 64 bit memory mapped IO register
- *
- * @adev: amdgpu_device pointer
- * @reg: dword aligned register offset
- * @v: 64 bit value to write to the register
- *
- * Writes the value specified to the offset specified.
- */
-void amdgpu_mm_wreg64(struct amdgpu_device *adev, uint32_t reg, uint64_t v)
-{
-	if ((reg * 4) < adev->rmmio_size)
-		atomic64_set((atomic64_t *)(adev->rmmio + (reg * 4)), v);
-	else
-		BUG();
-}
-
 /**
  * amdgpu_io_rreg - read an IO register
  *
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

Reviewed-by Hawking Zhang
#4 lore raw

RE: [PATCH 2/2] drm/amdgpu: remove RREG64/WREG64

Series is

Regards,
Hawking
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Tao Zhou
Sent: 2019年8月9日 12:28
To: [email protected]; Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Koenig, Christian <[email protected]>
Cc: Zhou1, Tao <[email protected]>
Subject: [PATCH 2/2] drm/amdgpu: remove RREG64/WREG64

atomic 64 bits REG operations are useless currently

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  4 ---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 33 ----------------------
 2 files changed, 37 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
index ed1a217e86e4..f6ae5652b2e5 100644
@@ -1042,8 +1042,6 @@ void amdgpu_mm_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v,
 		    uint32_t acc_flags);
 void amdgpu_mm_wreg8(struct amdgpu_device *adev, uint32_t offset, uint8_t value);  uint8_t amdgpu_mm_rreg8(struct amdgpu_device *adev, uint32_t offset); -uint64_t amdgpu_mm_rreg64(struct amdgpu_device *adev, uint32_t reg); -void amdgpu_mm_wreg64(struct amdgpu_device *adev, uint32_t reg, uint64_t v);
 
 u32 amdgpu_io_rreg(struct amdgpu_device *adev, u32 reg);  void amdgpu_io_wreg(struct amdgpu_device *adev, u32 reg, u32 v); @@ -1071,8 +1069,6 @@ int emu_soc_asic_init(struct amdgpu_device *adev);  #define DREG32(reg) printk(KERN_INFO "REGISTER: " #reg " : 0x%08X\n", amdgpu_mm_rreg(adev, (reg), 0))  #define WREG32(reg, v) amdgpu_mm_wreg(adev, (reg), (v), 0)  #define WREG32_IDX(reg, v) amdgpu_mm_wreg(adev, (reg), (v), AMDGPU_REGS_IDX) -#define RREG64(reg) amdgpu_mm_rreg64(adev, (reg)) -#define WREG64(reg, v) amdgpu_mm_wreg64(adev, (reg), (v))  #define REG_SET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK)  #define REG_GET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK)  #define RREG32_PCIE(reg) adev->pcie_rreg(adev, (reg)) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

index 7eb9e0b9235a..2f43c58f5d03 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -32
@@ -262,39 +262,6 @@ void amdgpu_mm_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v,
 	}
 }
 
-/**
- * amdgpu_mm_rreg64 - read a 64 bit memory mapped IO register
- *
- * @adev: amdgpu_device pointer
- * @reg: dword aligned register offset
- *
- * Returns the 64 bit value from the offset specified.
- */
-uint64_t amdgpu_mm_rreg64(struct amdgpu_device *adev, uint32_t reg) -{
-	if ((reg * 4) < adev->rmmio_size)
-		return atomic64_read((atomic64_t *)(adev->rmmio + (reg * 4)));
-	else
-		BUG();
-}
-
-/**
- * amdgpu_mm_wreg64 - write to a 64 bit memory mapped IO register
- *
- * @adev: amdgpu_device pointer
- * @reg: dword aligned register offset
- * @v: 64 bit value to write to the register
- *
- * Writes the value specified to the offset specified.
- */
-void amdgpu_mm_wreg64(struct amdgpu_device *adev, uint32_t reg, uint64_t v) -{
-	if ((reg * 4) < adev->rmmio_size)
-		atomic64_set((atomic64_t *)(adev->rmmio + (reg * 4)), v);
-	else
-		BUG();
-}
-
 /**
  * amdgpu_io_rreg - read an IO register
  *
--

2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reviewed-by Christian König
#5 lore raw

Re: [PATCH 2/2] drm/amdgpu: remove RREG64/WREG64

In reply to a message not in the archive

Am 09.08.19 um 06:27 schrieb Tao Zhou:

Quoted 3 lines

atomic 64 bits REG operations are useless currently

Quoted 61 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  4 ---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 33 ----------------------
  2 files changed, 37 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -4
index ed1a217e86e4..f6ae5652b2e5 100644
@@ -1042,8 +1042,6 @@ void amdgpu_mm_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v,
  		    uint32_t acc_flags);
  void amdgpu_mm_wreg8(struct amdgpu_device *adev, uint32_t offset, uint8_t value);
  uint8_t amdgpu_mm_rreg8(struct amdgpu_device *adev, uint32_t offset);
-uint64_t amdgpu_mm_rreg64(struct amdgpu_device *adev, uint32_t reg);
-void amdgpu_mm_wreg64(struct amdgpu_device *adev, uint32_t reg, uint64_t v);
 
  u32 amdgpu_io_rreg(struct amdgpu_device *adev, u32 reg);
  void amdgpu_io_wreg(struct amdgpu_device *adev, u32 reg, u32 v);
@@ -1071,8 +1069,6 @@ int emu_soc_asic_init(struct amdgpu_device *adev);
  #define DREG32(reg) printk(KERN_INFO "REGISTER: " #reg " : 0x%08X\n", amdgpu_mm_rreg(adev, (reg), 0))
  #define WREG32(reg, v) amdgpu_mm_wreg(adev, (reg), (v), 0)
  #define WREG32_IDX(reg, v) amdgpu_mm_wreg(adev, (reg), (v), AMDGPU_REGS_IDX)
-#define RREG64(reg) amdgpu_mm_rreg64(adev, (reg))
-#define WREG64(reg, v) amdgpu_mm_wreg64(adev, (reg), (v))
  #define REG_SET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK)
  #define REG_GET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK)
  #define RREG32_PCIE(reg) adev->pcie_rreg(adev, (reg))
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -26
index 7eb9e0b9235a..2f43c58f5d03 100644
@@ -262,39 +262,6 @@ void amdgpu_mm_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v,
  	}
  }
 
-/**
- * amdgpu_mm_rreg64 - read a 64 bit memory mapped IO register
- *
- * @adev: amdgpu_device pointer
- * @reg: dword aligned register offset
- *
- * Returns the 64 bit value from the offset specified.
- */
-uint64_t amdgpu_mm_rreg64(struct amdgpu_device *adev, uint32_t reg)
-{
-	if ((reg * 4) < adev->rmmio_size)
-		return atomic64_read((atomic64_t *)(adev->rmmio + (reg * 4)));
-	else
-		BUG();
-}
-
-/**
- * amdgpu_mm_wreg64 - write to a 64 bit memory mapped IO register
- *
- * @adev: amdgpu_device pointer
- * @reg: dword aligned register offset
- * @v: 64 bit value to write to the register
- *
- * Writes the value specified to the offset specified.
- */
-void amdgpu_mm_wreg64(struct amdgpu_device *adev, uint32_t reg, uint64_t v)

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c void amdgpu_mm_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v, · line 267

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -7
-{
-	if ((reg * 4) < adev->rmmio_size)
-		atomic64_set((atomic64_t *)(adev->rmmio + (reg * 4)), v);
-	else
-		BUG();
-}
-
  /**
   * amdgpu_io_rreg - read an IO register
   *

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#6 lore raw
In reply to a message not in the archive

Am 09.08.19 um 06:27 schrieb Tao Zhou:

Quoted 13 lines

implement 64 bits operations via 32 bits interface

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h |  9 +++++++++
  drivers/gpu/drm/amd/amdgpu/umc_v6_1.c   | 10 +++++-----
  2 files changed, 14 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +0 -0
index 9efdd66279e5..a617dcc9d257 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h line 27

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +4 -0
@@ -21,6 +21,15 @@
  #ifndef __AMDGPU_UMC_H__
  #define __AMDGPU_UMC_H__
 
+/* implement 64 bits REG operations via 32 bits interface */
+#define RREG64_UMC(reg)	(RREG32(reg) | \
+				((uint64_t)RREG32((reg) + 1) << 32))
+#define WREG64_UMC(reg, v)	\

Maybe call this WREG_LO_HI and RREG_LO_HI to explicitly note what they are doing. This way we can probably keep them in amdgpu.h as well.

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h line 30

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +3 -0
+	do {	\
+		WREG32((reg), (uint32_t)((v) & 0xffffffff));	\
+		WREG32((reg) + 1, (uint32_t)((v) >> 32));	\

I think I now understand why you wanted to have this macro.

We have explicit lower_32_bits() and upper_32_bits() functions to avoid the masking and shifting and make the code more readable.

For example see the UVD code:

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +0 -0
                 WREG32_SOC15(UVD, 0, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_LOW,
                         lower_32_bits(adev->vcn.gpu_addr));
                 WREG32_SOC15(UVD, 0, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_HIGH,

                        upper_32_bits(adev->vcn.gpu_addr));

I suggest to use those in your macro here as well, apart from that the patch looks good to me.

Thanks for taking care of this,
Christian.

Quoted 42 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +2 -0
+	} while (0)
+
  /*
   * void (*func)(struct amdgpu_device *adev, struct ras_err_data *err_data,
   *				uint32_t umc_reg_offset, uint32_t channel_index)
drivers/gpu/drm/amd/amdgpu/umc_v6_1.c +4 -4
index 64df37b860dd..8502e736f721 100644
@@ -116,7 +116,7 @@ static void umc_v6_1_query_correctable_error_count(struct amdgpu_device *adev,
 
  	/* check for SRAM correctable error
  	  MCUMC_STATUS is a 64 bit register */
-	mc_umc_status = RREG64(mc_umc_status_addr + umc_reg_offset);
+	mc_umc_status = RREG64_UMC(mc_umc_status_addr + umc_reg_offset);
  	if (REG_GET_FIELD(mc_umc_status, MCA_UMC_UMC0_MCUMC_STATUST0, ErrorCodeExt) == 6 &&
  	    REG_GET_FIELD(mc_umc_status, MCA_UMC_UMC0_MCUMC_STATUST0, Val) == 1 &&
  	    REG_GET_FIELD(mc_umc_status, MCA_UMC_UMC0_MCUMC_STATUST0, CECC) == 1)
@@ -134,7 +134,7 @@ static void umc_v6_1_querry_uncorrectable_error_count(struct amdgpu_device *adev
                  SOC15_REG_OFFSET(UMC, 0, mmMCA_UMC_UMC0_MCUMC_STATUST0);
 
  	/* check the MCUMC_STATUS */
-	mc_umc_status = RREG64(mc_umc_status_addr + umc_reg_offset);
+	mc_umc_status = RREG64_UMC(mc_umc_status_addr + umc_reg_offset);
  	if ((REG_GET_FIELD(mc_umc_status, MCA_UMC_UMC0_MCUMC_STATUST0, Val) == 1) &&
  	    (REG_GET_FIELD(mc_umc_status, MCA_UMC_UMC0_MCUMC_STATUST0, Deferred) == 1 ||
  	    REG_GET_FIELD(mc_umc_status, MCA_UMC_UMC0_MCUMC_STATUST0, UECC) == 1 ||
@@ -173,11 +173,11 @@ static void umc_v6_1_query_error_address(struct amdgpu_device *adev,
  	/* skip error address process if -ENOMEM */
  	if (!err_data->err_addr) {
  		/* clear umc status */
-		WREG64(mc_umc_status_addr + umc_reg_offset, 0x0ULL);
+		WREG64_UMC(mc_umc_status_addr + umc_reg_offset, 0x0ULL);
  		return;
  	}
 
-	mc_umc_status = RREG64(mc_umc_status_addr + umc_reg_offset);
+	mc_umc_status = RREG64_UMC(mc_umc_status_addr + umc_reg_offset);
 
  	/* calculate error address if ue/ce error is detected */
  	if (REG_GET_FIELD(mc_umc_status, MCA_UMC_UMC0_MCUMC_STATUST0, Val) == 1 &&

drivers/gpu/drm/amd/amdgpu/umc_v6_1.c static void umc_v6_1_query_error_address(struct amdgpu_device *adev, · line 206

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/umc_v6_1.c +1 -1
@@ -200,7 +200,7 @@ static void umc_v6_1_query_error_address(struct amdgpu_device *adev,
  	}
 
  	/* clear umc status */
-	WREG64(mc_umc_status_addr + umc_reg_offset, 0x0ULL);
+	WREG64_UMC(mc_umc_status_addr + umc_reg_offset, 0x0ULL);
  }
 
  static void umc_v6_1_query_ras_error_address(struct amdgpu_device *adev,

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx