Re: [PATCH v2 3/8] drm: zynqmp_dp: Adjust training values per-lane

2024-03-19 Thread Tomi Valkeinen

On 20/03/2024 00:51, Sean Anderson wrote:

The feedback we get from the DPRX is per-lane. Make changes using this
information, instead of picking the maximum values from all lanes. This
results in more-consistent training on marginal links.

Signed-off-by: Sean Anderson 
---

(no changes since v1)

  drivers/gpu/drm/xlnx/zynqmp_dp.c | 23 ---
  1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/xlnx/zynqmp_dp.c b/drivers/gpu/drm/xlnx/zynqmp_dp.c
index 98a32e6a0459..8635b5673386 100644
--- a/drivers/gpu/drm/xlnx/zynqmp_dp.c
+++ b/drivers/gpu/drm/xlnx/zynqmp_dp.c
@@ -605,28 +605,21 @@ static void zynqmp_dp_adjust_train(struct zynqmp_dp *dp,
   u8 link_status[DP_LINK_STATUS_SIZE])
  {
u8 *train_set = dp->train_set;
-   u8 voltage = 0, preemphasis = 0;
u8 i;
  
  	for (i = 0; i < dp->mode.lane_cnt; i++) {

-   u8 v = drm_dp_get_adjust_request_voltage(link_status, i);
-   u8 p = drm_dp_get_adjust_request_pre_emphasis(link_status, i);
+   u8 voltage = drm_dp_get_adjust_request_voltage(link_status, i);
+   u8 preemphasis =
+   drm_dp_get_adjust_request_pre_emphasis(link_status, i);
  
-		if (v > voltage)

-   voltage = v;
+   if (voltage >= DP_TRAIN_VOLTAGE_SWING_LEVEL_3)
+   voltage |= DP_TRAIN_MAX_SWING_REACHED;
  
-		if (p > preemphasis)

-   preemphasis = p;
-   }
+   if (preemphasis >= DP_TRAIN_PRE_EMPH_LEVEL_2)
+   preemphasis |= DP_TRAIN_MAX_PRE_EMPHASIS_REACHED;
  
-	if (voltage >= DP_TRAIN_VOLTAGE_SWING_LEVEL_3)

-   voltage |= DP_TRAIN_MAX_SWING_REACHED;
-
-   if (preemphasis >= DP_TRAIN_PRE_EMPH_LEVEL_2)
-   preemphasis |= DP_TRAIN_MAX_PRE_EMPHASIS_REACHED;
-
-   for (i = 0; i < dp->mode.lane_cnt; i++)
train_set[i] = voltage | preemphasis;
+   }
  }
  
  /**


Looks fine to me, but a few cosmetic suggestions, feel free to ignore if 
not to your liking:


1)

u8 voltage, preemphasis;

voltage = drm_dp_get_adjust_request_voltage(link_status, i);
preemphasis = drm_dp_get_adjust_request_pre_emphasis(link_status, i);

2)

for (unsigned int i = 0; i < dp->mode.lane_cnt; i++)

3)

dp->train_set[i] = voltage | preemphasis;


Reviewed-by: Tomi Valkeinen 

 Tomi



Re: [PATCH v2 2/8] drm: zynqmp_dp: Downgrade log level for aux retries message

2024-03-19 Thread Tomi Valkeinen

On 20/03/2024 00:51, Sean Anderson wrote:

Enable this message for verbose debugging only as it is otherwise
printed after every AUX message, quickly filling the log buffer.

Signed-off-by: Sean Anderson 
Reviewed-by: Laurent Pinchart 
---

(no changes since v1)

  drivers/gpu/drm/xlnx/zynqmp_dp.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/xlnx/zynqmp_dp.c b/drivers/gpu/drm/xlnx/zynqmp_dp.c
index a0606fab0e22..98a32e6a0459 100644
--- a/drivers/gpu/drm/xlnx/zynqmp_dp.c
+++ b/drivers/gpu/drm/xlnx/zynqmp_dp.c
@@ -1006,7 +1006,7 @@ zynqmp_dp_aux_transfer(struct drm_dp_aux *aux, struct 
drm_dp_aux_msg *msg)
   msg->buffer, msg->size,
   >reply);
if (!ret) {
-   dev_dbg(dp->dev, "aux %d retries\n", i);
+   dev_vdbg(dp->dev, "aux %d retries\n", i);
return msg->size;
}
  


Yes, these are annoying... In my work branch I had added "if (i)" there, 
so that this is only printed if there actually are retries.


But this is fine too (or even dropping the print totally), so:

Reviewed-by: Tomi Valkeinen 

 Tomi



Re: [PATCH v2 1/8] drm: xlnx: Fix kerneldoc

2024-03-19 Thread Tomi Valkeinen

On 20/03/2024 00:51, Sean Anderson wrote:

Fix a few errors in the kerneldoc. Mostly this addresses missing/renamed
members.

Signed-off-by: Sean Anderson 
---

Changes in v2:
- New

  drivers/gpu/drm/xlnx/zynqmp_disp.c  | 6 +++---
  drivers/gpu/drm/xlnx/zynqmp_dpsub.h | 1 +
  drivers/gpu/drm/xlnx/zynqmp_kms.h   | 4 ++--
  3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/xlnx/zynqmp_disp.c 
b/drivers/gpu/drm/xlnx/zynqmp_disp.c
index 407bc07cec69..f79bf3fb8110 100644
--- a/drivers/gpu/drm/xlnx/zynqmp_disp.c
+++ b/drivers/gpu/drm/xlnx/zynqmp_disp.c
@@ -128,9 +128,9 @@ struct zynqmp_disp_layer {
   * struct zynqmp_disp - Display controller
   * @dev: Device structure
   * @dpsub: Display subsystem
- * @blend.base: Register I/O base address for the blender
- * @avbuf.base: Register I/O base address for the audio/video buffer manager
- * @audio.base: Registers I/O base address for the audio mixer
+ * @blend: Register I/O base address for the blender
+ * @avbuf: Register I/O base address for the audio/video buffer manager
+ * @audio: Registers I/O base address for the audio mixer


Afaics, the kernel doc guide:

https://docs.kernel.org/doc-guide/kernel-doc.html#nested-structs-unions

says that the current version is correct. Or is the issue that while, 
say, 'base' is documented, 'blend' was not?


 Tomi



Re: [PATCH v2 11/14] drm/mediatek: Rename files "mtk_drm_plane.c" to "mtk_plane.c"

2024-03-19 Thread 宋孝謙


Re: [PATCH] video: fbdev: au1200fb: replace deprecated strncpy with strscpy

2024-03-19 Thread Kees Cook
On Mon, Mar 18, 2024 at 11:46:33PM +, Justin Stitt wrote:
> strncpy() is deprecated for use on NUL-terminated destination strings
> [1] and as such we should prefer more robust and less ambiguous string
> interfaces.
> 
> Let's use the new 2-argument strscpy() which guarantees NUL-termination
> on the destination buffer while also simplifying the syntax. Note that
> strscpy() will not NUL-pad the destination buffer like strncpy() does.
> 
> However, the NUL-padding behavior of strncpy() is not required since
> fbdev is already NUL-allocated from au1200fb_drv_probe() ->
> frameuffer_alloc(), rendering any additional NUL-padding redundant.
> | p = kzalloc(fb_info_size + size, GFP_KERNEL);
> 
> Link: 
> https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings
>  [1]
> Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html 
> [2]
> Link: https://github.com/KSPP/linux/issues/90
> Cc: linux-harden...@vger.kernel.org
> Signed-off-by: Justin Stitt 

Yup, looks correct.

Reviewed-by: Kees Cook 

-- 
Kees Cook


[PATCH v3 10/14] drm/mediatek: Rename files "mtk_drm_plane.h" to "mtk_plane.h"

2024-03-19 Thread Shawn Sung
From: Hsiao Chien Sung 

Rename files mtk_drm_plane.h to mtk_plane.h.

Reviewed-by: AngeloGioacchino Del Regno 

Reviewed-by: CK Hu 
Signed-off-by: Hsiao Chien Sung 
---
 drivers/gpu/drm/mediatek/mtk_crtc.c   | 2 +-
 drivers/gpu/drm/mediatek/mtk_crtc.h   | 2 +-
 drivers/gpu/drm/mediatek/mtk_ddp_comp.c   | 2 +-
 drivers/gpu/drm/mediatek/mtk_disp_drv.h   | 2 +-
 drivers/gpu/drm/mediatek/mtk_drm_plane.c  | 2 +-
 drivers/gpu/drm/mediatek/{mtk_drm_plane.h => mtk_plane.h} | 0
 6 files changed, 5 insertions(+), 5 deletions(-)
 rename drivers/gpu/drm/mediatek/{mtk_drm_plane.h => mtk_plane.h} (100%)

diff --git a/drivers/gpu/drm/mediatek/mtk_crtc.c 
b/drivers/gpu/drm/mediatek/mtk_crtc.c
index 7710e539e3da1..1ba47e65a32da 100644
--- a/drivers/gpu/drm/mediatek/mtk_crtc.c
+++ b/drivers/gpu/drm/mediatek/mtk_crtc.c
@@ -23,7 +23,7 @@
 #include "mtk_ddp_comp.h"
 #include "mtk_drm_drv.h"
 #include "mtk_drm_gem.h"
-#include "mtk_drm_plane.h"
+#include "mtk_plane.h"

 /*
  * struct mtk_crtc - MediaTek specific crtc structure.
diff --git a/drivers/gpu/drm/mediatek/mtk_crtc.h 
b/drivers/gpu/drm/mediatek/mtk_crtc.h
index fd6c006f0c169..388e900b6f4de 100644
--- a/drivers/gpu/drm/mediatek/mtk_crtc.h
+++ b/drivers/gpu/drm/mediatek/mtk_crtc.h
@@ -9,7 +9,7 @@
 #include 
 #include "mtk_ddp_comp.h"
 #include "mtk_drm_drv.h"
-#include "mtk_drm_plane.h"
+#include "mtk_plane.h"

 #define MTK_MAX_BPC10
 #define MTK_MIN_BPC3
diff --git a/drivers/gpu/drm/mediatek/mtk_ddp_comp.c 
b/drivers/gpu/drm/mediatek/mtk_ddp_comp.c
index ab96b1001de3e..c3441508f452f 100644
--- a/drivers/gpu/drm/mediatek/mtk_ddp_comp.c
+++ b/drivers/gpu/drm/mediatek/mtk_ddp_comp.c
@@ -18,7 +18,7 @@
 #include "mtk_ddp_comp.h"
 #include "mtk_disp_drv.h"
 #include "mtk_drm_drv.h"
-#include "mtk_drm_plane.h"
+#include "mtk_plane.h"


 #define DISP_REG_DITHER_EN 0x
diff --git a/drivers/gpu/drm/mediatek/mtk_disp_drv.h 
b/drivers/gpu/drm/mediatek/mtk_disp_drv.h
index 90e64467ea8f8..082ac18fe04aa 100644
--- a/drivers/gpu/drm/mediatek/mtk_disp_drv.h
+++ b/drivers/gpu/drm/mediatek/mtk_disp_drv.h
@@ -9,8 +9,8 @@
 #include 
 #include 
 #include 
-#include "mtk_drm_plane.h"
 #include "mtk_mdp_rdma.h"
+#include "mtk_plane.h"

 int mtk_aal_clk_enable(struct device *dev);
 void mtk_aal_clk_disable(struct device *dev);
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c 
b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
index 63a7a24468c13..95a4328a9b0b6 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
@@ -17,7 +17,7 @@
 #include "mtk_ddp_comp.h"
 #include "mtk_drm_drv.h"
 #include "mtk_drm_gem.h"
-#include "mtk_drm_plane.h"
+#include "mtk_plane.h"

 static const u64 modifiers[] = {
DRM_FORMAT_MOD_LINEAR,
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.h 
b/drivers/gpu/drm/mediatek/mtk_plane.h
similarity index 100%
rename from drivers/gpu/drm/mediatek/mtk_drm_plane.h
rename to drivers/gpu/drm/mediatek/mtk_plane.h
--
2.18.0



[PATCH v3 02/14] drm/mediatek: Rename "mtk_drm_ddp_comp" to "mtk_ddp_comp"

2024-03-19 Thread Shawn Sung
From: Hsiao Chien Sung 

Rename all "mtk_drm_ddp_comp" to "mtk_ddp_comp":
- To align the naming rule
- To reduce the code size

Reviewed-by: AngeloGioacchino Del Regno 

Reviewed-by: CK Hu 
Signed-off-by: Hsiao Chien Sung 
---
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 16 +++-
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h |  6 +++---
 2 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c 
b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
index 8a4b68898c601..16a6fc0bbdc9e 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
@@ -278,9 +278,9 @@ static void mtk_crtc_ddp_clk_disable(struct mtk_crtc 
*mtk_crtc)
 }
 
 static
-struct mtk_ddp_comp *mtk_drm_ddp_comp_for_plane(struct drm_crtc *crtc,
-   struct drm_plane *plane,
-   unsigned int *local_layer)
+struct mtk_ddp_comp *mtk_ddp_comp_for_plane(struct drm_crtc *crtc,
+   struct drm_plane *plane,
+   unsigned int *local_layer)
 {
struct mtk_crtc *mtk_crtc = to_mtk_crtc(crtc);
struct mtk_ddp_comp *comp;
@@ -430,7 +430,7 @@ static int mtk_crtc_ddp_hw_init(struct mtk_crtc *mtk_crtc)
 
/* should not enable layer before crtc enabled */
plane_state->pending.enable = false;
-   comp = mtk_drm_ddp_comp_for_plane(crtc, plane, _layer);
+   comp = mtk_ddp_comp_for_plane(crtc, plane, _layer);
if (comp)
mtk_ddp_comp_layer_config(comp, local_layer,
  plane_state, NULL);
@@ -521,8 +521,7 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc,
if (!plane_state->pending.config)
continue;
 
-   comp = mtk_drm_ddp_comp_for_plane(crtc, plane,
- _layer);
+   comp = mtk_ddp_comp_for_plane(crtc, plane, 
_layer);
 
if (comp)
mtk_ddp_comp_layer_config(comp, local_layer,
@@ -546,8 +545,7 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc,
if (!plane_state->pending.async_config)
continue;
 
-   comp = mtk_drm_ddp_comp_for_plane(crtc, plane,
- _layer);
+   comp = mtk_ddp_comp_for_plane(crtc, plane, 
_layer);
 
if (comp)
mtk_ddp_comp_layer_config(comp, local_layer,
@@ -711,7 +709,7 @@ int mtk_crtc_plane_check(struct drm_crtc *crtc, struct 
drm_plane *plane,
unsigned int local_layer;
struct mtk_ddp_comp *comp;
 
-   comp = mtk_drm_ddp_comp_for_plane(crtc, plane, _layer);
+   comp = mtk_ddp_comp_for_plane(crtc, plane, _layer);
if (comp)
return mtk_ddp_comp_layer_check(comp, local_layer, state);
return 0;
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h 
b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h
index 93d79a1366e91..ba985206fdd24 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h
+++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h
@@ -3,8 +3,8 @@
  * Copyright (c) 2015 MediaTek Inc.
  */
 
-#ifndef MTK_DRM_DDP_COMP_H
-#define MTK_DRM_DDP_COMP_H
+#ifndef MTK_DDP_COMP_H
+#define MTK_DDP_COMP_H
 
 #include 
 #include 
@@ -340,4 +340,4 @@ void mtk_ddp_write_relaxed(struct cmdq_pkt *cmdq_pkt, 
unsigned int value,
 void mtk_ddp_write_mask(struct cmdq_pkt *cmdq_pkt, unsigned int value,
struct cmdq_client_reg *cmdq_reg, void __iomem *regs,
unsigned int offset, unsigned int mask);
-#endif /* MTK_DRM_DDP_COMP_H */
+#endif /* MTK_DDP_COMP_H */
-- 
2.18.0



[PATCH v3 01/14] drm/mediatek: Rename "mtk_drm_crtc" to "mtk_crtc"

2024-03-19 Thread Shawn Sung
From: Hsiao Chien Sung 

Rename all "mtk_drm_crtc" to "mtk_crtc" due to the following benefits:
- Lower the matches when searching the native drm_crtc* codes
- Reduce the code size

Reviewed-by: AngeloGioacchino Del Regno 

Reviewed-by: CK Hu 
Signed-off-by: Hsiao Chien Sung 
---
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c  | 189 +++
 drivers/gpu/drm/mediatek/mtk_drm_crtc.h  |  28 ++--
 drivers/gpu/drm/mediatek/mtk_drm_drv.c   |  18 +--
 drivers/gpu/drm/mediatek/mtk_drm_drv.h   |   2 +-
 drivers/gpu/drm/mediatek/mtk_drm_plane.c |  10 +-
 drivers/gpu/drm/mediatek/mtk_dsi.c   |   2 +-
 6 files changed, 119 insertions(+), 130 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c 
b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
index a04499c4f9ca2..8a4b68898c601 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
@@ -26,7 +26,7 @@
 #include "mtk_drm_plane.h"

 /*
- * struct mtk_drm_crtc - MediaTek specific crtc structure.
+ * struct mtk_crtc - MediaTek specific crtc structure.
  * @base: crtc object.
  * @enabled: records whether crtc_enable succeeded
  * @planes: array of 4 drm_plane structures, one for each overlay plane
@@ -38,7 +38,7 @@
  *
  * TODO: Needs update: this header is missing a bunch of member descriptions.
  */
-struct mtk_drm_crtc {
+struct mtk_crtc {
struct drm_crtc base;
boolenabled;

@@ -80,9 +80,9 @@ struct mtk_crtc_state {
unsigned intpending_vrefresh;
 };

-static inline struct mtk_drm_crtc *to_mtk_crtc(struct drm_crtc *c)
+static inline struct mtk_crtc *to_mtk_crtc(struct drm_crtc *c)
 {
-   return container_of(c, struct mtk_drm_crtc, base);
+   return container_of(c, struct mtk_crtc, base);
 }

 static inline struct mtk_crtc_state *to_mtk_crtc_state(struct drm_crtc_state 
*s)
@@ -90,7 +90,7 @@ static inline struct mtk_crtc_state *to_mtk_crtc_state(struct 
drm_crtc_state *s)
return container_of(s, struct mtk_crtc_state, base);
 }

-static void mtk_drm_crtc_finish_page_flip(struct mtk_drm_crtc *mtk_crtc)
+static void mtk_crtc_finish_page_flip(struct mtk_crtc *mtk_crtc)
 {
struct drm_crtc *crtc = _crtc->base;
unsigned long flags;
@@ -104,11 +104,11 @@ static void mtk_drm_crtc_finish_page_flip(struct 
mtk_drm_crtc *mtk_crtc)
}
 }

-static void mtk_drm_finish_page_flip(struct mtk_drm_crtc *mtk_crtc)
+static void mtk_drm_finish_page_flip(struct mtk_crtc *mtk_crtc)
 {
drm_crtc_handle_vblank(_crtc->base);
if (!mtk_crtc->config_updating && mtk_crtc->pending_needs_vblank) {
-   mtk_drm_crtc_finish_page_flip(mtk_crtc);
+   mtk_crtc_finish_page_flip(mtk_crtc);
mtk_crtc->pending_needs_vblank = false;
}
 }
@@ -151,9 +151,9 @@ static void mtk_drm_cmdq_pkt_destroy(struct cmdq_pkt *pkt)
 }
 #endif

-static void mtk_drm_crtc_destroy(struct drm_crtc *crtc)
+static void mtk_crtc_destroy(struct drm_crtc *crtc)
 {
-   struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
+   struct mtk_crtc *mtk_crtc = to_mtk_crtc(crtc);
int i;

mtk_mutex_put(mtk_crtc->mutex);
@@ -176,7 +176,7 @@ static void mtk_drm_crtc_destroy(struct drm_crtc *crtc)
drm_crtc_cleanup(crtc);
 }

-static void mtk_drm_crtc_reset(struct drm_crtc *crtc)
+static void mtk_crtc_reset(struct drm_crtc *crtc)
 {
struct mtk_crtc_state *state;

@@ -191,7 +191,7 @@ static void mtk_drm_crtc_reset(struct drm_crtc *crtc)
__drm_atomic_helper_crtc_reset(crtc, >base);
 }

-static struct drm_crtc_state *mtk_drm_crtc_duplicate_state(struct drm_crtc 
*crtc)
+static struct drm_crtc_state *mtk_crtc_duplicate_state(struct drm_crtc *crtc)
 {
struct mtk_crtc_state *state;

@@ -208,18 +208,17 @@ static struct drm_crtc_state 
*mtk_drm_crtc_duplicate_state(struct drm_crtc *crtc
return >base;
 }

-static void mtk_drm_crtc_destroy_state(struct drm_crtc *crtc,
-  struct drm_crtc_state *state)
+static void mtk_crtc_destroy_state(struct drm_crtc *crtc,
+  struct drm_crtc_state *state)
 {
__drm_atomic_helper_crtc_destroy_state(state);
kfree(to_mtk_crtc_state(state));
 }

 static enum drm_mode_status
-mtk_drm_crtc_mode_valid(struct drm_crtc *crtc,
-   const struct drm_display_mode *mode)
+mtk_crtc_mode_valid(struct drm_crtc *crtc, const struct drm_display_mode *mode)
 {
-   struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
+   struct mtk_crtc *mtk_crtc = to_mtk_crtc(crtc);
enum drm_mode_status status = MODE_OK;
int i;

@@ -231,15 +230,15 @@ mtk_drm_crtc_mode_valid(struct drm_crtc *crtc,
return status;
 }

-static bool mtk_drm_crtc_mode_fixup(struct drm_crtc *crtc,
-   const struct drm_display_mode *mode,
-   struct drm_display_mode *adjusted_mode)

[PATCH v3 04/14] drm/mediatek: Rename "mtk_drm_gem" to "mtk_gem"

2024-03-19 Thread Shawn Sung
From: Hsiao Chien Sung 

Rename all "mtk_drm_gem" to "mtk_gem":
- To align the naming rule
- To reduce the code size

Reviewed-by: AngeloGioacchino Del Regno 

Reviewed-by: CK Hu 
Signed-off-by: Hsiao Chien Sung 
---
 drivers/gpu/drm/mediatek/mtk_drm_drv.c   |  8 +--
 drivers/gpu/drm/mediatek/mtk_drm_gem.c   | 63 
 drivers/gpu/drm/mediatek/mtk_drm_gem.h   | 23 +
 drivers/gpu/drm/mediatek/mtk_drm_plane.c |  2 +-
 4 files changed, 47 insertions(+), 49 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c 
b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
index c46773569b3c9..81e8aa65abd6d 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
@@ -576,8 +576,8 @@ DEFINE_DRM_GEM_FOPS(mtk_drm_fops);
  * We need to override this because the device used to import the memory is
  * not dev->dev, as drm_gem_prime_import() expects.
  */
-static struct drm_gem_object *mtk_drm_gem_prime_import(struct drm_device *dev,
-  struct dma_buf *dma_buf)
+static struct drm_gem_object *mtk_gem_prime_import(struct drm_device *dev,
+  struct dma_buf *dma_buf)
 {
struct mtk_drm_private *private = dev->dev_private;

@@ -587,9 +587,9 @@ static struct drm_gem_object 
*mtk_drm_gem_prime_import(struct drm_device *dev,
 static const struct drm_driver mtk_drm_driver = {
.driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_ATOMIC,

-   .dumb_create = mtk_drm_gem_dumb_create,
+   .dumb_create = mtk_gem_dumb_create,

-   .gem_prime_import = mtk_drm_gem_prime_import,
+   .gem_prime_import = mtk_gem_prime_import,
.gem_prime_import_sg_table = mtk_gem_prime_import_sg_table,
.fops = _drm_fops,

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_gem.c 
b/drivers/gpu/drm/mediatek/mtk_drm_gem.c
index 4f2e3feabc0f8..445fd8a8b8988 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_gem.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_gem.c
@@ -14,26 +14,26 @@
 #include "mtk_drm_drv.h"
 #include "mtk_drm_gem.h"

-static int mtk_drm_gem_object_mmap(struct drm_gem_object *obj, struct 
vm_area_struct *vma);
+static int mtk_gem_object_mmap(struct drm_gem_object *obj, struct 
vm_area_struct *vma);

 static const struct vm_operations_struct vm_ops = {
.open = drm_gem_vm_open,
.close = drm_gem_vm_close,
 };

-static const struct drm_gem_object_funcs mtk_drm_gem_object_funcs = {
-   .free = mtk_drm_gem_free_object,
+static const struct drm_gem_object_funcs mtk_gem_object_funcs = {
+   .free = mtk_gem_free_object,
.get_sg_table = mtk_gem_prime_get_sg_table,
-   .vmap = mtk_drm_gem_prime_vmap,
-   .vunmap = mtk_drm_gem_prime_vunmap,
-   .mmap = mtk_drm_gem_object_mmap,
+   .vmap = mtk_gem_prime_vmap,
+   .vunmap = mtk_gem_prime_vunmap,
+   .mmap = mtk_gem_object_mmap,
.vm_ops = _ops,
 };

-static struct mtk_drm_gem_obj *mtk_drm_gem_init(struct drm_device *dev,
-   unsigned long size)
+static struct mtk_gem_obj *mtk_gem_init(struct drm_device *dev,
+   unsigned long size)
 {
-   struct mtk_drm_gem_obj *mtk_gem_obj;
+   struct mtk_gem_obj *mtk_gem_obj;
int ret;

size = round_up(size, PAGE_SIZE);
@@ -42,7 +42,7 @@ static struct mtk_drm_gem_obj *mtk_drm_gem_init(struct 
drm_device *dev,
if (!mtk_gem_obj)
return ERR_PTR(-ENOMEM);

-   mtk_gem_obj->base.funcs = _drm_gem_object_funcs;
+   mtk_gem_obj->base.funcs = _gem_object_funcs;

ret = drm_gem_object_init(dev, _gem_obj->base, size);
if (ret < 0) {
@@ -54,15 +54,15 @@ static struct mtk_drm_gem_obj *mtk_drm_gem_init(struct 
drm_device *dev,
return mtk_gem_obj;
 }

-struct mtk_drm_gem_obj *mtk_drm_gem_create(struct drm_device *dev,
-  size_t size, bool alloc_kmap)
+struct mtk_gem_obj *mtk_gem_create(struct drm_device *dev,
+  size_t size, bool alloc_kmap)
 {
struct mtk_drm_private *priv = dev->dev_private;
-   struct mtk_drm_gem_obj *mtk_gem;
+   struct mtk_gem_obj *mtk_gem;
struct drm_gem_object *obj;
int ret;

-   mtk_gem = mtk_drm_gem_init(dev, size);
+   mtk_gem = mtk_gem_init(dev, size);
if (IS_ERR(mtk_gem))
return ERR_CAST(mtk_gem);

@@ -97,9 +97,9 @@ struct mtk_drm_gem_obj *mtk_drm_gem_create(struct drm_device 
*dev,
return ERR_PTR(ret);
 }

-void mtk_drm_gem_free_object(struct drm_gem_object *obj)
+void mtk_gem_free_object(struct drm_gem_object *obj)
 {
-   struct mtk_drm_gem_obj *mtk_gem = to_mtk_gem_obj(obj);
+   struct mtk_gem_obj *mtk_gem = to_mtk_gem_obj(obj);
struct mtk_drm_private *priv = obj->dev->dev_private;

if (mtk_gem->sg)
@@ -114,10 +114,10 @@ void mtk_drm_gem_free_object(struct drm_gem_object *obj)
   

[PATCH v3 06/14] drm/mediatek: Rename files "mtk_drm_crtc.h" to "mtk_crtc.h"

2024-03-19 Thread Shawn Sung
From: Hsiao Chien Sung 

Rename files mtk_drm_crtc.h to mtk_crtc.h.

Reviewed-by: AngeloGioacchino Del Regno 

Reviewed-by: CK Hu 
Signed-off-by: Hsiao Chien Sung 
---
 drivers/gpu/drm/mediatek/{mtk_drm_crtc.h => mtk_crtc.h} | 0
 drivers/gpu/drm/mediatek/mtk_disp_aal.c | 2 +-
 drivers/gpu/drm/mediatek/mtk_disp_ccorr.c   | 2 +-
 drivers/gpu/drm/mediatek/mtk_disp_color.c   | 2 +-
 drivers/gpu/drm/mediatek/mtk_disp_gamma.c   | 2 +-
 drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 2 +-
 drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c | 2 +-
 drivers/gpu/drm/mediatek/mtk_disp_rdma.c| 2 +-
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 2 +-
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 2 +-
 drivers/gpu/drm/mediatek/mtk_drm_drv.c  | 2 +-
 drivers/gpu/drm/mediatek/mtk_drm_plane.c| 2 +-
 drivers/gpu/drm/mediatek/mtk_ethdr.c| 2 +-
 drivers/gpu/drm/mediatek/mtk_padding.c  | 2 +-
 14 files changed, 13 insertions(+), 13 deletions(-)
 rename drivers/gpu/drm/mediatek/{mtk_drm_crtc.h => mtk_crtc.h} (100%)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.h 
b/drivers/gpu/drm/mediatek/mtk_crtc.h
similarity index 100%
rename from drivers/gpu/drm/mediatek/mtk_drm_crtc.h
rename to drivers/gpu/drm/mediatek/mtk_crtc.h
diff --git a/drivers/gpu/drm/mediatek/mtk_disp_aal.c 
b/drivers/gpu/drm/mediatek/mtk_disp_aal.c
index 40fe403086c3d..ba926e797af8a 100644
--- a/drivers/gpu/drm/mediatek/mtk_disp_aal.c
+++ b/drivers/gpu/drm/mediatek/mtk_disp_aal.c
@@ -11,8 +11,8 @@
 #include 
 #include 

+#include "mtk_crtc.h"
 #include "mtk_disp_drv.h"
-#include "mtk_drm_crtc.h"
 #include "mtk_drm_ddp_comp.h"
 #include "mtk_drm_drv.h"

diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ccorr.c 
b/drivers/gpu/drm/mediatek/mtk_disp_ccorr.c
index 465cddce0d324..79bcd3c487563 100644
--- a/drivers/gpu/drm/mediatek/mtk_disp_ccorr.c
+++ b/drivers/gpu/drm/mediatek/mtk_disp_ccorr.c
@@ -10,8 +10,8 @@
 #include 
 #include 

+#include "mtk_crtc.h"
 #include "mtk_disp_drv.h"
-#include "mtk_drm_crtc.h"
 #include "mtk_drm_ddp_comp.h"
 #include "mtk_drm_drv.h"

diff --git a/drivers/gpu/drm/mediatek/mtk_disp_color.c 
b/drivers/gpu/drm/mediatek/mtk_disp_color.c
index 78ea99f1444fa..4aa41b1ff2602 100644
--- a/drivers/gpu/drm/mediatek/mtk_disp_color.c
+++ b/drivers/gpu/drm/mediatek/mtk_disp_color.c
@@ -10,8 +10,8 @@
 #include 
 #include 

+#include "mtk_crtc.h"
 #include "mtk_disp_drv.h"
-#include "mtk_drm_crtc.h"
 #include "mtk_drm_ddp_comp.h"
 #include "mtk_drm_drv.h"

diff --git a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c 
b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c
index c1bc8b00d9380..1a1ee77127ee9 100644
--- a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c
+++ b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c
@@ -11,8 +11,8 @@
 #include 
 #include 

+#include "mtk_crtc.h"
 #include "mtk_disp_drv.h"
-#include "mtk_drm_crtc.h"
 #include "mtk_drm_ddp_comp.h"
 #include "mtk_drm_drv.h"

diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c 
b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
index 2bffe42454666..7f2219c0119be 100644
--- a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
+++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
@@ -15,8 +15,8 @@
 #include 
 #include 

+#include "mtk_crtc.h"
 #include "mtk_disp_drv.h"
-#include "mtk_drm_crtc.h"
 #include "mtk_drm_ddp_comp.h"
 #include "mtk_drm_drv.h"

diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c 
b/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c
index 034d31824d4dc..542dc2a20ea90 100644
--- a/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c
+++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c
@@ -17,8 +17,8 @@
 #include 
 #include 

+#include "mtk_crtc.h"
 #include "mtk_disp_drv.h"
-#include "mtk_drm_crtc.h"
 #include "mtk_drm_ddp_comp.h"
 #include "mtk_drm_drv.h"
 #include "mtk_ethdr.h"
diff --git a/drivers/gpu/drm/mediatek/mtk_disp_rdma.c 
b/drivers/gpu/drm/mediatek/mtk_disp_rdma.c
index faa907f2f443e..04f584372214f 100644
--- a/drivers/gpu/drm/mediatek/mtk_disp_rdma.c
+++ b/drivers/gpu/drm/mediatek/mtk_disp_rdma.c
@@ -13,8 +13,8 @@
 #include 
 #include 

+#include "mtk_crtc.h"
 #include "mtk_disp_drv.h"
-#include "mtk_drm_crtc.h"
 #include "mtk_drm_ddp_comp.h"
 #include "mtk_drm_drv.h"

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c 
b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
index 16a6fc0bbdc9e..631c1ef2847ef 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
@@ -19,8 +19,8 @@
 #include 
 #include 

+#include "mtk_crtc.h"
 #include "mtk_drm_drv.h"
-#include "mtk_drm_crtc.h"
 #include "mtk_drm_ddp_comp.h"
 #include "mtk_drm_gem.h"
 #include "mtk_drm_plane.h"
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c 
b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
index a515e96cfefcb..24389c6c3561f 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
+++ 

[PATCH v3 05/14] drm/mediatek: Rename "mtk_drm_hdmi" to "mtk_hdmi"

2024-03-19 Thread Shawn Sung
From: Hsiao Chien Sung 

Rename all "mtk_drm_hdmi" to "mtk_hdmi":
- To align the naming rule
- To reduce the code size

Reviewed-by: AngeloGioacchino Del Regno 

Reviewed-by: CK Hu 
Signed-off-by: Hsiao Chien Sung 
---
 drivers/gpu/drm/mediatek/mtk_hdmi.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c 
b/drivers/gpu/drm/mediatek/mtk_hdmi.c
index 86133bf16326b..d2876da1b43a7 100644
--- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
+++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
@@ -1687,7 +1687,7 @@ static int mtk_hdmi_register_audio_driver(struct device 
*dev)
return 0;
 }

-static int mtk_drm_hdmi_probe(struct platform_device *pdev)
+static int mtk_hdmi_probe(struct platform_device *pdev)
 {
struct mtk_hdmi *hdmi;
struct device *dev = >dev;
@@ -1746,7 +1746,7 @@ static int mtk_drm_hdmi_probe(struct platform_device 
*pdev)
return ret;
 }

-static void mtk_drm_hdmi_remove(struct platform_device *pdev)
+static void mtk_hdmi_remove(struct platform_device *pdev)
 {
struct mtk_hdmi *hdmi = platform_get_drvdata(pdev);

@@ -1790,7 +1790,7 @@ static const struct mtk_hdmi_conf mtk_hdmi_conf_mt8167 = {
.cea_modes_only = true,
 };

-static const struct of_device_id mtk_drm_hdmi_of_ids[] = {
+static const struct of_device_id mtk_hdmi_of_ids[] = {
{ .compatible = "mediatek,mt2701-hdmi",
  .data = _hdmi_conf_mt2701,
},
@@ -1801,14 +1801,14 @@ static const struct of_device_id mtk_drm_hdmi_of_ids[] 
= {
},
{}
 };
-MODULE_DEVICE_TABLE(of, mtk_drm_hdmi_of_ids);
+MODULE_DEVICE_TABLE(of, mtk_hdmi_of_ids);

 static struct platform_driver mtk_hdmi_driver = {
-   .probe = mtk_drm_hdmi_probe,
-   .remove_new = mtk_drm_hdmi_remove,
+   .probe = mtk_hdmi_probe,
+   .remove_new = mtk_hdmi_remove,
.driver = {
.name = "mediatek-drm-hdmi",
-   .of_match_table = mtk_drm_hdmi_of_ids,
+   .of_match_table = mtk_hdmi_of_ids,
.pm = _hdmi_pm_ops,
},
 };
--
2.18.0



[PATCH v3 08/14] drm/mediatek: Rename files "mtk_drm_ddp_comp.h" to "mtk_ddp_comp.h"

2024-03-19 Thread Shawn Sung
From: Hsiao Chien Sung 

Rename files mtk_drm_ddp_comp.h to mtk_ddp_comp.h.

Reviewed-by: AngeloGioacchino Del Regno 

Reviewed-by: CK Hu 
Signed-off-by: Hsiao Chien Sung 
---
 drivers/gpu/drm/mediatek/mtk_crtc.c | 2 +-
 drivers/gpu/drm/mediatek/mtk_crtc.h | 2 +-
 drivers/gpu/drm/mediatek/{mtk_drm_ddp_comp.h => mtk_ddp_comp.h} | 0
 drivers/gpu/drm/mediatek/mtk_disp_aal.c | 2 +-
 drivers/gpu/drm/mediatek/mtk_disp_ccorr.c   | 2 +-
 drivers/gpu/drm/mediatek/mtk_disp_color.c   | 2 +-
 drivers/gpu/drm/mediatek/mtk_disp_gamma.c   | 2 +-
 drivers/gpu/drm/mediatek/mtk_disp_merge.c   | 2 +-
 drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 2 +-
 drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c | 2 +-
 drivers/gpu/drm/mediatek/mtk_disp_rdma.c| 2 +-
 drivers/gpu/drm/mediatek/mtk_dpi.c  | 2 +-
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 2 +-
 drivers/gpu/drm/mediatek/mtk_drm_drv.c  | 2 +-
 drivers/gpu/drm/mediatek/mtk_drm_drv.h  | 2 +-
 drivers/gpu/drm/mediatek/mtk_drm_plane.c| 2 +-
 drivers/gpu/drm/mediatek/mtk_dsi.c  | 2 +-
 drivers/gpu/drm/mediatek/mtk_ethdr.c| 2 +-
 drivers/gpu/drm/mediatek/mtk_padding.c  | 2 +-
 19 files changed, 18 insertions(+), 18 deletions(-)
 rename drivers/gpu/drm/mediatek/{mtk_drm_ddp_comp.h => mtk_ddp_comp.h} (100%)

diff --git a/drivers/gpu/drm/mediatek/mtk_crtc.c 
b/drivers/gpu/drm/mediatek/mtk_crtc.c
index 631c1ef2847ef..7710e539e3da1 100644
--- a/drivers/gpu/drm/mediatek/mtk_crtc.c
+++ b/drivers/gpu/drm/mediatek/mtk_crtc.c
@@ -20,8 +20,8 @@
 #include 

 #include "mtk_crtc.h"
+#include "mtk_ddp_comp.h"
 #include "mtk_drm_drv.h"
-#include "mtk_drm_ddp_comp.h"
 #include "mtk_drm_gem.h"
 #include "mtk_drm_plane.h"

diff --git a/drivers/gpu/drm/mediatek/mtk_crtc.h 
b/drivers/gpu/drm/mediatek/mtk_crtc.h
index 2d9f28f436aea..fd6c006f0c169 100644
--- a/drivers/gpu/drm/mediatek/mtk_crtc.h
+++ b/drivers/gpu/drm/mediatek/mtk_crtc.h
@@ -7,7 +7,7 @@
 #define MTK_CRTC_H

 #include 
-#include "mtk_drm_ddp_comp.h"
+#include "mtk_ddp_comp.h"
 #include "mtk_drm_drv.h"
 #include "mtk_drm_plane.h"

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h 
b/drivers/gpu/drm/mediatek/mtk_ddp_comp.h
similarity index 100%
rename from drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h
rename to drivers/gpu/drm/mediatek/mtk_ddp_comp.h
diff --git a/drivers/gpu/drm/mediatek/mtk_disp_aal.c 
b/drivers/gpu/drm/mediatek/mtk_disp_aal.c
index ba926e797af8a..92acdaddd648d 100644
--- a/drivers/gpu/drm/mediatek/mtk_disp_aal.c
+++ b/drivers/gpu/drm/mediatek/mtk_disp_aal.c
@@ -12,8 +12,8 @@
 #include 

 #include "mtk_crtc.h"
+#include "mtk_ddp_comp.h"
 #include "mtk_disp_drv.h"
-#include "mtk_drm_ddp_comp.h"
 #include "mtk_drm_drv.h"

 #define DISP_AAL_EN0x
diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ccorr.c 
b/drivers/gpu/drm/mediatek/mtk_disp_ccorr.c
index 79bcd3c487563..975ee45a0f72c 100644
--- a/drivers/gpu/drm/mediatek/mtk_disp_ccorr.c
+++ b/drivers/gpu/drm/mediatek/mtk_disp_ccorr.c
@@ -11,8 +11,8 @@
 #include 

 #include "mtk_crtc.h"
+#include "mtk_ddp_comp.h"
 #include "mtk_disp_drv.h"
-#include "mtk_drm_ddp_comp.h"
 #include "mtk_drm_drv.h"

 #define DISP_CCORR_EN  0x
diff --git a/drivers/gpu/drm/mediatek/mtk_disp_color.c 
b/drivers/gpu/drm/mediatek/mtk_disp_color.c
index 4aa41b1ff2602..91e7837a32c86 100644
--- a/drivers/gpu/drm/mediatek/mtk_disp_color.c
+++ b/drivers/gpu/drm/mediatek/mtk_disp_color.c
@@ -11,8 +11,8 @@
 #include 

 #include "mtk_crtc.h"
+#include "mtk_ddp_comp.h"
 #include "mtk_disp_drv.h"
-#include "mtk_drm_ddp_comp.h"
 #include "mtk_drm_drv.h"

 #define DISP_COLOR_CFG_MAIN0x0400
diff --git a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c 
b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c
index 1a1ee77127ee9..51ae4f947c714 100644
--- a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c
+++ b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c
@@ -12,8 +12,8 @@
 #include 

 #include "mtk_crtc.h"
+#include "mtk_ddp_comp.h"
 #include "mtk_disp_drv.h"
-#include "mtk_drm_ddp_comp.h"
 #include "mtk_drm_drv.h"

 #define DISP_GAMMA_EN  0x
diff --git a/drivers/gpu/drm/mediatek/mtk_disp_merge.c 
b/drivers/gpu/drm/mediatek/mtk_disp_merge.c
index 32a29924bd54c..3b1e04ecb9d45 100644
--- a/drivers/gpu/drm/mediatek/mtk_disp_merge.c
+++ b/drivers/gpu/drm/mediatek/mtk_disp_merge.c
@@ -10,7 +10,7 @@
 #include 
 #include 

-#include "mtk_drm_ddp_comp.h"
+#include "mtk_ddp_comp.h"
 #include "mtk_drm_drv.h"
 #include "mtk_disp_drv.h"

diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c 
b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c

[PATCH v3 14/14] drm/mediatek: Rename mtk_ddp_comp functions

2024-03-19 Thread Shawn Sung
From: Hsiao Chien Sung 

Rename functions of mtk_ddp_comp:
- To align the naming rule
- To reduce the code size

Reviewed-by: AngeloGioacchino Del Regno 

Reviewed-by: CK Hu 
Signed-off-by: Hsiao Chien Sung 
---
 drivers/gpu/drm/mediatek/mtk_ddp_comp.c | 45 ++---
 drivers/gpu/drm/mediatek/mtk_ddp_comp.h |  3 +-
 drivers/gpu/drm/mediatek/mtk_dpi.c  |  2 +-
 drivers/gpu/drm/mediatek/mtk_dsi.c  |  2 +-
 4 files changed, 28 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_ddp_comp.c 
b/drivers/gpu/drm/mediatek/mtk_ddp_comp.c
index c3441508f452f..17b0364112922 100644
--- a/drivers/gpu/drm/mediatek/mtk_ddp_comp.c
+++ b/drivers/gpu/drm/mediatek/mtk_ddp_comp.c
@@ -497,10 +497,10 @@ static const struct mtk_ddp_comp_match 
mtk_ddp_matches[DDP_COMPONENT_DRM_ID_MAX]
[DDP_COMPONENT_WDMA1]   = { MTK_DISP_WDMA,  1, NULL 
},
 };

-static bool mtk_drm_find_comp_in_ddp(struct device *dev,
-const unsigned int *path,
-unsigned int path_len,
-struct mtk_ddp_comp *ddp_comp)
+static bool mtk_ddp_comp_find(struct device *dev,
+ const unsigned int *path,
+ unsigned int path_len,
+ struct mtk_ddp_comp *ddp_comp)
 {
unsigned int i;

@@ -514,10 +514,10 @@ static bool mtk_drm_find_comp_in_ddp(struct device *dev,
return false;
 }

-static unsigned int mtk_drm_find_comp_in_ddp_conn_path(struct device *dev,
-  const struct 
mtk_drm_route *routes,
-  unsigned int num_routes,
-  struct mtk_ddp_comp 
*ddp_comp)
+static unsigned int mtk_ddp_comp_find_in_route(struct device *dev,
+  const struct mtk_drm_route 
*routes,
+  unsigned int num_routes,
+  struct mtk_ddp_comp *ddp_comp)
 {
int ret;
unsigned int i;
@@ -554,26 +554,31 @@ int mtk_ddp_comp_get_id(struct device_node *node,
return -EINVAL;
 }

-unsigned int mtk_drm_find_possible_crtc_by_comp(struct drm_device *drm,
-   struct device *dev)
+unsigned int mtk_find_possible_crtcs(struct drm_device *drm, struct device 
*dev)
 {
struct mtk_drm_private *private = drm->dev_private;
unsigned int ret = 0;

-   if (mtk_drm_find_comp_in_ddp(dev, private->data->main_path, 
private->data->main_len,
-private->ddp_comp))
+   if (mtk_ddp_comp_find(dev,
+ private->data->main_path,
+ private->data->main_len,
+ private->ddp_comp))
ret = BIT(0);
-   else if (mtk_drm_find_comp_in_ddp(dev, private->data->ext_path,
- private->data->ext_len, 
private->ddp_comp))
+   else if (mtk_ddp_comp_find(dev,
+  private->data->ext_path,
+  private->data->ext_len,
+  private->ddp_comp))
ret = BIT(1);
-   else if (mtk_drm_find_comp_in_ddp(dev, private->data->third_path,
- private->data->third_len, 
private->ddp_comp))
+   else if (mtk_ddp_comp_find(dev,
+  private->data->third_path,
+  private->data->third_len,
+  private->ddp_comp))
ret = BIT(2);
else
-   ret = mtk_drm_find_comp_in_ddp_conn_path(dev,
-
private->data->conn_routes,
-
private->data->num_conn_routes,
-private->ddp_comp);
+   ret = mtk_ddp_comp_find_in_route(dev,
+private->data->conn_routes,
+private->data->num_conn_routes,
+private->ddp_comp);

return ret;
 }
diff --git a/drivers/gpu/drm/mediatek/mtk_ddp_comp.h 
b/drivers/gpu/drm/mediatek/mtk_ddp_comp.h
index ba985206fdd24..26236691ce4c2 100644
--- a/drivers/gpu/drm/mediatek/mtk_ddp_comp.h
+++ b/drivers/gpu/drm/mediatek/mtk_ddp_comp.h
@@ -326,8 +326,7 @@ static inline void mtk_ddp_comp_encoder_index_set(struct 
mtk_ddp_comp *comp)

 int mtk_ddp_comp_get_id(struct device_node *node,
enum mtk_ddp_comp_type comp_type);
-unsigned int mtk_drm_find_possible_crtc_by_comp(struct drm_device *drm,
-   

[PATCH v3 00/14] Rename mtk_drm_* to mtk_*

2024-03-19 Thread Shawn Sung
From: Hsiao Chien Sung 

Rename some unnecessary  "mtk_drm_*" to "mtk_*" because:
- Lower the matches when searching the native drm_* codes
- Reduce the code

Changes in v3:
- Fix typo and patch error

Changes in v2:
- Sort header files alphabetically
- Seperate patches for renaming .c files to avoid conflicts

This series is based on c958e86e9cc1b of mediatek-drm-next.

Hsiao Chien Sung (14):
  drm/mediatek: Rename "mtk_drm_crtc" to "mtk_crtc"
  drm/mediatek: Rename "mtk_drm_ddp_comp" to "mtk_ddp_comp"
  drm/mediatek: Rename "mtk_drm_plane" to "mtk_plane"
  drm/mediatek: Rename "mtk_drm_gem" to "mtk_gem"
  drm/mediatek: Rename "mtk_drm_hdmi" to "mtk_hdmi"
  drm/mediatek: Rename files "mtk_drm_crtc.h" to "mtk_crtc.h"
  drm/mediatek: Rename files "mtk_drm_crtc.c" to "mtk_crtc.c"
  drm/mediatek: Rename files "mtk_drm_ddp_comp.h" to "mtk_ddp_comp.h"
  drm/mediatek: Rename files "mtk_drm_ddp_comp.c" to "mtk_ddp_comp.c"
  drm/mediatek: Rename files "mtk_drm_plane.h" to "mtk_plane.h"
  drm/mediatek: Rename files "mtk_drm_plane.c" to "mtk_plane.c"
  drm/mediatek: Rename files "mtk_drm_gem.h" to "mtk_gem.h"
  drm/mediatek: Rename files "mtk_drm_gem.c" to "mtk_gem.c"
  drm/mediatek: Rename mtk_ddp_comp functions

 drivers/gpu/drm/mediatek/Makefile |  12 +-
 .../mediatek/{mtk_drm_crtc.c => mtk_crtc.c}   | 213 +-
 drivers/gpu/drm/mediatek/mtk_crtc.h   |  28 +++
 .../{mtk_drm_ddp_comp.c => mtk_ddp_comp.c}|  51 +++--
 .../{mtk_drm_ddp_comp.h => mtk_ddp_comp.h}|   9 +-
 drivers/gpu/drm/mediatek/mtk_disp_aal.c   |   4 +-
 drivers/gpu/drm/mediatek/mtk_disp_ccorr.c |   4 +-
 drivers/gpu/drm/mediatek/mtk_disp_color.c |   4 +-
 drivers/gpu/drm/mediatek/mtk_disp_drv.h   |   2 +-
 drivers/gpu/drm/mediatek/mtk_disp_gamma.c |   4 +-
 drivers/gpu/drm/mediatek/mtk_disp_merge.c |   2 +-
 drivers/gpu/drm/mediatek/mtk_disp_ovl.c   |   4 +-
 .../gpu/drm/mediatek/mtk_disp_ovl_adaptor.c   |   4 +-
 drivers/gpu/drm/mediatek/mtk_disp_rdma.c  |   4 +-
 drivers/gpu/drm/mediatek/mtk_dpi.c|   4 +-
 drivers/gpu/drm/mediatek/mtk_drm_crtc.h   |  30 ---
 drivers/gpu/drm/mediatek/mtk_drm_drv.c|  32 +--
 drivers/gpu/drm/mediatek/mtk_drm_drv.h|   4 +-
 drivers/gpu/drm/mediatek/mtk_dsi.c|   6 +-
 drivers/gpu/drm/mediatek/mtk_ethdr.c  |   4 +-
 .../drm/mediatek/{mtk_drm_gem.c => mtk_gem.c} |  65 +++---
 .../drm/mediatek/{mtk_drm_gem.h => mtk_gem.h} |  23 +-
 drivers/gpu/drm/mediatek/mtk_hdmi.c   |  14 +-
 drivers/gpu/drm/mediatek/mtk_padding.c|   4 +-
 .../mediatek/{mtk_drm_plane.c => mtk_plane.c} |  26 +--
 .../mediatek/{mtk_drm_plane.h => mtk_plane.h} |   4 +-
 26 files changed, 275 insertions(+), 286 deletions(-)
 rename drivers/gpu/drm/mediatek/{mtk_drm_crtc.c => mtk_crtc.c} (82%)
 create mode 100644 drivers/gpu/drm/mediatek/mtk_crtc.h
 rename drivers/gpu/drm/mediatek/{mtk_drm_ddp_comp.c => mtk_ddp_comp.c} (94%)
 rename drivers/gpu/drm/mediatek/{mtk_drm_ddp_comp.h => mtk_ddp_comp.h} (98%)
 delete mode 100644 drivers/gpu/drm/mediatek/mtk_drm_crtc.h
 rename drivers/gpu/drm/mediatek/{mtk_drm_gem.c => mtk_gem.c} (76%)
 rename drivers/gpu/drm/mediatek/{mtk_drm_gem.h => mtk_gem.h} (62%)
 rename drivers/gpu/drm/mediatek/{mtk_drm_plane.c => mtk_plane.c} (94%)
 rename drivers/gpu/drm/mediatek/{mtk_drm_plane.h => mtk_plane.h} (95%)

--
2.18.0



[PATCH v3 03/14] drm/mediatek: Rename "mtk_drm_plane" to "mtk_plane"

2024-03-19 Thread Shawn Sung
From: Hsiao Chien Sung 

Rename all "mtk_drm_plane" to "mtk_plane":
- To align the naming rule
- To reduce the code size

Reviewed-by: AngeloGioacchino Del Regno 

Reviewed-by: CK Hu 
Signed-off-by: Hsiao Chien Sung 
---
 drivers/gpu/drm/mediatek/mtk_drm_plane.c | 6 +++---
 drivers/gpu/drm/mediatek/mtk_drm_plane.h | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c 
b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
index cbdb70677d305..43137c46fc148 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
@@ -93,8 +93,8 @@ static bool mtk_plane_format_mod_supported(struct drm_plane 
*plane,
return true;
 }

-static void mtk_drm_plane_destroy_state(struct drm_plane *plane,
-   struct drm_plane_state *state)
+static void mtk_plane_destroy_state(struct drm_plane *plane,
+   struct drm_plane_state *state)
 {
__drm_atomic_helper_plane_destroy_state(state);
kfree(to_mtk_plane_state(state));
@@ -241,7 +241,7 @@ static const struct drm_plane_funcs mtk_plane_funcs = {
.destroy = drm_plane_cleanup,
.reset = mtk_plane_reset,
.atomic_duplicate_state = mtk_plane_duplicate_state,
-   .atomic_destroy_state = mtk_drm_plane_destroy_state,
+   .atomic_destroy_state = mtk_plane_destroy_state,
.format_mod_supported = mtk_plane_format_mod_supported,
 };

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.h 
b/drivers/gpu/drm/mediatek/mtk_drm_plane.h
index 99aff7da0831d..231bb7aac9473 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_plane.h
+++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.h
@@ -4,8 +4,8 @@
  * Author: CK Hu 
  */

-#ifndef _MTK_DRM_PLANE_H_
-#define _MTK_DRM_PLANE_H_
+#ifndef _MTK_PLANE_H_
+#define _MTK_PLANE_H_

 #include 
 #include 
--
2.18.0



[PATCH v3 07/14] drm/mediatek: Rename files "mtk_drm_crtc.c" to "mtk_crtc.c"

2024-03-19 Thread Shawn Sung
From: Hsiao Chien Sung 

Rename files mtk_drm_crtc.c to mtk_crtc.c and
modify the Makefile accordingly.

Reviewed-by: CK Hu 
Signed-off-by: Hsiao Chien Sung 
---
 drivers/gpu/drm/mediatek/Makefile   | 4 ++--
 drivers/gpu/drm/mediatek/{mtk_drm_crtc.c => mtk_crtc.c} | 0
 2 files changed, 2 insertions(+), 2 deletions(-)
 rename drivers/gpu/drm/mediatek/{mtk_drm_crtc.c => mtk_crtc.c} (100%)

diff --git a/drivers/gpu/drm/mediatek/Makefile 
b/drivers/gpu/drm/mediatek/Makefile
index 5e4436403b8d2..0198b50820d4c 100644
--- a/drivers/gpu/drm/mediatek/Makefile
+++ b/drivers/gpu/drm/mediatek/Makefile
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 
-mediatek-drm-y := mtk_disp_aal.o \
+mediatek-drm-y := mtk_crtc.o \
+ mtk_disp_aal.o \
  mtk_disp_ccorr.o \
  mtk_disp_color.o \
  mtk_disp_gamma.o \
@@ -8,7 +9,6 @@ mediatek-drm-y := mtk_disp_aal.o \
  mtk_disp_ovl.o \
  mtk_disp_ovl_adaptor.o \
  mtk_disp_rdma.o \
- mtk_drm_crtc.o \
  mtk_drm_ddp_comp.o \
  mtk_drm_drv.o \
  mtk_drm_gem.o \
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c 
b/drivers/gpu/drm/mediatek/mtk_crtc.c
similarity index 100%
rename from drivers/gpu/drm/mediatek/mtk_drm_crtc.c
rename to drivers/gpu/drm/mediatek/mtk_crtc.c
-- 
2.18.0



[PATCH v3 12/14] drm/mediatek: Rename files "mtk_drm_gem.h" to "mtk_gem.h"

2024-03-19 Thread Shawn Sung
From: Hsiao Chien Sung 

Rename files mtk_drm_gem.h to mtk_gem.h.

Reviewed-by: AngeloGioacchino Del Regno 

Reviewed-by: CK Hu 
Signed-off-by: Hsiao Chien Sung 
---
 drivers/gpu/drm/mediatek/mtk_crtc.c   | 2 +-
 drivers/gpu/drm/mediatek/mtk_drm_drv.c| 2 +-
 drivers/gpu/drm/mediatek/mtk_drm_gem.c| 2 +-
 drivers/gpu/drm/mediatek/{mtk_drm_gem.h => mtk_gem.h} | 0
 drivers/gpu/drm/mediatek/mtk_plane.c  | 2 +-
 5 files changed, 4 insertions(+), 4 deletions(-)
 rename drivers/gpu/drm/mediatek/{mtk_drm_gem.h => mtk_gem.h} (100%)

diff --git a/drivers/gpu/drm/mediatek/mtk_crtc.c 
b/drivers/gpu/drm/mediatek/mtk_crtc.c
index 1ba47e65a32da..d5974fc1a729a 100644
--- a/drivers/gpu/drm/mediatek/mtk_crtc.c
+++ b/drivers/gpu/drm/mediatek/mtk_crtc.c
@@ -22,7 +22,7 @@
 #include "mtk_crtc.h"
 #include "mtk_ddp_comp.h"
 #include "mtk_drm_drv.h"
-#include "mtk_drm_gem.h"
+#include "mtk_gem.h"
 #include "mtk_plane.h"

 /*
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c 
b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
index 113fdbaac5a14..b62320f648825 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
@@ -27,7 +27,7 @@
 #include "mtk_crtc.h"
 #include "mtk_ddp_comp.h"
 #include "mtk_drm_drv.h"
-#include "mtk_drm_gem.h"
+#include "mtk_gem.h"

 #define DRIVER_NAME "mediatek"
 #define DRIVER_DESC "Mediatek SoC DRM"
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_gem.c 
b/drivers/gpu/drm/mediatek/mtk_drm_gem.c
index 445fd8a8b8988..166a71dc40860 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_gem.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_gem.c
@@ -12,7 +12,7 @@
 #include 

 #include "mtk_drm_drv.h"
-#include "mtk_drm_gem.h"
+#include "mtk_gem.h"

 static int mtk_gem_object_mmap(struct drm_gem_object *obj, struct 
vm_area_struct *vma);

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_gem.h 
b/drivers/gpu/drm/mediatek/mtk_gem.h
similarity index 100%
rename from drivers/gpu/drm/mediatek/mtk_drm_gem.h
rename to drivers/gpu/drm/mediatek/mtk_gem.h
diff --git a/drivers/gpu/drm/mediatek/mtk_plane.c 
b/drivers/gpu/drm/mediatek/mtk_plane.c
index 95a4328a9b0b6..4625deb21d406 100644
--- a/drivers/gpu/drm/mediatek/mtk_plane.c
+++ b/drivers/gpu/drm/mediatek/mtk_plane.c
@@ -16,7 +16,7 @@
 #include "mtk_crtc.h"
 #include "mtk_ddp_comp.h"
 #include "mtk_drm_drv.h"
-#include "mtk_drm_gem.h"
+#include "mtk_gem.h"
 #include "mtk_plane.h"

 static const u64 modifiers[] = {
--
2.18.0



[PATCH v3 13/14] drm/mediatek: Rename files "mtk_drm_gem.c" to "mtk_gem.c"

2024-03-19 Thread Shawn Sung
From: Hsiao Chien Sung 

Rename files mtk_drm_gem.c to mtk_gem.c.

Reviewed-by: AngeloGioacchino Del Regno 

Reviewed-by: CK Hu 
Signed-off-by: Hsiao Chien Sung 
---
 drivers/gpu/drm/mediatek/Makefile | 2 +-
 drivers/gpu/drm/mediatek/{mtk_drm_gem.c => mtk_gem.c} | 0
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename drivers/gpu/drm/mediatek/{mtk_drm_gem.c => mtk_gem.c} (100%)

diff --git a/drivers/gpu/drm/mediatek/Makefile 
b/drivers/gpu/drm/mediatek/Makefile
index a47fbec7b9ce1..32a2ed6c0cfef 100644
--- a/drivers/gpu/drm/mediatek/Makefile
+++ b/drivers/gpu/drm/mediatek/Makefile
@@ -11,10 +11,10 @@ mediatek-drm-y := mtk_crtc.o \
  mtk_disp_ovl_adaptor.o \
  mtk_disp_rdma.o \
  mtk_drm_drv.o \
- mtk_drm_gem.o \
  mtk_dsi.o \
  mtk_dpi.o \
  mtk_ethdr.o \
+ mtk_gem.o \
  mtk_mdp_rdma.o \
  mtk_padding.o \
  mtk_plane.o
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_gem.c 
b/drivers/gpu/drm/mediatek/mtk_gem.c
similarity index 100%
rename from drivers/gpu/drm/mediatek/mtk_drm_gem.c
rename to drivers/gpu/drm/mediatek/mtk_gem.c
--
2.18.0



[PATCH v3 11/14] drm/mediatek: Rename files "mtk_drm_plane.c" to "mtk_plane.c"

2024-03-19 Thread Shawn Sung
From: Hsiao Chien Sung 

Rename files mtk_drm_plane.c to mtk_plane.c and
modify the Makefile accordingly.

Reviewed-by: AngeloGioacchino Del Regno 

Reviewed-by: CK Hu 
Signed-off-by: Hsiao Chien Sung 
---
 drivers/gpu/drm/mediatek/Makefile | 4 ++--
 drivers/gpu/drm/mediatek/{mtk_drm_plane.c => mtk_plane.c} | 0
 2 files changed, 2 insertions(+), 2 deletions(-)
 rename drivers/gpu/drm/mediatek/{mtk_drm_plane.c => mtk_plane.c} (100%)

diff --git a/drivers/gpu/drm/mediatek/Makefile 
b/drivers/gpu/drm/mediatek/Makefile
index bdb71738e1f31..a47fbec7b9ce1 100644
--- a/drivers/gpu/drm/mediatek/Makefile
+++ b/drivers/gpu/drm/mediatek/Makefile
@@ -12,12 +12,12 @@ mediatek-drm-y := mtk_crtc.o \
  mtk_disp_rdma.o \
  mtk_drm_drv.o \
  mtk_drm_gem.o \
- mtk_drm_plane.o \
  mtk_dsi.o \
  mtk_dpi.o \
  mtk_ethdr.o \
  mtk_mdp_rdma.o \
- mtk_padding.o
+ mtk_padding.o \
+ mtk_plane.o
 
 obj-$(CONFIG_DRM_MEDIATEK) += mediatek-drm.o
 
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c 
b/drivers/gpu/drm/mediatek/mtk_plane.c
similarity index 100%
rename from drivers/gpu/drm/mediatek/mtk_drm_plane.c
rename to drivers/gpu/drm/mediatek/mtk_plane.c
-- 
2.18.0



[PATCH v3 09/14] drm/mediatek: Rename files "mtk_drm_ddp_comp.c" to "mtk_ddp_comp.c"

2024-03-19 Thread Shawn Sung
From: Hsiao Chien Sung 

Rename files mtk_drm_ddp_comp.c to mtk_ddp_comp.c and
modify the Makefile accordingly.

Reviewed-by: CK Hu 
Signed-off-by: Hsiao Chien Sung 
---
 drivers/gpu/drm/mediatek/Makefile   | 2 +-
 drivers/gpu/drm/mediatek/{mtk_drm_ddp_comp.c => mtk_ddp_comp.c} | 0
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename drivers/gpu/drm/mediatek/{mtk_drm_ddp_comp.c => mtk_ddp_comp.c} (100%)

diff --git a/drivers/gpu/drm/mediatek/Makefile 
b/drivers/gpu/drm/mediatek/Makefile
index 0198b50820d4c..bdb71738e1f31 100644
--- a/drivers/gpu/drm/mediatek/Makefile
+++ b/drivers/gpu/drm/mediatek/Makefile
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 
 mediatek-drm-y := mtk_crtc.o \
+ mtk_ddp_comp.o \
  mtk_disp_aal.o \
  mtk_disp_ccorr.o \
  mtk_disp_color.o \
@@ -9,7 +10,6 @@ mediatek-drm-y := mtk_crtc.o \
  mtk_disp_ovl.o \
  mtk_disp_ovl_adaptor.o \
  mtk_disp_rdma.o \
- mtk_drm_ddp_comp.o \
  mtk_drm_drv.o \
  mtk_drm_gem.o \
  mtk_drm_plane.o \
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c 
b/drivers/gpu/drm/mediatek/mtk_ddp_comp.c
similarity index 100%
rename from drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
rename to drivers/gpu/drm/mediatek/mtk_ddp_comp.c
-- 
2.18.0



Re: [PATCH v2 13/14] drm/mediatek: Rename files "mtk_drm_gem.c" to "mtk_gem.c"

2024-03-19 Thread 胡俊光


Re: [PATCH v2 12/14] drm/mediatek: Rename files "mtk_drm_gem.h" to "mtk_gem.h"

2024-03-19 Thread 胡俊光


Re: [PATCH v2 11/14] drm/mediatek: Rename files "mtk_drm_plane.c" to "mtk_plane.c"

2024-03-19 Thread 胡俊光


Re: [PATCH v2 10/14] drm/mediatek: Rename files "mtk_drm_plane.h" to "mtk_plane.h"

2024-03-19 Thread 胡俊光


Re: [PATCH v2 09/14] drm/mediatek: Rename files "mtk_drm_ddp_comp.c" to "mtk_ddp_comp.c"

2024-03-19 Thread 胡俊光


Re: [PATCH v2 08/14] drm/mediatek: Rename files "mtk_drm_ddp_comp.h" to "mtk_ddp_comp.h"

2024-03-19 Thread 胡俊光


Re: [PATCH v2 07/14] drm/mediatek: Rename files "mtk_drm_crtc.c" to "mtk_crtc.c"

2024-03-19 Thread 胡俊光


Re: [PATCH v2 06/14] drm/mediatek: Rename files "mtk_drm_crtc.h" to "mtk_crtc.h"

2024-03-19 Thread 胡俊光


RE: [PATCH v2 5/8] drm: xlnx: zynqmp_dpsub: Set input live format

2024-03-19 Thread Klymenko, Anatoliy
Hi Laurent,

Thanks a lot for your review.

> -Original Message-
> From: Laurent Pinchart 
> Sent: Monday, March 18, 2024 5:35 PM
> To: Klymenko, Anatoliy 
> Cc: Maarten Lankhorst ; Maxime Ripard
> ; Thomas Zimmermann ; David
> Airlie ; Daniel Vetter ; Simek, Michal
> ; Andrzej Hajda ; Neil
> Armstrong ; Robert Foss ; Jonas
> Karlman ; Jernej Skrabec ; Rob
> Herring ; Krzysztof Kozlowski
> ; Conor Dooley ;
> Mauro Carvalho Chehab ; dri-
> de...@lists.freedesktop.org; linux-arm-ker...@lists.infradead.org; linux-
> ker...@vger.kernel.org; devicet...@vger.kernel.org; linux-
> me...@vger.kernel.org
> Subject: Re: [PATCH v2 5/8] drm: xlnx: zynqmp_dpsub: Set input live format
> 
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
> 
> 
> Hi Anatoliy,
> 
> Thank you for the patch.
> 
> On Tue, Mar 12, 2024 at 05:55:02PM -0700, Anatoliy Klymenko wrote:
> > Program live video input format according to selected media bus format.
> >
> > In the bridge mode of operation, DPSUB is connected to FPGA CRTC which
> > almost certainly supports a single media bus format as its output.
> > Expect this to be delivered via the new bridge atomic state. Program
> > DPSUB registers accordingly.
> 
> No line breaks within paragraphs. Add a blank line if you want to paragraphs,
> remove the line break otherwise.
> 

Got it - will fix. Thank you.

> > Update zynqmp_disp_layer_set_format() API to fit both live and
> > non-live layer types.
> >
> > Signed-off-by: Anatoliy Klymenko 
> > ---
> >  drivers/gpu/drm/xlnx/zynqmp_disp.c | 93
> > +++---
> >  drivers/gpu/drm/xlnx/zynqmp_disp.h |  2 +-
> >  drivers/gpu/drm/xlnx/zynqmp_dp.c   | 13 --
> >  drivers/gpu/drm/xlnx/zynqmp_kms.c  |  2 +-
> >  4 files changed, 87 insertions(+), 23 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/xlnx/zynqmp_disp.c
> > b/drivers/gpu/drm/xlnx/zynqmp_disp.c
> > index dd48fa60fa9a..0cacd597f4b8 100644
> > --- a/drivers/gpu/drm/xlnx/zynqmp_disp.c
> > +++ b/drivers/gpu/drm/xlnx/zynqmp_disp.c
> > @@ -383,7 +383,7 @@ static const struct zynqmp_disp_format
> avbuf_live_fmts[] = {
> > ZYNQMP_DISP_AV_BUF_LIVE_CONFIG_FMT_RGB,
> >   .sf = scaling_factors_666,
> >   }, {
> > - .bus_fmt= MEDIA_BUS_FMT_UYVY8_1X24,
> > + .bus_fmt= MEDIA_BUS_FMT_RBG888_1X24,
> 
> Does this belong to a previous patch ?

Yep, slipped between my fingers during the rebase. I will update this in the 
next version. 

> 
> >   .buf_fmt= ZYNQMP_DISP_AV_BUF_LIVE_CONFIG_BPC_8 |
> > ZYNQMP_DISP_AV_BUF_LIVE_CONFIG_FMT_RGB,
> >   .sf = scaling_factors_888,
> > @@ -433,19 +433,28 @@ static void zynqmp_disp_avbuf_set_format(struct
> zynqmp_disp *disp,
> >const struct zynqmp_disp_format
> > *fmt)  {
> >   unsigned int i;
> > - u32 val;
> > + u32 val, reg;
> >
> > - val = zynqmp_disp_avbuf_read(disp, ZYNQMP_DISP_AV_BUF_FMT);
> > - val &= zynqmp_disp_layer_is_video(layer)
> > - ? ~ZYNQMP_DISP_AV_BUF_FMT_NL_VID_MASK
> > - : ~ZYNQMP_DISP_AV_BUF_FMT_NL_GFX_MASK;
> > - val |= fmt->buf_fmt;
> > - zynqmp_disp_avbuf_write(disp, ZYNQMP_DISP_AV_BUF_FMT, val);
> > + layer->disp_fmt = fmt;
> > + if (layer->mode == ZYNQMP_DPSUB_LAYER_NONLIVE) {
> > + reg = ZYNQMP_DISP_AV_BUF_FMT;
> > + val = zynqmp_disp_avbuf_read(disp, ZYNQMP_DISP_AV_BUF_FMT);
> > + val &= zynqmp_disp_layer_is_video(layer)
> > + ? ~ZYNQMP_DISP_AV_BUF_FMT_NL_VID_MASK
> > + : ~ZYNQMP_DISP_AV_BUF_FMT_NL_GFX_MASK;
> > + val |= fmt->buf_fmt;
> > + } else {
> > + reg = zynqmp_disp_layer_is_video(layer)
> > + ? ZYNQMP_DISP_AV_BUF_LIVE_VID_CONFIG
> > + : ZYNQMP_DISP_AV_BUF_LIVE_GFX_CONFIG;
> > + val = fmt->buf_fmt;
> > + }
> > + zynqmp_disp_avbuf_write(disp, reg, val);
> >
> >   for (i = 0; i < ZYNQMP_DISP_AV_BUF_NUM_SF; i++) {
> > - unsigned int reg = zynqmp_disp_layer_is_video(layer)
> > -  ? ZYNQMP_DISP_AV_BUF_VID_COMP_SF(i)
> > -  : ZYNQMP_DISP_AV_BUF_GFX_COMP_SF(i);
> > + reg = zynqmp_disp_layer_is_video(layer)
> > + ? ZYNQMP_DISP_AV_BUF_VID_COMP_SF(i)
> > + : ZYNQMP_DISP_AV_BUF_GFX_COMP_SF(i);
> >
> >   zynqmp_disp_avbuf_write(disp, reg, fmt->sf[i]);
> >   }
> > @@ -984,23 +993,73 @@ void zynqmp_disp_layer_disable(struct
> zynqmp_disp_layer *layer)
> >   zynqmp_disp_blend_layer_disable(layer->disp, layer);  }
> >
> > +struct zynqmp_disp_bus_to_drm {
> > + u32 bus_fmt;
> > + u32 drm_fmt;
> > +};
> > +
> > +/**
> > + * zynqmp_disp_reference_drm_format - Get reference DRM 

Re: [PATCH v2 02/14] drm/mediatek: Rename "mtk_drm_ddp_comp" to "mtk_ddp_comp"

2024-03-19 Thread 宋孝謙


RE: [PATCH v2 4/8] drm: xlnx: zynqmp_dpsub: Minimize usage of global flag

2024-03-19 Thread Klymenko, Anatoliy
Hi Laurent,

Thank you for the review.

> -Original Message-
> From: Laurent Pinchart 
> Sent: Monday, March 18, 2024 5:13 PM
> To: Klymenko, Anatoliy 
> Cc: Maarten Lankhorst ; Maxime Ripard
> ; Thomas Zimmermann ; David
> Airlie ; Daniel Vetter ; Simek, Michal
> ; Andrzej Hajda ; Neil
> Armstrong ; Robert Foss ; Jonas
> Karlman ; Jernej Skrabec ; Rob
> Herring ; Krzysztof Kozlowski
> ; Conor Dooley ;
> Mauro Carvalho Chehab ; dri-
> de...@lists.freedesktop.org; linux-arm-ker...@lists.infradead.org; linux-
> ker...@vger.kernel.org; devicet...@vger.kernel.org; linux-
> me...@vger.kernel.org
> Subject: Re: [PATCH v2 4/8] drm: xlnx: zynqmp_dpsub: Minimize usage of global
> flag
> 
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
> 
> 
> Hi Anatoliy,
> 
> Thank you for the patch.
> 
> On Tue, Mar 12, 2024 at 05:55:01PM -0700, Anatoliy Klymenko wrote:
> > Avoid usage of global zynqmp_dpsub.dma_enabled flag in DPSUB layer
> > context. This flag signals whether the driver runs in DRM CRTC or DRM
> > bridge mode, assuming that all display layers share the same live or
> > non-live mode of operation. Using per-layer mode instead of global
> > flag will siplify future support of the hybrid scenario.
> 
> s/siplify/simplify/
> 
> > Signed-off-by: Anatoliy Klymenko 
> > ---
> >  drivers/gpu/drm/xlnx/zynqmp_disp.c | 11 ---
> >  1 file changed, 4 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/xlnx/zynqmp_disp.c
> > b/drivers/gpu/drm/xlnx/zynqmp_disp.c
> > index af851190f447..dd48fa60fa9a 100644
> > --- a/drivers/gpu/drm/xlnx/zynqmp_disp.c
> > +++ b/drivers/gpu/drm/xlnx/zynqmp_disp.c
> > @@ -975,7 +975,7 @@ void zynqmp_disp_layer_disable(struct
> > zynqmp_disp_layer *layer)  {
> >   unsigned int i;
> >
> > - if (layer->disp->dpsub->dma_enabled) {
> > + if (layer->mode == ZYNQMP_DPSUB_LAYER_NONLIVE) {
> >   for (i = 0; i < layer->drm_fmt->num_planes; i++)
> >   dmaengine_terminate_sync(layer->dmas[i].chan);
> >   }
> > @@ -1001,7 +1001,7 @@ void zynqmp_disp_layer_set_format(struct
> > zynqmp_disp_layer *layer,
> >
> >   zynqmp_disp_avbuf_set_format(layer->disp, layer,
> > layer->disp_fmt);
> >
> > - if (!layer->disp->dpsub->dma_enabled)
> > + if (layer->mode == ZYNQMP_DPSUB_LAYER_LIVE)
> >   return;
> >
> >   /*
> > @@ -1039,7 +1039,7 @@ int zynqmp_disp_layer_update(struct
> zynqmp_disp_layer *layer,
> >   const struct drm_format_info *info = layer->drm_fmt;
> >   unsigned int i;
> >
> > - if (!layer->disp->dpsub->dma_enabled)
> > + if (layer->mode == ZYNQMP_DPSUB_LAYER_LIVE)
> >   return 0;
> 
> The above changes look nice.
> 
> >
> >   for (i = 0; i < info->num_planes; i++) { @@ -1089,7 +1089,7 @@
> > static void zynqmp_disp_layer_release_dma(struct zynqmp_disp *disp,  {
> >   unsigned int i;
> >
> > - if (!layer->info || !disp->dpsub->dma_enabled)
> > + if (!layer->info)
> 
> This, however, doesn't seem right, as this function is called unconditionally 
> from
> the remove path. The change below seems weird too.
> If I'm missing something, it should at least be explained in the commit 
> message.
> 

Actually, this whole condition should be removed, as now we're setting 
layer.info for all types of layers. On top of that, we're setting the number of 
DMA channels to zero for the live layers, which in turn prevents any DMA 
channel initialization or release. You are right - that probably should be 
mentioned explicitly in the commit message. I'll update it.

> >   return;
> >
> >   for (i = 0; i < layer->info->num_channels; i++) { @@ -1132,9
> > +1132,6 @@ static int zynqmp_disp_layer_request_dma(struct zynqmp_disp
> *disp,
> >   unsigned int i;
> >   int ret;
> >
> > - if (!disp->dpsub->dma_enabled)
> > - return 0;
> > -
> >   for (i = 0; i < layer->info->num_channels; i++) {
> >   struct zynqmp_disp_layer_dma *dma = >dmas[i];
> >   char dma_channel_name[16];
> >
> 
> --
> Regards,
> 
> Laurent Pinchart

Thank you,
Anatoliy


RE: [PATCH v2 3/8] drm: xlnx: zynqmp_dpsub: Anounce supported input formats

2024-03-19 Thread Klymenko, Anatoliy
Hi Laurent,

Thanks a lot for the review.

> -Original Message-
> From: Laurent Pinchart 
> Sent: Monday, March 18, 2024 5:05 PM
> To: Klymenko, Anatoliy 
> Cc: Maarten Lankhorst ; Maxime Ripard
> ; Thomas Zimmermann ; David
> Airlie ; Daniel Vetter ; Simek, Michal
> ; Andrzej Hajda ; Neil
> Armstrong ; Robert Foss ; Jonas
> Karlman ; Jernej Skrabec ; Rob
> Herring ; Krzysztof Kozlowski
> ; Conor Dooley ;
> Mauro Carvalho Chehab ; dri-
> de...@lists.freedesktop.org; linux-arm-ker...@lists.infradead.org; linux-
> ker...@vger.kernel.org; devicet...@vger.kernel.org; linux-
> me...@vger.kernel.org
> Subject: Re: [PATCH v2 3/8] drm: xlnx: zynqmp_dpsub: Anounce supported input
> formats
> 
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
> 
> 
> Hi Anatoliy,
> 
> Thank you for the patch.
> 
> On Tue, Mar 12, 2024 at 05:55:00PM -0700, Anatoliy Klymenko wrote:
> > DPSUB in bridge mode supports multiple input media bus formats.
> >
> > Announce the list of supported input media bus formats via
> > drm_bridge.atomic_get_input_bus_fmts callback.
> > Introduce a set of live input formats, supported by DPSUB.
> > Rename zynqmp_disp_layer_drm_formats() to zynqmp_disp_layer_formats()
> > to reflect semantics for both live and non-live layer format lists.
> >
> > Signed-off-by: Anatoliy Klymenko 
> > ---
> >  drivers/gpu/drm/xlnx/zynqmp_disp.c | 67
> > +-
> >  drivers/gpu/drm/xlnx/zynqmp_disp.h |  4 +--
> >  drivers/gpu/drm/xlnx/zynqmp_dp.c   | 26 +++
> >  drivers/gpu/drm/xlnx/zynqmp_kms.c  |  2 +-
> >  4 files changed, 88 insertions(+), 11 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/xlnx/zynqmp_disp.c
> > b/drivers/gpu/drm/xlnx/zynqmp_disp.c
> > index e6d26ef60e89..af851190f447 100644
> > --- a/drivers/gpu/drm/xlnx/zynqmp_disp.c
> > +++ b/drivers/gpu/drm/xlnx/zynqmp_disp.c
> > @@ -18,6 +18,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -77,12 +78,16 @@ enum zynqmp_dpsub_layer_mode {
> >  /**
> >   * struct zynqmp_disp_format - Display subsystem format information
> >   * @drm_fmt: DRM format (4CC)
> > + * @bus_fmt: Media bus format
> >   * @buf_fmt: AV buffer format
> >   * @swap: Flag to swap R & B for RGB formats, and U & V for YUV formats
> >   * @sf: Scaling factors for color components
> >   */
> >  struct zynqmp_disp_format {
> > - u32 drm_fmt;
> > + union {
> > + u32 drm_fmt;
> > + u32 bus_fmt;
> > + };
> 
> I'm not a big fan of the union, but I can live with it.
> 

I'm trying to represent the duality of the layer formats - non-live described 
by the DRM fourcc, and live by the bus format.

> >   u32 buf_fmt;
> >   bool swap;
> >   const u32 *sf;
> > @@ -182,6 +187,12 @@ static const u32 scaling_factors_565[] = {
> >   ZYNQMP_DISP_AV_BUF_5BIT_SF,
> >  };
> >
> > +static const u32 scaling_factors_666[] = {
> > + ZYNQMP_DISP_AV_BUF_6BIT_SF,
> > + ZYNQMP_DISP_AV_BUF_6BIT_SF,
> > + ZYNQMP_DISP_AV_BUF_6BIT_SF,
> > +};
> > +
> >  static const u32 scaling_factors_888[] = {
> >   ZYNQMP_DISP_AV_BUF_8BIT_SF,
> >   ZYNQMP_DISP_AV_BUF_8BIT_SF,
> > @@ -364,6 +375,36 @@ static const struct zynqmp_disp_format
> avbuf_gfx_fmts[] = {
> >   },
> >  };
> >
> > +/* List of live video layer formats */ static const struct
> > +zynqmp_disp_format avbuf_live_fmts[] = {
> > + {
> > + .bus_fmt= MEDIA_BUS_FMT_RGB666_1X18,
> > + .buf_fmt= ZYNQMP_DISP_AV_BUF_LIVE_CONFIG_BPC_6 |
> > +   ZYNQMP_DISP_AV_BUF_LIVE_CONFIG_FMT_RGB,
> > + .sf = scaling_factors_666,
> > + }, {
> > + .bus_fmt= MEDIA_BUS_FMT_UYVY8_1X24,
> > + .buf_fmt= ZYNQMP_DISP_AV_BUF_LIVE_CONFIG_BPC_8 |
> > +   ZYNQMP_DISP_AV_BUF_LIVE_CONFIG_FMT_RGB,
> > + .sf = scaling_factors_888,
> > + }, {
> > + .bus_fmt= MEDIA_BUS_FMT_UYVY8_1X16,
> > + .buf_fmt= ZYNQMP_DISP_AV_BUF_LIVE_CONFIG_BPC_8 |
> > +   ZYNQMP_DISP_AV_BUF_LIVE_CONFIG_FMT_YUV422,
> > + .sf = scaling_factors_888,
> > + }, {
> > + .bus_fmt= MEDIA_BUS_FMT_VUY8_1X24,
> > + .buf_fmt= ZYNQMP_DISP_AV_BUF_LIVE_CONFIG_BPC_8 |
> > +   ZYNQMP_DISP_AV_BUF_LIVE_CONFIG_FMT_YUV444,
> > + .sf = scaling_factors_888,
> > + }, {
> > + .bus_fmt= MEDIA_BUS_FMT_UYVY10_1X20,
> > + .buf_fmt= ZYNQMP_DISP_AV_BUF_LIVE_CONFIG_BPC_10 |
> > +   ZYNQMP_DISP_AV_BUF_LIVE_CONFIG_FMT_YUV422,
> > + .sf = scaling_factors_101010,
> > + },
> > +};
> > +
> >  static u32 

[PATCH] dma-buf: Fix NULL pointer dereference in sanitycheck()

2024-03-19 Thread Pavel Sakharov
If due to a memory allocation failure mock_chain() returns NULL, it is
passed to dma_fence_enable_sw_signaling() resulting in NULL pointer
dereference there.

Call dma_fence_enable_sw_signaling() only if mock_chain() succeeds.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: d62c43a953ce ("dma-buf: Enable signaling on fence for selftests")
Signed-off-by: Pavel Sakharov 

---
 drivers/dma-buf/st-dma-fence-chain.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/dma-buf/st-dma-fence-chain.c 
b/drivers/dma-buf/st-dma-fence-chain.c
index 9c2a0c082a76..ed4b323886e4 100644
--- a/drivers/dma-buf/st-dma-fence-chain.c
+++ b/drivers/dma-buf/st-dma-fence-chain.c
@@ -84,11 +84,11 @@ static int sanitycheck(void *arg)
return -ENOMEM;

chain = mock_chain(NULL, f, 1);
-   if (!chain)
+   if (chain)
+   dma_fence_enable_sw_signaling(chain);
+   else
err = -ENOMEM;

-   dma_fence_enable_sw_signaling(chain);
-
dma_fence_signal(f);
dma_fence_put(f);

--
2.44.0



Re: [PATCH v2 0/8] drm: zynqmp_dp: Misc. patches and debugfs support

2024-03-19 Thread Sean Anderson
On 3/19/24 18:51, Sean Anderson wrote:
> This series adds debugfs support for the zynqmp_dp driver. The intent is
> to enable compliance testing or to help debug signal-integrity issues.
> 
> The first four patches are general improvements (and could be applied
> independently), while the last four add debugfs support.
> 
> Changes in v2:
> - Fix kerneldoc
> - Rearrange zynqmp_dp for better padding
> - Document hpd_irq_work
> - Split off the HPD IRQ work into another commit
> - Expand the commit message
> - Document debugfs files
> - Add ignore_aux_errors and ignore_hpd debugfs files to replace earlier
>   implicit functionality
> - Attempt to fix unreproducable, spurious build warning
> - Drop "Optionally ignore DPCD errors" in favor of a debugfs file
>   directly affecting zynqmp_dp_aux_transfer.
> 
> Sean Anderson (8):
>   drm: xlnx: Fix kerneldoc
>   drm: zynqmp_dp: Downgrade log level for aux retries message
>   drm: zynqmp_dp: Adjust training values per-lane
>   drm: zynqmp_dp: Rearrange zynqmp_dp for better padding
>   drm: zynqmp_dp: Don't retrain the link in our IRQ
>   drm: zynqmp_dp: Add locking
>   drm: zynqmp_dp: Split off several helper functions
>   drm: zynqmp_dp: Add debugfs interface for compliance testing
> 
>  Documentation/gpu/drivers.rst   |   1 +
>  Documentation/gpu/zynqmp.rst| 149 +
>  MAINTAINERS |   1 +
>  drivers/gpu/drm/xlnx/zynqmp_disp.c  |   6 +-
>  drivers/gpu/drm/xlnx/zynqmp_dp.c| 836 +---
>  drivers/gpu/drm/xlnx/zynqmp_dpsub.h |   1 +
>  drivers/gpu/drm/xlnx/zynqmp_kms.h   |   4 +-
>  7 files changed, 931 insertions(+), 67 deletions(-)
>  create mode 100644 Documentation/gpu/zynqmp.rst
> 

+CC Dmitry, Tomi, and Anatoliy who I forgot to CC

Let me know if you want to be taken off CC for future revisions

--Sean


[PATCH v2 8/8] drm: zynqmp_dp: Add debugfs interface for compliance testing

2024-03-19 Thread Sean Anderson
Add a debugfs interface for exercising the various test modes supported
by the DisplayPort controller. This allows performing compliance
testing, or performing signal integrity measurements on a failing link.
At the moment, we do not support sink-driven link quality testing,
although such support would be fairly easy to add.

Additionally, add some debugfs files for ignoring AUX errors and HPD
events, as this can allow testing with equipment that cannot emulate a
DPRX.

Signed-off-by: Sean Anderson 
---

Changes in v2:
- Document debugfs files
- Add ignore_aux_errors and ignore_hpd debugfs files to replace earlier
  implicit functionality
- Attempt to fix unreproducable, spurious build warning

 Documentation/gpu/drivers.rst|   1 +
 Documentation/gpu/zynqmp.rst | 149 +++
 MAINTAINERS  |   1 +
 drivers/gpu/drm/xlnx/zynqmp_dp.c | 675 ++-
 4 files changed, 823 insertions(+), 3 deletions(-)
 create mode 100644 Documentation/gpu/zynqmp.rst

diff --git a/Documentation/gpu/drivers.rst b/Documentation/gpu/drivers.rst
index b899cbc5c2b4..187201aedbe5 100644
--- a/Documentation/gpu/drivers.rst
+++ b/Documentation/gpu/drivers.rst
@@ -22,6 +22,7 @@ GPU Driver Documentation
afbc
komeda-kms
panfrost
+   zynqmp
 
 .. only::  subproject and html
 
diff --git a/Documentation/gpu/zynqmp.rst b/Documentation/gpu/zynqmp.rst
new file mode 100644
index ..4173a79972a2
--- /dev/null
+++ b/Documentation/gpu/zynqmp.rst
@@ -0,0 +1,149 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+===
+Xilinx ZynqMP Ultrascale+ DisplayPort Subsystem
+===
+
+This subsystem handles DisplayPort video and audio output on the ZynqMP. It
+supports in-memory framebuffers with the DisplayPort DMA controller
+(xilinx-dpdma), as well as "live" video and audio from the programmable logic
+(PL). This subsystem can perform several transformations, including color space
+conversion, alpha blending, and audio mixing, although not all features are
+currently supported.
+
+debugfs
+---
+
+To support debugging and compliance testing, several test modes can be enabled
+though debugfs. The following files in /sys/kernel/debug/dri/X/DP-1/test/
+control the DisplayPort test modes:
+
+active:
+Writing a 1 to this file will activate test mode, and writing a 0 will
+deactivate test mode. Writing a 1 or 0 when the test mode is already
+active/inactive will re-activate/re-deactivate test mode. When test
+mode is inactive, changes made to other files will have no (immediate)
+effect, although the settings will be saved for when test mode is
+activated. When test mode is active, changes made to other files will
+apply immediately.
+
+custom:
+Custom test pattern value
+
+downspread:
+Enable/disable clock downspreading (spread-spectrum clocking) by
+writing 1/0
+
+enhanced:
+Enable/disable enhanced framing
+
+ignore_aux_errors:
+Ignore AUX errors when set to 1. Writes to this file take effect
+immediately (regardless of whether test mode is active) and affect all
+AUX transfers.
+
+ignore_hpd:
+Ignore hotplug events (such as cable removals or monitor link
+retraining requests) when set to 1. Writes to this file take effect
+immediately (regardless of whether test mode is active).
+
+laneX_preemphasis:
+Preemphasis from 0 (lowest) to 2 (most) for lane X
+
+laneX_swing:
+Voltage swing from 0 (lowest) to 3 (most) for lane X
+
+lanes:
+Number of lanes to use (1, 2, or 4)
+
+pattern:
+Test pattern. May be one of:
+
+video
+Use regular video input
+
+symbol-error
+Symbol error measurement pattern
+
+prbs7
+Output of the PRBS7 (x^7 + x^6 + 1) polynomial
+
+80bit-custom
+A custom 80-bit pattern
+
+cp2520
+HBR2 compliance eye pattern
+
+tps1
+Link training symbol pattern TPS1 (/D10.2/)
+
+tps2
+Link training symbol pattern TPS2
+
+tps3
+Link training symbol pattern TPS3 (for HBR2)
+
+rate:
+Rate in hertz. One of
+
+* 54 (HBR2)
+* 27 (HBR)
+* 162000 (RBR)
+
+You can dump the displayport test settings with the following command::
+
+for prop in /sys/kernel/debug/dri/1/DP-1/test/*; do
+printf '%-17s ' ${prop##*/}
+if [ ${prop##*/} = custom ]; then
+hexdump -C $prop | head -1
+else
+cat $prop
+fi
+done
+
+The output could look something like::

[PATCH v2 6/8] drm: zynqmp_dp: Add locking

2024-03-19 Thread Sean Anderson
Add some locking to prevent the IRQ/workers/bridge API calls from stepping
on each other's toes. This lock protects:

- Non-atomic registers configuring the link. That is, everything but the
  IRQ registers (since these are accessed in an atomic fashion), and the DP
  AUX registers (since these don't affect the link). We also access AUX
  while holding this lock, so it would be very tricky to support.
- Link configuration. This is effectively everything in zynqmp_dp which
  isn't read-only after probe time. So from next_bridge onward.

This lock is designed to protect configuration changes so we don't have to
do anything tricky. Configuration should never be in the hot path, so I'm
not worried about performance.

Signed-off-by: Sean Anderson 
---

Changes in v2:
- Split off the HPD IRQ work into another commit
- Expand the commit message

 drivers/gpu/drm/xlnx/zynqmp_dp.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/drivers/gpu/drm/xlnx/zynqmp_dp.c b/drivers/gpu/drm/xlnx/zynqmp_dp.c
index f3fcdbf662fa..a90ab5c0f5cf 100644
--- a/drivers/gpu/drm/xlnx/zynqmp_dp.c
+++ b/drivers/gpu/drm/xlnx/zynqmp_dp.c
@@ -279,6 +279,7 @@ struct zynqmp_dp_config {
  * @dpsub: Display subsystem
  * @iomem: device I/O memory for register access
  * @reset: reset controller
+ * @lock: Mutex protecting this struct and register access (but not AUX)
  * @irq: irq
  * @bridge: DRM bridge for the DP encoder
  * @next_bridge: The downstream bridge
@@ -294,12 +295,17 @@ struct zynqmp_dp_config {
  * @link_config: common link configuration between IP core and sink device
  * @mode: current mode between IP core and sink device
  * @train_set: set of training data
+ *
+ * @lock covers the link configuration in this struct and the device's
+ * registers. It does not cover @aux. It is not strictly required for any of
+ * the members which are only modified at probe/remove time (e.g. @dev).
  */
 struct zynqmp_dp {
struct drm_dp_aux aux;
struct drm_bridge bridge;
struct delayed_work hpd_work;
struct delayed_work hpd_irq_work;
+   struct mutex lock;
 
struct drm_bridge *next_bridge;
struct device *dev;
@@ -1373,8 +1379,10 @@ zynqmp_dp_bridge_mode_valid(struct drm_bridge *bridge,
}
 
/* Check with link rate and lane count */
+   mutex_lock(>lock);
rate = zynqmp_dp_max_rate(dp->link_config.max_rate,
  dp->link_config.max_lanes, dp->config.bpp);
+   mutex_unlock(>lock);
if (mode->clock > rate) {
dev_dbg(dp->dev, "filtered mode %s for high pixel rate\n",
mode->name);
@@ -1401,6 +1409,7 @@ static void zynqmp_dp_bridge_atomic_enable(struct 
drm_bridge *bridge,
 
pm_runtime_get_sync(dp->dev);
 
+   mutex_lock(>lock);
zynqmp_dp_disp_enable(dp, old_bridge_state);
 
/*
@@ -1461,6 +1470,7 @@ static void zynqmp_dp_bridge_atomic_enable(struct 
drm_bridge *bridge,
zynqmp_dp_write(dp, ZYNQMP_DP_SOFTWARE_RESET,
ZYNQMP_DP_SOFTWARE_RESET_ALL);
zynqmp_dp_write(dp, ZYNQMP_DP_MAIN_STREAM_ENABLE, 1);
+   mutex_unlock(>lock);
 }
 
 static void zynqmp_dp_bridge_atomic_disable(struct drm_bridge *bridge,
@@ -1468,6 +1478,7 @@ static void zynqmp_dp_bridge_atomic_disable(struct 
drm_bridge *bridge,
 {
struct zynqmp_dp *dp = bridge_to_dp(bridge);
 
+   mutex_lock(>lock);
dp->enabled = false;
cancel_delayed_work(>hpd_work);
zynqmp_dp_write(dp, ZYNQMP_DP_MAIN_STREAM_ENABLE, 0);
@@ -1478,6 +1489,7 @@ static void zynqmp_dp_bridge_atomic_disable(struct 
drm_bridge *bridge,
zynqmp_dp_write(dp, ZYNQMP_DP_TX_AUDIO_CONTROL, 0);
 
zynqmp_dp_disp_disable(dp, old_bridge_state);
+   mutex_unlock(>lock);
 
pm_runtime_put_sync(dp->dev);
 }
@@ -1520,6 +1532,8 @@ static enum drm_connector_status 
zynqmp_dp_bridge_detect(struct drm_bridge *brid
u32 state, i;
int ret;
 
+   mutex_lock(>lock);
+
/*
 * This is from heuristic. It takes some delay (ex, 100 ~ 500 msec) to
 * get the HPD signal with some monitors.
@@ -1547,11 +1561,13 @@ static enum drm_connector_status 
zynqmp_dp_bridge_detect(struct drm_bridge *brid
   dp->num_lanes);
 
dp->status = connector_status_connected;
+   mutex_unlock(>lock);
return connector_status_connected;
}
 
 disconnected:
dp->status = connector_status_disconnected;
+   mutex_unlock(>lock);
return connector_status_disconnected;
 }
 
@@ -1620,6 +1636,7 @@ static void zynqmp_dp_hpd_irq_work_func(struct 
work_struct *work)
u8 status[DP_LINK_STATUS_SIZE + 2];
int err;
 
+   mutex_lock(>lock);
err = drm_dp_dpcd_read(>aux, DP_SINK_COUNT, status,
   DP_LINK_STATUS_SIZE + 2);
if (err < 0) {
@@ -1632,6 +1649,7 @@ static 

[PATCH v2 5/8] drm: zynqmp_dp: Don't retrain the link in our IRQ

2024-03-19 Thread Sean Anderson
Retraining the link can take a while, and might involve waiting for
DPCD reads/writes to complete. This is inappropriate for an IRQ handler.
Just schedule this work for later completion. This is racy, but will be
fixed in the next commit.

Signed-off-by: Sean Anderson 
---
Actually, on second look this IRQ is threaded. So why do we have a
workqueue for HPD events? Maybe we should make it unthreaded?

Changes in v2:
- Document hpd_irq_work
- Split this off from the lcoking changes

 drivers/gpu/drm/xlnx/zynqmp_dp.c | 43 
 1 file changed, 27 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/xlnx/zynqmp_dp.c b/drivers/gpu/drm/xlnx/zynqmp_dp.c
index f1834c8e3c02..f3fcdbf662fa 100644
--- a/drivers/gpu/drm/xlnx/zynqmp_dp.c
+++ b/drivers/gpu/drm/xlnx/zynqmp_dp.c
@@ -287,6 +287,7 @@ struct zynqmp_dp_config {
  * @phy: PHY handles for DP lanes
  * @num_lanes: number of enabled phy lanes
  * @hpd_work: hot plug detection worker
+ * @hpd_irq_work: hot plug detection IRQ worker
  * @status: connection status
  * @enabled: flag to indicate if the device is enabled
  * @dpcd: DP configuration data from currently connected sink device
@@ -298,6 +299,7 @@ struct zynqmp_dp {
struct drm_dp_aux aux;
struct drm_bridge bridge;
struct delayed_work hpd_work;
+   struct delayed_work hpd_irq_work;
 
struct drm_bridge *next_bridge;
struct device *dev;
@@ -1611,6 +1613,27 @@ static void zynqmp_dp_hpd_work_func(struct work_struct 
*work)
drm_bridge_hpd_notify(>bridge, status);
 }
 
+static void zynqmp_dp_hpd_irq_work_func(struct work_struct *work)
+{
+   struct zynqmp_dp *dp = container_of(work, struct zynqmp_dp,
+   hpd_irq_work.work);
+   u8 status[DP_LINK_STATUS_SIZE + 2];
+   int err;
+
+   err = drm_dp_dpcd_read(>aux, DP_SINK_COUNT, status,
+  DP_LINK_STATUS_SIZE + 2);
+   if (err < 0) {
+   dev_dbg_ratelimited(dp->dev,
+   "could not read sink status: %d\n", err);
+   } else {
+   if (status[4] & DP_LINK_STATUS_UPDATED ||
+   !drm_dp_clock_recovery_ok([2], dp->mode.lane_cnt) ||
+   !drm_dp_channel_eq_ok([2], dp->mode.lane_cnt)) {
+   zynqmp_dp_train_loop(dp);
+   }
+   }
+}
+
 static irqreturn_t zynqmp_dp_irq_handler(int irq, void *data)
 {
struct zynqmp_dp *dp = (struct zynqmp_dp *)data;
@@ -1635,23 +1658,9 @@ static irqreturn_t zynqmp_dp_irq_handler(int irq, void 
*data)
if (status & ZYNQMP_DP_INT_HPD_EVENT)
schedule_delayed_work(>hpd_work, 0);
 
-   if (status & ZYNQMP_DP_INT_HPD_IRQ) {
-   int ret;
-   u8 status[DP_LINK_STATUS_SIZE + 2];
+   if (status & ZYNQMP_DP_INT_HPD_IRQ)
+   schedule_delayed_work(>hpd_irq_work, 0);
 
-   ret = drm_dp_dpcd_read(>aux, DP_SINK_COUNT, status,
-  DP_LINK_STATUS_SIZE + 2);
-   if (ret < 0)
-   goto handled;
-
-   if (status[4] & DP_LINK_STATUS_UPDATED ||
-   !drm_dp_clock_recovery_ok([2], dp->mode.lane_cnt) ||
-   !drm_dp_channel_eq_ok([2], dp->mode.lane_cnt)) {
-   zynqmp_dp_train_loop(dp);
-   }
-   }
-
-handled:
return IRQ_HANDLED;
 }
 
@@ -1676,6 +1685,7 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub)
dp->status = connector_status_disconnected;
 
INIT_DELAYED_WORK(>hpd_work, zynqmp_dp_hpd_work_func);
+   INIT_DELAYED_WORK(>hpd_irq_work, zynqmp_dp_hpd_irq_work_func);
 
/* Acquire all resources (IOMEM, IRQ and PHYs). */
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dp");
@@ -1775,6 +1785,7 @@ void zynqmp_dp_remove(struct zynqmp_dpsub *dpsub)
zynqmp_dp_write(dp, ZYNQMP_DP_INT_DS, ZYNQMP_DP_INT_ALL);
disable_irq(dp->irq);
 
+   cancel_delayed_work_sync(>hpd_irq_work);
cancel_delayed_work_sync(>hpd_work);
 
zynqmp_dp_write(dp, ZYNQMP_DP_TRANSMITTER_ENABLE, 0);
-- 
2.35.1.1320.gc452695387.dirty



[PATCH v2 4/8] drm: zynqmp_dp: Rearrange zynqmp_dp for better padding

2024-03-19 Thread Sean Anderson
Sort the members of struct zynqmp_dp to reduce padding necessary for
alignment.

Signed-off-by: Sean Anderson 
---

Changes in v2:
- New

 drivers/gpu/drm/xlnx/zynqmp_dp.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/xlnx/zynqmp_dp.c b/drivers/gpu/drm/xlnx/zynqmp_dp.c
index 8635b5673386..f1834c8e3c02 100644
--- a/drivers/gpu/drm/xlnx/zynqmp_dp.c
+++ b/drivers/gpu/drm/xlnx/zynqmp_dp.c
@@ -255,10 +255,10 @@ struct zynqmp_dp_link_config {
  * @fmt: format identifier string
  */
 struct zynqmp_dp_mode {
-   u8 bw_code;
-   u8 lane_cnt;
-   int pclock;
const char *fmt;
+   int pclock;
+   u8 bw_code;
+   u8 lane_cnt;
 };
 
 /**
@@ -295,27 +295,27 @@ struct zynqmp_dp_config {
  * @train_set: set of training data
  */
 struct zynqmp_dp {
+   struct drm_dp_aux aux;
+   struct drm_bridge bridge;
+   struct delayed_work hpd_work;
+
+   struct drm_bridge *next_bridge;
struct device *dev;
struct zynqmp_dpsub *dpsub;
void __iomem *iomem;
struct reset_control *reset;
-   int irq;
-
-   struct drm_bridge bridge;
-   struct drm_bridge *next_bridge;
-
-   struct zynqmp_dp_config config;
-   struct drm_dp_aux aux;
struct phy *phy[ZYNQMP_DP_MAX_LANES];
-   u8 num_lanes;
-   struct delayed_work hpd_work;
+
enum drm_connector_status status;
+   int irq;
bool enabled;
 
-   u8 dpcd[DP_RECEIVER_CAP_SIZE];
-   struct zynqmp_dp_link_config link_config;
struct zynqmp_dp_mode mode;
+   struct zynqmp_dp_link_config link_config;
+   struct zynqmp_dp_config config;
+   u8 dpcd[DP_RECEIVER_CAP_SIZE];
u8 train_set[ZYNQMP_DP_MAX_LANES];
+   u8 num_lanes;
 };
 
 static inline struct zynqmp_dp *bridge_to_dp(struct drm_bridge *bridge)
-- 
2.35.1.1320.gc452695387.dirty



[PATCH v2 7/8] drm: zynqmp_dp: Split off several helper functions

2024-03-19 Thread Sean Anderson
In preparation for supporting compliance testing, split off several
helper functions. No functional change intended.

Signed-off-by: Sean Anderson 
Reviewed-by: Laurent Pinchart 
---

(no changes since v1)

 drivers/gpu/drm/xlnx/zynqmp_dp.c | 49 ++--
 1 file changed, 34 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/xlnx/zynqmp_dp.c b/drivers/gpu/drm/xlnx/zynqmp_dp.c
index a90ab5c0f5cf..6e04dcf61e19 100644
--- a/drivers/gpu/drm/xlnx/zynqmp_dp.c
+++ b/drivers/gpu/drm/xlnx/zynqmp_dp.c
@@ -633,6 +633,7 @@ static void zynqmp_dp_adjust_train(struct zynqmp_dp *dp,
 /**
  * zynqmp_dp_update_vs_emph - Update the training values
  * @dp: DisplayPort IP core structure
+ * @train_set: A set of training values
  *
  * Update the training values based on the request from sink. The mapped values
  * are predefined, and values(vs, pe, pc) are from the device manual.
@@ -640,12 +641,12 @@ static void zynqmp_dp_adjust_train(struct zynqmp_dp *dp,
  * Return: 0 if vs and emph are updated successfully, or the error code 
returned
  * by drm_dp_dpcd_write().
  */
-static int zynqmp_dp_update_vs_emph(struct zynqmp_dp *dp)
+static int zynqmp_dp_update_vs_emph(struct zynqmp_dp *dp, u8 *train_set)
 {
unsigned int i;
int ret;
 
-   ret = drm_dp_dpcd_write(>aux, DP_TRAINING_LANE0_SET, dp->train_set,
+   ret = drm_dp_dpcd_write(>aux, DP_TRAINING_LANE0_SET, train_set,
dp->mode.lane_cnt);
if (ret < 0)
return ret;
@@ -653,7 +654,7 @@ static int zynqmp_dp_update_vs_emph(struct zynqmp_dp *dp)
for (i = 0; i < dp->mode.lane_cnt; i++) {
u32 reg = ZYNQMP_DP_SUB_TX_PHY_PRECURSOR_LANE_0 + i * 4;
union phy_configure_opts opts = { 0 };
-   u8 train = dp->train_set[i];
+   u8 train = train_set[i];
 
opts.dp.voltage[0] = (train & DP_TRAIN_VOLTAGE_SWING_MASK)
   >> DP_TRAIN_VOLTAGE_SWING_SHIFT;
@@ -697,7 +698,7 @@ static int zynqmp_dp_link_train_cr(struct zynqmp_dp *dp)
 * So, This loop should exit before 512 iterations
 */
for (max_tries = 0; max_tries < 512; max_tries++) {
-   ret = zynqmp_dp_update_vs_emph(dp);
+   ret = zynqmp_dp_update_vs_emph(dp, dp->train_set);
if (ret)
return ret;
 
@@ -762,7 +763,7 @@ static int zynqmp_dp_link_train_ce(struct zynqmp_dp *dp)
return ret;
 
for (tries = 0; tries < DP_MAX_TRAINING_TRIES; tries++) {
-   ret = zynqmp_dp_update_vs_emph(dp);
+   ret = zynqmp_dp_update_vs_emph(dp, dp->train_set);
if (ret)
return ret;
 
@@ -785,28 +786,29 @@ static int zynqmp_dp_link_train_ce(struct zynqmp_dp *dp)
 }
 
 /**
- * zynqmp_dp_train - Train the link
+ * zynqmp_dp_setup() - Set up major link parameters
  * @dp: DisplayPort IP core structure
+ * @bw_code: The link bandwidth as a multiple of 270 MHz
+ * @lane_cnt: The number of lanes to use
+ * @enhanced: Use enhanced framing
+ * @downspread: Enable spread-spectrum clocking
  *
- * Return: 0 if all trains are done successfully, or corresponding error code.
+ * Return: 0 on success, or -errno on failure
  */
-static int zynqmp_dp_train(struct zynqmp_dp *dp)
+static int zynqmp_dp_setup(struct zynqmp_dp *dp, u8 bw_code, u8 lane_cnt,
+  bool enhanced, bool downspread)
 {
u32 reg;
-   u8 bw_code = dp->mode.bw_code;
-   u8 lane_cnt = dp->mode.lane_cnt;
u8 aux_lane_cnt = lane_cnt;
-   bool enhanced;
int ret;
 
zynqmp_dp_write(dp, ZYNQMP_DP_LANE_COUNT_SET, lane_cnt);
-   enhanced = drm_dp_enhanced_frame_cap(dp->dpcd);
if (enhanced) {
zynqmp_dp_write(dp, ZYNQMP_DP_ENHANCED_FRAME_EN, 1);
aux_lane_cnt |= DP_LANE_COUNT_ENHANCED_FRAME_EN;
}
 
-   if (dp->dpcd[3] & 0x1) {
+   if (downspread) {
zynqmp_dp_write(dp, ZYNQMP_DP_DOWNSPREAD_CTL, 1);
drm_dp_dpcd_writeb(>aux, DP_DOWNSPREAD_CTRL,
   DP_SPREAD_AMP_0_5);
@@ -849,8 +851,25 @@ static int zynqmp_dp_train(struct zynqmp_dp *dp)
}
 
zynqmp_dp_write(dp, ZYNQMP_DP_PHY_CLOCK_SELECT, reg);
-   ret = zynqmp_dp_phy_ready(dp);
-   if (ret < 0)
+   return zynqmp_dp_phy_ready(dp);
+}
+
+
+/**
+ * zynqmp_dp_train - Train the link
+ * @dp: DisplayPort IP core structure
+ *
+ * Return: 0 if all trains are done successfully, or corresponding error code.
+ */
+static int zynqmp_dp_train(struct zynqmp_dp *dp)
+{
+   int ret;
+
+   ret = zynqmp_dp_setup(dp, dp->mode.bw_code, dp->mode.lane_cnt,
+ drm_dp_enhanced_frame_cap(dp->dpcd),
+ dp->dpcd[DP_MAX_DOWNSPREAD] &
+ DP_MAX_DOWNSPREAD_0_5);
+   if (ret)
return ret;
 

[PATCH v2 0/8] drm: zynqmp_dp: Misc. patches and debugfs support

2024-03-19 Thread Sean Anderson
This series adds debugfs support for the zynqmp_dp driver. The intent is
to enable compliance testing or to help debug signal-integrity issues.

The first four patches are general improvements (and could be applied
independently), while the last four add debugfs support.

Changes in v2:
- Fix kerneldoc
- Rearrange zynqmp_dp for better padding
- Document hpd_irq_work
- Split off the HPD IRQ work into another commit
- Expand the commit message
- Document debugfs files
- Add ignore_aux_errors and ignore_hpd debugfs files to replace earlier
  implicit functionality
- Attempt to fix unreproducable, spurious build warning
- Drop "Optionally ignore DPCD errors" in favor of a debugfs file
  directly affecting zynqmp_dp_aux_transfer.

Sean Anderson (8):
  drm: xlnx: Fix kerneldoc
  drm: zynqmp_dp: Downgrade log level for aux retries message
  drm: zynqmp_dp: Adjust training values per-lane
  drm: zynqmp_dp: Rearrange zynqmp_dp for better padding
  drm: zynqmp_dp: Don't retrain the link in our IRQ
  drm: zynqmp_dp: Add locking
  drm: zynqmp_dp: Split off several helper functions
  drm: zynqmp_dp: Add debugfs interface for compliance testing

 Documentation/gpu/drivers.rst   |   1 +
 Documentation/gpu/zynqmp.rst| 149 +
 MAINTAINERS |   1 +
 drivers/gpu/drm/xlnx/zynqmp_disp.c  |   6 +-
 drivers/gpu/drm/xlnx/zynqmp_dp.c| 836 +---
 drivers/gpu/drm/xlnx/zynqmp_dpsub.h |   1 +
 drivers/gpu/drm/xlnx/zynqmp_kms.h   |   4 +-
 7 files changed, 931 insertions(+), 67 deletions(-)
 create mode 100644 Documentation/gpu/zynqmp.rst

-- 
2.35.1.1320.gc452695387.dirty



[PATCH v2 3/8] drm: zynqmp_dp: Adjust training values per-lane

2024-03-19 Thread Sean Anderson
The feedback we get from the DPRX is per-lane. Make changes using this
information, instead of picking the maximum values from all lanes. This
results in more-consistent training on marginal links.

Signed-off-by: Sean Anderson 
---

(no changes since v1)

 drivers/gpu/drm/xlnx/zynqmp_dp.c | 23 ---
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/xlnx/zynqmp_dp.c b/drivers/gpu/drm/xlnx/zynqmp_dp.c
index 98a32e6a0459..8635b5673386 100644
--- a/drivers/gpu/drm/xlnx/zynqmp_dp.c
+++ b/drivers/gpu/drm/xlnx/zynqmp_dp.c
@@ -605,28 +605,21 @@ static void zynqmp_dp_adjust_train(struct zynqmp_dp *dp,
   u8 link_status[DP_LINK_STATUS_SIZE])
 {
u8 *train_set = dp->train_set;
-   u8 voltage = 0, preemphasis = 0;
u8 i;
 
for (i = 0; i < dp->mode.lane_cnt; i++) {
-   u8 v = drm_dp_get_adjust_request_voltage(link_status, i);
-   u8 p = drm_dp_get_adjust_request_pre_emphasis(link_status, i);
+   u8 voltage = drm_dp_get_adjust_request_voltage(link_status, i);
+   u8 preemphasis =
+   drm_dp_get_adjust_request_pre_emphasis(link_status, i);
 
-   if (v > voltage)
-   voltage = v;
+   if (voltage >= DP_TRAIN_VOLTAGE_SWING_LEVEL_3)
+   voltage |= DP_TRAIN_MAX_SWING_REACHED;
 
-   if (p > preemphasis)
-   preemphasis = p;
-   }
+   if (preemphasis >= DP_TRAIN_PRE_EMPH_LEVEL_2)
+   preemphasis |= DP_TRAIN_MAX_PRE_EMPHASIS_REACHED;
 
-   if (voltage >= DP_TRAIN_VOLTAGE_SWING_LEVEL_3)
-   voltage |= DP_TRAIN_MAX_SWING_REACHED;
-
-   if (preemphasis >= DP_TRAIN_PRE_EMPH_LEVEL_2)
-   preemphasis |= DP_TRAIN_MAX_PRE_EMPHASIS_REACHED;
-
-   for (i = 0; i < dp->mode.lane_cnt; i++)
train_set[i] = voltage | preemphasis;
+   }
 }
 
 /**
-- 
2.35.1.1320.gc452695387.dirty



[PATCH v2 2/8] drm: zynqmp_dp: Downgrade log level for aux retries message

2024-03-19 Thread Sean Anderson
Enable this message for verbose debugging only as it is otherwise
printed after every AUX message, quickly filling the log buffer.

Signed-off-by: Sean Anderson 
Reviewed-by: Laurent Pinchart 
---

(no changes since v1)

 drivers/gpu/drm/xlnx/zynqmp_dp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/xlnx/zynqmp_dp.c b/drivers/gpu/drm/xlnx/zynqmp_dp.c
index a0606fab0e22..98a32e6a0459 100644
--- a/drivers/gpu/drm/xlnx/zynqmp_dp.c
+++ b/drivers/gpu/drm/xlnx/zynqmp_dp.c
@@ -1006,7 +1006,7 @@ zynqmp_dp_aux_transfer(struct drm_dp_aux *aux, struct 
drm_dp_aux_msg *msg)
   msg->buffer, msg->size,
   >reply);
if (!ret) {
-   dev_dbg(dp->dev, "aux %d retries\n", i);
+   dev_vdbg(dp->dev, "aux %d retries\n", i);
return msg->size;
}
 
-- 
2.35.1.1320.gc452695387.dirty



[PATCH v2 1/8] drm: xlnx: Fix kerneldoc

2024-03-19 Thread Sean Anderson
Fix a few errors in the kerneldoc. Mostly this addresses missing/renamed
members.

Signed-off-by: Sean Anderson 
---

Changes in v2:
- New

 drivers/gpu/drm/xlnx/zynqmp_disp.c  | 6 +++---
 drivers/gpu/drm/xlnx/zynqmp_dpsub.h | 1 +
 drivers/gpu/drm/xlnx/zynqmp_kms.h   | 4 ++--
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/xlnx/zynqmp_disp.c 
b/drivers/gpu/drm/xlnx/zynqmp_disp.c
index 407bc07cec69..f79bf3fb8110 100644
--- a/drivers/gpu/drm/xlnx/zynqmp_disp.c
+++ b/drivers/gpu/drm/xlnx/zynqmp_disp.c
@@ -128,9 +128,9 @@ struct zynqmp_disp_layer {
  * struct zynqmp_disp - Display controller
  * @dev: Device structure
  * @dpsub: Display subsystem
- * @blend.base: Register I/O base address for the blender
- * @avbuf.base: Register I/O base address for the audio/video buffer manager
- * @audio.base: Registers I/O base address for the audio mixer
+ * @blend: Register I/O base address for the blender
+ * @avbuf: Register I/O base address for the audio/video buffer manager
+ * @audio: Registers I/O base address for the audio mixer
  * @layers: Layers (planes)
  */
 struct zynqmp_disp {
diff --git a/drivers/gpu/drm/xlnx/zynqmp_dpsub.h 
b/drivers/gpu/drm/xlnx/zynqmp_dpsub.h
index 09ea01878f2a..b18554467e9c 100644
--- a/drivers/gpu/drm/xlnx/zynqmp_dpsub.h
+++ b/drivers/gpu/drm/xlnx/zynqmp_dpsub.h
@@ -53,6 +53,7 @@ enum zynqmp_dpsub_format {
  * @drm: The DRM/KMS device data
  * @bridge: The DP encoder bridge
  * @disp: The display controller
+ * @layers: Video and graphics layers
  * @dp: The DisplayPort controller
  * @dma_align: DMA alignment constraint (must be a power of 2)
  */
diff --git a/drivers/gpu/drm/xlnx/zynqmp_kms.h 
b/drivers/gpu/drm/xlnx/zynqmp_kms.h
index 01be96b00e3f..cb13c6b8008e 100644
--- a/drivers/gpu/drm/xlnx/zynqmp_kms.h
+++ b/drivers/gpu/drm/xlnx/zynqmp_kms.h
@@ -22,9 +22,9 @@
 struct zynqmp_dpsub;
 
 /**
- * struct zynqmp_dpsub - ZynqMP DisplayPort Subsystem DRM/KMS data
+ * struct zynqmp_dpsub_drm - ZynqMP DisplayPort Subsystem DRM/KMS data
  * @dpsub: Backpointer to the DisplayPort subsystem
- * @drm: The DRM/KMS device
+ * @dev: The DRM/KMS device
  * @planes: The DRM planes
  * @crtc: The DRM CRTC
  * @encoder: The dummy DRM encoder
-- 
2.35.1.1320.gc452695387.dirty



Re: [PATCH v2] drm/dp: Clarify that wait_hpd_asserted() is not optional for panels

2024-03-19 Thread Dmitry Baryshkov
On Tue, 19 Mar 2024 at 22:58, Douglas Anderson  wrote:
>
> In response to my patch removing the "wait for HPD" logic at the
> beginning of the MSM DP transfer() callback [1], we had some debate
> about what the "This is an optional function" meant in the
> documentation of the wait_hpd_asserted() callback. Let's clarify.
>
> As talked about in the MSM DP patch [1], before wait_hpd_asserted()
> was introduced there was no great way for panel drivers to wait for
> HPD in the case that the "built-in" HPD signal was used. Panel drivers
> could only wait for HPD if a GPIO was used. At the time, we ended up
> just saying that if we were using the "built-in" HPD signal that DP
> AUX controllers needed to wait for HPD themselves at the beginning of
> their transfer() callback. The fact that the wait for HPD at the
> beginning of transfer() was awkward/problematic was the whole reason
> wait_hpd_asserted() was added.
>
> Let's make it obvious that if a DP AUX controller implements
> wait_hpd_asserted() that they don't need a loop waiting for HPD at the
> start of their transfer() function. We'll still allow DP controllers
> to work the old way but mark it as deprecated.
>
> [1] 
> https://lore.kernel.org/r/20240315143621.v2.3.I535606f6d4f7e3e5588bb75c55996f61980183cd@changeid
>
> Reviewed-by: Abhinav Kumar 
> Signed-off-by: Douglas Anderson 
> ---
> I would consider changing the docs to say that implementing
> wait_hpd_asserted() is actually _required_ for any DP controllers that
> want to support eDP panels parented on the DP AUX bus. The issue is
> that one DP controller (tegra/dpaux.c, found by looking for those that
> include display/drm_dp_aux_bus.h) does populate the DP AUX bus but
> doesn't implement wait_hpd_asserted(). I'm actually not sure how/if
> this work on tegra since I also don't see any delay loop for HPD in
> tegra's transfer() callback. For now, I've left wait_hpd_asserted() as
> optional and described the old/deprecated way things used to work
> before wait_hpd_asserted().
>
> Changes in v2:
> - Make it clear that panels don't need to call if HPD is a GPIO.
>
>  include/drm/display/drm_dp_helper.h | 13 -
>  1 file changed, 12 insertions(+), 1 deletion(-)

Reviewed-by: Dmitry Baryshkov 


-- 
With best wishes
Dmitry


Re: [PATCH v3 3/5] drm/msm/dpu: handle perf mode in _dpu_core_perf_crtc_update_bus()

2024-03-19 Thread Dmitry Baryshkov
On Tue, 19 Mar 2024 at 23:35, Abhinav Kumar  wrote:
>
>
>
> On 3/19/2024 1:43 PM, Dmitry Baryshkov wrote:
> > On Tue, 19 Mar 2024 at 22:34, Abhinav Kumar  
> > wrote:
> >>
> >>
> >>
> >> On 3/13/2024 6:10 PM, Dmitry Baryshkov wrote:
> >>> Move perf mode handling for the bandwidth to
> >>> _dpu_core_perf_crtc_update_bus() rather than overriding per-CRTC data
> >>> and then aggregating known values.
> >>>
> >>> Note, this changes the fix_core_ab_vote. Previously it would be
> >>> multiplied per the CRTC number, now it will be used directly for
> >>> interconnect voting.
> >>>
> >>> Signed-off-by: Dmitry Baryshkov 
> >>> ---
> >>>drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c | 39 
> >>> +--
> >>>1 file changed, 19 insertions(+), 20 deletions(-)
> >>>
> >>> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c 
> >>> b/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c
> >>> index 87b892069526..ff2942a6a678 100644
> >>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c
> >>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c
> >>> @@ -118,21 +118,9 @@ static void _dpu_core_perf_calc_crtc(const struct 
> >>> dpu_core_perf *core_perf,
> >>>return;
> >>>}
> >>>
> >>> - memset(perf, 0, sizeof(struct dpu_core_perf_params));
> >>> -
> >>> - if (core_perf->perf_tune.mode == DPU_PERF_MODE_MINIMUM) {
> >>> - perf->bw_ctl = 0;
> >>> - perf->max_per_pipe_ib = 0;
> >>> - perf->core_clk_rate = 0;
> >>> - } else if (core_perf->perf_tune.mode == DPU_PERF_MODE_FIXED) {
> >>> - perf->bw_ctl = core_perf->fix_core_ab_vote;
> >>> - perf->max_per_pipe_ib = core_perf->fix_core_ib_vote;
> >>> - perf->core_clk_rate = core_perf->fix_core_clk_rate;
> >>> - } else {
> >>> - perf->bw_ctl = _dpu_core_perf_calc_bw(perf_cfg, crtc);
> >>> - perf->max_per_pipe_ib = perf_cfg->min_dram_ib;
> >>> - perf->core_clk_rate = _dpu_core_perf_calc_clk(perf_cfg, 
> >>> crtc, state);
> >>> - }
> >>> + perf->bw_ctl = _dpu_core_perf_calc_bw(perf_cfg, crtc);
> >>> + perf->max_per_pipe_ib = perf_cfg->min_dram_ib;
> >>> + perf->core_clk_rate = _dpu_core_perf_calc_clk(perf_cfg, crtc, 
> >>> state);
> >>>
> >>>DRM_DEBUG_ATOMIC(
> >>>"crtc=%d clk_rate=%llu core_ib=%llu core_ab=%llu\n",
> >>> @@ -233,18 +221,29 @@ static int _dpu_core_perf_crtc_update_bus(struct 
> >>> dpu_kms *kms,
> >>>{
> >>>struct dpu_core_perf_params perf = { 0 };
> >>>int i, ret = 0;
> >>> - u64 avg_bw;
> >>> + u32 avg_bw;
> >>> + u32 peak_bw;
>
> Why were avg_bw and peak_bw values brought down to u32?
>
> I think we might go higher so u64 was better.

First of all, icc_set_bw takes u32, not u64. The unit is 1000 bps, not
1 bps, so sensible values fit into u32.

>
> >>>
> >>>if (!kms->num_paths)
> >>>return 0;
> >>>
> >>> - dpu_core_perf_aggregate(crtc->dev, dpu_crtc_get_client_type(crtc), 
> >>> );
> >>> + if (kms->perf.perf_tune.mode == DPU_PERF_MODE_MINIMUM) {
> >>> + avg_bw = 0;
> >>> + peak_bw = 0;
> >>> + } else if (kms->perf.perf_tune.mode == DPU_PERF_MODE_FIXED) {
> >>> + avg_bw = kms->perf.fix_core_ab_vote;
> >>> + peak_bw = kms->perf.fix_core_ib_vote;
>
> Instead of changing the value of avg_bw like mentioned in commit text,
> why cant we do avg_bw = fix_core_ab * (drm_mode_config::num_crtc);
>
> Any reason you want to change it from "per CRTC fixed" to just "fixed"?
>
> Now, the user who wants to hard-code this also needs to first account
> for number of CRTCs from the dri state and then program the fixed value
> using debugfs. Thats not convenient.

Different CRTCs have different bandwidth values, so programming as
value-per-CRTC is not efficient. In the end we care for the overall
bandwidth, so one has to calculate the expected value then divide it
per num_crtc.

>
> >>> + } else {
> >>> + dpu_core_perf_aggregate(crtc->dev, 
> >>> dpu_crtc_get_client_type(crtc), );
> >>
> >> Where is this function dpu_core_perf_aggregate() defined? I dont see it
> >> in msm-next
> >
> > In the previous patch.
> >
>
> Sorry, my bad. I thought it had a different name in the prev patch :/

No problems.

>
>
> >>
> >>> +
> >>> + avg_bw = div_u64(perf.bw_ctl, 1000); /*Bps_to_icc*/
> >>> + peak_bw = perf.max_per_pipe_ib;
> >>> + }
> >>>
> >>> - avg_bw = perf.bw_ctl;
> >>> - do_div(avg_bw, (kms->num_paths * 1000)); /*Bps_to_icc*/
> >>> + avg_bw /= kms->num_paths;
> >>>
>
> >>>for (i = 0; i < kms->num_paths; i++)
> >>> - icc_set_bw(kms->path[i], avg_bw, perf.max_per_pipe_ib);
> >>> + icc_set_bw(kms->path[i], avg_bw, peak_bw);
> >>>
> >>>return ret;
> >>>}
> >>>
> >
> >
> >



-- 
With best wishes
Dmitry


Re: [PATCH v3 3/5] drm/msm/dpu: handle perf mode in _dpu_core_perf_crtc_update_bus()

2024-03-19 Thread Abhinav Kumar




On 3/19/2024 1:43 PM, Dmitry Baryshkov wrote:

On Tue, 19 Mar 2024 at 22:34, Abhinav Kumar  wrote:




On 3/13/2024 6:10 PM, Dmitry Baryshkov wrote:

Move perf mode handling for the bandwidth to
_dpu_core_perf_crtc_update_bus() rather than overriding per-CRTC data
and then aggregating known values.

Note, this changes the fix_core_ab_vote. Previously it would be
multiplied per the CRTC number, now it will be used directly for
interconnect voting.

Signed-off-by: Dmitry Baryshkov 
---
   drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c | 39 
+--
   1 file changed, 19 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c
index 87b892069526..ff2942a6a678 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c
@@ -118,21 +118,9 @@ static void _dpu_core_perf_calc_crtc(const struct 
dpu_core_perf *core_perf,
   return;
   }

- memset(perf, 0, sizeof(struct dpu_core_perf_params));
-
- if (core_perf->perf_tune.mode == DPU_PERF_MODE_MINIMUM) {
- perf->bw_ctl = 0;
- perf->max_per_pipe_ib = 0;
- perf->core_clk_rate = 0;
- } else if (core_perf->perf_tune.mode == DPU_PERF_MODE_FIXED) {
- perf->bw_ctl = core_perf->fix_core_ab_vote;
- perf->max_per_pipe_ib = core_perf->fix_core_ib_vote;
- perf->core_clk_rate = core_perf->fix_core_clk_rate;
- } else {
- perf->bw_ctl = _dpu_core_perf_calc_bw(perf_cfg, crtc);
- perf->max_per_pipe_ib = perf_cfg->min_dram_ib;
- perf->core_clk_rate = _dpu_core_perf_calc_clk(perf_cfg, crtc, 
state);
- }
+ perf->bw_ctl = _dpu_core_perf_calc_bw(perf_cfg, crtc);
+ perf->max_per_pipe_ib = perf_cfg->min_dram_ib;
+ perf->core_clk_rate = _dpu_core_perf_calc_clk(perf_cfg, crtc, state);

   DRM_DEBUG_ATOMIC(
   "crtc=%d clk_rate=%llu core_ib=%llu core_ab=%llu\n",
@@ -233,18 +221,29 @@ static int _dpu_core_perf_crtc_update_bus(struct dpu_kms 
*kms,
   {
   struct dpu_core_perf_params perf = { 0 };
   int i, ret = 0;
- u64 avg_bw;
+ u32 avg_bw;
+ u32 peak_bw;


Why were avg_bw and peak_bw values brought down to u32?

I think we might go higher so u64 was better.



   if (!kms->num_paths)
   return 0;

- dpu_core_perf_aggregate(crtc->dev, dpu_crtc_get_client_type(crtc), );
+ if (kms->perf.perf_tune.mode == DPU_PERF_MODE_MINIMUM) {
+ avg_bw = 0;
+ peak_bw = 0;
+ } else if (kms->perf.perf_tune.mode == DPU_PERF_MODE_FIXED) {
+ avg_bw = kms->perf.fix_core_ab_vote;
+ peak_bw = kms->perf.fix_core_ib_vote;


Instead of changing the value of avg_bw like mentioned in commit text, 
why cant we do avg_bw = fix_core_ab * (drm_mode_config::num_crtc);


Any reason you want to change it from "per CRTC fixed" to just "fixed"?

Now, the user who wants to hard-code this also needs to first account 
for number of CRTCs from the dri state and then program the fixed value 
using debugfs. Thats not convenient.



+ } else {
+ dpu_core_perf_aggregate(crtc->dev, dpu_crtc_get_client_type(crtc), 
);


Where is this function dpu_core_perf_aggregate() defined? I dont see it
in msm-next


In the previous patch.



Sorry, my bad. I thought it had a different name in the prev patch :/





+
+ avg_bw = div_u64(perf.bw_ctl, 1000); /*Bps_to_icc*/
+ peak_bw = perf.max_per_pipe_ib;
+ }

- avg_bw = perf.bw_ctl;
- do_div(avg_bw, (kms->num_paths * 1000)); /*Bps_to_icc*/
+ avg_bw /= kms->num_paths;




   for (i = 0; i < kms->num_paths; i++)
- icc_set_bw(kms->path[i], avg_bw, perf.max_per_pipe_ib);
+ icc_set_bw(kms->path[i], avg_bw, peak_bw);

   return ret;
   }







Re: [PATCH] drm/dp: Clarify that wait_hpd_asserted() is not optional for panels

2024-03-19 Thread Doug Anderson
Hi,

On Tue, Mar 19, 2024 at 1:55 PM Dmitry Baryshkov
 wrote:
>
> >  -* panel to finish powering on. This is an optional function.
> >  +* panel to finish powering on. It is optional for DP AUX 
> >  controllers
> >  +* to implement this function but required for DP AUX 
> >  endpoints (panel
> >  +* drivers) to call it after powering up but before doing AUX 
> >  transfers.
> >  +* If a DP AUX controller does not implement this function 
> >  then it
> >  +* may still support eDP panels that use the AUX controller's 
> >  built-in
> >  +* HPD signal by implementing a long wait for HPD in the 
> >  transfer()
> >  +* callback, though this is deprecated.
> > >>>
> > >>> It doesn't cover a valid case when the panel driver handles HPD signal
> > >>> on its own.
> > >>>
> > >>
> > >> This doc is only for wait_for_hpd_asserted(). If panel driver handles
> > >> HPD signal on its own, this will not be called. Do we need a doc for 
> > >> that?
> > >
> > > This comment declares that this callback must be called by the panel
> > > driver: '...but required for DP AUX endpoints [...] to call it after
> > > powering up but before doing AUX transfers.'
> > >
> > > If we were to follow documentation changes from this patch, we'd have
> > > to patch panel-edp to always call wait_for_hpd_asserted, even if HPD
> > > GPIO is used. However this is not correct from my POV.
> > >
> >
> > hmmm I dont mind explicitly saying "unless the panel can independently
> > check the HPD state" but not required in my opinion because if panel was
> > capable of checking the HPD gpio (its self-capable) why would it even
> > call wait_for_hpd_asserted?
>
> I'm fine with the proposed change. Doug?
>
> >
> > I will let you and Doug discuss this but fwiw, I am fine without this
> > additional clarification. So the R-b stands with or without this
> > additional clause.

Adjusted wording in v2. Kept Abhniav's R-b. PTAL.

https://lore.kernel.org/r/20240319135836.v2.1.I521dad0693cc24fe4dd14cba0c7048d94f5b6b41@changeid


[PATCH v2] drm/dp: Clarify that wait_hpd_asserted() is not optional for panels

2024-03-19 Thread Douglas Anderson
In response to my patch removing the "wait for HPD" logic at the
beginning of the MSM DP transfer() callback [1], we had some debate
about what the "This is an optional function" meant in the
documentation of the wait_hpd_asserted() callback. Let's clarify.

As talked about in the MSM DP patch [1], before wait_hpd_asserted()
was introduced there was no great way for panel drivers to wait for
HPD in the case that the "built-in" HPD signal was used. Panel drivers
could only wait for HPD if a GPIO was used. At the time, we ended up
just saying that if we were using the "built-in" HPD signal that DP
AUX controllers needed to wait for HPD themselves at the beginning of
their transfer() callback. The fact that the wait for HPD at the
beginning of transfer() was awkward/problematic was the whole reason
wait_hpd_asserted() was added.

Let's make it obvious that if a DP AUX controller implements
wait_hpd_asserted() that they don't need a loop waiting for HPD at the
start of their transfer() function. We'll still allow DP controllers
to work the old way but mark it as deprecated.

[1] 
https://lore.kernel.org/r/20240315143621.v2.3.I535606f6d4f7e3e5588bb75c55996f61980183cd@changeid

Reviewed-by: Abhinav Kumar 
Signed-off-by: Douglas Anderson 
---
I would consider changing the docs to say that implementing
wait_hpd_asserted() is actually _required_ for any DP controllers that
want to support eDP panels parented on the DP AUX bus. The issue is
that one DP controller (tegra/dpaux.c, found by looking for those that
include display/drm_dp_aux_bus.h) does populate the DP AUX bus but
doesn't implement wait_hpd_asserted(). I'm actually not sure how/if
this work on tegra since I also don't see any delay loop for HPD in
tegra's transfer() callback. For now, I've left wait_hpd_asserted() as
optional and described the old/deprecated way things used to work
before wait_hpd_asserted().

Changes in v2:
- Make it clear that panels don't need to call if HPD is a GPIO.

 include/drm/display/drm_dp_helper.h | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/include/drm/display/drm_dp_helper.h 
b/include/drm/display/drm_dp_helper.h
index a62fcd051d4d..6c6a96496df6 100644
--- a/include/drm/display/drm_dp_helper.h
+++ b/include/drm/display/drm_dp_helper.h
@@ -422,7 +422,18 @@ struct drm_dp_aux {
 * @wait_hpd_asserted: wait for HPD to be asserted
 *
 * This is mainly useful for eDP panels drivers to wait for an eDP
-* panel to finish powering on. This is an optional function.
+* panel to finish powering on. It is optional for DP AUX controllers
+* to implement this function. It is required for DP AUX endpoints
+* (panel drivers) to call this function after powering up but before
+* doing AUX transfers unless the DP AUX endpoint driver knows that
+* we're not using the AUX controller's HPD. One example of the panel
+* driver not needing to call this is if HPD is hooked up to a GPIO
+* that the panel driver can read directly.
+*
+* If a DP AUX controller does not implement this function then it
+* may still support eDP panels that use the AUX controller's built-in
+* HPD signal by implementing a long wait for HPD in the transfer()
+* callback, though this is deprecated.
 *
 * This function will efficiently wait for the HPD signal to be
 * asserted. The `wait_us` parameter that is passed in says that we
-- 
2.44.0.291.gc1ea87d7ee-goog



Re: [PATCH] drm/dp: Clarify that wait_hpd_asserted() is not optional for panels

2024-03-19 Thread Dmitry Baryshkov
On Tue, 19 Mar 2024 at 22:39, Abhinav Kumar  wrote:
>
>
>
> On 3/19/2024 1:16 PM, Dmitry Baryshkov wrote:
> > On Tue, 19 Mar 2024 at 21:02, Abhinav Kumar  
> > wrote:
> >>
> >>
> >>
> >> On 3/19/2024 11:35 AM, Dmitry Baryshkov wrote:
> >>> On Tue, 19 Mar 2024 at 20:15, Douglas Anderson  
> >>> wrote:
> 
>  In response to my patch removing the "wait for HPD" logic at the
>  beginning of the MSM DP transfer() callback [1], we had some debate
>  about what the "This is an optional function" meant in the
>  documentation of the wait_hpd_asserted() callback. Let's clarify.
> 
>  As talked about in the MSM DP patch [1], before wait_hpd_asserted()
>  was introduced there was no great way for panel drivers to wait for
>  HPD in the case that the "built-in" HPD signal was used. Panel drivers
>  could only wait for HPD if a GPIO was used. At the time, we ended up
>  just saying that if we were using the "built-in" HPD signal that DP
>  AUX controllers needed to wait for HPD themselves at the beginning of
>  their transfer() callback. The fact that the wait for HPD at the
>  beginning of transfer() was awkward/problematic was the whole reason
>  wait_hpd_asserted() was added.
> 
>  Let's make it obvious that if a DP AUX controller implements
>  wait_hpd_asserted() that they don't need a loop waiting for HPD at the
>  start of their transfer() function. We'll still allow DP controllers
>  to work the old way but mark it as deprecated.
> 
>  [1] 
>  https://lore.kernel.org/r/20240315143621.v2.3.I535606f6d4f7e3e5588bb75c55996f61980183cd@changeid
> 
>  Signed-off-by: Douglas Anderson 
>  ---
>  I would consider changing the docs to say that implementing
>  wait_hpd_asserted() is actually _required_ for any DP controllers that
>  want to support eDP panels parented on the DP AUX bus. The issue is
>  that one DP controller (tegra/dpaux.c, found by looking for those that
>  include display/drm_dp_aux_bus.h) does populate the DP AUX bus but
>  doesn't implement wait_hpd_asserted(). I'm actually not sure how/if
>  this work on tegra since I also don't see any delay loop for HPD in
>  tegra's transfer() callback. For now, I've left wait_hpd_asserted() as
>  optional and described the old/deprecated way things used to work
>  before wait_hpd_asserted().
> 
> include/drm/display/drm_dp_helper.h | 8 +++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
> 
>  diff --git a/include/drm/display/drm_dp_helper.h 
>  b/include/drm/display/drm_dp_helper.h
>  index a62fcd051d4d..b170efa1f5d2 100644
>  --- a/include/drm/display/drm_dp_helper.h
>  +++ b/include/drm/display/drm_dp_helper.h
>  @@ -422,7 +422,13 @@ struct drm_dp_aux {
> * @wait_hpd_asserted: wait for HPD to be asserted
> *
> * This is mainly useful for eDP panels drivers to wait for an 
>  eDP
>  -* panel to finish powering on. This is an optional function.
>  +* panel to finish powering on. It is optional for DP AUX 
>  controllers
>  +* to implement this function but required for DP AUX endpoints 
>  (panel
>  +* drivers) to call it after powering up but before doing AUX 
>  transfers.
>  +* If a DP AUX controller does not implement this function then 
>  it
>  +* may still support eDP panels that use the AUX controller's 
>  built-in
>  +* HPD signal by implementing a long wait for HPD in the 
>  transfer()
>  +* callback, though this is deprecated.
> >>>
> >>> It doesn't cover a valid case when the panel driver handles HPD signal
> >>> on its own.
> >>>
> >>
> >> This doc is only for wait_for_hpd_asserted(). If panel driver handles
> >> HPD signal on its own, this will not be called. Do we need a doc for that?
> >
> > This comment declares that this callback must be called by the panel
> > driver: '...but required for DP AUX endpoints [...] to call it after
> > powering up but before doing AUX transfers.'
> >
> > If we were to follow documentation changes from this patch, we'd have
> > to patch panel-edp to always call wait_for_hpd_asserted, even if HPD
> > GPIO is used. However this is not correct from my POV.
> >
>
> hmmm I dont mind explicitly saying "unless the panel can independently
> check the HPD state" but not required in my opinion because if panel was
> capable of checking the HPD gpio (its self-capable) why would it even
> call wait_for_hpd_asserted?

I'm fine with the proposed change. Doug?

>
> I will let you and Doug discuss this but fwiw, I am fine without this
> additional clarification. So the R-b stands with or without this
> additional clause.
>
> *
> * This function will efficiently wait for the HPD signal to be
> * asserted. The `wait_us` 

Re: [PATCH v3 3/5] drm/msm/dpu: handle perf mode in _dpu_core_perf_crtc_update_bus()

2024-03-19 Thread Dmitry Baryshkov
On Tue, 19 Mar 2024 at 22:34, Abhinav Kumar  wrote:
>
>
>
> On 3/13/2024 6:10 PM, Dmitry Baryshkov wrote:
> > Move perf mode handling for the bandwidth to
> > _dpu_core_perf_crtc_update_bus() rather than overriding per-CRTC data
> > and then aggregating known values.
> >
> > Note, this changes the fix_core_ab_vote. Previously it would be
> > multiplied per the CRTC number, now it will be used directly for
> > interconnect voting.
> >
> > Signed-off-by: Dmitry Baryshkov 
> > ---
> >   drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c | 39 
> > +--
> >   1 file changed, 19 insertions(+), 20 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c 
> > b/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c
> > index 87b892069526..ff2942a6a678 100644
> > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c
> > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c
> > @@ -118,21 +118,9 @@ static void _dpu_core_perf_calc_crtc(const struct 
> > dpu_core_perf *core_perf,
> >   return;
> >   }
> >
> > - memset(perf, 0, sizeof(struct dpu_core_perf_params));
> > -
> > - if (core_perf->perf_tune.mode == DPU_PERF_MODE_MINIMUM) {
> > - perf->bw_ctl = 0;
> > - perf->max_per_pipe_ib = 0;
> > - perf->core_clk_rate = 0;
> > - } else if (core_perf->perf_tune.mode == DPU_PERF_MODE_FIXED) {
> > - perf->bw_ctl = core_perf->fix_core_ab_vote;
> > - perf->max_per_pipe_ib = core_perf->fix_core_ib_vote;
> > - perf->core_clk_rate = core_perf->fix_core_clk_rate;
> > - } else {
> > - perf->bw_ctl = _dpu_core_perf_calc_bw(perf_cfg, crtc);
> > - perf->max_per_pipe_ib = perf_cfg->min_dram_ib;
> > - perf->core_clk_rate = _dpu_core_perf_calc_clk(perf_cfg, crtc, 
> > state);
> > - }
> > + perf->bw_ctl = _dpu_core_perf_calc_bw(perf_cfg, crtc);
> > + perf->max_per_pipe_ib = perf_cfg->min_dram_ib;
> > + perf->core_clk_rate = _dpu_core_perf_calc_clk(perf_cfg, crtc, state);
> >
> >   DRM_DEBUG_ATOMIC(
> >   "crtc=%d clk_rate=%llu core_ib=%llu core_ab=%llu\n",
> > @@ -233,18 +221,29 @@ static int _dpu_core_perf_crtc_update_bus(struct 
> > dpu_kms *kms,
> >   {
> >   struct dpu_core_perf_params perf = { 0 };
> >   int i, ret = 0;
> > - u64 avg_bw;
> > + u32 avg_bw;
> > + u32 peak_bw;
> >
> >   if (!kms->num_paths)
> >   return 0;
> >
> > - dpu_core_perf_aggregate(crtc->dev, dpu_crtc_get_client_type(crtc), 
> > );
> > + if (kms->perf.perf_tune.mode == DPU_PERF_MODE_MINIMUM) {
> > + avg_bw = 0;
> > + peak_bw = 0;
> > + } else if (kms->perf.perf_tune.mode == DPU_PERF_MODE_FIXED) {
> > + avg_bw = kms->perf.fix_core_ab_vote;
> > + peak_bw = kms->perf.fix_core_ib_vote;
> > + } else {
> > + dpu_core_perf_aggregate(crtc->dev, 
> > dpu_crtc_get_client_type(crtc), );
>
> Where is this function dpu_core_perf_aggregate() defined? I dont see it
> in msm-next

In the previous patch.

>
> > +
> > + avg_bw = div_u64(perf.bw_ctl, 1000); /*Bps_to_icc*/
> > + peak_bw = perf.max_per_pipe_ib;
> > + }
> >
> > - avg_bw = perf.bw_ctl;
> > - do_div(avg_bw, (kms->num_paths * 1000)); /*Bps_to_icc*/
> > + avg_bw /= kms->num_paths;
> >
> >   for (i = 0; i < kms->num_paths; i++)
> > - icc_set_bw(kms->path[i], avg_bw, perf.max_per_pipe_ib);
> > + icc_set_bw(kms->path[i], avg_bw, peak_bw);
> >
> >   return ret;
> >   }
> >



-- 
With best wishes
Dmitry


Re: [PATCH] drm/dp: Clarify that wait_hpd_asserted() is not optional for panels

2024-03-19 Thread Abhinav Kumar




On 3/19/2024 1:16 PM, Dmitry Baryshkov wrote:

On Tue, 19 Mar 2024 at 21:02, Abhinav Kumar  wrote:




On 3/19/2024 11:35 AM, Dmitry Baryshkov wrote:

On Tue, 19 Mar 2024 at 20:15, Douglas Anderson  wrote:


In response to my patch removing the "wait for HPD" logic at the
beginning of the MSM DP transfer() callback [1], we had some debate
about what the "This is an optional function" meant in the
documentation of the wait_hpd_asserted() callback. Let's clarify.

As talked about in the MSM DP patch [1], before wait_hpd_asserted()
was introduced there was no great way for panel drivers to wait for
HPD in the case that the "built-in" HPD signal was used. Panel drivers
could only wait for HPD if a GPIO was used. At the time, we ended up
just saying that if we were using the "built-in" HPD signal that DP
AUX controllers needed to wait for HPD themselves at the beginning of
their transfer() callback. The fact that the wait for HPD at the
beginning of transfer() was awkward/problematic was the whole reason
wait_hpd_asserted() was added.

Let's make it obvious that if a DP AUX controller implements
wait_hpd_asserted() that they don't need a loop waiting for HPD at the
start of their transfer() function. We'll still allow DP controllers
to work the old way but mark it as deprecated.

[1] 
https://lore.kernel.org/r/20240315143621.v2.3.I535606f6d4f7e3e5588bb75c55996f61980183cd@changeid

Signed-off-by: Douglas Anderson 
---
I would consider changing the docs to say that implementing
wait_hpd_asserted() is actually _required_ for any DP controllers that
want to support eDP panels parented on the DP AUX bus. The issue is
that one DP controller (tegra/dpaux.c, found by looking for those that
include display/drm_dp_aux_bus.h) does populate the DP AUX bus but
doesn't implement wait_hpd_asserted(). I'm actually not sure how/if
this work on tegra since I also don't see any delay loop for HPD in
tegra's transfer() callback. For now, I've left wait_hpd_asserted() as
optional and described the old/deprecated way things used to work
before wait_hpd_asserted().

   include/drm/display/drm_dp_helper.h | 8 +++-
   1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/include/drm/display/drm_dp_helper.h 
b/include/drm/display/drm_dp_helper.h
index a62fcd051d4d..b170efa1f5d2 100644
--- a/include/drm/display/drm_dp_helper.h
+++ b/include/drm/display/drm_dp_helper.h
@@ -422,7 +422,13 @@ struct drm_dp_aux {
   * @wait_hpd_asserted: wait for HPD to be asserted
   *
   * This is mainly useful for eDP panels drivers to wait for an eDP
-* panel to finish powering on. This is an optional function.
+* panel to finish powering on. It is optional for DP AUX controllers
+* to implement this function but required for DP AUX endpoints (panel
+* drivers) to call it after powering up but before doing AUX transfers.
+* If a DP AUX controller does not implement this function then it
+* may still support eDP panels that use the AUX controller's built-in
+* HPD signal by implementing a long wait for HPD in the transfer()
+* callback, though this is deprecated.


It doesn't cover a valid case when the panel driver handles HPD signal
on its own.



This doc is only for wait_for_hpd_asserted(). If panel driver handles
HPD signal on its own, this will not be called. Do we need a doc for that?


This comment declares that this callback must be called by the panel
driver: '...but required for DP AUX endpoints [...] to call it after
powering up but before doing AUX transfers.'

If we were to follow documentation changes from this patch, we'd have
to patch panel-edp to always call wait_for_hpd_asserted, even if HPD
GPIO is used. However this is not correct from my POV.



hmmm I dont mind explicitly saying "unless the panel can independently 
check the HPD state" but not required in my opinion because if panel was 
capable of checking the HPD gpio (its self-capable) why would it even 
call wait_for_hpd_asserted?


I will let you and Doug discuss this but fwiw, I am fine without this 
additional clarification. So the R-b stands with or without this 
additional clause.



   *
   * This function will efficiently wait for the HPD signal to be
   * asserted. The `wait_us` parameter that is passed in says that we
--
2.44.0.291.gc1ea87d7ee-goog










Re: [PATCH v3 3/5] drm/msm/dpu: handle perf mode in _dpu_core_perf_crtc_update_bus()

2024-03-19 Thread Abhinav Kumar




On 3/13/2024 6:10 PM, Dmitry Baryshkov wrote:

Move perf mode handling for the bandwidth to
_dpu_core_perf_crtc_update_bus() rather than overriding per-CRTC data
and then aggregating known values.

Note, this changes the fix_core_ab_vote. Previously it would be
multiplied per the CRTC number, now it will be used directly for
interconnect voting.

Signed-off-by: Dmitry Baryshkov 
---
  drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c | 39 +--
  1 file changed, 19 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c
index 87b892069526..ff2942a6a678 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c
@@ -118,21 +118,9 @@ static void _dpu_core_perf_calc_crtc(const struct 
dpu_core_perf *core_perf,
return;
}
  
-	memset(perf, 0, sizeof(struct dpu_core_perf_params));

-
-   if (core_perf->perf_tune.mode == DPU_PERF_MODE_MINIMUM) {
-   perf->bw_ctl = 0;
-   perf->max_per_pipe_ib = 0;
-   perf->core_clk_rate = 0;
-   } else if (core_perf->perf_tune.mode == DPU_PERF_MODE_FIXED) {
-   perf->bw_ctl = core_perf->fix_core_ab_vote;
-   perf->max_per_pipe_ib = core_perf->fix_core_ib_vote;
-   perf->core_clk_rate = core_perf->fix_core_clk_rate;
-   } else {
-   perf->bw_ctl = _dpu_core_perf_calc_bw(perf_cfg, crtc);
-   perf->max_per_pipe_ib = perf_cfg->min_dram_ib;
-   perf->core_clk_rate = _dpu_core_perf_calc_clk(perf_cfg, crtc, 
state);
-   }
+   perf->bw_ctl = _dpu_core_perf_calc_bw(perf_cfg, crtc);
+   perf->max_per_pipe_ib = perf_cfg->min_dram_ib;
+   perf->core_clk_rate = _dpu_core_perf_calc_clk(perf_cfg, crtc, state);
  
  	DRM_DEBUG_ATOMIC(

"crtc=%d clk_rate=%llu core_ib=%llu core_ab=%llu\n",
@@ -233,18 +221,29 @@ static int _dpu_core_perf_crtc_update_bus(struct dpu_kms 
*kms,
  {
struct dpu_core_perf_params perf = { 0 };
int i, ret = 0;
-   u64 avg_bw;
+   u32 avg_bw;
+   u32 peak_bw;
  
  	if (!kms->num_paths)

return 0;
  
-	dpu_core_perf_aggregate(crtc->dev, dpu_crtc_get_client_type(crtc), );

+   if (kms->perf.perf_tune.mode == DPU_PERF_MODE_MINIMUM) {
+   avg_bw = 0;
+   peak_bw = 0;
+   } else if (kms->perf.perf_tune.mode == DPU_PERF_MODE_FIXED) {
+   avg_bw = kms->perf.fix_core_ab_vote;
+   peak_bw = kms->perf.fix_core_ib_vote;
+   } else {
+   dpu_core_perf_aggregate(crtc->dev, dpu_crtc_get_client_type(crtc), 
);


Where is this function dpu_core_perf_aggregate() defined? I dont see it 
in msm-next



+
+   avg_bw = div_u64(perf.bw_ctl, 1000); /*Bps_to_icc*/
+   peak_bw = perf.max_per_pipe_ib;
+   }
  
-	avg_bw = perf.bw_ctl;

-   do_div(avg_bw, (kms->num_paths * 1000)); /*Bps_to_icc*/
+   avg_bw /= kms->num_paths;
  
  	for (i = 0; i < kms->num_paths; i++)

-   icc_set_bw(kms->path[i], avg_bw, perf.max_per_pipe_ib);
+   icc_set_bw(kms->path[i], avg_bw, peak_bw);
  
  	return ret;

  }



Re: [PATCH] drm/dp: Clarify that wait_hpd_asserted() is not optional for panels

2024-03-19 Thread Dmitry Baryshkov
On Tue, 19 Mar 2024 at 21:02, Abhinav Kumar  wrote:
>
>
>
> On 3/19/2024 11:35 AM, Dmitry Baryshkov wrote:
> > On Tue, 19 Mar 2024 at 20:15, Douglas Anderson  
> > wrote:
> >>
> >> In response to my patch removing the "wait for HPD" logic at the
> >> beginning of the MSM DP transfer() callback [1], we had some debate
> >> about what the "This is an optional function" meant in the
> >> documentation of the wait_hpd_asserted() callback. Let's clarify.
> >>
> >> As talked about in the MSM DP patch [1], before wait_hpd_asserted()
> >> was introduced there was no great way for panel drivers to wait for
> >> HPD in the case that the "built-in" HPD signal was used. Panel drivers
> >> could only wait for HPD if a GPIO was used. At the time, we ended up
> >> just saying that if we were using the "built-in" HPD signal that DP
> >> AUX controllers needed to wait for HPD themselves at the beginning of
> >> their transfer() callback. The fact that the wait for HPD at the
> >> beginning of transfer() was awkward/problematic was the whole reason
> >> wait_hpd_asserted() was added.
> >>
> >> Let's make it obvious that if a DP AUX controller implements
> >> wait_hpd_asserted() that they don't need a loop waiting for HPD at the
> >> start of their transfer() function. We'll still allow DP controllers
> >> to work the old way but mark it as deprecated.
> >>
> >> [1] 
> >> https://lore.kernel.org/r/20240315143621.v2.3.I535606f6d4f7e3e5588bb75c55996f61980183cd@changeid
> >>
> >> Signed-off-by: Douglas Anderson 
> >> ---
> >> I would consider changing the docs to say that implementing
> >> wait_hpd_asserted() is actually _required_ for any DP controllers that
> >> want to support eDP panels parented on the DP AUX bus. The issue is
> >> that one DP controller (tegra/dpaux.c, found by looking for those that
> >> include display/drm_dp_aux_bus.h) does populate the DP AUX bus but
> >> doesn't implement wait_hpd_asserted(). I'm actually not sure how/if
> >> this work on tegra since I also don't see any delay loop for HPD in
> >> tegra's transfer() callback. For now, I've left wait_hpd_asserted() as
> >> optional and described the old/deprecated way things used to work
> >> before wait_hpd_asserted().
> >>
> >>   include/drm/display/drm_dp_helper.h | 8 +++-
> >>   1 file changed, 7 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/include/drm/display/drm_dp_helper.h 
> >> b/include/drm/display/drm_dp_helper.h
> >> index a62fcd051d4d..b170efa1f5d2 100644
> >> --- a/include/drm/display/drm_dp_helper.h
> >> +++ b/include/drm/display/drm_dp_helper.h
> >> @@ -422,7 +422,13 @@ struct drm_dp_aux {
> >>   * @wait_hpd_asserted: wait for HPD to be asserted
> >>   *
> >>   * This is mainly useful for eDP panels drivers to wait for an eDP
> >> -* panel to finish powering on. This is an optional function.
> >> +* panel to finish powering on. It is optional for DP AUX 
> >> controllers
> >> +* to implement this function but required for DP AUX endpoints 
> >> (panel
> >> +* drivers) to call it after powering up but before doing AUX 
> >> transfers.
> >> +* If a DP AUX controller does not implement this function then it
> >> +* may still support eDP panels that use the AUX controller's 
> >> built-in
> >> +* HPD signal by implementing a long wait for HPD in the transfer()
> >> +* callback, though this is deprecated.
> >
> > It doesn't cover a valid case when the panel driver handles HPD signal
> > on its own.
> >
>
> This doc is only for wait_for_hpd_asserted(). If panel driver handles
> HPD signal on its own, this will not be called. Do we need a doc for that?

This comment declares that this callback must be called by the panel
driver: '...but required for DP AUX endpoints [...] to call it after
powering up but before doing AUX transfers.'

If we were to follow documentation changes from this patch, we'd have
to patch panel-edp to always call wait_for_hpd_asserted, even if HPD
GPIO is used. However this is not correct from my POV.

> >>   *
> >>   * This function will efficiently wait for the HPD signal to be
> >>   * asserted. The `wait_us` parameter that is passed in says that 
> >> we
> >> --
> >> 2.44.0.291.gc1ea87d7ee-goog
> >>
> >
> >



-- 
With best wishes
Dmitry


Re: [PATCH v3 2/5] drm/msm/dpu: core_perf: extract bandwidth aggregation function

2024-03-19 Thread Abhinav Kumar




On 3/13/2024 6:10 PM, Dmitry Baryshkov wrote:

In preparation to refactoring the dpu_core_perf debugfs interface,
extract the bandwidth aggregation function from
_dpu_core_perf_crtc_update_bus().

Signed-off-by: Dmitry Baryshkov 
---
  drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c | 45 +++
  1 file changed, 25 insertions(+), 20 deletions(-)



no need of core_perf : in the subject line.


diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c
index 68fae048a9a8..87b892069526 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c
@@ -204,36 +204,41 @@ int dpu_core_perf_crtc_check(struct drm_crtc *crtc,
return 0;
  }
  
-static int _dpu_core_perf_crtc_update_bus(struct dpu_kms *kms,

-   struct drm_crtc *crtc)
+static void dpu_core_perf_aggregate(struct drm_device *ddev,
+   enum dpu_crtc_client_type curr_client_type,
+   struct dpu_core_perf_params *perf)
  {
-   struct dpu_core_perf_params perf = { 0 };
-   enum dpu_crtc_client_type curr_client_type
-   = dpu_crtc_get_client_type(crtc);
-   struct drm_crtc *tmp_crtc;
struct dpu_crtc_state *dpu_cstate;
-   int i, ret = 0;
-   u64 avg_bw;
-
-   if (!kms->num_paths)
-   return 0;
+   struct drm_crtc *tmp_crtc;
  
-	drm_for_each_crtc(tmp_crtc, crtc->dev) {

+   drm_for_each_crtc(tmp_crtc, ddev) {
if (tmp_crtc->enabled &&
-   curr_client_type ==
-   dpu_crtc_get_client_type(tmp_crtc)) {
+   curr_client_type == dpu_crtc_get_client_type(tmp_crtc)) {
dpu_cstate = to_dpu_crtc_state(tmp_crtc->state);
  
-			perf.max_per_pipe_ib = max(perf.max_per_pipe_ib,

-   dpu_cstate->new_perf.max_per_pipe_ib);
+   perf->max_per_pipe_ib = max(perf->max_per_pipe_ib,
+   
dpu_cstate->new_perf.max_per_pipe_ib);
  
-			perf.bw_ctl += dpu_cstate->new_perf.bw_ctl;

+   perf->bw_ctl += dpu_cstate->new_perf.bw_ctl;
  
-			DRM_DEBUG_ATOMIC("crtc=%d bw=%llu paths:%d\n",

- tmp_crtc->base.id,
- dpu_cstate->new_perf.bw_ctl, kms->num_paths);
+   DRM_DEBUG_ATOMIC("crtc=%d bw=%llu\n",
+tmp_crtc->base.id,
+dpu_cstate->new_perf.bw_ctl);
}
}
+}
+
+static int _dpu_core_perf_crtc_update_bus(struct dpu_kms *kms,
+   struct drm_crtc *crtc)
+{


since you have fixed some of the formatting inside the function, do you 
also want to align struct drm_crtc *crtc with the opening braces?


With that fixed,

Reviewed-by: Abhinav Kumar 



+   struct dpu_core_perf_params perf = { 0 };
+   int i, ret = 0;
+   u64 avg_bw;
+
+   if (!kms->num_paths)
+   return 0;
+
+   dpu_core_perf_aggregate(crtc->dev, dpu_crtc_get_client_type(crtc), 
);
  
  	avg_bw = perf.bw_ctl;

do_div(avg_bw, (kms->num_paths * 1000)); /*Bps_to_icc*/



Re: [PATCH] drm/tilcdc: Set preferred depth

2024-03-19 Thread Frej Drejhammar
Hi, Jyri

sa...@kapsi.fi writes:

> So the trouble here is the 16bpp and 24/32bpp color wiring being
> crossed, right? I'd just like to remind that there is another option
> to overcome the issue by editing device tree files. The current
> configuration from some 8 years back supports RG16, BG24, and XB24
> formats, but on Beaglebone-Black its possible - thanks to tda998x -
> change the support to BG16, RG24, and XR24, by changing these lines
> before building a new dtb-file:

I don't think that will solve the problem. The unmodified
drm_driver_legacy_fb_format() gives RG16 if it is asked for a 16 bit
depth (and the corresponding bpp in the way that the X server does) and
RG24 if asked for 24 bits. So swapping the bits around will always break
one of the hardware-supported depths unless you can cross/uncross the
wires dynamically when setting the frame buffer.

Best regards,

--Frej


Re: [PATCH] drm/dp: Clarify that wait_hpd_asserted() is not optional for panels

2024-03-19 Thread Abhinav Kumar




On 3/19/2024 11:35 AM, Dmitry Baryshkov wrote:

On Tue, 19 Mar 2024 at 20:15, Douglas Anderson  wrote:


In response to my patch removing the "wait for HPD" logic at the
beginning of the MSM DP transfer() callback [1], we had some debate
about what the "This is an optional function" meant in the
documentation of the wait_hpd_asserted() callback. Let's clarify.

As talked about in the MSM DP patch [1], before wait_hpd_asserted()
was introduced there was no great way for panel drivers to wait for
HPD in the case that the "built-in" HPD signal was used. Panel drivers
could only wait for HPD if a GPIO was used. At the time, we ended up
just saying that if we were using the "built-in" HPD signal that DP
AUX controllers needed to wait for HPD themselves at the beginning of
their transfer() callback. The fact that the wait for HPD at the
beginning of transfer() was awkward/problematic was the whole reason
wait_hpd_asserted() was added.

Let's make it obvious that if a DP AUX controller implements
wait_hpd_asserted() that they don't need a loop waiting for HPD at the
start of their transfer() function. We'll still allow DP controllers
to work the old way but mark it as deprecated.

[1] 
https://lore.kernel.org/r/20240315143621.v2.3.I535606f6d4f7e3e5588bb75c55996f61980183cd@changeid

Signed-off-by: Douglas Anderson 
---
I would consider changing the docs to say that implementing
wait_hpd_asserted() is actually _required_ for any DP controllers that
want to support eDP panels parented on the DP AUX bus. The issue is
that one DP controller (tegra/dpaux.c, found by looking for those that
include display/drm_dp_aux_bus.h) does populate the DP AUX bus but
doesn't implement wait_hpd_asserted(). I'm actually not sure how/if
this work on tegra since I also don't see any delay loop for HPD in
tegra's transfer() callback. For now, I've left wait_hpd_asserted() as
optional and described the old/deprecated way things used to work
before wait_hpd_asserted().

  include/drm/display/drm_dp_helper.h | 8 +++-
  1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/include/drm/display/drm_dp_helper.h 
b/include/drm/display/drm_dp_helper.h
index a62fcd051d4d..b170efa1f5d2 100644
--- a/include/drm/display/drm_dp_helper.h
+++ b/include/drm/display/drm_dp_helper.h
@@ -422,7 +422,13 @@ struct drm_dp_aux {
  * @wait_hpd_asserted: wait for HPD to be asserted
  *
  * This is mainly useful for eDP panels drivers to wait for an eDP
-* panel to finish powering on. This is an optional function.
+* panel to finish powering on. It is optional for DP AUX controllers
+* to implement this function but required for DP AUX endpoints (panel
+* drivers) to call it after powering up but before doing AUX transfers.
+* If a DP AUX controller does not implement this function then it
+* may still support eDP panels that use the AUX controller's built-in
+* HPD signal by implementing a long wait for HPD in the transfer()
+* callback, though this is deprecated.


It doesn't cover a valid case when the panel driver handles HPD signal
on its own.



This doc is only for wait_for_hpd_asserted(). If panel driver handles 
HPD signal on its own, this will not be called. Do we need a doc for that?



  *
  * This function will efficiently wait for the HPD signal to be
  * asserted. The `wait_us` parameter that is passed in says that we
--
2.44.0.291.gc1ea87d7ee-goog






Re: [PATCH] drm/dp: Clarify that wait_hpd_asserted() is not optional for panels

2024-03-19 Thread Dmitry Baryshkov
On Tue, 19 Mar 2024 at 20:15, Douglas Anderson  wrote:
>
> In response to my patch removing the "wait for HPD" logic at the
> beginning of the MSM DP transfer() callback [1], we had some debate
> about what the "This is an optional function" meant in the
> documentation of the wait_hpd_asserted() callback. Let's clarify.
>
> As talked about in the MSM DP patch [1], before wait_hpd_asserted()
> was introduced there was no great way for panel drivers to wait for
> HPD in the case that the "built-in" HPD signal was used. Panel drivers
> could only wait for HPD if a GPIO was used. At the time, we ended up
> just saying that if we were using the "built-in" HPD signal that DP
> AUX controllers needed to wait for HPD themselves at the beginning of
> their transfer() callback. The fact that the wait for HPD at the
> beginning of transfer() was awkward/problematic was the whole reason
> wait_hpd_asserted() was added.
>
> Let's make it obvious that if a DP AUX controller implements
> wait_hpd_asserted() that they don't need a loop waiting for HPD at the
> start of their transfer() function. We'll still allow DP controllers
> to work the old way but mark it as deprecated.
>
> [1] 
> https://lore.kernel.org/r/20240315143621.v2.3.I535606f6d4f7e3e5588bb75c55996f61980183cd@changeid
>
> Signed-off-by: Douglas Anderson 
> ---
> I would consider changing the docs to say that implementing
> wait_hpd_asserted() is actually _required_ for any DP controllers that
> want to support eDP panels parented on the DP AUX bus. The issue is
> that one DP controller (tegra/dpaux.c, found by looking for those that
> include display/drm_dp_aux_bus.h) does populate the DP AUX bus but
> doesn't implement wait_hpd_asserted(). I'm actually not sure how/if
> this work on tegra since I also don't see any delay loop for HPD in
> tegra's transfer() callback. For now, I've left wait_hpd_asserted() as
> optional and described the old/deprecated way things used to work
> before wait_hpd_asserted().
>
>  include/drm/display/drm_dp_helper.h | 8 +++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/include/drm/display/drm_dp_helper.h 
> b/include/drm/display/drm_dp_helper.h
> index a62fcd051d4d..b170efa1f5d2 100644
> --- a/include/drm/display/drm_dp_helper.h
> +++ b/include/drm/display/drm_dp_helper.h
> @@ -422,7 +422,13 @@ struct drm_dp_aux {
>  * @wait_hpd_asserted: wait for HPD to be asserted
>  *
>  * This is mainly useful for eDP panels drivers to wait for an eDP
> -* panel to finish powering on. This is an optional function.
> +* panel to finish powering on. It is optional for DP AUX controllers
> +* to implement this function but required for DP AUX endpoints (panel
> +* drivers) to call it after powering up but before doing AUX 
> transfers.
> +* If a DP AUX controller does not implement this function then it
> +* may still support eDP panels that use the AUX controller's built-in
> +* HPD signal by implementing a long wait for HPD in the transfer()
> +* callback, though this is deprecated.

It doesn't cover a valid case when the panel driver handles HPD signal
on its own.

>  *
>  * This function will efficiently wait for the HPD signal to be
>  * asserted. The `wait_us` parameter that is passed in says that we
> --
> 2.44.0.291.gc1ea87d7ee-goog
>


-- 
With best wishes
Dmitry


Re: [PATCH v3 1/5] drm/msm/dpu: don't allow overriding data from catalog

2024-03-19 Thread Abhinav Kumar




On 3/13/2024 6:10 PM, Dmitry Baryshkov wrote:

The data from catalog is marked as const, so it is a part of the RO
segment. Allowing userspace to write to it through debugfs can cause
protection faults. Set debugfs file mode to read-only for debug entries
corresponding to perf_cfg coming from catalog.

Fixes: abda0d925f9c ("drm/msm/dpu: Mark various data tables as const")
Signed-off-by: Dmitry Baryshkov 
---
  drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c | 10 +-
  1 file changed, 5 insertions(+), 5 deletions(-)



Thanks for the fix,

Reviewed-by: Abhinav Kumar 



Re: [PATCH v2 3/4] drm/msm/dp: Delete the old 500 ms wait for eDP HPD in aux transfer

2024-03-19 Thread Abhinav Kumar




On 3/19/2024 11:15 AM, Doug Anderson wrote:

Hi,

On Tue, Mar 19, 2024 at 10:27 AM Dmitry Baryshkov
 wrote:


On Tue, 19 Mar 2024 at 19:13, Abhinav Kumar  wrote:




On 3/18/2024 5:55 PM, Dmitry Baryshkov wrote:

On Tue, 19 Mar 2024 at 02:19, Abhinav Kumar  wrote:


+bjorn, johan as fyi for sc8280xp

On 3/15/2024 2:36 PM, Douglas Anderson wrote:

Before the introduction of the wait_hpd_asserted() callback in commit
841d742f094e ("drm/dp: Add wait_hpd_asserted() callback to struct
drm_dp_aux") the API between panel drivers and DP AUX bus drivers was
that it was up to the AUX bus driver to wait for HPD in the transfer()
function.

Now wait_hpd_asserted() has been added. The two panel drivers that are
DP AUX endpoints use it. See commit 2327b13d6c47 ("drm/panel-edp: Take
advantage of wait_hpd_asserted() in struct drm_dp_aux") and commit
3b5765df375c ("drm/panel: atna33xc20: Take advantage of
wait_hpd_asserted() in struct drm_dp_aux"). We've implemented
wait_hpd_asserted() in the MSM DP driver as of commit e2969ee30252
("drm/msm/dp: move of_dp_aux_populate_bus() to eDP probe()"). There is
no longer any reason for long wait in the AUX transfer() function.
Remove it.

NOTE: the wait_hpd_asserted() is listed as "optional". That means it's
optional for the DP AUX bus to implement. In the case of the MSM DP
driver we implement it so we can assume it will be called.



How do we enforce that for any new edp panels to be used with MSM, the
panels should atleast invoke wait_hpd_asserted()?

I agree that since MSM implements it, even though its listed as
optional, we can drop this additional wait. So nothing wrong with this
patch for current users including sc8280xp, sc7280 and sc7180.

But, does there need to be some documentation that the edp panels not
using the panel-edp framework should still invoke wait_hpd_asserted()?

Since its marked as optional, what happens if the edp panel driver,
skips calling wait_hpd_asserted()?


It is optional for the DP AUX implementations, not for the panel to be called.



Yes, I understood that part, but is there anything from the panel side
which mandates calling wait_hpd_asserted()?

Is this documented somewhere for all edp panels to do:

if (aux->wait_hpd_asserted)
 aux->wait_hpd_asserted(aux, wait_us);


That's obviously not true, e.g. if panel-edp.c handled HPD signal via
the GPIO pin.

But the documentation explicitly says that the host will be powered up
automatically, but the caller must ensure that the panel is powered
on. `It's up to the caller of this code to make sure that the panel is
powered on if getting an error back is not OK.'


It wouldn't hurt to send out a documentation patch that makes this
more explicit. OK, I sent:

https://lore.kernel.org/r/20240319111432.1.I521dad0693cc24fe4dd14cba0c7048d94f5b6b41@changeid

-Doug


Thanks, with that in place, this is

Reviewed-by: Abhinav Kumar 


Re: [PATCH] drm/dp: Clarify that wait_hpd_asserted() is not optional for panels

2024-03-19 Thread Abhinav Kumar




On 3/19/2024 11:14 AM, Douglas Anderson wrote:

In response to my patch removing the "wait for HPD" logic at the
beginning of the MSM DP transfer() callback [1], we had some debate
about what the "This is an optional function" meant in the
documentation of the wait_hpd_asserted() callback. Let's clarify.

As talked about in the MSM DP patch [1], before wait_hpd_asserted()
was introduced there was no great way for panel drivers to wait for
HPD in the case that the "built-in" HPD signal was used. Panel drivers
could only wait for HPD if a GPIO was used. At the time, we ended up
just saying that if we were using the "built-in" HPD signal that DP
AUX controllers needed to wait for HPD themselves at the beginning of
their transfer() callback. The fact that the wait for HPD at the
beginning of transfer() was awkward/problematic was the whole reason
wait_hpd_asserted() was added.

Let's make it obvious that if a DP AUX controller implements
wait_hpd_asserted() that they don't need a loop waiting for HPD at the
start of their transfer() function. We'll still allow DP controllers
to work the old way but mark it as deprecated.

[1] 
https://lore.kernel.org/r/20240315143621.v2.3.I535606f6d4f7e3e5588bb75c55996f61980183cd@changeid

Signed-off-by: Douglas Anderson 
---
I would consider changing the docs to say that implementing
wait_hpd_asserted() is actually _required_ for any DP controllers that
want to support eDP panels parented on the DP AUX bus. The issue is
that one DP controller (tegra/dpaux.c, found by looking for those that
include display/drm_dp_aux_bus.h) does populate the DP AUX bus but
doesn't implement wait_hpd_asserted(). I'm actually not sure how/if
this work on tegra since I also don't see any delay loop for HPD in
tegra's transfer() callback. For now, I've left wait_hpd_asserted() as
optional and described the old/deprecated way things used to work
before wait_hpd_asserted().

  include/drm/display/drm_dp_helper.h | 8 +++-
  1 file changed, 7 insertions(+), 1 deletion(-)



Thanks for the change,

Reviewed-by: Abhinav Kumar 


Re: [PATCH v2 3/4] drm/msm/dp: Delete the old 500 ms wait for eDP HPD in aux transfer

2024-03-19 Thread Doug Anderson
Hi,

On Tue, Mar 19, 2024 at 10:27 AM Dmitry Baryshkov
 wrote:
>
> On Tue, 19 Mar 2024 at 19:13, Abhinav Kumar  wrote:
> >
> >
> >
> > On 3/18/2024 5:55 PM, Dmitry Baryshkov wrote:
> > > On Tue, 19 Mar 2024 at 02:19, Abhinav Kumar  
> > > wrote:
> > >>
> > >> +bjorn, johan as fyi for sc8280xp
> > >>
> > >> On 3/15/2024 2:36 PM, Douglas Anderson wrote:
> > >>> Before the introduction of the wait_hpd_asserted() callback in commit
> > >>> 841d742f094e ("drm/dp: Add wait_hpd_asserted() callback to struct
> > >>> drm_dp_aux") the API between panel drivers and DP AUX bus drivers was
> > >>> that it was up to the AUX bus driver to wait for HPD in the transfer()
> > >>> function.
> > >>>
> > >>> Now wait_hpd_asserted() has been added. The two panel drivers that are
> > >>> DP AUX endpoints use it. See commit 2327b13d6c47 ("drm/panel-edp: Take
> > >>> advantage of wait_hpd_asserted() in struct drm_dp_aux") and commit
> > >>> 3b5765df375c ("drm/panel: atna33xc20: Take advantage of
> > >>> wait_hpd_asserted() in struct drm_dp_aux"). We've implemented
> > >>> wait_hpd_asserted() in the MSM DP driver as of commit e2969ee30252
> > >>> ("drm/msm/dp: move of_dp_aux_populate_bus() to eDP probe()"). There is
> > >>> no longer any reason for long wait in the AUX transfer() function.
> > >>> Remove it.
> > >>>
> > >>> NOTE: the wait_hpd_asserted() is listed as "optional". That means it's
> > >>> optional for the DP AUX bus to implement. In the case of the MSM DP
> > >>> driver we implement it so we can assume it will be called.
> > >>>
> > >>
> > >> How do we enforce that for any new edp panels to be used with MSM, the
> > >> panels should atleast invoke wait_hpd_asserted()?
> > >>
> > >> I agree that since MSM implements it, even though its listed as
> > >> optional, we can drop this additional wait. So nothing wrong with this
> > >> patch for current users including sc8280xp, sc7280 and sc7180.
> > >>
> > >> But, does there need to be some documentation that the edp panels not
> > >> using the panel-edp framework should still invoke wait_hpd_asserted()?
> > >>
> > >> Since its marked as optional, what happens if the edp panel driver,
> > >> skips calling wait_hpd_asserted()?
> > >
> > > It is optional for the DP AUX implementations, not for the panel to be 
> > > called.
> > >
> >
> > Yes, I understood that part, but is there anything from the panel side
> > which mandates calling wait_hpd_asserted()?
> >
> > Is this documented somewhere for all edp panels to do:
> >
> > if (aux->wait_hpd_asserted)
> > aux->wait_hpd_asserted(aux, wait_us);
>
> That's obviously not true, e.g. if panel-edp.c handled HPD signal via
> the GPIO pin.
>
> But the documentation explicitly says that the host will be powered up
> automatically, but the caller must ensure that the panel is powered
> on. `It's up to the caller of this code to make sure that the panel is
> powered on if getting an error back is not OK.'

It wouldn't hurt to send out a documentation patch that makes this
more explicit. OK, I sent:

https://lore.kernel.org/r/20240319111432.1.I521dad0693cc24fe4dd14cba0c7048d94f5b6b41@changeid

-Doug


[PATCH] drm/dp: Clarify that wait_hpd_asserted() is not optional for panels

2024-03-19 Thread Douglas Anderson
In response to my patch removing the "wait for HPD" logic at the
beginning of the MSM DP transfer() callback [1], we had some debate
about what the "This is an optional function" meant in the
documentation of the wait_hpd_asserted() callback. Let's clarify.

As talked about in the MSM DP patch [1], before wait_hpd_asserted()
was introduced there was no great way for panel drivers to wait for
HPD in the case that the "built-in" HPD signal was used. Panel drivers
could only wait for HPD if a GPIO was used. At the time, we ended up
just saying that if we were using the "built-in" HPD signal that DP
AUX controllers needed to wait for HPD themselves at the beginning of
their transfer() callback. The fact that the wait for HPD at the
beginning of transfer() was awkward/problematic was the whole reason
wait_hpd_asserted() was added.

Let's make it obvious that if a DP AUX controller implements
wait_hpd_asserted() that they don't need a loop waiting for HPD at the
start of their transfer() function. We'll still allow DP controllers
to work the old way but mark it as deprecated.

[1] 
https://lore.kernel.org/r/20240315143621.v2.3.I535606f6d4f7e3e5588bb75c55996f61980183cd@changeid

Signed-off-by: Douglas Anderson 
---
I would consider changing the docs to say that implementing
wait_hpd_asserted() is actually _required_ for any DP controllers that
want to support eDP panels parented on the DP AUX bus. The issue is
that one DP controller (tegra/dpaux.c, found by looking for those that
include display/drm_dp_aux_bus.h) does populate the DP AUX bus but
doesn't implement wait_hpd_asserted(). I'm actually not sure how/if
this work on tegra since I also don't see any delay loop for HPD in
tegra's transfer() callback. For now, I've left wait_hpd_asserted() as
optional and described the old/deprecated way things used to work
before wait_hpd_asserted().

 include/drm/display/drm_dp_helper.h | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/include/drm/display/drm_dp_helper.h 
b/include/drm/display/drm_dp_helper.h
index a62fcd051d4d..b170efa1f5d2 100644
--- a/include/drm/display/drm_dp_helper.h
+++ b/include/drm/display/drm_dp_helper.h
@@ -422,7 +422,13 @@ struct drm_dp_aux {
 * @wait_hpd_asserted: wait for HPD to be asserted
 *
 * This is mainly useful for eDP panels drivers to wait for an eDP
-* panel to finish powering on. This is an optional function.
+* panel to finish powering on. It is optional for DP AUX controllers
+* to implement this function but required for DP AUX endpoints (panel
+* drivers) to call it after powering up but before doing AUX transfers.
+* If a DP AUX controller does not implement this function then it
+* may still support eDP panels that use the AUX controller's built-in
+* HPD signal by implementing a long wait for HPD in the transfer()
+* callback, though this is deprecated.
 *
 * This function will efficiently wait for the HPD signal to be
 * asserted. The `wait_us` parameter that is passed in says that we
-- 
2.44.0.291.gc1ea87d7ee-goog



Re: [PATCH] nouveau/gsp: don't check devinit disable on GSP.

2024-03-19 Thread Danilo Krummrich

On 3/19/24 18:38, Timothy Maden wrote:

Hello

Can this be merged please ?


Applied this to drm-misc-next-fixes a couple of hours ago.

- Danilo



On 3/14/24 03:45, Dave Airlie wrote:

From: Dave Airlie 

GSP should be handling this and I can see no evidence in opengpu
driver that this register should be touched.

Fixed acceleration on 2080 Ti GPUs.

Fixes: 15740541e8f0 ("drm/nouveau/devinit/tu102-: prepare for GSP-RM")

Signed-off-by: Dave Airlie 
---
  drivers/gpu/drm/nouveau/nvkm/subdev/devinit/r535.c | 1 -
  1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/r535.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/r535.c
index 666eb93b1742..11b4c9c274a1 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/r535.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/r535.c
@@ -41,7 +41,6 @@ r535_devinit_new(const struct nvkm_devinit_func *hw,
  rm->dtor = r535_devinit_dtor;
  rm->post = hw->post;
-    rm->disable = hw->disable;
  ret = nv50_devinit_new_(rm, device, type, inst, pdevinit);
  if (ret)





Re: [PATCH v2 3/4] drm/msm/dp: Delete the old 500 ms wait for eDP HPD in aux transfer

2024-03-19 Thread Dmitry Baryshkov
On Tue, 19 Mar 2024 at 19:13, Abhinav Kumar  wrote:
>
>
>
> On 3/18/2024 5:55 PM, Dmitry Baryshkov wrote:
> > On Tue, 19 Mar 2024 at 02:19, Abhinav Kumar  
> > wrote:
> >>
> >> +bjorn, johan as fyi for sc8280xp
> >>
> >> On 3/15/2024 2:36 PM, Douglas Anderson wrote:
> >>> Before the introduction of the wait_hpd_asserted() callback in commit
> >>> 841d742f094e ("drm/dp: Add wait_hpd_asserted() callback to struct
> >>> drm_dp_aux") the API between panel drivers and DP AUX bus drivers was
> >>> that it was up to the AUX bus driver to wait for HPD in the transfer()
> >>> function.
> >>>
> >>> Now wait_hpd_asserted() has been added. The two panel drivers that are
> >>> DP AUX endpoints use it. See commit 2327b13d6c47 ("drm/panel-edp: Take
> >>> advantage of wait_hpd_asserted() in struct drm_dp_aux") and commit
> >>> 3b5765df375c ("drm/panel: atna33xc20: Take advantage of
> >>> wait_hpd_asserted() in struct drm_dp_aux"). We've implemented
> >>> wait_hpd_asserted() in the MSM DP driver as of commit e2969ee30252
> >>> ("drm/msm/dp: move of_dp_aux_populate_bus() to eDP probe()"). There is
> >>> no longer any reason for long wait in the AUX transfer() function.
> >>> Remove it.
> >>>
> >>> NOTE: the wait_hpd_asserted() is listed as "optional". That means it's
> >>> optional for the DP AUX bus to implement. In the case of the MSM DP
> >>> driver we implement it so we can assume it will be called.
> >>>
> >>
> >> How do we enforce that for any new edp panels to be used with MSM, the
> >> panels should atleast invoke wait_hpd_asserted()?
> >>
> >> I agree that since MSM implements it, even though its listed as
> >> optional, we can drop this additional wait. So nothing wrong with this
> >> patch for current users including sc8280xp, sc7280 and sc7180.
> >>
> >> But, does there need to be some documentation that the edp panels not
> >> using the panel-edp framework should still invoke wait_hpd_asserted()?
> >>
> >> Since its marked as optional, what happens if the edp panel driver,
> >> skips calling wait_hpd_asserted()?
> >
> > It is optional for the DP AUX implementations, not for the panel to be 
> > called.
> >
>
> Yes, I understood that part, but is there anything from the panel side
> which mandates calling wait_hpd_asserted()?
>
> Is this documented somewhere for all edp panels to do:
>
> if (aux->wait_hpd_asserted)
> aux->wait_hpd_asserted(aux, wait_us);

That's obviously not true, e.g. if panel-edp.c handled HPD signal via
the GPIO pin.

But the documentation explicitly says that the host will be powered up
automatically, but the caller must ensure that the panel is powered
on. `It's up to the caller of this code to make sure that the panel is
powered on if getting an error back is not OK.'

>
> >>
> >> Now, since the wait from MSM is removed, it has a potential to fail.
> >>
> >>> ALSO NOTE: the wait wasn't actually _hurting_ anything and wasn't even
> >>> causing long timeouts, but it's still nice to get rid of unneeded
> >>> code. Specificaly it's not truly needed because to handle other DP
> >>> drivers that can't power on as quickly (specifically parade-ps8640) we
> >>> already avoid DP AUX transfers for eDP panels that aren't powered
> >>> on. See commit 8df1ddb5bf11 ("drm/dp: Don't attempt AUX transfers when
> >>> eDP panels are not powered").
> >>>
> >>> Signed-off-by: Douglas Anderson 
> >>> ---
> >>>
> >>> (no changes since v1)
> >>>
> >>>drivers/gpu/drm/msm/dp/dp_aux.c | 17 -
> >>>1 file changed, 17 deletions(-)
> >>>
> >>> diff --git a/drivers/gpu/drm/msm/dp/dp_aux.c 
> >>> b/drivers/gpu/drm/msm/dp/dp_aux.c
> >>> index 75c51f3ee106..ecefd1922d6d 100644
> >>> --- a/drivers/gpu/drm/msm/dp/dp_aux.c
> >>> +++ b/drivers/gpu/drm/msm/dp/dp_aux.c
> >>> @@ -313,23 +313,6 @@ static ssize_t dp_aux_transfer(struct drm_dp_aux 
> >>> *dp_aux,
> >>>goto exit;
> >>>}
> >>>
> >>> - /*
> >>> -  * For eDP it's important to give a reasonably long wait here for 
> >>> HPD
> >>> -  * to be asserted. This is because the panel driver may have _just_
> >>> -  * turned on the panel and then tried to do an AUX transfer. The 
> >>> panel
> >>> -  * driver has no way of knowing when the panel is ready, so it's up
> >>> -  * to us to wait. For DP we never get into this situation so let's
> >>> -  * avoid ever doing the extra long wait for DP.
> >>> -  */
> >>> - if (aux->is_edp) {
> >>> - ret = 
> >>> dp_catalog_aux_wait_for_hpd_connect_state(aux->catalog,
> >>> - 50);
> >>> - if (ret) {
> >>> - DRM_DEBUG_DP("Panel not ready for aux 
> >>> transactions\n");
> >>> - goto exit;
> >>> - }
> >>> - }
> >>> -
> >>>dp_aux_update_offset_and_segment(aux, msg);
> >>>dp_aux_transfer_helper(aux, msg, true);
> >>>
> >
> >
> >



-- 
With best wishes
Dmitry


Re: [PATCH v2 3/4] drm/msm/dp: Delete the old 500 ms wait for eDP HPD in aux transfer

2024-03-19 Thread Abhinav Kumar




On 3/18/2024 5:55 PM, Dmitry Baryshkov wrote:

On Tue, 19 Mar 2024 at 02:19, Abhinav Kumar  wrote:


+bjorn, johan as fyi for sc8280xp

On 3/15/2024 2:36 PM, Douglas Anderson wrote:

Before the introduction of the wait_hpd_asserted() callback in commit
841d742f094e ("drm/dp: Add wait_hpd_asserted() callback to struct
drm_dp_aux") the API between panel drivers and DP AUX bus drivers was
that it was up to the AUX bus driver to wait for HPD in the transfer()
function.

Now wait_hpd_asserted() has been added. The two panel drivers that are
DP AUX endpoints use it. See commit 2327b13d6c47 ("drm/panel-edp: Take
advantage of wait_hpd_asserted() in struct drm_dp_aux") and commit
3b5765df375c ("drm/panel: atna33xc20: Take advantage of
wait_hpd_asserted() in struct drm_dp_aux"). We've implemented
wait_hpd_asserted() in the MSM DP driver as of commit e2969ee30252
("drm/msm/dp: move of_dp_aux_populate_bus() to eDP probe()"). There is
no longer any reason for long wait in the AUX transfer() function.
Remove it.

NOTE: the wait_hpd_asserted() is listed as "optional". That means it's
optional for the DP AUX bus to implement. In the case of the MSM DP
driver we implement it so we can assume it will be called.



How do we enforce that for any new edp panels to be used with MSM, the
panels should atleast invoke wait_hpd_asserted()?

I agree that since MSM implements it, even though its listed as
optional, we can drop this additional wait. So nothing wrong with this
patch for current users including sc8280xp, sc7280 and sc7180.

But, does there need to be some documentation that the edp panels not
using the panel-edp framework should still invoke wait_hpd_asserted()?

Since its marked as optional, what happens if the edp panel driver,
skips calling wait_hpd_asserted()?


It is optional for the DP AUX implementations, not for the panel to be called.



Yes, I understood that part, but is there anything from the panel side 
which mandates calling wait_hpd_asserted()?


Is this documented somewhere for all edp panels to do:

if (aux->wait_hpd_asserted)
aux->wait_hpd_asserted(aux, wait_us);



Now, since the wait from MSM is removed, it has a potential to fail.


ALSO NOTE: the wait wasn't actually _hurting_ anything and wasn't even
causing long timeouts, but it's still nice to get rid of unneeded
code. Specificaly it's not truly needed because to handle other DP
drivers that can't power on as quickly (specifically parade-ps8640) we
already avoid DP AUX transfers for eDP panels that aren't powered
on. See commit 8df1ddb5bf11 ("drm/dp: Don't attempt AUX transfers when
eDP panels are not powered").

Signed-off-by: Douglas Anderson 
---

(no changes since v1)

   drivers/gpu/drm/msm/dp/dp_aux.c | 17 -
   1 file changed, 17 deletions(-)

diff --git a/drivers/gpu/drm/msm/dp/dp_aux.c b/drivers/gpu/drm/msm/dp/dp_aux.c
index 75c51f3ee106..ecefd1922d6d 100644
--- a/drivers/gpu/drm/msm/dp/dp_aux.c
+++ b/drivers/gpu/drm/msm/dp/dp_aux.c
@@ -313,23 +313,6 @@ static ssize_t dp_aux_transfer(struct drm_dp_aux *dp_aux,
   goto exit;
   }

- /*
-  * For eDP it's important to give a reasonably long wait here for HPD
-  * to be asserted. This is because the panel driver may have _just_
-  * turned on the panel and then tried to do an AUX transfer. The panel
-  * driver has no way of knowing when the panel is ready, so it's up
-  * to us to wait. For DP we never get into this situation so let's
-  * avoid ever doing the extra long wait for DP.
-  */
- if (aux->is_edp) {
- ret = dp_catalog_aux_wait_for_hpd_connect_state(aux->catalog,
- 50);
- if (ret) {
- DRM_DEBUG_DP("Panel not ready for aux transactions\n");
- goto exit;
- }
- }
-
   dp_aux_update_offset_and_segment(aux, msg);
   dp_aux_transfer_helper(aux, msg, true);







Re: [PATCH 0/2] Add POWERTIP PH128800T006-ZHC01 panel

2024-03-19 Thread Neil Armstrong
Hi,

On Mon, 18 Mar 2024 09:17:06 -0700, Nathan Morrisson wrote:
> Add the device tree bindings, timings, and compatible string for the
> POWERTIP PH128800T006-ZHC01 panel.
> 
> Nathan Morrisson (2):
>   dt-bindings: display: simple: Add POWERTIP PH128800T-006-ZHC01 panel
>   drm/panel: simple: Add POWERTIP PH128800T006-ZHC01 panel entry
> 
> [...]

Thanks, Applied to https://gitlab.freedesktop.org/drm/misc/kernel.git 
(drm-misc-next)

[1/2] dt-bindings: display: simple: Add POWERTIP PH128800T-006-ZHC01 panel
  
https://gitlab.freedesktop.org/drm/misc/kernel/-/commit/3b2304cfeddd141523cb50cc1a3ba7624b865011
[2/2] drm/panel: simple: Add POWERTIP PH128800T006-ZHC01 panel entry
  
https://gitlab.freedesktop.org/drm/misc/kernel/-/commit/fd6aa8f2dcb7236e511c1a58d82c2a178170e6ff

-- 
Neil



Re: [PATCH] drm: bridge: thc63lvd1024: Print error message when DT parsing fails

2024-03-19 Thread Neil Armstrong
Hi,

On Mon, 18 Mar 2024 18:06:01 +0200, Laurent Pinchart wrote:
> Commit 00084f0c01bf ("drm: bridge: thc63lvd1024: Switch to use
> of_graph_get_remote_node()") simplified the thc63lvd1024 driver by
> replacing hand-rolled code with a helper function. While doing so, it
> created an error code path at probe time without any error message,
> potentially causing probe issues that get annoying to debug. Fix it by
> adding an error message.
> 
> [...]

Thanks, Applied to https://gitlab.freedesktop.org/drm/misc/kernel.git 
(drm-misc-next)

[1/1] drm: bridge: thc63lvd1024: Print error message when DT parsing fails
  
https://gitlab.freedesktop.org/drm/misc/kernel/-/commit/974652d7a90be7ae3b24779794a65bfb90980044

-- 
Neil



Re: [PATCH] drm: bridge: thc63lvd1024: Print error message when DT parsing fails

2024-03-19 Thread Neil Armstrong

On 18/03/2024 20:23, Sui Jingfeng wrote:

Hi,


On 2024/3/19 02:04, Laurent Pinchart wrote:

Improving core helpers is certainly a good idea, and if we do so, we can
simplify drivers. What I'm concerned is that commit 00084f0c01bf creates
a silent probe failure path,



No, I can't agree here. It doesn't creates a silent probe failure path.


It doesn't _in debug mode_, I agree with Laurent, having a verbose probe error 
should be kept.

Neil



Simply because

1) It is NOT silent.
2) It should be exist at product level kernel.



which didn't exist before it.



Again, it shouldn't be exist.

Otherwise it hints us that there is ill-behavior-ed DT in the mainstream kernel
or a specific product(or development board). If I were you, I would like to fix
the boot failure first.

In the earlier stage of my attempt to contribute, I also would like to enable
debug output as much as possible. Just like you, the benefit is obvious: It 
really
eliminate the pain on developing stage and when bugs happens.

But I was told many many times that mainstream kernel is not for debug, it is
for sound products. I bet you have seen some product level drivers print very 
less.
I'm not understand why in the past, but I think I could understand something 
now.
Probably because professional programmers really confident about what they have
wrote. As they have been tested and/or reviewed thousands or ten thousands 
times.

Enable this debug output by default can only prove to the community that you are
not confident about something, either the community's reviewing power on DTS or
your debug techniques.



This is why
this patch references it in the Fixes: tag, making sure that this patch
will get backported to any stable kernel that includes commit
00084f0c01bf.



No, I keep insist on my judgement. A fixes tag is only meant for cases where 
your
patch fixes a bug. The bug should really be happened. All of the discussion 
ongoing
here are just things imaginary about the *debug* phase and development phase.



  As far as I understand, this is business as usual. There's
nothing personal here, and no judgement on the quality of your code.


Please don't misunderstanding, I do cares the quality of my code.
If it is really introduce a bug, I will responsible and help to solve.
But this is not the case. Sorry.



Signed-off-by: Laurent Pinchart
---
   drivers/gpu/drm/bridge/thc63lvd1024.c | 5 -
   1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/thc63lvd1024.c 
b/drivers/gpu/drm/bridge/thc63lvd1024.c
index 5f99f9724081..674efc489e3a 100644
--- a/drivers/gpu/drm/bridge/thc63lvd1024.c
+++ b/drivers/gpu/drm/bridge/thc63lvd1024.c
@@ -125,8 +125,11 @@ static int thc63_parse_dt(struct thc63_dev *thc63)
   remote = of_graph_get_remote_node(thc63->dev->of_node,
 THC63_RGB_OUT0, -1);
-    if (!remote)
+    if (!remote) {
+    dev_err(thc63->dev, "No remote endpoint for port@%u\n",
+    THC63_RGB_OUT0);
   return -ENODEV;
+    }


An side effect of this patch is that we will add one more extra error message 
in the console.
As the of_graph_get_remote_node() function already print one for us if I add 
'#define DEBUG 1'
on the top of this source file. What's worse, it does not really tell us what's 
really the
error is.

It could be no valid endpoint or no valid remote node because of bad coding in 
DT, or It is
also simply because the remove node(or device) is being disabled intentionally 
by adding
'status = "disabled"' clause. Therefore, the error printing code added here is 
very confusing
in practice. It cannot really help for locating the root cause of the problem.

After think about this more than twice, either help to improve the core 
of_graph_get_remote_node()
function or just to drop this. This what I can tell as a ordinary reviewer. 
Despite you and/or
other more advanced programmer & reviewer could override what I said though.





Re: [PATCH] drm: bridge: thc63lvd1024: Print error message when DT parsing fails

2024-03-19 Thread Neil Armstrong

On 18/03/2024 17:06, Laurent Pinchart wrote:

Commit 00084f0c01bf ("drm: bridge: thc63lvd1024: Switch to use
of_graph_get_remote_node()") simplified the thc63lvd1024 driver by
replacing hand-rolled code with a helper function. While doing so, it
created an error code path at probe time without any error message,
potentially causing probe issues that get annoying to debug. Fix it by
adding an error message.

Fixes: 00084f0c01bf ("drm: bridge: thc63lvd1024: Switch to use 
of_graph_get_remote_node()")
Signed-off-by: Laurent Pinchart 
---
  drivers/gpu/drm/bridge/thc63lvd1024.c | 5 -
  1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/thc63lvd1024.c 
b/drivers/gpu/drm/bridge/thc63lvd1024.c
index 5f99f9724081..674efc489e3a 100644
--- a/drivers/gpu/drm/bridge/thc63lvd1024.c
+++ b/drivers/gpu/drm/bridge/thc63lvd1024.c
@@ -125,8 +125,11 @@ static int thc63_parse_dt(struct thc63_dev *thc63)
  
  	remote = of_graph_get_remote_node(thc63->dev->of_node,

  THC63_RGB_OUT0, -1);
-   if (!remote)
+   if (!remote) {
+   dev_err(thc63->dev, "No remote endpoint for port@%u\n",
+   THC63_RGB_OUT0);
return -ENODEV;
+   }
  
  	thc63->next = of_drm_find_bridge(remote);

of_node_put(remote);

base-commit: 00084f0c01bf3a2591d007010b196e048281c455


Reviewed-by: Neil Armstrong 


Re: [PATCH v2] drm: Document requirements for driver-specific KMS props in new drivers

2024-03-19 Thread Daniel Vetter
On Thu, Mar 14, 2024 at 11:20:09AM +0100, Maxime Ripard wrote:
> On Mon, Mar 11, 2024 at 04:58:58PM +0100, Sebastian Wick wrote:
> > When extending support for a driver-specific KMS property to additional
> > drivers, we should apply all the requirements for new properties and
> > make sure the semantics are the same and documented.
> > 
> > v2: devs of the driver which introduced property shall help and ack
> > 
> > Signed-off-by: Sebastian Wick 
> 
> Acked-by: Maxime Ripard 
> 
> We probably want to have Dave or Sima ack on that one too

Yeah that's a good idea and defacto how we handled this - additional users
of anything (whether library or uapi or whatever) get to clean up an
existing mess if it's too bad. But for uapi it's good to be really
explicit and document that.

Acked-by: Daniel Vetter 

Cheers, Sima
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


Re: [PATCH v2 3/6] backlight: omap1: Replace FB_BLANK_ states with simple on/off

2024-03-19 Thread Daniel Thompson
On Tue, Mar 19, 2024 at 10:37:22AM +0100, Thomas Zimmermann wrote:
> The backlight is on for fb_blank eq FB_BLANK_UNBLANK, or off for
> any other value in fb_blank. But the field fb_blank in struct
> backlight_properties is deprecated and should not be used any
> longer.
>
> Replace the test for fb_blank in omap's backlight code with a
> simple boolean parameter and push the test into the update_status
> helper. Instead of reading fb_blank directly, decode the backlight
> device's status with backlight_is_blank().
>
> Signed-off-by: Thomas Zimmermann 
> Reviewed-by: Dan Carpenter 

Reviewed-by: Daniel Thompson 


Daniel.


Re: Future handling of complex RGB devices on Linux v3

2024-03-19 Thread Werner Sembach

Hi Hans,

Am 18.03.24 um 12:11 schrieb Hans de Goede:

Hi Werner,

Sorry for the late reply.

np


On 2/22/24 2:14 PM, Werner Sembach wrote:

Hi,

Thanks everyone for the exhaustive feedback. And at least this thread is a good 
comprehesive reference for the future ^^.

To recap the hopefully final UAPI for complex RGB lighting devices:

- By default there is a singular /sys/class/leds/* entry that treats the device 
as if it was a single zone RGB keyboard backlight with no special effects.

Ack this sounds good.


- There is an accompanying misc device with the sysfs attributes "name", "device_type",  
"firmware_version_string", "serial_number" for device identification and "use_leds_uapi" that 
defaults to 1.

You don't need a char misc device here, you can just make this sysfs attributes 
on the LED class device's parent device by using device_driver.dev_groups. 
Please don't use a char misc device just to attach sysfs attributes to it.

Also I'm a bit unsure about most of these attributes, "use_leds_uapi" was 
discussed before
and makes sense. But at least for HID devices the rest of this info is already 
available
in sysfs attributes on the HID devices (things like vendor and product id) and 
since the
userspace code needs per device code to drive the kbd anyways it can also have 
device
specific code to retrieve all this info, so the other sysfs attributes just 
feel like
duplicating information. Also there already are a ton of existing hidraw 
userspace rgbkbd
drivers which already get this info from other places.
The parent device can be a hid device, a wmi device, a platform device etc. so I 
thought it would be nice to have some unified way for identification.



     - If set to 0 the /sys/class/leds/* entry disappears. The driver should 
keep the last state the backlight was in active if possible.

     - If set 1 it appears again. The driver should bring it back to a static 1 
zone setting while avoiding flicker if possible.

Ack, if this finds it way into some documentation (which it should) please make 
it
clear that this is about the "use_leds_uapi" sysfs attribute.

Ack



- If the device is not controllable by for example hidraw, the misc device 
might also implement additional ioctls or sysfs attributes to allow a more 
complex low level control for the keyboard backlight. This is will be a highly 
vendor specific UAPI.

IMHO this is the only case where actually using a misc device makes sense, so 
that
you have a chardev to do the ioctls on. misc-device-s should really only be used
when you need a chardev under /dev . Since you don't need the chardev for the 
e.g.
hidraw case you should not use a miscdev there IMHO.


My train of thought was that it would be nice to have the use_leds_uapi at a 
somewhat unified location in sysfs. The parent device can be of any kind, like I 
mentioned above, and while for deactivating it can easily be found via 
/sys/class/leds/*/device/. For reactivating, the leds entry doesn't exist.





     - The actual logic interacting with this low level UAPI is implemented by 
a userspace driver

Implementation wise: For the creation of the misc device with the use_leds_uapi 
switch a helper function/macro might be useful? Wonder if it should go into 
leds.h, led-class-multicolor.h, or a new header file?

See above, I don't think we want the misc device for the hidraw case, at which
point I think the helper becomes unnecessary since just a single sysfs write
callback is necessary.

Also for adding new sysfs attributes it is strongly encouraged to use
device_driver.dev_groups so that the device core handled registering /
unregistering the sysfs attributes which fixes a bunch of races; and
using device_driver.dev_groups does not mix well with a helper as you've
suggested.

Ok, I will see when I start implementing.



- Out of my head it would look something like this:

led_classdev_add_optional_misc_control(
     struct led_classdev *led_cdev,
     char* name,
     char* device_type,
     char* firmware_version_string,
     char* serial_number,
     void (*deregister_led)(struct led_classdev *led_cdev),
     void (*reregister_led)(struct led_classdev *led_cdev))

Let me know your thoughts and hopefully I can start implementing it soon for 
one of our devices.

I think overall the plan sounds good, with my main suggested change
being to not use an unnecessary misc device for the hid-raw case.

Regards,

Hans



Thanks for the feedback,

Werner



RE: [PATCH v2] drm/amdgpu: refactor code to reuse system information

2024-03-19 Thread Khatri, Sunil
[AMD Official Use Only - General]

Ignore this as I have send v3.

-Original Message-
From: Sunil Khatri 
Sent: Tuesday, March 19, 2024 8:41 PM
To: Deucher, Alexander ; Koenig, Christian 
; Sharma, Shashank 
Cc: amd-...@lists.freedesktop.org; dri-devel@lists.freedesktop.org; 
linux-ker...@vger.kernel.org; Zhang, Hawking ; Kuehling, 
Felix ; Lazar, Lijo ; Khatri, Sunil 

Subject: [PATCH v2] drm/amdgpu: refactor code to reuse system information

Refactor the code so debugfs and devcoredump can reuse the common information 
and avoid unnecessary copy of it.

created a new file which would be the right place to hold functions which will 
be used between ioctl, debugfs and devcoredump.

Cc: Christian König 
Cc: Alex Deucher 
Signed-off-by: Sunil Khatri 
---
 drivers/gpu/drm/amd/amdgpu/Makefile  |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_coreinfo.c | 146 +++  
drivers/gpu/drm/amd/amdgpu/amdgpu_coreinfo.h |  33 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c  | 117 +--
 4 files changed, 182 insertions(+), 116 deletions(-)  create mode 100644 
drivers/gpu/drm/amd/amdgpu/amdgpu_coreinfo.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_coreinfo.h

diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile 
b/drivers/gpu/drm/amd/amdgpu/Makefile
index 4536c8ad0e11..2c5c800c1ed6 100644
--- a/drivers/gpu/drm/amd/amdgpu/Makefile
+++ b/drivers/gpu/drm/amd/amdgpu/Makefile
@@ -80,7 +80,7 @@ amdgpu-y += amdgpu_device.o amdgpu_doorbell_mgr.o 
amdgpu_kms.o \
amdgpu_umc.o smu_v11_0_i2c.o amdgpu_fru_eeprom.o amdgpu_rap.o \
amdgpu_fw_attestation.o amdgpu_securedisplay.o \
amdgpu_eeprom.o amdgpu_mca.o amdgpu_psp_ta.o amdgpu_lsdma.o \
-   amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o
+   amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o
+amdgpu_coreinfo.o

 amdgpu-$(CONFIG_PROC_FS) += amdgpu_fdinfo.o

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_coreinfo.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_coreinfo.c
new file mode 100644
index ..597fc9d432ce
--- /dev/null
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_coreinfo.c
@@ -0,0 +1,146 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright 2024 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person
+obtaining a
+ * copy of this software and associated documentation files (the
+"Software"),
+ * to deal in the Software without restriction, including without
+limitation
+ * the rights to use, copy, modify, merge, publish, distribute,
+sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom
+the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT
+SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM,
+DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "amdgpu_coreinfo.h"
+#include "amd_pcie.h"
+
+
+void amdgpu_coreinfo_devinfo(struct amdgpu_device *adev, struct
+drm_amdgpu_info_device *dev_info) {
+   int ret;
+   uint64_t vm_size;
+   uint32_t pcie_gen_mask;
+
+   dev_info->device_id = adev->pdev->device;
+   dev_info->chip_rev = adev->rev_id;
+   dev_info->external_rev = adev->external_rev_id;
+   dev_info->pci_rev = adev->pdev->revision;
+   dev_info->family = adev->family;
+   dev_info->num_shader_engines = adev->gfx.config.max_shader_engines;
+   dev_info->num_shader_arrays_per_engine = adev->gfx.config.max_sh_per_se;
+   /* return all clocks in KHz */
+   dev_info->gpu_counter_freq = amdgpu_asic_get_xclk(adev) * 10;
+   if (adev->pm.dpm_enabled) {
+   dev_info->max_engine_clock = amdgpu_dpm_get_sclk(adev, false) * 
10;
+   dev_info->max_memory_clock = amdgpu_dpm_get_mclk(adev, false) * 
10;
+   dev_info->min_engine_clock = amdgpu_dpm_get_sclk(adev, true) * 
10;
+   dev_info->min_memory_clock = amdgpu_dpm_get_mclk(adev, true) * 
10;
+   } else {
+   dev_info->max_engine_clock =
+   dev_info->min_engine_clock =
+   adev->clock.default_sclk * 10;
+   dev_info->max_memory_clock =
+   dev_info->min_memory_clock =
+   adev->clock.default_mclk * 10;
+   }
+   dev_info->enabled_rb_pipes_mask = adev->gfx.config.backend_enable_mask;
+   dev_info->num_rb_pipes = adev->gfx.config.max_backends_per_se *
+   

[PATCH v3] drm/amdgpu: refactor code to reuse system information

2024-03-19 Thread Sunil Khatri
Refactor the code so debugfs and devcoredump can reuse
the common information and avoid unnecessary copy of it.

created a new file which would be the right place to
hold functions which will be used between ioctl, debugfs
and devcoredump.

Cc: Christian König 
Cc: Alex Deucher 
Signed-off-by: Sunil Khatri 
---
 drivers/gpu/drm/amd/amdgpu/Makefile  |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_coreinfo.c | 146 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_coreinfo.h |  33 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c  | 117 +--
 4 files changed, 182 insertions(+), 116 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_coreinfo.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_coreinfo.h

diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile 
b/drivers/gpu/drm/amd/amdgpu/Makefile
index 4536c8ad0e11..2c5c800c1ed6 100644
--- a/drivers/gpu/drm/amd/amdgpu/Makefile
+++ b/drivers/gpu/drm/amd/amdgpu/Makefile
@@ -80,7 +80,7 @@ amdgpu-y += amdgpu_device.o amdgpu_doorbell_mgr.o 
amdgpu_kms.o \
amdgpu_umc.o smu_v11_0_i2c.o amdgpu_fru_eeprom.o amdgpu_rap.o \
amdgpu_fw_attestation.o amdgpu_securedisplay.o \
amdgpu_eeprom.o amdgpu_mca.o amdgpu_psp_ta.o amdgpu_lsdma.o \
-   amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o
+   amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o 
amdgpu_coreinfo.o
 
 amdgpu-$(CONFIG_PROC_FS) += amdgpu_fdinfo.o
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_coreinfo.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_coreinfo.c
new file mode 100644
index ..597fc9d432ce
--- /dev/null
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_coreinfo.c
@@ -0,0 +1,146 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright 2024 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "amdgpu_coreinfo.h"
+#include "amd_pcie.h"
+
+
+void amdgpu_coreinfo_devinfo(struct amdgpu_device *adev, struct 
drm_amdgpu_info_device *dev_info)
+{
+   int ret;
+   uint64_t vm_size;
+   uint32_t pcie_gen_mask;
+
+   dev_info->device_id = adev->pdev->device;
+   dev_info->chip_rev = adev->rev_id;
+   dev_info->external_rev = adev->external_rev_id;
+   dev_info->pci_rev = adev->pdev->revision;
+   dev_info->family = adev->family;
+   dev_info->num_shader_engines = adev->gfx.config.max_shader_engines;
+   dev_info->num_shader_arrays_per_engine = adev->gfx.config.max_sh_per_se;
+   /* return all clocks in KHz */
+   dev_info->gpu_counter_freq = amdgpu_asic_get_xclk(adev) * 10;
+   if (adev->pm.dpm_enabled) {
+   dev_info->max_engine_clock = amdgpu_dpm_get_sclk(adev, false) * 
10;
+   dev_info->max_memory_clock = amdgpu_dpm_get_mclk(adev, false) * 
10;
+   dev_info->min_engine_clock = amdgpu_dpm_get_sclk(adev, true) * 
10;
+   dev_info->min_memory_clock = amdgpu_dpm_get_mclk(adev, true) * 
10;
+   } else {
+   dev_info->max_engine_clock =
+   dev_info->min_engine_clock =
+   adev->clock.default_sclk * 10;
+   dev_info->max_memory_clock =
+   dev_info->min_memory_clock =
+   adev->clock.default_mclk * 10;
+   }
+   dev_info->enabled_rb_pipes_mask = adev->gfx.config.backend_enable_mask;
+   dev_info->num_rb_pipes = adev->gfx.config.max_backends_per_se *
+   adev->gfx.config.max_shader_engines;
+   dev_info->num_hw_gfx_contexts = adev->gfx.config.max_hw_contexts;
+   dev_info->ids_flags = 0;
+   if (adev->flags & AMD_IS_APU)
+   dev_info->ids_flags |= AMDGPU_IDS_FLAGS_FUSION;
+   if (adev->gfx.mcbp)
+   dev_info->ids_flags |= AMDGPU_IDS_FLAGS_PREEMPTION;
+   if (amdgpu_is_tmz(adev))
+   dev_info->ids_flags |= AMDGPU_IDS_FLAGS_TMZ;
+   if 

Re: [PATCH] drm/amdgpu: refactor code to reuse system information

2024-03-19 Thread Khatri, Sunil

Sent a new patch based on discussion with Alex.

On 3/19/2024 8:34 PM, Christian König wrote:

Am 19.03.24 um 15:59 schrieb Alex Deucher:

On Tue, Mar 19, 2024 at 10:56 AM Christian König
 wrote:

Am 19.03.24 um 15:26 schrieb Alex Deucher:
On Tue, Mar 19, 2024 at 8:32 AM Sunil Khatri  
wrote:

Refactor the code so debugfs and devcoredump can reuse
the common information and avoid unnecessary copy of it.

created a new file which would be the right place to
hold functions which will be used between sysfs, debugfs
and devcoredump.

Cc: Christian König 
Cc: Alex Deucher 
Signed-off-by: Sunil Khatri 
---
   drivers/gpu/drm/amd/amdgpu/Makefile |   2 +-
   drivers/gpu/drm/amd/amdgpu/amdgpu.h |   1 +
   drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c | 151 


   drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 118 +--
   4 files changed, 157 insertions(+), 115 deletions(-)
   create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c

diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile 
b/drivers/gpu/drm/amd/amdgpu/Makefile

index 4536c8ad0e11..05d34f4b18f5 100644
--- a/drivers/gpu/drm/amd/amdgpu/Makefile
+++ b/drivers/gpu/drm/amd/amdgpu/Makefile
@@ -80,7 +80,7 @@ amdgpu-y += amdgpu_device.o 
amdgpu_doorbell_mgr.o amdgpu_kms.o \
  amdgpu_umc.o smu_v11_0_i2c.o amdgpu_fru_eeprom.o 
amdgpu_rap.o \

  amdgpu_fw_attestation.o amdgpu_securedisplay.o \
  amdgpu_eeprom.o amdgpu_mca.o amdgpu_psp_ta.o 
amdgpu_lsdma.o \

-   amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o
+   amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o 
amdgpu_devinfo.o


   amdgpu-$(CONFIG_PROC_FS) += amdgpu_fdinfo.o

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h

index 9c62552bec34..0267870aa9b1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1609,4 +1609,5 @@ extern const struct attribute_group 
amdgpu_vram_mgr_attr_group;

   extern const struct attribute_group amdgpu_gtt_mgr_attr_group;
   extern const struct attribute_group amdgpu_flash_attr_group;

+int amdgpu_device_info(struct amdgpu_device *adev, struct 
drm_amdgpu_info_device *dev_info);

   #endif
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c

new file mode 100644
index ..d2c15a1dcb0d
--- /dev/null
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c
@@ -0,0 +1,151 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright 2024 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person 
obtaining a
+ * copy of this software and associated documentation files (the 
"Software"),
+ * to deal in the Software without restriction, including without 
limitation
+ * the rights to use, copy, modify, merge, publish, distribute, 
sublicense,
+ * and/or sell copies of the Software, and to permit persons to 
whom the
+ * Software is furnished to do so, subject to the following 
conditions:

+ *
+ * The above copyright notice and this permission notice shall be 
included in

+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 
KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO 
EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, 
DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 
USE OR

+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "amdgpu.h"
+#include "amd_pcie.h"
+
+#include 
+
+int amdgpu_device_info(struct amdgpu_device *adev, struct 
drm_amdgpu_info_device *dev_info)

We can probably keep this in amdgpu_kms.c unless that file is getting
too big.  I don't think it warrants a new file at this point.  If you
do keep it in amdgpu_kms.c, I'd recommend renaming it to something
like amdgpu_kms_device_info() to keep the naming conventions.

We should not be using this for anything new in the first place.

A whole bunch of the stuff inside the devinfo structure has been
deprecated because we found that putting everything into one structure
was a bad idea.

It's a convenient way to collect a lot of useful information that we
want in the core dump.  Plus it's not going anywhere because we need
to keep compatibility in the IOCTL.


Yeah and exactly that is what I'm strictly against. The devinfo wasn't 
used for new stuff because we found that it is way to inflexible.


That's why we have multiple separate IOCTLs for the memory and 
firmware information for example.


We should really *not* reuse that for the device core dumping.

Rather just use the same information from the different IPs and 
subsystems directly. E.g. add a function to the VM, GFX etc for 
printing out devcoredump infos.


I have pushed new v2 based 

[PATCH v2] drm/amdgpu: refactor code to reuse system information

2024-03-19 Thread Sunil Khatri
Refactor the code so debugfs and devcoredump can reuse
the common information and avoid unnecessary copy of it.

created a new file which would be the right place to
hold functions which will be used between ioctl, debugfs
and devcoredump.

Cc: Christian König 
Cc: Alex Deucher 
Signed-off-by: Sunil Khatri 
---
 drivers/gpu/drm/amd/amdgpu/Makefile  |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_coreinfo.c | 146 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_coreinfo.h |  33 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c  | 117 +--
 4 files changed, 182 insertions(+), 116 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_coreinfo.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_coreinfo.h

diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile 
b/drivers/gpu/drm/amd/amdgpu/Makefile
index 4536c8ad0e11..2c5c800c1ed6 100644
--- a/drivers/gpu/drm/amd/amdgpu/Makefile
+++ b/drivers/gpu/drm/amd/amdgpu/Makefile
@@ -80,7 +80,7 @@ amdgpu-y += amdgpu_device.o amdgpu_doorbell_mgr.o 
amdgpu_kms.o \
amdgpu_umc.o smu_v11_0_i2c.o amdgpu_fru_eeprom.o amdgpu_rap.o \
amdgpu_fw_attestation.o amdgpu_securedisplay.o \
amdgpu_eeprom.o amdgpu_mca.o amdgpu_psp_ta.o amdgpu_lsdma.o \
-   amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o
+   amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o 
amdgpu_coreinfo.o
 
 amdgpu-$(CONFIG_PROC_FS) += amdgpu_fdinfo.o
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_coreinfo.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_coreinfo.c
new file mode 100644
index ..597fc9d432ce
--- /dev/null
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_coreinfo.c
@@ -0,0 +1,146 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright 2024 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "amdgpu_coreinfo.h"
+#include "amd_pcie.h"
+
+
+void amdgpu_coreinfo_devinfo(struct amdgpu_device *adev, struct 
drm_amdgpu_info_device *dev_info)
+{
+   int ret;
+   uint64_t vm_size;
+   uint32_t pcie_gen_mask;
+
+   dev_info->device_id = adev->pdev->device;
+   dev_info->chip_rev = adev->rev_id;
+   dev_info->external_rev = adev->external_rev_id;
+   dev_info->pci_rev = adev->pdev->revision;
+   dev_info->family = adev->family;
+   dev_info->num_shader_engines = adev->gfx.config.max_shader_engines;
+   dev_info->num_shader_arrays_per_engine = adev->gfx.config.max_sh_per_se;
+   /* return all clocks in KHz */
+   dev_info->gpu_counter_freq = amdgpu_asic_get_xclk(adev) * 10;
+   if (adev->pm.dpm_enabled) {
+   dev_info->max_engine_clock = amdgpu_dpm_get_sclk(adev, false) * 
10;
+   dev_info->max_memory_clock = amdgpu_dpm_get_mclk(adev, false) * 
10;
+   dev_info->min_engine_clock = amdgpu_dpm_get_sclk(adev, true) * 
10;
+   dev_info->min_memory_clock = amdgpu_dpm_get_mclk(adev, true) * 
10;
+   } else {
+   dev_info->max_engine_clock =
+   dev_info->min_engine_clock =
+   adev->clock.default_sclk * 10;
+   dev_info->max_memory_clock =
+   dev_info->min_memory_clock =
+   adev->clock.default_mclk * 10;
+   }
+   dev_info->enabled_rb_pipes_mask = adev->gfx.config.backend_enable_mask;
+   dev_info->num_rb_pipes = adev->gfx.config.max_backends_per_se *
+   adev->gfx.config.max_shader_engines;
+   dev_info->num_hw_gfx_contexts = adev->gfx.config.max_hw_contexts;
+   dev_info->ids_flags = 0;
+   if (adev->flags & AMD_IS_APU)
+   dev_info->ids_flags |= AMDGPU_IDS_FLAGS_FUSION;
+   if (adev->gfx.mcbp)
+   dev_info->ids_flags |= AMDGPU_IDS_FLAGS_PREEMPTION;
+   if (amdgpu_is_tmz(adev))
+   dev_info->ids_flags |= AMDGPU_IDS_FLAGS_TMZ;
+   if 

Re: [PATCH] drm/amdgpu: refactor code to reuse system information

2024-03-19 Thread Christian König

Am 19.03.24 um 15:59 schrieb Alex Deucher:

On Tue, Mar 19, 2024 at 10:56 AM Christian König
 wrote:

Am 19.03.24 um 15:26 schrieb Alex Deucher:

On Tue, Mar 19, 2024 at 8:32 AM Sunil Khatri  wrote:

Refactor the code so debugfs and devcoredump can reuse
the common information and avoid unnecessary copy of it.

created a new file which would be the right place to
hold functions which will be used between sysfs, debugfs
and devcoredump.

Cc: Christian König 
Cc: Alex Deucher 
Signed-off-by: Sunil Khatri 
---
   drivers/gpu/drm/amd/amdgpu/Makefile |   2 +-
   drivers/gpu/drm/amd/amdgpu/amdgpu.h |   1 +
   drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c | 151 
   drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 118 +--
   4 files changed, 157 insertions(+), 115 deletions(-)
   create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c

diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile 
b/drivers/gpu/drm/amd/amdgpu/Makefile
index 4536c8ad0e11..05d34f4b18f5 100644
--- a/drivers/gpu/drm/amd/amdgpu/Makefile
+++ b/drivers/gpu/drm/amd/amdgpu/Makefile
@@ -80,7 +80,7 @@ amdgpu-y += amdgpu_device.o amdgpu_doorbell_mgr.o 
amdgpu_kms.o \
  amdgpu_umc.o smu_v11_0_i2c.o amdgpu_fru_eeprom.o amdgpu_rap.o \
  amdgpu_fw_attestation.o amdgpu_securedisplay.o \
  amdgpu_eeprom.o amdgpu_mca.o amdgpu_psp_ta.o amdgpu_lsdma.o \
-   amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o
+   amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o 
amdgpu_devinfo.o

   amdgpu-$(CONFIG_PROC_FS) += amdgpu_fdinfo.o

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 9c62552bec34..0267870aa9b1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1609,4 +1609,5 @@ extern const struct attribute_group 
amdgpu_vram_mgr_attr_group;
   extern const struct attribute_group amdgpu_gtt_mgr_attr_group;
   extern const struct attribute_group amdgpu_flash_attr_group;

+int amdgpu_device_info(struct amdgpu_device *adev, struct 
drm_amdgpu_info_device *dev_info);
   #endif
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c
new file mode 100644
index ..d2c15a1dcb0d
--- /dev/null
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c
@@ -0,0 +1,151 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright 2024 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "amdgpu.h"
+#include "amd_pcie.h"
+
+#include 
+
+int amdgpu_device_info(struct amdgpu_device *adev, struct 
drm_amdgpu_info_device *dev_info)

We can probably keep this in amdgpu_kms.c unless that file is getting
too big.  I don't think it warrants a new file at this point.  If you
do keep it in amdgpu_kms.c, I'd recommend renaming it to something
like amdgpu_kms_device_info() to keep the naming conventions.

We should not be using this for anything new in the first place.

A whole bunch of the stuff inside the devinfo structure has been
deprecated because we found that putting everything into one structure
was a bad idea.

It's a convenient way to collect a lot of useful information that we
want in the core dump.  Plus it's not going anywhere because we need
to keep compatibility in the IOCTL.


Yeah and exactly that is what I'm strictly against. The devinfo wasn't 
used for new stuff because we found that it is way to inflexible.


That's why we have multiple separate IOCTLs for the memory and firmware 
information for example.


We should really *not* reuse that for the device core dumping.

Rather just use the same information from the different IPs and 
subsystems directly. E.g. add a function to the VM, GFX etc for printing 
out devcoredump infos.


Christian.



Alex


Regards,
Christian.


+{
+   int ret;
+   uint64_t vm_size;
+   uint32_t pcie_gen_mask;
+
+   if (dev_info == 

Re: [PATCH] drm/amdgpu: refactor code to reuse system information

2024-03-19 Thread Alex Deucher
On Tue, Mar 19, 2024 at 10:56 AM Christian König
 wrote:
>
> Am 19.03.24 um 15:26 schrieb Alex Deucher:
> > On Tue, Mar 19, 2024 at 8:32 AM Sunil Khatri  wrote:
> >> Refactor the code so debugfs and devcoredump can reuse
> >> the common information and avoid unnecessary copy of it.
> >>
> >> created a new file which would be the right place to
> >> hold functions which will be used between sysfs, debugfs
> >> and devcoredump.
> >>
> >> Cc: Christian König 
> >> Cc: Alex Deucher 
> >> Signed-off-by: Sunil Khatri 
> >> ---
> >>   drivers/gpu/drm/amd/amdgpu/Makefile |   2 +-
> >>   drivers/gpu/drm/amd/amdgpu/amdgpu.h |   1 +
> >>   drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c | 151 
> >>   drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 118 +--
> >>   4 files changed, 157 insertions(+), 115 deletions(-)
> >>   create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c
> >>
> >> diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile 
> >> b/drivers/gpu/drm/amd/amdgpu/Makefile
> >> index 4536c8ad0e11..05d34f4b18f5 100644
> >> --- a/drivers/gpu/drm/amd/amdgpu/Makefile
> >> +++ b/drivers/gpu/drm/amd/amdgpu/Makefile
> >> @@ -80,7 +80,7 @@ amdgpu-y += amdgpu_device.o amdgpu_doorbell_mgr.o 
> >> amdgpu_kms.o \
> >>  amdgpu_umc.o smu_v11_0_i2c.o amdgpu_fru_eeprom.o amdgpu_rap.o \
> >>  amdgpu_fw_attestation.o amdgpu_securedisplay.o \
> >>  amdgpu_eeprom.o amdgpu_mca.o amdgpu_psp_ta.o amdgpu_lsdma.o \
> >> -   amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o
> >> +   amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o 
> >> amdgpu_devinfo.o
> >>
> >>   amdgpu-$(CONFIG_PROC_FS) += amdgpu_fdinfo.o
> >>
> >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
> >> b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> >> index 9c62552bec34..0267870aa9b1 100644
> >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> >> @@ -1609,4 +1609,5 @@ extern const struct attribute_group 
> >> amdgpu_vram_mgr_attr_group;
> >>   extern const struct attribute_group amdgpu_gtt_mgr_attr_group;
> >>   extern const struct attribute_group amdgpu_flash_attr_group;
> >>
> >> +int amdgpu_device_info(struct amdgpu_device *adev, struct 
> >> drm_amdgpu_info_device *dev_info);
> >>   #endif
> >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c 
> >> b/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c
> >> new file mode 100644
> >> index ..d2c15a1dcb0d
> >> --- /dev/null
> >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c
> >> @@ -0,0 +1,151 @@
> >> +// SPDX-License-Identifier: MIT
> >> +/*
> >> + * Copyright 2024 Advanced Micro Devices, Inc.
> >> + *
> >> + * Permission is hereby granted, free of charge, to any person obtaining a
> >> + * copy of this software and associated documentation files (the 
> >> "Software"),
> >> + * to deal in the Software without restriction, including without 
> >> limitation
> >> + * the rights to use, copy, modify, merge, publish, distribute, 
> >> sublicense,
> >> + * and/or sell copies of the Software, and to permit persons to whom the
> >> + * Software is furnished to do so, subject to the following conditions:
> >> + *
> >> + * The above copyright notice and this permission notice shall be 
> >> included in
> >> + * all copies or substantial portions of the Software.
> >> + *
> >> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
> >> EXPRESS OR
> >> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
> >> MERCHANTABILITY,
> >> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT 
> >> SHALL
> >> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES 
> >> OR
> >> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
> >> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
> >> + * OTHER DEALINGS IN THE SOFTWARE.
> >> + *
> >> + */
> >> +
> >> +#include "amdgpu.h"
> >> +#include "amd_pcie.h"
> >> +
> >> +#include 
> >> +
> >> +int amdgpu_device_info(struct amdgpu_device *adev, struct 
> >> drm_amdgpu_info_device *dev_info)
> > We can probably keep this in amdgpu_kms.c unless that file is getting
> > too big.  I don't think it warrants a new file at this point.  If you
> > do keep it in amdgpu_kms.c, I'd recommend renaming it to something
> > like amdgpu_kms_device_info() to keep the naming conventions.
>
> We should not be using this for anything new in the first place.
>
> A whole bunch of the stuff inside the devinfo structure has been
> deprecated because we found that putting everything into one structure
> was a bad idea.

It's a convenient way to collect a lot of useful information that we
want in the core dump.  Plus it's not going anywhere because we need
to keep compatibility in the IOCTL.

Alex

>
> Regards,
> Christian.
>
> >
> >> +{
> >> +   int ret;
> >> +   uint64_t vm_size;
> >> +   uint32_t pcie_gen_mask;
> >> +
> >> +   if (dev_info == NULL)
> 

Re: [PATCH] drm/amdgpu: refactor code to reuse system information

2024-03-19 Thread Christian König

Am 19.03.24 um 15:26 schrieb Alex Deucher:

On Tue, Mar 19, 2024 at 8:32 AM Sunil Khatri  wrote:

Refactor the code so debugfs and devcoredump can reuse
the common information and avoid unnecessary copy of it.

created a new file which would be the right place to
hold functions which will be used between sysfs, debugfs
and devcoredump.

Cc: Christian König 
Cc: Alex Deucher 
Signed-off-by: Sunil Khatri 
---
  drivers/gpu/drm/amd/amdgpu/Makefile |   2 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu.h |   1 +
  drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c | 151 
  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 118 +--
  4 files changed, 157 insertions(+), 115 deletions(-)
  create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c

diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile 
b/drivers/gpu/drm/amd/amdgpu/Makefile
index 4536c8ad0e11..05d34f4b18f5 100644
--- a/drivers/gpu/drm/amd/amdgpu/Makefile
+++ b/drivers/gpu/drm/amd/amdgpu/Makefile
@@ -80,7 +80,7 @@ amdgpu-y += amdgpu_device.o amdgpu_doorbell_mgr.o 
amdgpu_kms.o \
 amdgpu_umc.o smu_v11_0_i2c.o amdgpu_fru_eeprom.o amdgpu_rap.o \
 amdgpu_fw_attestation.o amdgpu_securedisplay.o \
 amdgpu_eeprom.o amdgpu_mca.o amdgpu_psp_ta.o amdgpu_lsdma.o \
-   amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o
+   amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o 
amdgpu_devinfo.o

  amdgpu-$(CONFIG_PROC_FS) += amdgpu_fdinfo.o

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 9c62552bec34..0267870aa9b1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1609,4 +1609,5 @@ extern const struct attribute_group 
amdgpu_vram_mgr_attr_group;
  extern const struct attribute_group amdgpu_gtt_mgr_attr_group;
  extern const struct attribute_group amdgpu_flash_attr_group;

+int amdgpu_device_info(struct amdgpu_device *adev, struct 
drm_amdgpu_info_device *dev_info);
  #endif
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c
new file mode 100644
index ..d2c15a1dcb0d
--- /dev/null
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c
@@ -0,0 +1,151 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright 2024 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "amdgpu.h"
+#include "amd_pcie.h"
+
+#include 
+
+int amdgpu_device_info(struct amdgpu_device *adev, struct 
drm_amdgpu_info_device *dev_info)

We can probably keep this in amdgpu_kms.c unless that file is getting
too big.  I don't think it warrants a new file at this point.  If you
do keep it in amdgpu_kms.c, I'd recommend renaming it to something
like amdgpu_kms_device_info() to keep the naming conventions.


We should not be using this for anything new in the first place.

A whole bunch of the stuff inside the devinfo structure has been 
deprecated because we found that putting everything into one structure 
was a bad idea.


Regards,
Christian.




+{
+   int ret;
+   uint64_t vm_size;
+   uint32_t pcie_gen_mask;
+
+   if (dev_info == NULL)
+   return -EINVAL;
+
+   dev_info->device_id = adev->pdev->device;
+   dev_info->chip_rev = adev->rev_id;
+   dev_info->external_rev = adev->external_rev_id;
+   dev_info->pci_rev = adev->pdev->revision;
+   dev_info->family = adev->family;
+   dev_info->num_shader_engines = adev->gfx.config.max_shader_engines;
+   dev_info->num_shader_arrays_per_engine = adev->gfx.config.max_sh_per_se;
+   /* return all clocks in KHz */
+   dev_info->gpu_counter_freq = amdgpu_asic_get_xclk(adev) * 10;
+   if (adev->pm.dpm_enabled) {
+   dev_info->max_engine_clock = amdgpu_dpm_get_sclk(adev, false) * 
10;
+   dev_info->max_memory_clock = amdgpu_dpm_get_mclk(adev, false) * 
10;
+   

Re: [PATCH v2] drm/amdgpu: refactor code to reuse system information

2024-03-19 Thread Christian König

Am 19.03.24 um 15:44 schrieb Khatri, Sunil:


On 3/19/2024 8:07 PM, Christian König wrote:

Am 19.03.24 um 15:25 schrieb Sunil Khatri:

Refactor the code so debugfs and devcoredump can reuse
the common information and avoid unnecessary copy of it.

created a new file which would be the right place to
hold functions which will be used between ioctl, debugfs
and devcoredump.


Ok, taking a closer look that is certainly not a good idea.

The devinfo structure was just created because somebody thought that 
mixing all that stuff into one structure would be a good idea.


We have pretty much deprecated that approach and should *really* not 
change anything here any more.
To support the ioctl we are keeping that information same without 
changing it. The intent to add a new file is because we will have more 
information coming in this new file. Next in line is firmware 
information which is again a huge function with lot of information and 
to use that information in devcoredump and ioctl and sysfs the new 
file seems to be right idea after some discussions.
FYI: this will not be just one function in new file but more to come 
so code can be reused without copying it.


That is exactly the point. I would say we should really *not* use that 
code for devcoredump.


This code is rather deprecated and we expose a lot of the information 
through other IOCTLs.


So the problem here isn't that you want to add a new file, but rather 
that you touch deprecated functionality.


Regards,
Christian.



Regards,
Christian.



Cc: Christian König 
Cc: Alex Deucher 
Signed-off-by: Sunil Khatri 
---
  drivers/gpu/drm/amd/amdgpu/Makefile |   2 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu.h |   1 +
  drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c | 151 


  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 118 +--
  4 files changed, 157 insertions(+), 115 deletions(-)
  create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c

diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile 
b/drivers/gpu/drm/amd/amdgpu/Makefile

index 4536c8ad0e11..05d34f4b18f5 100644
--- a/drivers/gpu/drm/amd/amdgpu/Makefile
+++ b/drivers/gpu/drm/amd/amdgpu/Makefile
@@ -80,7 +80,7 @@ amdgpu-y += amdgpu_device.o amdgpu_doorbell_mgr.o 
amdgpu_kms.o \

  amdgpu_umc.o smu_v11_0_i2c.o amdgpu_fru_eeprom.o amdgpu_rap.o \
  amdgpu_fw_attestation.o amdgpu_securedisplay.o \
  amdgpu_eeprom.o amdgpu_mca.o amdgpu_psp_ta.o amdgpu_lsdma.o \
-    amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o
+    amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o 
amdgpu_devinfo.o

    amdgpu-$(CONFIG_PROC_FS) += amdgpu_fdinfo.o
  diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h

index 9c62552bec34..0267870aa9b1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1609,4 +1609,5 @@ extern const struct attribute_group 
amdgpu_vram_mgr_attr_group;

  extern const struct attribute_group amdgpu_gtt_mgr_attr_group;
  extern const struct attribute_group amdgpu_flash_attr_group;
  +int amdgpu_device_info(struct amdgpu_device *adev, struct 
drm_amdgpu_info_device *dev_info);

  #endif
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c

new file mode 100644
index ..fdcbc1984031
--- /dev/null
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c
@@ -0,0 +1,151 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright 2024 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person 
obtaining a
+ * copy of this software and associated documentation files (the 
"Software"),
+ * to deal in the Software without restriction, including without 
limitation
+ * the rights to use, copy, modify, merge, publish, distribute, 
sublicense,
+ * and/or sell copies of the Software, and to permit persons to 
whom the
+ * Software is furnished to do so, subject to the following 
conditions:

+ *
+ * The above copyright notice and this permission notice shall be 
included in

+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO 
EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, 
DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 
USE OR

+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "amdgpu.h"
+#include "amd_pcie.h"
+
+#include 
+
+int amdgpu_device_info(struct amdgpu_device *adev, struct 
drm_amdgpu_info_device *dev_info)

+{
+    int ret;
+    uint64_t vm_size;
+    uint32_t pcie_gen_mask;
+
+    if (dev_info == NULL)
+    return -EINVAL;
+
+    dev_info->device_id = adev->pdev->device;
+    

Re: [PATCH v2] drm/amdgpu: refactor code to reuse system information

2024-03-19 Thread Khatri, Sunil



On 3/19/2024 8:07 PM, Christian König wrote:

Am 19.03.24 um 15:25 schrieb Sunil Khatri:

Refactor the code so debugfs and devcoredump can reuse
the common information and avoid unnecessary copy of it.

created a new file which would be the right place to
hold functions which will be used between ioctl, debugfs
and devcoredump.


Ok, taking a closer look that is certainly not a good idea.

The devinfo structure was just created because somebody thought that 
mixing all that stuff into one structure would be a good idea.


We have pretty much deprecated that approach and should *really* not 
change anything here any more.
To support the ioctl we are keeping that information same without 
changing it. The intent to add a new file is because we will have more 
information coming in this new file. Next in line is firmware 
information which is again a huge function with lot of information and 
to use that information in devcoredump and ioctl and sysfs the new file 
seems to be right idea after some discussions.
FYI: this will not be just one function in new file but more to come so 
code can be reused without copying it.


Regards,
Christian.



Cc: Christian König 
Cc: Alex Deucher 
Signed-off-by: Sunil Khatri 
---
  drivers/gpu/drm/amd/amdgpu/Makefile |   2 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu.h |   1 +
  drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c | 151 
  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 118 +--
  4 files changed, 157 insertions(+), 115 deletions(-)
  create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c

diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile 
b/drivers/gpu/drm/amd/amdgpu/Makefile

index 4536c8ad0e11..05d34f4b18f5 100644
--- a/drivers/gpu/drm/amd/amdgpu/Makefile
+++ b/drivers/gpu/drm/amd/amdgpu/Makefile
@@ -80,7 +80,7 @@ amdgpu-y += amdgpu_device.o amdgpu_doorbell_mgr.o 
amdgpu_kms.o \

  amdgpu_umc.o smu_v11_0_i2c.o amdgpu_fru_eeprom.o amdgpu_rap.o \
  amdgpu_fw_attestation.o amdgpu_securedisplay.o \
  amdgpu_eeprom.o amdgpu_mca.o amdgpu_psp_ta.o amdgpu_lsdma.o \
-    amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o
+    amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o 
amdgpu_devinfo.o

    amdgpu-$(CONFIG_PROC_FS) += amdgpu_fdinfo.o
  diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h

index 9c62552bec34..0267870aa9b1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1609,4 +1609,5 @@ extern const struct attribute_group 
amdgpu_vram_mgr_attr_group;

  extern const struct attribute_group amdgpu_gtt_mgr_attr_group;
  extern const struct attribute_group amdgpu_flash_attr_group;
  +int amdgpu_device_info(struct amdgpu_device *adev, struct 
drm_amdgpu_info_device *dev_info);

  #endif
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c

new file mode 100644
index ..fdcbc1984031
--- /dev/null
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c
@@ -0,0 +1,151 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright 2024 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person 
obtaining a
+ * copy of this software and associated documentation files (the 
"Software"),
+ * to deal in the Software without restriction, including without 
limitation
+ * the rights to use, copy, modify, merge, publish, distribute, 
sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom 
the

+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be 
included in

+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO 
EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, 
DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 
USE OR

+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "amdgpu.h"
+#include "amd_pcie.h"
+
+#include 
+
+int amdgpu_device_info(struct amdgpu_device *adev, struct 
drm_amdgpu_info_device *dev_info)

+{
+    int ret;
+    uint64_t vm_size;
+    uint32_t pcie_gen_mask;
+
+    if (dev_info == NULL)
+    return -EINVAL;
+
+    dev_info->device_id = adev->pdev->device;
+    dev_info->chip_rev = adev->rev_id;
+    dev_info->external_rev = adev->external_rev_id;
+    dev_info->pci_rev = adev->pdev->revision;
+    dev_info->family = adev->family;
+    dev_info->num_shader_engines = adev->gfx.config.max_shader_engines;
+    dev_info->num_shader_arrays_per_engine = 
adev->gfx.config.max_sh_per_se;

+    /* return all clocks in KHz */
+    

Re: [PATCH v2] drm/amdgpu: refactor code to reuse system information

2024-03-19 Thread Christian König

Am 19.03.24 um 15:25 schrieb Sunil Khatri:

Refactor the code so debugfs and devcoredump can reuse
the common information and avoid unnecessary copy of it.

created a new file which would be the right place to
hold functions which will be used between ioctl, debugfs
and devcoredump.


Ok, taking a closer look that is certainly not a good idea.

The devinfo structure was just created because somebody thought that 
mixing all that stuff into one structure would be a good idea.


We have pretty much deprecated that approach and should *really* not 
change anything here any more.


Regards,
Christian.



Cc: Christian König 
Cc: Alex Deucher 
Signed-off-by: Sunil Khatri 
---
  drivers/gpu/drm/amd/amdgpu/Makefile |   2 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu.h |   1 +
  drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c | 151 
  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 118 +--
  4 files changed, 157 insertions(+), 115 deletions(-)
  create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c

diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile 
b/drivers/gpu/drm/amd/amdgpu/Makefile
index 4536c8ad0e11..05d34f4b18f5 100644
--- a/drivers/gpu/drm/amd/amdgpu/Makefile
+++ b/drivers/gpu/drm/amd/amdgpu/Makefile
@@ -80,7 +80,7 @@ amdgpu-y += amdgpu_device.o amdgpu_doorbell_mgr.o 
amdgpu_kms.o \
amdgpu_umc.o smu_v11_0_i2c.o amdgpu_fru_eeprom.o amdgpu_rap.o \
amdgpu_fw_attestation.o amdgpu_securedisplay.o \
amdgpu_eeprom.o amdgpu_mca.o amdgpu_psp_ta.o amdgpu_lsdma.o \
-   amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o
+   amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o 
amdgpu_devinfo.o
  
  amdgpu-$(CONFIG_PROC_FS) += amdgpu_fdinfo.o
  
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h

index 9c62552bec34..0267870aa9b1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1609,4 +1609,5 @@ extern const struct attribute_group 
amdgpu_vram_mgr_attr_group;
  extern const struct attribute_group amdgpu_gtt_mgr_attr_group;
  extern const struct attribute_group amdgpu_flash_attr_group;
  
+int amdgpu_device_info(struct amdgpu_device *adev, struct drm_amdgpu_info_device *dev_info);

  #endif
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c
new file mode 100644
index ..fdcbc1984031
--- /dev/null
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c
@@ -0,0 +1,151 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright 2024 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "amdgpu.h"
+#include "amd_pcie.h"
+
+#include 
+
+int amdgpu_device_info(struct amdgpu_device *adev, struct 
drm_amdgpu_info_device *dev_info)
+{
+   int ret;
+   uint64_t vm_size;
+   uint32_t pcie_gen_mask;
+
+   if (dev_info == NULL)
+   return -EINVAL;
+
+   dev_info->device_id = adev->pdev->device;
+   dev_info->chip_rev = adev->rev_id;
+   dev_info->external_rev = adev->external_rev_id;
+   dev_info->pci_rev = adev->pdev->revision;
+   dev_info->family = adev->family;
+   dev_info->num_shader_engines = adev->gfx.config.max_shader_engines;
+   dev_info->num_shader_arrays_per_engine = adev->gfx.config.max_sh_per_se;
+   /* return all clocks in KHz */
+   dev_info->gpu_counter_freq = amdgpu_asic_get_xclk(adev) * 10;
+   if (adev->pm.dpm_enabled) {
+   dev_info->max_engine_clock = amdgpu_dpm_get_sclk(adev, false) * 
10;
+   dev_info->max_memory_clock = amdgpu_dpm_get_mclk(adev, false) * 
10;
+   dev_info->min_engine_clock = amdgpu_dpm_get_sclk(adev, true) * 
10;
+   dev_info->min_memory_clock = amdgpu_dpm_get_mclk(adev, true) * 
10;
+   } else {
+   dev_info->max_engine_clock =
+   

Re: [PATCH] drm/amdgpu: refactor code to reuse system information

2024-03-19 Thread Alex Deucher
On Tue, Mar 19, 2024 at 8:32 AM Sunil Khatri  wrote:
>
> Refactor the code so debugfs and devcoredump can reuse
> the common information and avoid unnecessary copy of it.
>
> created a new file which would be the right place to
> hold functions which will be used between sysfs, debugfs
> and devcoredump.
>
> Cc: Christian König 
> Cc: Alex Deucher 
> Signed-off-by: Sunil Khatri 
> ---
>  drivers/gpu/drm/amd/amdgpu/Makefile |   2 +-
>  drivers/gpu/drm/amd/amdgpu/amdgpu.h |   1 +
>  drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c | 151 
>  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 118 +--
>  4 files changed, 157 insertions(+), 115 deletions(-)
>  create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile 
> b/drivers/gpu/drm/amd/amdgpu/Makefile
> index 4536c8ad0e11..05d34f4b18f5 100644
> --- a/drivers/gpu/drm/amd/amdgpu/Makefile
> +++ b/drivers/gpu/drm/amd/amdgpu/Makefile
> @@ -80,7 +80,7 @@ amdgpu-y += amdgpu_device.o amdgpu_doorbell_mgr.o 
> amdgpu_kms.o \
> amdgpu_umc.o smu_v11_0_i2c.o amdgpu_fru_eeprom.o amdgpu_rap.o \
> amdgpu_fw_attestation.o amdgpu_securedisplay.o \
> amdgpu_eeprom.o amdgpu_mca.o amdgpu_psp_ta.o amdgpu_lsdma.o \
> -   amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o
> +   amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o 
> amdgpu_devinfo.o
>
>  amdgpu-$(CONFIG_PROC_FS) += amdgpu_fdinfo.o
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> index 9c62552bec34..0267870aa9b1 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> @@ -1609,4 +1609,5 @@ extern const struct attribute_group 
> amdgpu_vram_mgr_attr_group;
>  extern const struct attribute_group amdgpu_gtt_mgr_attr_group;
>  extern const struct attribute_group amdgpu_flash_attr_group;
>
> +int amdgpu_device_info(struct amdgpu_device *adev, struct 
> drm_amdgpu_info_device *dev_info);
>  #endif
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c
> new file mode 100644
> index ..d2c15a1dcb0d
> --- /dev/null
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c
> @@ -0,0 +1,151 @@
> +// SPDX-License-Identifier: MIT
> +/*
> + * Copyright 2024 Advanced Micro Devices, Inc.
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
> + * OTHER DEALINGS IN THE SOFTWARE.
> + *
> + */
> +
> +#include "amdgpu.h"
> +#include "amd_pcie.h"
> +
> +#include 
> +
> +int amdgpu_device_info(struct amdgpu_device *adev, struct 
> drm_amdgpu_info_device *dev_info)

We can probably keep this in amdgpu_kms.c unless that file is getting
too big.  I don't think it warrants a new file at this point.  If you
do keep it in amdgpu_kms.c, I'd recommend renaming it to something
like amdgpu_kms_device_info() to keep the naming conventions.

> +{
> +   int ret;
> +   uint64_t vm_size;
> +   uint32_t pcie_gen_mask;
> +
> +   if (dev_info == NULL)
> +   return -EINVAL;
> +
> +   dev_info->device_id = adev->pdev->device;
> +   dev_info->chip_rev = adev->rev_id;
> +   dev_info->external_rev = adev->external_rev_id;
> +   dev_info->pci_rev = adev->pdev->revision;
> +   dev_info->family = adev->family;
> +   dev_info->num_shader_engines = adev->gfx.config.max_shader_engines;
> +   dev_info->num_shader_arrays_per_engine = 
> adev->gfx.config.max_sh_per_se;
> +   /* return all clocks in KHz */
> +   dev_info->gpu_counter_freq = amdgpu_asic_get_xclk(adev) * 10;
> +   if (adev->pm.dpm_enabled) {
> +   dev_info->max_engine_clock = amdgpu_dpm_get_sclk(adev, false) 
> * 10;
> +   dev_info->max_memory_clock = amdgpu_dpm_get_mclk(adev, false) 
> * 10;
> +   dev_info->min_engine_clock = amdgpu_dpm_get_sclk(adev, true) 
> * 10;
> +   

[PATCH v2] drm/amdgpu: refactor code to reuse system information

2024-03-19 Thread Sunil Khatri
Refactor the code so debugfs and devcoredump can reuse
the common information and avoid unnecessary copy of it.

created a new file which would be the right place to
hold functions which will be used between ioctl, debugfs
and devcoredump.

Cc: Christian König 
Cc: Alex Deucher 
Signed-off-by: Sunil Khatri 
---
 drivers/gpu/drm/amd/amdgpu/Makefile |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu.h |   1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c | 151 
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 118 +--
 4 files changed, 157 insertions(+), 115 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c

diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile 
b/drivers/gpu/drm/amd/amdgpu/Makefile
index 4536c8ad0e11..05d34f4b18f5 100644
--- a/drivers/gpu/drm/amd/amdgpu/Makefile
+++ b/drivers/gpu/drm/amd/amdgpu/Makefile
@@ -80,7 +80,7 @@ amdgpu-y += amdgpu_device.o amdgpu_doorbell_mgr.o 
amdgpu_kms.o \
amdgpu_umc.o smu_v11_0_i2c.o amdgpu_fru_eeprom.o amdgpu_rap.o \
amdgpu_fw_attestation.o amdgpu_securedisplay.o \
amdgpu_eeprom.o amdgpu_mca.o amdgpu_psp_ta.o amdgpu_lsdma.o \
-   amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o
+   amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o 
amdgpu_devinfo.o
 
 amdgpu-$(CONFIG_PROC_FS) += amdgpu_fdinfo.o
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 9c62552bec34..0267870aa9b1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1609,4 +1609,5 @@ extern const struct attribute_group 
amdgpu_vram_mgr_attr_group;
 extern const struct attribute_group amdgpu_gtt_mgr_attr_group;
 extern const struct attribute_group amdgpu_flash_attr_group;
 
+int amdgpu_device_info(struct amdgpu_device *adev, struct 
drm_amdgpu_info_device *dev_info);
 #endif
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c
new file mode 100644
index ..fdcbc1984031
--- /dev/null
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c
@@ -0,0 +1,151 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright 2024 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "amdgpu.h"
+#include "amd_pcie.h"
+
+#include 
+
+int amdgpu_device_info(struct amdgpu_device *adev, struct 
drm_amdgpu_info_device *dev_info)
+{
+   int ret;
+   uint64_t vm_size;
+   uint32_t pcie_gen_mask;
+
+   if (dev_info == NULL)
+   return -EINVAL;
+
+   dev_info->device_id = adev->pdev->device;
+   dev_info->chip_rev = adev->rev_id;
+   dev_info->external_rev = adev->external_rev_id;
+   dev_info->pci_rev = adev->pdev->revision;
+   dev_info->family = adev->family;
+   dev_info->num_shader_engines = adev->gfx.config.max_shader_engines;
+   dev_info->num_shader_arrays_per_engine = adev->gfx.config.max_sh_per_se;
+   /* return all clocks in KHz */
+   dev_info->gpu_counter_freq = amdgpu_asic_get_xclk(adev) * 10;
+   if (adev->pm.dpm_enabled) {
+   dev_info->max_engine_clock = amdgpu_dpm_get_sclk(adev, false) * 
10;
+   dev_info->max_memory_clock = amdgpu_dpm_get_mclk(adev, false) * 
10;
+   dev_info->min_engine_clock = amdgpu_dpm_get_sclk(adev, true) * 
10;
+   dev_info->min_memory_clock = amdgpu_dpm_get_mclk(adev, true) * 
10;
+   } else {
+   dev_info->max_engine_clock =
+   dev_info->min_engine_clock =
+   adev->clock.default_sclk * 10;
+   dev_info->max_memory_clock =
+   dev_info->min_memory_clock =
+   adev->clock.default_mclk * 10;
+   }
+   dev_info->enabled_rb_pipes_mask = adev->gfx.config.backend_enable_mask;
+   dev_info->num_rb_pipes = 

Re: [PATCH v2] drm: Fix drm_fixp2int_round() making it add 0.5

2024-03-19 Thread Melissa Wen
On 03/17, Maíra Canal wrote:
> Hi Melissa,
> 
> On 3/17/24 14:50, Melissa Wen wrote:
> > On 03/16, Arthur Grillo wrote:
> > > As well noted by Pekka[1], the rounding of drm_fixp2int_round is wrong.
> > > To round a number, you need to add 0.5 to the number and floor that,
> > > drm_fixp2int_round() is adding 0.076. Make it add 0.5.
> > > 
> > > [1]: 
> > > https://lore.kernel.org/all/20240301135327.22efe0dd.pekka.paala...@collabora.com/
> > > 
> > > Fixes: 8b25320887d7 ("drm: Add fixed-point helper to get rounded integer 
> > > values")
> > > Suggested-by: Pekka Paalanen 
> > > Reviewed-by: Harry Wentland 
> > > Signed-off-by: Arthur Grillo 
> > 
> > Great, thanks!
> > 
> > Reviewed-by: Melissa Wen 
> > 
> > I'll apply to drm-misc-next.
> 
> Shouldn't this patch be applied in drm-misc-fixes?

After discussions on IRC, I applied to drm-misc-next-fixes, since we are
in a merge window.

Thanks,

Melissa

> 
> Best Regards,
> - Maíra
> 
> > 
> > Melissa
> > 
> > > ---
> > > Changes in v2:
> > > - Add Fixes tag (Melissa Wen)
> > > - Remove DRM_FIXED_POINT_HALF (Melissa Wen)
> > > - Link to v1: 
> > > https://lore.kernel.org/all/20240306-louis-vkms-conv-v1-1-5bfe7d129...@riseup.net/
> > > ---
> > >   include/drm/drm_fixed.h | 3 +--
> > >   1 file changed, 1 insertion(+), 2 deletions(-)
> > > 
> > > diff --git a/include/drm/drm_fixed.h b/include/drm/drm_fixed.h
> > > index 0c9f917a4d4b..81572d32db0c 100644
> > > --- a/include/drm/drm_fixed.h
> > > +++ b/include/drm/drm_fixed.h
> > > @@ -71,7 +71,6 @@ static inline u32 dfixed_div(fixed20_12 A, fixed20_12 B)
> > >   }
> > >   #define DRM_FIXED_POINT 32
> > > -#define DRM_FIXED_POINT_HALF 16
> > >   #define DRM_FIXED_ONE   (1ULL << DRM_FIXED_POINT)
> > >   #define DRM_FIXED_DECIMAL_MASK  (DRM_FIXED_ONE - 1)
> > >   #define DRM_FIXED_DIGITS_MASK   (~DRM_FIXED_DECIMAL_MASK)
> > > @@ -90,7 +89,7 @@ static inline int drm_fixp2int(s64 a)
> > >   static inline int drm_fixp2int_round(s64 a)
> > >   {
> > > - return drm_fixp2int(a + (1 << (DRM_FIXED_POINT_HALF - 1)));
> > > + return drm_fixp2int(a + DRM_FIXED_ONE / 2);
> > >   }
> > >   static inline int drm_fixp2int_ceil(s64 a)
> > > 
> > > ---
> > > base-commit: f89632a9e5fa6c4787c14458cd42a9ef42025434
> > > change-id: 20240315-drm_fixed-c680ba078ecb
> > > 
> > > Best regards,
> > > -- 
> > > Arthur Grillo 
> > > 


Re: [PATCH] drm/amdgpu: refactor code to reuse system information

2024-03-19 Thread Alex Deucher
On Tue, Mar 19, 2024 at 10:22 AM Lazar, Lijo  wrote:
>
>
>
> On 3/19/2024 7:27 PM, Khatri, Sunil wrote:
> >
> > On 3/19/2024 7:19 PM, Lazar, Lijo wrote:
> >>
> >> On 3/19/2024 6:02 PM, Sunil Khatri wrote:
> >>> Refactor the code so debugfs and devcoredump can reuse
> >>> the common information and avoid unnecessary copy of it.
> >>>
> >>> created a new file which would be the right place to
> >>> hold functions which will be used between sysfs, debugfs
> >>> and devcoredump.
> >>>
> >>> Cc: Christian König 
> >>> Cc: Alex Deucher 
> >>> Signed-off-by: Sunil Khatri 
> >>> ---
> >>>   drivers/gpu/drm/amd/amdgpu/Makefile |   2 +-
> >>>   drivers/gpu/drm/amd/amdgpu/amdgpu.h |   1 +
> >>>   drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c | 151 
> >>>   drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 118 +--
> >>>   4 files changed, 157 insertions(+), 115 deletions(-)
> >>>   create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c
> >>>
> >>> diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile
> >>> b/drivers/gpu/drm/amd/amdgpu/Makefile
> >>> index 4536c8ad0e11..05d34f4b18f5 100644
> >>> --- a/drivers/gpu/drm/amd/amdgpu/Makefile
> >>> +++ b/drivers/gpu/drm/amd/amdgpu/Makefile
> >>> @@ -80,7 +80,7 @@ amdgpu-y += amdgpu_device.o amdgpu_doorbell_mgr.o
> >>> amdgpu_kms.o \
> >>>   amdgpu_umc.o smu_v11_0_i2c.o amdgpu_fru_eeprom.o amdgpu_rap.o \
> >>>   amdgpu_fw_attestation.o amdgpu_securedisplay.o \
> >>>   amdgpu_eeprom.o amdgpu_mca.o amdgpu_psp_ta.o amdgpu_lsdma.o \
> >>> -amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o
> >>> +amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o
> >>> amdgpu_devinfo.o
> >>> amdgpu-$(CONFIG_PROC_FS) += amdgpu_fdinfo.o
> >>>   diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> >>> b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> >>> index 9c62552bec34..0267870aa9b1 100644
> >>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> >>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> >>> @@ -1609,4 +1609,5 @@ extern const struct attribute_group
> >>> amdgpu_vram_mgr_attr_group;
> >>>   extern const struct attribute_group amdgpu_gtt_mgr_attr_group;
> >>>   extern const struct attribute_group amdgpu_flash_attr_group;
> >>>   +int amdgpu_device_info(struct amdgpu_device *adev, struct
> >>> drm_amdgpu_info_device *dev_info);
> >>>   #endif
> >>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c
> >>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c
> >>> new file mode 100644
> >>> index ..d2c15a1dcb0d
> >>> --- /dev/null
> >>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c
> >>> @@ -0,0 +1,151 @@
> >>> +// SPDX-License-Identifier: MIT
> >>> +/*
> >>> + * Copyright 2024 Advanced Micro Devices, Inc.
> >>> + *
> >>> + * Permission is hereby granted, free of charge, to any person
> >>> obtaining a
> >>> + * copy of this software and associated documentation files (the
> >>> "Software"),
> >>> + * to deal in the Software without restriction, including without
> >>> limitation
> >>> + * the rights to use, copy, modify, merge, publish, distribute,
> >>> sublicense,
> >>> + * and/or sell copies of the Software, and to permit persons to whom
> >>> the
> >>> + * Software is furnished to do so, subject to the following conditions:
> >>> + *
> >>> + * The above copyright notice and this permission notice shall be
> >>> included in
> >>> + * all copies or substantial portions of the Software.
> >>> + *
> >>> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> >>> EXPRESS OR
> >>> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> >>> MERCHANTABILITY,
> >>> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO
> >>> EVENT SHALL
> >>> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM,
> >>> DAMAGES OR
> >>> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
> >>> OTHERWISE,
> >>> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
> >>> USE OR
> >>> + * OTHER DEALINGS IN THE SOFTWARE.
> >>> + *
> >>> + */
> >>> +
> >>> +#include "amdgpu.h"
> >>> +#include "amd_pcie.h"
> >>> +
> >>> +#include 
> >>> +
> >>> +int amdgpu_device_info(struct amdgpu_device *adev, struct
> >>> drm_amdgpu_info_device *dev_info)
> >>> +{
> >>> +int ret;
> >>> +uint64_t vm_size;
> >>> +uint32_t pcie_gen_mask;
> >>> +
> >>> +if (dev_info == NULL)
> >>> +return -EINVAL;
> >>> +
> >>> +dev_info->device_id = adev->pdev->device;
> >>> +dev_info->chip_rev = adev->rev_id;
> >>> +dev_info->external_rev = adev->external_rev_id;
> >>> +dev_info->pci_rev = adev->pdev->revision;
> >>> +dev_info->family = adev->family;
> >>> +dev_info->num_shader_engines = adev->gfx.config.max_shader_engines;
> >>> +dev_info->num_shader_arrays_per_engine =
> >>> adev->gfx.config.max_sh_per_se;
> >>> +/* return all clocks in KHz */
> >>> +dev_info->gpu_counter_freq = amdgpu_asic_get_xclk(adev) * 10;
> >>> +if (adev->pm.dpm_enabled) {

Re: [PATCH] drm/amdgpu: refactor code to reuse system information

2024-03-19 Thread Khatri, Sunil


On 3/19/2024 7:43 PM, Lazar, Lijo wrote:


On 3/19/2024 7:27 PM, Khatri, Sunil wrote:

On 3/19/2024 7:19 PM, Lazar, Lijo wrote:

On 3/19/2024 6:02 PM, Sunil Khatri wrote:

Refactor the code so debugfs and devcoredump can reuse
the common information and avoid unnecessary copy of it.

created a new file which would be the right place to
hold functions which will be used between sysfs, debugfs
and devcoredump.

Cc: Christian König
Cc: Alex Deucher
Signed-off-by: Sunil Khatri
---
   drivers/gpu/drm/amd/amdgpu/Makefile |   2 +-
   drivers/gpu/drm/amd/amdgpu/amdgpu.h |   1 +
   drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c | 151 
   drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 118 +--
   4 files changed, 157 insertions(+), 115 deletions(-)
   create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c

diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile
b/drivers/gpu/drm/amd/amdgpu/Makefile
index 4536c8ad0e11..05d34f4b18f5 100644
--- a/drivers/gpu/drm/amd/amdgpu/Makefile
+++ b/drivers/gpu/drm/amd/amdgpu/Makefile
@@ -80,7 +80,7 @@ amdgpu-y += amdgpu_device.o amdgpu_doorbell_mgr.o
amdgpu_kms.o \
   amdgpu_umc.o smu_v11_0_i2c.o amdgpu_fru_eeprom.o amdgpu_rap.o \
   amdgpu_fw_attestation.o amdgpu_securedisplay.o \
   amdgpu_eeprom.o amdgpu_mca.o amdgpu_psp_ta.o amdgpu_lsdma.o \
-    amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o
+    amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o
amdgpu_devinfo.o
     amdgpu-$(CONFIG_PROC_FS) += amdgpu_fdinfo.o
   diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 9c62552bec34..0267870aa9b1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1609,4 +1609,5 @@ extern const struct attribute_group
amdgpu_vram_mgr_attr_group;
   extern const struct attribute_group amdgpu_gtt_mgr_attr_group;
   extern const struct attribute_group amdgpu_flash_attr_group;
   +int amdgpu_device_info(struct amdgpu_device *adev, struct
drm_amdgpu_info_device *dev_info);
   #endif
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c
new file mode 100644
index ..d2c15a1dcb0d
--- /dev/null
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c
@@ -0,0 +1,151 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright 2024 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person
obtaining a
+ * copy of this software and associated documentation files (the
"Software"),
+ * to deal in the Software without restriction, including without
limitation
+ * the rights to use, copy, modify, merge, publish, distribute,
sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom
the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO
EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM,
DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "amdgpu.h"
+#include "amd_pcie.h"
+
+#include 
+
+int amdgpu_device_info(struct amdgpu_device *adev, struct
drm_amdgpu_info_device *dev_info)
+{
+    int ret;
+    uint64_t vm_size;
+    uint32_t pcie_gen_mask;
+
+    if (dev_info == NULL)
+    return -EINVAL;
+
+    dev_info->device_id = adev->pdev->device;
+    dev_info->chip_rev = adev->rev_id;
+    dev_info->external_rev = adev->external_rev_id;
+    dev_info->pci_rev = adev->pdev->revision;
+    dev_info->family = adev->family;
+    dev_info->num_shader_engines = adev->gfx.config.max_shader_engines;
+    dev_info->num_shader_arrays_per_engine =
adev->gfx.config.max_sh_per_se;
+    /* return all clocks in KHz */
+    dev_info->gpu_counter_freq = amdgpu_asic_get_xclk(adev) * 10;
+    if (adev->pm.dpm_enabled) {
+    dev_info->max_engine_clock = amdgpu_dpm_get_sclk(adev,
false) * 10;
+    dev_info->max_memory_clock = amdgpu_dpm_get_mclk(adev,
false) * 10;
+    dev_info->min_engine_clock = amdgpu_dpm_get_sclk(adev, true)
* 10;
+    dev_info->min_memory_clock = amdgpu_dpm_get_mclk(adev, true)
* 10;
+    } else {
+    dev_info->max_engine_clock =
+    dev_info->min_engine_clock =
+    adev->clock.default_sclk * 10;
+    dev_info->max_memory_clock =
+    dev_info->min_memory_clock =
+    adev->clock.default_mclk * 10;
+    }
+    dev_info->enabled_rb_pipes_mask =
adev->gfx.config.backend_enable_mask;
+    dev_info->num_rb_pipes = 

Re: [PATCH] drm/Makefile: Move tiny drivers before native drivers

2024-03-19 Thread Huacai Chen
Hi, Jaak,

On Mon, Mar 18, 2024 at 11:42 PM Jaak Ristioja  wrote:
>
> Hi Huacai,
>
> Uh, no, sorry, I did not get to test such changes. From what Thomas
> wrote I presumed that this got fixed and no further action would be
> required.
>
> To speed things up I would appreciate it if you provided a patch. As I
> worked around the problem for the end user by changing the kernel
> configuration, I have long forgotten the exact details. It would
> otherwise probably take me a while to understand what and where you
> propose to change exactly.
>
> Also, do you want me to test it on some newer kernel or should I
> re-download the 6.5.# version sources?
Yes, it is better to use 6.5, you can simply change the last line of
drivers/firmware/sysfb.c to fs_initcall(sysfb_init), So no patch
needed.

And to Thomas,

I'm sorry that reverting 60aebc95594 solve Jaak's problem, but my
original problem exist (at least in 6.5), and I want to know the
result of the above experiment to understand what happens.

Huacai

>
>
> Best regards,
> Jaak
>
> On 18.03.24 16:43, Huacai Chen wrote:
> > Hi, Jaak,
> >
> > I'm still here as a boring man. :)
> > Have you ever tested whether using "fs_initcall(sysfb_init)" works
> > fine on your machine?
> >
> > Huacai
> >
> > On Wed, Jan 24, 2024 at 5:21 AM Jaak Ristioja  wrote:
> >>
> >> Hi,
> >>
> >> I apologize for not finding the time to test this earlier.
> >>
> >> On 11.12.23 05:08, Huacai Chen wrote:
> >>> And Jaak, could you please test with the below patch (but keep the
> >>> original order in Makefile) and then give me the dmesg output?
> >>>
> >>> diff --git a/drivers/video/aperture.c b/drivers/video/aperture.c
> >>> index 561be8feca96..cc2e39fb98f5 100644
> >>> --- a/drivers/video/aperture.c
> >>> +++ b/drivers/video/aperture.c
> >>> @@ -350,21 +350,29 @@ int
> >>> aperture_remove_conflicting_pci_devices(struct pci_dev *pdev, const
> >>> char *na
> >>>   resource_size_t base, size;
> >>>   int bar, ret = 0;
> >>>
> >>> -   if (pdev == vga_default_device())
> >>> +   printk("DEBUG: remove 1\n");
> >>> +
> >>> +   if (pdev == vga_default_device()) {
> >>> +   printk("DEBUG: primary = true\n");
> >>>   primary = true;
> >>> +   }
> >>>
> >>> -   if (primary)
> >>> +   if (primary) {
> >>> +   printk("DEBUG: disable sysfb\n");
> >>>   sysfb_disable();
> >>> +   }
> >>>
> >>>   for (bar = 0; bar < PCI_STD_NUM_BARS; ++bar) {
> >>>   if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM))
> >>>   continue;
> >>>
> >>> +   printk("DEBUG: remove 2\n");
> >>>   base = pci_resource_start(pdev, bar);
> >>>   size = pci_resource_len(pdev, bar);
> >>>   aperture_detach_devices(base, size);
> >>>   }
> >>>
> >>> +   printk("DEBUG: remove 3\n");
> >>>   /*
> >>>* If this is the primary adapter, there could be a VGA device
> >>>* that consumes the VGA framebuffer I/O range. Remove this
> >>>
> >>> [1]  
> >>> https://lore.kernel.org/lkml/170222766284.86103.11020060769330721...@leemhuis.info/T/#u
> >>
> >> Copy-pasting this from the e-mail body didn't work well, but I applied
> >> the changes manually to a 6.5.9 kernel without any of the other patches.
> >> Here's the relevant dmesg output on the Lenovo L570:
> >>
> >> ...
> >> [2.953405] ACPI: bus type drm_connector registered
> >> [2.954014] i915 :00:02.0: [drm] VT-d active for gfx access
> >> [2.954018] DEBUG: remove 1
> >> [2.954020] DEBUG: remove 2
> >> [2.954021] DEBUG: remove 2
> >> [2.954023] DEBUG: remove 3
> >> [2.954029] resource: resource sanity check: requesting [mem
> >> 0xe000-0xefff], which spans more than BOOTFB
> >> [mem 0xe000-0xe012bfff]
> >> [2.954035] caller i915_ggtt_init_hw+0x88/0x120 mapping multiple BARs
> >> [2.954061] i915 :00:02.0: [drm] Using Transparent Hugepages
> >> [2.955103] Loading firmware: i915/kbl_dmc_ver1_04.bin
> >> [2.955384] i915 :00:02.0: [drm] Finished loading DMC firmware
> >> i915/kbl_dmc_ver1_04.bin (v1.4)
> >> ...
> >> [4.145013] [drm] Initialized i915 1.6.0 20201103 for :00:02.0 on
> >> minor 0
> >> [4.147101] ACPI: video: Video Device [GFX0] (multi-head: yes  rom:
> >> no  post: no)
> >> [4.147244] input: Video Bus as
> >> /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/LNXVIDEO:00/input/input4
> >> [4.147410] [drm] Initialized vgem 1.0.0 20120112 for vgem on minor 1
> >> [4.147420] usbcore: registered new interface driver udl
> >> [4.147500] [drm] Initialized simpledrm 1.0.0 20200625 for
> >> simple-framebuffer.0 on minor 2
> >> [4.148643] Console: switching to colour frame buffer device 80x30
> >> [4.153216] simple-framebuffer simple-framebuffer.0: [drm] fb0:
> >> simpledrmdrmfb frame buffer device
> >> [4.154043] loop: module loaded

Re: [PATCH] drm/amdgpu: refactor code to reuse system information

2024-03-19 Thread Lazar, Lijo



On 3/19/2024 7:27 PM, Khatri, Sunil wrote:
> 
> On 3/19/2024 7:19 PM, Lazar, Lijo wrote:
>>
>> On 3/19/2024 6:02 PM, Sunil Khatri wrote:
>>> Refactor the code so debugfs and devcoredump can reuse
>>> the common information and avoid unnecessary copy of it.
>>>
>>> created a new file which would be the right place to
>>> hold functions which will be used between sysfs, debugfs
>>> and devcoredump.
>>>
>>> Cc: Christian König 
>>> Cc: Alex Deucher 
>>> Signed-off-by: Sunil Khatri 
>>> ---
>>>   drivers/gpu/drm/amd/amdgpu/Makefile |   2 +-
>>>   drivers/gpu/drm/amd/amdgpu/amdgpu.h |   1 +
>>>   drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c | 151 
>>>   drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 118 +--
>>>   4 files changed, 157 insertions(+), 115 deletions(-)
>>>   create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile
>>> b/drivers/gpu/drm/amd/amdgpu/Makefile
>>> index 4536c8ad0e11..05d34f4b18f5 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/Makefile
>>> +++ b/drivers/gpu/drm/amd/amdgpu/Makefile
>>> @@ -80,7 +80,7 @@ amdgpu-y += amdgpu_device.o amdgpu_doorbell_mgr.o
>>> amdgpu_kms.o \
>>>   amdgpu_umc.o smu_v11_0_i2c.o amdgpu_fru_eeprom.o amdgpu_rap.o \
>>>   amdgpu_fw_attestation.o amdgpu_securedisplay.o \
>>>   amdgpu_eeprom.o amdgpu_mca.o amdgpu_psp_ta.o amdgpu_lsdma.o \
>>> -    amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o
>>> +    amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o
>>> amdgpu_devinfo.o
>>>     amdgpu-$(CONFIG_PROC_FS) += amdgpu_fdinfo.o
>>>   diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
>>> index 9c62552bec34..0267870aa9b1 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
>>> @@ -1609,4 +1609,5 @@ extern const struct attribute_group
>>> amdgpu_vram_mgr_attr_group;
>>>   extern const struct attribute_group amdgpu_gtt_mgr_attr_group;
>>>   extern const struct attribute_group amdgpu_flash_attr_group;
>>>   +int amdgpu_device_info(struct amdgpu_device *adev, struct
>>> drm_amdgpu_info_device *dev_info);
>>>   #endif
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c
>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c
>>> new file mode 100644
>>> index ..d2c15a1dcb0d
>>> --- /dev/null
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c
>>> @@ -0,0 +1,151 @@
>>> +// SPDX-License-Identifier: MIT
>>> +/*
>>> + * Copyright 2024 Advanced Micro Devices, Inc.
>>> + *
>>> + * Permission is hereby granted, free of charge, to any person
>>> obtaining a
>>> + * copy of this software and associated documentation files (the
>>> "Software"),
>>> + * to deal in the Software without restriction, including without
>>> limitation
>>> + * the rights to use, copy, modify, merge, publish, distribute,
>>> sublicense,
>>> + * and/or sell copies of the Software, and to permit persons to whom
>>> the
>>> + * Software is furnished to do so, subject to the following conditions:
>>> + *
>>> + * The above copyright notice and this permission notice shall be
>>> included in
>>> + * all copies or substantial portions of the Software.
>>> + *
>>> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
>>> EXPRESS OR
>>> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
>>> MERCHANTABILITY,
>>> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO
>>> EVENT SHALL
>>> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM,
>>> DAMAGES OR
>>> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
>>> OTHERWISE,
>>> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
>>> USE OR
>>> + * OTHER DEALINGS IN THE SOFTWARE.
>>> + *
>>> + */
>>> +
>>> +#include "amdgpu.h"
>>> +#include "amd_pcie.h"
>>> +
>>> +#include 
>>> +
>>> +int amdgpu_device_info(struct amdgpu_device *adev, struct
>>> drm_amdgpu_info_device *dev_info)
>>> +{
>>> +    int ret;
>>> +    uint64_t vm_size;
>>> +    uint32_t pcie_gen_mask;
>>> +
>>> +    if (dev_info == NULL)
>>> +    return -EINVAL;
>>> +
>>> +    dev_info->device_id = adev->pdev->device;
>>> +    dev_info->chip_rev = adev->rev_id;
>>> +    dev_info->external_rev = adev->external_rev_id;
>>> +    dev_info->pci_rev = adev->pdev->revision;
>>> +    dev_info->family = adev->family;
>>> +    dev_info->num_shader_engines = adev->gfx.config.max_shader_engines;
>>> +    dev_info->num_shader_arrays_per_engine =
>>> adev->gfx.config.max_sh_per_se;
>>> +    /* return all clocks in KHz */
>>> +    dev_info->gpu_counter_freq = amdgpu_asic_get_xclk(adev) * 10;
>>> +    if (adev->pm.dpm_enabled) {
>>> +    dev_info->max_engine_clock = amdgpu_dpm_get_sclk(adev,
>>> false) * 10;
>>> +    dev_info->max_memory_clock = amdgpu_dpm_get_mclk(adev,
>>> false) * 10;
>>> +    dev_info->min_engine_clock = amdgpu_dpm_get_sclk(adev, true)
>>> * 10;
>>> +    

Re: [PATCH] drm/amdgpu: refactor code to reuse system information

2024-03-19 Thread Khatri, Sunil



On 3/19/2024 7:19 PM, Lazar, Lijo wrote:


On 3/19/2024 6:02 PM, Sunil Khatri wrote:

Refactor the code so debugfs and devcoredump can reuse
the common information and avoid unnecessary copy of it.

created a new file which would be the right place to
hold functions which will be used between sysfs, debugfs
and devcoredump.

Cc: Christian König 
Cc: Alex Deucher 
Signed-off-by: Sunil Khatri 
---
  drivers/gpu/drm/amd/amdgpu/Makefile |   2 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu.h |   1 +
  drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c | 151 
  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 118 +--
  4 files changed, 157 insertions(+), 115 deletions(-)
  create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c

diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile 
b/drivers/gpu/drm/amd/amdgpu/Makefile
index 4536c8ad0e11..05d34f4b18f5 100644
--- a/drivers/gpu/drm/amd/amdgpu/Makefile
+++ b/drivers/gpu/drm/amd/amdgpu/Makefile
@@ -80,7 +80,7 @@ amdgpu-y += amdgpu_device.o amdgpu_doorbell_mgr.o 
amdgpu_kms.o \
amdgpu_umc.o smu_v11_0_i2c.o amdgpu_fru_eeprom.o amdgpu_rap.o \
amdgpu_fw_attestation.o amdgpu_securedisplay.o \
amdgpu_eeprom.o amdgpu_mca.o amdgpu_psp_ta.o amdgpu_lsdma.o \
-   amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o
+   amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o 
amdgpu_devinfo.o
  
  amdgpu-$(CONFIG_PROC_FS) += amdgpu_fdinfo.o
  
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h

index 9c62552bec34..0267870aa9b1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1609,4 +1609,5 @@ extern const struct attribute_group 
amdgpu_vram_mgr_attr_group;
  extern const struct attribute_group amdgpu_gtt_mgr_attr_group;
  extern const struct attribute_group amdgpu_flash_attr_group;
  
+int amdgpu_device_info(struct amdgpu_device *adev, struct drm_amdgpu_info_device *dev_info);

  #endif
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c
new file mode 100644
index ..d2c15a1dcb0d
--- /dev/null
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c
@@ -0,0 +1,151 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright 2024 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "amdgpu.h"
+#include "amd_pcie.h"
+
+#include 
+
+int amdgpu_device_info(struct amdgpu_device *adev, struct 
drm_amdgpu_info_device *dev_info)
+{
+   int ret;
+   uint64_t vm_size;
+   uint32_t pcie_gen_mask;
+
+   if (dev_info == NULL)
+   return -EINVAL;
+
+   dev_info->device_id = adev->pdev->device;
+   dev_info->chip_rev = adev->rev_id;
+   dev_info->external_rev = adev->external_rev_id;
+   dev_info->pci_rev = adev->pdev->revision;
+   dev_info->family = adev->family;
+   dev_info->num_shader_engines = adev->gfx.config.max_shader_engines;
+   dev_info->num_shader_arrays_per_engine = adev->gfx.config.max_sh_per_se;
+   /* return all clocks in KHz */
+   dev_info->gpu_counter_freq = amdgpu_asic_get_xclk(adev) * 10;
+   if (adev->pm.dpm_enabled) {
+   dev_info->max_engine_clock = amdgpu_dpm_get_sclk(adev, false) * 
10;
+   dev_info->max_memory_clock = amdgpu_dpm_get_mclk(adev, false) * 
10;
+   dev_info->min_engine_clock = amdgpu_dpm_get_sclk(adev, true) * 
10;
+   dev_info->min_memory_clock = amdgpu_dpm_get_mclk(adev, true) * 
10;
+   } else {
+   dev_info->max_engine_clock =
+   dev_info->min_engine_clock =
+   adev->clock.default_sclk * 10;
+   dev_info->max_memory_clock =
+   dev_info->min_memory_clock =
+   adev->clock.default_mclk * 10;
+   }
+   

Re: [PATCH v9 2/3] drm/amdgpu: Enable clear page functionality

2024-03-19 Thread Paneer Selvam, Arunpravin

Hi Christian,

On 3/19/2024 7:17 PM, Christian König wrote:

Am 19.03.24 um 12:41 schrieb Paneer Selvam, Arunpravin:

Hi Christian,

On 3/19/2024 3:58 PM, Christian König wrote:



Am 18.03.24 um 22:40 schrieb Arunpravin Paneer Selvam:

Add clear page support in vram memory region.

v1(Christian):
   - Dont handle clear page as TTM flag since when moving the BO back
 in from GTT again we don't need that.
   - Make a specialized version of amdgpu_fill_buffer() which only
 clears the VRAM areas which are not already cleared
   - Drop the TTM_PL_FLAG_WIPE_ON_RELEASE check in
 amdgpu_object.c

v2:
   - Modify the function name amdgpu_ttm_* (Alex)
   - Drop the delayed parameter (Christian)
   - handle amdgpu_res_cleared() just above the size
 calculation (Christian)
   - Use AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE for clearing the 
buffers

 in the free path to properly wait for fences etc.. (Christian)

v3(Christian):
   - Remove buffer clear code in VRAM manager instead change the
 AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE handling to set
 the DRM_BUDDY_CLEARED flag.
   - Remove ! from amdgpu_res_cleared() check.

Signed-off-by: Arunpravin Paneer Selvam 


Suggested-by: Christian König 
Acked-by: Felix Kuehling 


Just a few nit picks below, but in general already looks good to me.


---
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c    | 22 ---
  .../gpu/drm/amd/amdgpu/amdgpu_res_cursor.h    | 25 
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c   | 61 
++-

  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h   |  5 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c  |  6 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.h  |  5 ++
  6 files changed, 111 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c

index 8bc79924d171..c92d92b28a57 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -39,6 +39,7 @@
  #include "amdgpu.h"
  #include "amdgpu_trace.h"
  #include "amdgpu_amdkfd.h"
+#include "amdgpu_vram_mgr.h"
    /**
   * DOC: amdgpu_object
@@ -601,8 +602,7 @@ int amdgpu_bo_create(struct amdgpu_device *adev,
  if (!amdgpu_bo_support_uswc(bo->flags))
  bo->flags &= ~AMDGPU_GEM_CREATE_CPU_GTT_USWC;
  -    if (adev->ras_enabled)
-    bo->flags |= AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE;
+    bo->flags |= AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE;
    bo->tbo.bdev = >mman.bdev;
  if (bp->domain & (AMDGPU_GEM_DOMAIN_GWS | AMDGPU_GEM_DOMAIN_OA |
@@ -632,15 +632,17 @@ int amdgpu_bo_create(struct amdgpu_device *adev,
    if (bp->flags & AMDGPU_GEM_CREATE_VRAM_CLEARED &&
  bo->tbo.resource->mem_type == TTM_PL_VRAM) {
-    struct dma_fence *fence;
+    struct dma_fence *fence = NULL;
  -    r = amdgpu_fill_buffer(bo, 0, bo->tbo.base.resv, , 
true);

+    r = amdgpu_ttm_clear_buffer(bo, bo->tbo.base.resv, );
  if (unlikely(r))
  goto fail_unreserve;
  -    dma_resv_add_fence(bo->tbo.base.resv, fence,
-   DMA_RESV_USAGE_KERNEL);
-    dma_fence_put(fence);
+    if (fence) {
+    dma_resv_add_fence(bo->tbo.base.resv, fence,
+   DMA_RESV_USAGE_KERNEL);
+    dma_fence_put(fence);
+    }
  }
  if (!bp->resv)
  amdgpu_bo_unreserve(bo);
@@ -1365,8 +1367,12 @@ void amdgpu_bo_release_notify(struct 
ttm_buffer_object *bo)

  if (WARN_ON_ONCE(!dma_resv_trylock(bo->base.resv)))
  return;
  -    r = amdgpu_fill_buffer(abo, AMDGPU_POISON, bo->base.resv, 
, true);

+    r = amdgpu_fill_buffer(abo, 0, bo->base.resv, , true);
  if (!WARN_ON(r)) {
+    struct amdgpu_vram_mgr_resource *vres;
+
+    vres = to_amdgpu_vram_mgr_resource(bo->resource);
+    vres->flags |= DRM_BUDDY_CLEARED;


Those lines should probably be in the VRAM manager.
This flag is set based on the amdgpu_fill_buffer() function return 
value, can we move the amdgpu_fill_buffer() function call and
DRM_BUDDY_CLEARED flag set lines to amdgpu_vram_mgr_del() in VRAM 
manager and does it require to wipe the VRAM buffers here as well

without setting the DRM_BUDDY_CLEARED.


No that won't work. The call to amdgpu_fill_buffer() *must* be here 
because that here is called before the resource is actually freed.


Only setting the vres->flags should probably be moved into 
amdgpu_vram_mgr.c.


So instead of calling that manually here just make a function for it 
to keep the code related to the buddy allocator in one place.

I got it, Thanks.

Regards,
Arun.


Regards,
Christian.




  amdgpu_bo_fence(abo, fence, false);
  dma_fence_put(fence);
  }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_res_cursor.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_res_cursor.h

index 381101d2bf05..50fcd86e1033 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_res_cursor.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_res_cursor.h
@@ 

Re: [PATCH] drm/amdgpu: refactor code to reuse system information

2024-03-19 Thread Lazar, Lijo



On 3/19/2024 6:02 PM, Sunil Khatri wrote:
> Refactor the code so debugfs and devcoredump can reuse
> the common information and avoid unnecessary copy of it.
> 
> created a new file which would be the right place to
> hold functions which will be used between sysfs, debugfs
> and devcoredump.
> 
> Cc: Christian König 
> Cc: Alex Deucher 
> Signed-off-by: Sunil Khatri 
> ---
>  drivers/gpu/drm/amd/amdgpu/Makefile |   2 +-
>  drivers/gpu/drm/amd/amdgpu/amdgpu.h |   1 +
>  drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c | 151 
>  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 118 +--
>  4 files changed, 157 insertions(+), 115 deletions(-)
>  create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile 
> b/drivers/gpu/drm/amd/amdgpu/Makefile
> index 4536c8ad0e11..05d34f4b18f5 100644
> --- a/drivers/gpu/drm/amd/amdgpu/Makefile
> +++ b/drivers/gpu/drm/amd/amdgpu/Makefile
> @@ -80,7 +80,7 @@ amdgpu-y += amdgpu_device.o amdgpu_doorbell_mgr.o 
> amdgpu_kms.o \
>   amdgpu_umc.o smu_v11_0_i2c.o amdgpu_fru_eeprom.o amdgpu_rap.o \
>   amdgpu_fw_attestation.o amdgpu_securedisplay.o \
>   amdgpu_eeprom.o amdgpu_mca.o amdgpu_psp_ta.o amdgpu_lsdma.o \
> - amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o
> + amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o 
> amdgpu_devinfo.o
>  
>  amdgpu-$(CONFIG_PROC_FS) += amdgpu_fdinfo.o
>  
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> index 9c62552bec34..0267870aa9b1 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> @@ -1609,4 +1609,5 @@ extern const struct attribute_group 
> amdgpu_vram_mgr_attr_group;
>  extern const struct attribute_group amdgpu_gtt_mgr_attr_group;
>  extern const struct attribute_group amdgpu_flash_attr_group;
>  
> +int amdgpu_device_info(struct amdgpu_device *adev, struct 
> drm_amdgpu_info_device *dev_info);
>  #endif
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c
> new file mode 100644
> index ..d2c15a1dcb0d
> --- /dev/null
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_devinfo.c
> @@ -0,0 +1,151 @@
> +// SPDX-License-Identifier: MIT
> +/*
> + * Copyright 2024 Advanced Micro Devices, Inc.
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
> + * OTHER DEALINGS IN THE SOFTWARE.
> + *
> + */
> +
> +#include "amdgpu.h"
> +#include "amd_pcie.h"
> +
> +#include 
> +
> +int amdgpu_device_info(struct amdgpu_device *adev, struct 
> drm_amdgpu_info_device *dev_info)
> +{
> + int ret;
> + uint64_t vm_size;
> + uint32_t pcie_gen_mask;
> +
> + if (dev_info == NULL)
> + return -EINVAL;
> +
> + dev_info->device_id = adev->pdev->device;
> + dev_info->chip_rev = adev->rev_id;
> + dev_info->external_rev = adev->external_rev_id;
> + dev_info->pci_rev = adev->pdev->revision;
> + dev_info->family = adev->family;
> + dev_info->num_shader_engines = adev->gfx.config.max_shader_engines;
> + dev_info->num_shader_arrays_per_engine = adev->gfx.config.max_sh_per_se;
> + /* return all clocks in KHz */
> + dev_info->gpu_counter_freq = amdgpu_asic_get_xclk(adev) * 10;
> + if (adev->pm.dpm_enabled) {
> + dev_info->max_engine_clock = amdgpu_dpm_get_sclk(adev, false) * 
> 10;
> + dev_info->max_memory_clock = amdgpu_dpm_get_mclk(adev, false) * 
> 10;
> + dev_info->min_engine_clock = amdgpu_dpm_get_sclk(adev, true) * 
> 10;
> + dev_info->min_memory_clock = amdgpu_dpm_get_mclk(adev, true) * 
> 10;
> + } else {
> + dev_info->max_engine_clock =
> + dev_info->min_engine_clock =
> + adev->clock.default_sclk * 10;
> + dev_info->max_memory_clock =
> + 

Re: [PATCH v9 2/3] drm/amdgpu: Enable clear page functionality

2024-03-19 Thread Christian König

Am 19.03.24 um 12:41 schrieb Paneer Selvam, Arunpravin:

Hi Christian,

On 3/19/2024 3:58 PM, Christian König wrote:



Am 18.03.24 um 22:40 schrieb Arunpravin Paneer Selvam:

Add clear page support in vram memory region.

v1(Christian):
   - Dont handle clear page as TTM flag since when moving the BO back
 in from GTT again we don't need that.
   - Make a specialized version of amdgpu_fill_buffer() which only
 clears the VRAM areas which are not already cleared
   - Drop the TTM_PL_FLAG_WIPE_ON_RELEASE check in
 amdgpu_object.c

v2:
   - Modify the function name amdgpu_ttm_* (Alex)
   - Drop the delayed parameter (Christian)
   - handle amdgpu_res_cleared() just above the size
 calculation (Christian)
   - Use AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE for clearing the 
buffers

 in the free path to properly wait for fences etc.. (Christian)

v3(Christian):
   - Remove buffer clear code in VRAM manager instead change the
 AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE handling to set
 the DRM_BUDDY_CLEARED flag.
   - Remove ! from amdgpu_res_cleared() check.

Signed-off-by: Arunpravin Paneer Selvam 


Suggested-by: Christian König 
Acked-by: Felix Kuehling 


Just a few nit picks below, but in general already looks good to me.


---
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c    | 22 ---
  .../gpu/drm/amd/amdgpu/amdgpu_res_cursor.h    | 25 
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c   | 61 
++-

  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h   |  5 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c  |  6 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.h  |  5 ++
  6 files changed, 111 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c

index 8bc79924d171..c92d92b28a57 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -39,6 +39,7 @@
  #include "amdgpu.h"
  #include "amdgpu_trace.h"
  #include "amdgpu_amdkfd.h"
+#include "amdgpu_vram_mgr.h"
    /**
   * DOC: amdgpu_object
@@ -601,8 +602,7 @@ int amdgpu_bo_create(struct amdgpu_device *adev,
  if (!amdgpu_bo_support_uswc(bo->flags))
  bo->flags &= ~AMDGPU_GEM_CREATE_CPU_GTT_USWC;
  -    if (adev->ras_enabled)
-    bo->flags |= AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE;
+    bo->flags |= AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE;
    bo->tbo.bdev = >mman.bdev;
  if (bp->domain & (AMDGPU_GEM_DOMAIN_GWS | AMDGPU_GEM_DOMAIN_OA |
@@ -632,15 +632,17 @@ int amdgpu_bo_create(struct amdgpu_device *adev,
    if (bp->flags & AMDGPU_GEM_CREATE_VRAM_CLEARED &&
  bo->tbo.resource->mem_type == TTM_PL_VRAM) {
-    struct dma_fence *fence;
+    struct dma_fence *fence = NULL;
  -    r = amdgpu_fill_buffer(bo, 0, bo->tbo.base.resv, , 
true);

+    r = amdgpu_ttm_clear_buffer(bo, bo->tbo.base.resv, );
  if (unlikely(r))
  goto fail_unreserve;
  -    dma_resv_add_fence(bo->tbo.base.resv, fence,
-   DMA_RESV_USAGE_KERNEL);
-    dma_fence_put(fence);
+    if (fence) {
+    dma_resv_add_fence(bo->tbo.base.resv, fence,
+   DMA_RESV_USAGE_KERNEL);
+    dma_fence_put(fence);
+    }
  }
  if (!bp->resv)
  amdgpu_bo_unreserve(bo);
@@ -1365,8 +1367,12 @@ void amdgpu_bo_release_notify(struct 
ttm_buffer_object *bo)

  if (WARN_ON_ONCE(!dma_resv_trylock(bo->base.resv)))
  return;
  -    r = amdgpu_fill_buffer(abo, AMDGPU_POISON, bo->base.resv, 
, true);

+    r = amdgpu_fill_buffer(abo, 0, bo->base.resv, , true);
  if (!WARN_ON(r)) {
+    struct amdgpu_vram_mgr_resource *vres;
+
+    vres = to_amdgpu_vram_mgr_resource(bo->resource);
+    vres->flags |= DRM_BUDDY_CLEARED;


Those lines should probably be in the VRAM manager.
This flag is set based on the amdgpu_fill_buffer() function return 
value, can we move the amdgpu_fill_buffer() function call and
DRM_BUDDY_CLEARED flag set lines to amdgpu_vram_mgr_del() in VRAM 
manager and does it require to wipe the VRAM buffers here as well

without setting the DRM_BUDDY_CLEARED.


No that won't work. The call to amdgpu_fill_buffer() *must* be here 
because that here is called before the resource is actually freed.


Only setting the vres->flags should probably be moved into 
amdgpu_vram_mgr.c.


So instead of calling that manually here just make a function for it to 
keep the code related to the buddy allocator in one place.


Regards,
Christian.




  amdgpu_bo_fence(abo, fence, false);
  dma_fence_put(fence);
  }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_res_cursor.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_res_cursor.h

index 381101d2bf05..50fcd86e1033 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_res_cursor.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_res_cursor.h
@@ -164,4 +164,29 @@ static inline void amdgpu_res_next(struct 
amdgpu_res_cursor *cur, uint64_t size)

[PATCH 9/9] drm/msm/dpu: sync mode_config limits to the FB limits in dpu_plane.c

2024-03-19 Thread Dmitry Baryshkov
Lift mode_config limits set by the DPU driver to the actual FB limits as
handled by the dpu_plane.c.

Signed-off-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
index 7257ac4020d8..e7dda9eca466 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
@@ -1136,13 +1136,8 @@ static int dpu_kms_hw_init(struct msm_kms *kms)
dev->mode_config.min_width = 0;
dev->mode_config.min_height = 0;
 
-   /*
-* max crtc width is equal to the max mixer width * 2 and max height is
-* is 4K
-*/
-   dev->mode_config.max_width =
-   dpu_kms->catalog->caps->max_mixer_width * 2;
-   dev->mode_config.max_height = 4096;
+   dev->mode_config.max_width = DPU_MAX_IMG_WIDTH;
+   dev->mode_config.max_height = DPU_MAX_IMG_HEIGHT;
 
dev->max_vblank_count = 0x;
/* Disable vblank irqs aggressively for power-saving */

-- 
2.39.2



[PATCH 1/9] drm/msm/dpu: drop dpu_format_check_modified_format

2024-03-19 Thread Dmitry Baryshkov
The msm_kms_funcs::check_modified_format() callback is not used by the
driver. Drop it completely.

Signed-off-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c | 45 -
 drivers/gpu/drm/msm/disp/dpu1/dpu_formats.h | 15 --
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c |  1 -
 drivers/gpu/drm/msm/msm_kms.h   |  5 
 4 files changed, 66 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c
index e366ab134249..ff0df478c958 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c
@@ -960,51 +960,6 @@ int dpu_format_populate_layout(
return ret;
 }
 
-int dpu_format_check_modified_format(
-   const struct msm_kms *kms,
-   const struct msm_format *msm_fmt,
-   const struct drm_mode_fb_cmd2 *cmd,
-   struct drm_gem_object **bos)
-{
-   const struct drm_format_info *info;
-   const struct dpu_format *fmt;
-   struct dpu_hw_fmt_layout layout;
-   uint32_t bos_total_size = 0;
-   int ret, i;
-
-   if (!msm_fmt || !cmd || !bos) {
-   DRM_ERROR("invalid arguments\n");
-   return -EINVAL;
-   }
-
-   fmt = to_dpu_format(msm_fmt);
-   info = drm_format_info(fmt->base.pixel_format);
-   if (!info)
-   return -EINVAL;
-
-   ret = dpu_format_get_plane_sizes(fmt, cmd->width, cmd->height,
-   , cmd->pitches);
-   if (ret)
-   return ret;
-
-   for (i = 0; i < info->num_planes; i++) {
-   if (!bos[i]) {
-   DRM_ERROR("invalid handle for plane %d\n", i);
-   return -EINVAL;
-   }
-   if ((i == 0) || (bos[i] != bos[0]))
-   bos_total_size += bos[i]->size;
-   }
-
-   if (bos_total_size < layout.total_size) {
-   DRM_ERROR("buffers total size too small %u expected %u\n",
-   bos_total_size, layout.total_size);
-   return -EINVAL;
-   }
-
-   return 0;
-}
-
 const struct dpu_format *dpu_get_dpu_format_ext(
const uint32_t format,
const uint64_t modifier)
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.h 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.h
index 84b8b3289f18..9442445f1a86 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.h
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.h
@@ -54,21 +54,6 @@ const struct msm_format *dpu_get_msm_format(
const uint32_t format,
const uint64_t modifiers);
 
-/**
- * dpu_format_check_modified_format - validate format and buffers for
- *   dpu non-standard, i.e. modified format
- * @kms: kms driver
- * @msm_fmt: pointer to the msm_fmt base pointer of an dpu_format
- * @cmd: fb_cmd2 structure user request
- * @bos: gem buffer object list
- *
- * Return: error code on failure, 0 on success
- */
-int dpu_format_check_modified_format(
-   const struct msm_kms *kms,
-   const struct msm_format *msm_fmt,
-   const struct drm_mode_fb_cmd2 *cmd,
-   struct drm_gem_object **bos);
 
 /**
  * dpu_format_populate_layout - populate the given format layout based on
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
index a1f5d7c4ab91..7257ac4020d8 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
@@ -969,7 +969,6 @@ static const struct msm_kms_funcs kms_funcs = {
.complete_commit = dpu_kms_complete_commit,
.enable_vblank   = dpu_kms_enable_vblank,
.disable_vblank  = dpu_kms_disable_vblank,
-   .check_modified_format = dpu_format_check_modified_format,
.get_format  = dpu_get_msm_format,
.destroy = dpu_kms_destroy,
.snapshot= dpu_kms_mdp_snapshot,
diff --git a/drivers/gpu/drm/msm/msm_kms.h b/drivers/gpu/drm/msm/msm_kms.h
index 0641f6111b93..b794ed918b56 100644
--- a/drivers/gpu/drm/msm/msm_kms.h
+++ b/drivers/gpu/drm/msm/msm_kms.h
@@ -96,11 +96,6 @@ struct msm_kms_funcs {
const struct msm_format *(*get_format)(struct msm_kms *kms,
const uint32_t format,
const uint64_t modifiers);
-   /* do format checking on format modified through fb_cmd2 modifiers */
-   int (*check_modified_format)(const struct msm_kms *kms,
-   const struct msm_format *msm_fmt,
-   const struct drm_mode_fb_cmd2 *cmd,
-   struct drm_gem_object **bos);
 
/* misc: */
long (*round_pixclk)(struct msm_kms *kms, unsigned long rate,

-- 
2.39.2



[PATCH 7/9] drm/msm/dpu: check for overflow in _dpu_crtc_setup_lm_bounds()

2024-03-19 Thread Dmitry Baryshkov
Check in _dpu_crtc_setup_lm_bounds() that CRTC width is not overflowing
LM requirements.

Signed-off-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
index 64befead366f..2fc1c2729bfd 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
@@ -711,12 +711,13 @@ void dpu_crtc_complete_commit(struct drm_crtc *crtc)
_dpu_crtc_complete_flip(crtc);
 }
 
-static void _dpu_crtc_setup_lm_bounds(struct drm_crtc *crtc,
+static int _dpu_crtc_setup_lm_bounds(struct drm_crtc *crtc,
struct drm_crtc_state *state)
 {
struct dpu_crtc_state *cstate = to_dpu_crtc_state(state);
struct drm_display_mode *adj_mode = >adjusted_mode;
u32 crtc_split_width = adj_mode->hdisplay / cstate->num_mixers;
+   struct dpu_kms *dpu_kms = _dpu_crtc_get_kms(crtc);
int i;
 
for (i = 0; i < cstate->num_mixers; i++) {
@@ -727,7 +728,12 @@ static void _dpu_crtc_setup_lm_bounds(struct drm_crtc 
*crtc,
r->y2 = adj_mode->vdisplay;
 
trace_dpu_crtc_setup_lm_bounds(DRMID(crtc), i, r);
+
+   if (drm_rect_width(r) > dpu_kms->catalog->caps->max_mixer_width)
+   return -E2BIG;
}
+
+   return 0;
 }
 
 static void _dpu_crtc_get_pcc_coeff(struct drm_crtc_state *state,
@@ -1195,8 +1201,11 @@ static int dpu_crtc_atomic_check(struct drm_crtc *crtc,
if (crtc_state->active_changed)
crtc_state->mode_changed = true;
 
-   if (cstate->num_mixers)
-   _dpu_crtc_setup_lm_bounds(crtc, crtc_state);
+   if (cstate->num_mixers) {
+   rc = _dpu_crtc_setup_lm_bounds(crtc, crtc_state);
+   if (rc)
+   return rc;
+   }
 
/* FIXME: move this to dpu_plane_atomic_check? */
drm_atomic_crtc_state_for_each_plane_state(plane, pstate, crtc_state) {

-- 
2.39.2



[PATCH 6/9] drm/msm/dpu: drop call to _dpu_crtc_setup_lm_bounds from atomic_begin

2024-03-19 Thread Dmitry Baryshkov
The dpu_crtc_atomic_check() already calls _dpu_crtc_setup_lm_bounds().
There is no need to call it from dpu_crtc_atomic_begin().

Signed-off-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
index 88c2e51ab166..64befead366f 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
@@ -803,8 +803,6 @@ static void dpu_crtc_atomic_begin(struct drm_crtc *crtc,
 
DRM_DEBUG_ATOMIC("crtc%d\n", crtc->base.id);
 
-   _dpu_crtc_setup_lm_bounds(crtc, crtc->state);
-
/* encoder will trigger pending mask now */
drm_for_each_encoder_mask(encoder, crtc->dev, crtc->state->encoder_mask)
dpu_encoder_trigger_kickoff_pending(encoder);

-- 
2.39.2



[PATCH 3/9] drm/msm/dpu: split dpu_format_populate_layout

2024-03-19 Thread Dmitry Baryshkov
Split dpu_format_populate_layout() into addess-related and
pitch/format-related parts.

Signed-off-by: Dmitry Baryshkov 
---
 .../gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c|  8 +++-
 drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c| 44 +++---
 drivers/gpu/drm/msm/disp/dpu1/dpu_formats.h|  8 +++-
 drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c  | 12 --
 4 files changed, 45 insertions(+), 27 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c
index 1924a2b28e53..0fd85c0479ec 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c
@@ -584,7 +584,13 @@ static void dpu_encoder_phys_wb_prepare_wb_job(struct 
dpu_encoder_phys *phys_enc
return;
}
 
-   ret = dpu_format_populate_layout(aspace, job->fb, _cfg->dest);
+   ret = dpu_format_populate_plane_sizes(job->fb, _cfg->dest);
+   if (ret) {
+   DPU_DEBUG("failed to populate plane sizes%d\n", ret);
+   return;
+   }
+
+   ret = dpu_format_populate_addrs(aspace, job->fb, _cfg->dest);
if (ret) {
DPU_DEBUG("failed to populate layout %d\n", ret);
return;
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c
index ff0df478c958..1fc9817278df 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c
@@ -629,7 +629,7 @@ static int _dpu_format_get_media_color_ubwc(const struct 
dpu_format *fmt)
return color_fmt;
 }
 
-static int _dpu_format_get_plane_sizes_ubwc(
+static int _dpu_format_populate_plane_sizes_ubwc(
const struct dpu_format *fmt,
const uint32_t width,
const uint32_t height,
@@ -708,7 +708,7 @@ static int _dpu_format_get_plane_sizes_ubwc(
return 0;
 }
 
-static int _dpu_format_get_plane_sizes_linear(
+static int _dpu_format_populate_plane_sizes_linear(
const struct dpu_format *fmt,
const uint32_t width,
const uint32_t height,
@@ -780,27 +780,37 @@ static int _dpu_format_get_plane_sizes_linear(
return 0;
 }
 
-static int dpu_format_get_plane_sizes(
-   const struct dpu_format *fmt,
-   const uint32_t w,
-   const uint32_t h,
-   struct dpu_hw_fmt_layout *layout,
-   const uint32_t *pitches)
+/*
+ * dpu_format_populate_addrs - populate non-address part of the layout based on
+ * fb, and format found in the fb
+ * @fb:framebuffer pointer
+ * @layout:  format layout structure to populate
+ *
+ * Return: error code on failure or 0 if new addresses were populated
+ */
+int dpu_format_populate_plane_sizes(
+   struct drm_framebuffer *fb,
+   struct dpu_hw_fmt_layout *layout)
 {
-   if (!layout || !fmt) {
+   struct dpu_format *fmt;
+
+   if (!layout || !fb) {
DRM_ERROR("invalid pointer\n");
return -EINVAL;
}
 
-   if ((w > DPU_MAX_IMG_WIDTH) || (h > DPU_MAX_IMG_HEIGHT)) {
+   if ((fb->width > DPU_MAX_IMG_WIDTH) || (fb->height > 
DPU_MAX_IMG_HEIGHT)) {
DRM_ERROR("image dimensions outside max range\n");
return -ERANGE;
}
 
+   fmt = to_dpu_format(msm_framebuffer_format(fb));
+
if (DPU_FORMAT_IS_UBWC(fmt) || DPU_FORMAT_IS_TILE(fmt))
-   return _dpu_format_get_plane_sizes_ubwc(fmt, w, h, layout);
+   return _dpu_format_populate_plane_sizes_ubwc(fmt, fb->width, 
fb->height, layout);
 
-   return _dpu_format_get_plane_sizes_linear(fmt, w, h, layout, pitches);
+   return _dpu_format_populate_plane_sizes_linear(fmt, fb->width, 
fb->height,
+  layout, fb->pitches);
 }
 
 static int _dpu_format_populate_addrs_ubwc(
@@ -924,7 +934,7 @@ static int _dpu_format_populate_addrs_linear(
return 0;
 }
 
-int dpu_format_populate_layout(
+int dpu_format_populate_addrs(
struct msm_gem_address_space *aspace,
struct drm_framebuffer *fb,
struct dpu_hw_fmt_layout *layout)
@@ -942,14 +952,6 @@ int dpu_format_populate_layout(
return -ERANGE;
}
 
-   layout->format = to_dpu_format(msm_framebuffer_format(fb));
-
-   /* Populate the plane sizes etc via get_format */
-   ret = dpu_format_get_plane_sizes(layout->format, fb->width, fb->height,
-   layout, fb->pitches);
-   if (ret)
-   return ret;
-
/* Populate the addresses given the fb */
if (DPU_FORMAT_IS_UBWC(layout->format) ||
DPU_FORMAT_IS_TILE(layout->format))
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.h 

[PATCH 8/9] drm/msm/dpu: merge MAX_IMG_WIDTH/HEIGHT with DPU_MAX_IMG_WIDTH/HEIGHT

2024-03-19 Thread Dmitry Baryshkov
dpu_formats.c defines DPU_MAX_IMG_WIDTH and _HEIGHT, while
dpu_hw_catalog.h defines just MAX_IMG_WIDTH and _HEIGHT. Merge these
constants to remove duplication.

Signed-off-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c| 3 ---
 drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h | 4 ++--
 drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c  | 4 ++--
 3 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c
index 1fc9817278df..1ee78ba640b5 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c
@@ -20,9 +20,6 @@
 #define DPU_TILE_HEIGHT_UBWC   4
 #define DPU_TILE_HEIGHT_NV12   8
 
-#define DPU_MAX_IMG_WIDTH  0x3FFF
-#define DPU_MAX_IMG_HEIGHT 0x3FFF
-
 /*
  * DPU supported format packing, bpp, and other format
  * information.
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h
index d1aef778340b..af2ead1c4886 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h
@@ -21,8 +21,8 @@
 
 #define DPU_HW_BLK_NAME_LEN16
 
-#define MAX_IMG_WIDTH 0x3fff
-#define MAX_IMG_HEIGHT 0x3fff
+#define DPU_MAX_IMG_WIDTH 0x3fff
+#define DPU_MAX_IMG_HEIGHT 0x3fff
 
 #define CRTC_DUAL_MIXERS   2
 
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
index 9e57c51f5343..47165d2bd4ea 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
@@ -851,8 +851,8 @@ static int dpu_plane_atomic_check(struct drm_plane *plane,
fb_rect.y2 = new_plane_state->fb->height;
 
/* Ensure fb size is supported */
-   if (drm_rect_width(_rect) > MAX_IMG_WIDTH ||
-   drm_rect_height(_rect) > MAX_IMG_HEIGHT) {
+   if (drm_rect_width(_rect) > DPU_MAX_IMG_WIDTH ||
+   drm_rect_height(_rect) > DPU_MAX_IMG_HEIGHT) {
DPU_DEBUG_PLANE(pdpu, "invalid framebuffer " DRM_RECT_FMT "\n",
DRM_RECT_ARG(_rect));
return -E2BIG;

-- 
2.39.2



[PATCH 5/9] drm/msm/dpu: check for the plane pitch overflow

2024-03-19 Thread Dmitry Baryshkov
Check that the plane pitch doesn't overflow the maximum pitch size
allowed by the hardware.

Signed-off-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_hw_sspp.h | 2 ++
 drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c   | 6 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_sspp.h 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_sspp.h
index b7dc52312c39..86b1defa5d21 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_sspp.h
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_sspp.h
@@ -12,6 +12,8 @@
 
 struct dpu_hw_sspp;
 
+#define DPU_SSPP_MAX_PITCH_SIZE0x
+
 /**
  * Flags
  */
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
index a9de1fbd0df3..9e57c51f5343 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
@@ -790,7 +790,7 @@ static int dpu_plane_atomic_check(struct drm_plane *plane,
 {
struct drm_plane_state *new_plane_state = 
drm_atomic_get_new_plane_state(state,

 plane);
-   int ret = 0, min_scale;
+   int i, ret = 0, min_scale;
struct dpu_plane *pdpu = to_dpu_plane(plane);
struct dpu_kms *kms = _dpu_plane_get_kms(>base);
u64 max_mdp_clk_rate = kms->perf.max_core_clk_rate;
@@ -864,6 +864,10 @@ static int dpu_plane_atomic_check(struct drm_plane *plane,
return ret;
}
 
+   for (i = 0; i < pstate->layout.num_planes; i++)
+   if (pstate->layout.plane_pitch[i] > DPU_SSPP_MAX_PITCH_SIZE)
+   return -E2BIG;
+
fmt = to_dpu_format(msm_framebuffer_format(new_plane_state->fb));
 
max_linewidth = pdpu->catalog->caps->max_linewidth;

-- 
2.39.2



  1   2   3   >