RE: [PATCH] drm/amdgpu: Program gds backup address as zero if no gds allocated

2023-05-24 Thread Zhu, Jiadong
[AMD Official Use Only - General]

> Presumably other gfx versions require something similar?

From firmware guys, that is always the case. firmware would checks 
gds_backup_addr zero or not to restore gds partition in the resumed sequence.
Currently, only gfx9 has the scenario that os sending resubmission ib after 
mcbp happens.

Thanks,
Jiadong

-Original Message-
From: Alex Deucher 
Sent: Wednesday, May 24, 2023 8:30 PM
To: Zhu, Jiadong 
Cc: amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/amdgpu: Program gds backup address as zero if no gds 
allocated

On Wed, May 24, 2023 at 5:00 AM  wrote:
>
> From: Jiadong Zhu 
>
> It is firmware requirement to set gds_backup_addrlo and
> gds_backup_addrhi of DE meta both zero if no gds partition is allocated for 
> the frame.

Presumably other gfx versions require something similar?

Reviewed-by: Alex Deucher 

>
> Signed-off-by: Jiadong Zhu 
> ---
>  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 13 -
>  1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
> b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
> index cbdd9918b3e7..cbcf6126cce5 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
> @@ -765,7 +765,7 @@ static void gfx_v9_0_set_rlc_funcs(struct
> amdgpu_device *adev);  static int gfx_v9_0_get_cu_info(struct amdgpu_device 
> *adev,
> struct amdgpu_cu_info *cu_info);
> static uint64_t gfx_v9_0_get_gpu_clock_counter(struct amdgpu_device
> *adev); -static void gfx_v9_0_ring_emit_de_meta(struct amdgpu_ring
> *ring, bool resume);
> +static void gfx_v9_0_ring_emit_de_meta(struct amdgpu_ring *ring, bool
> +resume, bool usegds);
>  static u64 gfx_v9_0_ring_get_rptr_compute(struct amdgpu_ring *ring);
> static void gfx_v9_0_query_ras_error_count(struct amdgpu_device *adev,
>   void *ras_error_status); @@
> -5160,7 +5160,8 @@ static void gfx_v9_0_ring_emit_ib_gfx(struct amdgpu_ring 
> *ring,
> gfx_v9_0_ring_emit_de_meta(ring,
>
> (!amdgpu_sriov_vf(ring->adev) &&
>flags & 
> AMDGPU_IB_PREEMPTED) ?
> -  true : false);
> +  true : false,
> +  job->gds_size > 0
> + && job->gds_base != 0);
> }
>
> amdgpu_ring_write(ring, header); @@ -5435,7 +5436,7 @@ static
> int gfx_v9_0_ring_preempt_ib(struct amdgpu_ring *ring)
> return r;
>  }
>
> -static void gfx_v9_0_ring_emit_de_meta(struct amdgpu_ring *ring, bool
> resume)
> +static void gfx_v9_0_ring_emit_de_meta(struct amdgpu_ring *ring, bool
> +resume, bool usegds)
>  {
> struct amdgpu_device *adev = ring->adev;
> struct v9_de_ib_state de_payload = {0}; @@ -5466,8 +5467,10 @@
> static void gfx_v9_0_ring_emit_de_meta(struct amdgpu_ring *ring, bool resume)
>  PAGE_SIZE);
> }
>
> -   de_payload.gds_backup_addrlo = lower_32_bits(gds_addr);
> -   de_payload.gds_backup_addrhi = upper_32_bits(gds_addr);
> +   if (usegds) {
> +   de_payload.gds_backup_addrlo = lower_32_bits(gds_addr);
> +   de_payload.gds_backup_addrhi = upper_32_bits(gds_addr);
> +   }
>
> cnt = (sizeof(de_payload) >> 2) + 4 - 2;
> amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, cnt));
> --
> 2.25.1
>


Re: [v4,12/13] drm/fbdev-generic: Implement dedicated fbdev I/O helpers

2023-05-24 Thread Sui Jingfeng

Reviewed-by: Sui Jingfeng 


On 2023/5/24 17:21, Thomas Zimmermann wrote:

Implement dedicated fbdev helpers for framebuffer I/O instead
of using DRM's helpers. Use an fbdev generator macro for
deferred I/O to create the callbacks. Fbdev-generic was the
only caller of the DRM helpers, so remove them from the helper
module.

v4:
* generate deferred-I/O helpers
* use initializer macros for fb_ops
v2:
* use FB_SYS_HELPERS_DEFERRED option

Signed-off-by: Thomas Zimmermann 
---
  drivers/gpu/drm/Kconfig |   6 +-
  drivers/gpu/drm/drm_fb_helper.c | 107 
  drivers/gpu/drm/drm_fbdev_generic.c |  11 ++-
  include/drm/drm_fb_helper.h |  41 ---
  4 files changed, 6 insertions(+), 159 deletions(-)

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 77fb10ddd8a2..92a782827b7b 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -95,6 +95,7 @@ config DRM_KUNIT_TEST
  config DRM_KMS_HELPER
tristate
depends on DRM
+   select FB_SYS_HELPERS_DEFERRED if DRM_FBDEV_EMULATION
help
  CRTC helpers for KMS drivers.
  
@@ -135,11 +136,6 @@ config DRM_FBDEV_EMULATION

select FB_CFB_FILLRECT
select FB_CFB_COPYAREA
select FB_CFB_IMAGEBLIT
-   select FB_DEFERRED_IO
-   select FB_SYS_FOPS
-   select FB_SYS_FILLRECT
-   select FB_SYS_COPYAREA
-   select FB_SYS_IMAGEBLIT
select FRAMEBUFFER_CONSOLE if !EXPERT
select FRAMEBUFFER_CONSOLE_DETECT_PRIMARY if FRAMEBUFFER_CONSOLE
default y
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index cb03099fd2e3..bab6b252f02a 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -736,113 +736,6 @@ void drm_fb_helper_deferred_io(struct fb_info *info, 
struct list_head *pagerefli
  }
  EXPORT_SYMBOL(drm_fb_helper_deferred_io);
  
-/**

- * drm_fb_helper_sys_read - Implements struct _ops.fb_read for system memory
- * @info: fb_info struct pointer
- * @buf: userspace buffer to read from framebuffer memory
- * @count: number of bytes to read from framebuffer memory
- * @ppos: read offset within framebuffer memory
- *
- * Returns:
- * The number of bytes read on success, or an error code otherwise.
- */
-ssize_t drm_fb_helper_sys_read(struct fb_info *info, char __user *buf,
-  size_t count, loff_t *ppos)
-{
-   return fb_sys_read(info, buf, count, ppos);
-}
-EXPORT_SYMBOL(drm_fb_helper_sys_read);
-
-/**
- * drm_fb_helper_sys_write - Implements struct _ops.fb_write for system 
memory
- * @info: fb_info struct pointer
- * @buf: userspace buffer to write to framebuffer memory
- * @count: number of bytes to write to framebuffer memory
- * @ppos: write offset within framebuffer memory
- *
- * Returns:
- * The number of bytes written on success, or an error code otherwise.
- */
-ssize_t drm_fb_helper_sys_write(struct fb_info *info, const char __user *buf,
-   size_t count, loff_t *ppos)
-{
-   struct drm_fb_helper *helper = info->par;
-   loff_t pos = *ppos;
-   ssize_t ret;
-   struct drm_rect damage_area;
-
-   ret = fb_sys_write(info, buf, count, ppos);
-   if (ret <= 0)
-   return ret;
-
-   if (helper->funcs->fb_dirty) {
-   drm_fb_helper_memory_range_to_clip(info, pos, ret, 
_area);
-   drm_fb_helper_damage(helper, damage_area.x1, damage_area.y1,
-drm_rect_width(_area),
-drm_rect_height(_area));
-   }
-
-   return ret;
-}
-EXPORT_SYMBOL(drm_fb_helper_sys_write);
-
-/**
- * drm_fb_helper_sys_fillrect - wrapper around sys_fillrect
- * @info: fbdev registered by the helper
- * @rect: info about rectangle to fill
- *
- * A wrapper around sys_fillrect implemented by fbdev core
- */
-void drm_fb_helper_sys_fillrect(struct fb_info *info,
-   const struct fb_fillrect *rect)
-{
-   struct drm_fb_helper *helper = info->par;
-
-   sys_fillrect(info, rect);
-
-   if (helper->funcs->fb_dirty)
-   drm_fb_helper_damage(helper, rect->dx, rect->dy, rect->width, 
rect->height);
-}
-EXPORT_SYMBOL(drm_fb_helper_sys_fillrect);
-
-/**
- * drm_fb_helper_sys_copyarea - wrapper around sys_copyarea
- * @info: fbdev registered by the helper
- * @area: info about area to copy
- *
- * A wrapper around sys_copyarea implemented by fbdev core
- */
-void drm_fb_helper_sys_copyarea(struct fb_info *info,
-   const struct fb_copyarea *area)
-{
-   struct drm_fb_helper *helper = info->par;
-
-   sys_copyarea(info, area);
-
-   if (helper->funcs->fb_dirty)
-   drm_fb_helper_damage(helper, area->dx, area->dy, area->width, 
area->height);
-}
-EXPORT_SYMBOL(drm_fb_helper_sys_copyarea);
-
-/**
- * drm_fb_helper_sys_imageblit - wrapper around sys_imageblit
- * 

Re: [PATCH 21/36] drm/amd/display: add CRTC 3D LUT support

2023-05-24 Thread kernel test robot
Hi Melissa,

kernel test robot noticed the following build warnings:

[auto build test WARNING on drm-misc/drm-misc-next]
[also build test WARNING on linus/master v6.4-rc3 next-20230524]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:
https://github.com/intel-lab-lkp/linux/commits/Melissa-Wen/drm-drm_mode_object-increase-max-objects-to-accommodate-new-color-props/20230524-062917
base:   git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
patch link:
https://lore.kernel.org/r/20230523221520.3115570-22-mwen%40igalia.com
patch subject: [PATCH 21/36] drm/amd/display: add CRTC 3D LUT support
config: sparc-allyesconfig 
(https://download.01.org/0day-ci/archive/20230525/202305250946.oxxf7yxr-...@intel.com/config)
compiler: sparc64-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
mkdir -p ~/bin
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# 
https://github.com/intel-lab-lkp/linux/commit/be212490fea8837eece5d56fa4a4963c0a21626f
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review 
Melissa-Wen/drm-drm_mode_object-increase-max-objects-to-accommodate-new-color-props/20230524-062917
git checkout be212490fea8837eece5d56fa4a4963c0a21626f
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 ~/bin/make.cross 
W=1 O=build_dir ARCH=sparc olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 ~/bin/make.cross 
W=1 O=build_dir ARCH=sparc SHELL=/bin/bash drivers/gpu/drm/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot 
| Closes: 
https://lore.kernel.org/oe-kbuild-all/202305250946.oxxf7yxr-...@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_color.c:515: 
>> warning: expecting prototype for amdgpu_dm_lut3d_size(). Prototype was for 
>> amdgpu_dm_get_lut3d_size() instead


vim +515 drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_color.c

   504  
   505  /**
   506   * amdgpu_dm_lut3d_size - get expected size according to hw color caps
   507   * @adev: amdgpu device
   508   * @lut_size: default size
   509   *
   510   * Return:
   511   * lut_size if DC 3D LUT is supported, zero otherwise.
   512   */
   513  static uint32_t amdgpu_dm_get_lut3d_size(struct amdgpu_device *adev,
   514   uint32_t lut_size)
 > 515  {
   516  return adev->dm.dc->caps.color.mpc.num_3dluts ? lut_size : 0;
   517  }
   518  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


Re: [v4,13/13] drm/i915: Implement dedicated fbdev I/O helpers

2023-05-24 Thread Sui Jingfeng

Hi,


I have just tested this patch on my i3-8100@3.6Ghz cpu + h110 
motherboard with fbtest:



Benchmarking... 10x10 squares: 26.44 Mpixels/s
Benchmarking... 20x20 squares: 52.54 Mpixels/s
Benchmarking... 50x50 squares: 128.13 Mpixels/s
Benchmarking... 100x100 squares: 252.21 Mpixels/s
Benchmarking... 200x200 squares: 489.48 Mpixels/s
Benchmarking... 500x500 squares: 1073.42 Mpixels/s
Benchmarking... 1000x1000 squares: 1823.72 Mpixels/s
Benchmarking... R5 circles: 18.73 Mpixels/s
Benchmarking... R10 circles: 39.05 Mpixels/s
Benchmarking... R25 circles: 98.60 Mpixels/s
Benchmarking... R50 circles: 196.31 Mpixels/s
Benchmarking... R100 circles: 382.81 Mpixels/s
Benchmarking... R250 circles: 872.09 Mpixels/s
Benchmarking... R500 circles: 1511.50 Mpixels/s


Then I mount ast2400 card on the same motherboard:


Benchmarking... 10x10 squares: 261.75 Mpixels/s
Benchmarking... 20x20 squares: 539.37 Mpixels/s
Benchmarking... 50x50 squares: 1161.53 Mpixels/s
Benchmarking... 100x100 squares: 1624.30 Mpixels/s
Benchmarking... 200x200 squares: 2089.74 Mpixels/s
Benchmarking... 500x500 squares: 2779.27 Mpixels/s
Benchmarking... 1000x1000 squares: 2382.28 Mpixels/s
Benchmarking... R5 circles: 151.03 Mpixels/s
Benchmarking... R10 circles: 311.34 Mpixels/s
Benchmarking... R25 circles: 698.63 Mpixels/s
Benchmarking... R50 circles: 1184.14 Mpixels/s
Benchmarking... R100 circles: 1791.60 Mpixels/s
Benchmarking... R250 circles: 2641.76 Mpixels/s
Benchmarking... R500 circles: 2669.38 Mpixels/s


The logs of fbtest and fbdev of IGT say passed.


On 2023/5/24 17:21, Thomas Zimmermann wrote:

Implement dedicated fbdev helpers for framebuffer I/O instead
of using DRM's helpers. Use an fbdev generator macro for
deferred I/O to create the fbdev callbacks. i915 was the only
caller of the DRM helpers, so remove them from the helper module.

i915's fbdev emulation is still incomplete as it doesn't implement
deferred I/O and damage handling for mmaped pages.

v4:
* generate deferred-I/O helpers
* use initializer macros for fb_ops
v2:
* use FB_IO_HELPERS options

Signed-off-by: Thomas Zimmermann 
Cc: Jani Nikula 
Cc: Joonas Lahtinen 
Cc: Rodrigo Vivi 
Cc: Tvrtko Ursulin 
Cc: "Ville Syrjälä" 
---
  drivers/gpu/drm/Kconfig|   3 -
  drivers/gpu/drm/drm_fb_helper.c| 107 -
  drivers/gpu/drm/i915/Kconfig   |   1 +
  drivers/gpu/drm/i915/display/intel_fbdev.c |  14 +--
  include/drm/drm_fb_helper.h|  39 
  5 files changed, 9 insertions(+), 155 deletions(-)

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 92a782827b7b..bb2e48cc6cd6 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -133,9 +133,6 @@ config DRM_FBDEV_EMULATION
bool "Enable legacy fbdev support for your modesetting driver"
depends on DRM_KMS_HELPER
depends on FB=y || FB=DRM_KMS_HELPER
-   select FB_CFB_FILLRECT
-   select FB_CFB_COPYAREA
-   select FB_CFB_IMAGEBLIT
select FRAMEBUFFER_CONSOLE if !EXPERT
select FRAMEBUFFER_CONSOLE_DETECT_PRIMARY if FRAMEBUFFER_CONSOLE
default y
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index bab6b252f02a..9978147bbc8a 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -736,113 +736,6 @@ void drm_fb_helper_deferred_io(struct fb_info *info, 
struct list_head *pagerefli
  }
  EXPORT_SYMBOL(drm_fb_helper_deferred_io);
  
-/**

- * drm_fb_helper_cfb_read - Implements struct _ops.fb_read for I/O memory
- * @info: fb_info struct pointer
- * @buf: userspace buffer to read from framebuffer memory
- * @count: number of bytes to read from framebuffer memory
- * @ppos: read offset within framebuffer memory
- *
- * Returns:
- * The number of bytes read on success, or an error code otherwise.
- */
-ssize_t drm_fb_helper_cfb_read(struct fb_info *info, char __user *buf,
-  size_t count, loff_t *ppos)
-{
-   return fb_io_read(info, buf, count, ppos);
-}
-EXPORT_SYMBOL(drm_fb_helper_cfb_read);
-
-/**
- * drm_fb_helper_cfb_write - Implements struct _ops.fb_write for I/O memory
- * @info: fb_info struct pointer
- * @buf: userspace buffer to write to framebuffer memory
- * @count: number of bytes to write to framebuffer memory
- * @ppos: write offset within framebuffer memory
- *
- * Returns:
- * The number of bytes written on success, or an error code otherwise.
- */
-ssize_t drm_fb_helper_cfb_write(struct fb_info *info, const char __user *buf,
-   size_t count, loff_t *ppos)
-{
-   struct drm_fb_helper *helper = info->par;
-   loff_t pos = *ppos;
-   ssize_t ret;
-   struct drm_rect damage_area;
-
-   ret = fb_io_write(info, buf, count, ppos);
-   if (ret <= 0)
-   return ret;
-
-   if (helper->funcs->fb_dirty) {
-   drm_fb_helper_memory_range_to_clip(info, pos, ret, 
_area);
- 

RE: [PATCH] drm/jpeg: add init value for num_jpeg_rings

2023-05-24 Thread Li, Ying
[AMD Official Use Only - General]

Tested-by: Ying Li  for the patch

-Original Message-
From: Zhu, James 
Sent: Wednesday, May 24, 2023 4:35 PM
To: amd-gfx@lists.freedesktop.org; Li, Ying 
Cc: Wu, Jason ; Deng, Bonnie ; Liang, 
Richard qi 
Subject: [PATCH] drm/jpeg: add init value for num_jpeg_rings

Need init new num_jpeg_rings to 1 on jpeg.

Signed-off-by: James Zhu 
---
 drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c | 1 +  
drivers/gpu/drm/amd/amdgpu/jpeg_v2_0.c | 1 +  
drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c | 1 +  
drivers/gpu/drm/amd/amdgpu/jpeg_v3_0.c | 1 +  
drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c | 1 +
 5 files changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c 
b/drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c
index 1c5b60604a19..77595e9622da 100644
--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c
@@ -460,6 +460,7 @@ int jpeg_v1_0_early_init(void *handle)
struct amdgpu_device *adev = (struct amdgpu_device *)handle;

adev->jpeg.num_jpeg_inst = 1;
+   adev->jpeg.num_jpeg_rings = 1;

jpeg_v1_0_set_dec_ring_funcs(adev);
jpeg_v1_0_set_irq_funcs(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/jpeg_v2_0.c 
b/drivers/gpu/drm/amd/amdgpu/jpeg_v2_0.c
index 3aeeceae34a5..c25d4a07350b 100644
--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v2_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v2_0.c
@@ -49,6 +49,7 @@ static int jpeg_v2_0_early_init(void *handle)
struct amdgpu_device *adev = (struct amdgpu_device *)handle;

adev->jpeg.num_jpeg_inst = 1;
+   adev->jpeg.num_jpeg_rings = 1;

jpeg_v2_0_set_dec_ring_funcs(adev);
jpeg_v2_0_set_irq_funcs(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c 
b/drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c
index f533ede484d4..aadb74de52bc 100644
--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c
+++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c
@@ -60,6 +60,7 @@ static int jpeg_v2_5_early_init(void *handle)
u32 harvest;
int i;

+   adev->jpeg.num_jpeg_rings = 1;
adev->jpeg.num_jpeg_inst = JPEG25_MAX_HW_INSTANCES_ARCTURUS;
for (i = 0; i < adev->jpeg.num_jpeg_inst; i++) {
harvest = RREG32_SOC15(JPEG, i, mmCC_UVD_HARVESTING); diff 
--git a/drivers/gpu/drm/amd/amdgpu/jpeg_v3_0.c 
b/drivers/gpu/drm/amd/amdgpu/jpeg_v3_0.c
index cb5494effc0f..79791379fc2b 100644
--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v3_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v3_0.c
@@ -64,6 +64,7 @@ static int jpeg_v3_0_early_init(void *handle)
}

adev->jpeg.num_jpeg_inst = 1;
+   adev->jpeg.num_jpeg_rings = 1;

jpeg_v3_0_set_dec_ring_funcs(adev);
jpeg_v3_0_set_irq_funcs(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c 
b/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c
index 86383fbf9358..a707d407fbd0 100644
--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c
@@ -58,6 +58,7 @@ static int jpeg_v4_0_early_init(void *handle)


adev->jpeg.num_jpeg_inst = 1;
+   adev->jpeg.num_jpeg_rings = 1;

jpeg_v4_0_set_dec_ring_funcs(adev);
jpeg_v4_0_set_irq_funcs(adev);
--
2.34.1



RE: [PATCH] drm/jpeg: add init value for num_jpeg_rings

2023-05-24 Thread Liang, Richard qi
[AMD Official Use Only - General]

Reviewed-by: Richard Liang  for the patch.

-Original Message-
From: Zhu, James 
Sent: Wednesday, May 24, 2023 4:35 PM
To: amd-gfx@lists.freedesktop.org; Li, Ying 
Cc: Wu, Jason ; Deng, Bonnie ; Liang, 
Richard qi 
Subject: [PATCH] drm/jpeg: add init value for num_jpeg_rings

Need init new num_jpeg_rings to 1 on jpeg.

Signed-off-by: James Zhu 
---
 drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c | 1 +  
drivers/gpu/drm/amd/amdgpu/jpeg_v2_0.c | 1 +  
drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c | 1 +  
drivers/gpu/drm/amd/amdgpu/jpeg_v3_0.c | 1 +  
drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c | 1 +
 5 files changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c 
b/drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c
index 1c5b60604a19..77595e9622da 100644
--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c
@@ -460,6 +460,7 @@ int jpeg_v1_0_early_init(void *handle)
struct amdgpu_device *adev = (struct amdgpu_device *)handle;

adev->jpeg.num_jpeg_inst = 1;
+   adev->jpeg.num_jpeg_rings = 1;

jpeg_v1_0_set_dec_ring_funcs(adev);
jpeg_v1_0_set_irq_funcs(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/jpeg_v2_0.c 
b/drivers/gpu/drm/amd/amdgpu/jpeg_v2_0.c
index 3aeeceae34a5..c25d4a07350b 100644
--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v2_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v2_0.c
@@ -49,6 +49,7 @@ static int jpeg_v2_0_early_init(void *handle)
struct amdgpu_device *adev = (struct amdgpu_device *)handle;

adev->jpeg.num_jpeg_inst = 1;
+   adev->jpeg.num_jpeg_rings = 1;

jpeg_v2_0_set_dec_ring_funcs(adev);
jpeg_v2_0_set_irq_funcs(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c 
b/drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c
index f533ede484d4..aadb74de52bc 100644
--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c
+++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c
@@ -60,6 +60,7 @@ static int jpeg_v2_5_early_init(void *handle)
u32 harvest;
int i;

+   adev->jpeg.num_jpeg_rings = 1;
adev->jpeg.num_jpeg_inst = JPEG25_MAX_HW_INSTANCES_ARCTURUS;
for (i = 0; i < adev->jpeg.num_jpeg_inst; i++) {
harvest = RREG32_SOC15(JPEG, i, mmCC_UVD_HARVESTING); diff 
--git a/drivers/gpu/drm/amd/amdgpu/jpeg_v3_0.c 
b/drivers/gpu/drm/amd/amdgpu/jpeg_v3_0.c
index cb5494effc0f..79791379fc2b 100644
--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v3_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v3_0.c
@@ -64,6 +64,7 @@ static int jpeg_v3_0_early_init(void *handle)
}

adev->jpeg.num_jpeg_inst = 1;
+   adev->jpeg.num_jpeg_rings = 1;

jpeg_v3_0_set_dec_ring_funcs(adev);
jpeg_v3_0_set_irq_funcs(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c 
b/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c
index 86383fbf9358..a707d407fbd0 100644
--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c
@@ -58,6 +58,7 @@ static int jpeg_v4_0_early_init(void *handle)


adev->jpeg.num_jpeg_inst = 1;
+   adev->jpeg.num_jpeg_rings = 1;

jpeg_v4_0_set_dec_ring_funcs(adev);
jpeg_v4_0_set_irq_funcs(adev);
--
2.34.1



[pull] amdgpu, radeon drm-fixes-6.4

2023-05-24 Thread Alex Deucher
Hi Dave, Daniel,

Fixes for 6.4.

The following changes since commit 79ef1c9d14c65a5c3f7eec47389d8c2a33be8e8d:

  Merge tag 'amd-drm-fixes-6.4-2023-05-18' of 
https://gitlab.freedesktop.org/agd5f/linux into drm-fixes (2023-05-19 11:26:21 
+1000)

are available in the Git repository at:

  https://gitlab.freedesktop.org/agd5f/linux.git 
tags/amd-drm-fixes-6.4-2023-05-24

for you to fetch changes up to 482e6ad9adde69d9da08864b4ccf4dfd53edb2f0:

  drm/amd/display: Have Payload Properly Created After Resume (2023-05-24 
16:37:00 -0400)


amd-drm-fixes-6.4-2023-05-24:

amdgpu:
- Fix missing BO unlocking in KIQ error path
- Avoid spurious secure display error messages
- SMU13 fix
- Fix an OD regression
- GPU reset display IRQ warning fix
- MST fix

radeon:
- Fix a DP regression


Alan Liu (1):
  drm/amd/display: Fix warning in disabling vblank irq

Alex Deucher (1):
  drm/radeon: reintroduce radeon_dp_work_func content

Evan Quan (1):
  drm/amd/pm: add missing NotifyPowerSource message mapping for SMU13.0.7

Fangzhi Zuo (1):
  drm/amd/display: Have Payload Properly Created After Resume

Jesse Zhang (1):
  drm/amdgpu: don't enable secure display on incompatible platforms

Jonatas Esteves (1):
  drm/amd/pm: Fix output of pp_od_clk_voltage

Sukrut Bellary (1):
  drm:amd:amdgpu: Fix missing buffer object unlock in failure path

 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c |  4 +++-
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c  |  4 +++-
 drivers/gpu/drm/amd/amdgpu/psp_v10_0.c |  8 ++-
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c  | 25 +-
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c | 16 +++---
 drivers/gpu/drm/amd/pm/amdgpu_pm.c | 12 +--
 .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c   |  1 +
 drivers/gpu/drm/radeon/radeon_irq_kms.c| 10 +
 8 files changed, 47 insertions(+), 33 deletions(-)


Re: [v4,02/13] fbdev: Add initializer macros for struct fb_ops

2023-05-24 Thread Sui Jingfeng

Hi,


we love your patch:


On 2023/5/24 17:21, Thomas Zimmermann wrote:

For framebuffers in I/O and system memory, add macros that set
struct fb_ops to the respective callback functions.

For deferred I/O, add macros that generate callback functions with
damage handling. Add initializer macros that set struct fb_ops to
the generated callbacks.

These macros can remove a lot boilerplate code from fbdev drivers.
The drivers are supposed to use the macro that is required for its
framebuffer. Each macro is split into smaller helpers, so that
drivers with non-standard callbacks can pick and customize callbacks
as needed. There are individual helper macros for read/write, mmap
and drawing.

Signed-off-by: Thomas Zimmermann 
---
  include/linux/fb.h | 112 +
  1 file changed, 112 insertions(+)

diff --git a/include/linux/fb.h b/include/linux/fb.h
index 2cf8efcb9e32..731472a2bb62 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -538,9 +538,31 @@ extern ssize_t fb_io_read(struct fb_info *info, char 
__user *buf,
  extern ssize_t fb_io_write(struct fb_info *info, const char __user *buf,
   size_t count, loff_t *ppos);
  
+/*

+ * Initializes struct fb_ops for framebuffers in I/O memory.
+ */
+
+#define __FB_DEFAULT_IO_OPS_RDWR \
+   .fb_read= fb_io_read, \
+   .fb_write   = fb_io_write
+
+#define __FB_DEFAULT_IO_OPS_DRAW \
+.fb_fillrect   = cfb_fillrect, \
+.fb_copyarea   = cfb_copyarea, \
+.fb_imageblit  = cfb_imageblit


Here,  it seems that your text editor replace the tap with space, but 
I'm OK.


I'm asking because I see other __FB__DEFAULT_* macro begin with tabs.


+#define __FB_DEFAULT_IO_OPS_MMAP \
+   .fb_mmap= NULL // default implementation
+
+#define FB_DEFAULT_IO_OPS \
+   __FB_DEFAULT_IO_OPS_RDWR, \
+   __FB_DEFAULT_IO_OPS_DRAW, \
+   __FB_DEFAULT_IO_OPS_MMAP
+
  /*
   * Drawing operations where framebuffer is in system RAM
   */
+
  extern void sys_fillrect(struct fb_info *info, const struct fb_fillrect 
*rect);
  extern void sys_copyarea(struct fb_info *info, const struct fb_copyarea 
*area);
  extern void sys_imageblit(struct fb_info *info, const struct fb_image *image);
@@ -549,6 +571,27 @@ extern ssize_t fb_sys_read(struct fb_info *info, char 
__user *buf,
  extern ssize_t fb_sys_write(struct fb_info *info, const char __user *buf,
size_t count, loff_t *ppos);
  
+/*

+ * Initializes struct fb_ops for framebuffers in system memory.
+ */
+
+#define __FB_DEFAULT_SYS_OPS_RDWR \
+   .fb_read= fb_sys_read, \
+   .fb_write   = fb_sys_write
+
+#define __FB_DEFAULT_SYS_OPS_DRAW \
+.fb_fillrect   = sys_fillrect, \
+.fb_copyarea   = sys_copyarea, \
+.fb_imageblit  = sys_imageblit
+
+#define __FB_DEFAULT_SYS_OPS_MMAP \
+   .fb_mmap= NULL // default implementation
+
+#define FB_DEFAULT_SYS_OPS \
+   __FB_DEFAULT_SYS_OPS_RDWR, \
+   __FB_DEFAULT_SYS_OPS_DRAW, \
+   __FB_DEFAULT_SYS_OPS_MMAP
+
  /* drivers/video/fbmem.c */
  extern int register_framebuffer(struct fb_info *fb_info);
  extern void unregister_framebuffer(struct fb_info *fb_info);
@@ -604,6 +647,75 @@ extern void fb_deferred_io_cleanup(struct fb_info *info);
  extern int fb_deferred_io_fsync(struct file *file, loff_t start,
loff_t end, int datasync);
  
+/*

+ * Generate callbacks for deferred I/O
+ */
+
+#define __FB_GEN_DEFAULT_DEFERRED_OPS_RDWR(__prefix, __damage_range, __mode) \
+   static ssize_t __prefix ## _defio_read(struct fb_info *info, char 
__user *buf, \
+  size_t count, loff_t *ppos) \
+   { \
+   return fb_ ## __mode ## _read(info, buf, count, ppos); \
+   } \
+   static ssize_t __prefix ## _defio_write(struct fb_info *info, const 
char __user *buf, \
+   size_t count, loff_t *ppos) \
+   { \
+   unsigned long offset = *ppos; \
+   ssize_t ret = fb_ ## __mode ## _write(info, buf, count, ppos); \
+   if (ret > 0) \
+   __damage_range(info, offset, ret); \
+   return ret; \
+   }
+
+#define __FB_GEN_DEFAULT_DEFERRED_OPS_DRAW(__prefix, __damage_area, __mode) \
+   static void __prefix ## _defio_fillrect(struct fb_info *info, \
+   const struct fb_fillrect *rect) 
\
+   { \
+   __mode ## _fillrect(info, rect); \
+   __damage_area(info, rect->dx, rect->dy, rect->width, 
rect->height); \
+   } \
+   static void __prefix ## _defio_copyarea(struct fb_info *info, \
+   const struct fb_copyarea *area) 
\
+   { \
+   __mode ## _copyarea(info, area); \
+   __damage_area(info, area->dx, area->dy, area->width, 
area->height); \
+ 

Re: [v4, 01/13] fbdev: Add Kconfig options to select different fb_ops helpers

2023-05-24 Thread Sui Jingfeng

Reviewed-by: Sui Jingfeng 


On 2023/5/24 17:21, Thomas Zimmermann wrote:

Many fbdev drivers use the same set of fb_ops helpers. Add Kconfig
options to select them at once. This will help with making DRM's
fbdev emulation code more modular, but can also be used to simplify
fbdev's driver configs.

v3:
* fix select statement (Jingfeng)

Signed-off-by: Thomas Zimmermann 
---
  drivers/video/fbdev/Kconfig | 21 +
  1 file changed, 21 insertions(+)

diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
index e8889035c882..6df9bd09454a 100644
--- a/drivers/video/fbdev/Kconfig
+++ b/drivers/video/fbdev/Kconfig
@@ -158,6 +158,27 @@ config FB_DEFERRED_IO
bool
depends on FB
  
+config FB_IO_HELPERS

+   bool
+   depends on FB
+   select FB_CFB_COPYAREA
+   select FB_CFB_FILLRECT
+   select FB_CFB_IMAGEBLIT
+
+config FB_SYS_HELPERS
+   bool
+   depends on FB
+   select FB_SYS_COPYAREA
+   select FB_SYS_FILLRECT
+   select FB_SYS_FOPS
+   select FB_SYS_IMAGEBLIT
+
+config FB_SYS_HELPERS_DEFERRED
+   bool
+   depends on FB
+   select FB_DEFERRED_IO
+   select FB_SYS_HELPERS
+
  config FB_HECUBA
tristate
depends on FB


Re: [PATCH] drm/jpeg: add init value for num_jpeg_rings

2023-05-24 Thread Alex Deucher
Acked-by: Alex Deucher 

On Wed, May 24, 2023 at 4:35 PM James Zhu  wrote:
>
> Need init new num_jpeg_rings to 1 on jpeg.
>
> Signed-off-by: James Zhu 
> ---
>  drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c | 1 +
>  drivers/gpu/drm/amd/amdgpu/jpeg_v2_0.c | 1 +
>  drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c | 1 +
>  drivers/gpu/drm/amd/amdgpu/jpeg_v3_0.c | 1 +
>  drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c | 1 +
>  5 files changed, 5 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c 
> b/drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c
> index 1c5b60604a19..77595e9622da 100644
> --- a/drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c
> @@ -460,6 +460,7 @@ int jpeg_v1_0_early_init(void *handle)
> struct amdgpu_device *adev = (struct amdgpu_device *)handle;
>
> adev->jpeg.num_jpeg_inst = 1;
> +   adev->jpeg.num_jpeg_rings = 1;
>
> jpeg_v1_0_set_dec_ring_funcs(adev);
> jpeg_v1_0_set_irq_funcs(adev);
> diff --git a/drivers/gpu/drm/amd/amdgpu/jpeg_v2_0.c 
> b/drivers/gpu/drm/amd/amdgpu/jpeg_v2_0.c
> index 3aeeceae34a5..c25d4a07350b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/jpeg_v2_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v2_0.c
> @@ -49,6 +49,7 @@ static int jpeg_v2_0_early_init(void *handle)
> struct amdgpu_device *adev = (struct amdgpu_device *)handle;
>
> adev->jpeg.num_jpeg_inst = 1;
> +   adev->jpeg.num_jpeg_rings = 1;
>
> jpeg_v2_0_set_dec_ring_funcs(adev);
> jpeg_v2_0_set_irq_funcs(adev);
> diff --git a/drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c 
> b/drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c
> index f533ede484d4..aadb74de52bc 100644
> --- a/drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c
> +++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c
> @@ -60,6 +60,7 @@ static int jpeg_v2_5_early_init(void *handle)
> u32 harvest;
> int i;
>
> +   adev->jpeg.num_jpeg_rings = 1;
> adev->jpeg.num_jpeg_inst = JPEG25_MAX_HW_INSTANCES_ARCTURUS;
> for (i = 0; i < adev->jpeg.num_jpeg_inst; i++) {
> harvest = RREG32_SOC15(JPEG, i, mmCC_UVD_HARVESTING);
> diff --git a/drivers/gpu/drm/amd/amdgpu/jpeg_v3_0.c 
> b/drivers/gpu/drm/amd/amdgpu/jpeg_v3_0.c
> index cb5494effc0f..79791379fc2b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/jpeg_v3_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v3_0.c
> @@ -64,6 +64,7 @@ static int jpeg_v3_0_early_init(void *handle)
> }
>
> adev->jpeg.num_jpeg_inst = 1;
> +   adev->jpeg.num_jpeg_rings = 1;
>
> jpeg_v3_0_set_dec_ring_funcs(adev);
> jpeg_v3_0_set_irq_funcs(adev);
> diff --git a/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c 
> b/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c
> index 86383fbf9358..a707d407fbd0 100644
> --- a/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c
> @@ -58,6 +58,7 @@ static int jpeg_v4_0_early_init(void *handle)
>
>
> adev->jpeg.num_jpeg_inst = 1;
> +   adev->jpeg.num_jpeg_rings = 1;
>
> jpeg_v4_0_set_dec_ring_funcs(adev);
> jpeg_v4_0_set_irq_funcs(adev);
> --
> 2.34.1
>


[PATCH] drm/jpeg: add init value for num_jpeg_rings

2023-05-24 Thread James Zhu
Need init new num_jpeg_rings to 1 on jpeg.

Signed-off-by: James Zhu 
---
 drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c | 1 +
 drivers/gpu/drm/amd/amdgpu/jpeg_v2_0.c | 1 +
 drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c | 1 +
 drivers/gpu/drm/amd/amdgpu/jpeg_v3_0.c | 1 +
 drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c | 1 +
 5 files changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c 
b/drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c
index 1c5b60604a19..77595e9622da 100644
--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c
@@ -460,6 +460,7 @@ int jpeg_v1_0_early_init(void *handle)
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
adev->jpeg.num_jpeg_inst = 1;
+   adev->jpeg.num_jpeg_rings = 1;
 
jpeg_v1_0_set_dec_ring_funcs(adev);
jpeg_v1_0_set_irq_funcs(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/jpeg_v2_0.c 
b/drivers/gpu/drm/amd/amdgpu/jpeg_v2_0.c
index 3aeeceae34a5..c25d4a07350b 100644
--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v2_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v2_0.c
@@ -49,6 +49,7 @@ static int jpeg_v2_0_early_init(void *handle)
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
adev->jpeg.num_jpeg_inst = 1;
+   adev->jpeg.num_jpeg_rings = 1;
 
jpeg_v2_0_set_dec_ring_funcs(adev);
jpeg_v2_0_set_irq_funcs(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c 
b/drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c
index f533ede484d4..aadb74de52bc 100644
--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c
+++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c
@@ -60,6 +60,7 @@ static int jpeg_v2_5_early_init(void *handle)
u32 harvest;
int i;
 
+   adev->jpeg.num_jpeg_rings = 1;
adev->jpeg.num_jpeg_inst = JPEG25_MAX_HW_INSTANCES_ARCTURUS;
for (i = 0; i < adev->jpeg.num_jpeg_inst; i++) {
harvest = RREG32_SOC15(JPEG, i, mmCC_UVD_HARVESTING);
diff --git a/drivers/gpu/drm/amd/amdgpu/jpeg_v3_0.c 
b/drivers/gpu/drm/amd/amdgpu/jpeg_v3_0.c
index cb5494effc0f..79791379fc2b 100644
--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v3_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v3_0.c
@@ -64,6 +64,7 @@ static int jpeg_v3_0_early_init(void *handle)
}
 
adev->jpeg.num_jpeg_inst = 1;
+   adev->jpeg.num_jpeg_rings = 1;
 
jpeg_v3_0_set_dec_ring_funcs(adev);
jpeg_v3_0_set_irq_funcs(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c 
b/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c
index 86383fbf9358..a707d407fbd0 100644
--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c
@@ -58,6 +58,7 @@ static int jpeg_v4_0_early_init(void *handle)
 
 
adev->jpeg.num_jpeg_inst = 1;
+   adev->jpeg.num_jpeg_rings = 1;
 
jpeg_v4_0_set_dec_ring_funcs(adev);
jpeg_v4_0_set_irq_funcs(adev);
-- 
2.34.1



Re: [PATCH v2] drm/amd/display: enable more strict compile checks

2023-05-24 Thread Hamza Mahfooz

+ Kees

On 5/24/23 15:50, Alex Deucher wrote:

On Wed, May 24, 2023 at 3:46 PM Felix Kuehling  wrote:


Sure, I think we tried enabling warnings as errors before and had to
revert it because of weird compiler quirks or the variety of compiler
versions that need to be supported.

Alex, are you planning to upstream this, or is this only to enforce more
internal discipline about not ignoring warnings?


I'd like to upstream it.  Upstream already has CONFIG_WERROR as a
config option, but it's been problematic to enable in CI because of
various breakages outside of the driver and in different compilers.
That said, I don't know how much trouble enabling it will cause with
various compilers in the wild.

Alex



Regards,
Felix


On 2023-05-24 15:41, Russell, Kent wrote:


[AMD Official Use Only - General]


(Adding Felix in CC)

I’m a fan of adding it to KFD as well. Felix, can you foresee any
issues here?

Kent

*From:* amd-gfx  *On Behalf Of
*Ho, Kenny
*Sent:* Wednesday, May 24, 2023 3:23 PM
*To:* Alex Deucher ; Mahfooz, Hamza

*Cc:* Li, Sun peng (Leo) ; Wentland, Harry
; Pan, Xinhui ; Siqueira,
Rodrigo ; linux-ker...@vger.kernel.org;
dri-de...@lists.freedesktop.org; amd-gfx@lists.freedesktop.org; Daniel
Vetter ; Deucher, Alexander
; David Airlie ; Koenig,
Christian 
*Subject:* Re: [PATCH v2] drm/amd/display: enable more strict compile
checks

[AMD Official Use Only - General]

[AMD Official Use Only - General]

(+ Felix)

Should we do the same for other modules under amd (amdkfd)?  I was
going to enable full kernel werror in the kconfig used by my CI but
this is probably better.

Kenny



*From:*Alex Deucher 
*Sent:* Wednesday, May 24, 2023 3:22 PM
*To:* Mahfooz, Hamza 
*Cc:* amd-gfx@lists.freedesktop.org ;
Li, Sun peng (Leo) ; Ho, Kenny ;
Pan, Xinhui ; Siqueira, Rodrigo
; linux-ker...@vger.kernel.org
; dri-de...@lists.freedesktop.org
; Daniel Vetter ;
Deucher, Alexander ; David Airlie
; Wentland, Harry ; Koenig,
Christian 
*Subject:* Re: [PATCH v2] drm/amd/display: enable more strict compile
checks

On Wed, May 24, 2023 at 3:20 PM Hamza Mahfooz 
wrote:


Currently, there are quite a number of issues that are quite easy for
the CI to catch, that slip through the cracks. Among them, there are
unused variable and indentation issues. Also, we should consider all
warnings to be compile errors, since the community will eventually end
up complaining about them. So, enable -Werror, -Wunused and
-Wmisleading-indentation for all kernel builds.

Cc: Alex Deucher 
Cc: Harry Wentland 
Cc: Kenny Ho 
Signed-off-by: Hamza Mahfooz 
---
v2: fix grammatical error
---
  drivers/gpu/drm/amd/display/Makefile | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/Makefile

b/drivers/gpu/drm/amd/display/Makefile

index 0d610cb376bb..3c44162ebe21 100644
--- a/drivers/gpu/drm/amd/display/Makefile
+++ b/drivers/gpu/drm/amd/display/Makefile
@@ -26,6 +26,8 @@

  AMDDALPATH = $(RELATIVE_AMD_DISPLAY_PATH)

+subdir-ccflags-y += -Werror -Wunused -Wmisleading-indentation
+


Care to enable this for the rest of amdgpu as well?  Or send out an
additional patch to do that?  Either way:
Reviewed-by: Alex Deucher 

Alex


  subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/inc/
  subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/inc/hw
  subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/clk_mgr
--
2.40.1




--
Hamza



Re: [v4,12/13] drm/fbdev-generic: Implement dedicated fbdev I/O helpers

2023-05-24 Thread Sui Jingfeng

Tested-by: Sui Jingfeng 


This version works fine, I have tested it On LoongArch with 
drm/loongson(v14) as it is most handy for me.


Also because it using fbdev-generic. fbdev of IGT report no error. Then 
I run fbtest from geert[1],



Before apply your patch:


Benchmarking... 10x10 squares: 468.39 Mpixels/s
Benchmarking... 20x20 squares: 985.02 Mpixels/s
Benchmarking... 50x50 squares: 2247.22 Mpixels/s
Benchmarking... 100x100 squares: 2242.30 Mpixels/s
Benchmarking... 200x200 squares: 2883.18 Mpixels/s
Benchmarking... 500x500 squares: 3642.18 Mpixels/s
Benchmarking... 1000x1000 squares: 3992.77 Mpixels/s
Benchmarking... R5 circles: 261.90 Mpixels/s
Benchmarking... R10 circles: 596.27 Mpixels/s
Benchmarking... R25 circles: 1513.96 Mpixels/s
Benchmarking... R50 circles: 1965.07 Mpixels/s
Benchmarking... R100 circles: 2470.75 Mpixels/s
Benchmarking... R250 circles: 3288.00 Mpixels/s
Benchmarking... R500 circles: 3705.66 Mpixels/s


After apply your patch:


Benchmarking... 10x10 squares: 477.04 Mpixels/s
Benchmarking... 20x20 squares: 1021.07 Mpixels/s
Benchmarking... 50x50 squares: 2315.70 Mpixels/s
Benchmarking... 100x100 squares: 2267.69 Mpixels/s
Benchmarking... 200x200 squares: 3006.28 Mpixels/s
Benchmarking... 500x500 squares: 3761.44 Mpixels/s
Benchmarking... 1000x1000 squares: 4112.49 Mpixels/s
Benchmarking... R5 circles: 269.19 Mpixels/s
Benchmarking... R10 circles: 620.77 Mpixels/s
Benchmarking... R25 circles: 1559.02 Mpixels/s
Benchmarking... R50 circles: 2027.36 Mpixels/s
Benchmarking... R100 circles: 2574.42 Mpixels/s
Benchmarking... R250 circles: 3363.28 Mpixels/s
Benchmarking... R500 circles: 3815.51 Mpixels/s


It seems that this bring a little bit performance gain.

Directly operate on video RAM is slower than have a shadow in system RAM.

I also test this patch in intel i3-8100 @ 3.6Ghz, the results show that 
i915 is a bit slower.


Because it operate directly on device memory.


[1] https://git.kernel.org/pub/scm/linux/kernel/git/geert/fbtest.git


On 2023/5/24 17:21, Thomas Zimmermann wrote:

Implement dedicated fbdev helpers for framebuffer I/O instead
of using DRM's helpers. Use an fbdev generator macro for
deferred I/O to create the callbacks. Fbdev-generic was the
only caller of the DRM helpers, so remove them from the helper
module.

v4:
* generate deferred-I/O helpers
* use initializer macros for fb_ops
v2:
* use FB_SYS_HELPERS_DEFERRED option

Signed-off-by: Thomas Zimmermann 
---
  drivers/gpu/drm/Kconfig |   6 +-
  drivers/gpu/drm/drm_fb_helper.c | 107 
  drivers/gpu/drm/drm_fbdev_generic.c |  11 ++-
  include/drm/drm_fb_helper.h |  41 ---
  4 files changed, 6 insertions(+), 159 deletions(-)

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 77fb10ddd8a2..92a782827b7b 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -95,6 +95,7 @@ config DRM_KUNIT_TEST
  config DRM_KMS_HELPER
tristate
depends on DRM
+   select FB_SYS_HELPERS_DEFERRED if DRM_FBDEV_EMULATION
help
  CRTC helpers for KMS drivers.
  
@@ -135,11 +136,6 @@ config DRM_FBDEV_EMULATION

select FB_CFB_FILLRECT
select FB_CFB_COPYAREA
select FB_CFB_IMAGEBLIT
-   select FB_DEFERRED_IO
-   select FB_SYS_FOPS
-   select FB_SYS_FILLRECT
-   select FB_SYS_COPYAREA
-   select FB_SYS_IMAGEBLIT
select FRAMEBUFFER_CONSOLE if !EXPERT
select FRAMEBUFFER_CONSOLE_DETECT_PRIMARY if FRAMEBUFFER_CONSOLE
default y
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index cb03099fd2e3..bab6b252f02a 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -736,113 +736,6 @@ void drm_fb_helper_deferred_io(struct fb_info *info, 
struct list_head *pagerefli
  }
  EXPORT_SYMBOL(drm_fb_helper_deferred_io);
  
-/**

- * drm_fb_helper_sys_read - Implements struct _ops.fb_read for system memory
- * @info: fb_info struct pointer
- * @buf: userspace buffer to read from framebuffer memory
- * @count: number of bytes to read from framebuffer memory
- * @ppos: read offset within framebuffer memory
- *
- * Returns:
- * The number of bytes read on success, or an error code otherwise.
- */
-ssize_t drm_fb_helper_sys_read(struct fb_info *info, char __user *buf,
-  size_t count, loff_t *ppos)
-{
-   return fb_sys_read(info, buf, count, ppos);
-}
-EXPORT_SYMBOL(drm_fb_helper_sys_read);
-
-/**
- * drm_fb_helper_sys_write - Implements struct _ops.fb_write for system 
memory
- * @info: fb_info struct pointer
- * @buf: userspace buffer to write to framebuffer memory
- * @count: number of bytes to write to framebuffer memory
- * @ppos: write offset within framebuffer memory
- *
- * Returns:
- * The number of bytes written on success, or an error code otherwise.
- */
-ssize_t drm_fb_helper_sys_write(struct fb_info *info, const char __user *buf,
-  

Re: [PATCH v2] drm/amd/display: enable more strict compile checks

2023-05-24 Thread Hamza Mahfooz

On 5/24/23 15:54, Harry Wentland wrote:



On 5/24/23 15:27, Hamza Mahfooz wrote:

On 5/24/23 15:22, Alex Deucher wrote:

On Wed, May 24, 2023 at 3:20 PM Hamza Mahfooz  wrote:


Currently, there are quite a number of issues that are quite easy for
the CI to catch, that slip through the cracks. Among them, there are
unused variable and indentation issues. Also, we should consider all
warnings to be compile errors, since the community will eventually end
up complaining about them. So, enable -Werror, -Wunused and
-Wmisleading-indentation for all kernel builds.

Cc: Alex Deucher 
Cc: Harry Wentland 
Cc: Kenny Ho 
Signed-off-by: Hamza Mahfooz 
---
v2: fix grammatical error
---
   drivers/gpu/drm/amd/display/Makefile | 2 ++
   1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/Makefile 
b/drivers/gpu/drm/amd/display/Makefile
index 0d610cb376bb..3c44162ebe21 100644
--- a/drivers/gpu/drm/amd/display/Makefile
+++ b/drivers/gpu/drm/amd/display/Makefile
@@ -26,6 +26,8 @@

   AMDDALPATH = $(RELATIVE_AMD_DISPLAY_PATH)

+subdir-ccflags-y += -Werror -Wunused -Wmisleading-indentation
+


Care to enable this for the rest of amdgpu as well?  Or send out an
additional patch to do that?  Either way:
Reviewed-by: Alex Deucher 


As far as I can tell, if `CONFIG_DRM_AMD_DC` is set it will run these
checks on at least the base driver code.



It's probable best to put that into amdgpu/Makefile in that case.


I tried the following, but it doesn't seem to work:

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

index 74a9aa6fe18c..d97bde0796dc 100644
--- a/drivers/gpu/drm/amd/amdgpu/Makefile
+++ b/drivers/gpu/drm/amd/amdgpu/Makefile
@@ -39,6 +39,8 @@ ccflags-y := -I$(FULL_AMD_PATH)/include/asic_reg \
-I$(FULL_AMD_DISPLAY_PATH)/amdgpu_dm \
-I$(FULL_AMD_PATH)/amdkfd

+ccflags-y += -Werror -Wunused -Wmisleading-indentation
+
 amdgpu-y := amdgpu_drv.o

 # add KMS driver



Harry



Alex


   subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/inc/
   subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/inc/hw
   subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/clk_mgr
--
2.40.1




--
Hamza



Re: [PATCH v2] drm/amd/display: enable more strict compile checks

2023-05-24 Thread Ho, Kenny
[AMD Official Use Only - General]

I ran some experiment yesterday to turn on CONFIG_WERROR and here are some 
results (summary: gcc 12 seems ok but gcc 13 gives a lot more error, but not 
necessarily in our module.)

Build with gcc13 using Fedora 38:
http://zuul.linux.amd.com/t/osg/build/722ad77affed4f988d72051a84979e9f/log/job-output.txt#2924

Build with gcc12 using Fedora 37:
http://zuul.linux.amd.com/t/osg/build/9e90f08bbeb044a2997a41b6cdc13f29/log/job-output.txt#7534

Kenny


From: Alex Deucher 
Sent: Wednesday, May 24, 2023 3:50 PM
To: Kuehling, Felix 
Cc: Russell, Kent ; Ho, Kenny ; 
Mahfooz, Hamza ; Li, Sun peng (Leo) 
; Wentland, Harry ; Pan, Xinhui 
; Siqueira, Rodrigo ; 
linux-ker...@vger.kernel.org ; 
dri-de...@lists.freedesktop.org ; 
amd-gfx@lists.freedesktop.org ; Daniel Vetter 
; Deucher, Alexander ; David Airlie 
; Koenig, Christian 
Subject: Re: [PATCH v2] drm/amd/display: enable more strict compile checks

On Wed, May 24, 2023 at 3:46 PM Felix Kuehling  wrote:
>
> Sure, I think we tried enabling warnings as errors before and had to
> revert it because of weird compiler quirks or the variety of compiler
> versions that need to be supported.
>
> Alex, are you planning to upstream this, or is this only to enforce more
> internal discipline about not ignoring warnings?

I'd like to upstream it.  Upstream already has CONFIG_WERROR as a
config option, but it's been problematic to enable in CI because of
various breakages outside of the driver and in different compilers.
That said, I don't know how much trouble enabling it will cause with
various compilers in the wild.

Alex

>
> Regards,
>Felix
>
>
> On 2023-05-24 15:41, Russell, Kent wrote:
> >
> > [AMD Official Use Only - General]
> >
> >
> > (Adding Felix in CC)
> >
> > I’m a fan of adding it to KFD as well. Felix, can you foresee any
> > issues here?
> >
> > Kent
> >
> > *From:* amd-gfx  *On Behalf Of
> > *Ho, Kenny
> > *Sent:* Wednesday, May 24, 2023 3:23 PM
> > *To:* Alex Deucher ; Mahfooz, Hamza
> > 
> > *Cc:* Li, Sun peng (Leo) ; Wentland, Harry
> > ; Pan, Xinhui ; Siqueira,
> > Rodrigo ; linux-ker...@vger.kernel.org;
> > dri-de...@lists.freedesktop.org; amd-gfx@lists.freedesktop.org; Daniel
> > Vetter ; Deucher, Alexander
> > ; David Airlie ; Koenig,
> > Christian 
> > *Subject:* Re: [PATCH v2] drm/amd/display: enable more strict compile
> > checks
> >
> > [AMD Official Use Only - General]
> >
> > [AMD Official Use Only - General]
> >
> > (+ Felix)
> >
> > Should we do the same for other modules under amd (amdkfd)?  I was
> > going to enable full kernel werror in the kconfig used by my CI but
> > this is probably better.
> >
> > Kenny
> >
> > 
> >
> > *From:*Alex Deucher 
> > *Sent:* Wednesday, May 24, 2023 3:22 PM
> > *To:* Mahfooz, Hamza 
> > *Cc:* amd-gfx@lists.freedesktop.org ;
> > Li, Sun peng (Leo) ; Ho, Kenny ;
> > Pan, Xinhui ; Siqueira, Rodrigo
> > ; linux-ker...@vger.kernel.org
> > ; dri-de...@lists.freedesktop.org
> > ; Daniel Vetter ;
> > Deucher, Alexander ; David Airlie
> > ; Wentland, Harry ; Koenig,
> > Christian 
> > *Subject:* Re: [PATCH v2] drm/amd/display: enable more strict compile
> > checks
> >
> > On Wed, May 24, 2023 at 3:20 PM Hamza Mahfooz 
> > wrote:
> > >
> > > Currently, there are quite a number of issues that are quite easy for
> > > the CI to catch, that slip through the cracks. Among them, there are
> > > unused variable and indentation issues. Also, we should consider all
> > > warnings to be compile errors, since the community will eventually end
> > > up complaining about them. So, enable -Werror, -Wunused and
> > > -Wmisleading-indentation for all kernel builds.
> > >
> > > Cc: Alex Deucher 
> > > Cc: Harry Wentland 
> > > Cc: Kenny Ho 
> > > Signed-off-by: Hamza Mahfooz 
> > > ---
> > > v2: fix grammatical error
> > > ---
> > >  drivers/gpu/drm/amd/display/Makefile | 2 ++
> > >  1 file changed, 2 insertions(+)
> > >
> > > diff --git a/drivers/gpu/drm/amd/display/Makefile
> > b/drivers/gpu/drm/amd/display/Makefile
> > > index 0d610cb376bb..3c44162ebe21 100644
> > > --- a/drivers/gpu/drm/amd/display/Makefile
> > > +++ b/drivers/gpu/drm/amd/display/Makefile
> > > @@ -26,6 +26,8 @@
> > >
> > >  AMDDALPATH = $(RELATIVE_AMD_DISPLAY_PATH)
> > >
> > > +subdir-ccflags-y += -Werror -Wunused -Wmisleading-indentation
> > > +
> >
> > Care to enable this for the rest of amdgpu as well?  Or send out an
> > additional patch to do that?  Either way:
> > Reviewed-by: Alex Deucher 
> >
> > Alex
> >
> > >  subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/inc/
> > >  subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/inc/hw
> > >  subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/clk_mgr
> > > --
> > > 2.40.1
> > >
> >


Re: [PATCH v2] drm/amd/display: enable more strict compile checks

2023-05-24 Thread Harry Wentland



On 5/24/23 15:27, Hamza Mahfooz wrote:
> On 5/24/23 15:22, Alex Deucher wrote:
>> On Wed, May 24, 2023 at 3:20 PM Hamza Mahfooz  wrote:
>>>
>>> Currently, there are quite a number of issues that are quite easy for
>>> the CI to catch, that slip through the cracks. Among them, there are
>>> unused variable and indentation issues. Also, we should consider all
>>> warnings to be compile errors, since the community will eventually end
>>> up complaining about them. So, enable -Werror, -Wunused and
>>> -Wmisleading-indentation for all kernel builds.
>>>
>>> Cc: Alex Deucher 
>>> Cc: Harry Wentland 
>>> Cc: Kenny Ho 
>>> Signed-off-by: Hamza Mahfooz 
>>> ---
>>> v2: fix grammatical error
>>> ---
>>>   drivers/gpu/drm/amd/display/Makefile | 2 ++
>>>   1 file changed, 2 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/amd/display/Makefile 
>>> b/drivers/gpu/drm/amd/display/Makefile
>>> index 0d610cb376bb..3c44162ebe21 100644
>>> --- a/drivers/gpu/drm/amd/display/Makefile
>>> +++ b/drivers/gpu/drm/amd/display/Makefile
>>> @@ -26,6 +26,8 @@
>>>
>>>   AMDDALPATH = $(RELATIVE_AMD_DISPLAY_PATH)
>>>
>>> +subdir-ccflags-y += -Werror -Wunused -Wmisleading-indentation
>>> +
>>
>> Care to enable this for the rest of amdgpu as well?  Or send out an
>> additional patch to do that?  Either way:
>> Reviewed-by: Alex Deucher 
> 
> As far as I can tell, if `CONFIG_DRM_AMD_DC` is set it will run these
> checks on at least the base driver code.
> 

It's probable best to put that into amdgpu/Makefile in that case.

Harry

>>
>> Alex
>>
>>>   subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/inc/
>>>   subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/inc/hw
>>>   subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/clk_mgr
>>> -- 
>>> 2.40.1
>>>



Re: [PATCH v3 09/17] drm/amd/display: Register Colorspace property for DP and HDMI

2023-05-24 Thread Harry Wentland



On 3/17/23 09:53, Joshua Ashton wrote:
> 
> 
> On 3/17/23 13:35, Pekka Paalanen wrote:
>> On Fri, 17 Mar 2023 14:50:40 +0200
>> Ville Syrjälä  wrote:
>>
>>> On Fri, Mar 17, 2023 at 10:53:35AM +0200, Pekka Paalanen wrote:
 On Fri, 17 Mar 2023 01:01:38 +0200
 Ville Syrjälä  wrote:
   
> On Thu, Mar 16, 2023 at 10:13:54PM +0100, Sebastian Wick wrote:
>> On Thu, Mar 16, 2023 at 1:35 PM Ville Syrjälä
>>  wrote:
>>>
>>> On Thu, Mar 16, 2023 at 01:34:49PM +0200, Pekka Paalanen wrote:
 On Thu, 16 Mar 2023 12:47:51 +0200
 Ville Syrjälä  wrote:
    
> On Thu, Mar 16, 2023 at 12:07:01PM +0200, Pekka Paalanen wrote:
>> On Thu, 16 Mar 2023 11:50:27 +0200
>> Ville Syrjälä  wrote:
>>    
>>> On Thu, Mar 16, 2023 at 01:37:24AM +0100, Sebastian Wick wrote:
 On Tue, Mar 7, 2023 at 4:12 PM Harry Wentland 
  wrote:
>
> We want compositors to be able to set the output
> colorspace on DP and HDMI outputs, based on the
> caps reported from the receiver via EDID.

 About that... The documentation says that user space has to check 
 the
 EDID for what the sink actually supports. So whatever is in
 supported_colorspaces is just what the driver/hardware is able to 
 set
 but doesn't actually indicate that the sink supports it.

 So the only way to enable bt2020 is by checking if the sink 
 supports
 both RGB and YUV variants because both could be used by the driver.
 Not great at all. Something to remember for the new property.
>>>
>>> Hmm. I wonder if that's even legal... Looks like maybe it
>>> is since I can't immediately spot anything in CTA-861 to
>>> forbid it :/
>>
>> Wouldn't the driver do the same EDID check before choosing whether it
>> uses RGB or YCbCr signalling?
>
> I suppose it could. The modeset would then fail, which is perhaps

 Could? What are they missing?
>>>
>>> The fact that the new property that also affects the rgb->ycbcr matrix
>>> doesn't even exist?
>>
>> I think the question was about the current Colorspace property.

 Yes.

 We need to be able to set ColourPrimaries infoframe field for the sink.
 Only userspace knows what ColourPrimaries it uses, and the driver has
 no need to care at all, other than tell the sink what we have.

 When a driver chooses to use YCbCr, it needs to use the
 MatrixCoefficients the sink expects.

 If we send the infoframe to the sink telling the signal uses BT.2020
 ColourPrimaries, does that same bit pattern also tell the sink we are
 using the BT.2020 NCL MatrixCoefficients if the driver chooses YCbCr?

 Do drivers actually use BT.2020 NCL MatrixCoefficients in that case?
>>>
>>> No. I think I've repeated this same line a thousand times already:
>>> The current colorspace property *only* affects the infoframe/msa/sdp,
>>> nothing else.
> 
> No, sorry, this is completely nonsensical.
> 
> Even with the current Colorspace property that we want to deprecate, drivers 
> doing an implicit conversion from RGB -> to YCC should respect the colorspace 
> property to pick the right matrix coefficients here.
> 
> Doing so simply introduces a useless mismatch that is unavoidable from 
> userspace and makes absolutely no sense.
> 
> Arguing about this is kind of completely useless anyway... as we are 
> deprecating this property... Let's plase let it die.
> 
> I am not sure why these patches were re-submitted with my RB again after we 
> had the discussion previously about making a new one that's actually going to 
> get tested and have userspace consumers.
> 

Apologies for that. I must've mis-read thins. Dropping them from the
next version of this set.

Based on the hackfest discussions I'll iterate on this with the hopes
to unblock the Colorspace property on AMD HW. A more thorough API will
require more work and rushing it would be unwise. In the meantime we
do really need something on AMD HW.

Harry

> (FTR, I guess Gamescope *is* a userspace consumer for this broken property 
> right now, but I am completely happy for AMDGPU upstream to never support 
> this and to just move onto the new property and leave this one behind).
> 
>>
>> That's the problem. I don't know what that means.
>>
>> Does it mean that the sink expects BT.2020 NCL MatrixCoefficients to
>> have been used?
> 
> Yes.
> 
>>
>> And the driver will never use BT.2020 NCL MatrixCoefficients in any
>> circumstances?
> 
> That is what Ville is describing and what I disagree with, yes.
> 
> But whether or not Ville or I agree on that is kind of irrelevant as we are 
> going to deprecate the property... right... right?
> 
>>
>> See the conflict? 

Re: [PATCH v2] drm/amd/display: enable more strict compile checks

2023-05-24 Thread Alex Deucher
On Wed, May 24, 2023 at 3:46 PM Felix Kuehling  wrote:
>
> Sure, I think we tried enabling warnings as errors before and had to
> revert it because of weird compiler quirks or the variety of compiler
> versions that need to be supported.
>
> Alex, are you planning to upstream this, or is this only to enforce more
> internal discipline about not ignoring warnings?

I'd like to upstream it.  Upstream already has CONFIG_WERROR as a
config option, but it's been problematic to enable in CI because of
various breakages outside of the driver and in different compilers.
That said, I don't know how much trouble enabling it will cause with
various compilers in the wild.

Alex

>
> Regards,
>Felix
>
>
> On 2023-05-24 15:41, Russell, Kent wrote:
> >
> > [AMD Official Use Only - General]
> >
> >
> > (Adding Felix in CC)
> >
> > I’m a fan of adding it to KFD as well. Felix, can you foresee any
> > issues here?
> >
> > Kent
> >
> > *From:* amd-gfx  *On Behalf Of
> > *Ho, Kenny
> > *Sent:* Wednesday, May 24, 2023 3:23 PM
> > *To:* Alex Deucher ; Mahfooz, Hamza
> > 
> > *Cc:* Li, Sun peng (Leo) ; Wentland, Harry
> > ; Pan, Xinhui ; Siqueira,
> > Rodrigo ; linux-ker...@vger.kernel.org;
> > dri-de...@lists.freedesktop.org; amd-gfx@lists.freedesktop.org; Daniel
> > Vetter ; Deucher, Alexander
> > ; David Airlie ; Koenig,
> > Christian 
> > *Subject:* Re: [PATCH v2] drm/amd/display: enable more strict compile
> > checks
> >
> > [AMD Official Use Only - General]
> >
> > [AMD Official Use Only - General]
> >
> > (+ Felix)
> >
> > Should we do the same for other modules under amd (amdkfd)?  I was
> > going to enable full kernel werror in the kconfig used by my CI but
> > this is probably better.
> >
> > Kenny
> >
> > 
> >
> > *From:*Alex Deucher 
> > *Sent:* Wednesday, May 24, 2023 3:22 PM
> > *To:* Mahfooz, Hamza 
> > *Cc:* amd-gfx@lists.freedesktop.org ;
> > Li, Sun peng (Leo) ; Ho, Kenny ;
> > Pan, Xinhui ; Siqueira, Rodrigo
> > ; linux-ker...@vger.kernel.org
> > ; dri-de...@lists.freedesktop.org
> > ; Daniel Vetter ;
> > Deucher, Alexander ; David Airlie
> > ; Wentland, Harry ; Koenig,
> > Christian 
> > *Subject:* Re: [PATCH v2] drm/amd/display: enable more strict compile
> > checks
> >
> > On Wed, May 24, 2023 at 3:20 PM Hamza Mahfooz 
> > wrote:
> > >
> > > Currently, there are quite a number of issues that are quite easy for
> > > the CI to catch, that slip through the cracks. Among them, there are
> > > unused variable and indentation issues. Also, we should consider all
> > > warnings to be compile errors, since the community will eventually end
> > > up complaining about them. So, enable -Werror, -Wunused and
> > > -Wmisleading-indentation for all kernel builds.
> > >
> > > Cc: Alex Deucher 
> > > Cc: Harry Wentland 
> > > Cc: Kenny Ho 
> > > Signed-off-by: Hamza Mahfooz 
> > > ---
> > > v2: fix grammatical error
> > > ---
> > >  drivers/gpu/drm/amd/display/Makefile | 2 ++
> > >  1 file changed, 2 insertions(+)
> > >
> > > diff --git a/drivers/gpu/drm/amd/display/Makefile
> > b/drivers/gpu/drm/amd/display/Makefile
> > > index 0d610cb376bb..3c44162ebe21 100644
> > > --- a/drivers/gpu/drm/amd/display/Makefile
> > > +++ b/drivers/gpu/drm/amd/display/Makefile
> > > @@ -26,6 +26,8 @@
> > >
> > >  AMDDALPATH = $(RELATIVE_AMD_DISPLAY_PATH)
> > >
> > > +subdir-ccflags-y += -Werror -Wunused -Wmisleading-indentation
> > > +
> >
> > Care to enable this for the rest of amdgpu as well?  Or send out an
> > additional patch to do that?  Either way:
> > Reviewed-by: Alex Deucher 
> >
> > Alex
> >
> > >  subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/inc/
> > >  subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/inc/hw
> > >  subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/clk_mgr
> > > --
> > > 2.40.1
> > >
> >


Re: [PATCH v2] drm/amd/display: enable more strict compile checks

2023-05-24 Thread Felix Kuehling
Sure, I think we tried enabling warnings as errors before and had to 
revert it because of weird compiler quirks or the variety of compiler 
versions that need to be supported.


Alex, are you planning to upstream this, or is this only to enforce more 
internal discipline about not ignoring warnings?


Regards,
  Felix


On 2023-05-24 15:41, Russell, Kent wrote:


[AMD Official Use Only - General]


(Adding Felix in CC)

I’m a fan of adding it to KFD as well. Felix, can you foresee any 
issues here?


Kent

*From:* amd-gfx  *On Behalf Of 
*Ho, Kenny

*Sent:* Wednesday, May 24, 2023 3:23 PM
*To:* Alex Deucher ; Mahfooz, Hamza 

*Cc:* Li, Sun peng (Leo) ; Wentland, Harry 
; Pan, Xinhui ; Siqueira, 
Rodrigo ; linux-ker...@vger.kernel.org; 
dri-de...@lists.freedesktop.org; amd-gfx@lists.freedesktop.org; Daniel 
Vetter ; Deucher, Alexander 
; David Airlie ; Koenig, 
Christian 
*Subject:* Re: [PATCH v2] drm/amd/display: enable more strict compile 
checks


[AMD Official Use Only - General]

[AMD Official Use Only - General]

(+ Felix)

Should we do the same for other modules under amd (amdkfd)?  I was 
going to enable full kernel werror in the kconfig used by my CI but 
this is probably better.


Kenny



*From:*Alex Deucher 
*Sent:* Wednesday, May 24, 2023 3:22 PM
*To:* Mahfooz, Hamza 
*Cc:* amd-gfx@lists.freedesktop.org ; 
Li, Sun peng (Leo) ; Ho, Kenny ; 
Pan, Xinhui ; Siqueira, Rodrigo 
; linux-ker...@vger.kernel.org 
; dri-de...@lists.freedesktop.org 
; Daniel Vetter ; 
Deucher, Alexander ; David Airlie 
; Wentland, Harry ; Koenig, 
Christian 
*Subject:* Re: [PATCH v2] drm/amd/display: enable more strict compile 
checks


On Wed, May 24, 2023 at 3:20 PM Hamza Mahfooz  
wrote:

>
> Currently, there are quite a number of issues that are quite easy for
> the CI to catch, that slip through the cracks. Among them, there are
> unused variable and indentation issues. Also, we should consider all
> warnings to be compile errors, since the community will eventually end
> up complaining about them. So, enable -Werror, -Wunused and
> -Wmisleading-indentation for all kernel builds.
>
> Cc: Alex Deucher 
> Cc: Harry Wentland 
> Cc: Kenny Ho 
> Signed-off-by: Hamza Mahfooz 
> ---
> v2: fix grammatical error
> ---
>  drivers/gpu/drm/amd/display/Makefile | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/display/Makefile 
b/drivers/gpu/drm/amd/display/Makefile

> index 0d610cb376bb..3c44162ebe21 100644
> --- a/drivers/gpu/drm/amd/display/Makefile
> +++ b/drivers/gpu/drm/amd/display/Makefile
> @@ -26,6 +26,8 @@
>
>  AMDDALPATH = $(RELATIVE_AMD_DISPLAY_PATH)
>
> +subdir-ccflags-y += -Werror -Wunused -Wmisleading-indentation
> +

Care to enable this for the rest of amdgpu as well?  Or send out an
additional patch to do that?  Either way:
Reviewed-by: Alex Deucher 

Alex

>  subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/inc/
>  subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/inc/hw
>  subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/clk_mgr
> --
> 2.40.1
>



RE: [PATCH v2] drm/amd/display: enable more strict compile checks

2023-05-24 Thread Russell, Kent
[AMD Official Use Only - General]

(Adding Felix in CC)

I’m a fan of adding it to KFD as well. Felix, can you foresee any issues here?

Kent

From: amd-gfx  On Behalf Of Ho, Kenny
Sent: Wednesday, May 24, 2023 3:23 PM
To: Alex Deucher ; Mahfooz, Hamza 
Cc: Li, Sun peng (Leo) ; Wentland, Harry 
; Pan, Xinhui ; Siqueira, Rodrigo 
; linux-ker...@vger.kernel.org; 
dri-de...@lists.freedesktop.org; amd-gfx@lists.freedesktop.org; Daniel Vetter 
; Deucher, Alexander ; David Airlie 
; Koenig, Christian 
Subject: Re: [PATCH v2] drm/amd/display: enable more strict compile checks


[AMD Official Use Only - General]


[AMD Official Use Only - General]

(+ Felix)

Should we do the same for other modules under amd (amdkfd)?  I was going to 
enable full kernel werror in the kconfig used by my CI but this is probably 
better.

Kenny

From: Alex Deucher mailto:alexdeuc...@gmail.com>>
Sent: Wednesday, May 24, 2023 3:22 PM
To: Mahfooz, Hamza mailto:hamza.mahf...@amd.com>>
Cc: amd-gfx@lists.freedesktop.org 
mailto:amd-gfx@lists.freedesktop.org>>; Li, Sun 
peng (Leo) mailto:sunpeng...@amd.com>>; Ho, Kenny 
mailto:kenny...@amd.com>>; Pan, Xinhui 
mailto:xinhui@amd.com>>; Siqueira, Rodrigo 
mailto:rodrigo.sique...@amd.com>>; 
linux-ker...@vger.kernel.org 
mailto:linux-ker...@vger.kernel.org>>; 
dri-de...@lists.freedesktop.org 
mailto:dri-de...@lists.freedesktop.org>>; 
Daniel Vetter mailto:dan...@ffwll.ch>>; Deucher, Alexander 
mailto:alexander.deuc...@amd.com>>; David Airlie 
mailto:airl...@gmail.com>>; Wentland, Harry 
mailto:harry.wentl...@amd.com>>; Koenig, Christian 
mailto:christian.koe...@amd.com>>
Subject: Re: [PATCH v2] drm/amd/display: enable more strict compile checks

On Wed, May 24, 2023 at 3:20 PM Hamza Mahfooz 
mailto:hamza.mahf...@amd.com>> wrote:
>
> Currently, there are quite a number of issues that are quite easy for
> the CI to catch, that slip through the cracks. Among them, there are
> unused variable and indentation issues. Also, we should consider all
> warnings to be compile errors, since the community will eventually end
> up complaining about them. So, enable -Werror, -Wunused and
> -Wmisleading-indentation for all kernel builds.
>
> Cc: Alex Deucher mailto:alexander.deuc...@amd.com>>
> Cc: Harry Wentland mailto:harry.wentl...@amd.com>>
> Cc: Kenny Ho mailto:kenny...@amd.com>>
> Signed-off-by: Hamza Mahfooz 
> mailto:hamza.mahf...@amd.com>>
> ---
> v2: fix grammatical error
> ---
>  drivers/gpu/drm/amd/display/Makefile | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/display/Makefile 
> b/drivers/gpu/drm/amd/display/Makefile
> index 0d610cb376bb..3c44162ebe21 100644
> --- a/drivers/gpu/drm/amd/display/Makefile
> +++ b/drivers/gpu/drm/amd/display/Makefile
> @@ -26,6 +26,8 @@
>
>  AMDDALPATH = $(RELATIVE_AMD_DISPLAY_PATH)
>
> +subdir-ccflags-y += -Werror -Wunused -Wmisleading-indentation
> +

Care to enable this for the rest of amdgpu as well?  Or send out an
additional patch to do that?  Either way:
Reviewed-by: Alex Deucher 
mailto:alexander.deuc...@amd.com>>

Alex

>  subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/inc/
>  subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/inc/hw
>  subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/clk_mgr
> --
> 2.40.1
>


Re: [PATCH v2] drm/amd/display: enable more strict compile checks

2023-05-24 Thread Hamza Mahfooz

On 5/24/23 15:22, Alex Deucher wrote:

On Wed, May 24, 2023 at 3:20 PM Hamza Mahfooz  wrote:


Currently, there are quite a number of issues that are quite easy for
the CI to catch, that slip through the cracks. Among them, there are
unused variable and indentation issues. Also, we should consider all
warnings to be compile errors, since the community will eventually end
up complaining about them. So, enable -Werror, -Wunused and
-Wmisleading-indentation for all kernel builds.

Cc: Alex Deucher 
Cc: Harry Wentland 
Cc: Kenny Ho 
Signed-off-by: Hamza Mahfooz 
---
v2: fix grammatical error
---
  drivers/gpu/drm/amd/display/Makefile | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/Makefile 
b/drivers/gpu/drm/amd/display/Makefile
index 0d610cb376bb..3c44162ebe21 100644
--- a/drivers/gpu/drm/amd/display/Makefile
+++ b/drivers/gpu/drm/amd/display/Makefile
@@ -26,6 +26,8 @@

  AMDDALPATH = $(RELATIVE_AMD_DISPLAY_PATH)

+subdir-ccflags-y += -Werror -Wunused -Wmisleading-indentation
+


Care to enable this for the rest of amdgpu as well?  Or send out an
additional patch to do that?  Either way:
Reviewed-by: Alex Deucher 


As far as I can tell, if `CONFIG_DRM_AMD_DC` is set it will run these
checks on at least the base driver code.



Alex


  subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/inc/
  subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/inc/hw
  subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/clk_mgr
--
2.40.1


--
Hamza



Re: [PATCH v2] drm/amd/display: enable more strict compile checks

2023-05-24 Thread Ho, Kenny
[AMD Official Use Only - General]

(+ Felix)

Should we do the same for other modules under amd (amdkfd)?  I was going to 
enable full kernel werror in the kconfig used by my CI but this is probably 
better.

Kenny

From: Alex Deucher 
Sent: Wednesday, May 24, 2023 3:22 PM
To: Mahfooz, Hamza 
Cc: amd-gfx@lists.freedesktop.org ; Li, Sun peng 
(Leo) ; Ho, Kenny ; Pan, Xinhui 
; Siqueira, Rodrigo ; 
linux-ker...@vger.kernel.org ; 
dri-de...@lists.freedesktop.org ; Daniel 
Vetter ; Deucher, Alexander ; David 
Airlie ; Wentland, Harry ; Koenig, 
Christian 
Subject: Re: [PATCH v2] drm/amd/display: enable more strict compile checks

On Wed, May 24, 2023 at 3:20 PM Hamza Mahfooz  wrote:
>
> Currently, there are quite a number of issues that are quite easy for
> the CI to catch, that slip through the cracks. Among them, there are
> unused variable and indentation issues. Also, we should consider all
> warnings to be compile errors, since the community will eventually end
> up complaining about them. So, enable -Werror, -Wunused and
> -Wmisleading-indentation for all kernel builds.
>
> Cc: Alex Deucher 
> Cc: Harry Wentland 
> Cc: Kenny Ho 
> Signed-off-by: Hamza Mahfooz 
> ---
> v2: fix grammatical error
> ---
>  drivers/gpu/drm/amd/display/Makefile | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/display/Makefile 
> b/drivers/gpu/drm/amd/display/Makefile
> index 0d610cb376bb..3c44162ebe21 100644
> --- a/drivers/gpu/drm/amd/display/Makefile
> +++ b/drivers/gpu/drm/amd/display/Makefile
> @@ -26,6 +26,8 @@
>
>  AMDDALPATH = $(RELATIVE_AMD_DISPLAY_PATH)
>
> +subdir-ccflags-y += -Werror -Wunused -Wmisleading-indentation
> +

Care to enable this for the rest of amdgpu as well?  Or send out an
additional patch to do that?  Either way:
Reviewed-by: Alex Deucher 

Alex

>  subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/inc/
>  subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/inc/hw
>  subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/clk_mgr
> --
> 2.40.1
>


Re: [PATCH v2] drm/amd/display: enable more strict compile checks

2023-05-24 Thread Alex Deucher
On Wed, May 24, 2023 at 3:20 PM Hamza Mahfooz  wrote:
>
> Currently, there are quite a number of issues that are quite easy for
> the CI to catch, that slip through the cracks. Among them, there are
> unused variable and indentation issues. Also, we should consider all
> warnings to be compile errors, since the community will eventually end
> up complaining about them. So, enable -Werror, -Wunused and
> -Wmisleading-indentation for all kernel builds.
>
> Cc: Alex Deucher 
> Cc: Harry Wentland 
> Cc: Kenny Ho 
> Signed-off-by: Hamza Mahfooz 
> ---
> v2: fix grammatical error
> ---
>  drivers/gpu/drm/amd/display/Makefile | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/display/Makefile 
> b/drivers/gpu/drm/amd/display/Makefile
> index 0d610cb376bb..3c44162ebe21 100644
> --- a/drivers/gpu/drm/amd/display/Makefile
> +++ b/drivers/gpu/drm/amd/display/Makefile
> @@ -26,6 +26,8 @@
>
>  AMDDALPATH = $(RELATIVE_AMD_DISPLAY_PATH)
>
> +subdir-ccflags-y += -Werror -Wunused -Wmisleading-indentation
> +

Care to enable this for the rest of amdgpu as well?  Or send out an
additional patch to do that?  Either way:
Reviewed-by: Alex Deucher 

Alex

>  subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/inc/
>  subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/inc/hw
>  subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/clk_mgr
> --
> 2.40.1
>


[PATCH v2] drm/amd/display: enable more strict compile checks

2023-05-24 Thread Hamza Mahfooz
Currently, there are quite a number of issues that are quite easy for
the CI to catch, that slip through the cracks. Among them, there are
unused variable and indentation issues. Also, we should consider all
warnings to be compile errors, since the community will eventually end
up complaining about them. So, enable -Werror, -Wunused and
-Wmisleading-indentation for all kernel builds.

Cc: Alex Deucher 
Cc: Harry Wentland 
Cc: Kenny Ho 
Signed-off-by: Hamza Mahfooz 
---
v2: fix grammatical error
---
 drivers/gpu/drm/amd/display/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/Makefile 
b/drivers/gpu/drm/amd/display/Makefile
index 0d610cb376bb..3c44162ebe21 100644
--- a/drivers/gpu/drm/amd/display/Makefile
+++ b/drivers/gpu/drm/amd/display/Makefile
@@ -26,6 +26,8 @@
 
 AMDDALPATH = $(RELATIVE_AMD_DISPLAY_PATH)
 
+subdir-ccflags-y += -Werror -Wunused -Wmisleading-indentation
+
 subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/inc/
 subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/inc/hw
 subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/clk_mgr
-- 
2.40.1



[PATCH] drm/amd/display: enable more strict compile checks

2023-05-24 Thread Hamza Mahfooz
Currently, there are quite a number of issues that are quite easy for
the CI to catch, that slip through the cracks. Among them, there unused
variable and indentation issues. Also, we should consider all warnings
to be compile errors, since the community will eventually end up
complaining about them. So, enable -Werror, -Wunused and
-Wmisleading-indentation for all kernel builds.

Cc: Alex Deucher 
Cc: Harry Wentland 
Cc: Kenny Ho 
Signed-off-by: Hamza Mahfooz 
---
 drivers/gpu/drm/amd/display/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/Makefile 
b/drivers/gpu/drm/amd/display/Makefile
index 0d610cb376bb..3c44162ebe21 100644
--- a/drivers/gpu/drm/amd/display/Makefile
+++ b/drivers/gpu/drm/amd/display/Makefile
@@ -26,6 +26,8 @@
 
 AMDDALPATH = $(RELATIVE_AMD_DISPLAY_PATH)
 
+subdir-ccflags-y += -Werror -Wunused -Wmisleading-indentation
+
 subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/inc/
 subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/inc/hw
 subdir-ccflags-y += -I$(FULL_AMD_DISPLAY_PATH)/dc/clk_mgr
-- 
2.40.1



Re: [PATCH] drm/amdgpu: Fix return types of certain NBIOv7.9 callbacks

2023-05-24 Thread Alex Deucher
Applied.  Thanks!

On Wed, May 24, 2023 at 12:44 PM Nathan Chancellor  wrote:
>
> When building with clang's -Wincompatible-function-pointer-types-strict,
> which ensures that function pointer signatures match exactly to avoid
> tripping clang's Control Flow Integrity (kCFI) checks at run time and
> will eventually be turned on for the kernel, the following instances
> appear in the NBIOv7.9 code:
>
>   drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c:465:32: error: incompatible function 
> pointer types initializing 'int (*)(struct amdgpu_device *)' with an 
> expression of type 'enum amdgpu_gfx_partition (struct amdgpu_device *)' 
> [-Werror,-Wincompatible-function-pointer-types-strict]
>   .get_compute_partition_mode = nbio_v7_9_get_compute_partition_mode,
> ^~~~
>   drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c:467:31: error: incompatible function 
> pointer types initializing 'u32 (*)(struct amdgpu_device *, u32 *)' (aka 
> 'unsigned int (*)(struct amdgpu_device *, unsigned int *)') with an 
> expression of type 'enum amdgpu_memory_partition (struct amdgpu_device *, u32 
> *)' (aka 'enum amdgpu_memory_partition (struct amdgpu_device *, unsigned int 
> *)') [-Werror,-Wincompatible-function-pointer-types-strict]
>   .get_memory_partition_mode = nbio_v7_9_get_memory_partition_mode,
>^~~
>   2 errors generated.
>
> Change the return types of these callbacks to match the prototypes to
> clear up the warning and avoid tripping kCFI at run time. Both functions
> return a value from ffs(), which is an integer that can fit into either
> int or unsigned int.
>
> Fixes: 11f64eb1472f ("drm/amdgpu: add sysfs node for compute partition mode")
> Fixes: 41a717ea8afc ("drm/amdgpu: detect current GPU memory partition mode")
> Signed-off-by: Nathan Chancellor 
> ---
>  drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c 
> b/drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c
> index e082f6343d20..d19325476752 100644
> --- a/drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c
> +++ b/drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c
> @@ -382,7 +382,7 @@ static void nbio_v7_9_enable_doorbell_interrupt(struct 
> amdgpu_device *adev,
>   DOORBELL_INTERRUPT_DISABLE, enable ? 0 : 1);
>  }
>
> -static enum amdgpu_gfx_partition nbio_v7_9_get_compute_partition_mode(struct 
> amdgpu_device *adev)
> +static int nbio_v7_9_get_compute_partition_mode(struct amdgpu_device *adev)
>  {
> u32 tmp, px;
>
> @@ -408,8 +408,8 @@ static void nbio_v7_9_set_compute_partition_mode(struct 
> amdgpu_device *adev,
> WREG32_SOC15(NBIO, 0, regBIF_BX_PF0_PARTITION_COMPUTE_STATUS, tmp);
>  }
>
> -static enum amdgpu_memory_partition
> -nbio_v7_9_get_memory_partition_mode(struct amdgpu_device *adev, u32 
> *supp_modes)
> +static u32 nbio_v7_9_get_memory_partition_mode(struct amdgpu_device *adev,
> +  u32 *supp_modes)
>  {
> u32 tmp;
>
>
> ---
> base-commit: fd8f7bb391fa9c1979232cb5ab5bedb08abc855d
> change-id: 
> 20230524-nbio_v7_9-wincompatible-function-pointer-types-strict-c894636ce146
>
> Best regards,
> --
> Nathan Chancellor 
>


Re: [PATCH v2] amdgpu: validate drm_amdgpu_gem_va addrs

2023-05-24 Thread Christian König

Am 24.05.23 um 00:53 schrieb Chia-I Wu:

Validate drm_amdgpu_gem_va addrs in amdgpu_gem_va_ioctl.
amdgpu_vm_bo_replace_map no longer needs to validate (and its
validations were insufficient either).  amdgpu_vm_bo_map has internal
users and its validations are kept.


No, please keep all validation inside amdgpu_vm.c code.

See the offset is unused or might have a different meaning for some use 
cases, so validating it here is actually not correct.


Christian.



This is motivated by OOB access in amdgpu_vm_update_range when
offset_in_bo+map_size overflows.

Userspace (radeonsi and radv) seems fine as well.

v2: keep the validations in amdgpu_vm_bo_map

Fixes: 9f7eb5367d00 ("drm/amdgpu: actually use the VM map parameters")
Signed-off-by: Chia-I Wu 
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 15 +++
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c  |  8 +---
  2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index d8e683688daab..36d5adfdf0f69 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -681,6 +681,21 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,
uint64_t vm_size;
int r = 0;
  
+	if (args->va_address & ~PAGE_MASK || args->offset_in_bo & ~PAGE_MASK ||

+   args->map_size & ~PAGE_MASK) {
+   dev_dbg(dev->dev, "unaligned va_address 0x%LX, offset_in_bo 0x%LX, 
or map_size 0x%LX\n",
+   args->va_address, args->offset_in_bo, args->map_size);
+   return -EINVAL;
+   }
+
+   if (args->map_size == 0 ||
+   args->va_address + args->map_size < args->va_address ||
+   args->offset_in_bo + args->map_size < args->offset_in_bo) {
+   dev_dbg(dev->dev, "invalid map_size 0x%LX (va_address 0x%LX, 
offset_in_bo 0x%LX)\n",
+   args->map_size, args->va_address, args->offset_in_bo);
+   return -EINVAL;
+   }
+
if (args->va_address < AMDGPU_VA_RESERVED_SIZE) {
dev_dbg(dev->dev,
"va_address 0x%LX is in reserved area 0x%LX\n",
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index b9441ab457ea7..6307baaa136cf 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -1501,15 +1501,9 @@ int amdgpu_vm_bo_replace_map(struct amdgpu_device *adev,
uint64_t eaddr;
int r;
  
-	/* validate the parameters */

-   if (saddr & ~PAGE_MASK || offset & ~PAGE_MASK ||
-   size == 0 || size & ~PAGE_MASK)
-   return -EINVAL;
-
/* make sure object fit at this offset */
eaddr = saddr + size - 1;
-   if (saddr >= eaddr ||
-   (bo && offset + size > amdgpu_bo_size(bo)) ||
+   if ((bo && offset + size > amdgpu_bo_size(bo)) ||
(eaddr >= adev->vm_manager.max_pfn << AMDGPU_GPU_PAGE_SHIFT))
return -EINVAL;
  




Re: [PATCH v3 09/17] drm/amd/display: Register Colorspace property for DP and HDMI

2023-05-24 Thread Harry Wentland



On 3/8/23 04:24, Pekka Paalanen wrote:
> On Tue, 7 Mar 2023 10:10:59 -0500
> Harry Wentland  wrote:
> 
>> We want compositors to be able to set the output
>> colorspace on DP and HDMI outputs, based on the
>> caps reported from the receiver via EDID.
>>
>> Signed-off-by: Harry Wentland 
>> Cc: Pekka Paalanen 
>> Cc: Sebastian Wick 
>> Cc: vitaly.pros...@amd.com
>> Cc: Joshua Ashton 
>> Cc: dri-de...@lists.freedesktop.org
>> Cc: amd-gfx@lists.freedesktop.org
>> Reviewed-By: Joshua Ashton 
>> ---
>>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 15 +++
>>  1 file changed, 15 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
>> b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>> index f91b2ea13d96..2d883c6dae90 100644
>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>> @@ -7184,6 +7184,12 @@ static int amdgpu_dm_connector_get_modes(struct 
>> drm_connector *connector)
>>  return amdgpu_dm_connector->num_modes;
>>  }
>>  
>> +static const u32 supported_colorspaces =
>> +BIT(DRM_MODE_COLORIMETRY_BT709_YCC) |
>> +BIT(DRM_MODE_COLORIMETRY_OPRGB) |
>> +BIT(DRM_MODE_COLORIMETRY_BT2020) |
>> +BIT(DRM_MODE_COLORIMETRY_BT2020_DEPRECATED);
> 
> No DEFAULT?

DEFAULT is always added in drm_mode_create_colorspace_property.

> No BT.709 RGB, i.e. sRGB?
> 

No RGB variants for BT.709 or sRGB are explicitly defined in the API
(which is based on the infoframe values). Not trying to change things
up here.

You'll probably want to select "DEFAULT" if you want sRGB.

Harry

> Doesn't DRM core reject enum uint values that are not listed in the enum
> property?
> 
> 
> Thanks,
> pq
> 
>> +
>>  void amdgpu_dm_connector_init_helper(struct amdgpu_display_manager *dm,
>>   struct amdgpu_dm_connector *aconnector,
>>   int connector_type,
>> @@ -7264,6 +7270,15 @@ void amdgpu_dm_connector_init_helper(struct 
>> amdgpu_display_manager *dm,
>>  adev->mode_info.abm_level_property, 0);
>>  }
>>  
>> +if (connector_type == DRM_MODE_CONNECTOR_HDMIA) {
>> +if 
>> (!drm_mode_create_hdmi_colorspace_property(>base, 
>> supported_colorspaces))
>> +
>> drm_connector_attach_colorspace_property(>base);
>> +} else if (connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
>> +   connector_type == DRM_MODE_CONNECTOR_eDP) {
>> +if (!drm_mode_create_dp_colorspace_property(>base, 
>> supported_colorspaces))
>> +
>> drm_connector_attach_colorspace_property(>base);
>> +}
>> +
>>  if (connector_type == DRM_MODE_CONNECTOR_HDMIA ||
>>  connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
>>  connector_type == DRM_MODE_CONNECTOR_eDP) {
> 



Re: [PATCH] drm/amd: Drop debugfs access to the DPCD

2023-05-24 Thread Harry Wentland



On 5/24/23 13:58, Mario Limonciello wrote:
> There is already access to the DPCD from userspace through
> `CONFIG_DRM_DP_AUX_CHARDEV`, so it's unnecessary to reinvent the wheel
> with a set of extra debugfs nodes specific to amdgpu.
> 
> The character device interface behaves more like you would expect in that
> you can seek/read/write all from the same file.
> 
> Signed-off-by: Mario Limonciello 

Reviewed-by: Harry Wentland 

Harry

> ---
>  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |   4 -
>  .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 107 --
>  2 files changed, 111 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h 
> b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
> index 2e2413fd73a4..4561f55afa99 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
> @@ -661,10 +661,6 @@ struct amdgpu_dm_connector {
>   struct mutex hpd_lock;
>  
>   bool fake_enable;
> -#ifdef CONFIG_DEBUG_FS
> - uint32_t debugfs_dpcd_address;
> - uint32_t debugfs_dpcd_size;
> -#endif
>   bool force_yuv420_output;
>   struct dsc_preferred_settings dsc_settings;
>   union dp_downstream_port_present mst_downstream_port_present;
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c 
> b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
> index 827fcb4fb3b3..82234397dd44 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
> @@ -1039,88 +1039,6 @@ static ssize_t dp_sdp_message_debugfs_write(struct 
> file *f, const char __user *b
>   return write_size;
>  }
>  
> -static ssize_t dp_dpcd_address_write(struct file *f, const char __user *buf,
> -  size_t size, loff_t *pos)
> -{
> - int r;
> - struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
> -
> - if (size < sizeof(connector->debugfs_dpcd_address))
> - return -EINVAL;
> -
> - r = copy_from_user(>debugfs_dpcd_address,
> - buf, sizeof(connector->debugfs_dpcd_address));
> -
> - return size - r;
> -}
> -
> -static ssize_t dp_dpcd_size_write(struct file *f, const char __user *buf,
> -  size_t size, loff_t *pos)
> -{
> - int r;
> - struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
> -
> - if (size < sizeof(connector->debugfs_dpcd_size))
> - return -EINVAL;
> -
> - r = copy_from_user(>debugfs_dpcd_size,
> - buf, sizeof(connector->debugfs_dpcd_size));
> -
> - if (connector->debugfs_dpcd_size > 256)
> - connector->debugfs_dpcd_size = 0;
> -
> - return size - r;
> -}
> -
> -static ssize_t dp_dpcd_data_write(struct file *f, const char __user *buf,
> -  size_t size, loff_t *pos)
> -{
> - int r;
> - char *data;
> - struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
> - struct dc_link *link = connector->dc_link;
> - uint32_t write_size = connector->debugfs_dpcd_size;
> -
> - if (!write_size || size < write_size)
> - return -EINVAL;
> -
> - data = kzalloc(write_size, GFP_KERNEL);
> - if (!data)
> - return 0;
> -
> - r = copy_from_user(data, buf, write_size);
> -
> - dm_helpers_dp_write_dpcd(link->ctx, link,
> - connector->debugfs_dpcd_address, data, write_size - r);
> - kfree(data);
> - return write_size - r;
> -}
> -
> -static ssize_t dp_dpcd_data_read(struct file *f, char __user *buf,
> -  size_t size, loff_t *pos)
> -{
> - int r;
> - char *data;
> - struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
> - struct dc_link *link = connector->dc_link;
> - uint32_t read_size = connector->debugfs_dpcd_size;
> -
> - if (!read_size || size < read_size)
> - return 0;
> -
> - data = kzalloc(read_size, GFP_KERNEL);
> - if (!data)
> - return 0;
> -
> - dm_helpers_dp_read_dpcd(link->ctx, link,
> - connector->debugfs_dpcd_address, data, read_size);
> -
> - r = copy_to_user(buf, data, read_size);
> -
> - kfree(data);
> - return read_size - r;
> -}
> -
>  /* function: Read link's DSC & FEC capabilities
>   *
>   *
> @@ -2682,25 +2600,6 @@ static const struct file_operations sdp_message_fops = 
> {
>   .llseek = default_llseek
>  };
>  
> -static const struct file_operations dp_dpcd_address_debugfs_fops = {
> - .owner = THIS_MODULE,
> - .write = dp_dpcd_address_write,
> - .llseek = default_llseek
> -};
> -
> -static const struct file_operations dp_dpcd_size_debugfs_fops = {
> - .owner = THIS_MODULE,
> - .write = dp_dpcd_size_write,
> - .llseek = default_llseek
> -};
> -
> -static const struct file_operations dp_dpcd_data_debugfs_fops = {
> - 

Re: [PATCH] drm/amd: Drop debugfs access to the DPCD

2023-05-24 Thread Hamza Mahfooz

On 5/24/23 13:58, Mario Limonciello wrote:

There is already access to the DPCD from userspace through
`CONFIG_DRM_DP_AUX_CHARDEV`, so it's unnecessary to reinvent the wheel
with a set of extra debugfs nodes specific to amdgpu.

The character device interface behaves more like you would expect in that
you can seek/read/write all from the same file.

Signed-off-by: Mario Limonciello 


Reviewed-by: Hamza Mahfooz 


---
  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |   4 -
  .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 107 --
  2 files changed, 111 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
index 2e2413fd73a4..4561f55afa99 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
@@ -661,10 +661,6 @@ struct amdgpu_dm_connector {
struct mutex hpd_lock;
  
  	bool fake_enable;

-#ifdef CONFIG_DEBUG_FS
-   uint32_t debugfs_dpcd_address;
-   uint32_t debugfs_dpcd_size;
-#endif
bool force_yuv420_output;
struct dsc_preferred_settings dsc_settings;
union dp_downstream_port_present mst_downstream_port_present;
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
index 827fcb4fb3b3..82234397dd44 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
@@ -1039,88 +1039,6 @@ static ssize_t dp_sdp_message_debugfs_write(struct file 
*f, const char __user *b
return write_size;
  }
  
-static ssize_t dp_dpcd_address_write(struct file *f, const char __user *buf,

-size_t size, loff_t *pos)
-{
-   int r;
-   struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
-
-   if (size < sizeof(connector->debugfs_dpcd_address))
-   return -EINVAL;
-
-   r = copy_from_user(>debugfs_dpcd_address,
-   buf, sizeof(connector->debugfs_dpcd_address));
-
-   return size - r;
-}
-
-static ssize_t dp_dpcd_size_write(struct file *f, const char __user *buf,
-size_t size, loff_t *pos)
-{
-   int r;
-   struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
-
-   if (size < sizeof(connector->debugfs_dpcd_size))
-   return -EINVAL;
-
-   r = copy_from_user(>debugfs_dpcd_size,
-   buf, sizeof(connector->debugfs_dpcd_size));
-
-   if (connector->debugfs_dpcd_size > 256)
-   connector->debugfs_dpcd_size = 0;
-
-   return size - r;
-}
-
-static ssize_t dp_dpcd_data_write(struct file *f, const char __user *buf,
-size_t size, loff_t *pos)
-{
-   int r;
-   char *data;
-   struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
-   struct dc_link *link = connector->dc_link;
-   uint32_t write_size = connector->debugfs_dpcd_size;
-
-   if (!write_size || size < write_size)
-   return -EINVAL;
-
-   data = kzalloc(write_size, GFP_KERNEL);
-   if (!data)
-   return 0;
-
-   r = copy_from_user(data, buf, write_size);
-
-   dm_helpers_dp_write_dpcd(link->ctx, link,
-   connector->debugfs_dpcd_address, data, write_size - r);
-   kfree(data);
-   return write_size - r;
-}
-
-static ssize_t dp_dpcd_data_read(struct file *f, char __user *buf,
-size_t size, loff_t *pos)
-{
-   int r;
-   char *data;
-   struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
-   struct dc_link *link = connector->dc_link;
-   uint32_t read_size = connector->debugfs_dpcd_size;
-
-   if (!read_size || size < read_size)
-   return 0;
-
-   data = kzalloc(read_size, GFP_KERNEL);
-   if (!data)
-   return 0;
-
-   dm_helpers_dp_read_dpcd(link->ctx, link,
-   connector->debugfs_dpcd_address, data, read_size);
-
-   r = copy_to_user(buf, data, read_size);
-
-   kfree(data);
-   return read_size - r;
-}
-
  /* function: Read link's DSC & FEC capabilities
   *
   *
@@ -2682,25 +2600,6 @@ static const struct file_operations sdp_message_fops = {
.llseek = default_llseek
  };
  
-static const struct file_operations dp_dpcd_address_debugfs_fops = {

-   .owner = THIS_MODULE,
-   .write = dp_dpcd_address_write,
-   .llseek = default_llseek
-};
-
-static const struct file_operations dp_dpcd_size_debugfs_fops = {
-   .owner = THIS_MODULE,
-   .write = dp_dpcd_size_write,
-   .llseek = default_llseek
-};
-
-static const struct file_operations dp_dpcd_data_debugfs_fops = {
-   .owner = THIS_MODULE,
-   .read = dp_dpcd_data_read,
-   .write = dp_dpcd_data_write,
-   .llseek = default_llseek
-};
-
  static const struct 

[PATCH] drm/amd: Drop debugfs access to the DPCD

2023-05-24 Thread Mario Limonciello
There is already access to the DPCD from userspace through
`CONFIG_DRM_DP_AUX_CHARDEV`, so it's unnecessary to reinvent the wheel
with a set of extra debugfs nodes specific to amdgpu.

The character device interface behaves more like you would expect in that
you can seek/read/write all from the same file.

Signed-off-by: Mario Limonciello 
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |   4 -
 .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 107 --
 2 files changed, 111 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
index 2e2413fd73a4..4561f55afa99 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
@@ -661,10 +661,6 @@ struct amdgpu_dm_connector {
struct mutex hpd_lock;
 
bool fake_enable;
-#ifdef CONFIG_DEBUG_FS
-   uint32_t debugfs_dpcd_address;
-   uint32_t debugfs_dpcd_size;
-#endif
bool force_yuv420_output;
struct dsc_preferred_settings dsc_settings;
union dp_downstream_port_present mst_downstream_port_present;
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
index 827fcb4fb3b3..82234397dd44 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
@@ -1039,88 +1039,6 @@ static ssize_t dp_sdp_message_debugfs_write(struct file 
*f, const char __user *b
return write_size;
 }
 
-static ssize_t dp_dpcd_address_write(struct file *f, const char __user *buf,
-size_t size, loff_t *pos)
-{
-   int r;
-   struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
-
-   if (size < sizeof(connector->debugfs_dpcd_address))
-   return -EINVAL;
-
-   r = copy_from_user(>debugfs_dpcd_address,
-   buf, sizeof(connector->debugfs_dpcd_address));
-
-   return size - r;
-}
-
-static ssize_t dp_dpcd_size_write(struct file *f, const char __user *buf,
-size_t size, loff_t *pos)
-{
-   int r;
-   struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
-
-   if (size < sizeof(connector->debugfs_dpcd_size))
-   return -EINVAL;
-
-   r = copy_from_user(>debugfs_dpcd_size,
-   buf, sizeof(connector->debugfs_dpcd_size));
-
-   if (connector->debugfs_dpcd_size > 256)
-   connector->debugfs_dpcd_size = 0;
-
-   return size - r;
-}
-
-static ssize_t dp_dpcd_data_write(struct file *f, const char __user *buf,
-size_t size, loff_t *pos)
-{
-   int r;
-   char *data;
-   struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
-   struct dc_link *link = connector->dc_link;
-   uint32_t write_size = connector->debugfs_dpcd_size;
-
-   if (!write_size || size < write_size)
-   return -EINVAL;
-
-   data = kzalloc(write_size, GFP_KERNEL);
-   if (!data)
-   return 0;
-
-   r = copy_from_user(data, buf, write_size);
-
-   dm_helpers_dp_write_dpcd(link->ctx, link,
-   connector->debugfs_dpcd_address, data, write_size - r);
-   kfree(data);
-   return write_size - r;
-}
-
-static ssize_t dp_dpcd_data_read(struct file *f, char __user *buf,
-size_t size, loff_t *pos)
-{
-   int r;
-   char *data;
-   struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
-   struct dc_link *link = connector->dc_link;
-   uint32_t read_size = connector->debugfs_dpcd_size;
-
-   if (!read_size || size < read_size)
-   return 0;
-
-   data = kzalloc(read_size, GFP_KERNEL);
-   if (!data)
-   return 0;
-
-   dm_helpers_dp_read_dpcd(link->ctx, link,
-   connector->debugfs_dpcd_address, data, read_size);
-
-   r = copy_to_user(buf, data, read_size);
-
-   kfree(data);
-   return read_size - r;
-}
-
 /* function: Read link's DSC & FEC capabilities
  *
  *
@@ -2682,25 +2600,6 @@ static const struct file_operations sdp_message_fops = {
.llseek = default_llseek
 };
 
-static const struct file_operations dp_dpcd_address_debugfs_fops = {
-   .owner = THIS_MODULE,
-   .write = dp_dpcd_address_write,
-   .llseek = default_llseek
-};
-
-static const struct file_operations dp_dpcd_size_debugfs_fops = {
-   .owner = THIS_MODULE,
-   .write = dp_dpcd_size_write,
-   .llseek = default_llseek
-};
-
-static const struct file_operations dp_dpcd_data_debugfs_fops = {
-   .owner = THIS_MODULE,
-   .read = dp_dpcd_data_read,
-   .write = dp_dpcd_data_write,
-   .llseek = default_llseek
-};
-
 static const struct file_operations dp_max_bpc_debugfs_fops = {
.owner = THIS_MODULE,
.read 

Re: [PATCH] drm/amdgpu: Reset CP_VMID_PREEMPT after trailing fence signaled

2023-05-24 Thread Deucher, Alexander
[AMD Official Use Only - General]

Acked-by: Alex Deucher 

From: amd-gfx  on behalf of 
jiadong@amd.com 
Sent: Wednesday, May 24, 2023 12:35 AM
To: amd-gfx@lists.freedesktop.org 
Cc: Zhu, Jiadong 
Subject: [PATCH] drm/amdgpu: Reset CP_VMID_PREEMPT after trailing fence signaled

From: Jiadong Zhu 

When MEC executes unmap_queue for mid command buffer preemption, it will
kick the write pointer of the gfx ring, set CP_VMID_PREEMPT to trigger the
preemption and wait for CP_VMID_PREEMPT becomes zero after the preemption
done. There is a race condition that PFP may excute the resetting command
before MEC set CP_VMID_PREEMPT. As a result, hang happens as
CP_VMID_PREEMPT is always 0x.

To avoid this, we send resetting CP_VMID_PREEMPT command after the trailing
fence is siganled and update gfx write pointer explicitly.

Signed-off-by: Jiadong Zhu 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
index 8bf95a6b0767..cbdd9918b3e7 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
@@ -5402,10 +5402,6 @@ static int gfx_v9_0_ring_preempt_ib(struct amdgpu_ring 
*ring)
 amdgpu_ring_alloc(ring, 13);
 gfx_v9_0_ring_emit_fence(ring, ring->trail_fence_gpu_addr,
  ring->trail_seq, AMDGPU_FENCE_FLAG_EXEC | 
AMDGPU_FENCE_FLAG_INT);
-   /*reset the CP_VMID_PREEMPT after trailing fence*/
-   amdgpu_ring_emit_wreg(ring,
- SOC15_REG_OFFSET(GC, 0, mmCP_VMID_PREEMPT),
- 0x0);

 /* assert IB preemption, emit the trailing fence */
 kiq->pmf->kiq_unmap_queues(kiq_ring, ring, PREEMPT_QUEUES_NO_UNMAP,
@@ -5428,6 +5424,10 @@ static int gfx_v9_0_ring_preempt_ib(struct amdgpu_ring 
*ring)
 DRM_WARN("ring %d timeout to preempt ib\n", ring->idx);
 }

+   /*reset the CP_VMID_PREEMPT after trailing fence*/
+   amdgpu_ring_emit_wreg(ring,
+ SOC15_REG_OFFSET(GC, 0, mmCP_VMID_PREEMPT),
+ 0x0);
 amdgpu_ring_commit(ring);

 /* deassert preemption condition */
--
2.25.1



Re: [PATCH v3 03/17] drm/connector: Deprecate split for BT.2020 in drm_colorspace enum

2023-05-24 Thread Harry Wentland



On 3/8/23 04:09, Pekka Paalanen wrote:
> On Tue, 7 Mar 2023 10:10:53 -0500
> Harry Wentland  wrote:
> 
>> From: Joshua Ashton 
>>
>> Userspace has no way of controlling or knowing the pixel encoding
>> currently, so there is no way for it to ever get the right values here.
>>
>> When we do add pixel_encoding control from userspace,we can pick the
>> right value for the colorimetry packet based on the
>> pixel_encoding + the colorspace.
>>
>> Let's deprecate these values, and have one BT.2020 colorspace entry
>> that userspace can use.
>>
>> v2:
>>  - leave CYCC alone for now; it serves a purpose
>>  - leave BT2020_RGB the new default BT2020
>>
>> Signed-off-by: Joshua Ashton 
>> Signed-off-by: Harry Wentland 
>> Reviewed-by: Harry Wentland 
>>
>> Cc: Pekka Paalanen 
>> Cc: Sebastian Wick 
>> Cc: vitaly.pros...@amd.com
>> Cc: Uma Shankar 
>> Cc: Ville Syrjälä 
>> Cc: Joshua Ashton 
>> Cc: dri-de...@lists.freedesktop.org
>> Cc: amd-gfx@lists.freedesktop.org
>> ---
>>  drivers/gpu/drm/display/drm_hdmi_helper.c |  7 +++
>>  drivers/gpu/drm/drm_connector.c   |  8 
>>  drivers/gpu/drm/i915/display/intel_dp.c   | 14 +++---
>>  include/drm/drm_connector.h   | 15 +--
>>  4 files changed, 23 insertions(+), 21 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/display/drm_hdmi_helper.c 
>> b/drivers/gpu/drm/display/drm_hdmi_helper.c
>> index faf5e9efa7d3..05a0d03ffcda 100644
>> --- a/drivers/gpu/drm/display/drm_hdmi_helper.c
>> +++ b/drivers/gpu/drm/display/drm_hdmi_helper.c
>> @@ -97,8 +97,7 @@ EXPORT_SYMBOL(drm_hdmi_infoframe_set_hdr_metadata);
>>  #define HDMI_COLORIMETRY_OPYCC_601  (C(3) | EC(3) | ACE(0))
>>  #define HDMI_COLORIMETRY_OPRGB  (C(3) | EC(4) | ACE(0))
>>  #define HDMI_COLORIMETRY_BT2020_CYCC(C(3) | EC(5) | ACE(0))
>> -#define HDMI_COLORIMETRY_BT2020_RGB (C(3) | EC(6) | ACE(0))
>> -#define HDMI_COLORIMETRY_BT2020_YCC (C(3) | EC(6) | ACE(0))
>> +#define HDMI_COLORIMETRY_BT2020 (C(3) | EC(6) | ACE(0))
>>  #define HDMI_COLORIMETRY_DCI_P3_RGB_D65 (C(3) | EC(7) | ACE(0))
>>  #define HDMI_COLORIMETRY_DCI_P3_RGB_THEATER (C(3) | EC(7) | ACE(1))
>>  
>> @@ -112,8 +111,8 @@ static const u32 hdmi_colorimetry_val[] = {
>>  [DRM_MODE_COLORIMETRY_OPYCC_601] = HDMI_COLORIMETRY_OPYCC_601,
>>  [DRM_MODE_COLORIMETRY_OPRGB] = HDMI_COLORIMETRY_OPRGB,
>>  [DRM_MODE_COLORIMETRY_BT2020_CYCC] = HDMI_COLORIMETRY_BT2020_CYCC,
>> -[DRM_MODE_COLORIMETRY_BT2020_RGB] = HDMI_COLORIMETRY_BT2020_RGB,
>> -[DRM_MODE_COLORIMETRY_BT2020_YCC] = HDMI_COLORIMETRY_BT2020_YCC,
>> +[DRM_MODE_COLORIMETRY_BT2020_DEPRECATED] = HDMI_COLORIMETRY_BT2020,
>> +[DRM_MODE_COLORIMETRY_BT2020] = HDMI_COLORIMETRY_BT2020,
>>  };
>>  
>>  #undef C
>> diff --git a/drivers/gpu/drm/drm_connector.c 
>> b/drivers/gpu/drm/drm_connector.c
>> index 61c29ce74b03..fe7eab15f727 100644
>> --- a/drivers/gpu/drm/drm_connector.c
>> +++ b/drivers/gpu/drm/drm_connector.c
>> @@ -1031,9 +1031,9 @@ static const struct drm_prop_enum_list 
>> hdmi_colorspaces[] = {
>>  /* Colorimetry based on ITU-R BT.2020 */
>>  { DRM_MODE_COLORIMETRY_BT2020_CYCC, "BT2020_CYCC" },
>>  /* Colorimetry based on ITU-R BT.2020 */
>> -{ DRM_MODE_COLORIMETRY_BT2020_RGB, "BT2020_RGB" },
>> +{ DRM_MODE_COLORIMETRY_BT2020, "BT2020" },
>>  /* Colorimetry based on ITU-R BT.2020 */
>> -{ DRM_MODE_COLORIMETRY_BT2020_YCC, "BT2020_YCC" },
>> +{ DRM_MODE_COLORIMETRY_BT2020_DEPRECATED, "BT2020_DEPRECATED" },
>>  /* Added as part of Additional Colorimetry Extension in 861.G */
>>  { DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65, "DCI-P3_RGB_D65" },
>>  { DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER, "DCI-P3_RGB_Theater" },
>> @@ -1054,7 +1054,7 @@ static const struct drm_prop_enum_list 
>> dp_colorspaces[] = {
>>  /* Colorimetry based on SMPTE RP 431-2 */
>>  { DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65, "DCI-P3_RGB_D65" },
>>  /* Colorimetry based on ITU-R BT.2020 */
>> -{ DRM_MODE_COLORIMETRY_BT2020_RGB, "BT2020_RGB" },
>> +{ DRM_MODE_COLORIMETRY_BT2020, "BT2020" },
>>  { DRM_MODE_COLORIMETRY_BT601_YCC, "BT601_YCC" },
>>  { DRM_MODE_COLORIMETRY_BT709_YCC, "BT709_YCC" },
>>  /* Standard Definition Colorimetry based on IEC 61966-2-4 */
>> @@ -1068,7 +1068,7 @@ static const struct drm_prop_enum_list 
>> dp_colorspaces[] = {
>>  /* Colorimetry based on ITU-R BT.2020 */
>>  { DRM_MODE_COLORIMETRY_BT2020_CYCC, "BT2020_CYCC" },
>>  /* Colorimetry based on ITU-R BT.2020 */
>> -{ DRM_MODE_COLORIMETRY_BT2020_YCC, "BT2020_YCC" },
>> +{ DRM_MODE_COLORIMETRY_BT2020_DEPRECATED, "BT2020_DEPRECATED" },
> 
> Let's hope no-one complains about missing the old string names in UABI. :-)
> 

As discussed at the hackfest, I'll drop this patch.

Harry

> Actually, you should write in the commit message why removing old names
> is fine.
> 
>>  };
>>  
>>  /**
>> diff --git 

Re: [PATCH v3 02/17] drm/connector: Add enum documentation to drm_colorspace

2023-05-24 Thread Harry Wentland



On 3/8/23 03:59, Pekka Paalanen wrote:
> On Tue, 7 Mar 2023 10:10:52 -0500
> Harry Wentland  wrote:
> 
>> From: Joshua Ashton 
>>
>> To match the other enums, and add more information about these values.
>>
>> v2:
>>  - Specify where an enum entry comes from
>>  - Clarify DEFAULT and NO_DATA behavior
>>  - BT.2020 CYCC is "constant luminance"
>>  - correct type for BT.601
>>
>> Signed-off-by: Joshua Ashton 
>> Signed-off-by: Harry Wentland 
>> Reviewed-by: Harry Wentland 
> 
> Hi,
> 
> this effort is really good, but of course I still find things to
> nitpick about. If there is no answer to my questions, then I would
> prefer the documentation to spell out the unknowns and ambiguities.
> 

Finally finding time to look at this again and want to make sure I
try to address your comments as best as I can. I'm terribly at tracking
emails, so if anything was clarified already I apologize.

>> Cc: Pekka Paalanen 
>> Cc: Sebastian Wick 
>> Cc: vitaly.pros...@amd.com
>> Cc: Uma Shankar 
>> Cc: Ville Syrjälä 
>> Cc: Joshua Ashton 
>> Cc: dri-de...@lists.freedesktop.org
>> Cc: amd-gfx@lists.freedesktop.org
>> ---
>>  include/drm/drm_connector.h | 67 +++--
>>  1 file changed, 65 insertions(+), 2 deletions(-)
>>
>> diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
>> index 6d6a53a6b010..bb078666dc34 100644
>> --- a/include/drm/drm_connector.h
>> +++ b/include/drm/drm_connector.h
>> @@ -363,13 +363,76 @@ enum drm_privacy_screen_status {
>>  PRIVACY_SCREEN_ENABLED_LOCKED,
>>  };
>>  
>> -/*
>> - * This is a consolidated colorimetry list supported by HDMI and
>> +/**
>> + * enum drm_colorspace - color space
>> + *
>> + * This enum is a consolidated colorimetry list supported by HDMI and
>>   * DP protocol standard. The respective connectors will register
>>   * a property with the subset of this list (supported by that
>>   * respective protocol). Userspace will set the colorspace through
>>   * a colorspace property which will be created and exposed to
>>   * userspace.
>> + *
>> + * DP definitions come from the DP v2.0 spec
>> + * HDMI definitions come from the CTA-861-H spec
>> + *
>> + * @DRM_MODE_COLORIMETRY_DEFAULT:
>> + *   Driver specific behavior.
>> + *   For DP:
>> + *  RGB encoded: sRGB (IEC 61966-2-1)
>> + *  YCbCr encoded: ITU-R BT.601 colorimetry format
> 
> Does this mean that HDMI behavior is driver-specific while DP behavior
> is as defined?
> 

I should drop the bits that specify what this means for DP. I really
just took the 0h value for the colorimetry of the VSC SDP packet
(SDP = DP infoframe).

> Is it intentional that YCbCr encoding also uses different RGB-primaries
> than RGB-encoded signal? (BT.601 vs. BT.709/sRGB)
> 
> Or do you need to be more explicit on which parts of each spec apply
> (ColourPrimaries vs. TransferCharacteristics vs. MatrixCoefficients in
> CICP parlance)?
> 
> E.g. BT.709/sRGB ColourPrimaries with BT.601 MatrixCoefficients.
> 
>> + * @DRM_MODE_COLORIMETRY_NO_DATA:
>> + *   Driver specific behavior.
>> + *   For HDMI:
>> + *  Sets "No Data" in infoframe
> 
> Does DEFAULT mean that something else than "No Data" may be set in the
> HDMI infoframe?
> 
> If so, since these two have the same value, where is the difference? Is
> DEFAULT purely an UAPI token, and NO_DATA used internally? Or NO_DATA
> used only when crafting actual infoframe packets?
> 
> Should NO_DATA be documented to be a strictly driver-internal value,
> and not documented with UAPI?
> 

I don't think I have an answer for you. I will remove the "For HDMI"
bit to avoid confusion.

> I am unclear if userspace is using these enum values directly, or do
> they use the string names only.
> 

Userspace is using these enum values directly.

>> + * @DRM_MODE_COLORIMETRY_SMPTE_170M_YCC:
>> + *   (HDMI)
>> + *   SMPTE ST 170M colorimetry format
> 
> Does "colorimetry format" mean that the spec is used in full, for all
> of ColourPrimaries, TransferCharacteristics and MatrixCoefficients?
> 
> If yes, good. If not, the wording misleads me.
> 
>> + * @DRM_MODE_COLORIMETRY_BT709_YCC:
>> + *   (HDMI, DP)
>> + *   ITU-R BT.709 colorimetry format
>> + * @DRM_MODE_COLORIMETRY_XVYCC_601:
>> + *   (HDMI, DP)
>> + *   xvYCC601 colorimetry format
>> + * @DRM_MODE_COLORIMETRY_XVYCC_709:
>> + *   (HDMI, DP)
>> + *   xvYCC709 colorimetry format
> 
> Btw. xvYCC are funny because they require limited quantization range
> encoding, but use the foot- and headroom to encode out-of-nominal-range
> values in order to expand the color gamut with negative and greater
> than unity values.
> 
> Just for curiosity, is it in any way possible today to make use of that
> extended color gamut through KMS? Has it ever been possible?
> 
> I mean, the KMS color pipeline assumes full-range RGB, so I don't see
> any way to make use of xvYCC.
> 

I don't know it's possible. I wasn't the one to write the original
API for this. I think this API defines things that have never been
well 

[PATCH] drm/amdgpu: Fix return types of certain NBIOv7.9 callbacks

2023-05-24 Thread Nathan Chancellor
When building with clang's -Wincompatible-function-pointer-types-strict,
which ensures that function pointer signatures match exactly to avoid
tripping clang's Control Flow Integrity (kCFI) checks at run time and
will eventually be turned on for the kernel, the following instances
appear in the NBIOv7.9 code:

  drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c:465:32: error: incompatible function 
pointer types initializing 'int (*)(struct amdgpu_device *)' with an expression 
of type 'enum amdgpu_gfx_partition (struct amdgpu_device *)' 
[-Werror,-Wincompatible-function-pointer-types-strict]
  .get_compute_partition_mode = nbio_v7_9_get_compute_partition_mode,
^~~~
  drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c:467:31: error: incompatible function 
pointer types initializing 'u32 (*)(struct amdgpu_device *, u32 *)' (aka 
'unsigned int (*)(struct amdgpu_device *, unsigned int *)') with an expression 
of type 'enum amdgpu_memory_partition (struct amdgpu_device *, u32 *)' (aka 
'enum amdgpu_memory_partition (struct amdgpu_device *, unsigned int *)') 
[-Werror,-Wincompatible-function-pointer-types-strict]
  .get_memory_partition_mode = nbio_v7_9_get_memory_partition_mode,
   ^~~
  2 errors generated.

Change the return types of these callbacks to match the prototypes to
clear up the warning and avoid tripping kCFI at run time. Both functions
return a value from ffs(), which is an integer that can fit into either
int or unsigned int.

Fixes: 11f64eb1472f ("drm/amdgpu: add sysfs node for compute partition mode")
Fixes: 41a717ea8afc ("drm/amdgpu: detect current GPU memory partition mode")
Signed-off-by: Nathan Chancellor 
---
 drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c 
b/drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c
index e082f6343d20..d19325476752 100644
--- a/drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c
+++ b/drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c
@@ -382,7 +382,7 @@ static void nbio_v7_9_enable_doorbell_interrupt(struct 
amdgpu_device *adev,
  DOORBELL_INTERRUPT_DISABLE, enable ? 0 : 1);
 }
 
-static enum amdgpu_gfx_partition nbio_v7_9_get_compute_partition_mode(struct 
amdgpu_device *adev)
+static int nbio_v7_9_get_compute_partition_mode(struct amdgpu_device *adev)
 {
u32 tmp, px;
 
@@ -408,8 +408,8 @@ static void nbio_v7_9_set_compute_partition_mode(struct 
amdgpu_device *adev,
WREG32_SOC15(NBIO, 0, regBIF_BX_PF0_PARTITION_COMPUTE_STATUS, tmp);
 }
 
-static enum amdgpu_memory_partition
-nbio_v7_9_get_memory_partition_mode(struct amdgpu_device *adev, u32 
*supp_modes)
+static u32 nbio_v7_9_get_memory_partition_mode(struct amdgpu_device *adev,
+  u32 *supp_modes)
 {
u32 tmp;
 

---
base-commit: fd8f7bb391fa9c1979232cb5ab5bedb08abc855d
change-id: 
20230524-nbio_v7_9-wincompatible-function-pointer-types-strict-c894636ce146

Best regards,
-- 
Nathan Chancellor 



Re: [PATCH] drm/amd/display: Drop unused res_create_maximus_funcs & debug_defaults_diags variables

2023-05-24 Thread Hamza Mahfooz

On 5/24/23 12:19, Srinivasan Shanmugam wrote:

gcc with W=1
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn321/dcn321_resource.c:1346:43: 
warning: ‘res_create_maximus_funcs’ defined but not used 
[-Wunused-const-variable=]
  1346 | static const struct resource_create_funcs res_create_maximus_funcs = {
   |   ^~~~
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn321/dcn321_resource.c:735:38: 
warning: ‘debug_defaults_diags’ defined but not used [-Wunused-const-variable=]
   735 | static const struct dc_debug_options debug_defaults_diags = {
   |  ^~~~
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn32/dcn32_resource.c:1360:43: 
warning: ‘res_create_maximus_funcs’ defined but not used 
[-Wunused-const-variable=]
  1360 | static const struct resource_create_funcs res_create_maximus_funcs = {
   |   ^~~~
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn32/dcn32_resource.c:737:38: 
warning: ‘debug_defaults_diags’ defined but not used [-Wunused-const-variable=]
   737 | static const struct dc_debug_options debug_defaults_diags = {
   |

These variables are not used so removed them.

Cc: Aurabindo Pillai 
Signed-off-by: Srinivasan Shanmugam 


There is already a series queued that addresses this issue.


---
  .../drm/amd/display/dc/dcn32/dcn32_resource.c | 29 --
  .../amd/display/dc/dcn321/dcn321_resource.c   | 30 ---
  2 files changed, 59 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource.c
index 33abc8c9d4be..2e6b39fe2613 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource.c
@@ -734,26 +734,6 @@ static const struct dc_debug_options debug_defaults_drv = {
.fpo_vactive_max_blank_us = 1000,
  };
  
-static const struct dc_debug_options debug_defaults_diags = {

-   .disable_dmcu = true,
-   .force_abm_enable = false,
-   .timing_trace = true,
-   .clock_trace = true,
-   .disable_dpp_power_gate = true,
-   .disable_hubp_power_gate = true,
-   .disable_dsc_power_gate = true,
-   .disable_clock_gate = true,
-   .disable_pplib_clock_request = true,
-   .disable_pplib_wm_range = true,
-   .disable_stutter = false,
-   .scl_reset_length10 = true,
-   .dwb_fi_phase = -1, // -1 = disable
-   .dmub_command_table = true,
-   .enable_tri_buf = true,
-   .use_max_lb = true,
-   .force_disable_subvp = true
-};
-
  static struct dce_aux *dcn32_aux_engine_create(
struct dc_context *ctx,
uint32_t inst)
@@ -1357,15 +1337,6 @@ static const struct resource_create_funcs 
res_create_funcs = {
.create_hwseq = dcn32_hwseq_create,
  };
  
-static const struct resource_create_funcs res_create_maximus_funcs = {

-   .read_dce_straps = NULL,
-   .create_audio = NULL,
-   .create_stream_encoder = NULL,
-   .create_hpo_dp_stream_encoder = dcn32_hpo_dp_stream_encoder_create,
-   .create_hpo_dp_link_encoder = dcn32_hpo_dp_link_encoder_create,
-   .create_hwseq = dcn32_hwseq_create,
-};
-
  static void dcn32_resource_destruct(struct dcn32_resource_pool *pool)
  {
unsigned int i;
diff --git a/drivers/gpu/drm/amd/display/dc/dcn321/dcn321_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn321/dcn321_resource.c
index af0bb3e94250..bbcd3579fea6 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn321/dcn321_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn321/dcn321_resource.c
@@ -732,27 +732,6 @@ static const struct dc_debug_options debug_defaults_drv = {
.fpo_vactive_max_blank_us = 1000,
  };
  
-static const struct dc_debug_options debug_defaults_diags = {

-   .disable_dmcu = true,
-   .force_abm_enable = false,
-   .timing_trace = true,
-   .clock_trace = true,
-   .disable_dpp_power_gate = true,
-   .disable_hubp_power_gate = true,
-   .disable_dsc_power_gate = true,
-   .disable_clock_gate = true,
-   .disable_pplib_clock_request = true,
-   .disable_pplib_wm_range = true,
-   .disable_stutter = false,
-   .scl_reset_length10 = true,
-   .dwb_fi_phase = -1, // -1 = disable
-   .dmub_command_table = true,
-   .enable_tri_buf = true,
-   .use_max_lb = true,
-   .force_disable_subvp = true,
-};
-
-
  static struct dce_aux *dcn321_aux_engine_create(
struct dc_context *ctx,
uint32_t inst)
@@ -1343,15 +1322,6 @@ static const struct resource_create_funcs 
res_create_funcs = {
.create_hwseq = dcn321_hwseq_create,
  };
  
-static const struct resource_create_funcs res_create_maximus_funcs = {

-   .read_dce_straps = NULL,
-   .create_audio = NULL,
-   .create_stream_encoder = NULL,
-   .create_hpo_dp_stream_encoder = dcn321_hpo_dp_stream_encoder_create,
-   

[PATCH] drm/amd/display: Drop unused res_create_maximus_funcs & debug_defaults_diags variables

2023-05-24 Thread Srinivasan Shanmugam
gcc with W=1
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn321/dcn321_resource.c:1346:43: 
warning: ‘res_create_maximus_funcs’ defined but not used 
[-Wunused-const-variable=]
 1346 | static const struct resource_create_funcs res_create_maximus_funcs = {
  |   ^~~~
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn321/dcn321_resource.c:735:38: 
warning: ‘debug_defaults_diags’ defined but not used [-Wunused-const-variable=]
  735 | static const struct dc_debug_options debug_defaults_diags = {
  |  ^~~~
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn32/dcn32_resource.c:1360:43: 
warning: ‘res_create_maximus_funcs’ defined but not used 
[-Wunused-const-variable=]
 1360 | static const struct resource_create_funcs res_create_maximus_funcs = {
  |   ^~~~
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn32/dcn32_resource.c:737:38: 
warning: ‘debug_defaults_diags’ defined but not used [-Wunused-const-variable=]
  737 | static const struct dc_debug_options debug_defaults_diags = {
  |

These variables are not used so removed them.

Cc: Aurabindo Pillai 
Signed-off-by: Srinivasan Shanmugam 
---
 .../drm/amd/display/dc/dcn32/dcn32_resource.c | 29 --
 .../amd/display/dc/dcn321/dcn321_resource.c   | 30 ---
 2 files changed, 59 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource.c
index 33abc8c9d4be..2e6b39fe2613 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource.c
@@ -734,26 +734,6 @@ static const struct dc_debug_options debug_defaults_drv = {
.fpo_vactive_max_blank_us = 1000,
 };
 
-static const struct dc_debug_options debug_defaults_diags = {
-   .disable_dmcu = true,
-   .force_abm_enable = false,
-   .timing_trace = true,
-   .clock_trace = true,
-   .disable_dpp_power_gate = true,
-   .disable_hubp_power_gate = true,
-   .disable_dsc_power_gate = true,
-   .disable_clock_gate = true,
-   .disable_pplib_clock_request = true,
-   .disable_pplib_wm_range = true,
-   .disable_stutter = false,
-   .scl_reset_length10 = true,
-   .dwb_fi_phase = -1, // -1 = disable
-   .dmub_command_table = true,
-   .enable_tri_buf = true,
-   .use_max_lb = true,
-   .force_disable_subvp = true
-};
-
 static struct dce_aux *dcn32_aux_engine_create(
struct dc_context *ctx,
uint32_t inst)
@@ -1357,15 +1337,6 @@ static const struct resource_create_funcs 
res_create_funcs = {
.create_hwseq = dcn32_hwseq_create,
 };
 
-static const struct resource_create_funcs res_create_maximus_funcs = {
-   .read_dce_straps = NULL,
-   .create_audio = NULL,
-   .create_stream_encoder = NULL,
-   .create_hpo_dp_stream_encoder = dcn32_hpo_dp_stream_encoder_create,
-   .create_hpo_dp_link_encoder = dcn32_hpo_dp_link_encoder_create,
-   .create_hwseq = dcn32_hwseq_create,
-};
-
 static void dcn32_resource_destruct(struct dcn32_resource_pool *pool)
 {
unsigned int i;
diff --git a/drivers/gpu/drm/amd/display/dc/dcn321/dcn321_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn321/dcn321_resource.c
index af0bb3e94250..bbcd3579fea6 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn321/dcn321_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn321/dcn321_resource.c
@@ -732,27 +732,6 @@ static const struct dc_debug_options debug_defaults_drv = {
.fpo_vactive_max_blank_us = 1000,
 };
 
-static const struct dc_debug_options debug_defaults_diags = {
-   .disable_dmcu = true,
-   .force_abm_enable = false,
-   .timing_trace = true,
-   .clock_trace = true,
-   .disable_dpp_power_gate = true,
-   .disable_hubp_power_gate = true,
-   .disable_dsc_power_gate = true,
-   .disable_clock_gate = true,
-   .disable_pplib_clock_request = true,
-   .disable_pplib_wm_range = true,
-   .disable_stutter = false,
-   .scl_reset_length10 = true,
-   .dwb_fi_phase = -1, // -1 = disable
-   .dmub_command_table = true,
-   .enable_tri_buf = true,
-   .use_max_lb = true,
-   .force_disable_subvp = true,
-};
-
-
 static struct dce_aux *dcn321_aux_engine_create(
struct dc_context *ctx,
uint32_t inst)
@@ -1343,15 +1322,6 @@ static const struct resource_create_funcs 
res_create_funcs = {
.create_hwseq = dcn321_hwseq_create,
 };
 
-static const struct resource_create_funcs res_create_maximus_funcs = {
-   .read_dce_straps = NULL,
-   .create_audio = NULL,
-   .create_stream_encoder = NULL,
-   .create_hpo_dp_stream_encoder = dcn321_hpo_dp_stream_encoder_create,
-   .create_hpo_dp_link_encoder = dcn321_hpo_dp_link_encoder_create,
-   .create_hwseq = dcn321_hwseq_create,
-};
-
 static void 

Re: (subset) [PATCH v4 0/9] drm: fdinfo memory stats

2023-05-24 Thread Neil Armstrong

On 24/05/2023 18:10, Neil Armstrong wrote:

Hi,

On Mon, 15 May 2023 07:30:07 -0700, Rob Clark wrote:

Similar motivation to other similar recent attempt[1].  But with an
attempt to have some shared code for this.  As well as documentation.

It is probably a bit UMA-centric, I guess devices with VRAM might want
some placement stats as well.  But this seems like a reasonable start.

Basic gputop support: https://patchwork.freedesktop.org/series/116236/
And already nvtop support: https://github.com/Syllo/nvtop/pull/204

[...]


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

[1/9] drm/docs: Fix usage stats typos
   
https://cgit.freedesktop.org/drm/drm-misc/commit/?id=0020582a8afe9a8570f80ec503c59bf049a616de
[2/9] drm: Add common fdinfo helper
   
https://cgit.freedesktop.org/drm/drm-misc/commit/?id=3f09a0cd4ea3b9d34495450d686227d48e7ec648
[3/9] drm/msm: Switch to fdinfo helper
   
https://cgit.freedesktop.org/drm/drm-misc/commit/?id=51d86ee5e07ccef85af04ee9850b0baa107999b6
[4/9] drm/amdgpu: Switch to fdinfo helper
   
https://cgit.freedesktop.org/drm/drm-misc/commit/?id=376c25f8ca47084c4f0aff0f14684780756ccef4
[5/9] drm: Add fdinfo memory stats
   
https://cgit.freedesktop.org/drm/drm-misc/commit/?id=686b21b5f6ca2f8a716f9a4ade07246dbfb2713e
[6/9] drm/msm: Add memory stats to fdinfo
   
https://cgit.freedesktop.org/drm/drm-misc/commit/?id=3e9757f5ddb98238226ad68a1609aa313de35adb
[7/9] drm/doc: Relax fdinfo string constraints
   
https://cgit.freedesktop.org/drm/drm-misc/commit/?id=90d63a150b85fd1debb9c01237fb78faee02746a



Hmm no idea what happened, but I really applied v5 !

Neil


Re: [PATCH v5 0/7] drm: fdinfo memory stats

2023-05-24 Thread Neil Armstrong
Hi,

On Wed, 24 May 2023 08:59:30 -0700, Rob Clark wrote:
> From: Rob Clark 
> 
> Similar motivation to other similar recent attempt[1].  But with an
> attempt to have some shared code for this.  As well as documentation.
> 
> It is probably a bit UMA-centric, I guess devices with VRAM might want
> some placement stats as well.  But this seems like a reasonable start.
> 
> [...]

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

[1/7] drm/docs: Fix usage stats typos
  
https://cgit.freedesktop.org/drm/drm-misc/commit/?id=0020582a8afe9a8570f80ec503c59bf049a616de
[2/7] drm: Add common fdinfo helper
  
https://cgit.freedesktop.org/drm/drm-misc/commit/?id=3f09a0cd4ea3b9d34495450d686227d48e7ec648
[3/7] drm/msm: Switch to fdinfo helper
  
https://cgit.freedesktop.org/drm/drm-misc/commit/?id=51d86ee5e07ccef85af04ee9850b0baa107999b6
[4/7] drm/amdgpu: Switch to fdinfo helper
  
https://cgit.freedesktop.org/drm/drm-misc/commit/?id=376c25f8ca47084c4f0aff0f14684780756ccef4
[5/7] drm: Add fdinfo memory stats
  
https://cgit.freedesktop.org/drm/drm-misc/commit/?id=686b21b5f6ca2f8a716f9a4ade07246dbfb2713e
[6/7] drm/msm: Add memory stats to fdinfo
  
https://cgit.freedesktop.org/drm/drm-misc/commit/?id=3e9757f5ddb98238226ad68a1609aa313de35adb
[7/7] drm/doc: Relax fdinfo string constraints
  
https://cgit.freedesktop.org/drm/drm-misc/commit/?id=90d63a150b85fd1debb9c01237fb78faee02746a

-- 
Neil



Re: (subset) [PATCH v4 0/9] drm: fdinfo memory stats

2023-05-24 Thread Neil Armstrong
Hi,

On Mon, 15 May 2023 07:30:07 -0700, Rob Clark wrote:
> Similar motivation to other similar recent attempt[1].  But with an
> attempt to have some shared code for this.  As well as documentation.
> 
> It is probably a bit UMA-centric, I guess devices with VRAM might want
> some placement stats as well.  But this seems like a reasonable start.
> 
> Basic gputop support: https://patchwork.freedesktop.org/series/116236/
> And already nvtop support: https://github.com/Syllo/nvtop/pull/204
> 
> [...]

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

[1/9] drm/docs: Fix usage stats typos
  
https://cgit.freedesktop.org/drm/drm-misc/commit/?id=0020582a8afe9a8570f80ec503c59bf049a616de
[2/9] drm: Add common fdinfo helper
  
https://cgit.freedesktop.org/drm/drm-misc/commit/?id=3f09a0cd4ea3b9d34495450d686227d48e7ec648
[3/9] drm/msm: Switch to fdinfo helper
  
https://cgit.freedesktop.org/drm/drm-misc/commit/?id=51d86ee5e07ccef85af04ee9850b0baa107999b6
[4/9] drm/amdgpu: Switch to fdinfo helper
  
https://cgit.freedesktop.org/drm/drm-misc/commit/?id=376c25f8ca47084c4f0aff0f14684780756ccef4
[5/9] drm: Add fdinfo memory stats
  
https://cgit.freedesktop.org/drm/drm-misc/commit/?id=686b21b5f6ca2f8a716f9a4ade07246dbfb2713e
[6/9] drm/msm: Add memory stats to fdinfo
  
https://cgit.freedesktop.org/drm/drm-misc/commit/?id=3e9757f5ddb98238226ad68a1609aa313de35adb
[7/9] drm/doc: Relax fdinfo string constraints
  
https://cgit.freedesktop.org/drm/drm-misc/commit/?id=90d63a150b85fd1debb9c01237fb78faee02746a

-- 
Neil



[PATCH v2] drm/amdgpu: Enable VM_CONTEXT1_CNTL after page table addr is set.

2023-05-24 Thread ghostfly233
In setup_vmid_config functions of all mmhubs, the CONTEXT1_CNTL reg is
enabled before related CONTEXT1_PAGE_TABLE_START_ADDR and
CONTEXT1_PAGE_TABLE_END_ADDR regs are written, which may cause
undefined behavior.

This patch enable CONTEXT1_CNTL after page table addresses are set,
so that it can ensure no undefined behavior will happen.

Signed-off-by: Zibin Liu 
---
 drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c   | 5 -
 drivers/gpu/drm/amd/amdgpu/gfxhub_v1_2.c   | 5 -
 drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.c   | 5 -
 drivers/gpu/drm/amd/amdgpu/gfxhub_v2_1.c   | 5 -
 drivers/gpu/drm/amd/amdgpu/gfxhub_v3_0.c   | 5 -
 drivers/gpu/drm/amd/amdgpu/gfxhub_v3_0_3.c | 5 -
 drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c| 5 -
 drivers/gpu/drm/amd/amdgpu/mmhub_v1_7.c| 5 -
 drivers/gpu/drm/amd/amdgpu/mmhub_v1_8.c| 5 -
 drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c| 5 -
 drivers/gpu/drm/amd/amdgpu/mmhub_v2_3.c| 5 -
 drivers/gpu/drm/amd/amdgpu/mmhub_v3_0.c| 5 -
 drivers/gpu/drm/amd/amdgpu/mmhub_v3_0_1.c  | 5 -
 drivers/gpu/drm/amd/amdgpu/mmhub_v3_0_2.c  | 5 -
 drivers/gpu/drm/amd/amdgpu/mmhub_v9_4.c| 7 ++-
 15 files changed, 62 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c
index ab2325f6c7ac..8ff4f70c97a6 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c
@@ -261,7 +261,7 @@ static void gfxhub_v1_0_setup_vmid_config(struct 
amdgpu_device *adev)
 
for (i = 0; i <= 14; i++) {
tmp = RREG32_SOC15_OFFSET(GC, 0, mmVM_CONTEXT1_CNTL, i);
-   tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, ENABLE_CONTEXT, 1);
+   tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, ENABLE_CONTEXT, 0);
tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, PAGE_TABLE_DEPTH,
num_level);
tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL,
@@ -302,6 +302,9 @@ static void gfxhub_v1_0_setup_vmid_config(struct 
amdgpu_device *adev)
WREG32_SOC15_OFFSET(GC, 0, 
mmVM_CONTEXT1_PAGE_TABLE_END_ADDR_HI32,
i * hub->ctx_addr_distance,
upper_32_bits(adev->vm_manager.max_pfn - 
1));
+   tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, ENABLE_CONTEXT, 1);
+   WREG32_SOC15_OFFSET(GC, 0, mmVM_CONTEXT1_CNTL,
+   i * hub->ctx_distance, tmp);
}
 }
 
diff --git a/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_2.c 
b/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_2.c
index c59c6c85fbff..1c501066926b 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_2.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_2.c
@@ -266,7 +266,7 @@ static void gfxhub_v1_2_setup_vmid_config(struct 
amdgpu_device *adev)
 
for (i = 0; i <= 14; i++) {
tmp = RREG32_SOC15_OFFSET(GC, 0, regVM_CONTEXT1_CNTL, i);
-   tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, ENABLE_CONTEXT, 1);
+   tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, ENABLE_CONTEXT, 0);
tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, PAGE_TABLE_DEPTH,
num_level);
tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL,
@@ -311,6 +311,9 @@ static void gfxhub_v1_2_setup_vmid_config(struct 
amdgpu_device *adev)
regVM_CONTEXT1_PAGE_TABLE_END_ADDR_HI32,
i * hub->ctx_addr_distance,
upper_32_bits(adev->vm_manager.max_pfn - 
1));
+   tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, ENABLE_CONTEXT, 1);
+   WREG32_SOC15_OFFSET(GC, 0, regVM_CONTEXT1_CNTL,
+   i * hub->ctx_distance, tmp);
}
 }
 
diff --git a/drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.c
index 9b3a02527318..ef660f3bca7b 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.c
@@ -288,7 +288,7 @@ static void gfxhub_v2_0_setup_vmid_config(struct 
amdgpu_device *adev)
 
for (i = 0; i <= 14; i++) {
tmp = RREG32_SOC15_OFFSET(GC, 0, mmGCVM_CONTEXT1_CNTL, i);
-   tmp = REG_SET_FIELD(tmp, GCVM_CONTEXT1_CNTL, ENABLE_CONTEXT, 1);
+   tmp = REG_SET_FIELD(tmp, GCVM_CONTEXT1_CNTL, ENABLE_CONTEXT, 0);
tmp = REG_SET_FIELD(tmp, GCVM_CONTEXT1_CNTL, PAGE_TABLE_DEPTH,
adev->vm_manager.num_level);
tmp = REG_SET_FIELD(tmp, GCVM_CONTEXT1_CNTL,
@@ -324,6 +324,9 @@ static void gfxhub_v2_0_setup_vmid_config(struct 
amdgpu_device *adev)
WREG32_SOC15_OFFSET(GC, 0, 
mmGCVM_CONTEXT1_PAGE_TABLE_END_ADDR_HI32,
i * hub->ctx_addr_distance,
upper_32_bits(adev->vm_manager.max_pfn - 
1));
+ 

[PATCH v5 4/7] drm/amdgpu: Switch to fdinfo helper

2023-05-24 Thread Rob Clark
From: Rob Clark 

v2: Rebase on drm-misc-next

Signed-off-by: Rob Clark 
Reviewed-by: Christian König 
Acked-by: Dave Airlie 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c|  3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c | 32 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.h |  2 +-
 3 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index b1ca1ab6d6ad..1b46e7ac7cb0 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -2740,21 +2740,21 @@ static const struct file_operations 
amdgpu_driver_kms_fops = {
.flush = amdgpu_flush,
.release = drm_release,
.unlocked_ioctl = amdgpu_drm_ioctl,
.mmap = drm_gem_mmap,
.poll = drm_poll,
.read = drm_read,
 #ifdef CONFIG_COMPAT
.compat_ioctl = amdgpu_kms_compat_ioctl,
 #endif
 #ifdef CONFIG_PROC_FS
-   .show_fdinfo = amdgpu_show_fdinfo
+   .show_fdinfo = drm_show_fdinfo,
 #endif
 };
 
 int amdgpu_file_to_fpriv(struct file *filp, struct amdgpu_fpriv **fpriv)
 {
struct drm_file *file;
 
if (!filp)
return -EINVAL;
 
@@ -2795,20 +2795,21 @@ static const struct drm_driver amdgpu_kms_driver = {
DRIVER_SYNCOBJ_TIMELINE,
.open = amdgpu_driver_open_kms,
.postclose = amdgpu_driver_postclose_kms,
.lastclose = amdgpu_driver_lastclose_kms,
.ioctls = amdgpu_ioctls_kms,
.num_ioctls = ARRAY_SIZE(amdgpu_ioctls_kms),
.dumb_create = amdgpu_mode_dumb_create,
.dumb_map_offset = amdgpu_mode_dumb_mmap,
.fops = _driver_kms_fops,
.release = _driver_release_kms,
+   .show_fdinfo = amdgpu_show_fdinfo,
 
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
.gem_prime_import = amdgpu_gem_prime_import,
.gem_prime_mmap = drm_gem_prime_mmap,
 
.name = DRIVER_NAME,
.desc = DRIVER_DESC,
.date = DRIVER_DATE,
.major = KMS_DRIVER_MAJOR,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c
index c57252f004e8..13d7413d4ca3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c
@@ -46,23 +46,22 @@ static const char *amdgpu_ip_name[AMDGPU_HW_IP_NUM] = {
[AMDGPU_HW_IP_COMPUTE]  =   "compute",
[AMDGPU_HW_IP_DMA]  =   "dma",
[AMDGPU_HW_IP_UVD]  =   "dec",
[AMDGPU_HW_IP_VCE]  =   "enc",
[AMDGPU_HW_IP_UVD_ENC]  =   "enc_1",
[AMDGPU_HW_IP_VCN_DEC]  =   "dec",
[AMDGPU_HW_IP_VCN_ENC]  =   "enc",
[AMDGPU_HW_IP_VCN_JPEG] =   "jpeg",
 };
 
-void amdgpu_show_fdinfo(struct seq_file *m, struct file *f)
+void amdgpu_show_fdinfo(struct drm_printer *p, struct drm_file *file)
 {
-   struct drm_file *file = f->private_data;
struct amdgpu_device *adev = drm_to_adev(file->minor->dev);
struct amdgpu_fpriv *fpriv = file->driver_priv;
struct amdgpu_vm *vm = >vm;
 
struct amdgpu_mem_stats stats;
ktime_t usage[AMDGPU_HW_IP_NUM];
uint32_t bus, dev, fn, domain;
unsigned int hw_ip;
int ret;
 
@@ -80,38 +79,37 @@ void amdgpu_show_fdinfo(struct seq_file *m, struct file *f)
amdgpu_bo_unreserve(vm->root.bo);
 
amdgpu_ctx_mgr_usage(>ctx_mgr, usage);
 
/*
 * **
 * For text output format description please see drm-usage-stats.rst!
 * **
 */
 
-   seq_printf(m, "pasid:\t%u\n", fpriv->vm.pasid);
-   seq_printf(m, "drm-driver:\t%s\n", file->minor->dev->driver->name);
-   seq_printf(m, "drm-pdev:\t%04x:%02x:%02x.%d\n", domain, bus, dev, fn);
-   seq_printf(m, "drm-client-id:\t%Lu\n", vm->immediate.fence_context);
-   seq_printf(m, "drm-memory-vram:\t%llu KiB\n", stats.vram/1024UL);
-   seq_printf(m, "drm-memory-gtt: \t%llu KiB\n", stats.gtt/1024UL);
-   seq_printf(m, "drm-memory-cpu: \t%llu KiB\n", stats.cpu/1024UL);
-   seq_printf(m, "amd-memory-visible-vram:\t%llu KiB\n",
+   drm_printf(p, "pasid:\t%u\n", fpriv->vm.pasid);
+   drm_printf(p, "drm-driver:\t%s\n", file->minor->dev->driver->name);
+   drm_printf(p, "drm-pdev:\t%04x:%02x:%02x.%d\n", domain, bus, dev, fn);
+   drm_printf(p, "drm-client-id:\t%Lu\n", vm->immediate.fence_context);
+   drm_printf(p, "drm-memory-vram:\t%llu KiB\n", stats.vram/1024UL);
+   drm_printf(p, "drm-memory-gtt: \t%llu KiB\n", stats.gtt/1024UL);
+   drm_printf(p, "drm-memory-cpu: \t%llu KiB\n", stats.cpu/1024UL);
+   drm_printf(p, "amd-memory-visible-vram:\t%llu KiB\n",
   stats.visible_vram/1024UL);
-   seq_printf(m, 

[PATCH v5 0/7] drm: fdinfo memory stats

2023-05-24 Thread Rob Clark
From: Rob Clark 

Similar motivation to other similar recent attempt[1].  But with an
attempt to have some shared code for this.  As well as documentation.

It is probably a bit UMA-centric, I guess devices with VRAM might want
some placement stats as well.  But this seems like a reasonable start.

Basic gputop support: https://patchwork.freedesktop.org/series/116236/
And already nvtop support: https://github.com/Syllo/nvtop/pull/204

I've combined the separate series to add comm/cmdline override onto
the end of this, simply out of convenience (they would otherwise
conflict in a bunch of places).

v2: Extend things to allow for multiple regions other than just system
"memory", make drm_show_memory_stats() a helper so that, drivers
can use it or not based on their needs (but in either case, re-
use drm_print_memory_stats()
v3: Docs fixes
v4: use u64 for drm_memory_stats, small docs update and collected
Tvrtko's a-b
v5: Rebase on drm-misc-next, drop comm/cmdline override patches

[1] https://patchwork.freedesktop.org/series/112397/

Rob Clark (7):
  drm/docs: Fix usage stats typos
  drm: Add common fdinfo helper
  drm/msm: Switch to fdinfo helper
  drm/amdgpu: Switch to fdinfo helper
  drm: Add fdinfo memory stats
  drm/msm: Add memory stats to fdinfo
  drm/doc: Relax fdinfo string constraints

 Documentation/gpu/drm-usage-stats.rst  |  91 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c|   3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c |  32 +++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.h |   2 +-
 drivers/gpu/drm/drm_file.c | 132 +
 drivers/gpu/drm/msm/msm_drv.c  |  13 +-
 drivers/gpu/drm/msm/msm_gem.c  |  15 +++
 drivers/gpu/drm/msm/msm_gpu.c  |   2 -
 include/drm/drm_drv.h  |   7 ++
 include/drm/drm_file.h |  32 +
 include/drm/drm_gem.h  |  32 +
 11 files changed, 308 insertions(+), 53 deletions(-)

-- 
2.40.1



Re: [PATCH 1/2] drm/amd/display: clean up some inconsistent indenting

2023-05-24 Thread Hamza Mahfooz

On 5/24/23 04:57, Jiapeng Chong wrote:

No functional modification involved.

drivers/gpu/drm/amd/amdgpu/../display/dc/dml/dcn314/dcn314_fpu.c:269 
dcn314_update_bw_bounding_box_fpu() warn: inconsistent indenting.

Reported-by: Abaci Robot 
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5305
Signed-off-by: Jiapeng Chong 


I have applied the series, thanks!


---
  drivers/gpu/drm/amd/display/dc/dml/dcn314/dcn314_fpu.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn314/dcn314_fpu.c 
b/drivers/gpu/drm/amd/display/dc/dml/dcn314/dcn314_fpu.c
index 318b9c2bc9be..c9afddd11589 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/dcn314/dcn314_fpu.c
+++ b/drivers/gpu/drm/amd/display/dc/dml/dcn314/dcn314_fpu.c
@@ -265,8 +265,7 @@ void dcn314_update_bw_bounding_box_fpu(struct dc *dc, 
struct clk_bw_params *bw_p
}
  
  	dcn20_patch_bounding_box(dc, _14_soc);

-
-   dml_init_instance(>dml, _14_soc, _14_ip, 
DML_PROJECT_DCN314);
+   dml_init_instance(>dml, _14_soc, _14_ip, 
DML_PROJECT_DCN314);
  }
  
  static bool is_dual_plane(enum surface_pixel_format format)

--
Hamza



Re: [PATCH -next 01/13] drm/amd/display: remove unused definition

2023-05-24 Thread Hamza Mahfooz

On 5/23/23 23:59, Yang Li wrote:

Eliminate the following warning:
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn10/dcn10_resource.c:889:43: 
warning: unused variable 'res_create_maximus_funcs'

Reported-by: Abaci Robot 
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5296
Fixes: 00df97e1df57 ("drm/amd/display: Clean FPGA code in dc")
Signed-off-by: Yang Li 


I have applied the series, thanks!


---
  drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c | 7 ---
  1 file changed, 7 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
index a0625209c86d..26ddf73fd5b1 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
@@ -886,13 +886,6 @@ static const struct resource_create_funcs res_create_funcs 
= {
.create_hwseq = dcn10_hwseq_create,
  };
  
-static const struct resource_create_funcs res_create_maximus_funcs = {

-   .read_dce_straps = NULL,
-   .create_audio = NULL,
-   .create_stream_encoder = NULL,
-   .create_hwseq = dcn10_hwseq_create,
-};
-
  static void dcn10_clock_source_destroy(struct clock_source **clk_src)
  {
kfree(TO_DCE110_CLK_SRC(*clk_src));

--
Hamza



Re: [PATCH] drm/amdgpu: Enable GCVM_CONTEXT1_CNTL after page table addr is set.

2023-05-24 Thread Alex Deucher
On Wed, May 24, 2023 at 11:25 AM ghostfly233  wrote:
>
> In gfxhub_v2_1_setup_vmid_config(), the GCVM_CONTEXT1_CNTL reg is
> enabled before related GCVM_CONTEXT1_PAGE_TABLE_START_ADDR and
> GCVM_CONTEXT1_PAGE_TABLE_END_ADDR regs are written, which may
> cause undefined behavior.
>
> This patch enable GCVM_CONNTEXT1_CNTL after page table addresses are set,
> so that it can ensure no undefined behavior will happen.

Please update all of the gfxhub and mmhub files with this change.

Alex

>
> Signed-off-by: Zibin Liu 
> ---
>  drivers/gpu/drm/amd/amdgpu/gfxhub_v2_1.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfxhub_v2_1.c 
> b/drivers/gpu/drm/amd/amdgpu/gfxhub_v2_1.c
> index 4aacbbec31e2..791afc8e9e85 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfxhub_v2_1.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfxhub_v2_1.c
> @@ -297,7 +297,7 @@ static void gfxhub_v2_1_setup_vmid_config(struct 
> amdgpu_device *adev)
>
> for (i = 0; i <= 14; i++) {
> tmp = RREG32_SOC15_OFFSET(GC, 0, mmGCVM_CONTEXT1_CNTL, i);
> -   tmp = REG_SET_FIELD(tmp, GCVM_CONTEXT1_CNTL, ENABLE_CONTEXT, 
> 1);
> +   tmp = REG_SET_FIELD(tmp, GCVM_CONTEXT1_CNTL, ENABLE_CONTEXT, 
> 0);
> tmp = REG_SET_FIELD(tmp, GCVM_CONTEXT1_CNTL, PAGE_TABLE_DEPTH,
> adev->vm_manager.num_level);
> tmp = REG_SET_FIELD(tmp, GCVM_CONTEXT1_CNTL,
> @@ -333,6 +333,9 @@ static void gfxhub_v2_1_setup_vmid_config(struct 
> amdgpu_device *adev)
> WREG32_SOC15_OFFSET(GC, 0, 
> mmGCVM_CONTEXT1_PAGE_TABLE_END_ADDR_HI32,
> i * hub->ctx_addr_distance,
> upper_32_bits(adev->vm_manager.max_pfn - 
> 1));
> +   tmp = REG_SET_FIELD(tmp, GCVM_CONTEXT1_CNTL, ENABLE_CONTEXT, 
> 1);
> +   WREG32_SOC15_OFFSET(GC, 0, mmGCVM_CONTEXT1_CNTL,
> +   i * hub->ctx_distance, tmp);
> }
>
> hub->vm_cntx_cntl = tmp;
> --
> 2.34.1
>


[PATCH] drm/amdgpu: Enable GCVM_CONTEXT1_CNTL after page table addr is set.

2023-05-24 Thread ghostfly233
In gfxhub_v2_1_setup_vmid_config(), the GCVM_CONTEXT1_CNTL reg is
enabled before related GCVM_CONTEXT1_PAGE_TABLE_START_ADDR and
GCVM_CONTEXT1_PAGE_TABLE_END_ADDR regs are written, which may
cause undefined behavior.

This patch enable GCVM_CONNTEXT1_CNTL after page table addresses are set,
so that it can ensure no undefined behavior will happen.

Signed-off-by: Zibin Liu 
---
 drivers/gpu/drm/amd/amdgpu/gfxhub_v2_1.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfxhub_v2_1.c 
b/drivers/gpu/drm/amd/amdgpu/gfxhub_v2_1.c
index 4aacbbec31e2..791afc8e9e85 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfxhub_v2_1.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfxhub_v2_1.c
@@ -297,7 +297,7 @@ static void gfxhub_v2_1_setup_vmid_config(struct 
amdgpu_device *adev)
 
for (i = 0; i <= 14; i++) {
tmp = RREG32_SOC15_OFFSET(GC, 0, mmGCVM_CONTEXT1_CNTL, i);
-   tmp = REG_SET_FIELD(tmp, GCVM_CONTEXT1_CNTL, ENABLE_CONTEXT, 1);
+   tmp = REG_SET_FIELD(tmp, GCVM_CONTEXT1_CNTL, ENABLE_CONTEXT, 0);
tmp = REG_SET_FIELD(tmp, GCVM_CONTEXT1_CNTL, PAGE_TABLE_DEPTH,
adev->vm_manager.num_level);
tmp = REG_SET_FIELD(tmp, GCVM_CONTEXT1_CNTL,
@@ -333,6 +333,9 @@ static void gfxhub_v2_1_setup_vmid_config(struct 
amdgpu_device *adev)
WREG32_SOC15_OFFSET(GC, 0, 
mmGCVM_CONTEXT1_PAGE_TABLE_END_ADDR_HI32,
i * hub->ctx_addr_distance,
upper_32_bits(adev->vm_manager.max_pfn - 
1));
+   tmp = REG_SET_FIELD(tmp, GCVM_CONTEXT1_CNTL, ENABLE_CONTEXT, 1);
+   WREG32_SOC15_OFFSET(GC, 0, mmGCVM_CONTEXT1_CNTL,
+   i * hub->ctx_distance, tmp);
}
 
hub->vm_cntx_cntl = tmp;
-- 
2.34.1



Re: [PATCH] drm/amdgpu: Fix defined but not used gfx9_cs_data in gfx_v9_4_3.c

2023-05-24 Thread Alex Deucher
On Wed, May 24, 2023 at 11:22 AM Srinivasan Shanmugam
 wrote:
>
> gcc with W=1
> In file included from drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c:33:
> drivers/gpu/drm/amd/amdgpu/clearstate_gfx9.h:939:36: warning: ‘gfx9_cs_data’ 
> defined but not used [-Wunused-const-variable=]
>   939 | static const struct cs_section_def gfx9_cs_data[] = {
>   |
>
> gfx9_cs_data is not used in gfx_v9_4_3.c, hence remove its
> include in gfx_v9_4_3.c
>
> Cc: Christian König 
> Cc: Alex Deucher 
> Signed-off-by: Srinivasan Shanmugam 

Acked-by: Alex Deucher 

> ---
>  drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c 
> b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
> index ed41a7862d9f..bdaea50cafe7 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
> @@ -29,7 +29,6 @@
>  #include "soc15_common.h"
>  #include "vega10_enum.h"
>
> -#include "clearstate_gfx9.h"
>  #include "v9_structs.h"
>
>  #include "ivsrcid/gfx/irqsrcs_gfx_9_0.h"
> --
> 2.25.1
>


[PATCH] drm/amdgpu: Fix defined but not used gfx9_cs_data in gfx_v9_4_3.c

2023-05-24 Thread Srinivasan Shanmugam
gcc with W=1
In file included from drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c:33:
drivers/gpu/drm/amd/amdgpu/clearstate_gfx9.h:939:36: warning: ‘gfx9_cs_data’ 
defined but not used [-Wunused-const-variable=]
  939 | static const struct cs_section_def gfx9_cs_data[] = {
  |

gfx9_cs_data is not used in gfx_v9_4_3.c, hence remove its
include in gfx_v9_4_3.c

Cc: Christian König 
Cc: Alex Deucher 
Signed-off-by: Srinivasan Shanmugam 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
index ed41a7862d9f..bdaea50cafe7 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
@@ -29,7 +29,6 @@
 #include "soc15_common.h"
 #include "vega10_enum.h"
 
-#include "clearstate_gfx9.h"
 #include "v9_structs.h"
 
 #include "ivsrcid/gfx/irqsrcs_gfx_9_0.h"
-- 
2.25.1



[PATCH v3] drm/amdgpu: bypass bios dependent operations

2023-05-24 Thread Shiwu Zhang
Since bios reading does not work currently so just bypass all operations
related to bios

v2: hardcode the vram info for APP_APU case (hawking)
v3: correct the vram_width with channel number * channel size (lijo)

Signed-off-by: Shiwu Zhang 
Reviewed-by: Yang Wang 
Reviewed-by: Hawking Zhang 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 66 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c|  7 ++-
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c  | 63 +
 3 files changed, 85 insertions(+), 51 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index a9d9bbe8586b..46cfa8821c2d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1388,6 +1388,15 @@ int amdgpu_device_resize_fb_bar(struct amdgpu_device 
*adev)
return 0;
 }
 
+static bool amdgpu_device_read_bios(struct amdgpu_device *adev)
+{
+   if (hweight32(adev->aid_mask) && (adev->flags & AMD_IS_APU)) {
+   return false;
+   }
+
+   return true;
+}
+
 /*
  * GPU helpers function.
  */
@@ -1407,6 +1416,9 @@ bool amdgpu_device_need_post(struct amdgpu_device *adev)
if (amdgpu_sriov_vf(adev))
return false;
 
+   if (!amdgpu_device_read_bios(adev))
+   return false;
+
if (amdgpu_passthrough(adev)) {
/* for FIJI: In whole GPU pass-through virtualization case, 
after VM reboot
 * some old smc fw still need driver do vPost otherwise gpu 
hang, while
@@ -2317,14 +2329,16 @@ static int amdgpu_device_ip_early_init(struct 
amdgpu_device *adev)
return r;
 
/* Read BIOS */
-   if (!amdgpu_get_bios(adev))
-   return -EINVAL;
+   if (amdgpu_device_read_bios(adev)) {
+   if (!amdgpu_get_bios(adev))
+   return -EINVAL;
 
-   r = amdgpu_atombios_init(adev);
-   if (r) {
-   dev_err(adev->dev, "amdgpu_atombios_init 
failed\n");
-   amdgpu_vf_error_put(adev, 
AMDGIM_ERROR_VF_ATOMBIOS_INIT_FAIL, 0, 0);
-   return r;
+   r = amdgpu_atombios_init(adev);
+   if (r) {
+   dev_err(adev->dev, 
"amdgpu_atombios_init failed\n");
+   amdgpu_vf_error_put(adev, 
AMDGIM_ERROR_VF_ATOMBIOS_INIT_FAIL, 0, 0);
+   return r;
+   }
}
 
/*get pf2vf msg info at it's earliest time*/
@@ -3944,25 +3958,27 @@ int amdgpu_device_init(struct amdgpu_device *adev,
}
}
 
-   if (adev->is_atom_fw) {
-   /* Initialize clocks */
-   r = amdgpu_atomfirmware_get_clock_info(adev);
-   if (r) {
-   dev_err(adev->dev, "amdgpu_atomfirmware_get_clock_info 
failed\n");
-   amdgpu_vf_error_put(adev, 
AMDGIM_ERROR_VF_ATOMBIOS_GET_CLOCK_FAIL, 0, 0);
-   goto failed;
-   }
-   } else {
-   /* Initialize clocks */
-   r = amdgpu_atombios_get_clock_info(adev);
-   if (r) {
-   dev_err(adev->dev, "amdgpu_atombios_get_clock_info 
failed\n");
-   amdgpu_vf_error_put(adev, 
AMDGIM_ERROR_VF_ATOMBIOS_GET_CLOCK_FAIL, 0, 0);
-   goto failed;
+   if (adev->bios) {
+   if (adev->is_atom_fw) {
+   /* Initialize clocks */
+   r = amdgpu_atomfirmware_get_clock_info(adev);
+   if (r) {
+   dev_err(adev->dev, 
"amdgpu_atomfirmware_get_clock_info failed\n");
+   amdgpu_vf_error_put(adev, 
AMDGIM_ERROR_VF_ATOMBIOS_GET_CLOCK_FAIL, 0, 0);
+   goto failed;
+   }
+   } else {
+   /* Initialize clocks */
+   r = amdgpu_atombios_get_clock_info(adev);
+   if (r) {
+   dev_err(adev->dev, 
"amdgpu_atombios_get_clock_info failed\n");
+   amdgpu_vf_error_put(adev, 
AMDGIM_ERROR_VF_ATOMBIOS_GET_CLOCK_FAIL, 0, 0);
+   goto failed;
+   }
+   /* init i2c buses */
+   if (!amdgpu_device_has_dc_support(adev))
+   amdgpu_atombios_i2c_init(adev);
}
-   /* init i2c buses */
-   if (!amdgpu_device_has_dc_support(adev))
-   

Re: [PATCH] drm/amdgpu: Program gds backup address as zero if no gds allocated

2023-05-24 Thread Alex Deucher
On Wed, May 24, 2023 at 5:00 AM  wrote:
>
> From: Jiadong Zhu 
>
> It is firmware requirement to set gds_backup_addrlo and gds_backup_addrhi
> of DE meta both zero if no gds partition is allocated for the frame.

Presumably other gfx versions require something similar?

Reviewed-by: Alex Deucher 

>
> Signed-off-by: Jiadong Zhu 
> ---
>  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 13 -
>  1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c 
> b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
> index cbdd9918b3e7..cbcf6126cce5 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
> @@ -765,7 +765,7 @@ static void gfx_v9_0_set_rlc_funcs(struct amdgpu_device 
> *adev);
>  static int gfx_v9_0_get_cu_info(struct amdgpu_device *adev,
> struct amdgpu_cu_info *cu_info);
>  static uint64_t gfx_v9_0_get_gpu_clock_counter(struct amdgpu_device *adev);
> -static void gfx_v9_0_ring_emit_de_meta(struct amdgpu_ring *ring, bool 
> resume);
> +static void gfx_v9_0_ring_emit_de_meta(struct amdgpu_ring *ring, bool 
> resume, bool usegds);
>  static u64 gfx_v9_0_ring_get_rptr_compute(struct amdgpu_ring *ring);
>  static void gfx_v9_0_query_ras_error_count(struct amdgpu_device *adev,
>   void *ras_error_status);
> @@ -5160,7 +5160,8 @@ static void gfx_v9_0_ring_emit_ib_gfx(struct 
> amdgpu_ring *ring,
> gfx_v9_0_ring_emit_de_meta(ring,
>
> (!amdgpu_sriov_vf(ring->adev) &&
>flags & 
> AMDGPU_IB_PREEMPTED) ?
> -  true : false);
> +  true : false,
> +  job->gds_size > 0 && 
> job->gds_base != 0);
> }
>
> amdgpu_ring_write(ring, header);
> @@ -5435,7 +5436,7 @@ static int gfx_v9_0_ring_preempt_ib(struct amdgpu_ring 
> *ring)
> return r;
>  }
>
> -static void gfx_v9_0_ring_emit_de_meta(struct amdgpu_ring *ring, bool resume)
> +static void gfx_v9_0_ring_emit_de_meta(struct amdgpu_ring *ring, bool 
> resume, bool usegds)
>  {
> struct amdgpu_device *adev = ring->adev;
> struct v9_de_ib_state de_payload = {0};
> @@ -5466,8 +5467,10 @@ static void gfx_v9_0_ring_emit_de_meta(struct 
> amdgpu_ring *ring, bool resume)
>  PAGE_SIZE);
> }
>
> -   de_payload.gds_backup_addrlo = lower_32_bits(gds_addr);
> -   de_payload.gds_backup_addrhi = upper_32_bits(gds_addr);
> +   if (usegds) {
> +   de_payload.gds_backup_addrlo = lower_32_bits(gds_addr);
> +   de_payload.gds_backup_addrhi = upper_32_bits(gds_addr);
> +   }
>
> cnt = (sizeof(de_payload) >> 2) + 4 - 2;
> amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, cnt));
> --
> 2.25.1
>


[PATCH 2/2] drm/amd/display: clean up some inconsistent indenting

2023-05-24 Thread Jiapeng Chong
No functional modification involved.

drivers/gpu/drm/amd/amdgpu/../display/dc/dml/dcn321/dcn321_fpu.c:556 
dcn321_update_bw_bounding_box_fpu() warn: inconsistent indenting.

Reported-by: Abaci Robot 
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5304
Signed-off-by: Jiapeng Chong 
---
 .../amd/display/dc/dml/dcn321/dcn321_fpu.c| 242 +-
 1 file changed, 121 insertions(+), 121 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn321/dcn321_fpu.c 
b/drivers/gpu/drm/amd/display/dc/dml/dcn321/dcn321_fpu.c
index ffd7c3c1b142..1aaff6f2d453 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/dcn321/dcn321_fpu.c
+++ b/drivers/gpu/drm/amd/display/dc/dml/dcn321/dcn321_fpu.c
@@ -553,148 +553,148 @@ void dcn321_update_bw_bounding_box_fpu(struct dc *dc, 
struct clk_bw_params *bw_p
dc->dml.soc.dispclk_dppclk_vco_speed_mhz = 
dc->clk_mgr->dentist_vco_freq_khz / 1000.0;
 
/* Overrides Clock levelsfrom CLK Mgr table entries as reported by PM 
FW */
-   if (dc->debug.use_legacy_soc_bb_mechanism) {
-   unsigned int i = 0, j = 0, num_states = 0;
-
-   unsigned int dcfclk_mhz[DC__VOLTAGE_STATES] = {0};
-   unsigned int dram_speed_mts[DC__VOLTAGE_STATES] = {0};
-   unsigned int 
optimal_uclk_for_dcfclk_sta_targets[DC__VOLTAGE_STATES] = {0};
-   unsigned int 
optimal_dcfclk_for_uclk[DC__VOLTAGE_STATES] = {0};
-
-   unsigned int dcfclk_sta_targets[DC__VOLTAGE_STATES] = 
{615, 906, 1324, 1564};
-   unsigned int num_dcfclk_sta_targets = 4, 
num_uclk_states = 0;
-   unsigned int max_dcfclk_mhz = 0, max_dispclk_mhz = 0, 
max_dppclk_mhz = 0, max_phyclk_mhz = 0;
-
-   for (i = 0; i < MAX_NUM_DPM_LVL; i++) {
-   if (bw_params->clk_table.entries[i].dcfclk_mhz 
> max_dcfclk_mhz)
-   max_dcfclk_mhz = 
bw_params->clk_table.entries[i].dcfclk_mhz;
-   if (bw_params->clk_table.entries[i].dispclk_mhz 
> max_dispclk_mhz)
-   max_dispclk_mhz = 
bw_params->clk_table.entries[i].dispclk_mhz;
-   if (bw_params->clk_table.entries[i].dppclk_mhz 
> max_dppclk_mhz)
-   max_dppclk_mhz = 
bw_params->clk_table.entries[i].dppclk_mhz;
-   if (bw_params->clk_table.entries[i].phyclk_mhz 
> max_phyclk_mhz)
-   max_phyclk_mhz = 
bw_params->clk_table.entries[i].phyclk_mhz;
-   }
-   if (!max_dcfclk_mhz)
-   max_dcfclk_mhz = 
dcn3_21_soc.clock_limits[0].dcfclk_mhz;
-   if (!max_dispclk_mhz)
-   max_dispclk_mhz = 
dcn3_21_soc.clock_limits[0].dispclk_mhz;
-   if (!max_dppclk_mhz)
-   max_dppclk_mhz = 
dcn3_21_soc.clock_limits[0].dppclk_mhz;
-   if (!max_phyclk_mhz)
-   max_phyclk_mhz = 
dcn3_21_soc.clock_limits[0].phyclk_mhz;
-
-   if (max_dcfclk_mhz > 
dcfclk_sta_targets[num_dcfclk_sta_targets-1]) {
-   // If max DCFCLK is greater than the max DCFCLK 
STA target, insert into the DCFCLK STA target array
-   dcfclk_sta_targets[num_dcfclk_sta_targets] = 
max_dcfclk_mhz;
-   num_dcfclk_sta_targets++;
-   } else if (max_dcfclk_mhz < 
dcfclk_sta_targets[num_dcfclk_sta_targets-1]) {
-   // If max DCFCLK is less than the max DCFCLK 
STA target, cap values and remove duplicates
-   for (i = 0; i < num_dcfclk_sta_targets; i++) {
-   if (dcfclk_sta_targets[i] > 
max_dcfclk_mhz) {
-   dcfclk_sta_targets[i] = 
max_dcfclk_mhz;
-   break;
-   }
+   if (dc->debug.use_legacy_soc_bb_mechanism) {
+   unsigned int i = 0, j = 0, num_states = 0;
+
+   unsigned int dcfclk_mhz[DC__VOLTAGE_STATES] = {0};
+   unsigned int dram_speed_mts[DC__VOLTAGE_STATES] = {0};
+   unsigned int 
optimal_uclk_for_dcfclk_sta_targets[DC__VOLTAGE_STATES] = {0};
+   unsigned int optimal_dcfclk_for_uclk[DC__VOLTAGE_STATES] = {0};
+
+   unsigned int dcfclk_sta_targets[DC__VOLTAGE_STATES] = {615, 
906, 1324, 1564};
+   unsigned int num_dcfclk_sta_targets = 4, num_uclk_states = 0;
+   unsigned int max_dcfclk_mhz = 0, max_dispclk_mhz = 0, 
max_dppclk_mhz = 0, max_phyclk_mhz = 0;
+
+   for (i = 0; i < MAX_NUM_DPM_LVL; i++) {
+   if 

Re: [PATCH 06/36] drm/amd/display: add CRTC driver-specific property for gamma TF

2023-05-24 Thread Pekka Paalanen
On Tue, 23 May 2023 21:14:50 -0100
Melissa Wen  wrote:

> Hook up driver-specific atomic operations for managing AMD color
> properties and create AMD driver-specific color management properties
> and attach them according to HW capabilities defined by `struct
> dc_color_caps`. Add enumerated transfer function property to DRM CRTC
> gamma to convert to wire encoding with or without a user gamma LUT.
> Enumerated TFs are not supported yet by the DRM color pipeline,
> therefore, create a DRM enum list with the predefined TFs supported by
> the AMD display driver.
> 
> Co-developed-by: Joshua Ashton 
> Signed-off-by: Joshua Ashton 
> Signed-off-by: Melissa Wen 
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_display.c   | 36 ++
>  drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h  |  8 +++
>  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 22 ++
>  .../amd/display/amdgpu_dm/amdgpu_dm_crtc.c| 72 ++-
>  4 files changed, 137 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> index 389396eac222..88af075e6c18 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> @@ -1247,6 +1247,38 @@ amdgpu_display_user_framebuffer_create(struct 
> drm_device *dev,
>   return _fb->base;
>  }
>  
> +static const struct drm_prop_enum_list drm_transfer_function_enum_list[] = {
> + { DRM_TRANSFER_FUNCTION_DEFAULT, "Default" },
> + { DRM_TRANSFER_FUNCTION_SRGB, "sRGB" },
> + { DRM_TRANSFER_FUNCTION_BT709, "BT.709" },
> + { DRM_TRANSFER_FUNCTION_PQ, "PQ (Perceptual Quantizer)" },
> + { DRM_TRANSFER_FUNCTION_LINEAR, "Linear" },
> + { DRM_TRANSFER_FUNCTION_UNITY, "Unity" },
> + { DRM_TRANSFER_FUNCTION_HLG, "HLG (Hybrid Log Gamma)" },
> + { DRM_TRANSFER_FUNCTION_GAMMA22, "Gamma 2.2" },
> + { DRM_TRANSFER_FUNCTION_GAMMA24, "Gamma 2.4" },
> + { DRM_TRANSFER_FUNCTION_GAMMA26, "Gamma 2.6" },
> +};
> +
> +#ifdef AMD_PRIVATE_COLOR
> +static int
> +amdgpu_display_create_color_properties(struct amdgpu_device *adev)
> +{
> + struct drm_property *prop;
> +
> + prop = drm_property_create_enum(adev_to_drm(adev),
> + DRM_MODE_PROP_ENUM,
> + "AMD_REGAMMA_TF",

Hi,

is this REGAMMA element capable of applying only optical-to-electrical
direction of the listed TFs?

I was expecting that the listed TF names would include an explanation
of the direction, for example "PQ EOTF" vs. "inverse PQ EOTF".

Very specifically "inverse EOTF" and not "OETF" because they
generally are not the same concept.

PQ defines only EOTF while HLG for example defines OETF (HLG defines
its EOTF as a combination of inverse HLG OETF and a parameterised HLG
OOTF). So if you say "PQ TF" I will assume it means
electrical-to-optical and if you say HLG TF I might assume
optical-to-electrical. I think these enum names should be more explicit
about what they refer to, to avoid any ambiguity.

What kind of TF is "Unity"?

This patch is not adding any docs for any of these. Is there another
patch that does?

I'm still confused about how this "private" API should be thought of.
Should it be documented at all? Is it free to use for userspace?
Was the expectation that only the Steam Deck distribution would enable
these in the kernel, and no-one else? And if anyone builds their own
kernel with these enabled? So my ask for docs may or may not be
warranted.

I don't like the names degamma/regamma/gamma at all. I don't like
calling something a LUT when it can have a parametric or enumerated
curve. I don't like calling an element a transfer function if it could
be a shaper or a combination of TF and shaper and maybe something else
(i.e. a LUT).

But that's nothing new. If the expectation is that no-one should use
these, then it's fine, and you don't need to CC me. You know I will
always respond with similar comments about documenting things, having
good names, etc. that is important for generic userspace, which is just
not needed for "no-users UAPI". ;-)


Thanks,
pq

> + drm_transfer_function_enum_list,
> + 
> ARRAY_SIZE(drm_transfer_function_enum_list));
> + if (!prop)
> + return -ENOMEM;
> + adev->mode_info.regamma_tf_property = prop;
> +
> + return 0;
> +}
> +#endif
> +
>  const struct drm_mode_config_funcs amdgpu_mode_funcs = {
>   .fb_create = amdgpu_display_user_framebuffer_create,
>  };
> @@ -1323,6 +1355,10 @@ int amdgpu_display_modeset_create_props(struct 
> amdgpu_device *adev)
>   return -ENOMEM;
>   }
>  
> +#ifdef AMD_PRIVATE_COLOR
> + if (amdgpu_display_create_color_properties(adev))
> + return -ENOMEM;
> +#endif
>   return 0;
>  }
>  
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
> index 

[PATCH 1/2] drm/amd/display: clean up some inconsistent indenting

2023-05-24 Thread Jiapeng Chong
No functional modification involved.

drivers/gpu/drm/amd/amdgpu/../display/dc/dml/dcn314/dcn314_fpu.c:269 
dcn314_update_bw_bounding_box_fpu() warn: inconsistent indenting.

Reported-by: Abaci Robot 
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5305
Signed-off-by: Jiapeng Chong 
---
 drivers/gpu/drm/amd/display/dc/dml/dcn314/dcn314_fpu.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn314/dcn314_fpu.c 
b/drivers/gpu/drm/amd/display/dc/dml/dcn314/dcn314_fpu.c
index 318b9c2bc9be..c9afddd11589 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/dcn314/dcn314_fpu.c
+++ b/drivers/gpu/drm/amd/display/dc/dml/dcn314/dcn314_fpu.c
@@ -265,8 +265,7 @@ void dcn314_update_bw_bounding_box_fpu(struct dc *dc, 
struct clk_bw_params *bw_p
}
 
dcn20_patch_bounding_box(dc, _14_soc);
-
-   dml_init_instance(>dml, _14_soc, _14_ip, 
DML_PROJECT_DCN314);
+   dml_init_instance(>dml, _14_soc, _14_ip, 
DML_PROJECT_DCN314);
 }
 
 static bool is_dual_plane(enum surface_pixel_format format)
-- 
2.20.1.7.g153144c



[PATCH -next 07/13] drm/amd/display: remove unused definition

2023-05-24 Thread Yang Li
Eliminate the following warnings:
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn302/dcn302_resource.c:957:43: 
warning: unused variable 'res_create_maximus_funcs'
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn302/dcn302_resource.c:101:38: 
warning: unused variable 'debug_defaults_diags'

Reported-by: Abaci Robot 
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5296
Fixes: 00df97e1df57 ("drm/amd/display: Clean FPGA code in dc")
Signed-off-by: Yang Li 
---
 .../amd/display/dc/dcn302/dcn302_resource.c   | 25 ---
 1 file changed, 25 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn302/dcn302_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn302/dcn302_resource.c
index efd98d64588d..93f42132c900 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn302/dcn302_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn302/dcn302_resource.c
@@ -98,24 +98,6 @@ static const struct dc_debug_options debug_defaults_drv = {
.exit_idle_opt_for_cursor_updates = true
 };
 
-static const struct dc_debug_options debug_defaults_diags = {
-   .disable_dmcu = true,
-   .force_abm_enable = false,
-   .timing_trace = true,
-   .clock_trace = true,
-   .disable_dpp_power_gate = true,
-   .disable_hubp_power_gate = true,
-   .disable_clock_gate = true,
-   .disable_pplib_clock_request = true,
-   .disable_pplib_wm_range = true,
-   .disable_stutter = false,
-   .scl_reset_length10 = true,
-   .dwb_fi_phase = -1, // -1 = disable
-   .dmub_command_table = true,
-   .enable_tri_buf = true,
-   .use_max_lb = true
-};
-
 static const struct dc_panel_config panel_config_defaults = {
.psr = {
.disable_psr = false,
@@ -954,13 +936,6 @@ static const struct resource_create_funcs res_create_funcs 
= {
.create_hwseq = dcn302_hwseq_create,
 };
 
-static const struct resource_create_funcs res_create_maximus_funcs = {
-   .read_dce_straps = NULL,
-   .create_audio = NULL,
-   .create_stream_encoder = NULL,
-   .create_hwseq = dcn302_hwseq_create,
-};
-
 static bool is_soc_bounding_box_valid(struct dc *dc)
 {
uint32_t hw_internal_rev = dc->ctx->asic_id.hw_internal_rev;
-- 
2.20.1.7.g153144c



[PATCH -next 09/13] drm/amd/display: remove unused definition

2023-05-24 Thread Yang Li
Eliminate the following warning:
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn314/dcn314_resource.c:1390:43: 
warning: unused variable 'res_create_maximus_funcs'

Reported-by: Abaci Robot 
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5296
Fixes: 00df97e1df57 ("drm/amd/display: Clean FPGA code in dc")
Signed-off-by: Yang Li 
---
 drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c | 9 -
 1 file changed, 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c
index 2483d37e425d..3592efcc7fae 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c
@@ -1387,15 +1387,6 @@ static const struct resource_create_funcs 
res_create_funcs = {
.create_hwseq = dcn314_hwseq_create,
 };
 
-static const struct resource_create_funcs res_create_maximus_funcs = {
-   .read_dce_straps = NULL,
-   .create_audio = NULL,
-   .create_stream_encoder = NULL,
-   .create_hpo_dp_stream_encoder = dcn31_hpo_dp_stream_encoder_create,
-   .create_hpo_dp_link_encoder = dcn31_hpo_dp_link_encoder_create,
-   .create_hwseq = dcn314_hwseq_create,
-};
-
 static void dcn314_resource_destruct(struct dcn314_resource_pool *pool)
 {
unsigned int i;
-- 
2.20.1.7.g153144c



[PATCH -next 01/13] drm/amd/display: remove unused definition

2023-05-24 Thread Yang Li
Eliminate the following warning:
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn10/dcn10_resource.c:889:43: 
warning: unused variable 'res_create_maximus_funcs'

Reported-by: Abaci Robot 
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5296
Fixes: 00df97e1df57 ("drm/amd/display: Clean FPGA code in dc")
Signed-off-by: Yang Li 
---
 drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
index a0625209c86d..26ddf73fd5b1 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
@@ -886,13 +886,6 @@ static const struct resource_create_funcs res_create_funcs 
= {
.create_hwseq = dcn10_hwseq_create,
 };
 
-static const struct resource_create_funcs res_create_maximus_funcs = {
-   .read_dce_straps = NULL,
-   .create_audio = NULL,
-   .create_stream_encoder = NULL,
-   .create_hwseq = dcn10_hwseq_create,
-};
-
 static void dcn10_clock_source_destroy(struct clock_source **clk_src)
 {
kfree(TO_DCE110_CLK_SRC(*clk_src));
-- 
2.20.1.7.g153144c



[PATCH] drm/amdgpu: resove reboot exception for si oland

2023-05-24 Thread Zhenneng Li
During reboot test on arm64 platform, it may failure
on boot.

The error message are as follows:
[1.706570][ 3] [  T273] [drm:si_thermal_enable_alert [amdgpu]] *ERROR* 
Could not enable thermal interrupts.
[1.716547][ 3] [  T273] [drm:amdgpu_device_ip_late_init [amdgpu]] *ERROR* 
late_init of IP block  failed -22
[1.727064][ 3] [  T273] amdgpu :02:00.0: amdgpu_device_ip_late_init 
failed
[1.734367][ 3] [  T273] amdgpu :02:00.0: Fatal error during GPU init

Signed-off-by: Zhenneng Li 
---
 drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 12 
 1 file changed, 12 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c 
b/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
index d6d9e3b1b2c0..ca9bce895dbe 100644
--- a/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
+++ b/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
@@ -7626,18 +7626,6 @@ static int si_dpm_process_interrupt(struct amdgpu_device 
*adev,
 
 static int si_dpm_late_init(void *handle)
 {
-   int ret;
-   struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-
-   if (!adev->pm.dpm_enabled)
-   return 0;
-
-   ret = si_set_temperature_range(adev);
-   if (ret)
-   return ret;
-#if 0 //TODO ?
-   si_dpm_powergate_uvd(adev, true);
-#endif
return 0;
 }
 
-- 
2.25.1


No virus found
Checked by Hillstone Network AntiVirus


[PATCH v4] drm/amdgpu: resove reboot exception for si oland

2023-05-24 Thread Zhenneng Li
During reboot test on arm64 platform, it may failure
on boot.

The error message are as follows:
[1.706570][ 3] [  T273] [drm:si_thermal_enable_alert [amdgpu]] *ERROR* 
Could not enable thermal interrupts.
[1.716547][ 3] [  T273] [drm:amdgpu_device_ip_late_init [amdgpu]] *ERROR* 
late_init of IP block  failed -22
[1.727064][ 3] [  T273] amdgpu :02:00.0: amdgpu_device_ip_late_init 
failed
[1.734367][ 3] [  T273] amdgpu :02:00.0: Fatal error during GPU init

Signed-off-by: Zhenneng Li 
---
 drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 12 
 1 file changed, 12 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c 
b/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
index d6d9e3b1b2c0..ca9bce895dbe 100644
--- a/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
+++ b/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
@@ -7626,18 +7626,6 @@ static int si_dpm_process_interrupt(struct amdgpu_device 
*adev,
 
 static int si_dpm_late_init(void *handle)
 {
-   int ret;
-   struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-
-   if (!adev->pm.dpm_enabled)
-   return 0;
-
-   ret = si_set_temperature_range(adev);
-   if (ret)
-   return ret;
-#if 0 //TODO ?
-   si_dpm_powergate_uvd(adev, true);
-#endif
return 0;
 }
 
-- 
2.25.1


No virus found
Checked by Hillstone Network AntiVirus


[PATCH -next 06/13] drm/amd/display: remove unused definition

2023-05-24 Thread Yang Li
Eliminate the following warnings:
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn301/dcn301_resource.c:1050:43: 
warning: unused variable 'res_create_maximus_funcs'
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn301/dcn301_resource.c:705:38: 
warning: unused variable 'debug_defaults_diags'

Reported-by: Abaci Robot 
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5296
Fixes: 00df97e1df57 ("drm/amd/display: Clean FPGA code in dc")
Signed-off-by: Yang Li 
---
 .../amd/display/dc/dcn301/dcn301_resource.c   | 24 ---
 1 file changed, 24 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c
index 1cf84a086fec..3485fbb1093e 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c
@@ -702,23 +702,6 @@ static const struct dc_debug_options debug_defaults_drv = {
.exit_idle_opt_for_cursor_updates = true
 };
 
-static const struct dc_debug_options debug_defaults_diags = {
-   .disable_dmcu = true,
-   .force_abm_enable = false,
-   .timing_trace = true,
-   .clock_trace = true,
-   .disable_dpp_power_gate = false,
-   .disable_hubp_power_gate = false,
-   .disable_clock_gate = true,
-   .disable_pplib_clock_request = true,
-   .disable_pplib_wm_range = true,
-   .disable_stutter = true,
-   .scl_reset_length10 = true,
-   .dwb_fi_phase = -1, // -1 = disable
-   .dmub_command_table = true,
-   .use_max_lb = false,
-};
-
 static void dcn301_dpp_destroy(struct dpp **dpp)
 {
kfree(TO_DCN20_DPP(*dpp));
@@ -1047,13 +1030,6 @@ static const struct resource_create_funcs 
res_create_funcs = {
.create_hwseq = dcn301_hwseq_create,
 };
 
-static const struct resource_create_funcs res_create_maximus_funcs = {
-   .read_dce_straps = NULL,
-   .create_audio = NULL,
-   .create_stream_encoder = NULL,
-   .create_hwseq = dcn301_hwseq_create,
-};
-
 static void dcn301_destruct(struct dcn301_resource_pool *pool)
 {
unsigned int i;
-- 
2.20.1.7.g153144c



[PATCH -next 11/13] drm/amd/display: remove unused definition

2023-05-24 Thread Yang Li
Eliminate the following warnings:
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn316/dcn316_resource.c:1355:43: 
warning: unused variable 'res_create_maximus_funcs'
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn316/dcn316_resource.c:899:38: 
warning: unused variable 'debug_defaults_diags'

Reported-by: Abaci Robot 
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5296
Fixes: 00df97e1df57 ("drm/amd/display: Clean FPGA code in dc")
Signed-off-by: Yang Li 
---
 .../amd/display/dc/dcn316/dcn316_resource.c   | 27 ---
 1 file changed, 27 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn316/dcn316_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn316/dcn316_resource.c
index a3be61cc541f..b6e0aa2ab27a 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn316/dcn316_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn316/dcn316_resource.c
@@ -886,24 +886,6 @@ static const struct dc_debug_options debug_defaults_drv = {
},
 };
 
-static const struct dc_debug_options debug_defaults_diags = {
-   .disable_dmcu = true,
-   .force_abm_enable = false,
-   .timing_trace = true,
-   .clock_trace = true,
-   .disable_dpp_power_gate = true,
-   .disable_hubp_power_gate = true,
-   .disable_clock_gate = true,
-   .disable_pplib_clock_request = true,
-   .disable_pplib_wm_range = true,
-   .disable_stutter = false,
-   .scl_reset_length10 = true,
-   .dwb_fi_phase = -1, // -1 = disable
-   .dmub_command_table = true,
-   .enable_tri_buf = true,
-   .use_max_lb = true
-};
-
 static const struct dc_panel_config panel_config_defaults = {
.psr = {
.disable_psr = false,
@@ -1352,15 +1334,6 @@ static const struct resource_create_funcs 
res_create_funcs = {
.create_hwseq = dcn31_hwseq_create,
 };
 
-static const struct resource_create_funcs res_create_maximus_funcs = {
-   .read_dce_straps = NULL,
-   .create_audio = NULL,
-   .create_stream_encoder = NULL,
-   .create_hpo_dp_stream_encoder = dcn31_hpo_dp_stream_encoder_create,
-   .create_hpo_dp_link_encoder = dcn31_hpo_dp_link_encoder_create,
-   .create_hwseq = dcn31_hwseq_create,
-};
-
 static void dcn316_resource_destruct(struct dcn316_resource_pool *pool)
 {
unsigned int i;
-- 
2.20.1.7.g153144c



[PATCH -next 10/13] drm/amd/display: remove unused definition

2023-05-24 Thread Yang Li
Eliminate the following warnings:
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn315/dcn315_resource.c:1357:43: 
warning: unused variable 'res_create_maximus_funcs'
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn315/dcn315_resource.c:893:38: 
warning: unused variable 'debug_defaults_diags'

Reported-by: Abaci Robot 
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5296
Fixes: 00df97e1df57 ("drm/amd/display: Clean FPGA code in dc")
Signed-off-by: Yang Li 
---
 .../amd/display/dc/dcn315/dcn315_resource.c   | 27 ---
 1 file changed, 27 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn315/dcn315_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn315/dcn315_resource.c
index e6d87c162d26..cb95e978417b 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn315/dcn315_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn315/dcn315_resource.c
@@ -890,24 +890,6 @@ static const struct dc_debug_options debug_defaults_drv = {
.psr_power_use_phy_fsm = 0,
 };
 
-static const struct dc_debug_options debug_defaults_diags = {
-   .disable_dmcu = true,
-   .force_abm_enable = false,
-   .timing_trace = true,
-   .clock_trace = true,
-   .disable_dpp_power_gate = true,
-   .disable_hubp_power_gate = true,
-   .disable_clock_gate = true,
-   .disable_pplib_clock_request = true,
-   .disable_pplib_wm_range = true,
-   .disable_stutter = false,
-   .scl_reset_length10 = true,
-   .dwb_fi_phase = -1, // -1 = disable
-   .dmub_command_table = true,
-   .enable_tri_buf = true,
-   .use_max_lb = true
-};
-
 static const struct dc_panel_config panel_config_defaults = {
.psr = {
.disable_psr = false,
@@ -1354,15 +1336,6 @@ static const struct resource_create_funcs 
res_create_funcs = {
.create_hwseq = dcn31_hwseq_create,
 };
 
-static const struct resource_create_funcs res_create_maximus_funcs = {
-   .read_dce_straps = NULL,
-   .create_audio = NULL,
-   .create_stream_encoder = NULL,
-   .create_hpo_dp_stream_encoder = dcn31_hpo_dp_stream_encoder_create,
-   .create_hpo_dp_link_encoder = dcn31_hpo_dp_link_encoder_create,
-   .create_hwseq = dcn31_hwseq_create,
-};
-
 static void dcn315_resource_destruct(struct dcn315_resource_pool *pool)
 {
unsigned int i;
-- 
2.20.1.7.g153144c



[PATCH -next 05/13] drm/amd/display: remove unused definition

2023-05-24 Thread Yang Li
Eliminate the following warnings:
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn32/dcn32_resource.c:1360:43: 
warning: unused variable 'res_create_maximus_funcs'
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn32/dcn32_resource.c:737:38: 
warning: unused variable 'debug_defaults_diags'

Reported-by: Abaci Robot 
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5296
Fixes: 00df97e1df57 ("drm/amd/display: Clean FPGA code in dc")
Signed-off-by: Yang Li 
---
 .../drm/amd/display/dc/dcn32/dcn32_resource.c | 29 ---
 1 file changed, 29 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource.c
index 33abc8c9d4be..2e6b39fe2613 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource.c
@@ -734,26 +734,6 @@ static const struct dc_debug_options debug_defaults_drv = {
.fpo_vactive_max_blank_us = 1000,
 };
 
-static const struct dc_debug_options debug_defaults_diags = {
-   .disable_dmcu = true,
-   .force_abm_enable = false,
-   .timing_trace = true,
-   .clock_trace = true,
-   .disable_dpp_power_gate = true,
-   .disable_hubp_power_gate = true,
-   .disable_dsc_power_gate = true,
-   .disable_clock_gate = true,
-   .disable_pplib_clock_request = true,
-   .disable_pplib_wm_range = true,
-   .disable_stutter = false,
-   .scl_reset_length10 = true,
-   .dwb_fi_phase = -1, // -1 = disable
-   .dmub_command_table = true,
-   .enable_tri_buf = true,
-   .use_max_lb = true,
-   .force_disable_subvp = true
-};
-
 static struct dce_aux *dcn32_aux_engine_create(
struct dc_context *ctx,
uint32_t inst)
@@ -1357,15 +1337,6 @@ static const struct resource_create_funcs 
res_create_funcs = {
.create_hwseq = dcn32_hwseq_create,
 };
 
-static const struct resource_create_funcs res_create_maximus_funcs = {
-   .read_dce_straps = NULL,
-   .create_audio = NULL,
-   .create_stream_encoder = NULL,
-   .create_hpo_dp_stream_encoder = dcn32_hpo_dp_stream_encoder_create,
-   .create_hpo_dp_link_encoder = dcn32_hpo_dp_link_encoder_create,
-   .create_hwseq = dcn32_hwseq_create,
-};
-
 static void dcn32_resource_destruct(struct dcn32_resource_pool *pool)
 {
unsigned int i;
-- 
2.20.1.7.g153144c



[PATCH -next 12/13] drm/amd/display: remove unused definition

2023-05-24 Thread Yang Li
Eliminate the following warnings:
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn321/dcn321_resource.c:1346:43: 
warning: unused variable 'res_create_maximus_funcs'
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn321/dcn321_resource.c:735:38: 
warning: unused variable 'debug_defaults_diags'

Reported-by: Abaci Robot 
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5296
Fixes: 00df97e1df57 ("drm/amd/display: Clean FPGA code in dc")
Signed-off-by: Yang Li 
---
 .../amd/display/dc/dcn321/dcn321_resource.c   | 30 ---
 1 file changed, 30 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn321/dcn321_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn321/dcn321_resource.c
index af0bb3e94250..bbcd3579fea6 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn321/dcn321_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn321/dcn321_resource.c
@@ -732,27 +732,6 @@ static const struct dc_debug_options debug_defaults_drv = {
.fpo_vactive_max_blank_us = 1000,
 };
 
-static const struct dc_debug_options debug_defaults_diags = {
-   .disable_dmcu = true,
-   .force_abm_enable = false,
-   .timing_trace = true,
-   .clock_trace = true,
-   .disable_dpp_power_gate = true,
-   .disable_hubp_power_gate = true,
-   .disable_dsc_power_gate = true,
-   .disable_clock_gate = true,
-   .disable_pplib_clock_request = true,
-   .disable_pplib_wm_range = true,
-   .disable_stutter = false,
-   .scl_reset_length10 = true,
-   .dwb_fi_phase = -1, // -1 = disable
-   .dmub_command_table = true,
-   .enable_tri_buf = true,
-   .use_max_lb = true,
-   .force_disable_subvp = true,
-};
-
-
 static struct dce_aux *dcn321_aux_engine_create(
struct dc_context *ctx,
uint32_t inst)
@@ -1343,15 +1322,6 @@ static const struct resource_create_funcs 
res_create_funcs = {
.create_hwseq = dcn321_hwseq_create,
 };
 
-static const struct resource_create_funcs res_create_maximus_funcs = {
-   .read_dce_straps = NULL,
-   .create_audio = NULL,
-   .create_stream_encoder = NULL,
-   .create_hpo_dp_stream_encoder = dcn321_hpo_dp_stream_encoder_create,
-   .create_hpo_dp_link_encoder = dcn321_hpo_dp_link_encoder_create,
-   .create_hwseq = dcn321_hwseq_create,
-};
-
 static void dcn321_resource_destruct(struct dcn321_resource_pool *pool)
 {
unsigned int i;
-- 
2.20.1.7.g153144c



[PATCH -next 02/13] drm/amd/display: remove unused definition

2023-05-24 Thread Yang Li
Eliminate the following warnings:
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn21/dcn21_resource.c:1222:43: 
warning: unused variable 'res_create_maximus_funcs'
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn21/dcn21_resource.c:658:38: 
warning: unused variable 'debug_defaults_diags'

Reported-by: Abaci Robot 
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5296
Fixes: 00df97e1df57 ("drm/amd/display: Clean FPGA code in dc")
Signed-off-by: Yang Li 
---
 .../drm/amd/display/dc/dcn21/dcn21_resource.c | 23 ---
 1 file changed, 23 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
index 76268a7b7934..da6d42de0554 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
@@ -655,22 +655,6 @@ static const struct dc_debug_options debug_defaults_drv = {
.use_max_lb = true,
 };
 
-static const struct dc_debug_options debug_defaults_diags = {
-   .disable_dmcu = false,
-   .force_abm_enable = false,
-   .timing_trace = true,
-   .clock_trace = true,
-   .disable_dpp_power_gate = true,
-   .disable_hubp_power_gate = true,
-   .disable_clock_gate = true,
-   .disable_pplib_clock_request = true,
-   .disable_pplib_wm_range = true,
-   .disable_stutter = true,
-   .disable_48mhz_pwrdwn = true,
-   .enable_tri_buf = true,
-   .use_max_lb = true
-};
-
 static const struct dc_panel_config panel_config_defaults = {
.psr = {
.disable_psr = false,
@@ -1219,13 +1203,6 @@ static const struct resource_create_funcs 
res_create_funcs = {
.create_hwseq = dcn21_hwseq_create,
 };
 
-static const struct resource_create_funcs res_create_maximus_funcs = {
-   .read_dce_straps = NULL,
-   .create_audio = NULL,
-   .create_stream_encoder = NULL,
-   .create_hwseq = dcn21_hwseq_create,
-};
-
 static const struct encoder_feature_support link_enc_feature = {
.max_hdmi_deep_color = COLOR_DEPTH_121212,
.max_hdmi_pixel_clock = 60,
-- 
2.20.1.7.g153144c



[PATCH -next 03/13] drm/amd/display: remove unused definition

2023-05-24 Thread Yang Li
Eliminate the following warnings:
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn30/dcn30_resource.c:1079:43: 
warning: unused variable 'res_create_maximus_funcs'
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn30/dcn30_resource.c:731:38: 
warning: unused variable 'debug_defaults_diags'

Reported-by: Abaci Robot 
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5296
Fixes: 00df97e1df57 ("drm/amd/display: Clean FPGA code in dc")
Signed-off-by: Yang Li 
---
 .../drm/amd/display/dc/dcn30/dcn30_resource.c | 25 ---
 1 file changed, 25 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c
index cd94b5f5fdb4..f4ee4b3df596 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c
@@ -728,24 +728,6 @@ static const struct dc_debug_options debug_defaults_drv = {
.exit_idle_opt_for_cursor_updates = true
 };
 
-static const struct dc_debug_options debug_defaults_diags = {
-   .disable_dmcu = true, //No dmcu on DCN30
-   .force_abm_enable = false,
-   .timing_trace = true,
-   .clock_trace = true,
-   .disable_dpp_power_gate = true,
-   .disable_hubp_power_gate = true,
-   .disable_clock_gate = true,
-   .disable_pplib_clock_request = true,
-   .disable_pplib_wm_range = true,
-   .disable_stutter = false,
-   .scl_reset_length10 = true,
-   .dwb_fi_phase = -1, // -1 = disable
-   .dmub_command_table = true,
-   .enable_tri_buf = true,
-   .use_max_lb = true
-};
-
 static const struct dc_panel_config panel_config_defaults = {
.psr = {
.disable_psr = false,
@@ -1076,13 +1058,6 @@ static const struct resource_create_funcs 
res_create_funcs = {
.create_hwseq = dcn30_hwseq_create,
 };
 
-static const struct resource_create_funcs res_create_maximus_funcs = {
-   .read_dce_straps = NULL,
-   .create_audio = NULL,
-   .create_stream_encoder = NULL,
-   .create_hwseq = dcn30_hwseq_create,
-};
-
 static void dcn30_resource_destruct(struct dcn30_resource_pool *pool)
 {
unsigned int i;
-- 
2.20.1.7.g153144c



[PATCH v3] drm/amdgpu: resove reboot exception for si oland

2023-05-24 Thread Zhenneng Li
During reboot test on arm64 platform, it may failure
on boot.

The error message are as follows:
[1.706570][ 3] [  T273] [drm:si_thermal_enable_alert [amdgpu]] *ERROR* 
Could not enable thermal interrupts.
[1.716547][ 3] [  T273] [drm:amdgpu_device_ip_late_init [amdgpu]] *ERROR* 
late_init of IP block  failed -22
[1.727064][ 3] [  T273] amdgpu :02:00.0: amdgpu_device_ip_late_init 
failed
[1.734367][ 3] [  T273] amdgpu :02:00.0: Fatal error during GPU init
---
 drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 12 
 1 file changed, 12 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c 
b/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
index d6d9e3b1b2c0..ca9bce895dbe 100644
--- a/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
+++ b/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
@@ -7626,18 +7626,6 @@ static int si_dpm_process_interrupt(struct amdgpu_device 
*adev,
 
 static int si_dpm_late_init(void *handle)
 {
-   int ret;
-   struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-
-   if (!adev->pm.dpm_enabled)
-   return 0;
-
-   ret = si_set_temperature_range(adev);
-   if (ret)
-   return ret;
-#if 0 //TODO ?
-   si_dpm_powergate_uvd(adev, true);
-#endif
return 0;
 }
 
-- 
2.25.1


No virus found
Checked by Hillstone Network AntiVirus


[Linux-kernel-mentorship] [PATCH] drm/amdgpu: remove excess parameter description in amdgpu_device.c

2023-05-24 Thread Ziqi Zhao
This patch is part of the Linux Kernel Bug Fixing Summer screening
tasks. By removing the extra description, several documentation
compilation warnings such as the following have been fixed:

> ./drivers/gpu/drm/amd/amdgpu/amdgpu_device.c:758: warning: Excess function 
> parameter 'pcie_index' description in 'amdgpu_device_indirect_wreg'

Note: I assume the description can be safely removed based on this
earlier patch:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/patch?id=65ba96e91b689c23d6fa99c11cfd65965dcddc47

Signed-off-by: Ziqi Zhao 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 5c7d40873ee2..58d8f60c6a3a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -747,8 +747,6 @@ u64 amdgpu_device_indirect_rreg64(struct amdgpu_device 
*adev,
  * amdgpu_device_indirect_wreg - write an indirect register address
  *
  * @adev: amdgpu_device pointer
- * @pcie_index: mmio register offset
- * @pcie_data: mmio register offset
  * @reg_addr: indirect register offset
  * @reg_data: indirect register data
  *
@@ -778,8 +776,6 @@ void amdgpu_device_indirect_wreg(struct amdgpu_device *adev,
  * amdgpu_device_indirect_wreg64 - write a 64bits indirect register address
  *
  * @adev: amdgpu_device pointer
- * @pcie_index: mmio register offset
- * @pcie_data: mmio register offset
  * @reg_addr: indirect register offset
  * @reg_data: indirect register data
  *
-- 
2.34.1



[PATCH -next 08/13] drm/amd/display: remove unused definition

2023-05-24 Thread Yang Li
Eliminate the following warnings:
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn303/dcn303_resource.c:884:43: 
warning: unused variable 'res_create_maximus_funcs'
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn303/dcn303_resource.c:84:38: 
warning: unused variable 'debug_defaults_diags'

Reported-by: Abaci Robot 
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5296
Fixes: 00df97e1df57 ("drm/amd/display: Clean FPGA code in dc")
Signed-off-by: Yang Li 
---
 .../amd/display/dc/dcn303/dcn303_resource.c   | 24 ---
 1 file changed, 24 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn303/dcn303_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn303/dcn303_resource.c
index fcd126602178..f35514188a5c 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn303/dcn303_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn303/dcn303_resource.c
@@ -81,23 +81,6 @@ static const struct dc_debug_options debug_defaults_drv = {
.disable_idle_power_optimizations = false,
 };
 
-static const struct dc_debug_options debug_defaults_diags = {
-   .disable_dmcu = true,
-   .force_abm_enable = false,
-   .timing_trace = true,
-   .clock_trace = true,
-   .disable_dpp_power_gate = true,
-   .disable_hubp_power_gate = true,
-   .disable_clock_gate = true,
-   .disable_pplib_clock_request = true,
-   .disable_pplib_wm_range = true,
-   .disable_stutter = false,
-   .scl_reset_length10 = true,
-   .dwb_fi_phase = -1, // -1 = disable
-   .dmub_command_table = true,
-   .enable_tri_buf = true,
-};
-
 static const struct dc_panel_config panel_config_defaults = {
.psr = {
.disable_psr = false,
@@ -881,13 +864,6 @@ static const struct resource_create_funcs res_create_funcs 
= {
.create_hwseq = dcn303_hwseq_create,
 };
 
-static const struct resource_create_funcs res_create_maximus_funcs = {
-   .read_dce_straps = NULL,
-   .create_audio = NULL,
-   .create_stream_encoder = NULL,
-   .create_hwseq = dcn303_hwseq_create,
-};
-
 static bool is_soc_bounding_box_valid(struct dc *dc)
 {
uint32_t hw_internal_rev = dc->ctx->asic_id.hw_internal_rev;
-- 
2.20.1.7.g153144c



[bug report] drm/amd/display: Clean FPGA code in dc

2023-05-24 Thread Dan Carpenter
Hello Qingqing Zhuo,

The patch 00df97e1df57: "drm/amd/display: Clean FPGA code in dc" from
Mar 16, 2023, leads to the following Smatch static checker warning:

drivers/gpu/drm/amd/amdgpu/../display/dc/clk_mgr/dcn21/rn_clk_mgr.c:775 
rn_clk_mgr_construct()
warn: variable dereferenced before check 'ctx->dc_bios->integrated_info' (see 
line 743)

drivers/gpu/drm/amd/amdgpu/../display/dc/clk_mgr/dcn301/vg_clk_mgr.c:731
vg_clk_mgr_construct() warn: variable dereferenced before check 
'ctx->dc_bios->integrated_info' (see line 717)

drivers/gpu/drm/amd/amdgpu/../display/dc/clk_mgr/dcn314/dcn314_clk_mgr.c:834
dcn314_clk_mgr_construct() warn: variable dereferenced before check 
'ctx->dc_bios->integrated_info' (see line 773)

drivers/gpu/drm/amd/amdgpu/../display/dc/clk_mgr/dcn31/dcn31_clk_mgr.c:782
dcn31_clk_mgr_construct() warn: variable dereferenced before check 
'ctx->dc_bios->integrated_info' (see line 721)

Also some indenting stuff:
drivers/gpu/drm/amd/amdgpu/../display/dc/dml/dcn314/dcn314_fpu.c:269 
dcn314_update_bw_bounding_box_fpu()
warn: inconsistent indenting

drivers/gpu/drm/amd/amdgpu/../display/dc/link/link_dpms.c:2377 
link_set_dpms_on()
warn: inconsistent indenting

drivers/gpu/drm/amd/amdgpu/../display/dc/clk_mgr/dcn21/rn_clk_mgr.c
698 void rn_clk_mgr_construct(
699 struct dc_context *ctx,
700 struct clk_mgr_internal *clk_mgr,
701 struct pp_smu_funcs *pp_smu,
702 struct dccg *dccg)
703 {
704 struct dc_debug_options *debug = >dc->debug;
705 struct dpm_clocks clock_table = { 0 };
706 enum pp_smu_status status = 0;
707 int is_green_sardine = 0;
708 struct clk_log_info log_info = {0};
709 
710 #if defined(CONFIG_DRM_AMD_DC_FP)
711 is_green_sardine = 
ASICREV_IS_GREEN_SARDINE(ctx->asic_id.hw_internal_rev);
712 #endif
713 
714 clk_mgr->base.ctx = ctx;
715 clk_mgr->base.funcs = _funcs;
716 
717 clk_mgr->pp_smu = pp_smu;
718 
719 clk_mgr->dccg = dccg;
720 clk_mgr->dfs_bypass_disp_clk = 0;
721 
722 clk_mgr->dprefclk_ss_percentage = 0;
723 clk_mgr->dprefclk_ss_divider = 1000;
724 clk_mgr->ss_on_dprefclk = false;
725 clk_mgr->dfs_ref_freq_khz = 48000;
726 
727 clk_mgr->smu_ver = rn_vbios_smu_get_smu_version(clk_mgr);
728 
729 clk_mgr->periodic_retraining_disabled = 
rn_vbios_smu_is_periodic_retraining_disabled(clk_mgr);
730 
731 /* SMU Version 55.51.0 and up no longer have an issue
732  * that needs to limit minimum dispclk */
733 if (clk_mgr->smu_ver >= SMU_VER_55_51_0)
734 debug->min_disp_clk_khz = 0;
735 
736 /* TODO: Check we get what we expect during bringup */
737 clk_mgr->base.dentist_vco_freq_khz = 
get_vco_frequency_from_reg(clk_mgr);
738 
739 /* in case we don't get a value from the register, use default 
*/
740 if (clk_mgr->base.dentist_vco_freq_khz == 0)
741 clk_mgr->base.dentist_vco_freq_khz = 360;
742 
743 if (ctx->dc_bios->integrated_info->memory_type == 
LpDdr4MemType) {
^
This dereference was in an if statement before so Smatch didn't
trigger a warning.

744 if (clk_mgr->periodic_retraining_disabled) {
745 rn_bw_params.wm_table = 
lpddr4_wm_table_with_disabled_ppt;
746 } else {
747 if (is_green_sardine)
748 rn_bw_params.wm_table = 
lpddr4_wm_table_gs;
749 else
750 rn_bw_params.wm_table = 
lpddr4_wm_table_rn;
751 }
752 } else {
753 if (is_green_sardine)
754 rn_bw_params.wm_table = ddr4_wm_table_gs;
755 else {
756 if (ctx->dc->config.is_single_rank_dimm)
757 rn_bw_params.wm_table = 
ddr4_1R_wm_table_rn;
758 else
759 rn_bw_params.wm_table = 
ddr4_wm_table_rn;
760 }
761 }
762 /* Saved clocks configured at boot for debug purposes */
763 rn_dump_clk_registers(_mgr->base.boot_snapshot, 
_mgr->base, _info);
764 
765 clk_mgr->base.dprefclk_khz = 60;
766 dce_clock_read_ss_info(clk_mgr);
767 
768 
769 clk_mgr->base.bw_params = _bw_params;
770 
771 if (pp_smu && pp_smu->rn_funcs.get_dpm_clock_table) {
772 status = 
pp_smu->rn_funcs.get_dpm_clock_table(_smu->rn_funcs.pp_smu, _table);
773 
774 if 

[PATCH -next 04/13] drm/amd/display: remove unused definition

2023-05-24 Thread Yang Li
Eliminate the following warnings:
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn31/dcn31_resource.c:1356:43: 
warning: unused variable 'res_create_maximus_funcs'
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn31/dcn31_resource.c:894:38: 
warning: unused variable 'debug_defaults_diags'

Reported-by: Abaci Robot 
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5296
Fixes: 00df97e1df57 ("drm/amd/display: Clean FPGA code in dc")
Signed-off-by: Yang Li 
---
 .../drm/amd/display/dc/dcn31/dcn31_resource.c | 27 ---
 1 file changed, 27 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c
index 9c637c895f91..f2d589c505a8 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c
@@ -891,24 +891,6 @@ static const struct dc_debug_options debug_defaults_drv = {
.dml_hostvm_override = DML_HOSTVM_OVERRIDE_FALSE,
 };
 
-static const struct dc_debug_options debug_defaults_diags = {
-   .disable_dmcu = true,
-   .force_abm_enable = false,
-   .timing_trace = true,
-   .clock_trace = true,
-   .disable_dpp_power_gate = true,
-   .disable_hubp_power_gate = true,
-   .disable_clock_gate = true,
-   .disable_pplib_clock_request = true,
-   .disable_pplib_wm_range = true,
-   .disable_stutter = false,
-   .scl_reset_length10 = true,
-   .dwb_fi_phase = -1, // -1 = disable
-   .dmub_command_table = true,
-   .enable_tri_buf = true,
-   .use_max_lb = true
-};
-
 static const struct dc_panel_config panel_config_defaults = {
.psr = {
.disable_psr = false,
@@ -1353,15 +1335,6 @@ static const struct resource_create_funcs 
res_create_funcs = {
.create_hwseq = dcn31_hwseq_create,
 };
 
-static const struct resource_create_funcs res_create_maximus_funcs = {
-   .read_dce_straps = NULL,
-   .create_audio = NULL,
-   .create_stream_encoder = NULL,
-   .create_hpo_dp_stream_encoder = dcn31_hpo_dp_stream_encoder_create,
-   .create_hpo_dp_link_encoder = dcn31_hpo_dp_link_encoder_create,
-   .create_hwseq = dcn31_hwseq_create,
-};
-
 static void dcn31_resource_destruct(struct dcn31_resource_pool *pool)
 {
unsigned int i;
-- 
2.20.1.7.g153144c



[PATCH v2] drm/amdgpu: resove reboot exception for si oland

2023-05-24 Thread Zhenneng Li
During reboot test on arm64 platform, it may failure
on boot.

The error message are as follows:
[1.706570][ 3] [  T273] [drm:si_thermal_enable_alert [amdgpu]] *ERROR* 
Could not enable thermal interrupts.
[1.716547][ 3] [  T273] [drm:amdgpu_device_ip_late_init [amdgpu]] *ERROR* 
late_init of IP block  failed -22
[1.727064][ 3] [  T273] amdgpu :02:00.0: amdgpu_device_ip_late_init 
failed
[1.734367][ 3] [  T273] amdgpu :02:00.0: Fatal error during GPU init

---
 drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 12 
 1 file changed, 12 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c 
b/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
index d6d9e3b1b2c0..ca9bce895dbe 100644
--- a/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
+++ b/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
@@ -7626,18 +7626,6 @@ static int si_dpm_process_interrupt(struct amdgpu_device 
*adev,
 
 static int si_dpm_late_init(void *handle)
 {
-   int ret;
-   struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-
-   if (!adev->pm.dpm_enabled)
-   return 0;
-
-   ret = si_set_temperature_range(adev);
-   if (ret)
-   return ret;
-#if 0 //TODO ?
-   si_dpm_powergate_uvd(adev, true);
-#endif
return 0;
 }
 
-- 
2.25.1


No virus found
Checked by Hillstone Network AntiVirus


[PATCH -next 13/13] drm/amd/display: remove unused definition

2023-05-24 Thread Yang Li
Eliminate the following warning:
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn201/dcn201_resource.c:899:43: 
warning: unused variable 'res_create_maximus_funcs'

Reported-by: Abaci Robot 
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5296
Fixes: 00df97e1df57 ("drm/amd/display: Clean FPGA code in dc")
Signed-off-by: Yang Li 
---
 drivers/gpu/drm/amd/display/dc/dcn201/dcn201_resource.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_resource.c
index 212c475d95cb..5ff09bf4bc30 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_resource.c
@@ -896,13 +896,6 @@ static const struct resource_create_funcs res_create_funcs 
= {
.create_hwseq = dcn201_hwseq_create,
 };
 
-static const struct resource_create_funcs res_create_maximus_funcs = {
-   .read_dce_straps = NULL,
-   .create_audio = NULL,
-   .create_stream_encoder = NULL,
-   .create_hwseq = dcn201_hwseq_create,
-};
-
 static void dcn201_clock_source_destroy(struct clock_source **clk_src)
 {
kfree(TO_DCE110_CLK_SRC(*clk_src));
-- 
2.20.1.7.g153144c



[PATCH] drm/amdgpu: add a flag to indicate if a VM is attached to fpriv

2023-05-24 Thread Guchun Chen
Recent code stores xcp_id to amdgpu bo for accounting memory
usage or find correct KFD node, and this xcp_id is from file
private data after opening device. However, not all VMs are
attached to this fpriv structure like the case in amdgpu_mes_self_test.
So add a flag to differentiate the cases. Otherwise, KASAN will
complain out of bound access.

[   77.292314] BUG: KASAN: slab-out-of-bounds in 
amdgpu_vm_pt_create+0x17e/0x4b0 [amdgpu]
[   77.293845] Read of size 4 at addr 888102c48a48 by task modprobe/1069
[   77.294146] Call Trace:
[   77.294178]  
[   77.294208]  dump_stack_lvl+0x49/0x63
[   77.294260]  print_report+0x16f/0x4a6
[   77.294307]  ? amdgpu_vm_pt_create+0x17e/0x4b0 [amdgpu]
[   77.295979]  ? kasan_complete_mode_report_info+0x3c/0x200
[   77.296057]  ? amdgpu_vm_pt_create+0x17e/0x4b0 [amdgpu]
[   77.297556]  kasan_report+0xb4/0x130
[   77.297609]  ? amdgpu_vm_pt_create+0x17e/0x4b0 [amdgpu]
[   77.299202]  __asan_load4+0x6f/0x90
[   77.299272]  amdgpu_vm_pt_create+0x17e/0x4b0 [amdgpu]
[   77.300796]  ? amdgpu_init+0x6e/0x1000 [amdgpu]
[   77.30]  ? amdgpu_vm_pt_clear+0x750/0x750 [amdgpu]
[   77.303721]  ? preempt_count_sub+0x18/0xc0
[   77.303786]  amdgpu_vm_init+0x39e/0x870 [amdgpu]
[   77.305186]  ? amdgpu_vm_wait_idle+0x90/0x90 [amdgpu]
[   77.306683]  ? kasan_set_track+0x25/0x30
[   77.306737]  ? kasan_save_alloc_info+0x1b/0x30
[   77.306795]  ? __kasan_kmalloc+0x87/0xa0
[   77.306852]  amdgpu_mes_self_test+0x169/0x620 [amdgpu]

Fixes: ffc6deb773f7("drm/amdkfd: Store xcp partition id to amdgpu bo")
Signed-off-by: Guchun Chen 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c   |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c   |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c|  5 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h|  5 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c | 12 +---
 5 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index 41d047e5de69..79b80f9233db 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -1229,7 +1229,7 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct 
drm_file *file_priv)
pasid = 0;
}
 
-   r = amdgpu_vm_init(adev, >vm);
+   r = amdgpu_vm_init(adev, >vm, true);
if (r)
goto error_pasid;
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
index 49bb6c03d606..3be5219edf88 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
@@ -1345,7 +1345,7 @@ int amdgpu_mes_self_test(struct amdgpu_device *adev)
goto error_pasid;
}
 
-   r = amdgpu_vm_init(adev, vm);
+   r = amdgpu_vm_init(adev, vm, false);
if (r) {
DRM_ERROR("failed to initialize vm\n");
goto error_pasid;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 37b9d8a8dbec..47ffaa1526a0 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -2099,13 +2099,15 @@ long amdgpu_vm_wait_idle(struct amdgpu_vm *vm, long 
timeout)
  *
  * @adev: amdgpu_device pointer
  * @vm: requested vm
+ * @vm_attach_to_fpriv: flag to tell if vm is attached to file private data
  *
  * Init @vm fields.
  *
  * Returns:
  * 0 for success, error for failure.
  */
-int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm)
+int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,
+  bool vm_attach_to_fpriv)
 {
struct amdgpu_bo *root_bo;
struct amdgpu_bo_vm *root;
@@ -2131,6 +2133,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct 
amdgpu_vm *vm)
 
vm->pte_support_ats = false;
vm->is_compute_context = false;
+   vm->vm_attach_to_fpriv = vm_attach_to_fpriv;
 
vm->use_cpu_for_update = !!(adev->vm_manager.vm_update_mode &
AMDGPU_VM_USE_CPU_FOR_GFX);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
index d551fca1780e..62ed14b1fc16 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
@@ -333,6 +333,9 @@ struct amdgpu_vm {
/* Flag to indicate if VM is used for compute */
boolis_compute_context;
 
+   /* Flag to tell if VM is attached to file private data */
+   bool vm_attach_to_fpriv;
+
/* Memory partition number, -1 means any partition */
int8_t  mem_id;
 };
@@ -392,7 +395,7 @@ int amdgpu_vm_set_pasid(struct amdgpu_device *adev, struct 
amdgpu_vm *vm,
u32 pasid);
 
 long amdgpu_vm_wait_idle(struct amdgpu_vm *vm, long timeout);
-int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm);
+int amdgpu_vm_init(struct amdgpu_device *adev, struct 

[PATCH v4 12/13] drm/fbdev-generic: Implement dedicated fbdev I/O helpers

2023-05-24 Thread Thomas Zimmermann
Implement dedicated fbdev helpers for framebuffer I/O instead
of using DRM's helpers. Use an fbdev generator macro for
deferred I/O to create the callbacks. Fbdev-generic was the
only caller of the DRM helpers, so remove them from the helper
module.

v4:
* generate deferred-I/O helpers
* use initializer macros for fb_ops
v2:
* use FB_SYS_HELPERS_DEFERRED option

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/Kconfig |   6 +-
 drivers/gpu/drm/drm_fb_helper.c | 107 
 drivers/gpu/drm/drm_fbdev_generic.c |  11 ++-
 include/drm/drm_fb_helper.h |  41 ---
 4 files changed, 6 insertions(+), 159 deletions(-)

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 77fb10ddd8a2..92a782827b7b 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -95,6 +95,7 @@ config DRM_KUNIT_TEST
 config DRM_KMS_HELPER
tristate
depends on DRM
+   select FB_SYS_HELPERS_DEFERRED if DRM_FBDEV_EMULATION
help
  CRTC helpers for KMS drivers.
 
@@ -135,11 +136,6 @@ config DRM_FBDEV_EMULATION
select FB_CFB_FILLRECT
select FB_CFB_COPYAREA
select FB_CFB_IMAGEBLIT
-   select FB_DEFERRED_IO
-   select FB_SYS_FOPS
-   select FB_SYS_FILLRECT
-   select FB_SYS_COPYAREA
-   select FB_SYS_IMAGEBLIT
select FRAMEBUFFER_CONSOLE if !EXPERT
select FRAMEBUFFER_CONSOLE_DETECT_PRIMARY if FRAMEBUFFER_CONSOLE
default y
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index cb03099fd2e3..bab6b252f02a 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -736,113 +736,6 @@ void drm_fb_helper_deferred_io(struct fb_info *info, 
struct list_head *pagerefli
 }
 EXPORT_SYMBOL(drm_fb_helper_deferred_io);
 
-/**
- * drm_fb_helper_sys_read - Implements struct _ops.fb_read for system memory
- * @info: fb_info struct pointer
- * @buf: userspace buffer to read from framebuffer memory
- * @count: number of bytes to read from framebuffer memory
- * @ppos: read offset within framebuffer memory
- *
- * Returns:
- * The number of bytes read on success, or an error code otherwise.
- */
-ssize_t drm_fb_helper_sys_read(struct fb_info *info, char __user *buf,
-  size_t count, loff_t *ppos)
-{
-   return fb_sys_read(info, buf, count, ppos);
-}
-EXPORT_SYMBOL(drm_fb_helper_sys_read);
-
-/**
- * drm_fb_helper_sys_write - Implements struct _ops.fb_write for system 
memory
- * @info: fb_info struct pointer
- * @buf: userspace buffer to write to framebuffer memory
- * @count: number of bytes to write to framebuffer memory
- * @ppos: write offset within framebuffer memory
- *
- * Returns:
- * The number of bytes written on success, or an error code otherwise.
- */
-ssize_t drm_fb_helper_sys_write(struct fb_info *info, const char __user *buf,
-   size_t count, loff_t *ppos)
-{
-   struct drm_fb_helper *helper = info->par;
-   loff_t pos = *ppos;
-   ssize_t ret;
-   struct drm_rect damage_area;
-
-   ret = fb_sys_write(info, buf, count, ppos);
-   if (ret <= 0)
-   return ret;
-
-   if (helper->funcs->fb_dirty) {
-   drm_fb_helper_memory_range_to_clip(info, pos, ret, 
_area);
-   drm_fb_helper_damage(helper, damage_area.x1, damage_area.y1,
-drm_rect_width(_area),
-drm_rect_height(_area));
-   }
-
-   return ret;
-}
-EXPORT_SYMBOL(drm_fb_helper_sys_write);
-
-/**
- * drm_fb_helper_sys_fillrect - wrapper around sys_fillrect
- * @info: fbdev registered by the helper
- * @rect: info about rectangle to fill
- *
- * A wrapper around sys_fillrect implemented by fbdev core
- */
-void drm_fb_helper_sys_fillrect(struct fb_info *info,
-   const struct fb_fillrect *rect)
-{
-   struct drm_fb_helper *helper = info->par;
-
-   sys_fillrect(info, rect);
-
-   if (helper->funcs->fb_dirty)
-   drm_fb_helper_damage(helper, rect->dx, rect->dy, rect->width, 
rect->height);
-}
-EXPORT_SYMBOL(drm_fb_helper_sys_fillrect);
-
-/**
- * drm_fb_helper_sys_copyarea - wrapper around sys_copyarea
- * @info: fbdev registered by the helper
- * @area: info about area to copy
- *
- * A wrapper around sys_copyarea implemented by fbdev core
- */
-void drm_fb_helper_sys_copyarea(struct fb_info *info,
-   const struct fb_copyarea *area)
-{
-   struct drm_fb_helper *helper = info->par;
-
-   sys_copyarea(info, area);
-
-   if (helper->funcs->fb_dirty)
-   drm_fb_helper_damage(helper, area->dx, area->dy, area->width, 
area->height);
-}
-EXPORT_SYMBOL(drm_fb_helper_sys_copyarea);
-
-/**
- * drm_fb_helper_sys_imageblit - wrapper around sys_imageblit
- * @info: fbdev registered by the helper
- * @image: info about image to blit
- *
- * A wrapper 

[PATCH v4 10/13] drm/tegra: Use regular fbdev I/O helpers

2023-05-24 Thread Thomas Zimmermann
Use the regular fbdev helpers for framebuffer I/O instead of DRM's
helpers. Tegra does not use damage handling, so DRM's fbdev helpers
are mere wrappers around the fbdev code.

By using fbdev helpers directly within each DRM fbdev emulation,
we can eventually remove DRM's wrapper functions entirely.

v4:
* use initializer macros for struct fb_ops
v2:
* use FB_SYS_HELPERS option

Signed-off-by: Thomas Zimmermann 
Cc: Thierry Reding 
Cc: Mikko Perttunen 
Cc: Jonathan Hunter 
---
 drivers/gpu/drm/tegra/Kconfig | 1 +
 drivers/gpu/drm/tegra/fbdev.c | 8 +++-
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/tegra/Kconfig b/drivers/gpu/drm/tegra/Kconfig
index 56453ca277c2..498313778175 100644
--- a/drivers/gpu/drm/tegra/Kconfig
+++ b/drivers/gpu/drm/tegra/Kconfig
@@ -12,6 +12,7 @@ config DRM_TEGRA
select DRM_KMS_HELPER
select DRM_MIPI_DSI
select DRM_PANEL
+   select FB_SYS_HELPERS if DRM_FBDEV_EMULATION
select TEGRA_HOST1X
select INTERCONNECT
select IOMMU_IOVA
diff --git a/drivers/gpu/drm/tegra/fbdev.c b/drivers/gpu/drm/tegra/fbdev.c
index dca9eccae466..e74d9be981c7 100644
--- a/drivers/gpu/drm/tegra/fbdev.c
+++ b/drivers/gpu/drm/tegra/fbdev.c
@@ -8,6 +8,7 @@
  */
 
 #include 
+#include 
 #include 
 
 #include 
@@ -58,12 +59,9 @@ static void tegra_fbdev_fb_destroy(struct fb_info *info)
 
 static const struct fb_ops tegra_fb_ops = {
.owner = THIS_MODULE,
+   __FB_DEFAULT_SYS_OPS_RDWR,
DRM_FB_HELPER_DEFAULT_OPS,
-   .fb_read = drm_fb_helper_sys_read,
-   .fb_write = drm_fb_helper_sys_write,
-   .fb_fillrect = drm_fb_helper_sys_fillrect,
-   .fb_copyarea = drm_fb_helper_sys_copyarea,
-   .fb_imageblit = drm_fb_helper_sys_imageblit,
+   __FB_DEFAULT_SYS_OPS_DRAW,
.fb_mmap = tegra_fb_mmap,
.fb_destroy = tegra_fbdev_fb_destroy,
 };
-- 
2.40.1



[PATCH v4 07/13] drm/fbdev-dma: Use regular fbdev I/O helpers

2023-05-24 Thread Thomas Zimmermann
Use the regular fbdev helpers for framebuffer I/O instead of DRM's
helpers. Fbdev-dma does not use damage handling, so DRM's fbdev helpers
are mere wrappers around the fbdev code.

By using fbdev helpers directly within each DRM fbdev emulation,
we can eventually remove DRM's wrapper functions entirely.

v4:
* use initializer macros for struct fb_ops
v2:
* use FB_SYS_HELPERS option

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/Kconfig |  1 +
 drivers/gpu/drm/drm_fbdev_dma.c | 11 +--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index ba3fb04bb691..77fb10ddd8a2 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -223,6 +223,7 @@ config DRM_TTM_HELPER
 config DRM_GEM_DMA_HELPER
tristate
depends on DRM
+   select FB_SYS_HELPERS if DRM_FBDEV_EMULATION
help
  Choose this if you need the GEM DMA helper functions
 
diff --git a/drivers/gpu/drm/drm_fbdev_dma.c b/drivers/gpu/drm/drm_fbdev_dma.c
index 728deffcc0d9..d86773fa8ab0 100644
--- a/drivers/gpu/drm/drm_fbdev_dma.c
+++ b/drivers/gpu/drm/drm_fbdev_dma.c
@@ -1,5 +1,7 @@
 // SPDX-License-Identifier: MIT
 
+#include 
+
 #include 
 #include 
 #include 
@@ -64,14 +66,11 @@ static const struct fb_ops drm_fbdev_dma_fb_ops = {
.owner = THIS_MODULE,
.fb_open = drm_fbdev_dma_fb_open,
.fb_release = drm_fbdev_dma_fb_release,
-   .fb_read = drm_fb_helper_sys_read,
-   .fb_write = drm_fb_helper_sys_write,
+   __FB_DEFAULT_SYS_OPS_RDWR,
DRM_FB_HELPER_DEFAULT_OPS,
-   .fb_fillrect = drm_fb_helper_sys_fillrect,
-   .fb_copyarea = drm_fb_helper_sys_copyarea,
-   .fb_imageblit = drm_fb_helper_sys_imageblit,
-   .fb_destroy = drm_fbdev_dma_fb_destroy,
+   __FB_DEFAULT_SYS_OPS_DRAW,
.fb_mmap = drm_fbdev_dma_fb_mmap,
+   .fb_destroy = drm_fbdev_dma_fb_destroy,
 };
 
 /*
-- 
2.40.1



[PATCH v4 02/13] fbdev: Add initializer macros for struct fb_ops

2023-05-24 Thread Thomas Zimmermann
For framebuffers in I/O and system memory, add macros that set
struct fb_ops to the respective callback functions.

For deferred I/O, add macros that generate callback functions with
damage handling. Add initializer macros that set struct fb_ops to
the generated callbacks.

These macros can remove a lot boilerplate code from fbdev drivers.
The drivers are supposed to use the macro that is required for its
framebuffer. Each macro is split into smaller helpers, so that
drivers with non-standard callbacks can pick and customize callbacks
as needed. There are individual helper macros for read/write, mmap
and drawing.

Signed-off-by: Thomas Zimmermann 
---
 include/linux/fb.h | 112 +
 1 file changed, 112 insertions(+)

diff --git a/include/linux/fb.h b/include/linux/fb.h
index 2cf8efcb9e32..731472a2bb62 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -538,9 +538,31 @@ extern ssize_t fb_io_read(struct fb_info *info, char 
__user *buf,
 extern ssize_t fb_io_write(struct fb_info *info, const char __user *buf,
   size_t count, loff_t *ppos);
 
+/*
+ * Initializes struct fb_ops for framebuffers in I/O memory.
+ */
+
+#define __FB_DEFAULT_IO_OPS_RDWR \
+   .fb_read= fb_io_read, \
+   .fb_write   = fb_io_write
+
+#define __FB_DEFAULT_IO_OPS_DRAW \
+.fb_fillrect   = cfb_fillrect, \
+.fb_copyarea   = cfb_copyarea, \
+.fb_imageblit  = cfb_imageblit
+
+#define __FB_DEFAULT_IO_OPS_MMAP \
+   .fb_mmap= NULL // default implementation
+
+#define FB_DEFAULT_IO_OPS \
+   __FB_DEFAULT_IO_OPS_RDWR, \
+   __FB_DEFAULT_IO_OPS_DRAW, \
+   __FB_DEFAULT_IO_OPS_MMAP
+
 /*
  * Drawing operations where framebuffer is in system RAM
  */
+
 extern void sys_fillrect(struct fb_info *info, const struct fb_fillrect *rect);
 extern void sys_copyarea(struct fb_info *info, const struct fb_copyarea *area);
 extern void sys_imageblit(struct fb_info *info, const struct fb_image *image);
@@ -549,6 +571,27 @@ extern ssize_t fb_sys_read(struct fb_info *info, char 
__user *buf,
 extern ssize_t fb_sys_write(struct fb_info *info, const char __user *buf,
size_t count, loff_t *ppos);
 
+/*
+ * Initializes struct fb_ops for framebuffers in system memory.
+ */
+
+#define __FB_DEFAULT_SYS_OPS_RDWR \
+   .fb_read= fb_sys_read, \
+   .fb_write   = fb_sys_write
+
+#define __FB_DEFAULT_SYS_OPS_DRAW \
+.fb_fillrect   = sys_fillrect, \
+.fb_copyarea   = sys_copyarea, \
+.fb_imageblit  = sys_imageblit
+
+#define __FB_DEFAULT_SYS_OPS_MMAP \
+   .fb_mmap= NULL // default implementation
+
+#define FB_DEFAULT_SYS_OPS \
+   __FB_DEFAULT_SYS_OPS_RDWR, \
+   __FB_DEFAULT_SYS_OPS_DRAW, \
+   __FB_DEFAULT_SYS_OPS_MMAP
+
 /* drivers/video/fbmem.c */
 extern int register_framebuffer(struct fb_info *fb_info);
 extern void unregister_framebuffer(struct fb_info *fb_info);
@@ -604,6 +647,75 @@ extern void fb_deferred_io_cleanup(struct fb_info *info);
 extern int fb_deferred_io_fsync(struct file *file, loff_t start,
loff_t end, int datasync);
 
+/*
+ * Generate callbacks for deferred I/O
+ */
+
+#define __FB_GEN_DEFAULT_DEFERRED_OPS_RDWR(__prefix, __damage_range, __mode) \
+   static ssize_t __prefix ## _defio_read(struct fb_info *info, char 
__user *buf, \
+  size_t count, loff_t *ppos) \
+   { \
+   return fb_ ## __mode ## _read(info, buf, count, ppos); \
+   } \
+   static ssize_t __prefix ## _defio_write(struct fb_info *info, const 
char __user *buf, \
+   size_t count, loff_t *ppos) \
+   { \
+   unsigned long offset = *ppos; \
+   ssize_t ret = fb_ ## __mode ## _write(info, buf, count, ppos); \
+   if (ret > 0) \
+   __damage_range(info, offset, ret); \
+   return ret; \
+   }
+
+#define __FB_GEN_DEFAULT_DEFERRED_OPS_DRAW(__prefix, __damage_area, __mode) \
+   static void __prefix ## _defio_fillrect(struct fb_info *info, \
+   const struct fb_fillrect *rect) 
\
+   { \
+   __mode ## _fillrect(info, rect); \
+   __damage_area(info, rect->dx, rect->dy, rect->width, 
rect->height); \
+   } \
+   static void __prefix ## _defio_copyarea(struct fb_info *info, \
+   const struct fb_copyarea *area) 
\
+   { \
+   __mode ## _copyarea(info, area); \
+   __damage_area(info, area->dx, area->dy, area->width, 
area->height); \
+   } \
+   static void __prefix ## _defio_imageblit(struct fb_info *info, \
+const struct fb_image *image) \
+   { \
+   __mode ## _imageblit(info, image); \
+   

[PATCH v4 06/13] drm/radeon: Use regular fbdev I/O helpers

2023-05-24 Thread Thomas Zimmermann
Use the regular fbdev helpers for framebuffer I/O instead of DRM's
helpers. Radeon does not use damage handling, so DRM's fbdev helpers
are mere wrappers around the fbdev code.

By using fbdev helpers directly within each DRM fbdev emulation,
we can eventually remove DRM's wrapper functions entirely.

v4:
* use initializer macros for struct fb_ops
v2:
* use FB_IO_HELPERS option

Signed-off-by: Thomas Zimmermann 
Acked-by: Alex Deucher 
Cc: Alex Deucher 
Cc: "Christian König" 
Cc: "Pan, Xinhui" 
---
 drivers/gpu/drm/radeon/Kconfig| 1 +
 drivers/gpu/drm/radeon/radeon_fbdev.c | 9 +++--
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/radeon/Kconfig b/drivers/gpu/drm/radeon/Kconfig
index e19d77d58810..fe498c8af1bb 100644
--- a/drivers/gpu/drm/radeon/Kconfig
+++ b/drivers/gpu/drm/radeon/Kconfig
@@ -11,6 +11,7 @@ config DRM_RADEON
select DRM_SUBALLOC_HELPER
 select DRM_TTM
select DRM_TTM_HELPER
+   select FB_IO_HELPERS if DRM_FBDEV_EMULATION
select SND_HDA_COMPONENT if SND_HDA_CORE
select POWER_SUPPLY
select HWMON
diff --git a/drivers/gpu/drm/radeon/radeon_fbdev.c 
b/drivers/gpu/drm/radeon/radeon_fbdev.c
index fe76e29910ef..28212c2d6c98 100644
--- a/drivers/gpu/drm/radeon/radeon_fbdev.c
+++ b/drivers/gpu/drm/radeon/radeon_fbdev.c
@@ -24,6 +24,7 @@
  * David Airlie
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -190,14 +191,10 @@ static void radeon_fbdev_fb_destroy(struct fb_info *info)
 
 static const struct fb_ops radeon_fbdev_fb_ops = {
.owner = THIS_MODULE,
-   DRM_FB_HELPER_DEFAULT_OPS,
.fb_open = radeon_fbdev_fb_open,
.fb_release = radeon_fbdev_fb_release,
-   .fb_read = drm_fb_helper_cfb_read,
-   .fb_write = drm_fb_helper_cfb_write,
-   .fb_fillrect = drm_fb_helper_cfb_fillrect,
-   .fb_copyarea = drm_fb_helper_cfb_copyarea,
-   .fb_imageblit = drm_fb_helper_cfb_imageblit,
+   FB_DEFAULT_IO_OPS,
+   DRM_FB_HELPER_DEFAULT_OPS,
.fb_destroy = radeon_fbdev_fb_destroy,
 };
 
-- 
2.40.1



[PATCH v4 09/13] drm/omapdrm: Use regular fbdev I/O helpers

2023-05-24 Thread Thomas Zimmermann
Use the regular fbdev helpers for framebuffer I/O instead of DRM's
helpers. Omapdrm does not use damage handling, so DRM's fbdev helpers
are mere wrappers around the fbdev code.

By using fbdev helpers directly within each DRM fbdev emulation,
we can eventually remove DRM's wrapper functions entirely.

v4:
* use initializer macros for struct fb_ops
v2:
* use FB_SYS_HELPERS option

Signed-off-by: Thomas Zimmermann 
Cc: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/Kconfig  |  1 +
 drivers/gpu/drm/omapdrm/omap_fbdev.c | 11 +++
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/Kconfig b/drivers/gpu/drm/omapdrm/Kconfig
index 76ded1568bd0..b4ac76c9f31b 100644
--- a/drivers/gpu/drm/omapdrm/Kconfig
+++ b/drivers/gpu/drm/omapdrm/Kconfig
@@ -4,6 +4,7 @@ config DRM_OMAP
depends on DRM && OF
depends on ARCH_OMAP2PLUS
select DRM_KMS_HELPER
+   select FB_SYS_HELPERS if DRM_FBDEV_EMULATION
select VIDEOMODE_HELPERS
select HDMI
default n
diff --git a/drivers/gpu/drm/omapdrm/omap_fbdev.c 
b/drivers/gpu/drm/omapdrm/omap_fbdev.c
index b950e93b3846..b7ccce0704a3 100644
--- a/drivers/gpu/drm/omapdrm/omap_fbdev.c
+++ b/drivers/gpu/drm/omapdrm/omap_fbdev.c
@@ -4,6 +4,8 @@
  * Author: Rob Clark 
  */
 
+#include 
+
 #include 
 #include 
 #include 
@@ -95,20 +97,13 @@ static void omap_fbdev_fb_destroy(struct fb_info *info)
 
 static const struct fb_ops omap_fb_ops = {
.owner = THIS_MODULE,
-
+   FB_DEFAULT_SYS_OPS,
.fb_check_var   = drm_fb_helper_check_var,
.fb_set_par = drm_fb_helper_set_par,
.fb_setcmap = drm_fb_helper_setcmap,
.fb_blank   = drm_fb_helper_blank,
.fb_pan_display = omap_fbdev_pan_display,
.fb_ioctl   = drm_fb_helper_ioctl,
-
-   .fb_read = drm_fb_helper_sys_read,
-   .fb_write = drm_fb_helper_sys_write,
-   .fb_fillrect = drm_fb_helper_sys_fillrect,
-   .fb_copyarea = drm_fb_helper_sys_copyarea,
-   .fb_imageblit = drm_fb_helper_sys_imageblit,
-
.fb_destroy = omap_fbdev_fb_destroy,
 };
 
-- 
2.40.1



[PATCH v4 11/13] drm/fb-helper: Export helpers for marking damage areas

2023-05-24 Thread Thomas Zimmermann
Export drm_fb_helper_damage() and drm_fb_helper_damage_range(), which
handle damage areas for fbdev emulation. This is a temporary export
that allows to move the DRM I/O helpers for fbdev into drivers. Only
fbdev-generic and i915 need them. Both will be updated to implement
damage handling by themselves and the exported functions will be removed.

v4:
* update interfaces

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

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index f0e9549b6bd7..cb03099fd2e3 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -670,6 +670,28 @@ static void drm_fb_helper_memory_range_to_clip(struct 
fb_info *info, off_t off,
drm_rect_init(clip, x1, y1, x2 - x1, y2 - y1);
 }
 
+/* Don't use in new code. */
+void drm_fb_helper_damage_range(struct fb_info *info, off_t off, size_t len)
+{
+   struct drm_fb_helper *fb_helper = info->par;
+   struct drm_rect damage_area;
+
+   drm_fb_helper_memory_range_to_clip(info, off, len, _area);
+   drm_fb_helper_damage(fb_helper, damage_area.x1, damage_area.y1,
+drm_rect_width(_area),
+drm_rect_height(_area));
+}
+EXPORT_SYMBOL(drm_fb_helper_damage_range);
+
+/* Don't use in new code. */
+void drm_fb_helper_damage_area(struct fb_info *info, u32 x, u32 y, u32 width, 
u32 height)
+{
+   struct drm_fb_helper *fb_helper = info->par;
+
+   drm_fb_helper_damage(fb_helper, x, y, width, height);
+}
+EXPORT_SYMBOL(drm_fb_helper_damage_area);
+
 /**
  * drm_fb_helper_deferred_io() - fbdev deferred_io callback function
  * @info: fb_info struct pointer
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index 72032c354a30..7d5804882be7 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -253,6 +253,9 @@ void drm_fb_helper_fill_info(struct fb_info *info,
 struct drm_fb_helper *fb_helper,
 struct drm_fb_helper_surface_size *sizes);
 
+void drm_fb_helper_damage_range(struct fb_info *info, off_t off, size_t len);
+void drm_fb_helper_damage_area(struct fb_info *info, u32 x, u32 y, u32 width, 
u32 height);
+
 void drm_fb_helper_deferred_io(struct fb_info *info, struct list_head 
*pagereflist);
 
 ssize_t drm_fb_helper_sys_read(struct fb_info *info, char __user *buf,
-- 
2.40.1



[PATCH v4 00/13] drm/fbdev: Remove DRM's helpers for fbdev I/O

2023-05-24 Thread Thomas Zimmermann
DRM provides a number of wrappers around fbdev cfb_() sys_(), fb_io_()
and fb_sys_() helpers. The DRM functions don't provide any additional
functionality for most DRM drivers. So remove them and call the fbdev
I/O helpers directly.

The DRM fbdev I/O wrappers were originally added because 
does not protect its content with CONFIG_FB. DRM fbdev emulation did
not build if the config option had been disabled. This has been
fixed. For fbdev-generic and i915, the wrappers added support for damage
handling. But this is better handled within the two callers, as each
is special in its damage handling.

Patch 1 adds several internal Kconfig options that DRM drivers (and
possibly other fbdev code) will use to select the correct set of I/O
helpers. Patch 2 adds initializers for struct fb_ops and generator
macros for the callback functions. These macros will simplify drivers.
This patchset applies the new options and macros to DRM fbdev emulation,
but regular fbdev drivers can use them as well.

Patches 3 to 10 replace the DRM wrappers in a number of fbdev emulations.
Patch 10 exports two helpers for damage handling. Patches 12 and 13
update fbdev-generic and i915 with the help of the exported functions.
The patches also remove DRM's fbdev I/O helpers, which are now unused.

DRM's fbdev helpers had to select fbdev I/O helpers for I/O and for
system memory. Each fbdev emulation now selects the correct helpers
for itself. Depending on the selected DRM drivers, kernel builds will
now only contain the necessary fbdev I/O helpers and might be slightly
smaller in size.

v4:
* use initializer and generator macros for struct fb_ops
* partially support damage handling in msm (Dmitri)
v3:
* fix Kconfig options (Jingfeng)
* minimize changes to exynos (Sam)
v2:
* simplify Kconfig handling (Sam)

Thomas Zimmermann (13):
  fbdev: Add Kconfig options to select different fb_ops helpers
  fbdev: Add initializer macros for struct fb_ops
  drm/armada: Use regular fbdev I/O helpers
  drm/exynos: Use regular fbdev I/O helpers
  drm/gma500: Use regular fbdev I/O helpers
  drm/radeon: Use regular fbdev I/O helpers
  drm/fbdev-dma: Use regular fbdev I/O helpers
  drm/msm: Use regular fbdev I/O helpers
  drm/omapdrm: Use regular fbdev I/O helpers
  drm/tegra: Use regular fbdev I/O helpers
  drm/fb-helper: Export helpers for marking damage areas
  drm/fbdev-generic: Implement dedicated fbdev I/O helpers
  drm/i915: Implement dedicated fbdev I/O helpers

 drivers/gpu/drm/Kconfig|  10 +-
 drivers/gpu/drm/armada/Kconfig |   1 +
 drivers/gpu/drm/armada/armada_fbdev.c  |   7 +-
 drivers/gpu/drm/drm_fb_helper.c| 236 ++---
 drivers/gpu/drm/drm_fbdev_dma.c|  11 +-
 drivers/gpu/drm/drm_fbdev_generic.c|  11 +-
 drivers/gpu/drm/exynos/Kconfig |   1 +
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c  |   9 +-
 drivers/gpu/drm/gma500/Kconfig |   1 +
 drivers/gpu/drm/gma500/fbdev.c |   8 +-
 drivers/gpu/drm/i915/Kconfig   |   1 +
 drivers/gpu/drm/i915/display/intel_fbdev.c |  14 +-
 drivers/gpu/drm/msm/Kconfig|   1 +
 drivers/gpu/drm/msm/msm_fbdev.c|  17 +-
 drivers/gpu/drm/omapdrm/Kconfig|   1 +
 drivers/gpu/drm/omapdrm/omap_fbdev.c   |  11 +-
 drivers/gpu/drm/radeon/Kconfig |   1 +
 drivers/gpu/drm/radeon/radeon_fbdev.c  |   9 +-
 drivers/gpu/drm/tegra/Kconfig  |   1 +
 drivers/gpu/drm/tegra/fbdev.c  |   8 +-
 drivers/video/fbdev/Kconfig|  21 ++
 include/drm/drm_fb_helper.h|  83 +---
 include/linux/fb.h | 112 ++
 23 files changed, 212 insertions(+), 363 deletions(-)


base-commit: 216281f91018b24567e59ae46ce7e96fb92063cf
prerequisite-patch-id: 0aa359f6144c4015c140c8a6750be19099c676fb
prerequisite-patch-id: c67e5d886a47b7d0266d81100837557fda34cb24
prerequisite-patch-id: cbc453ee02fae02af22fbfdce56ab732c7a88c36
prerequisite-patch-id: 8bff2b12862e44027a25837ea7510f633d40839e
prerequisite-patch-id: 97ac107455aff4e0ec039d166ecdd2430d20f22e
-- 
2.40.1



[PATCH v4 13/13] drm/i915: Implement dedicated fbdev I/O helpers

2023-05-24 Thread Thomas Zimmermann
Implement dedicated fbdev helpers for framebuffer I/O instead
of using DRM's helpers. Use an fbdev generator macro for
deferred I/O to create the fbdev callbacks. i915 was the only
caller of the DRM helpers, so remove them from the helper module.

i915's fbdev emulation is still incomplete as it doesn't implement
deferred I/O and damage handling for mmaped pages.

v4:
* generate deferred-I/O helpers
* use initializer macros for fb_ops
v2:
* use FB_IO_HELPERS options

Signed-off-by: Thomas Zimmermann 
Cc: Jani Nikula 
Cc: Joonas Lahtinen 
Cc: Rodrigo Vivi 
Cc: Tvrtko Ursulin 
Cc: "Ville Syrjälä" 
---
 drivers/gpu/drm/Kconfig|   3 -
 drivers/gpu/drm/drm_fb_helper.c| 107 -
 drivers/gpu/drm/i915/Kconfig   |   1 +
 drivers/gpu/drm/i915/display/intel_fbdev.c |  14 +--
 include/drm/drm_fb_helper.h|  39 
 5 files changed, 9 insertions(+), 155 deletions(-)

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 92a782827b7b..bb2e48cc6cd6 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -133,9 +133,6 @@ config DRM_FBDEV_EMULATION
bool "Enable legacy fbdev support for your modesetting driver"
depends on DRM_KMS_HELPER
depends on FB=y || FB=DRM_KMS_HELPER
-   select FB_CFB_FILLRECT
-   select FB_CFB_COPYAREA
-   select FB_CFB_IMAGEBLIT
select FRAMEBUFFER_CONSOLE if !EXPERT
select FRAMEBUFFER_CONSOLE_DETECT_PRIMARY if FRAMEBUFFER_CONSOLE
default y
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index bab6b252f02a..9978147bbc8a 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -736,113 +736,6 @@ void drm_fb_helper_deferred_io(struct fb_info *info, 
struct list_head *pagerefli
 }
 EXPORT_SYMBOL(drm_fb_helper_deferred_io);
 
-/**
- * drm_fb_helper_cfb_read - Implements struct _ops.fb_read for I/O memory
- * @info: fb_info struct pointer
- * @buf: userspace buffer to read from framebuffer memory
- * @count: number of bytes to read from framebuffer memory
- * @ppos: read offset within framebuffer memory
- *
- * Returns:
- * The number of bytes read on success, or an error code otherwise.
- */
-ssize_t drm_fb_helper_cfb_read(struct fb_info *info, char __user *buf,
-  size_t count, loff_t *ppos)
-{
-   return fb_io_read(info, buf, count, ppos);
-}
-EXPORT_SYMBOL(drm_fb_helper_cfb_read);
-
-/**
- * drm_fb_helper_cfb_write - Implements struct _ops.fb_write for I/O memory
- * @info: fb_info struct pointer
- * @buf: userspace buffer to write to framebuffer memory
- * @count: number of bytes to write to framebuffer memory
- * @ppos: write offset within framebuffer memory
- *
- * Returns:
- * The number of bytes written on success, or an error code otherwise.
- */
-ssize_t drm_fb_helper_cfb_write(struct fb_info *info, const char __user *buf,
-   size_t count, loff_t *ppos)
-{
-   struct drm_fb_helper *helper = info->par;
-   loff_t pos = *ppos;
-   ssize_t ret;
-   struct drm_rect damage_area;
-
-   ret = fb_io_write(info, buf, count, ppos);
-   if (ret <= 0)
-   return ret;
-
-   if (helper->funcs->fb_dirty) {
-   drm_fb_helper_memory_range_to_clip(info, pos, ret, 
_area);
-   drm_fb_helper_damage(helper, damage_area.x1, damage_area.y1,
-drm_rect_width(_area),
-drm_rect_height(_area));
-   }
-
-   return ret;
-}
-EXPORT_SYMBOL(drm_fb_helper_cfb_write);
-
-/**
- * drm_fb_helper_cfb_fillrect - wrapper around cfb_fillrect
- * @info: fbdev registered by the helper
- * @rect: info about rectangle to fill
- *
- * A wrapper around cfb_fillrect implemented by fbdev core
- */
-void drm_fb_helper_cfb_fillrect(struct fb_info *info,
-   const struct fb_fillrect *rect)
-{
-   struct drm_fb_helper *helper = info->par;
-
-   cfb_fillrect(info, rect);
-
-   if (helper->funcs->fb_dirty)
-   drm_fb_helper_damage(helper, rect->dx, rect->dy, rect->width, 
rect->height);
-}
-EXPORT_SYMBOL(drm_fb_helper_cfb_fillrect);
-
-/**
- * drm_fb_helper_cfb_copyarea - wrapper around cfb_copyarea
- * @info: fbdev registered by the helper
- * @area: info about area to copy
- *
- * A wrapper around cfb_copyarea implemented by fbdev core
- */
-void drm_fb_helper_cfb_copyarea(struct fb_info *info,
-   const struct fb_copyarea *area)
-{
-   struct drm_fb_helper *helper = info->par;
-
-   cfb_copyarea(info, area);
-
-   if (helper->funcs->fb_dirty)
-   drm_fb_helper_damage(helper, area->dx, area->dy, area->width, 
area->height);
-}
-EXPORT_SYMBOL(drm_fb_helper_cfb_copyarea);
-
-/**
- * drm_fb_helper_cfb_imageblit - wrapper around cfb_imageblit
- * @info: fbdev registered by the helper
- * @image: 

[PATCH v4 03/13] drm/armada: Use regular fbdev I/O helpers

2023-05-24 Thread Thomas Zimmermann
Use the regular fbdev helpers for framebuffer I/O instead of DRM's
helpers. Armada does not use damage handling, so DRM's fbdev helpers
are mere wrappers around the fbdev code.

By using fbdev helpers directly within each DRM fbdev emulation,
we can eventually remove DRM's wrapper functions entirely.

v4:
* use initializer macros for struct fb_ops
v2:
* use FB_IO_HELPERS option

Signed-off-by: Thomas Zimmermann 
Cc: Russell King 
---
 drivers/gpu/drm/armada/Kconfig| 1 +
 drivers/gpu/drm/armada/armada_fbdev.c | 7 ++-
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/armada/Kconfig b/drivers/gpu/drm/armada/Kconfig
index f5c66d89ba99..5afade25e217 100644
--- a/drivers/gpu/drm/armada/Kconfig
+++ b/drivers/gpu/drm/armada/Kconfig
@@ -3,6 +3,7 @@ config DRM_ARMADA
tristate "DRM support for Marvell Armada SoCs"
depends on DRM && HAVE_CLK && ARM && MMU
select DRM_KMS_HELPER
+   select FB_IO_HELPERS if DRM_FBDEV_EMULATION
help
  Support the "LCD" controllers found on the Marvell Armada 510
  devices.  There are two controllers on the device, each controller
diff --git a/drivers/gpu/drm/armada/armada_fbdev.c 
b/drivers/gpu/drm/armada/armada_fbdev.c
index 0a5fd1aa86eb..3943e89cc06c 100644
--- a/drivers/gpu/drm/armada/armada_fbdev.c
+++ b/drivers/gpu/drm/armada/armada_fbdev.c
@@ -5,6 +5,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 
@@ -33,12 +34,8 @@ static void armada_fbdev_fb_destroy(struct fb_info *info)
 
 static const struct fb_ops armada_fb_ops = {
.owner  = THIS_MODULE,
+   FB_DEFAULT_IO_OPS,
DRM_FB_HELPER_DEFAULT_OPS,
-   .fb_read= drm_fb_helper_cfb_read,
-   .fb_write   = drm_fb_helper_cfb_write,
-   .fb_fillrect= drm_fb_helper_cfb_fillrect,
-   .fb_copyarea= drm_fb_helper_cfb_copyarea,
-   .fb_imageblit   = drm_fb_helper_cfb_imageblit,
.fb_destroy = armada_fbdev_fb_destroy,
 };
 
-- 
2.40.1



[PATCH v4 08/13] drm/msm: Use regular fbdev I/O helpers

2023-05-24 Thread Thomas Zimmermann
Use the regular fbdev helpers for framebuffer I/O instead of DRM's
helpers. Msm does not use damage handling, so DRM's fbdev helpers
are mere wrappers around the fbdev code.

By using fbdev helpers directly within each DRM fbdev emulation,
we can eventually remove DRM's wrapper functions entirely.

Msm's fbdev emulation has been incomplete as it didn't implement
damage handling. Partilly fix this by implementing damage handling
for write and draw operation. It is still missing for mmaped pages.

v4:
* use initializer macros for struct fb_ops
* partially support damage handling
v2:
* use FB_SYS_HELPERS option

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Dmitry Baryshkov 
Cc: Rob Clark 
Cc: Abhinav Kumar 
Cc: Dmitry Baryshkov 
Cc: Sean Paul 
---
 drivers/gpu/drm/msm/Kconfig |  1 +
 drivers/gpu/drm/msm/msm_fbdev.c | 17 -
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/msm/Kconfig b/drivers/gpu/drm/msm/Kconfig
index 85f5ab1d552c..a78662bd6273 100644
--- a/drivers/gpu/drm/msm/Kconfig
+++ b/drivers/gpu/drm/msm/Kconfig
@@ -21,6 +21,7 @@ config DRM_MSM
select DRM_BRIDGE
select DRM_PANEL_BRIDGE
select DRM_SCHED
+   select FB_SYS_HELPERS if DRM_FBDEV_EMULATION
select SHMEM
select TMPFS
select QCOM_SCM
diff --git a/drivers/gpu/drm/msm/msm_fbdev.c b/drivers/gpu/drm/msm/msm_fbdev.c
index ce0ba6d1979a..fa9c1cbffae3 100644
--- a/drivers/gpu/drm/msm/msm_fbdev.c
+++ b/drivers/gpu/drm/msm/msm_fbdev.c
@@ -4,6 +4,8 @@
  * Author: Rob Clark 
  */
 
+#include 
+
 #include 
 #include 
 #include 
@@ -23,6 +25,10 @@ module_param(fbdev, bool, 0600);
  * fbdev funcs, to implement legacy fbdev interface on top of drm driver
  */
 
+FB_GEN_DEFAULT_DEFERRED_SYS_OPS(msm_fbdev,
+   drm_fb_helper_damage_range,
+   drm_fb_helper_damage_area)
+
 static int msm_fbdev_mmap(struct fb_info *info, struct vm_area_struct *vma)
 {
struct drm_fb_helper *helper = (struct drm_fb_helper *)info->par;
@@ -52,16 +58,9 @@ static void msm_fbdev_fb_destroy(struct fb_info *info)
 
 static const struct fb_ops msm_fb_ops = {
.owner = THIS_MODULE,
+   __FB_DEFAULT_DEFERRED_OPS_RDWR(msm_fbdev),
DRM_FB_HELPER_DEFAULT_OPS,
-
-   /* Note: to properly handle manual update displays, we wrap the
-* basic fbdev ops which write to the framebuffer
-*/
-   .fb_read = drm_fb_helper_sys_read,
-   .fb_write = drm_fb_helper_sys_write,
-   .fb_fillrect = drm_fb_helper_sys_fillrect,
-   .fb_copyarea = drm_fb_helper_sys_copyarea,
-   .fb_imageblit = drm_fb_helper_sys_imageblit,
+   __FB_DEFAULT_DEFERRED_OPS_DRAW(msm_fbdev),
.fb_mmap = msm_fbdev_mmap,
.fb_destroy = msm_fbdev_fb_destroy,
 };
-- 
2.40.1



[PATCH v4 05/13] drm/gma500: Use regular fbdev I/O helpers

2023-05-24 Thread Thomas Zimmermann
Use the regular fbdev helpers for framebuffer I/O instead of DRM's
helpers. Gma500 does not use damage handling, so DRM's fbdev helpers
are mere wrappers around the fbdev code.

By using fbdev helpers directly within each DRM fbdev emulation,
we can eventually remove DRM's wrapper functions entirely.

v4:
* use initializer macros for struct fb_ops
v2:
* use FB_IO_HELPERS option

Signed-off-by: Thomas Zimmermann 
Cc: Patrik Jakobsson 
---
 drivers/gpu/drm/gma500/Kconfig | 1 +
 drivers/gpu/drm/gma500/fbdev.c | 8 +++-
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/gma500/Kconfig b/drivers/gpu/drm/gma500/Kconfig
index 2efc0eb41c64..cd3d92725ed4 100644
--- a/drivers/gpu/drm/gma500/Kconfig
+++ b/drivers/gpu/drm/gma500/Kconfig
@@ -3,6 +3,7 @@ config DRM_GMA500
tristate "Intel GMA500/600/3600/3650 KMS Framebuffer"
depends on DRM && PCI && X86 && MMU
select DRM_KMS_HELPER
+   select FB_IO_HELPERS if DRM_FBDEV_EMULATION
select I2C
select I2C_ALGOBIT
# GMA500 depends on ACPI_VIDEO when ACPI is enabled, just like i915
diff --git a/drivers/gpu/drm/gma500/fbdev.c b/drivers/gpu/drm/gma500/fbdev.c
index 4f0309548b2b..955cbe9f05a7 100644
--- a/drivers/gpu/drm/gma500/fbdev.c
+++ b/drivers/gpu/drm/gma500/fbdev.c
@@ -5,6 +5,7 @@
  *
  **/
 
+#include 
 #include 
 
 #include 
@@ -134,13 +135,10 @@ static void psb_fbdev_fb_destroy(struct fb_info *info)
 
 static const struct fb_ops psb_fbdev_fb_ops = {
.owner = THIS_MODULE,
+   __FB_DEFAULT_IO_OPS_RDWR,
DRM_FB_HELPER_DEFAULT_OPS,
.fb_setcolreg = psb_fbdev_fb_setcolreg,
-   .fb_read = drm_fb_helper_cfb_read,
-   .fb_write = drm_fb_helper_cfb_write,
-   .fb_fillrect = drm_fb_helper_cfb_fillrect,
-   .fb_copyarea = drm_fb_helper_cfb_copyarea,
-   .fb_imageblit = drm_fb_helper_cfb_imageblit,
+   __FB_DEFAULT_IO_OPS_DRAW,
.fb_mmap = psb_fbdev_fb_mmap,
.fb_destroy = psb_fbdev_fb_destroy,
 };
-- 
2.40.1



[PATCH v4 04/13] drm/exynos: Use regular fbdev I/O helpers

2023-05-24 Thread Thomas Zimmermann
Use the regular fbdev helpers for framebuffer I/O instead of DRM's
helpers. Exynos does not use damage handling, so DRM's fbdev helpers
are mere wrappers around the fbdev code.

By using fbdev helpers directly within each DRM fbdev emulation,
we can eventually remove DRM's wrapper functions entirely.

v4:
* use initializer macros for struct fb_ops
v3:
* don't reorder Makefile rules (Sam)
v2:
* use FB_IO_HELPERS option

Signed-off-by: Thomas Zimmermann 
Cc: Inki Dae 
Cc: Seung-Woo Kim 
Cc: Kyungmin Park 
Cc: Krzysztof Kozlowski 
Cc: Alim Akhtar 
---
 drivers/gpu/drm/exynos/Kconfig| 1 +
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 9 -
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/exynos/Kconfig b/drivers/gpu/drm/exynos/Kconfig
index 0cb92d651ff1..7ca7e1dab52c 100644
--- a/drivers/gpu/drm/exynos/Kconfig
+++ b/drivers/gpu/drm/exynos/Kconfig
@@ -7,6 +7,7 @@ config DRM_EXYNOS
select DRM_DISPLAY_HELPER if DRM_EXYNOS_DP
select DRM_KMS_HELPER
select VIDEOMODE_HELPERS
+   select FB_IO_HELPERS if DRM_FBDEV_EMULATION
select SND_SOC_HDMI_CODEC if SND_SOC
help
  Choose this option if you have a Samsung SoC Exynos chipset.
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c 
b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
index ea4b3d248aac..fdf65587f1fe 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
@@ -8,6 +8,8 @@
  * Seung-Woo Kim 
  */
 
+#include 
+
 #include 
 #include 
 #include 
@@ -47,13 +49,10 @@ static void exynos_drm_fb_destroy(struct fb_info *info)
 
 static const struct fb_ops exynos_drm_fb_ops = {
.owner  = THIS_MODULE,
+   __FB_DEFAULT_IO_OPS_RDWR,
DRM_FB_HELPER_DEFAULT_OPS,
+   __FB_DEFAULT_IO_OPS_DRAW,
.fb_mmap= exynos_drm_fb_mmap,
-   .fb_read= drm_fb_helper_cfb_read,
-   .fb_write   = drm_fb_helper_cfb_write,
-   .fb_fillrect= drm_fb_helper_cfb_fillrect,
-   .fb_copyarea= drm_fb_helper_cfb_copyarea,
-   .fb_imageblit   = drm_fb_helper_cfb_imageblit,
.fb_destroy = exynos_drm_fb_destroy,
 };
 
-- 
2.40.1



[PATCH v4 01/13] fbdev: Add Kconfig options to select different fb_ops helpers

2023-05-24 Thread Thomas Zimmermann
Many fbdev drivers use the same set of fb_ops helpers. Add Kconfig
options to select them at once. This will help with making DRM's
fbdev emulation code more modular, but can also be used to simplify
fbdev's driver configs.

v3:
* fix select statement (Jingfeng)

Signed-off-by: Thomas Zimmermann 
---
 drivers/video/fbdev/Kconfig | 21 +
 1 file changed, 21 insertions(+)

diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
index e8889035c882..6df9bd09454a 100644
--- a/drivers/video/fbdev/Kconfig
+++ b/drivers/video/fbdev/Kconfig
@@ -158,6 +158,27 @@ config FB_DEFERRED_IO
bool
depends on FB
 
+config FB_IO_HELPERS
+   bool
+   depends on FB
+   select FB_CFB_COPYAREA
+   select FB_CFB_FILLRECT
+   select FB_CFB_IMAGEBLIT
+
+config FB_SYS_HELPERS
+   bool
+   depends on FB
+   select FB_SYS_COPYAREA
+   select FB_SYS_FILLRECT
+   select FB_SYS_FOPS
+   select FB_SYS_IMAGEBLIT
+
+config FB_SYS_HELPERS_DEFERRED
+   bool
+   depends on FB
+   select FB_DEFERRED_IO
+   select FB_SYS_HELPERS
+
 config FB_HECUBA
tristate
depends on FB
-- 
2.40.1



RE: [PATCH] drm/amd/pm: Remove unused static functions si_set_temperature_range.

2023-05-24 Thread Chen, Guchun
[Public]

Thanks for your prompt patch for this.

Reviewed-by: Guchun Chen 

Regards,
Guchun

> -Original Message-
> From: Zhang, Yifan 
> Sent: Wednesday, May 24, 2023 5:01 PM
> To: amd-gfx@lists.freedesktop.org
> Cc: Deucher, Alexander ; Chen, Guchun
> ; lizhenn...@kylinos.cn; Zhang, Yifan
> 
> Subject: [PATCH] drm/amd/pm: Remove unused static functions
> si_set_temperature_range.
>
> Fix compiling warnings:
>   CC [M]
> drivers/gpu/drm/amd/amdgpu/../display/dc/dcn20/dcn20_resource.o
>   CC [M]
> drivers/gpu/drm/amd/amdgpu/../display/dc/dcn20/dcn20_hwseq.o
> drivers/gpu/drm/amd/amdgpu/../pm/legacy-dpm/si_dpm.c:6928:12:
> warning: ‘si_set_temperature_range’ defined but not used [-Wunused-
> function]
>  6928 | static int si_set_temperature_range(struct amdgpu_device *adev)
>   |^~~~
>   CC [M]
> drivers/gpu/drm/amd/amdgpu/../display/dc/dcn30/dcn30_hwseq.o
>   CC [M]
> drivers/gpu/drm/amd/amdgpu/../display/dc/dce110/dce110_hw_sequencer
> .o
>   CC [M]
> drivers/gpu/drm/amd/amdgpu/../display/modules/hdcp/hdcp_psp.o
>
> Fixes: da449f3fef3b ("drm/amd/pm: resolve reboot exception for si oland")
> Signed-off-by: Yifan Zhang 
> ---
>  drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 17 -
>  1 file changed, 17 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
> b/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
> index ca9bce895dbe..02e69ccff3ba 100644
> --- a/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
> +++ b/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
> @@ -6925,23 +6925,6 @@ static int si_dpm_enable(struct amdgpu_device
> *adev)
>   return 0;
>  }
>
> -static int si_set_temperature_range(struct amdgpu_device *adev) -{
> - int ret;
> -
> - ret = si_thermal_enable_alert(adev, false);
> - if (ret)
> - return ret;
> - ret = si_thermal_set_temperature_range(adev,
> R600_TEMP_RANGE_MIN, R600_TEMP_RANGE_MAX);
> - if (ret)
> - return ret;
> - ret = si_thermal_enable_alert(adev, true);
> - if (ret)
> - return ret;
> -
> - return ret;
> -}
> -
>  static void si_dpm_disable(struct amdgpu_device *adev)  {
>   struct rv7xx_power_info *pi = rv770_get_pi(adev);
> --
> 2.37.3



[PATCH] drm/amd/pm: Remove unused static functions si_set_temperature_range.

2023-05-24 Thread Yifan Zhang
Fix compiling warnings:
  CC [M]  drivers/gpu/drm/amd/amdgpu/../display/dc/dcn20/dcn20_resource.o
  CC [M]  drivers/gpu/drm/amd/amdgpu/../display/dc/dcn20/dcn20_hwseq.o
drivers/gpu/drm/amd/amdgpu/../pm/legacy-dpm/si_dpm.c:6928:12: warning: 
‘si_set_temperature_range’ defined but not used [-Wunused-function]
 6928 | static int si_set_temperature_range(struct amdgpu_device *adev)
  |^~~~
  CC [M]  drivers/gpu/drm/amd/amdgpu/../display/dc/dcn30/dcn30_hwseq.o
  CC [M]  drivers/gpu/drm/amd/amdgpu/../display/dc/dce110/dce110_hw_sequencer.o
  CC [M]  drivers/gpu/drm/amd/amdgpu/../display/modules/hdcp/hdcp_psp.o

Fixes: da449f3fef3b ("drm/amd/pm: resolve reboot exception for si oland")
Signed-off-by: Yifan Zhang 
---
 drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 17 -
 1 file changed, 17 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c 
b/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
index ca9bce895dbe..02e69ccff3ba 100644
--- a/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
+++ b/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
@@ -6925,23 +6925,6 @@ static int si_dpm_enable(struct amdgpu_device *adev)
return 0;
 }
 
-static int si_set_temperature_range(struct amdgpu_device *adev)
-{
-   int ret;
-
-   ret = si_thermal_enable_alert(adev, false);
-   if (ret)
-   return ret;
-   ret = si_thermal_set_temperature_range(adev, R600_TEMP_RANGE_MIN, 
R600_TEMP_RANGE_MAX);
-   if (ret)
-   return ret;
-   ret = si_thermal_enable_alert(adev, true);
-   if (ret)
-   return ret;
-
-   return ret;
-}
-
 static void si_dpm_disable(struct amdgpu_device *adev)
 {
struct rv7xx_power_info *pi = rv770_get_pi(adev);
-- 
2.37.3



[PATCH] drm/amdgpu: Program gds backup address as zero if no gds allocated

2023-05-24 Thread jiadong.zhu
From: Jiadong Zhu 

It is firmware requirement to set gds_backup_addrlo and gds_backup_addrhi
of DE meta both zero if no gds partition is allocated for the frame.

Signed-off-by: Jiadong Zhu 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
index cbdd9918b3e7..cbcf6126cce5 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
@@ -765,7 +765,7 @@ static void gfx_v9_0_set_rlc_funcs(struct amdgpu_device 
*adev);
 static int gfx_v9_0_get_cu_info(struct amdgpu_device *adev,
struct amdgpu_cu_info *cu_info);
 static uint64_t gfx_v9_0_get_gpu_clock_counter(struct amdgpu_device *adev);
-static void gfx_v9_0_ring_emit_de_meta(struct amdgpu_ring *ring, bool resume);
+static void gfx_v9_0_ring_emit_de_meta(struct amdgpu_ring *ring, bool resume, 
bool usegds);
 static u64 gfx_v9_0_ring_get_rptr_compute(struct amdgpu_ring *ring);
 static void gfx_v9_0_query_ras_error_count(struct amdgpu_device *adev,
  void *ras_error_status);
@@ -5160,7 +5160,8 @@ static void gfx_v9_0_ring_emit_ib_gfx(struct amdgpu_ring 
*ring,
gfx_v9_0_ring_emit_de_meta(ring,
   
(!amdgpu_sriov_vf(ring->adev) &&
   flags & AMDGPU_IB_PREEMPTED) 
?
-  true : false);
+  true : false,
+  job->gds_size > 0 && 
job->gds_base != 0);
}
 
amdgpu_ring_write(ring, header);
@@ -5435,7 +5436,7 @@ static int gfx_v9_0_ring_preempt_ib(struct amdgpu_ring 
*ring)
return r;
 }
 
-static void gfx_v9_0_ring_emit_de_meta(struct amdgpu_ring *ring, bool resume)
+static void gfx_v9_0_ring_emit_de_meta(struct amdgpu_ring *ring, bool resume, 
bool usegds)
 {
struct amdgpu_device *adev = ring->adev;
struct v9_de_ib_state de_payload = {0};
@@ -5466,8 +5467,10 @@ static void gfx_v9_0_ring_emit_de_meta(struct 
amdgpu_ring *ring, bool resume)
 PAGE_SIZE);
}
 
-   de_payload.gds_backup_addrlo = lower_32_bits(gds_addr);
-   de_payload.gds_backup_addrhi = upper_32_bits(gds_addr);
+   if (usegds) {
+   de_payload.gds_backup_addrlo = lower_32_bits(gds_addr);
+   de_payload.gds_backup_addrhi = upper_32_bits(gds_addr);
+   }
 
cnt = (sizeof(de_payload) >> 2) + 4 - 2;
amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, cnt));
-- 
2.25.1



RE: [PATCH v2 4/6] drm/amdgpu: Use single copy per SDMA instance type (v2)

2023-05-24 Thread Zhang, Hawking
[AMD Official Use Only - General]

Reviewed-by: Hawking Zhang 

Regards,
Hawking
-Original Message-
From: amd-gfx  On Behalf Of Shiwu Zhang
Sent: Thursday, May 18, 2023 20:21
To: amd-gfx@lists.freedesktop.org
Subject: [PATCH v2 4/6] drm/amdgpu: Use single copy per SDMA instance type (v2)

From: Lijo Lazar 

v1: Only single copy per instance type is required for PSP. All instance types 
use the same firmware copy. (Lijo)

v2: Apply the change into amdgpu_sdma_init_microcode() due to rebase. (Morris)

Signed-off-by: Lijo Lazar 
Reviewed-by: Hawking Zhang 
Signed-off-by: Shiwu Zhang 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c
index 231ca06bc9c7..1797b45d0b55 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c
@@ -252,6 +252,13 @@ int amdgpu_sdma_init_microcode(struct amdgpu_device *adev,
if (!duplicate && (instance != i))
continue;
else {
+   /* Use a single copy per SDMA firmware 
type. PSP uses the same instance for all
+* groups of SDMAs */
+   if (adev->ip_versions[SDMA0_HWIP][0] == 
IP_VERSION(4, 4, 2) &&
+   adev->firmware.load_type == 
AMDGPU_FW_LOAD_PSP &&
+   adev->sdma.num_inst_per_aid == i) {
+   break;
+   }
info = 
>firmware.ucode[AMDGPU_UCODE_ID_SDMA0 + i];
info->ucode_id = AMDGPU_UCODE_ID_SDMA0 
+ i;
info->fw = adev->sdma.instance[i].fw;
--
2.17.1


RE: [PATCH v2 6/6] drm/amdgpu: complement the 4, 6 and 8 XCC cases

2023-05-24 Thread Zhang, Hawking
[AMD Official Use Only - General]

Reviewed-by: Hawking Zhang 

Regards,
Hawking
-Original Message-
From: amd-gfx  On Behalf Of Shiwu Zhang
Sent: Thursday, May 18, 2023 20:21
To: amd-gfx@lists.freedesktop.org
Subject: [PATCH v2 6/6] drm/amdgpu: complement the 4, 6 and 8 XCC cases

Signed-off-by: Shiwu Zhang 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
index e5cfb3adb3b3..97f6f854d077 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
@@ -1031,6 +1031,9 @@ static void gfx_v9_4_3_xcc_program_xcc_id(struct 
amdgpu_device *adev,
WREG32_SOC15(GC, GET_INST(GC, xcc_id), regCP_HYP_XCP_CTL, 0x8);
break;
case 2:
+   case 4:
+   case 6:
+   case 8:
tmp = (xcc_id % adev->gfx.num_xcc_per_xcp) << 
REG_FIELD_SHIFT(CP_HYP_XCP_CTL, VIRTUAL_XCC_ID);
tmp = tmp | (adev->gfx.num_xcc_per_xcp << 
REG_FIELD_SHIFT(CP_HYP_XCP_CTL, NUM_XCC_IN_XCP));
WREG32_SOC15(GC, GET_INST(GC, xcc_id), regCP_HYP_XCP_CTL, tmp);
-- 
2.17.1


RE: [PATCH v4] drm/amdgpu: resove reboot exception for si oland

2023-05-24 Thread Chen, Guchun
[Public]

Applied by modifying the subject a bit to " drm/amd/pm: resolve reboot 
exception for si oland". Thanks.

Regards,
Guchun

> -Original Message-
> From: Zhenneng Li 
> Sent: Wednesday, May 24, 2023 2:00 PM
> To: Chen, Guchun 
> Cc: Deucher, Alexander ; Koenig, Christian
> ; Pan, Xinhui ; David
> Airlie ; Daniel Vetter ; amd-
> g...@lists.freedesktop.org; Zhenneng Li 
> Subject: [PATCH v4] drm/amdgpu: resove reboot exception for si oland
>
> During reboot test on arm64 platform, it may failure on boot.
>
> The error message are as follows:
> [1.706570][ 3] [  T273] [drm:si_thermal_enable_alert [amdgpu]] *ERROR*
> Could not enable thermal interrupts.
> [1.716547][ 3] [  T273] [drm:amdgpu_device_ip_late_init [amdgpu]]
> *ERROR* late_init of IP block  failed -22
> [1.727064][ 3] [  T273] amdgpu :02:00.0: amdgpu_device_ip_late_init
> failed
> [1.734367][ 3] [  T273] amdgpu :02:00.0: Fatal error during GPU init
>
> Signed-off-by: Zhenneng Li 
> ---
>  drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 12 
>  1 file changed, 12 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
> b/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
> index d6d9e3b1b2c0..ca9bce895dbe 100644
> --- a/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
> +++ b/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
> @@ -7626,18 +7626,6 @@ static int si_dpm_process_interrupt(struct
> amdgpu_device *adev,
>
>  static int si_dpm_late_init(void *handle)  {
> - int ret;
> - struct amdgpu_device *adev = (struct amdgpu_device *)handle;
> -
> - if (!adev->pm.dpm_enabled)
> - return 0;
> -
> - ret = si_set_temperature_range(adev);
> - if (ret)
> - return ret;
> -#if 0 //TODO ?
> - si_dpm_powergate_uvd(adev, true);
> -#endif
>   return 0;
>  }
>
> --
> 2.25.1
>
>
> No virus found
>   Checked by Hillstone Network AntiVirus