[PATCH] drm/amdgpu: wait till Gfxoff allow signal completes during suspend

2022-11-03 Thread Harsh Jain
change guarantees that gfxoff is allowed before moving further in
s2idle sequence to add more reliablity about gfxoff in amdgpu IP's
suspend flow

Signed-off-by: Harsh Jain 

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
index 222d3d7ea076..5b2afe348c23 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
@@ -581,11 +581,11 @@ void amdgpu_gfx_off_ctrl(struct amdgpu_device *adev, bool 
enable)
 
if (adev->gfx.gfx_off_req_count == 0 &&
!adev->gfx.gfx_off_state) {
-   /* If going to s2idle, no need to wait */
-   if (adev->in_s0ix)
-   delay = GFX_OFF_NO_DELAY;
schedule_delayed_work(&adev->gfx.gfx_off_delay_work,
  delay);
+   /* If going to s2idle, no need to wait */
+   if (adev->in_s0ix)
+   
flush_delayed_work(&adev->gfx.gfx_off_delay_work);
}
} else {
if (adev->gfx.gfx_off_req_count == 0) {
-- 
2.25.1



Re: [PATCH] drm/amdkfd: Fix error handling in kfd_criu_restore_events

2022-11-03 Thread Bhardwaj, Rajneesh
[AMD Official Use Only - General]

Yes it helps avoid the unbalanced lock messages seen during criu restore 
failures for events. Looks good to me.

Reviewed-by: Rajneesh Bhardwaj 

Regards,
Rajneesh

From: amd-gfx  on behalf of Felix 
Kuehling 
Sent: Thursday, November 3, 2022 7:13:09 PM
To: amd-gfx@lists.freedesktop.org 
Subject: [PATCH] drm/amdkfd: Fix error handling in kfd_criu_restore_events

mutex_unlock before the exit label because all the error code paths that
jump there didn't take that lock. This fixes unbalanced locking errors
in case of restore errors.

Fixes: 40e8a766a761 ("drm/amdkfd: CRIU checkpoint and restore events")
Signed-off-by: Felix Kuehling 
---
 drivers/gpu/drm/amd/amdkfd/kfd_events.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_events.c 
b/drivers/gpu/drm/amd/amdkfd/kfd_events.c
index 83e3ce9f6049..729d26d648af 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_events.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_events.c
@@ -506,6 +506,7 @@ int kfd_criu_restore_event(struct file *devkfd,
 ret = create_other_event(p, ev, &ev_priv->event_id);
 break;
 }
+   mutex_unlock(&p->event_mutex);

 exit:
 if (ret)
@@ -513,8 +514,6 @@ int kfd_criu_restore_event(struct file *devkfd,

 kfree(ev_priv);

-   mutex_unlock(&p->event_mutex);
-
 return ret;
 }

--
2.32.0



RE: [PATCH] drm/amd/pm: update SMU IP v13.0.4 msg interface header

2022-11-03 Thread Zhang, Yifan
[AMD Official Use Only - General]

Reviewed-by: Yifan Zhang 

Best Regards,
Yifan

-Original Message-
From: Huang, Tim  
Sent: Thursday, November 3, 2022 4:50 PM
To: amd-gfx@lists.freedesktop.org
Cc: Deucher, Alexander ; Zhang, Yifan 
; Du, Xiaojian ; Huang, Tim 
; Limonciello, Mario 
Subject: [PATCH] drm/amd/pm: update SMU IP v13.0.4 msg interface header

Some of the unused messages that were used earlier in development have been 
freed up as spare messages, no intended functional changes.

Signed-off-by: Mario Limonciello 
Signed-off-by: Tim Huang 
---
 .../amd/pm/swsmu/inc/pmfw_if/smu_v13_0_4_ppsmc.h  | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_4_ppsmc.h 
b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_4_ppsmc.h
index d9b0cd752200..f4d6c07b56ea 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_4_ppsmc.h
+++ b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_4_ppsmc.h
@@ -54,14 +54,14 @@
 #define PPSMC_MSG_TestMessage   0x01 ///< To check if PMFW is 
alive and responding. Requirement specified by PMFW team
 #define PPSMC_MSG_GetPmfwVersion0x02 ///< Get PMFW version
 #define PPSMC_MSG_GetDriverIfVersion0x03 ///< Get PMFW_DRIVER_IF 
version
-#define PPSMC_MSG_EnableGfxOff  0x04 ///< Enable GFXOFF
-#define PPSMC_MSG_DisableGfxOff 0x05 ///< Disable GFXOFF
+#define PPSMC_MSG_SPARE00x04 ///< SPARE
+#define PPSMC_MSG_SPARE10x05 ///< SPARE
 #define PPSMC_MSG_PowerDownVcn  0x06 ///< Power down VCN
 #define PPSMC_MSG_PowerUpVcn0x07 ///< Power up VCN; VCN is 
power gated by default
 #define PPSMC_MSG_SetHardMinVcn 0x08 ///< For wireless display
 #define PPSMC_MSG_SetSoftMinGfxclk  0x09 ///< Set SoftMin for 
GFXCLK, argument is frequency in MHz
-#define PPSMC_MSG_ActiveProcessNotify   0x0A ///< Needs update
-#define PPSMC_MSG_ForcePowerDownGfx 0x0B ///< Force power down 
GFX, i.e. enter GFXOFF
+#define PPSMC_MSG_SPARE20x0A ///< SPARE
+#define PPSMC_MSG_SPARE30x0B ///< SPARE
 #define PPSMC_MSG_PrepareMp1ForUnload   0x0C ///< Prepare PMFW for GFX 
driver unload
 #define PPSMC_MSG_SetDriverDramAddrHigh 0x0D ///< Set high 32 bits of 
DRAM address for Driver table transfer
 #define PPSMC_MSG_SetDriverDramAddrLow  0x0E ///< Set low 32 bits of 
DRAM address for Driver table transfer
@@ -73,8 +73,7 @@
 #define PPSMC_MSG_SetSoftMinFclk0x14 ///< Set hard min for FCLK
 #define PPSMC_MSG_SetSoftMinVcn 0x15 ///< Set soft min for VCN 
clocks (VCLK and DCLK)
 
-
-#define PPSMC_MSG_EnableGfxImu  0x16 ///< Needs update
+#define PPSMC_MSG_EnableGfxImu  0x16 ///< Enable GFX IMU
 
 #define PPSMC_MSG_GetGfxclkFrequency0x17 ///< Get GFX clock 
frequency
 #define PPSMC_MSG_GetFclkFrequency  0x18 ///< Get FCLK frequency
@@ -102,8 +101,8 @@
 #define PPSMC_MSG_SetHardMinIspxclkByFreq   0x2C ///< Set HardMin by 
frequency for ISPXCLK
 #define PPSMC_MSG_PowerDownUmsch0x2D ///< Power down VCN.UMSCH 
(aka VSCH) scheduler
 #define PPSMC_MSG_PowerUpUmsch  0x2E ///< Power up VCN.UMSCH 
(aka VSCH) scheduler
-#define PPSMC_Message_IspStutterOn_MmhubPgDis   0x2F ///< ISP StutterOn mmHub 
PgDis
-#define PPSMC_Message_IspStutterOff_MmhubPgEn   0x30 ///< ISP StufferOff mmHub 
PgEn
+#define PPSMC_MSG_IspStutterOn_MmhubPgDis   0x2F ///< ISP StutterOn mmHub 
PgDis
+#define PPSMC_MSG_IspStutterOff_MmhubPgEn   0x30 ///< ISP StufferOff mmHub 
PgEn
 
 #define PPSMC_Message_Count 0x31 ///< Total number of 
PPSMC messages
 /** @}*/
--
2.25.1


[PATCH] drm/amd/amdgpu: Enable gfx pipe1 and fix related issues

2022-11-03 Thread Emily Deng
Starting from SIENNA CICHLID asic supports two gfx pipes, enabling
two graphics queues for performance concern.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c |  2 +-
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c  | 43 +
 2 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
index 331aa191910c..0072f36b44d1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
@@ -33,7 +33,7 @@
container_of((e), struct amdgpu_ctx_entity, entity)
 
 const unsigned int amdgpu_ctx_num_entities[AMDGPU_HW_IP_NUM] = {
-   [AMDGPU_HW_IP_GFX]  =   1,
+   [AMDGPU_HW_IP_GFX]  =   2,
[AMDGPU_HW_IP_COMPUTE]  =   4,
[AMDGPU_HW_IP_DMA]  =   2,
[AMDGPU_HW_IP_UVD]  =   1,
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index 49d34c7bbf20..9219cd29acd3 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -4606,7 +4606,7 @@ static int gfx_v10_0_sw_init(void *handle)
case IP_VERSION(10, 3, 3):
case IP_VERSION(10, 3, 7):
adev->gfx.me.num_me = 1;
-   adev->gfx.me.num_pipe_per_me = 1;
+   adev->gfx.me.num_pipe_per_me = 2;
adev->gfx.me.num_queue_per_pipe = 1;
adev->gfx.mec.num_mec = 2;
adev->gfx.mec.num_pipe_per_mec = 4;
@@ -6008,6 +6008,25 @@ static int gfx_v10_0_cp_gfx_load_microcode(struct 
amdgpu_device *adev)
return 0;
 }
 
+static int gfx_v10_0_wait_for_idle(void *handle)
+{
+   unsigned i;
+   u32 tmp;
+   struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+
+   for (i = 0; i < adev->usec_timeout; i++) {
+   /* read MC_STATUS */
+   tmp = RREG32_SOC15(GC, 0, mmGRBM_STATUS) &
+   GRBM_STATUS__GUI_ACTIVE_MASK;
+
+   if (!REG_GET_FIELD(tmp, GRBM_STATUS, GUI_ACTIVE))
+   return 0;
+   udelay(1);
+   }
+   printk("Emily:gfx_v10_0_wait_for_idle\n");
+   return -ETIMEDOUT;
+}
+
 static int gfx_v10_0_cp_gfx_start(struct amdgpu_device *adev)
 {
struct amdgpu_ring *ring;
@@ -6069,7 +6088,7 @@ static int gfx_v10_0_cp_gfx_start(struct amdgpu_device 
*adev)
amdgpu_ring_write(ring, 0x8000);
 
amdgpu_ring_commit(ring);
-
+   gfx_v10_0_wait_for_idle(adev);
/* submit cs packet to copy state 0 to next available state */
if (adev->gfx.num_gfx_rings > 1) {
/* maximum supported gfx ring is 2 */
@@ -7404,24 +7423,6 @@ static bool gfx_v10_0_is_idle(void *handle)
return true;
 }
 
-static int gfx_v10_0_wait_for_idle(void *handle)
-{
-   unsigned i;
-   u32 tmp;
-   struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-
-   for (i = 0; i < adev->usec_timeout; i++) {
-   /* read MC_STATUS */
-   tmp = RREG32_SOC15(GC, 0, mmGRBM_STATUS) &
-   GRBM_STATUS__GUI_ACTIVE_MASK;
-
-   if (!REG_GET_FIELD(tmp, GRBM_STATUS, GUI_ACTIVE))
-   return 0;
-   udelay(1);
-   }
-   return -ETIMEDOUT;
-}
-
 static int gfx_v10_0_soft_reset(void *handle)
 {
u32 grbm_soft_reset = 0;
@@ -8466,7 +8467,7 @@ static void gfx_v10_0_ring_emit_hdp_flush(struct 
amdgpu_ring *ring)
}
reg_mem_engine = 0;
} else {
-   ref_and_mask = nbio_hf_reg->ref_and_mask_cp0;
+   ref_and_mask = nbio_hf_reg->ref_and_mask_cp0 << ring->pipe;
reg_mem_engine = 1; /* pfp */
}
 
-- 
2.36.1



Re: [PATCH v3] drm/amdkfd: Fix error handling in criu_checkpoint

2022-11-03 Thread Bhardwaj, Rajneesh

This one is more elegant. Looks good to me!

Reviewed-and-tested-by: Rajneesh Bhardwaj 

On 11/3/2022 7:12 PM, Felix Kuehling wrote:

Checkpoint BOs last. That way we don't need to close dmabuf FDs if
something else fails later. This avoids problematic access to user mode
memory in the error handling code path.

criu_checkpoint_bos has its own error handling and cleanup that does not
depend on access to user memory.

In the private data, keep BOs before the remaining objects. This is
necessary to restore things in the correct order as restoring events
depends on the events-page BO being restored first.

Fixes: be072b06c739 ("drm/amdkfd: CRIU export BOs as prime dmabuf objects")
Reported-by: Jann Horn 
CC: Rajneesh Bhardwaj 
Signed-off-by: Felix Kuehling 

---

v3: Keep order of private data and restore order the same.
---
  drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 34 +++-
  1 file changed, 15 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c 
b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
index 5feaba6a77de..6d291aa6386b 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -1950,7 +1950,7 @@ static int criu_checkpoint(struct file *filep,
  {
int ret;
uint32_t num_devices, num_bos, num_objects;
-   uint64_t priv_size, priv_offset = 0;
+   uint64_t priv_size, priv_offset = 0, bo_priv_offset;
  
  	if (!args->devices || !args->bos || !args->priv_data)

return -EINVAL;
@@ -1994,38 +1994,34 @@ static int criu_checkpoint(struct file *filep,
if (ret)
goto exit_unlock;
  
-	ret = criu_checkpoint_bos(p, num_bos, (uint8_t __user *)args->bos,

-   (uint8_t __user *)args->priv_data, &priv_offset);
-   if (ret)
-   goto exit_unlock;
+   /* Leave room for BOs in the private data. They need to be restored
+* before events, but we checkpoint them last to simplify the error
+* handling.
+*/
+   bo_priv_offset = priv_offset;
+   priv_offset += num_bos * sizeof(struct kfd_criu_bo_priv_data);
  
  	if (num_objects) {

ret = kfd_criu_checkpoint_queues(p, (uint8_t __user 
*)args->priv_data,
 &priv_offset);
if (ret)
-   goto close_bo_fds;
+   goto exit_unlock;
  
  		ret = kfd_criu_checkpoint_events(p, (uint8_t __user *)args->priv_data,

 &priv_offset);
if (ret)
-   goto close_bo_fds;
+   goto exit_unlock;
  
  		ret = kfd_criu_checkpoint_svm(p, (uint8_t __user *)args->priv_data, &priv_offset);

if (ret)
-   goto close_bo_fds;
+   goto exit_unlock;
}
  
-close_bo_fds:

-   if (ret) {
-   /* If IOCTL returns err, user assumes all FDs opened in 
criu_dump_bos are closed */
-   uint32_t i;
-   struct kfd_criu_bo_bucket *bo_buckets = (struct kfd_criu_bo_bucket 
*) args->bos;
-
-   for (i = 0; i < num_bos; i++) {
-   if (bo_buckets[i].alloc_flags & 
KFD_IOC_ALLOC_MEM_FLAGS_VRAM)
-   close_fd(bo_buckets[i].dmabuf_fd);
-   }
-   }
+   /* This must be the last thing in this function that can fail.
+* Otherwise we leak dmabuf file descriptors.
+*/
+   ret = criu_checkpoint_bos(p, num_bos, (uint8_t __user *)args->bos,
+  (uint8_t __user *)args->priv_data, &bo_priv_offset);
  
  exit_unlock:

mutex_unlock(&p->mutex);


[PATCH] drm/amdkfd: Fix error handling in kfd_criu_restore_events

2022-11-03 Thread Felix Kuehling
mutex_unlock before the exit label because all the error code paths that
jump there didn't take that lock. This fixes unbalanced locking errors
in case of restore errors.

Fixes: 40e8a766a761 ("drm/amdkfd: CRIU checkpoint and restore events")
Signed-off-by: Felix Kuehling 
---
 drivers/gpu/drm/amd/amdkfd/kfd_events.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_events.c 
b/drivers/gpu/drm/amd/amdkfd/kfd_events.c
index 83e3ce9f6049..729d26d648af 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_events.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_events.c
@@ -506,6 +506,7 @@ int kfd_criu_restore_event(struct file *devkfd,
ret = create_other_event(p, ev, &ev_priv->event_id);
break;
}
+   mutex_unlock(&p->event_mutex);
 
 exit:
if (ret)
@@ -513,8 +514,6 @@ int kfd_criu_restore_event(struct file *devkfd,
 
kfree(ev_priv);
 
-   mutex_unlock(&p->event_mutex);
-
return ret;
 }
 
-- 
2.32.0



[PATCH v3] drm/amdkfd: Fix error handling in criu_checkpoint

2022-11-03 Thread Felix Kuehling
Checkpoint BOs last. That way we don't need to close dmabuf FDs if
something else fails later. This avoids problematic access to user mode
memory in the error handling code path.

criu_checkpoint_bos has its own error handling and cleanup that does not
depend on access to user memory.

In the private data, keep BOs before the remaining objects. This is
necessary to restore things in the correct order as restoring events
depends on the events-page BO being restored first.

Fixes: be072b06c739 ("drm/amdkfd: CRIU export BOs as prime dmabuf objects")
Reported-by: Jann Horn 
CC: Rajneesh Bhardwaj 
Signed-off-by: Felix Kuehling 

---

v3: Keep order of private data and restore order the same.
---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 34 +++-
 1 file changed, 15 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c 
b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
index 5feaba6a77de..6d291aa6386b 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -1950,7 +1950,7 @@ static int criu_checkpoint(struct file *filep,
 {
int ret;
uint32_t num_devices, num_bos, num_objects;
-   uint64_t priv_size, priv_offset = 0;
+   uint64_t priv_size, priv_offset = 0, bo_priv_offset;
 
if (!args->devices || !args->bos || !args->priv_data)
return -EINVAL;
@@ -1994,38 +1994,34 @@ static int criu_checkpoint(struct file *filep,
if (ret)
goto exit_unlock;
 
-   ret = criu_checkpoint_bos(p, num_bos, (uint8_t __user *)args->bos,
-   (uint8_t __user *)args->priv_data, &priv_offset);
-   if (ret)
-   goto exit_unlock;
+   /* Leave room for BOs in the private data. They need to be restored
+* before events, but we checkpoint them last to simplify the error
+* handling.
+*/
+   bo_priv_offset = priv_offset;
+   priv_offset += num_bos * sizeof(struct kfd_criu_bo_priv_data);
 
if (num_objects) {
ret = kfd_criu_checkpoint_queues(p, (uint8_t __user 
*)args->priv_data,
 &priv_offset);
if (ret)
-   goto close_bo_fds;
+   goto exit_unlock;
 
ret = kfd_criu_checkpoint_events(p, (uint8_t __user 
*)args->priv_data,
 &priv_offset);
if (ret)
-   goto close_bo_fds;
+   goto exit_unlock;
 
ret = kfd_criu_checkpoint_svm(p, (uint8_t __user 
*)args->priv_data, &priv_offset);
if (ret)
-   goto close_bo_fds;
+   goto exit_unlock;
}
 
-close_bo_fds:
-   if (ret) {
-   /* If IOCTL returns err, user assumes all FDs opened in 
criu_dump_bos are closed */
-   uint32_t i;
-   struct kfd_criu_bo_bucket *bo_buckets = (struct 
kfd_criu_bo_bucket *) args->bos;
-
-   for (i = 0; i < num_bos; i++) {
-   if (bo_buckets[i].alloc_flags & 
KFD_IOC_ALLOC_MEM_FLAGS_VRAM)
-   close_fd(bo_buckets[i].dmabuf_fd);
-   }
-   }
+   /* This must be the last thing in this function that can fail.
+* Otherwise we leak dmabuf file descriptors.
+*/
+   ret = criu_checkpoint_bos(p, num_bos, (uint8_t __user *)args->bos,
+  (uint8_t __user *)args->priv_data, &bo_priv_offset);
 
 exit_unlock:
mutex_unlock(&p->mutex);
-- 
2.32.0



Re: [PATCH] drm/amdgpu: workaround for TLB seq race

2022-11-03 Thread Philip Yang



On 2022-11-02 10:58, Christian König wrote:

It can happen that we query the sequence value before the callback
had a chance to run.

Work around that by grabbing the fence lock and releasing it again.
Should be replaced by hw handling soon.


kfd_flush_tlb is always called after waiting for map/unmap to GPU fence 
signalled, that means the callback is already executed and the sequence 
is increased if tlb flush is needed, so no such race from KFD.


I am not sure but seems the race does exist for amdgpu to grab vm and 
schedule job.


Acked-by: Philip Yang 


Signed-off-by: Christian König 
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 15 +++
  1 file changed, 15 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
index 9ecb7f663e19..e51a46c9582b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
@@ -485,6 +485,21 @@ void amdgpu_debugfs_vm_bo_info(struct amdgpu_vm *vm, 
struct seq_file *m);
   */
  static inline uint64_t amdgpu_vm_tlb_seq(struct amdgpu_vm *vm)
  {
+   unsigned long flags;
+   spinlock_t *lock;
+
+   /*
+* Work around to stop racing between the fence signaling and handling
+* the cb. The lock is static after initially setting it up, just make
+* sure that the dma_fence structure isn't freed up.
+*/
+   rcu_read_lock();
+   lock = vm->last_tlb_flush->lock;
+   rcu_read_unlock();
+
+   spin_lock_irqsave(lock, flags);
+   spin_unlock_irqrestore(lock, flags);
+
return atomic64_read(&vm->tlb_seq);
  }
  


[PATCH] drm/amd/display: don't enable DRM CRTC degamma property for DCE

2022-11-03 Thread Melissa Wen
DM maps DRM CRTC degamma to DPP (pre-blending) degamma block, but DCE doesn't
support programmable degamma curve anywhere. Currently, a custom degamma is
accepted by DM but just ignored by DCE driver and degamma correction isn't
actually applied. There is no way to map custom degamma in DCE, therefore, DRM
CRTC degamma property shouldn't be enabled for DCE drivers.

Signed-off-by: Melissa Wen 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c
index 9ac2805c5d63..b3eadfc61555 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c
@@ -415,7 +415,7 @@ int amdgpu_dm_crtc_init(struct amdgpu_display_manager *dm,
 {
struct amdgpu_crtc *acrtc = NULL;
struct drm_plane *cursor_plane;
-
+   bool is_dcn;
int res = -ENOMEM;
 
cursor_plane = kzalloc(sizeof(*cursor_plane), GFP_KERNEL);
@@ -453,8 +453,14 @@ int amdgpu_dm_crtc_init(struct amdgpu_display_manager *dm,
acrtc->otg_inst = -1;
 
dm->adev->mode_info.crtcs[crtc_index] = acrtc;
-   drm_crtc_enable_color_mgmt(&acrtc->base, MAX_COLOR_LUT_ENTRIES,
+
+   /* Don't enable DRM CRTC degamma property for DCE since it doesn't
+* support programmable degamma anywhere.
+*/
+   is_dcn = dm->adev->dm.dc->caps.color.dpp.dcn_arch;
+   drm_crtc_enable_color_mgmt(&acrtc->base, is_dcn ? MAX_COLOR_LUT_ENTRIES 
: 0,
   true, MAX_COLOR_LUT_ENTRIES);
+
drm_mode_crtc_set_gamma_size(&acrtc->base, 
MAX_COLOR_LEGACY_LUT_ENTRIES);
 
return 0;
-- 
2.35.1



[linux-next:master] BUILD SUCCESS WITH WARNING 81214a573d19ae2fa5b528286ba23cd1cb17feec

2022-11-03 Thread kernel test robot
tree/branch: 
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
branch HEAD: 81214a573d19ae2fa5b528286ba23cd1cb17feec  Add linux-next specific 
files for 20221103

Warning: (recently discovered and may have been fixed)

drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc.c:4878: warning: This comment 
starts with '/**', but isn't a kernel-doc comment. Refer 
Documentation/doc-guide/kernel-doc.rst
drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_link_dp.c:5044:24: warning: 
implicit conversion from 'enum ' to 'enum dc_status' 
[-Wenum-conversion]

Warning ids grouped by kconfigs:

gcc_recent_errors
|-- alpha-allyesconfig
|   |-- 
drivers-gpu-drm-amd-amdgpu-..-display-dc-core-dc.c:warning:This-comment-starts-with-but-isn-t-a-kernel-doc-comment.-Refer-Documentation-doc-guide-kernel-doc.rst
|   `-- 
drivers-gpu-drm-amd-amdgpu-..-display-dc-core-dc_link_dp.c:warning:implicit-conversion-from-enum-anonymous-to-enum-dc_status
|-- arc-allyesconfig
|   |-- 
drivers-gpu-drm-amd-amdgpu-..-display-dc-core-dc.c:warning:This-comment-starts-with-but-isn-t-a-kernel-doc-comment.-Refer-Documentation-doc-guide-kernel-doc.rst
|   `-- 
drivers-gpu-drm-amd-amdgpu-..-display-dc-core-dc_link_dp.c:warning:implicit-conversion-from-enum-anonymous-to-enum-dc_status
|-- arm-allyesconfig
|   |-- 
drivers-gpu-drm-amd-amdgpu-..-display-dc-core-dc.c:warning:This-comment-starts-with-but-isn-t-a-kernel-doc-comment.-Refer-Documentation-doc-guide-kernel-doc.rst
|   `-- 
drivers-gpu-drm-amd-amdgpu-..-display-dc-core-dc_link_dp.c:warning:implicit-conversion-from-enum-anonymous-to-enum-dc_status
|-- arm64-allyesconfig
|   |-- 
drivers-gpu-drm-amd-amdgpu-..-display-dc-core-dc.c:warning:This-comment-starts-with-but-isn-t-a-kernel-doc-comment.-Refer-Documentation-doc-guide-kernel-doc.rst
|   `-- 
drivers-gpu-drm-amd-amdgpu-..-display-dc-core-dc_link_dp.c:warning:implicit-conversion-from-enum-anonymous-to-enum-dc_status
|-- csky-randconfig-r003-20221103
|   |-- 
drivers-gpu-drm-amd-amdgpu-..-display-dc-core-dc.c:warning:This-comment-starts-with-but-isn-t-a-kernel-doc-comment.-Refer-Documentation-doc-guide-kernel-doc.rst
|   `-- 
drivers-gpu-drm-amd-amdgpu-..-display-dc-core-dc_link_dp.c:warning:implicit-conversion-from-enum-anonymous-to-enum-dc_status
|-- i386-allyesconfig
|   |-- 
drivers-gpu-drm-amd-amdgpu-..-display-dc-core-dc.c:warning:This-comment-starts-with-but-isn-t-a-kernel-doc-comment.-Refer-Documentation-doc-guide-kernel-doc.rst
|   `-- 
drivers-gpu-drm-amd-amdgpu-..-display-dc-core-dc_link_dp.c:warning:implicit-conversion-from-enum-anonymous-to-enum-dc_status
|-- ia64-allmodconfig
|   |-- 
drivers-gpu-drm-amd-amdgpu-..-display-dc-core-dc.c:warning:This-comment-starts-with-but-isn-t-a-kernel-doc-comment.-Refer-Documentation-doc-guide-kernel-doc.rst
|   `-- 
drivers-gpu-drm-amd-amdgpu-..-display-dc-core-dc_link_dp.c:warning:implicit-conversion-from-enum-anonymous-to-enum-dc_status
|-- mips-allyesconfig
|   |-- 
drivers-gpu-drm-amd-amdgpu-..-display-dc-core-dc.c:warning:This-comment-starts-with-but-isn-t-a-kernel-doc-comment.-Refer-Documentation-doc-guide-kernel-doc.rst
|   `-- 
drivers-gpu-drm-amd-amdgpu-..-display-dc-core-dc_link_dp.c:warning:implicit-conversion-from-enum-anonymous-to-enum-dc_status
|-- openrisc-randconfig-r002-20221103
|   |-- 
drivers-gpu-drm-amd-amdgpu-..-display-dc-core-dc.c:warning:This-comment-starts-with-but-isn-t-a-kernel-doc-comment.-Refer-Documentation-doc-guide-kernel-doc.rst
|   `-- 
drivers-gpu-drm-amd-amdgpu-..-display-dc-core-dc_link_dp.c:warning:implicit-conversion-from-enum-anonymous-to-enum-dc_status
|-- powerpc-allmodconfig
|   |-- 
drivers-gpu-drm-amd-amdgpu-..-display-dc-core-dc.c:warning:This-comment-starts-with-but-isn-t-a-kernel-doc-comment.-Refer-Documentation-doc-guide-kernel-doc.rst
|   `-- 
drivers-gpu-drm-amd-amdgpu-..-display-dc-core-dc_link_dp.c:warning:implicit-conversion-from-enum-anonymous-to-enum-dc_status
|-- s390-allyesconfig
|   |-- 
drivers-gpu-drm-amd-amdgpu-..-display-dc-core-dc.c:warning:This-comment-starts-with-but-isn-t-a-kernel-doc-comment.-Refer-Documentation-doc-guide-kernel-doc.rst
|   `-- 
drivers-gpu-drm-amd-amdgpu-..-display-dc-core-dc_link_dp.c:warning:implicit-conversion-from-enum-anonymous-to-enum-dc_status
|-- sparc-allyesconfig
|   |-- 
drivers-gpu-drm-amd-amdgpu-..-display-dc-core-dc.c:warning:This-comment-starts-with-but-isn-t-a-kernel-doc-comment.-Refer-Documentation-doc-guide-kernel-doc.rst
|   `-- 
drivers-gpu-drm-amd-amdgpu-..-display-dc-core-dc_link_dp.c:warning:implicit-conversion-from-enum-anonymous-to-enum-dc_status
`-- x86_64-allyesconfig
|-- 
drivers-gpu-drm-amd-amdgpu-..-display-dc-core-dc.c:warning:This-comment-starts-with-but-isn-t-a-kernel-doc-comment.-Refer-Documentation-doc-guide-kernel-doc.rst
`-- 
drivers-gpu-drm-amd-amdgpu-..-display-dc-core-dc_link_dp.c:warning:implicit-conversion-from-enum-anonymous-to-enum-dc_status

elapsed time: 721m

configs tested: 59
configs ski

Re: drm/amdgpu: workaround for TLB seq race

2022-11-03 Thread Limonciello, Mario

On 11/2/2022 09:58, Christian König wrote:

It can happen that we query the sequence value before the callback
had a chance to run.

Work around that by grabbing the fence lock and releasing it again.
Should be replaced by hw handling soon.

Signed-off-by: Christian König 
Acked-by: Alex Deucher 


You probably also want to add these tags:

Fixes: 5255e146c99a6 ("drm/amdgpu: rework TLB flushing")
Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2113


---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 15 +++
  1 file changed, 15 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
index 9ecb7f663e19..e51a46c9582b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
@@ -485,6 +485,21 @@ void amdgpu_debugfs_vm_bo_info(struct amdgpu_vm *vm, 
struct seq_file *m);
   */
  static inline uint64_t amdgpu_vm_tlb_seq(struct amdgpu_vm *vm)
  {
+   unsigned long flags;
+   spinlock_t *lock;
+
+   /*
+* Work around to stop racing between the fence signaling and handling
+* the cb. The lock is static after initially setting it up, just make
+* sure that the dma_fence structure isn't freed up.
+*/
+   rcu_read_lock();
+   lock = vm->last_tlb_flush->lock;
+   rcu_read_unlock();
+
+   spin_lock_irqsave(lock, flags);
+   spin_unlock_irqrestore(lock, flags);
+
return atomic64_read(&vm->tlb_seq);
  }
  


[PATCH] drm/amdgpu: workaround for TLB seq race

2022-11-03 Thread Stefan Springer
Looking good after 24+hrs of use
Tested-by: Stefan Springer 


drm/amdgpu: workaround for TLB seq race

2022-11-03 Thread Stefan Springer
Tested-by: Stefan Springer 


[PATCH v3 15/23] drm/fb-helper: Disconnect damage worker from update logic

2022-11-03 Thread Thomas Zimmermann
The fbdev helpers implement a damage worker that forwards fbdev
updates to the DRM driver. The worker's update logic depends on
the generic fbdev emulation. Separate the two via function pointer.

The generic fbdev emulation sets struct drm_fb_helper_funcs.fb_dirty,
a new callback that hides the update logic from the damage worker.
It's not possible to use the generic logic with other fbdev emulation,
because it contains additional code for the shadow buffering that
the generic emulation employs.

DRM drivers with internal fbdev emulation can set fb_dirty to their
own implementation if they require damage handling; although no such
drivers currently exist.

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Javier Martinez Canillas 
---
 drivers/gpu/drm/drm_fb_helper.c | 75 -
 include/drm/drm_fb_helper.h | 15 +++
 2 files changed, 61 insertions(+), 29 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index bfbb2af144060..f6d22cc4cd876 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -448,35 +448,24 @@ static int drm_fb_helper_damage_blit(struct drm_fb_helper 
*fb_helper,
 
 static void drm_fb_helper_damage_work(struct work_struct *work)
 {
-   struct drm_fb_helper *helper = container_of(work, struct drm_fb_helper,
-   damage_work);
-   struct drm_device *dev = helper->dev;
+   struct drm_fb_helper *helper = container_of(work, struct drm_fb_helper, 
damage_work);
struct drm_clip_rect *clip = &helper->damage_clip;
struct drm_clip_rect clip_copy;
unsigned long flags;
int ret;
 
+   if (!helper->funcs->fb_dirty)
+   return;
+
spin_lock_irqsave(&helper->damage_lock, flags);
clip_copy = *clip;
clip->x1 = clip->y1 = ~0;
clip->x2 = clip->y2 = 0;
spin_unlock_irqrestore(&helper->damage_lock, flags);
 
-   /* Call damage handlers only if necessary */
-   if (!(clip_copy.x1 < clip_copy.x2 && clip_copy.y1 < clip_copy.y2))
-   return;
-
-   if (helper->buffer) {
-   ret = drm_fb_helper_damage_blit(helper, &clip_copy);
-   if (drm_WARN_ONCE(dev, ret, "Damage blitter failed: ret=%d\n", 
ret))
-   goto err;
-   }
-
-   if (helper->fb->funcs->dirty) {
-   ret = helper->fb->funcs->dirty(helper->fb, NULL, 0, 0, 
&clip_copy, 1);
-   if (drm_WARN_ONCE(dev, ret, "Dirty helper failed: ret=%d\n", 
ret))
-   goto err;
-   }
+   ret = helper->funcs->fb_dirty(helper, &clip_copy);
+   if (ret)
+   goto err;
 
return;
 
@@ -670,16 +659,6 @@ void drm_fb_helper_fini(struct drm_fb_helper *fb_helper)
 }
 EXPORT_SYMBOL(drm_fb_helper_fini);
 
-static bool drm_fbdev_use_shadow_fb(struct drm_fb_helper *fb_helper)
-{
-   struct drm_device *dev = fb_helper->dev;
-   struct drm_framebuffer *fb = fb_helper->fb;
-
-   return dev->mode_config.prefer_shadow_fbdev ||
-  dev->mode_config.prefer_shadow ||
-  fb->funcs->dirty;
-}
-
 static void drm_fb_helper_damage(struct fb_info *info, u32 x, u32 y,
 u32 width, u32 height)
 {
@@ -687,7 +666,7 @@ static void drm_fb_helper_damage(struct fb_info *info, u32 
x, u32 y,
struct drm_clip_rect *clip = &helper->damage_clip;
unsigned long flags;
 
-   if (!drm_fbdev_use_shadow_fb(helper))
+   if (!helper->funcs->fb_dirty)
return;
 
spin_lock_irqsave(&helper->damage_lock, flags);
@@ -2111,6 +2090,16 @@ void drm_fb_helper_output_poll_changed(struct drm_device 
*dev)
 }
 EXPORT_SYMBOL(drm_fb_helper_output_poll_changed);
 
+static bool drm_fbdev_use_shadow_fb(struct drm_fb_helper *fb_helper)
+{
+   struct drm_device *dev = fb_helper->dev;
+   struct drm_framebuffer *fb = fb_helper->fb;
+
+   return dev->mode_config.prefer_shadow_fbdev ||
+  dev->mode_config.prefer_shadow ||
+  fb->funcs->dirty;
+}
+
 /* @user: 1=userspace, 0=fbcon */
 static int drm_fbdev_fb_open(struct fb_info *info, int user)
 {
@@ -2487,8 +2476,36 @@ static int drm_fb_helper_generic_probe(struct 
drm_fb_helper *fb_helper,
return 0;
 }
 
+static int drm_fbdev_fb_dirty(struct drm_fb_helper *helper, struct 
drm_clip_rect *clip)
+{
+   struct drm_device *dev = helper->dev;
+   int ret;
+
+   if (!drm_fbdev_use_shadow_fb(helper))
+   return 0;
+
+   /* Call damage handlers only if necessary */
+   if (!(clip->x1 < clip->x2 && clip->y1 < clip->y2))
+   return 0;
+
+   if (helper->buffer) {
+   ret = drm_fb_helper_damage_blit(helper, clip);
+   if (drm_WARN_ONCE(dev, ret, "Damage blitter failed: ret=%d\n", 
ret))
+   return ret;
+   }
+
+   if (helper->fb->funcs->dirty) {
+   ret 

[PATCH v3 17/23] drm/fb-helper: Perform all fbdev I/O with the same implementation

2022-11-03 Thread Thomas Zimmermann
Implement the fbdev's read/write helpers with the same functions. Use
the generic fbdev's code as template. Convert all drivers.

DRM's fb helpers must implement regular I/O functionality in struct
fb_ops and possibly perform a damage update. Handle all this in the
same functions and convert drivers. The functionality has been used
as part of the generic fbdev code for some time. The drivers don't
set struct drm_fb_helper.fb_dirty, so they will not be affected by
damage handling.

For I/O memory, fb helpers now provide drm_fb_helper_cfb_read() and
drm_fb_helper_cfb_write(). Several drivers require these. Until now
tegra used I/O read and write, although the memory buffer appears to
be in system memory. So use _sys_ helpers now.

v3:
* fix docs (Javier)
v2:
* rebase onto vmwgfx changes

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Javier Martinez Canillas 
---
 drivers/gpu/drm/armada/armada_fbdev.c  |   2 +
 drivers/gpu/drm/drm_fb_helper.c| 383 -
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c  |   2 +
 drivers/gpu/drm/gma500/framebuffer.c   |   2 +
 drivers/gpu/drm/i915/display/intel_fbdev.c |   2 +
 drivers/gpu/drm/radeon/radeon_fb.c |   2 +
 drivers/gpu/drm/tegra/fb.c |   2 +
 include/drm/drm_fb_helper.h|  17 +
 8 files changed, 254 insertions(+), 158 deletions(-)

diff --git a/drivers/gpu/drm/armada/armada_fbdev.c 
b/drivers/gpu/drm/armada/armada_fbdev.c
index f02f6a5ba8320..584cee123bd8e 100644
--- a/drivers/gpu/drm/armada/armada_fbdev.c
+++ b/drivers/gpu/drm/armada/armada_fbdev.c
@@ -19,6 +19,8 @@
 static const struct fb_ops armada_fb_ops = {
.owner  = THIS_MODULE,
DRM_FB_HELPER_DEFAULT_OPS,
+   .fb_read= drm_fb_helper_cfb_read,
+   .fb_write   = drm_fb_helper_cfb_write,
.fb_fillrect= drm_fb_helper_cfb_fillrect,
.fb_copyarea= drm_fb_helper_cfb_copyarea,
.fb_imageblit   = drm_fb_helper_cfb_imageblit,
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 379e0d2f67198..c7c0c0a8532b4 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -747,30 +747,132 @@ void drm_fb_helper_deferred_io(struct fb_info *info, 
struct list_head *pagerefli
 }
 EXPORT_SYMBOL(drm_fb_helper_deferred_io);
 
+typedef ssize_t (*drm_fb_helper_read_screen)(struct fb_info *info, char __user 
*buf,
+size_t count, loff_t pos);
+
+static ssize_t __drm_fb_helper_read(struct fb_info *info, char __user *buf, 
size_t count,
+   loff_t *ppos, drm_fb_helper_read_screen 
read_screen)
+{
+   loff_t pos = *ppos;
+   size_t total_size;
+   ssize_t ret;
+
+   if (info->screen_size)
+   total_size = info->screen_size;
+   else
+   total_size = info->fix.smem_len;
+
+   if (pos >= total_size)
+   return 0;
+   if (count >= total_size)
+   count = total_size;
+   if (total_size - count < pos)
+   count = total_size - pos;
+
+   if (info->fbops->fb_sync)
+   info->fbops->fb_sync(info);
+
+   ret = read_screen(info, buf, count, pos);
+   if (ret > 0)
+   *ppos += ret;
+
+   return ret;
+}
+
+typedef ssize_t (*drm_fb_helper_write_screen)(struct fb_info *info, const char 
__user *buf,
+ size_t count, loff_t pos);
+
+static ssize_t __drm_fb_helper_write(struct fb_info *info, const char __user 
*buf, size_t count,
+loff_t *ppos, drm_fb_helper_write_screen 
write_screen)
+{
+   loff_t pos = *ppos;
+   size_t total_size;
+   ssize_t ret;
+   int err = 0;
+
+   if (info->screen_size)
+   total_size = info->screen_size;
+   else
+   total_size = info->fix.smem_len;
+
+   if (pos > total_size)
+   return -EFBIG;
+   if (count > total_size) {
+   err = -EFBIG;
+   count = total_size;
+   }
+   if (total_size - count < pos) {
+   if (!err)
+   err = -ENOSPC;
+   count = total_size - pos;
+   }
+
+   if (info->fbops->fb_sync)
+   info->fbops->fb_sync(info);
+
+   /*
+* Copy to framebuffer even if we already logged an error. Emulates
+* the behavior of the original fbdev implementation.
+*/
+   ret = write_screen(info, buf, count, pos);
+   if (ret < 0)
+   return ret; /* return last error, if any */
+   else if (!ret)
+   return err; /* return previous error, if any */
+
+   *ppos += ret;
+
+   return ret;
+}
+
+static ssize_t drm_fb_helper_read_screen_buffer(struct fb_info *info, char 
__user *buf,
+   size_t count, loff_t pos)
+{
+   const char *src = info->screen_buffer +

[PATCH v3 23/23] drm/fb-helper: Clarify use of last_close and output_poll_changed

2022-11-03 Thread Thomas Zimmermann
Clarify documentation in the use of struct drm_driver.last_close and
struct drm_mode_config_funcs.output_poll_changed. Those callbacks should
not be said for fbdev implementations on top of struct drm_client_funcs.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/drm_fb_helper.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 5eb2f0d4bf8d4..e0384f967c0b3 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -89,11 +89,13 @@ static DEFINE_MUTEX(kernel_fb_helper_lock);
  * It will automatically set up deferred I/O if the driver requires a shadow
  * buffer.
  *
- * At runtime drivers should restore the fbdev console by using
+ * Existing fbdev implementations should restore the fbdev console by using
  * drm_fb_helper_lastclose() as their &drm_driver.lastclose callback.
  * They should also notify the fb helper code from updates to the output
  * configuration by using drm_fb_helper_output_poll_changed() as their
- * &drm_mode_config_funcs.output_poll_changed callback.
+ * &drm_mode_config_funcs.output_poll_changed callback. New implementations
+ * of fbdev should be build on top of struct &drm_client_funcs, which handles
+ * this automatically. Setting the old callbacks should be avoided.
  *
  * For suspend/resume consider using drm_mode_config_helper_suspend() and
  * drm_mode_config_helper_resume() which takes care of fbdev as well.
-- 
2.38.0



[PATCH v3 16/23] drm/fb-helper: Call fb_sync in I/O functions

2022-11-03 Thread Thomas Zimmermann
Call struct fb_ops.fb_sync in drm_fbdev_{read,write}() to mimic the
behavior of fbdev. Fbdev implementations of fb_read and fb_write in
struct fb_ops invoke fb_sync to synchronize with outstanding operations
before I/O. Doing the same in DRM implementations will allow us to use
them throughout DRM drivers.

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Javier Martinez Canillas 
---
 drivers/gpu/drm/drm_fb_helper.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index f6d22cc4cd876..379e0d2f67198 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -2246,6 +2246,9 @@ static ssize_t drm_fbdev_fb_read(struct fb_info *info, 
char __user *buf,
if (total_size - count < pos)
count = total_size - pos;
 
+   if (info->fbops->fb_sync)
+   info->fbops->fb_sync(info);
+
if (drm_fbdev_use_iomem(info))
ret = fb_read_screen_base(info, buf, count, pos);
else
@@ -2327,6 +2330,9 @@ static ssize_t drm_fbdev_fb_write(struct fb_info *info, 
const char __user *buf,
count = total_size - pos;
}
 
+   if (info->fbops->fb_sync)
+   info->fbops->fb_sync(info);
+
/*
 * Copy to framebuffer even if we already logged an error. Emulates
 * the behavior of the original fbdev implementation.
-- 
2.38.0



[PATCH v3 07/23] drm/logicvc: Don't set struct drm_driver.output_poll_changed

2022-11-03 Thread Thomas Zimmermann
Don't set struct drm_driver.output_poll_changed. It's used to restore
the fbdev console. But as logicvc uses generic fbdev emulation, the
console is being restored by the DRM client helpers already. See the
functions drm_kms_helper_hotplug_event() and
drm_kms_helper_connector_hotplug_event() in drm_probe_helper.c.

v2:
* fix commit description (Christian)

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Javier Martinez Canillas 
---
 drivers/gpu/drm/logicvc/logicvc_mode.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/logicvc/logicvc_mode.c 
b/drivers/gpu/drm/logicvc/logicvc_mode.c
index d8207ffda1af9..9971950ebd4ee 100644
--- a/drivers/gpu/drm/logicvc/logicvc_mode.c
+++ b/drivers/gpu/drm/logicvc/logicvc_mode.c
@@ -10,7 +10,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -26,7 +25,6 @@
 
 static const struct drm_mode_config_funcs logicvc_mode_config_funcs = {
.fb_create  = drm_gem_fb_create,
-   .output_poll_changed= drm_fb_helper_output_poll_changed,
.atomic_check   = drm_atomic_helper_check,
.atomic_commit  = drm_atomic_helper_commit,
 };
-- 
2.38.0



[PATCH v3 19/23] drm/fb-helper: Always initialize generic fbdev emulation

2022-11-03 Thread Thomas Zimmermann
Initialize the generic fbdev emulation even if it has been disabled
on the kernel command line. The hotplug and mode initialization will
fail accordingly.

The kernel parameter can still be changed at runtime and the emulation
will initialize after hotplugging the connector.

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Javier Martinez Canillas 
---
 drivers/gpu/drm/drm_fb_helper.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 3dfda1e3830b3..95f389433c4a6 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -526,11 +526,6 @@ int drm_fb_helper_init(struct drm_device *dev,
 {
int ret;
 
-   if (!drm_fbdev_emulation) {
-   dev->fb_helper = fb_helper;
-   return 0;
-   }
-
/*
 * If this is not the generic fbdev client, initialize a drm_client
 * without callbacks so we can use the modesets.
@@ -2716,9 +2711,6 @@ void drm_fbdev_generic_setup(struct drm_device *dev,
drm_WARN(dev, !dev->registered, "Device has not been registered.\n");
drm_WARN(dev, dev->fb_helper, "fb_helper is already set!\n");
 
-   if (!drm_fbdev_emulation)
-   return;
-
fb_helper = kzalloc(sizeof(*fb_helper), GFP_KERNEL);
if (!fb_helper) {
drm_err(dev, "Failed to allocate fb_helper\n");
-- 
2.38.0



[PATCH v3 22/23] drm/fb-helper: Remove unnecessary include statements

2022-11-03 Thread Thomas Zimmermann
Remove include statements for  where it is not
required (i.e., most of them). In a few places include other header
files that are required by the source code.

v3:
* fix amdgpu include statements
* fix rockchip include statements

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Javier Martinez Canillas 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c  | 1 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c  | 1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h| 1 -
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c  | 1 +
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c  | 1 +
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c   | 1 +
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c   | 1 +
 drivers/gpu/drm/arm/hdlcd_crtc.c| 1 -
 drivers/gpu/drm/ast/ast_drv.h   | 1 -
 drivers/gpu/drm/bridge/tc358762.c   | 2 +-
 drivers/gpu/drm/drm_crtc_helper.c   | 1 -
 drivers/gpu/drm/drm_gem_framebuffer_helper.c| 1 -
 drivers/gpu/drm/drm_probe_helper.c  | 1 -
 drivers/gpu/drm/etnaviv/etnaviv_drv.h   | 3 ++-
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h | 1 -
 drivers/gpu/drm/hyperv/hyperv_drm_modeset.c | 1 -
 drivers/gpu/drm/imx/imx-ldb.c   | 2 +-
 drivers/gpu/drm/imx/imx-tve.c   | 1 -
 drivers/gpu/drm/imx/parallel-display.c  | 2 +-
 drivers/gpu/drm/kmb/kmb_plane.c | 1 -
 drivers/gpu/drm/mgag200/mgag200_drv.h   | 1 -
 drivers/gpu/drm/qxl/qxl_drv.h   | 1 -
 drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 2 +-
 drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 1 +
 drivers/gpu/drm/tidss/tidss_kms.c   | 1 -
 drivers/gpu/drm/v3d/v3d_drv.c   | 1 -
 drivers/gpu/drm/vboxvideo/vbox_main.c   | 1 -
 drivers/gpu/drm/virtio/virtgpu_drv.h| 1 -
 drivers/gpu/drm/xen/xen_drm_front_gem.c | 1 -
 31 files changed, 14 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
index 491d4846fc02c..e1320edfc5274 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
@@ -26,7 +26,6 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include "amdgpu.h"
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index ddaecb2610c94..56a031a2e087e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -37,6 +37,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index dd6f9ae6fbe9f..311a8ea6f0654 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -39,8 +39,8 @@
 #include 
 #include 
 #include 
-#include 
 #include 
+#include 
 #include 
 #include 
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index bf1ff8f0e7120..e3a18f069ce5e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -29,6 +29,7 @@
 #include "amdgpu.h"
 #include 
 #include 
+#include 
 #include "amdgpu_uvd.h"
 #include "amdgpu_vce.h"
 #include "atom.h"
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
index 37322550d7508..8a39300b1a845 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
@@ -36,7 +36,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
index 05051d5d2ec31..90f87b2d985b5 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
@@ -21,6 +21,7 @@
  *
  */
 
+#include 
 #include 
 #include 
 
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c 
b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
index c928bc9eb2026..0352de72c886a 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
@@ -21,6 +21,7 @@
  *
  */
 
+#include 
 #include 
 #include 
 
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c 
b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
index 62315fd5a05f2..07bd16e820461 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
@@ -23,6 +23,7 @@
 
 #include 
 
+#include 
 #include 
 #include 
 
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c 
b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
index 87d5e4c21cb37..d73df100f2b3b 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
@@ -21,6 +21,7 @@
  *
  */
 
+#include 
 #include 
 #include 
 
diff --git a/driv

[PATCH v3 14/23] drm/fb-helper: Rename drm_fb_helper_unregister_fbi() to use _info postfix

2022-11-03 Thread Thomas Zimmermann
Rename drm_fb_helper_unregister_fbi() to drm_fb_helper_unregister_info()
as part of unifying the naming within fbdev helpers. Adapt drivers. No
functional changes.

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Javier Martinez Canillas 
---
 drivers/gpu/drm/armada/armada_fbdev.c  | 2 +-
 drivers/gpu/drm/drm_fb_helper.c| 8 
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c  | 2 +-
 drivers/gpu/drm/gma500/framebuffer.c   | 2 +-
 drivers/gpu/drm/i915/display/intel_fbdev.c | 2 +-
 drivers/gpu/drm/msm/msm_fbdev.c| 2 +-
 drivers/gpu/drm/nouveau/nouveau_fbcon.c| 2 +-
 drivers/gpu/drm/omapdrm/omap_fbdev.c   | 2 +-
 drivers/gpu/drm/radeon/radeon_fb.c | 2 +-
 drivers/gpu/drm/tegra/fb.c | 2 +-
 include/drm/drm_fb_helper.h| 4 ++--
 11 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/armada/armada_fbdev.c 
b/drivers/gpu/drm/armada/armada_fbdev.c
index eaae98d9377ae..f02f6a5ba8320 100644
--- a/drivers/gpu/drm/armada/armada_fbdev.c
+++ b/drivers/gpu/drm/armada/armada_fbdev.c
@@ -155,7 +155,7 @@ void armada_fbdev_fini(struct drm_device *dev)
struct drm_fb_helper *fbh = priv->fbdev;
 
if (fbh) {
-   drm_fb_helper_unregister_fbi(fbh);
+   drm_fb_helper_unregister_info(fbh);
 
drm_fb_helper_fini(fbh);
 
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 881e6a04fa706..bfbb2af144060 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -612,19 +612,19 @@ struct fb_info *drm_fb_helper_alloc_info(struct 
drm_fb_helper *fb_helper)
 EXPORT_SYMBOL(drm_fb_helper_alloc_info);
 
 /**
- * drm_fb_helper_unregister_fbi - unregister fb_info framebuffer device
+ * drm_fb_helper_unregister_info - unregister fb_info framebuffer device
  * @fb_helper: driver-allocated fbdev helper, can be NULL
  *
  * A wrapper around unregister_framebuffer, to release the fb_info
  * framebuffer device. This must be called before releasing all resources for
  * @fb_helper by calling drm_fb_helper_fini().
  */
-void drm_fb_helper_unregister_fbi(struct drm_fb_helper *fb_helper)
+void drm_fb_helper_unregister_info(struct drm_fb_helper *fb_helper)
 {
if (fb_helper && fb_helper->info)
unregister_framebuffer(fb_helper->info);
 }
-EXPORT_SYMBOL(drm_fb_helper_unregister_fbi);
+EXPORT_SYMBOL(drm_fb_helper_unregister_info);
 
 /**
  * drm_fb_helper_fini - finialize a &struct drm_fb_helper
@@ -2497,7 +2497,7 @@ static void drm_fbdev_client_unregister(struct 
drm_client_dev *client)
 
if (fb_helper->info)
/* drm_fbdev_fb_destroy() takes care of cleanup */
-   drm_fb_helper_unregister_fbi(fb_helper);
+   drm_fb_helper_unregister_info(fb_helper);
else
drm_fbdev_release(fb_helper);
 }
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c 
b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
index 8741eb0b1b604..86c489d945849 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
@@ -201,7 +201,7 @@ static void exynos_drm_fbdev_destroy(struct drm_device *dev,
drm_framebuffer_remove(fb);
}
 
-   drm_fb_helper_unregister_fbi(fb_helper);
+   drm_fb_helper_unregister_info(fb_helper);
 
drm_fb_helper_fini(fb_helper);
 }
diff --git a/drivers/gpu/drm/gma500/framebuffer.c 
b/drivers/gpu/drm/gma500/framebuffer.c
index 6d0e3bf6435ee..6098d936e44b6 100644
--- a/drivers/gpu/drm/gma500/framebuffer.c
+++ b/drivers/gpu/drm/gma500/framebuffer.c
@@ -383,7 +383,7 @@ static int psb_fbdev_destroy(struct drm_device *dev,
 {
struct drm_framebuffer *fb = fb_helper->fb;
 
-   drm_fb_helper_unregister_fbi(fb_helper);
+   drm_fb_helper_unregister_info(fb_helper);
 
drm_fb_helper_fini(fb_helper);
drm_framebuffer_unregister_private(fb);
diff --git a/drivers/gpu/drm/i915/display/intel_fbdev.c 
b/drivers/gpu/drm/i915/display/intel_fbdev.c
index 05b841343ea3e..1b576c859837b 100644
--- a/drivers/gpu/drm/i915/display/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/display/intel_fbdev.c
@@ -584,7 +584,7 @@ void intel_fbdev_unregister(struct drm_i915_private 
*dev_priv)
if (!current_is_async())
intel_fbdev_sync(ifbdev);
 
-   drm_fb_helper_unregister_fbi(&ifbdev->helper);
+   drm_fb_helper_unregister_info(&ifbdev->helper);
 }
 
 void intel_fbdev_fini(struct drm_i915_private *dev_priv)
diff --git a/drivers/gpu/drm/msm/msm_fbdev.c b/drivers/gpu/drm/msm/msm_fbdev.c
index 4d9a0fcbf95b6..31e1e30cb52a2 100644
--- a/drivers/gpu/drm/msm/msm_fbdev.c
+++ b/drivers/gpu/drm/msm/msm_fbdev.c
@@ -182,7 +182,7 @@ void msm_fbdev_free(struct drm_device *dev)
 
DBG();
 
-   drm_fb_helper_unregister_fbi(helper);
+   drm_fb_helper_unregister_info(helper);
 
drm_fb_helper_fini(helper);
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c

[PATCH v3 11/23] drm/fb-helper: Cleanup include statements in header file

2022-11-03 Thread Thomas Zimmermann
Only include what we have to.

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Javier Martinez Canillas 
---
 include/drm/drm_fb_helper.h | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index fddd0d1af6891..e923089522896 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -32,11 +32,9 @@
 
 struct drm_fb_helper;
 
-#include 
-#include 
-#include 
 #include 
-#include 
+
+#include 
 
 enum mode_set_atomic {
LEAVE_ATOMIC_MODE_SET,
-- 
2.38.0



[PATCH v3 13/23] drm/fb-helper: Rename drm_fb_helper_alloc_fbi() to use _info postfix

2022-11-03 Thread Thomas Zimmermann
Rename drm_fb_helper_alloc_fbi() to drm_fb_helper_alloc_info() as
part of unifying the naming within fbdev helpers. Adapt drivers. No
functional changes.

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Javier Martinez Canillas 
---
 drivers/gpu/drm/armada/armada_fbdev.c  | 2 +-
 drivers/gpu/drm/drm_fb_helper.c| 8 
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c  | 2 +-
 drivers/gpu/drm/gma500/framebuffer.c   | 2 +-
 drivers/gpu/drm/i915/display/intel_fbdev.c | 2 +-
 drivers/gpu/drm/msm/msm_fbdev.c| 2 +-
 drivers/gpu/drm/nouveau/nouveau_fbcon.c| 2 +-
 drivers/gpu/drm/omapdrm/omap_fbdev.c   | 2 +-
 drivers/gpu/drm/radeon/radeon_fb.c | 2 +-
 drivers/gpu/drm/tegra/fb.c | 2 +-
 include/drm/drm_fb_helper.h| 4 ++--
 11 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/armada/armada_fbdev.c 
b/drivers/gpu/drm/armada/armada_fbdev.c
index 38f5170c0fea6..eaae98d9377ae 100644
--- a/drivers/gpu/drm/armada/armada_fbdev.c
+++ b/drivers/gpu/drm/armada/armada_fbdev.c
@@ -72,7 +72,7 @@ static int armada_fbdev_create(struct drm_fb_helper *fbh,
if (IS_ERR(dfb))
return PTR_ERR(dfb);
 
-   info = drm_fb_helper_alloc_fbi(fbh);
+   info = drm_fb_helper_alloc_info(fbh);
if (IS_ERR(info)) {
ret = PTR_ERR(info);
goto err_fballoc;
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 480bf4f568b7b..881e6a04fa706 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -558,7 +558,7 @@ int drm_fb_helper_init(struct drm_device *dev,
 EXPORT_SYMBOL(drm_fb_helper_init);
 
 /**
- * drm_fb_helper_alloc_fbi - allocate fb_info and some of its members
+ * drm_fb_helper_alloc_info - allocate fb_info and some of its members
  * @fb_helper: driver-allocated fbdev helper
  *
  * A helper to alloc fb_info and the members cmap and apertures. Called
@@ -570,7 +570,7 @@ EXPORT_SYMBOL(drm_fb_helper_init);
  * fb_info pointer if things went okay, pointer containing error code
  * otherwise
  */
-struct fb_info *drm_fb_helper_alloc_fbi(struct drm_fb_helper *fb_helper)
+struct fb_info *drm_fb_helper_alloc_info(struct drm_fb_helper *fb_helper)
 {
struct device *dev = fb_helper->dev->dev;
struct fb_info *info;
@@ -609,7 +609,7 @@ struct fb_info *drm_fb_helper_alloc_fbi(struct 
drm_fb_helper *fb_helper)
framebuffer_release(info);
return ERR_PTR(ret);
 }
-EXPORT_SYMBOL(drm_fb_helper_alloc_fbi);
+EXPORT_SYMBOL(drm_fb_helper_alloc_info);
 
 /**
  * drm_fb_helper_unregister_fbi - unregister fb_info framebuffer device
@@ -2440,7 +2440,7 @@ static int drm_fb_helper_generic_probe(struct 
drm_fb_helper *fb_helper,
fb_helper->fb = buffer->fb;
fb = buffer->fb;
 
-   fbi = drm_fb_helper_alloc_fbi(fb_helper);
+   fbi = drm_fb_helper_alloc_info(fb_helper);
if (IS_ERR(fbi))
return PTR_ERR(fbi);
 
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c 
b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
index 767afd2bfa822..8741eb0b1b604 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
@@ -63,7 +63,7 @@ static int exynos_drm_fbdev_update(struct drm_fb_helper 
*helper,
unsigned int size = fb->width * fb->height * fb->format->cpp[0];
unsigned long offset;
 
-   fbi = drm_fb_helper_alloc_fbi(helper);
+   fbi = drm_fb_helper_alloc_info(helper);
if (IS_ERR(fbi)) {
DRM_DEV_ERROR(to_dma_dev(helper->dev),
  "failed to allocate fb info.\n");
diff --git a/drivers/gpu/drm/gma500/framebuffer.c 
b/drivers/gpu/drm/gma500/framebuffer.c
index 5f502a0048ab8..6d0e3bf6435ee 100644
--- a/drivers/gpu/drm/gma500/framebuffer.c
+++ b/drivers/gpu/drm/gma500/framebuffer.c
@@ -268,7 +268,7 @@ static int psbfb_create(struct drm_fb_helper *fb_helper,
 
memset(dev_priv->vram_addr + backing->offset, 0, size);
 
-   info = drm_fb_helper_alloc_fbi(fb_helper);
+   info = drm_fb_helper_alloc_info(fb_helper);
if (IS_ERR(info)) {
ret = PTR_ERR(info);
goto err_drm_gem_object_put;
diff --git a/drivers/gpu/drm/i915/display/intel_fbdev.c 
b/drivers/gpu/drm/i915/display/intel_fbdev.c
index d533ecd451025..05b841343ea3e 100644
--- a/drivers/gpu/drm/i915/display/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/display/intel_fbdev.c
@@ -254,7 +254,7 @@ static int intelfb_create(struct drm_fb_helper *helper,
goto out_unlock;
}
 
-   info = drm_fb_helper_alloc_fbi(helper);
+   info = drm_fb_helper_alloc_info(helper);
if (IS_ERR(info)) {
drm_err(&dev_priv->drm, "Failed to allocate fb_info (%pe)\n", 
info);
ret = PTR_ERR(info);
diff --git a/drivers/gpu/drm/msm/msm_fbdev.c b/drivers/gpu/drm/msm/msm_fbdev.c
index b373e30003203..4d9a0fcbf95b6 100644
--- a/drivers/gpu/d

[PATCH v3 20/23] drm/fb-helper: Set flag in struct drm_fb_helper for leaking physical addresses

2022-11-03 Thread Thomas Zimmermann
Uncouple the parameter drm_leak_fbdev_smem from the implementation by
setting a flag in struct drm_fb_helper. This will help to move the
generic fbdev emulation into its own source file, while keeping the
parameter in drm_fb_helper.c. No functional changes.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/drm_fb_helper.c | 10 +++---
 include/drm/drm_fb_helper.h |  2 ++
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 95f389433c4a6..105d9c8fe3250 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -74,7 +74,7 @@ MODULE_PARM_DESC(drm_fbdev_overalloc,
  * considered as a broken and legacy behaviour from a modern fbdev device.
  */
 #if IS_ENABLED(CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM)
-static bool drm_leak_fbdev_smem = false;
+static bool drm_leak_fbdev_smem;
 module_param_unsafe(drm_leak_fbdev_smem, bool, 0600);
 MODULE_PARM_DESC(drm_leak_fbdev_smem,
 "Allow unsafe leaking fbdev physical smem address 
[default=false]");
@@ -1968,6 +1968,10 @@ static int drm_fb_helper_single_fb_probe(struct 
drm_fb_helper *fb_helper,
sizes.surface_height = config->max_height;
}
 
+#if IS_ENABLED(CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM)
+   fb_helper->hint_leak_smem_start = drm_leak_fbdev_smem;
+#endif
+
/* push down into drivers */
ret = (*fb_helper->funcs->fb_probe)(fb_helper, &sizes);
if (ret < 0)
@@ -2165,7 +2169,7 @@ __drm_fb_helper_initial_config_and_unlock(struct 
drm_fb_helper *fb_helper,
info->var.pixclock = 0;
/* Shamelessly allow physical address leaking to userspace */
 #if IS_ENABLED(CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM)
-   if (!drm_leak_fbdev_smem)
+   if (!fb_helper->hint_leak_smem_start)
 #endif
/* don't leak any physical addresses to userspace */
info->flags |= FBINFO_HIDE_SMEM_START;
@@ -2564,7 +2568,7 @@ static int drm_fb_helper_generic_probe(struct 
drm_fb_helper *fb_helper,
 * case.
 */
 #if IS_ENABLED(CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM)
-   if (drm_leak_fbdev_smem && fbi->fix.smem_start == 0 &&
+   if (fb_helper->hint_leak_smem_start && fbi->fix.smem_start == 0 
&&
!drm_WARN_ON_ONCE(dev, map.is_iomem))
fbi->fix.smem_start =
page_to_phys(virt_to_page(fbi->screen_buffer));
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index 6581183618b89..3dfb5d1093871 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -199,6 +199,8 @@ struct drm_fb_helper {
 * See also: @deferred_setup
 */
int preferred_bpp;
+
+   bool hint_leak_smem_start;
 };
 
 static inline struct drm_fb_helper *
-- 
2.38.0



[PATCH v3 09/23] drm/panel-ili9341: Include

2022-11-03 Thread Thomas Zimmermann
Include  for devm_of_find_backlight().

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Javier Martinez Canillas 
---
 drivers/gpu/drm/panel/panel-ilitek-ili9341.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/panel/panel-ilitek-ili9341.c 
b/drivers/gpu/drm/panel/panel-ilitek-ili9341.c
index 39dc40cf681f0..b59472c29a40d 100644
--- a/drivers/gpu/drm/panel/panel-ilitek-ili9341.c
+++ b/drivers/gpu/drm/panel/panel-ilitek-ili9341.c
@@ -18,6 +18,7 @@
  * Copyright 2018 David Lechner 
  */
 
+#include 
 #include 
 #include 
 #include 
-- 
2.38.0



[PATCH v3 05/23] drm/imx/dcss: Don't set struct drm_driver.output_poll_changed

2022-11-03 Thread Thomas Zimmermann
Don't set struct drm_driver.output_poll_changed. It's used to restore
the fbdev console. But as DCSS uses generic fbdev emulation, the
console is being restored by the DRM client helpers already. See the
functions drm_kms_helper_hotplug_event() and
drm_kms_helper_connector_hotplug_event() in drm_probe_helper.c.

v2:
* fix commit description (Christian)

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Javier Martinez Canillas 
---
 drivers/gpu/drm/imx/dcss/dcss-kms.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/imx/dcss/dcss-kms.c 
b/drivers/gpu/drm/imx/dcss/dcss-kms.c
index b4f82ebca5325..1defd6a40f11d 100644
--- a/drivers/gpu/drm/imx/dcss/dcss-kms.c
+++ b/drivers/gpu/drm/imx/dcss/dcss-kms.c
@@ -21,7 +21,6 @@ DEFINE_DRM_GEM_DMA_FOPS(dcss_cma_fops);
 
 static const struct drm_mode_config_funcs dcss_drm_mode_config_funcs = {
.fb_create = drm_gem_fb_create,
-   .output_poll_changed = drm_fb_helper_output_poll_changed,
.atomic_check = drm_atomic_helper_check,
.atomic_commit = drm_atomic_helper_commit,
 };
-- 
2.38.0



[PATCH v3 12/23] drm/fb_helper: Rename field fbdev to info in struct drm_fb_helper

2022-11-03 Thread Thomas Zimmermann
Rename struct drm_fb_helper.fbdev to info. The current name is
misleading as it overlaps with generic fbdev naming conventions.
Adapt to the usual naming in fbdev drivers by calling the field
'info'. No functional changes.

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Javier Martinez Canillas 
---
 drivers/gpu/drm/drm_fb_helper.c| 40 +++---
 drivers/gpu/drm/i915/display/intel_fbdev.c |  2 +-
 drivers/gpu/drm/nouveau/nouveau_fbcon.c| 23 ++---
 drivers/gpu/drm/omapdrm/omap_fbdev.c   |  2 +-
 drivers/gpu/drm/tegra/fb.c |  2 +-
 include/drm/drm_fb_helper.h|  4 +--
 6 files changed, 36 insertions(+), 37 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 71edb80fe0fb9..480bf4f568b7b 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -368,7 +368,7 @@ static void drm_fb_helper_resume_worker(struct work_struct 
*work)
resume_work);
 
console_lock();
-   fb_set_suspend(helper->fbdev, 0);
+   fb_set_suspend(helper->info, 0);
console_unlock();
 }
 
@@ -401,7 +401,7 @@ static void drm_fb_helper_damage_blit_real(struct 
drm_fb_helper *fb_helper,
break;
}
 
-   src = fb_helper->fbdev->screen_buffer + offset;
+   src = fb_helper->info->screen_buffer + offset;
iosys_map_incr(dst, offset); /* go to first pixel within clip rect */
 
for (y = clip->y1; y < clip->y2; y++) {
@@ -598,7 +598,7 @@ struct fb_info *drm_fb_helper_alloc_fbi(struct 
drm_fb_helper *fb_helper)
goto err_free_cmap;
}
 
-   fb_helper->fbdev = info;
+   fb_helper->info = info;
info->skip_vt_switch = true;
 
return info;
@@ -621,8 +621,8 @@ EXPORT_SYMBOL(drm_fb_helper_alloc_fbi);
  */
 void drm_fb_helper_unregister_fbi(struct drm_fb_helper *fb_helper)
 {
-   if (fb_helper && fb_helper->fbdev)
-   unregister_framebuffer(fb_helper->fbdev);
+   if (fb_helper && fb_helper->info)
+   unregister_framebuffer(fb_helper->info);
 }
 EXPORT_SYMBOL(drm_fb_helper_unregister_fbi);
 
@@ -647,13 +647,13 @@ void drm_fb_helper_fini(struct drm_fb_helper *fb_helper)
cancel_work_sync(&fb_helper->resume_work);
cancel_work_sync(&fb_helper->damage_work);
 
-   info = fb_helper->fbdev;
+   info = fb_helper->info;
if (info) {
if (info->cmap.len)
fb_dealloc_cmap(&info->cmap);
framebuffer_release(info);
}
-   fb_helper->fbdev = NULL;
+   fb_helper->info = NULL;
 
mutex_lock(&kernel_fb_helper_lock);
if (!list_empty(&fb_helper->kernel_fb_list)) {
@@ -914,8 +914,8 @@ EXPORT_SYMBOL(drm_fb_helper_cfb_imageblit);
  */
 void drm_fb_helper_set_suspend(struct drm_fb_helper *fb_helper, bool suspend)
 {
-   if (fb_helper && fb_helper->fbdev)
-   fb_set_suspend(fb_helper->fbdev, suspend);
+   if (fb_helper && fb_helper->info)
+   fb_set_suspend(fb_helper->info, suspend);
 }
 EXPORT_SYMBOL(drm_fb_helper_set_suspend);
 
@@ -938,20 +938,20 @@ EXPORT_SYMBOL(drm_fb_helper_set_suspend);
 void drm_fb_helper_set_suspend_unlocked(struct drm_fb_helper *fb_helper,
bool suspend)
 {
-   if (!fb_helper || !fb_helper->fbdev)
+   if (!fb_helper || !fb_helper->info)
return;
 
/* make sure there's no pending/ongoing resume */
flush_work(&fb_helper->resume_work);
 
if (suspend) {
-   if (fb_helper->fbdev->state != FBINFO_STATE_RUNNING)
+   if (fb_helper->info->state != FBINFO_STATE_RUNNING)
return;
 
console_lock();
 
} else {
-   if (fb_helper->fbdev->state == FBINFO_STATE_RUNNING)
+   if (fb_helper->info->state == FBINFO_STATE_RUNNING)
return;
 
if (!console_trylock()) {
@@ -960,7 +960,7 @@ void drm_fb_helper_set_suspend_unlocked(struct 
drm_fb_helper *fb_helper,
}
}
 
-   fb_set_suspend(fb_helper->fbdev, suspend);
+   fb_set_suspend(fb_helper->info, suspend);
console_unlock();
 }
 EXPORT_SYMBOL(drm_fb_helper_set_suspend_unlocked);
@@ -1850,7 +1850,7 @@ EXPORT_SYMBOL(drm_fb_helper_fill_info);
 /*
  * This is a continuation of drm_setup_crtcs() that sets up anything related
  * to the framebuffer. During initialization, drm_setup_crtcs() is called 
before
- * the framebuffer has been allocated (fb_helper->fb and fb_helper->fbdev).
+ * the framebuffer has been allocated (fb_helper->fb and fb_helper->info).
  * So, any setup that touches those fields needs to be done here instead of in
  * drm_setup_crtcs().
  */
@@ -1858,7 +1858,7 @@ static void drm_setup_crtcs_fb(struct drm_fb_helper 
*fb_helper)
 {
struct drm_client_dev *client = &fb_helper-

[PATCH v3 21/23] drm/fb-helper: Move generic fbdev emulation into separate source file

2022-11-03 Thread Thomas Zimmermann
Move the generic fbdev implementation into its own source and header
file. Adapt drivers. No functional changes, but some of the internal
helpers have been renamed to fit into the drm_fbdev_ naming scheme.

v3:
* rename drm_fbdev.{c,h} to drm_fbdev_generic.{c,h}
* rebase onto vmwgfx changes
* rebase onto xlnx changes
* fix include statements in amdgpu

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Javier Martinez Canillas 
---
 drivers/gpu/drm/Makefile  |   4 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c   |   1 +
 .../gpu/drm/arm/display/komeda/komeda_drv.c   |   2 +-
 drivers/gpu/drm/arm/hdlcd_drv.c   |   2 +-
 drivers/gpu/drm/arm/malidp_drv.c  |   2 +-
 drivers/gpu/drm/aspeed/aspeed_gfx_drv.c   |   2 +-
 drivers/gpu/drm/ast/ast_drv.c |   1 +
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c  |   2 +-
 drivers/gpu/drm/drm_fb_helper.c   | 498 +-
 drivers/gpu/drm/drm_fbdev_generic.c   | 493 +
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c |   2 +-
 drivers/gpu/drm/gud/gud_drv.c |   2 +-
 .../gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c   |   1 +
 .../gpu/drm/hisilicon/kirin/kirin_drm_drv.c   |   2 +-
 drivers/gpu/drm/hyperv/hyperv_drm_drv.c   |   2 +-
 drivers/gpu/drm/imx/dcss/dcss-kms.c   |   2 +-
 drivers/gpu/drm/imx/imx-drm-core.c|   2 +-
 drivers/gpu/drm/ingenic/ingenic-drm-drv.c |   2 +-
 drivers/gpu/drm/kmb/kmb_drv.c |   2 +-
 drivers/gpu/drm/logicvc/logicvc_drm.c |   2 +-
 drivers/gpu/drm/mcde/mcde_drv.c   |   2 +-
 drivers/gpu/drm/mediatek/mtk_drm_drv.c|   2 +-
 drivers/gpu/drm/meson/meson_drv.c |   2 +-
 drivers/gpu/drm/mgag200/mgag200_drv.c |   1 +
 drivers/gpu/drm/mxsfb/lcdif_drv.c |   2 +-
 drivers/gpu/drm/mxsfb/mxsfb_drv.c |   2 +-
 drivers/gpu/drm/panel/panel-ilitek-ili9341.c  |   2 +-
 drivers/gpu/drm/pl111/pl111_drv.c |   2 +-
 drivers/gpu/drm/qxl/qxl_drv.c |   1 +
 drivers/gpu/drm/rcar-du/rcar_du_drv.c |   2 +-
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c   |   2 +-
 drivers/gpu/drm/solomon/ssd130x.c |   2 +-
 drivers/gpu/drm/sti/sti_drv.c |   2 +-
 drivers/gpu/drm/stm/drv.c |   2 +-
 drivers/gpu/drm/sun4i/sun4i_drv.c |   2 +-
 drivers/gpu/drm/tidss/tidss_drv.c |   2 +-
 drivers/gpu/drm/tilcdc/tilcdc_drv.c   |   2 +-
 drivers/gpu/drm/tiny/arcpgu.c |   2 +-
 drivers/gpu/drm/tiny/bochs.c  |   2 +-
 drivers/gpu/drm/tiny/cirrus.c |   2 +-
 drivers/gpu/drm/tiny/gm12u320.c   |   2 +-
 drivers/gpu/drm/tiny/hx8357d.c|   2 +-
 drivers/gpu/drm/tiny/ili9163.c|   2 +-
 drivers/gpu/drm/tiny/ili9225.c|   2 +-
 drivers/gpu/drm/tiny/ili9341.c|   2 +-
 drivers/gpu/drm/tiny/ili9486.c|   2 +-
 drivers/gpu/drm/tiny/mi0283qt.c   |   2 +-
 drivers/gpu/drm/tiny/ofdrm.c  |   2 +-
 drivers/gpu/drm/tiny/panel-mipi-dbi.c |   2 +-
 drivers/gpu/drm/tiny/repaper.c|   2 +-
 drivers/gpu/drm/tiny/simpledrm.c  |   2 +-
 drivers/gpu/drm/tiny/st7586.c |   2 +-
 drivers/gpu/drm/tiny/st7735r.c|   2 +-
 drivers/gpu/drm/tve200/tve200_drv.c   |   2 +-
 drivers/gpu/drm/udl/udl_drv.c |   2 +-
 drivers/gpu/drm/vboxvideo/vbox_drv.c  |   2 +-
 drivers/gpu/drm/vc4/vc4_drv.c |   2 +-
 drivers/gpu/drm/virtio/virtgpu_drv.c  |   1 +
 drivers/gpu/drm/vkms/vkms_drv.c   |   2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c   |   2 +-
 drivers/gpu/drm/xlnx/zynqmp_kms.c |   2 +-
 include/drm/drm_fb_helper.h   |   9 -
 include/drm/drm_fbdev_generic.h   |  15 +
 63 files changed, 571 insertions(+), 558 deletions(-)
 create mode 100644 drivers/gpu/drm/drm_fbdev_generic.c
 create mode 100644 include/drm/drm_fbdev_generic.h

diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 6e55c47288e42..c44a54cadb618 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -117,7 +117,9 @@ drm_kms_helper-y := \
drm_self_refresh_helper.o \
drm_simple_kms_helper.o
 drm_kms_helper-$(CONFIG_DRM_PANEL_BRIDGE) += bridge/panel.o
-drm_kms_helper-$(CONFIG_DRM_FBDEV_EMULATION) += drm_fb_helper.o
+drm_kms_helper-$(CONFIG_DRM_FBDEV_EMULATION) += \
+   drm_fbdev_generic.o \
+   drm_fb_helper.o
 obj-$(CONFIG_DRM_KMS_HELPER) += drm_kms_helper.o
 
 #
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 3c9fecdd6b2f3..ca96ee2c2c962 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -25,6 +25,7 @@
 #inclu

[PATCH v3 10/23] drm/tve200: Include

2022-11-03 Thread Thomas Zimmermann
Include  for of_match_ptr().

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Javier Martinez Canillas 
---
 drivers/gpu/drm/tve200/tve200_drv.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/tve200/tve200_drv.c 
b/drivers/gpu/drm/tve200/tve200_drv.c
index 04db72e3fa9c2..611785e097576 100644
--- a/drivers/gpu/drm/tve200/tve200_drv.c
+++ b/drivers/gpu/drm/tve200/tve200_drv.c
@@ -32,6 +32,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
-- 
2.38.0



[PATCH v3 18/23] drm/fb_helper: Minimize damage-helper overhead

2022-11-03 Thread Thomas Zimmermann
Pull the test for fb_dirty into the caller to avoid extra work
if no callback has been set. In this case no damage handling is
required and no damage area needs to be computed. Print a warning
if the damage worker runs without getting an fb_dirty callback.

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Javier Martinez Canillas 
---
 drivers/gpu/drm/drm_fb_helper.c | 90 ++---
 1 file changed, 60 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index c7c0c0a8532b4..3dfda1e3830b3 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -449,12 +449,13 @@ static int drm_fb_helper_damage_blit(struct drm_fb_helper 
*fb_helper,
 static void drm_fb_helper_damage_work(struct work_struct *work)
 {
struct drm_fb_helper *helper = container_of(work, struct drm_fb_helper, 
damage_work);
+   struct drm_device *dev = helper->dev;
struct drm_clip_rect *clip = &helper->damage_clip;
struct drm_clip_rect clip_copy;
unsigned long flags;
int ret;
 
-   if (!helper->funcs->fb_dirty)
+   if (drm_WARN_ON_ONCE(dev, !helper->funcs->fb_dirty))
return;
 
spin_lock_irqsave(&helper->damage_lock, flags);
@@ -659,16 +660,12 @@ void drm_fb_helper_fini(struct drm_fb_helper *fb_helper)
 }
 EXPORT_SYMBOL(drm_fb_helper_fini);
 
-static void drm_fb_helper_damage(struct fb_info *info, u32 x, u32 y,
+static void drm_fb_helper_damage(struct drm_fb_helper *helper, u32 x, u32 y,
 u32 width, u32 height)
 {
-   struct drm_fb_helper *helper = info->par;
struct drm_clip_rect *clip = &helper->damage_clip;
unsigned long flags;
 
-   if (!helper->funcs->fb_dirty)
-   return;
-
spin_lock_irqsave(&helper->damage_lock, flags);
clip->x1 = min_t(u32, clip->x1, x);
clip->y1 = min_t(u32, clip->y1, y);
@@ -718,6 +715,7 @@ static void drm_fb_helper_memory_range_to_clip(struct 
fb_info *info, off_t off,
  */
 void drm_fb_helper_deferred_io(struct fb_info *info, struct list_head 
*pagereflist)
 {
+   struct drm_fb_helper *helper = info->par;
unsigned long start, end, min_off, max_off;
struct fb_deferred_io_pageref *pageref;
struct drm_rect damage_area;
@@ -733,17 +731,19 @@ void drm_fb_helper_deferred_io(struct fb_info *info, 
struct list_head *pagerefli
if (min_off >= max_off)
return;
 
-   /*
-* As we can only track pages, we might reach beyond the end
-* of the screen and account for non-existing scanlines. Hence,
-* keep the covered memory area within the screen buffer.
-*/
-   max_off = min(max_off, info->screen_size);
+   if (helper->funcs->fb_dirty) {
+   /*
+* As we can only track pages, we might reach beyond the end
+* of the screen and account for non-existing scanlines. Hence,
+* keep the covered memory area within the screen buffer.
+*/
+   max_off = min(max_off, info->screen_size);
 
-   drm_fb_helper_memory_range_to_clip(info, min_off, max_off - min_off, 
&damage_area);
-   drm_fb_helper_damage(info, damage_area.x1, damage_area.y1,
-drm_rect_width(&damage_area),
-drm_rect_height(&damage_area));
+   drm_fb_helper_memory_range_to_clip(info, min_off, max_off - 
min_off, &damage_area);
+   drm_fb_helper_damage(helper, damage_area.x1, damage_area.y1,
+drm_rect_width(&damage_area),
+drm_rect_height(&damage_area));
+   }
 }
 EXPORT_SYMBOL(drm_fb_helper_deferred_io);
 
@@ -877,6 +877,7 @@ static ssize_t drm_fb_helper_write_screen_buffer(struct 
fb_info *info, const cha
 ssize_t drm_fb_helper_sys_write(struct fb_info *info, const char __user *buf,
size_t count, loff_t *ppos)
 {
+   struct drm_fb_helper *helper = info->par;
loff_t pos = *ppos;
ssize_t ret;
struct drm_rect damage_area;
@@ -885,10 +886,12 @@ ssize_t drm_fb_helper_sys_write(struct fb_info *info, 
const char __user *buf,
if (ret <= 0)
return ret;
 
-   drm_fb_helper_memory_range_to_clip(info, pos, ret, &damage_area);
-   drm_fb_helper_damage(info, damage_area.x1, damage_area.y1,
-drm_rect_width(&damage_area),
-drm_rect_height(&damage_area));
+   if (helper->funcs->fb_dirty) {
+   drm_fb_helper_memory_range_to_clip(info, pos, ret, 
&damage_area);
+   drm_fb_helper_damage(helper, damage_area.x1, damage_area.y1,
+drm_rect_width(&damage_area),
+drm_rect_height(&damage_area));
+   }
 
return ret;
 }
@@ -904,8 +907,12 @@ EXPORT

[PATCH v3 08/23] drm/rockchip: Don't set struct drm_driver.output_poll_changed

2022-11-03 Thread Thomas Zimmermann
Don't set struct drm_driver.output_poll_changed. It's used to restore
the fbdev console. But as rockchip uses generic fbdev emulation, the
console is being restored by the DRM client helpers already. See the
functions drm_kms_helper_hotplug_event() and
drm_kms_helper_connector_hotplug_event() in drm_probe_helper.c.

v2:
* fix commit description (Christian)

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Javier Martinez Canillas 
---
 drivers/gpu/drm/rockchip/rockchip_drm_fb.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
index 092bf863110b7..7de64b0ad047f 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
@@ -9,7 +9,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -101,7 +100,6 @@ rockchip_fb_create(struct drm_device *dev, struct drm_file 
*file,
 
 static const struct drm_mode_config_funcs rockchip_drm_mode_config_funcs = {
.fb_create = rockchip_fb_create,
-   .output_poll_changed = drm_fb_helper_output_poll_changed,
.atomic_check = drm_atomic_helper_check,
.atomic_commit = drm_atomic_helper_commit,
 };
-- 
2.38.0



[PATCH v3 04/23] drm/amdgpu: Don't set struct drm_driver.output_poll_changed

2022-11-03 Thread Thomas Zimmermann
Don't set struct drm_driver.output_poll_changed. It's used to restore
the fbdev console. But as amdgpu uses generic fbdev emulation, the
console is being restored by the DRM client helpers already. See the
functions drm_kms_helper_hotplug_event() and
drm_kms_helper_connector_hotplug_event() in drm_probe_helper.c.

v2:
* fix commit description (Christian)

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Javier Martinez Canillas 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c   | 1 -
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 --
 2 files changed, 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index 1a06b8d724f39..dd6f9ae6fbe9f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -1214,7 +1214,6 @@ amdgpu_display_user_framebuffer_create(struct drm_device 
*dev,
 
 const struct drm_mode_config_funcs amdgpu_mode_funcs = {
.fb_create = amdgpu_display_user_framebuffer_create,
-   .output_poll_changed = drm_fb_helper_output_poll_changed,
 };
 
 static const struct drm_prop_enum_list amdgpu_underscan_enum_list[] =
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 3c072754738d2..d58dd916488a1 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -82,7 +82,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -2810,7 +2809,6 @@ const struct amdgpu_ip_block_version dm_ip_block =
 static const struct drm_mode_config_funcs amdgpu_dm_mode_funcs = {
.fb_create = amdgpu_display_user_framebuffer_create,
.get_format_info = amd_get_format_info,
-   .output_poll_changed = drm_fb_helper_output_poll_changed,
.atomic_check = amdgpu_dm_atomic_check,
.atomic_commit = drm_atomic_helper_commit,
 };
-- 
2.38.0



[PATCH v3 01/23] drm/komeda: Don't set struct drm_driver.lastclose

2022-11-03 Thread Thomas Zimmermann
Don't set struct drm_driver.lastclose. It's used to restore the
fbdev console. But as komeda uses generic fbdev emulation, the
console is being restored by the DRM client helpers already. See
the call to drm_client_dev_restore() in drm_lastclose().

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Javier Martinez Canillas 
---
 drivers/gpu/drm/arm/display/komeda/komeda_kms.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c 
b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
index 451746ebbe713..62dc64550793e 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
@@ -10,7 +10,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -59,7 +58,6 @@ static irqreturn_t komeda_kms_irq_handler(int irq, void *data)
 
 static const struct drm_driver komeda_kms_driver = {
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
-   .lastclose  = drm_fb_helper_lastclose,
DRM_GEM_DMA_DRIVER_OPS_WITH_DUMB_CREATE(komeda_gem_dma_dumb_create),
.fops = &komeda_cma_fops,
.name = "komeda",
-- 
2.38.0



[PATCH v3 06/23] drm/ingenic: Don't set struct drm_driver.output_poll_changed

2022-11-03 Thread Thomas Zimmermann
Don't set struct drm_driver.output_poll_changed. It's used to restore
the fbdev console. But as ingenic uses generic fbdev emulation, the
console is being restored by the DRM client helpers already. See the
functions drm_kms_helper_hotplug_event() and
drm_kms_helper_connector_hotplug_event() in drm_probe_helper.c.

v2:
* fix commit description (Christian, Sergey)

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Javier Martinez Canillas 
---
 drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c 
b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
index ab0515d2c420a..99f86f1ba8bee 100644
--- a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
+++ b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
@@ -1018,7 +1018,6 @@ static const struct drm_bridge_funcs 
ingenic_drm_bridge_funcs = {
 
 static const struct drm_mode_config_funcs ingenic_drm_mode_config_funcs = {
.fb_create  = ingenic_drm_gem_fb_create,
-   .output_poll_changed= drm_fb_helper_output_poll_changed,
.atomic_check   = drm_atomic_helper_check,
.atomic_commit  = drm_atomic_helper_commit,
 };
-- 
2.38.0



[PATCH v3 02/23] drm/mcde: Don't set struct drm_driver.lastclose

2022-11-03 Thread Thomas Zimmermann
Don't set struct drm_driver.lastclose. It's used to restore the
fbdev console. But as mcde uses generic fbdev emulation, the
console is being restored by the DRM client helpers already. See
the call to drm_client_dev_restore() in drm_lastclose().

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Javier Martinez Canillas 
---
 drivers/gpu/drm/mcde/mcde_drv.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/mcde/mcde_drv.c b/drivers/gpu/drm/mcde/mcde_drv.c
index 1c4482ad507d9..38c3907bb151a 100644
--- a/drivers/gpu/drm/mcde/mcde_drv.c
+++ b/drivers/gpu/drm/mcde/mcde_drv.c
@@ -203,7 +203,6 @@ DEFINE_DRM_GEM_DMA_FOPS(drm_fops);
 static const struct drm_driver mcde_drm_driver = {
.driver_features =
DRIVER_MODESET | DRIVER_GEM | DRIVER_ATOMIC,
-   .lastclose = drm_fb_helper_lastclose,
.ioctls = NULL,
.fops = &drm_fops,
.name = "mcde",
-- 
2.38.0



[PATCH v3 03/23] drm/vboxvideo: Don't set struct drm_driver.lastclose

2022-11-03 Thread Thomas Zimmermann
Don't set struct drm_driver.lastclose. It's used to restore the
fbdev console. But as vboxvideo uses generic fbdev emulation, the
console is being restored by the DRM client helpers already. See
the call to drm_client_dev_restore() in drm_lastclose().

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Javier Martinez Canillas 
---
 drivers/gpu/drm/vboxvideo/vbox_drv.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/vboxvideo/vbox_drv.c 
b/drivers/gpu/drm/vboxvideo/vbox_drv.c
index f4f2bd79a7cb6..1cd716eb17a1c 100644
--- a/drivers/gpu/drm/vboxvideo/vbox_drv.c
+++ b/drivers/gpu/drm/vboxvideo/vbox_drv.c
@@ -178,8 +178,6 @@ static const struct drm_driver driver = {
.driver_features =
DRIVER_MODESET | DRIVER_GEM | DRIVER_ATOMIC,
 
-   .lastclose = drm_fb_helper_lastclose,
-
.fops = &vbox_fops,
.name = DRIVER_NAME,
.desc = DRIVER_DESC,
-- 
2.38.0



[PATCH v3 00/23] drm/fb-helper: Untangle fbdev emulation and helpers

2022-11-03 Thread Thomas Zimmermann
Separate generic fbdev emulation from the helper code that is shared
among the various fbdev implementations within DRM. Affects many drivers.

It has become apparent that our fully generic fbdev emulation will
never produce optimal results for all drivers. In its current form,
it is also hard to maintain. The goal of this patchset is to improve
readability and streamline the fbdev helper code within DRM. In the
long term, we want to get to a point where drivers or memory managers
can pick and combine the various helpers for optimal fbdev support.

Patches 1 to 8 start by preparing drivers. Setting struct drm_driver's
lastclose and output_poll_changed is not required by generic fbdev
emulation.

Two drivers depend on fb helpers implicitly including other Linux header
files. Fixing this in patches 9 and 10 allows to remove unnecesary include
statements from the fb-helper header in patch 11.

Do some renaming in patches 12 to 14.

There are currently various implementation of the fbdev I/O helpers
with varying feature sets. The fb helpers for fbdev I/O should all call
fb_sync, which is what fbdev's internal implementation does. For DRM,
damage handling needs to be performed after updating a framebuffer. The
damage worker is part of the fb helpers, but the actual update logic only
works with generic fbdev emulation. Separate the two, which also gives
other drivers an option to set their own damage handling if neccessary.
The full-featured I/O helpers can be moved under a shared implementation
and called by all drivers. Patches 15 to 18 resolve these issues.

Patch 19 changes fbdev disablement to work at the level of display
detection. If disabled, generic fbdev emulation will be initialized,
but no display will be detected. It can later be enabled by changing
the parameter in sysfs and plugging in a connector.

Patches 20 to 22 move the generic fbdev emulation into their own source
and header files and clean up the include statements throughout DRM. Many
drivers only call drm_fbdev_generic_setup() and can avoid including other
Linux header files.

Patch 23 is a documentation update.

Built on x86-64, aarch64, arm, ppc64le. Tested with various combinations
of bochs, i915, simpledrm.

v3:
* documentation fixes (Javier)
* rename drm_fbdev.{c,h} to drm_fbdev_generic.{c,h}
* keep drm_leak_fbdev_smem in drm_fb_helper.c
* fix several include statements
* rebases
v2:
* fixed commit descriptions (Christian, Sergey)

Thomas Zimmermann (23):
  drm/komeda: Don't set struct drm_driver.lastclose
  drm/mcde: Don't set struct drm_driver.lastclose
  drm/vboxvideo: Don't set struct drm_driver.lastclose
  drm/amdgpu: Don't set struct drm_driver.output_poll_changed
  drm/imx/dcss: Don't set struct drm_driver.output_poll_changed
  drm/ingenic: Don't set struct drm_driver.output_poll_changed
  drm/logicvc: Don't set struct drm_driver.output_poll_changed
  drm/rockchip: Don't set struct drm_driver.output_poll_changed
  drm/panel-ili9341: Include 
  drm/tve200: Include 
  drm/fb-helper: Cleanup include statements in header file
  drm/fb_helper: Rename field fbdev to info in struct drm_fb_helper
  drm/fb-helper: Rename drm_fb_helper_alloc_fbi() to use _info postfix
  drm/fb-helper: Rename drm_fb_helper_unregister_fbi() to use _info
postfix
  drm/fb-helper: Disconnect damage worker from update logic
  drm/fb-helper: Call fb_sync in I/O functions
  drm/fb-helper: Perform all fbdev I/O with the same implementation
  drm/fb_helper: Minimize damage-helper overhead
  drm/fb-helper: Always initialize generic fbdev emulation
  drm/fb-helper: Set flag in struct drm_fb_helper for leaking physical
addresses
  drm/fb-helper: Move generic fbdev emulation into separate source file
  drm/fb-helper: Remove unnecessary include statements
  drm/fb-helper: Clarify use of last_close and output_poll_changed

 drivers/gpu/drm/Makefile  |4 +-
 .../gpu/drm/amd/amdgpu/amdgpu_connectors.c|1 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c|1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c   |3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c   |1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c   |1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h  |1 -
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c|1 +
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c|1 +
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c |1 +
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c |1 +
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |2 -
 .../gpu/drm/arm/display/komeda/komeda_drv.c   |2 +-
 .../gpu/drm/arm/display/komeda/komeda_kms.c   |2 -
 drivers/gpu/drm/arm/hdlcd_crtc.c  |1 -
 drivers/gpu/drm/arm/hdlcd_drv.c   |2 +-
 drivers/gpu/drm/arm/malidp_drv.c  |2 +-
 drivers/gpu/drm/armada/armada_fbdev.c |6 +-
 drivers/gpu/drm/aspeed/aspeed_gfx_drv.c   |2 +-
 drivers/gpu/drm/ast/ast_drv.c   

RE: [PATCH v3 3/3] drm/amdgpu: remove the DID of Vangogh from pciidlist

2022-11-03 Thread Yuan, Perry
[AMD Official Use Only - General]

Hi Alex. 

> -Original Message-
> From: Alex Deucher 
> Sent: Thursday, November 3, 2022 9:15 PM
> To: Yuan, Perry 
> Cc: Deucher, Alexander ; Liang, Richard qi
> ; Huang, Shimmer
> ; amd-gfx@lists.freedesktop.org; Liu, Kun
> 
> Subject: Re: [PATCH v3 3/3] drm/amdgpu: remove the DID of Vangogh from
> pciidlist
> 
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
> 
> 
> On Thu, Nov 3, 2022 at 2:24 AM Perry Yuan  wrote:
> >
> > change the vangogh family to use IP discovery path to initialize IP
> > list, this needs to remove the DID from the PCI ID list to allow the
> > IP discovery path to set all the IP versions correctly.
> 
> As a follow up patch, it may make sense to remove CHIP_VANGOGH entirely
> so no one accidentally tries to use it.
> 
> Alex

Sure, I will create some following patches to remove the CHIP_VANGOGH relevant 
code. 

Perry. 

> 
> 
> >
> > Signed-off-by: Perry Yuan 
> > ---
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 ---
> >  1 file changed, 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> > index 429fcdf28836..9c323405e3bb 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> > @@ -1909,9 +1909,6 @@ static const struct pci_device_id pciidlist[] = {
> > {0x1002, 0x73AF, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
> CHIP_SIENNA_CICHLID},
> > {0x1002, 0x73BF, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
> > CHIP_SIENNA_CICHLID},
> >
> > -   /* Van Gogh */
> > -   {0x1002, 0x163F, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
> CHIP_VANGOGH|AMD_IS_APU},
> > -
> > /* Yellow Carp */
> > {0x1002, 0x164D, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
> CHIP_YELLOW_CARP|AMD_IS_APU},
> > {0x1002, 0x1681, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
> > CHIP_YELLOW_CARP|AMD_IS_APU},
> > --
> > 2.34.1
> >


[PATCH 1/1] drm/amdgpu: Unlock bo_list_mutex after error handling

2022-11-03 Thread Philip Yang
Get below kernel WARNING backtrace when pressing ctrl-C to kill kfdtest
application.

If amdgpu_cs_parser_bos returns error after taking bo_list_mutex, as
caller amdgpu_cs_ioctl will not unlock bo_list_mutex, this generates the
kernel WARNING.

Add unlock bo_list_mutex after amdgpu_cs_parser_bos error handling to
cleanup bo_list userptr bo.

 WARNING: kfdtest/2930 still has locks held!
 1 lock held by kfdtest/2930:
  (&list->bo_list_mutex){+.+.}-{3:3}, at: amdgpu_cs_ioctl+0xce5/0x1f10 [amdgpu]
  stack backtrace:
   dump_stack_lvl+0x44/0x57
   get_signal+0x79f/0xd00
   arch_do_signal_or_restart+0x36/0x7b0
   exit_to_user_mode_prepare+0xfd/0x1b0
   syscall_exit_to_user_mode+0x19/0x40
   do_syscall_64+0x40/0x80

Signed-off-by: Philip Yang 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index 1bbd39b3b0fc..d371000a5727 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -992,6 +992,7 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
kvfree(e->user_pages);
e->user_pages = NULL;
}
+   mutex_unlock(&p->bo_list->bo_list_mutex);
return r;
 }
 
-- 
2.35.1



Re: [PATCH v4 1/1] drm/amd/display: add DCN support for ARM64

2022-11-03 Thread Ao Zhong
Awesome, thanks!

Rodrigo Siqueira Jordao  schrieb am Do. 3. Nov.
2022 um 15:21:

>
>
> On 2022-11-01 12:31, Nathan Chancellor wrote:
> > On Tue, Nov 01, 2022 at 10:36:08AM -0400, Rodrigo Siqueira Jordao wrote:
> >>
> >>
> >> On 2022-10-31 15:37, Ao Zhong wrote:
> >>> After moving all FPU code to the DML folder, we can enable DCN support
> >>> for the ARM64 platform. Remove the -mgeneral-regs-only CFLAG from the
> >>> code in the DML folder that needs to use hardware FPU, and add a
> control
> >>> mechanism for ARM Neon.
> >>>
> >>> Signed-off-by: Ao Zhong 
> >>> ---
> >>>drivers/gpu/drm/amd/display/Kconfig   |  3 ++-
> >>>.../gpu/drm/amd/display/amdgpu_dm/dc_fpu.c|  6 ++
> >>>drivers/gpu/drm/amd/display/dc/dml/Makefile   | 20
> +++
> >>>3 files changed, 24 insertions(+), 5 deletions(-)
> >>>
> >>> diff --git a/drivers/gpu/drm/amd/display/Kconfig
> b/drivers/gpu/drm/amd/display/Kconfig
> >>> index 0142affcdaa3..843a55a6a3ac 100644
> >>> --- a/drivers/gpu/drm/amd/display/Kconfig
> >>> +++ b/drivers/gpu/drm/amd/display/Kconfig
> >>> @@ -6,7 +6,8 @@ config DRM_AMD_DC
> >>> bool "AMD DC - Enable new display engine"
> >>> default y
> >>> select SND_HDA_COMPONENT if SND_HDA_CORE
> >>> -   select DRM_AMD_DC_DCN if (X86 || PPC64)
> >>> +   # !CC_IS_CLANG:
> https://github.com/ClangBuiltLinux/linux/issues/1752 +  select
> DRM_AMD_DC_DCN if (X86 || PPC64 || (ARM64 && KERNEL_MODE_NEON &&
> !CC_IS_CLANG))
> >>> help
> >>>   Choose this option if you want to use the new display engine
> >>>   support for AMDGPU. This adds required support for Vega and
> >>> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c
> b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c
> >>> index ab0c6d191038..1743ca0a3641 100644
> >>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c
> >>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c
> >>> @@ -31,6 +31,8 @@
> >>>#elif defined(CONFIG_PPC64)
> >>>#include 
> >>>#include 
> >>> +#elif defined(CONFIG_ARM64)
> >>> +#include 
> >>>#endif
> >>>/**
> >>> @@ -99,6 +101,8 @@ void dc_fpu_begin(const char *function_name, const
> int line)
> >>> preempt_disable();
> >>> enable_kernel_fp();
> >>> }
> >>> +#elif defined(CONFIG_ARM64)
> >>> +   kernel_neon_begin();
> >>>#endif
> >>> }
> >>> @@ -136,6 +140,8 @@ void dc_fpu_end(const char *function_name, const
> int line)
> >>> disable_kernel_fp();
> >>> preempt_enable();
> >>> }
> >>> +#elif defined(CONFIG_ARM64)
> >>> +   kernel_neon_end();
> >>>#endif
> >>> }
> >>> diff --git a/drivers/gpu/drm/amd/display/dc/dml/Makefile
> b/drivers/gpu/drm/amd/display/dc/dml/Makefile
> >>> index d0c6cf61c676..d4e93bed1c8e 100644
> >>> --- a/drivers/gpu/drm/amd/display/dc/dml/Makefile
> >>> +++ b/drivers/gpu/drm/amd/display/dc/dml/Makefile
> >>> @@ -33,6 +33,10 @@ ifdef CONFIG_PPC64
> >>>dml_ccflags := -mhard-float -maltivec
> >>>endif
> >>> +ifdef CONFIG_ARM64
> >>> +dml_rcflags := -mgeneral-regs-only
> >>> +endif
> >>> +
> >>>ifdef CONFIG_CC_IS_GCC
> >>>ifeq ($(call cc-ifversion, -lt, 0701, y), y)
> >>>IS_OLD_GCC = 1
> >>> @@ -55,8 +59,6 @@ frame_warn_flag := -Wframe-larger-than=2048
> >>>endif
> >>>CFLAGS_$(AMDDALPATH)/dc/dml/display_mode_lib.o := $(dml_ccflags)
> >>> -
> >>> -ifdef CONFIG_DRM_AMD_DC_DCN
> >>>CFLAGS_$(AMDDALPATH)/dc/dml/display_mode_vba.o := $(dml_ccflags)
> >>>CFLAGS_$(AMDDALPATH)/dc/dml/dcn10/dcn10_fpu.o := $(dml_ccflags)
> >>>CFLAGS_$(AMDDALPATH)/dc/dml/dcn20/dcn20_fpu.o := $(dml_ccflags)
> >>> @@ -88,7 +90,6 @@ CFLAGS_$(AMDDALPATH)/dc/dml/calcs/dcn_calcs.o :=
> $(dml_ccflags)
> >>>CFLAGS_$(AMDDALPATH)/dc/dml/calcs/dcn_calc_auto.o := $(dml_ccflags)
> >>>CFLAGS_$(AMDDALPATH)/dc/dml/calcs/dcn_calc_math.o := $(dml_ccflags)
> -Wno-tautological-compare
> >>>CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/display_mode_vba.o :=
> $(dml_rcflags)
> >>> -CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn2x/dcn2x.o := $(dml_rcflags)
> >>>CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn20/display_mode_vba_20.o :=
> $(dml_rcflags)
> >>>CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn20/display_rq_dlg_calc_20.o
> := $(dml_rcflags)
> >>>CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn20/display_mode_vba_20v2.o :=
> $(dml_rcflags)
> >>> @@ -105,7 +106,18 @@
> CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn32/display_mode_vba_util_32.o :=
> $(dml_rcf
> >>>CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn301/dcn301_fpu.o :=
> $(dml_rcflags)
> >>>CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/display_mode_lib.o :=
> $(dml_rcflags)
> >>>CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dsc/rc_calc_fpu.o  :=
> $(dml_rcflags)
> >>> -endif
> >>> +CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn10/dcn10_fpu.o := $(dml_rcflags)
> >>> +CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn20/dcn20_fpu.o := $(dml_rcflags)
> >>> +CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn314/display_mo

Re: [PATCH v4 1/1] drm/amd/display: add DCN support for ARM64

2022-11-03 Thread Rodrigo Siqueira Jordao




On 2022-11-01 12:31, Nathan Chancellor wrote:

On Tue, Nov 01, 2022 at 10:36:08AM -0400, Rodrigo Siqueira Jordao wrote:



On 2022-10-31 15:37, Ao Zhong wrote:

After moving all FPU code to the DML folder, we can enable DCN support
for the ARM64 platform. Remove the -mgeneral-regs-only CFLAG from the
code in the DML folder that needs to use hardware FPU, and add a control
mechanism for ARM Neon.

Signed-off-by: Ao Zhong 
---
   drivers/gpu/drm/amd/display/Kconfig   |  3 ++-
   .../gpu/drm/amd/display/amdgpu_dm/dc_fpu.c|  6 ++
   drivers/gpu/drm/amd/display/dc/dml/Makefile   | 20 +++
   3 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/Kconfig 
b/drivers/gpu/drm/amd/display/Kconfig
index 0142affcdaa3..843a55a6a3ac 100644
--- a/drivers/gpu/drm/amd/display/Kconfig
+++ b/drivers/gpu/drm/amd/display/Kconfig
@@ -6,7 +6,8 @@ config DRM_AMD_DC
bool "AMD DC - Enable new display engine"
default y
select SND_HDA_COMPONENT if SND_HDA_CORE
-   select DRM_AMD_DC_DCN if (X86 || PPC64)
+   # !CC_IS_CLANG: https://github.com/ClangBuiltLinux/linux/issues/1752 +  select 
DRM_AMD_DC_DCN if (X86 || PPC64 || (ARM64 && KERNEL_MODE_NEON && !CC_IS_CLANG))
help
  Choose this option if you want to use the new display engine
  support for AMDGPU. This adds required support for Vega and
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c
index ab0c6d191038..1743ca0a3641 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c
@@ -31,6 +31,8 @@
   #elif defined(CONFIG_PPC64)
   #include 
   #include 
+#elif defined(CONFIG_ARM64)
+#include 
   #endif
   /**
@@ -99,6 +101,8 @@ void dc_fpu_begin(const char *function_name, const int line)
preempt_disable();
enable_kernel_fp();
}
+#elif defined(CONFIG_ARM64)
+   kernel_neon_begin();
   #endif
}
@@ -136,6 +140,8 @@ void dc_fpu_end(const char *function_name, const int line)
disable_kernel_fp();
preempt_enable();
}
+#elif defined(CONFIG_ARM64)
+   kernel_neon_end();
   #endif
}
diff --git a/drivers/gpu/drm/amd/display/dc/dml/Makefile 
b/drivers/gpu/drm/amd/display/dc/dml/Makefile
index d0c6cf61c676..d4e93bed1c8e 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/Makefile
+++ b/drivers/gpu/drm/amd/display/dc/dml/Makefile
@@ -33,6 +33,10 @@ ifdef CONFIG_PPC64
   dml_ccflags := -mhard-float -maltivec
   endif
+ifdef CONFIG_ARM64
+dml_rcflags := -mgeneral-regs-only
+endif
+
   ifdef CONFIG_CC_IS_GCC
   ifeq ($(call cc-ifversion, -lt, 0701, y), y)
   IS_OLD_GCC = 1
@@ -55,8 +59,6 @@ frame_warn_flag := -Wframe-larger-than=2048
   endif
   CFLAGS_$(AMDDALPATH)/dc/dml/display_mode_lib.o := $(dml_ccflags)
-
-ifdef CONFIG_DRM_AMD_DC_DCN
   CFLAGS_$(AMDDALPATH)/dc/dml/display_mode_vba.o := $(dml_ccflags)
   CFLAGS_$(AMDDALPATH)/dc/dml/dcn10/dcn10_fpu.o := $(dml_ccflags)
   CFLAGS_$(AMDDALPATH)/dc/dml/dcn20/dcn20_fpu.o := $(dml_ccflags)
@@ -88,7 +90,6 @@ CFLAGS_$(AMDDALPATH)/dc/dml/calcs/dcn_calcs.o := 
$(dml_ccflags)
   CFLAGS_$(AMDDALPATH)/dc/dml/calcs/dcn_calc_auto.o := $(dml_ccflags)
   CFLAGS_$(AMDDALPATH)/dc/dml/calcs/dcn_calc_math.o := $(dml_ccflags) 
-Wno-tautological-compare
   CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/display_mode_vba.o := $(dml_rcflags)
-CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn2x/dcn2x.o := $(dml_rcflags)
   CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn20/display_mode_vba_20.o := 
$(dml_rcflags)
   CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn20/display_rq_dlg_calc_20.o := 
$(dml_rcflags)
   CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn20/display_mode_vba_20v2.o := 
$(dml_rcflags)
@@ -105,7 +106,18 @@ 
CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn32/display_mode_vba_util_32.o := $(dml_rcf
   CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn301/dcn301_fpu.o := $(dml_rcflags)
   CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/display_mode_lib.o := $(dml_rcflags)
   CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dsc/rc_calc_fpu.o  := $(dml_rcflags)
-endif
+CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn10/dcn10_fpu.o := $(dml_rcflags)
+CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn20/dcn20_fpu.o := $(dml_rcflags)
+CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn314/display_mode_vba_314.o := 
$(dml_rcflags)
+CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn314/display_rq_dlg_calc_314.o := 
$(dml_rcflags)
+CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn314/dcn314_fpu.o := $(dml_rcflags)
+CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn30/dcn30_fpu.o := $(dml_rcflags)
+CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn32/dcn32_fpu.o := $(dml_rcflags)
+CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn321/dcn321_fpu.o := $(dml_rcflags)
+CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn31/dcn31_fpu.o := $(dml_rcflags)
+CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn302/dcn302_fpu.o := $(dml_rcflags)
+CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn303/dcn30

Re: [PATCH] drm/amd/pm: update SMU IP v13.0.4 msg interface header

2022-11-03 Thread Alex Deucher
Acked-by: Alex Deucher 

On Thu, Nov 3, 2022 at 4:50 AM Tim Huang  wrote:
>
> Some of the unused messages that were used earlier in development have
> been freed up as spare messages, no intended functional changes.
>
> Signed-off-by: Mario Limonciello 
> Signed-off-by: Tim Huang 
> ---
>  .../amd/pm/swsmu/inc/pmfw_if/smu_v13_0_4_ppsmc.h  | 15 +++
>  1 file changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_4_ppsmc.h 
> b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_4_ppsmc.h
> index d9b0cd752200..f4d6c07b56ea 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_4_ppsmc.h
> +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_4_ppsmc.h
> @@ -54,14 +54,14 @@
>  #define PPSMC_MSG_TestMessage   0x01 ///< To check if PMFW 
> is alive and responding. Requirement specified by PMFW team
>  #define PPSMC_MSG_GetPmfwVersion0x02 ///< Get PMFW version
>  #define PPSMC_MSG_GetDriverIfVersion0x03 ///< Get PMFW_DRIVER_IF 
> version
> -#define PPSMC_MSG_EnableGfxOff  0x04 ///< Enable GFXOFF
> -#define PPSMC_MSG_DisableGfxOff 0x05 ///< Disable GFXOFF
> +#define PPSMC_MSG_SPARE00x04 ///< SPARE
> +#define PPSMC_MSG_SPARE10x05 ///< SPARE
>  #define PPSMC_MSG_PowerDownVcn  0x06 ///< Power down VCN
>  #define PPSMC_MSG_PowerUpVcn0x07 ///< Power up VCN; VCN 
> is power gated by default
>  #define PPSMC_MSG_SetHardMinVcn 0x08 ///< For wireless 
> display
>  #define PPSMC_MSG_SetSoftMinGfxclk  0x09 ///< Set SoftMin for 
> GFXCLK, argument is frequency in MHz
> -#define PPSMC_MSG_ActiveProcessNotify   0x0A ///< Needs update
> -#define PPSMC_MSG_ForcePowerDownGfx 0x0B ///< Force power down 
> GFX, i.e. enter GFXOFF
> +#define PPSMC_MSG_SPARE20x0A ///< SPARE
> +#define PPSMC_MSG_SPARE30x0B ///< SPARE
>  #define PPSMC_MSG_PrepareMp1ForUnload   0x0C ///< Prepare PMFW for 
> GFX driver unload
>  #define PPSMC_MSG_SetDriverDramAddrHigh 0x0D ///< Set high 32 bits 
> of DRAM address for Driver table transfer
>  #define PPSMC_MSG_SetDriverDramAddrLow  0x0E ///< Set low 32 bits of 
> DRAM address for Driver table transfer
> @@ -73,8 +73,7 @@
>  #define PPSMC_MSG_SetSoftMinFclk0x14 ///< Set hard min for 
> FCLK
>  #define PPSMC_MSG_SetSoftMinVcn 0x15 ///< Set soft min for 
> VCN clocks (VCLK and DCLK)
>
> -
> -#define PPSMC_MSG_EnableGfxImu  0x16 ///< Needs update
> +#define PPSMC_MSG_EnableGfxImu  0x16 ///< Enable GFX IMU
>
>  #define PPSMC_MSG_GetGfxclkFrequency0x17 ///< Get GFX clock 
> frequency
>  #define PPSMC_MSG_GetFclkFrequency  0x18 ///< Get FCLK frequency
> @@ -102,8 +101,8 @@
>  #define PPSMC_MSG_SetHardMinIspxclkByFreq   0x2C ///< Set HardMin by 
> frequency for ISPXCLK
>  #define PPSMC_MSG_PowerDownUmsch0x2D ///< Power down 
> VCN.UMSCH (aka VSCH) scheduler
>  #define PPSMC_MSG_PowerUpUmsch  0x2E ///< Power up VCN.UMSCH 
> (aka VSCH) scheduler
> -#define PPSMC_Message_IspStutterOn_MmhubPgDis   0x2F ///< ISP StutterOn 
> mmHub PgDis
> -#define PPSMC_Message_IspStutterOff_MmhubPgEn   0x30 ///< ISP StufferOff 
> mmHub PgEn
> +#define PPSMC_MSG_IspStutterOn_MmhubPgDis   0x2F ///< ISP StutterOn 
> mmHub PgDis
> +#define PPSMC_MSG_IspStutterOff_MmhubPgEn   0x30 ///< ISP StufferOff 
> mmHub PgEn
>
>  #define PPSMC_Message_Count 0x31 ///< Total number of 
> PPSMC messages
>  /** @}*/
> --
> 2.25.1
>


Re: [PATCH v3 3/3] drm/amdgpu: remove the DID of Vangogh from pciidlist

2022-11-03 Thread Alex Deucher
On Thu, Nov 3, 2022 at 2:24 AM Perry Yuan  wrote:
>
> change the vangogh family to use IP discovery path to initialize IP
> list, this needs to remove the DID from the PCI ID list to allow the IP
> discovery path to set all the IP versions correctly.

As a follow up patch, it may make sense to remove CHIP_VANGOGH
entirely so no one accidentally tries to use it.

Alex


>
> Signed-off-by: Perry Yuan 
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 ---
>  1 file changed, 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> index 429fcdf28836..9c323405e3bb 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> @@ -1909,9 +1909,6 @@ static const struct pci_device_id pciidlist[] = {
> {0x1002, 0x73AF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SIENNA_CICHLID},
> {0x1002, 0x73BF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SIENNA_CICHLID},
>
> -   /* Van Gogh */
> -   {0x1002, 0x163F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
> CHIP_VANGOGH|AMD_IS_APU},
> -
> /* Yellow Carp */
> {0x1002, 0x164D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
> CHIP_YELLOW_CARP|AMD_IS_APU},
> {0x1002, 0x1681, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
> CHIP_YELLOW_CARP|AMD_IS_APU},
> --
> 2.34.1
>


Re: [PATCH v3 1/3] drm/amdgpu: add Vangogh APU flag to IP discovery path

2022-11-03 Thread Alex Deucher
Series is:
Reviewed-by: Alex Deucher 

On Thu, Nov 3, 2022 at 2:24 AM Perry Yuan  wrote:
>
> Add the missing apu flag for Vangogh when using IP discovery code path
> to initialize IPs
>
> Signed-off-by: Perry Yuan 
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
> index 95d34590cad1..c1b1f223f3d0 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
> @@ -2153,6 +2153,7 @@ int amdgpu_discovery_set_ip_blocks(struct amdgpu_device 
> *adev)
> break;
> case IP_VERSION(10, 3, 1):
> adev->family = AMDGPU_FAMILY_VGH;
> +   adev->apu_flags |= AMD_APU_IS_VANGOGH;
> break;
> case IP_VERSION(10, 3, 3):
> adev->family = AMDGPU_FAMILY_YC;
> --
> 2.34.1
>


Re: [PATCH 4/5] drm/amdgpu: MCBP based on DRM scheduler (v8)

2022-11-03 Thread Michel Dänzer
On 2022-11-03 03:58, Zhu, Jiadong wrote:
> [AMD Official Use Only - General]
> 
>> The bad news is that this series still makes some things very slow. The most 
>> extreme examples so far are glxgears (runs at ~400 fps now, ~7000 fps 
>> before, i.e. almost 20x slowdown) and hexchat (scrolling one page now takes 
>> ~1 second, I can see it drawing line by line; before it was almost 
>> instantaneous). I suspect this series makes the overhead of running a single 
>> GPU job much bigger. On the bright side, I'm not noticing any significant 
>> intermittent freezes anymore.
> 
> Hi Michel,
> 
> Thanks for the trying.
> Is there high priority jobs running while executing glxgears?

Yes, mutter is submitting high priority jobs. However, I don't think that can 
explain the problem by itself:

mutter only draws once per display refresh cycle. Let's assume mutter's GPU 
work takes ~6-7ms (conservative example, should be less than that usually). 
That leaves ~10ms per display refresh cycle (at 60 Hz refresh rate) where GPU 
work from glxgears & Xwayland can run without getting preempted. Since glxgears 
runs at ~7000 fps without this series, it should be able to draw at least ~70 
frames in 10ms[0], which corresponds to over 4000 fps. Yet it manages only 1/10 
of that.

[0] Worst case consideration, ignoring the fact that without this series, 
glxgears runs at ~7000 fps while mutter sustains 60 fps.


> I am running glxgears while submitting high priority ibs using amdgpu_test, 
> the fps ranges from 6000~8000.

It's getting clear that artificial tests such as amdgpu_test don't suffice for 
evaluating the real-world impact of this kind of change.


> Continuous preemption and resubmission may cause the slow fps. Could you have 
> a check about how fast the trailing fence seqNo expands. On my side, the 
> increment of Last signaled trailing fence is < 10 in a second.

I had to go back to a kernel without this series, as it was just unusable. As 
this is my main machine, I don't know when I'll get a chance to check this.


-- 
Earthling Michel Dänzer|  https://redhat.com
Libre software enthusiast  | Mesa and Xwayland developer



[PATCH] drm/amd/pm: update SMU IP v13.0.4 msg interface header

2022-11-03 Thread Tim Huang
Some of the unused messages that were used earlier in development have
been freed up as spare messages, no intended functional changes.

Signed-off-by: Mario Limonciello 
Signed-off-by: Tim Huang 
---
 .../amd/pm/swsmu/inc/pmfw_if/smu_v13_0_4_ppsmc.h  | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_4_ppsmc.h 
b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_4_ppsmc.h
index d9b0cd752200..f4d6c07b56ea 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_4_ppsmc.h
+++ b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_4_ppsmc.h
@@ -54,14 +54,14 @@
 #define PPSMC_MSG_TestMessage   0x01 ///< To check if PMFW is 
alive and responding. Requirement specified by PMFW team
 #define PPSMC_MSG_GetPmfwVersion0x02 ///< Get PMFW version
 #define PPSMC_MSG_GetDriverIfVersion0x03 ///< Get PMFW_DRIVER_IF 
version
-#define PPSMC_MSG_EnableGfxOff  0x04 ///< Enable GFXOFF
-#define PPSMC_MSG_DisableGfxOff 0x05 ///< Disable GFXOFF
+#define PPSMC_MSG_SPARE00x04 ///< SPARE
+#define PPSMC_MSG_SPARE10x05 ///< SPARE
 #define PPSMC_MSG_PowerDownVcn  0x06 ///< Power down VCN
 #define PPSMC_MSG_PowerUpVcn0x07 ///< Power up VCN; VCN is 
power gated by default
 #define PPSMC_MSG_SetHardMinVcn 0x08 ///< For wireless display
 #define PPSMC_MSG_SetSoftMinGfxclk  0x09 ///< Set SoftMin for 
GFXCLK, argument is frequency in MHz
-#define PPSMC_MSG_ActiveProcessNotify   0x0A ///< Needs update
-#define PPSMC_MSG_ForcePowerDownGfx 0x0B ///< Force power down 
GFX, i.e. enter GFXOFF
+#define PPSMC_MSG_SPARE20x0A ///< SPARE
+#define PPSMC_MSG_SPARE30x0B ///< SPARE
 #define PPSMC_MSG_PrepareMp1ForUnload   0x0C ///< Prepare PMFW for GFX 
driver unload
 #define PPSMC_MSG_SetDriverDramAddrHigh 0x0D ///< Set high 32 bits of 
DRAM address for Driver table transfer
 #define PPSMC_MSG_SetDriverDramAddrLow  0x0E ///< Set low 32 bits of 
DRAM address for Driver table transfer
@@ -73,8 +73,7 @@
 #define PPSMC_MSG_SetSoftMinFclk0x14 ///< Set hard min for FCLK
 #define PPSMC_MSG_SetSoftMinVcn 0x15 ///< Set soft min for VCN 
clocks (VCLK and DCLK)
 
-
-#define PPSMC_MSG_EnableGfxImu  0x16 ///< Needs update
+#define PPSMC_MSG_EnableGfxImu  0x16 ///< Enable GFX IMU
 
 #define PPSMC_MSG_GetGfxclkFrequency0x17 ///< Get GFX clock 
frequency
 #define PPSMC_MSG_GetFclkFrequency  0x18 ///< Get FCLK frequency
@@ -102,8 +101,8 @@
 #define PPSMC_MSG_SetHardMinIspxclkByFreq   0x2C ///< Set HardMin by 
frequency for ISPXCLK
 #define PPSMC_MSG_PowerDownUmsch0x2D ///< Power down VCN.UMSCH 
(aka VSCH) scheduler
 #define PPSMC_MSG_PowerUpUmsch  0x2E ///< Power up VCN.UMSCH 
(aka VSCH) scheduler
-#define PPSMC_Message_IspStutterOn_MmhubPgDis   0x2F ///< ISP StutterOn mmHub 
PgDis
-#define PPSMC_Message_IspStutterOff_MmhubPgEn   0x30 ///< ISP StufferOff mmHub 
PgEn
+#define PPSMC_MSG_IspStutterOn_MmhubPgDis   0x2F ///< ISP StutterOn mmHub 
PgDis
+#define PPSMC_MSG_IspStutterOff_MmhubPgEn   0x30 ///< ISP StufferOff mmHub 
PgEn
 
 #define PPSMC_Message_Count 0x31 ///< Total number of 
PPSMC messages
 /** @}*/
-- 
2.25.1



RE: [PATCH] drm/amdgpu: Disable GFX RAS feature for SRIOV case

2022-11-03 Thread Zhang, Hawking
[AMD Official Use Only - General]

No worries. Let's know if you run into any RAS issue in SRIOV environment.

Regards,
Hawking

-Original Message-
From: Wang, YuBiao  
Sent: Thursday, November 3, 2022 15:56
To: Zhang, Hawking ; amd-gfx@lists.freedesktop.org; 
Feng, Kenneth 
Cc: Xiao, Jack ; Wang, Yang(Kevin) ; 
Xu, Feifei ; Chen, Horace ; Tuikov, 
Luben ; Deucher, Alexander ; 
Quan, Evan ; Koenig, Christian ; 
Liu, Monk 
Subject: RE: [PATCH] drm/amdgpu: Disable GFX RAS feature for SRIOV case

Hi Hawking,

Yes I now noticed that. I was sending this patch since I found it as a 
regression on my side. So this is caused by IFWI regression instead of a 
sriov-only bug. Sorry for the misunderstanding. Thanks!

Regards,
Yubiao

-Original Message-
From: Zhang, Hawking  
Sent: Thursday, November 3, 2022 2:51 PM
To: Zhang, Hawking ; Wang, YuBiao ; 
amd-gfx@lists.freedesktop.org; Feng, Kenneth 
Cc: Xiao, Jack ; Wang, Yang(Kevin) ; 
Xu, Feifei ; Chen, Horace ; Tuikov, 
Luben ; Deucher, Alexander ; 
Quan, Evan ; Koenig, Christian ; 
Liu, Monk 
Subject: RE: [PATCH] drm/amdgpu: Disable GFX RAS feature for SRIOV case

[AMD Official Use Only - General]

Btw, if the concern is the gfx_late_init failure caused by incorrect setting in 
IFWI. @Feng, Kenneth already have a workaround.

Regards,
Hawking

-Original Message-
From: amd-gfx  On Behalf Of Zhang, 
Hawking
Sent: Thursday, November 3, 2022 14:46
To: Wang, YuBiao ; amd-gfx@lists.freedesktop.org
Cc: Xiao, Jack ; Wang, Yang(Kevin) ; 
Xu, Feifei ; Chen, Horace ; Tuikov, 
Luben ; Deucher, Alexander ; 
Quan, Evan ; Koenig, Christian ; 
Liu, Monk 
Subject: RE: [PATCH] drm/amdgpu: Disable GFX RAS feature for SRIOV case

[AMD Official Use Only - General]

amdgpu_ras_feature_enable won't send RAS command to firmware if it is invoked 
from guest side. The change seems unnecessary.

Regards,
Hawking

-Original Message-
From: Wang, YuBiao  
Sent: Thursday, November 3, 2022 14:39
To: Wang, YuBiao ; amd-gfx@lists.freedesktop.org; Zhang, 
Hawking 
Cc: Quan, Evan ; Chen, Horace ; Tuikov, 
Luben ; Koenig, Christian ; 
Deucher, Alexander ; Xiao, Jack ; 
Liu, Monk ; Xu, Feifei ; Wang, Yang(Kevin) 

Subject: RE: [PATCH] drm/amdgpu: Disable GFX RAS feature for SRIOV case

Hi Hawking,

This patch is to skip ras init in sriov case. Please help review.

Thanks,
Yubiao

-Original Message-
From: YuBiao Wang  
Sent: Thursday, November 3, 2022 11:12 AM
To: amd-gfx@lists.freedesktop.org
Cc: Andrey Grodzovsky ; Quan, Evan 
; Chen, Horace ; Tuikov, Luben 
; Koenig, Christian ; Deucher, 
Alexander ; Xiao, Jack ; Zhang, 
Hawking ; Liu, Monk ; Xu, Feifei 
; Wang, Yang(Kevin) ; Wang, YuBiao 

Subject: [PATCH] drm/amdgpu: Disable GFX RAS feature for SRIOV case

In sriov guest side doesn't need init ras feature, so skip it.

Signed-off-by: YuBiao Wang 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
index 84a76c36d9a7..be8ed617e269 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
@@ -4707,7 +4707,7 @@ static int gfx_v11_0_late_init(void *handle)
if (r)
return r;
 
-   if (adev->ip_versions[GC_HWIP][0] == IP_VERSION(11, 0, 3)) {
+   if (!amdgpu_sriov_vf(adev) && adev->ip_versions[GC_HWIP][0] == 
IP_VERSION(11, 0, 3)) {
r = gfx_v11_0_ras_late_init(handle);
if (r)
return r;
-- 
2.25.1


RE: [PATCH] drm/amdgpu: Disable GFX RAS feature for SRIOV case

2022-11-03 Thread Wang, YuBiao
Hi Hawking,

Yes I now noticed that. I was sending this patch since I found it as a 
regression on my side. So this is caused by IFWI regression instead of a 
sriov-only bug. Sorry for the misunderstanding. Thanks!

Regards,
Yubiao

-Original Message-
From: Zhang, Hawking  
Sent: Thursday, November 3, 2022 2:51 PM
To: Zhang, Hawking ; Wang, YuBiao ; 
amd-gfx@lists.freedesktop.org; Feng, Kenneth 
Cc: Xiao, Jack ; Wang, Yang(Kevin) ; 
Xu, Feifei ; Chen, Horace ; Tuikov, 
Luben ; Deucher, Alexander ; 
Quan, Evan ; Koenig, Christian ; 
Liu, Monk 
Subject: RE: [PATCH] drm/amdgpu: Disable GFX RAS feature for SRIOV case

[AMD Official Use Only - General]

Btw, if the concern is the gfx_late_init failure caused by incorrect setting in 
IFWI. @Feng, Kenneth already have a workaround.

Regards,
Hawking

-Original Message-
From: amd-gfx  On Behalf Of Zhang, 
Hawking
Sent: Thursday, November 3, 2022 14:46
To: Wang, YuBiao ; amd-gfx@lists.freedesktop.org
Cc: Xiao, Jack ; Wang, Yang(Kevin) ; 
Xu, Feifei ; Chen, Horace ; Tuikov, 
Luben ; Deucher, Alexander ; 
Quan, Evan ; Koenig, Christian ; 
Liu, Monk 
Subject: RE: [PATCH] drm/amdgpu: Disable GFX RAS feature for SRIOV case

[AMD Official Use Only - General]

amdgpu_ras_feature_enable won't send RAS command to firmware if it is invoked 
from guest side. The change seems unnecessary.

Regards,
Hawking

-Original Message-
From: Wang, YuBiao  
Sent: Thursday, November 3, 2022 14:39
To: Wang, YuBiao ; amd-gfx@lists.freedesktop.org; Zhang, 
Hawking 
Cc: Quan, Evan ; Chen, Horace ; Tuikov, 
Luben ; Koenig, Christian ; 
Deucher, Alexander ; Xiao, Jack ; 
Liu, Monk ; Xu, Feifei ; Wang, Yang(Kevin) 

Subject: RE: [PATCH] drm/amdgpu: Disable GFX RAS feature for SRIOV case

Hi Hawking,

This patch is to skip ras init in sriov case. Please help review.

Thanks,
Yubiao

-Original Message-
From: YuBiao Wang  
Sent: Thursday, November 3, 2022 11:12 AM
To: amd-gfx@lists.freedesktop.org
Cc: Andrey Grodzovsky ; Quan, Evan 
; Chen, Horace ; Tuikov, Luben 
; Koenig, Christian ; Deucher, 
Alexander ; Xiao, Jack ; Zhang, 
Hawking ; Liu, Monk ; Xu, Feifei 
; Wang, Yang(Kevin) ; Wang, YuBiao 

Subject: [PATCH] drm/amdgpu: Disable GFX RAS feature for SRIOV case

In sriov guest side doesn't need init ras feature, so skip it.

Signed-off-by: YuBiao Wang 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
index 84a76c36d9a7..be8ed617e269 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
@@ -4707,7 +4707,7 @@ static int gfx_v11_0_late_init(void *handle)
if (r)
return r;
 
-   if (adev->ip_versions[GC_HWIP][0] == IP_VERSION(11, 0, 3)) {
+   if (!amdgpu_sriov_vf(adev) && adev->ip_versions[GC_HWIP][0] == 
IP_VERSION(11, 0, 3)) {
r = gfx_v11_0_ras_late_init(handle);
if (r)
return r;
-- 
2.25.1


Re: [PATCH] drm/amdgpu: fix for suspend/resume sequence under sriov

2022-11-03 Thread Christian König

Am 03.11.22 um 05:06 schrieb Victor Zhao:

- clear kiq ring after suspend/resume under sriov to aviod kiq ring
test failure
- update irq after resume to fix kiq interrput loss


Good to see that somebody takes a look into this. Is that enough to get 
suspend/resume with SRIOV going?




Signed-off-by: Victor Zhao 
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 ++
  drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 2 ++
  2 files changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 522820eeaa59..5b9f992e4607 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -4197,6 +4197,8 @@ int amdgpu_device_resume(struct drm_device *dev, bool 
fbcon)
}
  
  	/* Make sure IB tests flushed */

+   if (amdgpu_sriov_vf(adev))
+   amdgpu_irq_gpu_reset_resume_helper(adev);


This is a pretty clear NAK because that should happen during resume 
anyway. If this doesn't happen we have a bug somewhere else and that 
here just hides it.



flush_delayed_work(&adev->delayed_init_work);
  
  	if (adev->in_s0ix) {

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index 7853d3ca58cf..49d34c7bbf20 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -6909,6 +6909,8 @@ static int gfx_v10_0_kiq_init_queue(struct amdgpu_ring 
*ring)
mutex_unlock(&adev->srbm_mutex);
} else {
memset((void *)mqd, 0, sizeof(*mqd));
+   if (amdgpu_sriov_vf(adev) && adev->in_suspend)
+   amdgpu_ring_clear_ring(ring);


Is there any good reason to not always clear the KIQ ring here? E.g. 
also on bare metal and during load/reset?


Regards,
Christian.


mutex_lock(&adev->srbm_mutex);
nv_grbm_select(adev, ring->me, ring->pipe, ring->queue, 0);
amdgpu_ring_init_mqd(ring);