drivers/gpu/drm/amd/amdgpu/amdgpu_device.c                |   28 --
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c               |  184 +++++++++++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c                   |    3 
 drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c                   |   19 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c                    |    6 
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h                    |    1 
 drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c                     |   13 
 drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c                     |    4 
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c         |   68 +++++
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c |    2 
 drivers/gpu/drm/amd/pm/amdgpu_pm.c                        |   10 
 drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c           |    5 
 drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c   |    4 
 drivers/gpu/drm/i915/gvt/handlers.c                       |    6 
 drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c                  |   10 
 drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c                 |   16 -
 drivers/gpu/drm/msm/disp/dpu1/dpu_plane.h                 |    6 
 drivers/gpu/drm/radeon/radeon_atombios.c                  |   26 +
 drivers/video/fbdev/core/fbmem.c                          |    2 
 19 files changed, 332 insertions(+), 81 deletions(-)

New commits:
commit 1a17b6532d4f06cf48b4eca656eb8f7be5e6ba8e
Merge: c3588b84799e 0844708ac3d2
Author: Kevin Brace <kevinbr...@gmx.com>
Date:   Fri May 14 20:41:29 2021 -0700

    Merge tag 'drm-next-2021-05-10' of git://anongit.freedesktop.org/drm/drm 
into drm-next-5.13
    
    drm fixes for 5.13-rc1
    
    amdgpu:
    - MPO hang workaround
    - Fix for concurrent VM flushes on vega/navi
    - dcefclk is not adjustable on navi1x and newer
    - MST HPD debugfs fix
    - Suspend/resumes fixes
    - Register VGA clients late in case driver fails to load
    - Fix GEM leak in user framebuffer create
    - Add support for polaris12 with 32 bit memory interface
    - Fix duplicate cursor issue when using overlay
    - Fix corruption with tiled surfaces on VCN3
    - Add BO size and stride check to fix BO size verification
    
    radeon:
    - Fix off-by-one in power state parsing
    - Fix possible memory leak in power state parsing
    
    msm:
    - NULL ptr dereference fix
    
    fbdev:
    - procfs disabled warning fix
    
    i915:
    - gvt: Fix a possible division by zero in vgpu display rate calculation

commit 0844708ac3d2dbdace70f4a6020669d56958697f
Merge: 59e528c5bc58 234055fd9728
Author: Dave Airlie <airl...@redhat.com>
Date:   Fri May 7 12:44:50 2021 +1000

    Merge tag 'amd-drm-fixes-5.13-2021-05-05' of 
https://gitlab.freedesktop.org/agd5f/linux into drm-next
    
    amd-drm-fixes-5.13-2021-05-05:
    
    amdgpu:
    - MPO hang workaround
    - Fix for concurrent VM flushes on vega/navi
    - dcefclk is not adjustable on navi1x and newer
    - MST HPD debugfs fix
    - Suspend/resumes fixes
    - Register VGA clients late in case driver fails to load
    - Fix GEM leak in user framebuffer create
    - Add support for polaris12 with 32 bit memory interface
    - Fix duplicate cursor issue when using overlay
    - Fix corruption with tiled surfaces on VCN3
    - Add BO size and stride check to fix BO size verification
    
    radeon:
    - Fix off-by-one in power state parsing
    - Fix possible memory leak in power state parsing
    
    Signed-off-by: Dave Airlie <airl...@redhat.com>
    From: Alex Deucher <alexander.deuc...@amd.com>
    Link: 
https://patchwork.freedesktop.org/patch/msgid/20210506033929.3875-1-alexander.deuc...@amd.com

diff --cc drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index 2e622c1675d7,dab98a1fdcaa..8a1fb8b6606e
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@@ -902,25 -1070,10 +1070,23 @@@ int amdgpu_display_gem_fb_verify_and_in
        int ret;
  
        rfb->base.obj[0] = obj;
- 
-       /* Verify that bo size can fit the fb size. */
-       ret = drm_gem_fb_init_with_funcs(dev, &rfb->base, file_priv, mode_cmd,
-                                        &amdgpu_fb_funcs);
+       drm_helper_mode_fill_fb_struct(dev, &rfb->base, mode_cmd);
+       ret = drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs);
        if (ret)
                goto err;
 +      /* Verify that the modifier is supported. */
 +      if (!drm_any_plane_has_format(dev, mode_cmd->pixel_format,
 +                                    mode_cmd->modifier[0])) {
 +              struct drm_format_name_buf format_name;
 +              drm_dbg_kms(dev,
 +                          "unsupported pixel format %s / modifier 0x%llx\n",
 +                          drm_get_format_name(mode_cmd->pixel_format,
 +                                              &format_name),
 +                          mode_cmd->modifier[0]);
 +
 +              ret = -EINVAL;
 +              goto err;
 +      }
  
        ret = amdgpu_display_framebuffer_init(dev, rfb, mode_cmd, obj);
        if (ret)
commit 59e528c5bc58db8426c3f15439d798dc3aca725e
Merge: 365002da3c46 b9d79e4ca4ff
Author: Dave Airlie <airl...@redhat.com>
Date:   Fri May 7 12:37:37 2021 +1000

    Merge tag 'drm-misc-next-fixes-2021-05-06' of 
git://anongit.freedesktop.org/drm/drm-misc into drm-next
    
    Two patches, one to fix a null pointer dereference in msm, and one to
    fix an unused warning for in fbdev when PROCFS is disabled.
    
    Signed-off-by: Dave Airlie <airl...@redhat.com>
    
    # gpg: Signature made Thu 06 May 2021 22:26:35 AEST
    # gpg:                using ? key E3EF0D6F671851C5
    # gpg: Can't check signature: unknown pubkey algorithm
    From: Maxime Ripard <max...@cerno.tech>
    Link: 
https://patchwork.freedesktop.org/patch/msgid/20210506122723.oqadel7oacazywij@gilmour

commit 365002da3c46333dcd4c0ef72d3b570d1af8b25c
Merge: 1cd6b4a04f03 c7b397e9ca4d
Author: Dave Airlie <airl...@redhat.com>
Date:   Fri May 7 11:55:43 2021 +1000

    Merge tag 'drm-intel-next-fixes-2021-04-30' of 
git://anongit.freedesktop.org/drm/drm-intel into drm-next
    
    drm/i915 GVT fixes for v5.13-rc1:
    - Fix a possible division by zero in vgpu display rate calculation
    
    Signed-off-by: Dave Airlie <airl...@redhat.com>
    From: Jani Nikula <jani.nik...@intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/87wnsk16sa....@intel.com

commit 234055fd9728e6726787bc63b24b6450034876cf
Author: Bas Nieuwenhuizen <b...@basnieuwenhuizen.nl>
Date:   Tue May 4 11:43:34 2021 +0200

    drm/amdgpu: Use device specific BO size & stride check.
    
    The builtin size check isn't really the right thing for AMD
    modifiers due to a couple of reasons:
    
    1) In the format structs we don't do set any of the tilesize / blocks
    etc. to avoid having format arrays per modifier/GPU
    2) The pitch on the main plane is pixel_pitch * bytes_per_pixel even
    for tiled ...
    3) The pitch for the DCC planes is really the pixel pitch of the main
    surface that would be covered by it ...
    
    Note that we only handle GFX9+ case but we do this after converting
    the implicit modifier to an explicit modifier, so on GFX9+ all
    framebuffers should be checked here.
    
    There is a TODO about DCC alignment, but it isn't worse than before
    and I'd need to dig a bunch into the specifics. Getting this out in
    a reasonable timeframe to make sure it gets the appropriate testing
    seemed more important.
    
    Finally as I've found that debugging addfb2 failures is a pita I was
    generous adding explicit error messages to every failure case.
    
    Fixes: f258907fdd83 ("drm/amdgpu: Verify bo size can fit framebuffer size 
on init.")
    Tested-by: Simon Ser <cont...@emersion.fr>
    Signed-off-by: Bas Nieuwenhuizen <b...@basnieuwenhuizen.nl>
    Signed-off-by: Alex Deucher <alexander.deuc...@amd.com>

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index c4cfefb33e03..dab98a1fdcaa 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -837,6 +837,174 @@ static int convert_tiling_flags_to_modifier(struct 
amdgpu_framebuffer *afb)
        return 0;
 }
 
+static void get_block_dimensions(unsigned int block_log2, unsigned int cpp,
+                                unsigned int *width, unsigned int *height)
+{
+       unsigned int cpp_log2 = ilog2(cpp);
+       unsigned int pixel_log2 = block_log2 - cpp_log2;
+       unsigned int width_log2 = (pixel_log2 + 1) / 2;
+       unsigned int height_log2 = pixel_log2 - width_log2;
+
+       *width = 1 << width_log2;
+       *height = 1 << height_log2;
+}
+
+static unsigned int get_dcc_block_size(uint64_t modifier, bool rb_aligned,
+                                      bool pipe_aligned)
+{
+       unsigned int ver = AMD_FMT_MOD_GET(TILE_VERSION, modifier);
+
+       switch (ver) {
+       case AMD_FMT_MOD_TILE_VER_GFX9: {
+               /*
+                * TODO: for pipe aligned we may need to check the alignment of 
the
+                * total size of the surface, which may need to be bigger than 
the
+                * natural alignment due to some HW workarounds
+                */
+               return max(10 + (rb_aligned ? (int)AMD_FMT_MOD_GET(RB, 
modifier) : 0), 12);
+       }
+       case AMD_FMT_MOD_TILE_VER_GFX10:
+       case AMD_FMT_MOD_TILE_VER_GFX10_RBPLUS: {
+               int pipes_log2 = AMD_FMT_MOD_GET(PIPE_XOR_BITS, modifier);
+
+               if (ver == AMD_FMT_MOD_TILE_VER_GFX10_RBPLUS && pipes_log2 > 1 
&&
+                   AMD_FMT_MOD_GET(PACKERS, modifier) == pipes_log2)
+                       ++pipes_log2;
+
+               return max(8 + (pipe_aligned ? pipes_log2 : 0), 12);
+       }
+       default:
+               return 0;
+       }
+}
+
+static int amdgpu_display_verify_plane(struct amdgpu_framebuffer *rfb, int 
plane,
+                                      const struct drm_format_info *format,
+                                      unsigned int block_width, unsigned int 
block_height,
+                                      unsigned int block_size_log2)
+{
+       unsigned int width = rfb->base.width /
+               ((plane && plane < format->num_planes) ? format->hsub : 1);
+       unsigned int height = rfb->base.height /
+               ((plane && plane < format->num_planes) ? format->vsub : 1);
+       unsigned int cpp = plane < format->num_planes ? format->cpp[plane] : 1;
+       unsigned int block_pitch = block_width * cpp;
+       unsigned int min_pitch = ALIGN(width * cpp, block_pitch);
+       unsigned int block_size = 1 << block_size_log2;
+       uint64_t size;
+
+       if (rfb->base.pitches[plane] % block_pitch) {
+               drm_dbg_kms(rfb->base.dev,
+                           "pitch %d for plane %d is not a multiple of block 
pitch %d\n",
+                           rfb->base.pitches[plane], plane, block_pitch);
+               return -EINVAL;
+       }
+       if (rfb->base.pitches[plane] < min_pitch) {
+               drm_dbg_kms(rfb->base.dev,
+                           "pitch %d for plane %d is less than minimum pitch 
%d\n",
+                           rfb->base.pitches[plane], plane, min_pitch);
+               return -EINVAL;
+       }
+
+       /* Force at least natural alignment. */
+       if (rfb->base.offsets[plane] % block_size) {
+               drm_dbg_kms(rfb->base.dev,
+                           "offset 0x%x for plane %d is not a multiple of 
block pitch 0x%x\n",
+                           rfb->base.offsets[plane], plane, block_size);
+               return -EINVAL;
+       }
+
+       size = rfb->base.offsets[plane] +
+               (uint64_t)rfb->base.pitches[plane] / block_pitch *
+               block_size * DIV_ROUND_UP(height, block_height);
+
+       if (rfb->base.obj[0]->size < size) {
+               drm_dbg_kms(rfb->base.dev,
+                           "BO size 0x%zx is less than 0x%llx required for 
plane %d\n",
+                           rfb->base.obj[0]->size, size, plane);
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+
+static int amdgpu_display_verify_sizes(struct amdgpu_framebuffer *rfb)
+{
+       const struct drm_format_info *format_info = 
drm_format_info(rfb->base.format->format);
+       uint64_t modifier = rfb->base.modifier;
+       int ret;
+       unsigned int i, block_width, block_height, block_size_log2;
+
+       if (!rfb->base.dev->mode_config.allow_fb_modifiers)
+               return 0;
+
+       for (i = 0; i < format_info->num_planes; ++i) {
+               if (modifier == DRM_FORMAT_MOD_LINEAR) {
+                       block_width = 256 / format_info->cpp[i];
+                       block_height = 1;
+                       block_size_log2 = 8;
+               } else {
+                       int swizzle = AMD_FMT_MOD_GET(TILE, modifier);
+
+                       switch ((swizzle & ~3) + 1) {
+                       case DC_SW_256B_S:
+                               block_size_log2 = 8;
+                               break;
+                       case DC_SW_4KB_S:
+                       case DC_SW_4KB_S_X:
+                               block_size_log2 = 12;
+                               break;
+                       case DC_SW_64KB_S:
+                       case DC_SW_64KB_S_T:
+                       case DC_SW_64KB_S_X:
+                               block_size_log2 = 16;
+                               break;
+                       default:
+                               drm_dbg_kms(rfb->base.dev,
+                                           "Swizzle mode with unknown block 
size: %d\n", swizzle);
+                               return -EINVAL;
+                       }
+
+                       get_block_dimensions(block_size_log2, 
format_info->cpp[i],
+                                            &block_width, &block_height);
+               }
+
+               ret = amdgpu_display_verify_plane(rfb, i, format_info,
+                                                 block_width, block_height, 
block_size_log2);
+               if (ret)
+                       return ret;
+       }
+
+       if (AMD_FMT_MOD_GET(DCC, modifier)) {
+               if (AMD_FMT_MOD_GET(DCC_RETILE, modifier)) {
+                       block_size_log2 = get_dcc_block_size(modifier, false, 
false);
+                       get_block_dimensions(block_size_log2 + 8, 
format_info->cpp[0],
+                                            &block_width, &block_height);
+                       ret = amdgpu_display_verify_plane(rfb, i, format_info,
+                                                         block_width, 
block_height,
+                                                         block_size_log2);
+                       if (ret)
+                               return ret;
+
+                       ++i;
+                       block_size_log2 = get_dcc_block_size(modifier, true, 
true);
+               } else {
+                       bool pipe_aligned = AMD_FMT_MOD_GET(DCC_PIPE_ALIGN, 
modifier);
+
+                       block_size_log2 = get_dcc_block_size(modifier, true, 
pipe_aligned);
+               }
+               get_block_dimensions(block_size_log2 + 8, format_info->cpp[0],
+                                    &block_width, &block_height);
+               ret = amdgpu_display_verify_plane(rfb, i, format_info,
+                                                 block_width, block_height, 
block_size_log2);
+               if (ret)
+                       return ret;
+       }
+
+       return 0;
+}
+
 static int amdgpu_display_get_fb_info(const struct amdgpu_framebuffer 
*amdgpu_fb,
                                      uint64_t *tiling_flags, bool *tmz_surface)
 {
@@ -902,10 +1070,8 @@ int amdgpu_display_gem_fb_verify_and_init(
        int ret;
 
        rfb->base.obj[0] = obj;
-
-       /* Verify that bo size can fit the fb size. */
-       ret = drm_gem_fb_init_with_funcs(dev, &rfb->base, file_priv, mode_cmd,
-                                        &amdgpu_fb_funcs);
+       drm_helper_mode_fill_fb_struct(dev, &rfb->base, mode_cmd);
+       ret = drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs);
        if (ret)
                goto err;
 
@@ -954,9 +1120,12 @@ int amdgpu_display_framebuffer_init(struct drm_device 
*dev,
                }
        }
 
-       for (i = 1; i < rfb->base.format->num_planes; ++i) {
+       ret = amdgpu_display_verify_sizes(rfb);
+       if (ret)
+               return ret;
+
+       for (i = 0; i < rfb->base.format->num_planes; ++i) {
                drm_gem_object_get(rfb->base.obj[0]);
-               drm_gem_object_put(rfb->base.obj[i]);
                rfb->base.obj[i] = rfb->base.obj[0];
        }
 
commit 8bf073ca9235fe38d7b74a0b4e779cfa7cc70fc9
Author: Bas Nieuwenhuizen <b...@basnieuwenhuizen.nl>
Date:   Wed May 5 03:27:49 2021 +0200

    drm/amdgpu: Init GFX10_ADDR_CONFIG for VCN v3 in DPG mode.
    
    Otherwise tiling modes that require the values form this field
    (In particular _*_X) would be corrupted upon video decode.
    
    Copied from the VCN v2 code.
    
    Fixes: 99541f392b4d ("drm/amdgpu: add mc resume DPG mode for VCN3.0")
    Reviewed-and-Tested by: Leo Liu <leo....@amd.com>
    Signed-off-by: Bas Nieuwenhuizen <b...@basnieuwenhuizen.nl>
    Signed-off-by: Alex Deucher <alexander.deuc...@amd.com>
    Cc: sta...@vger.kernel.org

diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c 
b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
index 3f15bf34123a..cf165ab5dd26 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
@@ -589,6 +589,10 @@ static void vcn_v3_0_mc_resume_dpg_mode(struct 
amdgpu_device *adev, int inst_idx
        WREG32_SOC15_DPG_MODE(inst_idx, SOC15_DPG_MODE_OFFSET(
                        VCN, inst_idx, mmUVD_VCPU_NONCACHE_SIZE0),
                        AMDGPU_GPU_PAGE_ALIGN(sizeof(struct amdgpu_fw_shared)), 
0, indirect);
+
+       /* VCN global tiling registers */
+       WREG32_SOC15_DPG_MODE(0, SOC15_DPG_MODE_OFFSET(
+               UVD, 0, mmUVD_GFX10_ADDR_CONFIG), 
adev->gfx.config.gb_addr_config, 0, indirect);
 }
 
 static void vcn_v3_0_disable_static_power_gating(struct amdgpu_device *adev, 
int inst)
commit 8651fcb9873be097bb6fe8542bfb6089020726ae
Author: Tom Rix <t...@redhat.com>
Date:   Fri Apr 30 10:16:54 2021 -0700

    drm/amd/pm: initialize variable
    
    Static analysis reports this problem
    
    amdgpu_pm.c:478:16: warning: The right operand of '<' is a garbage value
      for (i = 0; i < data.nums; i++) {
                    ^ ~~~~~~~~~
    
    In some cases data is not set.  Initialize to 0 and flag not setting
    data as an error with the existing check.
    
    Signed-off-by: Tom Rix <t...@redhat.com>
    Signed-off-by: Alex Deucher <alexander.deuc...@amd.com>

diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c 
b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
index a8d6cc2525b2..e2ea42b1b4f0 100644
--- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
@@ -451,7 +451,7 @@ static ssize_t amdgpu_get_pp_cur_state(struct device *dev,
        struct drm_device *ddev = dev_get_drvdata(dev);
        struct amdgpu_device *adev = drm_to_adev(ddev);
        const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
-       struct pp_states_info data;
+       struct pp_states_info data = {0};
        enum amd_pm_state_type pm = 0;
        int i = 0, ret = 0;
 
commit c69f27137a38d24301a6b659454a91ad85dff4aa
Author: Kees Cook <keesc...@chromium.org>
Date:   Sun May 2 22:06:08 2021 -0700

    drm/radeon: Avoid power table parsing memory leaks
    
    Avoid leaving a hanging pre-allocated clock_info if last mode is
    invalid, and avoid heap corruption if no valid modes are found.
    
    Bug: https://bugzilla.kernel.org/show_bug.cgi?id=211537
    Fixes: 6991b8f2a319 ("drm/radeon/kms: fix segfault in pm rework")
    Signed-off-by: Kees Cook <keesc...@chromium.org>
    Signed-off-by: Alex Deucher <alexander.deuc...@amd.com>

diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c 
b/drivers/gpu/drm/radeon/radeon_atombios.c
index f9f4efa1738c..28c4413f4dc8 100644
--- a/drivers/gpu/drm/radeon/radeon_atombios.c
+++ b/drivers/gpu/drm/radeon/radeon_atombios.c
@@ -2120,11 +2120,14 @@ static int radeon_atombios_parse_power_table_1_3(struct 
radeon_device *rdev)
                return state_index;
        /* last mode is usually default, array is low to high */
        for (i = 0; i < num_modes; i++) {
-               rdev->pm.power_state[state_index].clock_info =
-                       kcalloc(1, sizeof(struct radeon_pm_clock_info),
-                               GFP_KERNEL);
+               /* avoid memory leaks from invalid modes or unknown frev. */
+               if (!rdev->pm.power_state[state_index].clock_info) {
+                       rdev->pm.power_state[state_index].clock_info =
+                               kzalloc(sizeof(struct radeon_pm_clock_info),
+                                       GFP_KERNEL);
+               }
                if (!rdev->pm.power_state[state_index].clock_info)
-                       return state_index;
+                       goto out;
                rdev->pm.power_state[state_index].num_clock_modes = 1;
                rdev->pm.power_state[state_index].clock_info[0].voltage.type = 
VOLTAGE_NONE;
                switch (frev) {
@@ -2243,8 +2246,15 @@ static int radeon_atombios_parse_power_table_1_3(struct 
radeon_device *rdev)
                        break;
                }
        }
+out:
+       /* free any unused clock_info allocation. */
+       if (state_index && state_index < num_modes) {
+               kfree(rdev->pm.power_state[state_index].clock_info);
+               rdev->pm.power_state[state_index].clock_info = NULL;
+       }
+
        /* last mode is usually default */
-       if (rdev->pm.default_power_state_index == -1) {
+       if (state_index && rdev->pm.default_power_state_index == -1) {
                rdev->pm.power_state[state_index - 1].type =
                        POWER_STATE_TYPE_DEFAULT;
                rdev->pm.default_power_state_index = state_index - 1;
commit 5bbf219328849e83878bddb7c226d8d42e84affc
Author: Kees Cook <keesc...@chromium.org>
Date:   Sun May 2 22:06:07 2021 -0700

    drm/radeon: Fix off-by-one power_state index heap overwrite
    
    An out of bounds write happens when setting the default power state.
    KASAN sees this as:
    
    [drm] radeon: 512M of GTT memory ready.
    [drm] GART: num cpu pages 131072, num gpu pages 131072
    ==================================================================
    BUG: KASAN: slab-out-of-bounds in
    radeon_atombios_parse_power_table_1_3+0x1837/0x1998 [radeon]
    Write of size 4 at addr ffff88810178d858 by task systemd-udevd/157
    
    CPU: 0 PID: 157 Comm: systemd-udevd Not tainted 5.12.0-E620 #50
    Hardware name: eMachines        eMachines E620  /Nile       , BIOS V1.03 
09/30/2008
    Call Trace:
     dump_stack+0xa5/0xe6
     print_address_description.constprop.0+0x18/0x239
     kasan_report+0x170/0x1a8
     radeon_atombios_parse_power_table_1_3+0x1837/0x1998 [radeon]
     radeon_atombios_get_power_modes+0x144/0x1888 [radeon]
     radeon_pm_init+0x1019/0x1904 [radeon]
     rs690_init+0x76e/0x84a [radeon]
     radeon_device_init+0x1c1a/0x21e5 [radeon]
     radeon_driver_load_kms+0xf5/0x30b [radeon]
     drm_dev_register+0x255/0x4a0 [drm]
     radeon_pci_probe+0x246/0x2f6 [radeon]
     pci_device_probe+0x1aa/0x294
     really_probe+0x30e/0x850
     driver_probe_device+0xe6/0x135
     device_driver_attach+0xc1/0xf8
     __driver_attach+0x13f/0x146
     bus_for_each_dev+0xfa/0x146
     bus_add_driver+0x2b3/0x447
     driver_register+0x242/0x2c1
     do_one_initcall+0x149/0x2fd
     do_init_module+0x1ae/0x573
     load_module+0x4dee/0x5cca
     __do_sys_finit_module+0xf1/0x140
     do_syscall_64+0x33/0x40
     entry_SYSCALL_64_after_hwframe+0x44/0xae
    
    Without KASAN, this will manifest later when the kernel attempts to
    allocate memory that was stomped, since it collides with the inline slab
    freelist pointer:
    
    invalid opcode: 0000 [#1] SMP NOPTI
    CPU: 0 PID: 781 Comm: openrc-run.sh Tainted: G        W 5.10.12-gentoo-E620 
#2
    Hardware name: eMachines        eMachines E620  /Nile , BIOS V1.03       
09/30/2008
    RIP: 0010:kfree+0x115/0x230
    Code: 89 c5 e8 75 ea ff ff 48 8b 00 0f ba e0 09 72 63 e8 1f f4 ff ff 41 89 
c4 48 8b 45 00 0f ba e0 10 72 0a 48 8b 45 08 a8 01 75 02 <0f> 0b 44 89 e1 48 c7 
c2 00 f0 ff ff be 06 00 00 00 48 d3 e2 48 c7
    RSP: 0018:ffffb42f40267e10 EFLAGS: 00010246
    RAX: ffffd61280ee8d88 RBX: 0000000000000004 RCX: 000000008010000d
    RDX: 4000000000000000 RSI: ffffffffba1360b0 RDI: ffffd61280ee8d80
    RBP: ffffd61280ee8d80 R08: ffffffffb91bebdf R09: 0000000000000000
    R10: ffff8fe2c1047ac8 R11: 0000000000000000 R12: 0000000000000000
    R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000100
    FS:  00007fe80eff6b68(0000) GS:ffff8fe339c00000(0000) knlGS:0000000000000000
    CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 00007fe80eec7bc0 CR3: 0000000038012000 CR4: 00000000000006f0
    Call Trace:
     __free_fdtable+0x16/0x1f
     put_files_struct+0x81/0x9b
     do_exit+0x433/0x94d
     do_group_exit+0xa6/0xa6
     __x64_sys_exit_group+0xf/0xf
     do_syscall_64+0x33/0x40
     entry_SYSCALL_64_after_hwframe+0x44/0xa9
    RIP: 0033:0x7fe80ef64bea
    Code: Unable to access opcode bytes at RIP 0x7fe80ef64bc0.
    RSP: 002b:00007ffdb1c47528 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
    RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007fe80ef64bea
    RDX: 00007fe80ef64f60 RSI: 0000000000000000 RDI: 0000000000000000
    RBP: 0000000000000000 R08: 0000000000000001 R09: 0000000000000000
    R10: 00007fe80ee2c620 R11: 0000000000000246 R12: 00007fe80eff41e0
    R13: 00000000ffffffff R14: 0000000000000024 R15: 00007fe80edf9cd0
    Modules linked in: radeon(+) ath5k(+) snd_hda_codec_realtek ...
    
    Use a valid power_state index when initializing the "flags" and "misc"
    and "misc2" fields.
    
    Bug: https://bugzilla.kernel.org/show_bug.cgi?id=211537
    Reported-by: Erhard F. <erhar...@mailbox.org>
    Fixes: a48b9b4edb8b ("drm/radeon/kms/pm: add asic specific callbacks for 
getting power state (v2)")
    Fixes: 79daedc94281 ("drm/radeon/kms: minor pm cleanups")
    Signed-off-by: Kees Cook <keesc...@chromium.org>
    Signed-off-by: Alex Deucher <alexander.deuc...@amd.com>

diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c 
b/drivers/gpu/drm/radeon/radeon_atombios.c
index 42301b4e56f5..f9f4efa1738c 100644
--- a/drivers/gpu/drm/radeon/radeon_atombios.c
+++ b/drivers/gpu/drm/radeon/radeon_atombios.c
@@ -2250,10 +2250,10 @@ static int radeon_atombios_parse_power_table_1_3(struct 
radeon_device *rdev)
                rdev->pm.default_power_state_index = state_index - 1;
                rdev->pm.power_state[state_index - 1].default_clock_mode =
                        &rdev->pm.power_state[state_index - 1].clock_info[0];
-               rdev->pm.power_state[state_index].flags &=
+               rdev->pm.power_state[state_index - 1].flags &=
                        ~RADEON_PM_STATE_SINGLE_DISPLAY_ONLY;
-               rdev->pm.power_state[state_index].misc = 0;
-               rdev->pm.power_state[state_index].misc2 = 0;
+               rdev->pm.power_state[state_index - 1].misc = 0;
+               rdev->pm.power_state[state_index - 1].misc2 = 0;
        }
        return state_index;
 }
commit 16e9b3e58bc3fce7391539e0eb3fd167cbf9951f
Author: Rodrigo Siqueira <rodrigo.sique...@amd.com>
Date:   Tue Apr 13 20:06:04 2021 -0400

    drm/amd/display: Fix two cursor duplication when using overlay
    
    Our driver supports overlay planes, and as expected, some userspace
    compositor takes advantage of these features. If the userspace is not
    enabling the cursor, they can use multiple planes as they please.
    Nevertheless, we start to have constraints when userspace tries to
    enable hardware cursor with various planes. Basically, we cannot draw
    the cursor at the same size and position on two separated pipes since it
    uses extra bandwidth and DML only run with one cursor.
    
    For those reasons, when we enable hardware cursor and multiple planes,
    our driver should accept variations like the ones described below:
    
      +-------------+   +--------------+
      | +---------+ |   |              |
      | |Primary  | |   | Primary      |
      | |         | |   | Overlay      |
      | +---------+ |   |              |
      |Overlay      |   |              |
      +-------------+   +--------------+
    
    In this scenario, we can have the desktop UI in the overlay and some
    other framebuffer attached to the primary plane (e.g., video). However,
    userspace needs to obey some rules and avoid scenarios like the ones
    described below (when enabling hw cursor):
    
                                          +--------+
                                          |Overlay |
     +-------------+    +-----+-------+ +-|        |--+
     | +--------+  | +--------+       | | +--------+  |
     | |Overlay |  | |Overlay |       | |             |
     | |        |  | |        |       | |             |
     | +--------+  | +--------+       | |             |
     | Primary     |    | Primary     | | Primary     |
     +-------------+    +-------------+ +-------------+
    
     +-------------+   +-------------+
     |     +--------+  |  Primary    |
     |     |Overlay |  |             |
     |     |        |  |             |
     |     +--------+  | +--------+  |
     | Primary     |   | |Overlay |  |
     +-------------+   +-|        |--+
                         +--------+
    
    If the userspace violates some of the above scenarios, our driver needs
    to reject the commit; otherwise, we can have unexpected behavior. Since
    we don't have a proper driver validation for the above case, we can see
    some problems like a duplicate cursor in applications that use multiple
    planes. This commit fixes the cursor issue and others by adding adequate
    verification for multiple planes.
    
    Change since V1 (Harry and Sean):
    - Remove cursor verification from the equation.
    
    Cc: Louis Li <ching-shih...@amd.com>
    Cc: Nicholas Kazlauskas <nicholas.kazlaus...@amd.com>
    Cc: Harry Wentland <harry.wentl...@amd.com>
    Cc: Hersen Wu <hersenxs...@amd.com>
    Cc: Sean Paul <seanp...@chromium.org>
    Signed-off-by: Rodrigo Siqueira <rodrigo.sique...@amd.com>
    Reviewed-by: Harry Wentland <harry.wentl...@amd.com>
    Signed-off-by: Alex Deucher <alexander.deuc...@amd.com>

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 deec7e0466da..1b71e0ca1a89 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -9870,6 +9870,53 @@ static int add_affected_mst_dsc_crtcs(struct 
drm_atomic_state *state, struct drm
 }
 #endif
 
+static int validate_overlay(struct drm_atomic_state *state)
+{
+       int i;
+       struct drm_plane *plane;
+       struct drm_plane_state *old_plane_state, *new_plane_state;
+       struct drm_plane_state *primary_state, *overlay_state = NULL;
+
+       /* Check if primary plane is contained inside overlay */
+       for_each_oldnew_plane_in_state_reverse(state, plane, old_plane_state, 
new_plane_state, i) {
+               if (plane->type == DRM_PLANE_TYPE_OVERLAY) {
+                       if (drm_atomic_plane_disabling(plane->state, 
new_plane_state))
+                               return 0;
+
+                       overlay_state = new_plane_state;
+                       continue;
+               }
+       }
+
+       /* check if we're making changes to the overlay plane */
+       if (!overlay_state)
+               return 0;
+
+       /* check if overlay plane is enabled */
+       if (!overlay_state->crtc)
+               return 0;
+
+       /* find the primary plane for the CRTC that the overlay is enabled on */
+       primary_state = drm_atomic_get_plane_state(state, 
overlay_state->crtc->primary);
+       if (IS_ERR(primary_state))
+               return PTR_ERR(primary_state);
+
+       /* check if primary plane is enabled */
+       if (!primary_state->crtc)
+               return 0;
+
+       /* Perform the bounds check to ensure the overlay plane covers the 
primary */
+       if (primary_state->crtc_x < overlay_state->crtc_x ||
+           primary_state->crtc_y < overlay_state->crtc_y ||
+           primary_state->crtc_x + primary_state->crtc_w > 
overlay_state->crtc_x + overlay_state->crtc_w ||
+           primary_state->crtc_y + primary_state->crtc_h > 
overlay_state->crtc_y + overlay_state->crtc_h) {
+               DRM_DEBUG_ATOMIC("Overlay plane is enabled with hardware cursor 
but does not fully cover primary plane\n");
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
 /**
  * amdgpu_dm_atomic_check() - Atomic check implementation for AMDgpu DM.
  * @dev: The DRM device
@@ -10044,6 +10091,10 @@ static int amdgpu_dm_atomic_check(struct drm_device 
*dev,
                        goto fail;
        }
 
+       ret = validate_overlay(state);
+       if (ret)
+               goto fail;
+
        /* Add new/modified planes */
        for_each_oldnew_plane_in_state_reverse(state, plane, old_plane_state, 
new_plane_state, i) {
                ret = dm_update_plane_state(dc, state, plane,
commit c83c4e1912446db697a120eb30126cd80cbf6349
Author: Evan Quan <evan.q...@amd.com>
Date:   Wed Apr 28 12:00:20 2021 +0800

    drm/amdgpu: add new MC firmware for Polaris12 32bit ASIC
    
    Polaris12 32bit ASIC needs a special MC firmware.
    
    Signed-off-by: Evan Quan <evan.q...@amd.com>
    Reviewed-by: Alex Deucher <alexander.deuc...@amd.com>
    Signed-off-by: Alex Deucher <alexander.deuc...@amd.com>
    Cc: sta...@vger.kernel.org

diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c 
b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
index c1bd190841f8..e4f27b3f28fb 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
@@ -59,6 +59,7 @@ MODULE_FIRMWARE("amdgpu/tonga_mc.bin");
 MODULE_FIRMWARE("amdgpu/polaris11_mc.bin");
 MODULE_FIRMWARE("amdgpu/polaris10_mc.bin");
 MODULE_FIRMWARE("amdgpu/polaris12_mc.bin");
+MODULE_FIRMWARE("amdgpu/polaris12_32_mc.bin");
 MODULE_FIRMWARE("amdgpu/polaris11_k_mc.bin");
 MODULE_FIRMWARE("amdgpu/polaris10_k_mc.bin");
 MODULE_FIRMWARE("amdgpu/polaris12_k_mc.bin");
@@ -243,10 +244,16 @@ static int gmc_v8_0_init_microcode(struct amdgpu_device 
*adev)
                        chip_name = "polaris10";
                break;
        case CHIP_POLARIS12:
-               if (ASICID_IS_P23(adev->pdev->device, adev->pdev->revision))
+               if (ASICID_IS_P23(adev->pdev->device, adev->pdev->revision)) {
                        chip_name = "polaris12_k";
-               else
-                       chip_name = "polaris12";
+               } else {
+                       WREG32(mmMC_SEQ_IO_DEBUG_INDEX, ixMC_IO_DEBUG_UP_159);
+                       /* Polaris12 32bit ASIC needs a special MC firmware */
+                       if (RREG32(mmMC_SEQ_IO_DEBUG_DATA) == 0x05b4dc40)
+                               chip_name = "polaris12_32";
+                       else
+                               chip_name = "polaris12";
+               }
                break;
        case CHIP_FIJI:
        case CHIP_CARRIZO:
commit b9d79e4ca4ff23543d6b33c736ba07c1f0a9dcb1
Author: Guenter Roeck <li...@roeck-us.net>
Date:   Tue May 4 07:29:10 2021 -0700

    fbmem: Mark proc_fb_seq_ops as __maybe_unused
    
    With CONFIG_PROC_FS=n and -Werror, 0-day reports:
    
    drivers/video/fbdev/core/fbmem.c:736:36: error:
            'proc_fb_seq_ops' defined but not used
    
    Mark it as __maybe_unused.
    
    Reported-by: kernel test robot <l...@intel.com>
    Signed-off-by: Guenter Roeck <li...@roeck-us.net>
    Signed-off-by: Daniel Vetter <daniel.vet...@ffwll.ch>
    Link: 
https://patchwork.freedesktop.org/patch/msgid/20210504142910.2084722-1-li...@roeck-us.net

diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
index 372b52a2befa..52c606c0f8a2 100644
--- a/drivers/video/fbdev/core/fbmem.c
+++ b/drivers/video/fbdev/core/fbmem.c
@@ -733,7 +733,7 @@ static int fb_seq_show(struct seq_file *m, void *v)
        return 0;
 }
 
-static const struct seq_operations proc_fb_seq_ops = {
+static const struct __maybe_unused seq_operations proc_fb_seq_ops = {
        .start  = fb_seq_start,
        .next   = fb_seq_next,
        .stop   = fb_seq_stop,
commit a712b307cfde6dbe0d4829293afb1566beb30a9a
Author: Rob Clark <robdcl...@chromium.org>
Date:   Fri Apr 30 10:17:39 2021 -0700

    drm/msm/dpu: Delete bonkers code
    
    dpu_crtc_atomic_flush() was directly poking it's attached planes in a
    code path that ended up in dpu_plane_atomic_update(), even if the plane
    was not involved in the current atomic update.  While a bit dubious,
    this worked before because plane->state would always point to something
    valid.  But now using drm_atomic_get_new_plane_state() we could get a
    NULL state pointer instead, leading to:
    
       [   20.873273] Call trace:
       [   20.875740]  dpu_plane_atomic_update+0x5c/0xed0
       [   20.880311]  dpu_plane_restore+0x40/0x88
       [   20.884266]  dpu_crtc_atomic_flush+0xf4/0x208
       [   20.888660]  drm_atomic_helper_commit_planes+0x150/0x238
       [   20.894014]  msm_atomic_commit_tail+0x1d4/0x7a0
       [   20.898579]  commit_tail+0xa4/0x168
       [   20.902102]  drm_atomic_helper_commit+0x164/0x178
       [   20.906841]  drm_atomic_commit+0x54/0x60
       [   20.910798]  drm_atomic_connector_commit_dpms+0x10c/0x118
       [   20.916236]  drm_mode_obj_set_property_ioctl+0x1e4/0x440
       [   20.921588]  drm_connector_property_set_ioctl+0x60/0x88
       [   20.926852]  drm_ioctl_kernel+0xd0/0x120
       [   20.930807]  drm_ioctl+0x21c/0x478
       [   20.934235]  __arm64_sys_ioctl+0xa8/0xe0
       [   20.938193]  invoke_syscall+0x64/0x130
       [   20.941977]  el0_svc_common.constprop.3+0x5c/0xe0
       [   20.946716]  do_el0_svc+0x80/0xa0
       [   20.950058]  el0_svc+0x20/0x30
       [   20.953145]  el0_sync_handler+0x88/0xb0
       [   20.957014]  el0_sync+0x13c/0x140
    
    The reason for the codepath seems dubious, the atomic suspend/resume
    heplers should handle the power-collapse case.  If not, the CRTC's
    atomic_check() should be adding the planes to the atomic update.
    
    Reported-by: Stephen Boyd <swb...@chromium.org>
    Reported-by: John Stultz <john.stu...@linaro.org>
    Fixes: 37418bf14c13 ("drm: Use state helper instead of the plane state 
pointer")
    Tested-by: John Stultz <john.stu...@linaro.org>
    Signed-off-by: Rob Clark <robdcl...@chromium.org>
    Signed-off-by: Maxime Ripard <max...@cerno.tech>
    Link: 
https://patchwork.freedesktop.org/patch/msgid/20210430171744.1721408-1-robdcl...@gmail.com

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
index 9607a7644d4b..e65ff8168269 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
@@ -566,16 +566,6 @@ static void dpu_crtc_atomic_flush(struct drm_crtc *crtc,
        if (unlikely(!cstate->num_mixers))
                return;
 
-       /*
-        * For planes without commit update, drm framework will not add
-        * those planes to current state since hardware update is not
-        * required. However, if those planes were power collapsed since
-        * last commit cycle, driver has to restore the hardware state
-        * of those planes explicitly here prior to plane flush.
-        */
-       drm_atomic_crtc_for_each_plane(plane, crtc)
-               dpu_plane_restore(plane, state);
-
        /* update performance setting before crtc kickoff */
        dpu_core_perf_crtc_update(crtc, 1, false);
 
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
index df7f3d3afd8b..7a993547eb75 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
@@ -1258,22 +1258,6 @@ static void dpu_plane_atomic_update(struct drm_plane 
*plane,
        }
 }
 
-void dpu_plane_restore(struct drm_plane *plane, struct drm_atomic_state *state)
-{
-       struct dpu_plane *pdpu;
-
-       if (!plane || !plane->state) {
-               DPU_ERROR("invalid plane\n");
-               return;
-       }
-
-       pdpu = to_dpu_plane(plane);
-
-       DPU_DEBUG_PLANE(pdpu, "\n");
-
-       dpu_plane_atomic_update(plane, state);
-}
-
 static void dpu_plane_destroy(struct drm_plane *plane)
 {
        struct dpu_plane *pdpu = plane ? to_dpu_plane(plane) : NULL;
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.h 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.h
index 03b6365a750c..34e03ac05f4a 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.h
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.h
@@ -84,12 +84,6 @@ bool is_dpu_plane_virtual(struct drm_plane *plane);
 void dpu_plane_get_ctl_flush(struct drm_plane *plane, struct dpu_hw_ctl *ctl,
                u32 *flush_sspp);
 
-/**
- * dpu_plane_restore - restore hw state if previously power collapsed
- * @plane: Pointer to drm plane structure
- */
-void dpu_plane_restore(struct drm_plane *plane, struct drm_atomic_state 
*state);
-
 /**
  * dpu_plane_flush - final plane operations before commit flush
  * @plane: Pointer to drm plane structure
commit c7b397e9ca4d6828e3e3f504c80bcb1fe535c348
Merge: 270e3cc5aa38 d385c16173f2
Author: Jani Nikula <jani.nik...@intel.com>
Date:   Thu Apr 29 13:15:51 2021 +0300

    Merge tag 'gvt-next-fixes-2021-04-29' of https://github.com/intel/gvt-linux 
into drm-intel-next-fixes
    
    gvt-next-fixes-2021-04-29
    
    - Fix possible divide error in vgpu display rate calculation (Colin)
    
    Signed-off-by: Jani Nikula <jani.nik...@intel.com>
    From: Zhenyu Wang <zhen...@linux.intel.com>
    Link: 
https://patchwork.freedesktop.org/patch/msgid/20210429085142.gt1...@zhen-hp.sh.intel.com

commit d385c16173f28a18866abf54c764200c276dace0
Author: Colin Xu <colin...@intel.com>
Date:   Fri Apr 16 16:33:55 2021 +0800

    drm/i915/gvt: Prevent divided by zero when calculating refresh rate
    
    To get refresh rate as vblank timer period and keep the precision, the
    calculation of rate is multiplied by 1000. However old logic was using:
    rate = pixel clock / (h * v / 1000). When the h/v total is invalid, like
    all 0, h * v / 1000 will be rounded to 0, which leads to a divided by 0
    fault.
    
    0 H/V are already checked above. Instead of divide after divide, refine
    the calculation to divide after multiply: "pixel clock * 1000 / (h * v)"
    Guest driver should guarantee the correctness of the timing regs' value.
    
    Fixes: 6a4500c7b83f ("drm/i915/gvt: Get accurate vGPU virtual display 
refresh rate from vreg")
    Reported-by: Zhenyu Wang <zhen...@linux.intel.com>
    Signed-off-by: Colin Xu <colin...@intel.com>
    Signed-off-by: Zhenyu Wang <zhen...@linux.intel.com>
    Link: 
http://patchwork.freedesktop.org/patch/msgid/20210416083355.159305-1-colin...@intel.com
    Reviewed-by: Zhenyu Wang <zhen...@linux.intel.com>

diff --git a/drivers/gpu/drm/i915/gvt/handlers.c 
b/drivers/gpu/drm/i915/gvt/handlers.c
index 477badfcb258..dda320749c65 100644
--- a/drivers/gpu/drm/i915/gvt/handlers.c
+++ b/drivers/gpu/drm/i915/gvt/handlers.c
@@ -669,8 +669,8 @@ static void vgpu_update_refresh_rate(struct intel_vgpu 
*vgpu)
        link_n = vgpu_vreg_t(vgpu, PIPE_LINK_N1(TRANSCODER_A));
 
        /* Get H/V total from transcoder timing */
-       htotal = (vgpu_vreg_t(vgpu, HTOTAL(TRANSCODER_A)) >> 
TRANS_HTOTAL_SHIFT) + 1;
-       vtotal = (vgpu_vreg_t(vgpu, VTOTAL(TRANSCODER_A)) >> 
TRANS_VTOTAL_SHIFT) + 1;
+       htotal = (vgpu_vreg_t(vgpu, HTOTAL(TRANSCODER_A)) >> 
TRANS_HTOTAL_SHIFT);
+       vtotal = (vgpu_vreg_t(vgpu, VTOTAL(TRANSCODER_A)) >> 
TRANS_VTOTAL_SHIFT);
 
        if (dp_br && link_n && htotal && vtotal) {
                u64 pixel_clk = 0;
@@ -682,7 +682,7 @@ static void vgpu_update_refresh_rate(struct intel_vgpu 
*vgpu)
                pixel_clk *= MSEC_PER_SEC;
 
                /* Calcuate refresh rate by (pixel_clk / (h_total * v_total)) */
-               new_rate = DIV64_U64_ROUND_CLOSEST(pixel_clk, 
div64_u64(mul_u32_u32(htotal, vtotal), MSEC_PER_SEC));
+               new_rate = DIV64_U64_ROUND_CLOSEST(mul_u64_u32_shr(pixel_clk, 
MSEC_PER_SEC, 0), mul_u32_u32(htotal + 1, vtotal + 1));
 
                if (*old_rate != new_rate)
                        *old_rate = new_rate;
commit e0c16eb4b3610298a74ae5504c7f6939b12be991
Author: Simon Ser <cont...@emersion.fr>
Date:   Wed Apr 21 11:16:35 2021 +0200

    amdgpu: fix GEM obj leak in amdgpu_display_user_framebuffer_create
    
    This error code-path is missing a drm_gem_object_put call. Other
    error code-paths are fine.
    
    Signed-off-by: Simon Ser <cont...@emersion.fr>
    Fixes: 1769152ac64b ("drm/amdgpu: Fail fb creation from imported dma-bufs. 
(v2)")
    Cc: Alex Deucher <alexander.deuc...@amd.com>
    Cc: Harry Wentland <hwent...@amd.com>
    Cc: Nicholas Kazlauskas <nicholas.kazlaus...@amd.com>
    Cc: Bas Nieuwenhuizen <b...@basnieuwenhuizen.nl>
    Reviewed-by: Christian König <christian.koe...@amd.com>
    Signed-off-by: Alex Deucher <alexander.deuc...@amd.com>
    Cc: sta...@vger.kernel.org

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index 4fbae20839b7..c4cfefb33e03 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -986,6 +986,7 @@ amdgpu_display_user_framebuffer_create(struct drm_device 
*dev,
        domains = amdgpu_display_supported_domains(drm_to_adev(dev), bo->flags);
        if (obj->import_attach && !(domains & AMDGPU_GEM_DOMAIN_GTT)) {
                drm_dbg_kms(dev, "Cannot create framebuffer from imported 
dma_buf\n");
+               drm_gem_object_put(obj);
                return ERR_PTR(-EINVAL);
        }
 
commit 8c3dd61cfa05a65a7e1a8a028000fc95856156c4
Author: Kai-Heng Feng <kai.heng.f...@canonical.com>
Date:   Mon Apr 26 18:50:00 2021 +0800

    drm/amdgpu: Register VGA clients after init can no longer fail
    
    When an amdgpu device fails to init, it makes another VGA device cause
    kernel splat:
    kernel: amdgpu 0000:08:00.0: amdgpu: amdgpu_device_ip_init failed
    kernel: amdgpu 0000:08:00.0: amdgpu: Fatal error during GPU init
    kernel: amdgpu: probe of 0000:08:00.0 failed with error -110
    ...
    kernel: amdgpu 0000:01:00.0: vgaarb: changed VGA decodes: 
olddecodes=io+mem,decodes=none:owns=none
    kernel: BUG: kernel NULL pointer dereference, address: 0000000000000018
    kernel: #PF: supervisor read access in kernel mode
    kernel: #PF: error_code(0x0000) - not-present page
    kernel: PGD 0 P4D 0
    kernel: Oops: 0000 [#1] SMP NOPTI
    kernel: CPU: 6 PID: 1080 Comm: Xorg Tainted: G        W         5.12.0-rc8+ 
#12
    kernel: Hardware name: HP HP EliteDesk 805 G6/872B, BIOS S09 Ver. 02.02.00 
12/30/2020
    kernel: RIP: 0010:amdgpu_device_vga_set_decode+0x13/0x30 [amdgpu]
    kernel: Code: 06 31 c0 c3 b8 ea ff ff ff 5d c3 66 2e 0f 1f 84 00 00 00 00 
00 66 90 0f 1f 44 00 00 55 48 8b 87 90 06 00 00 48 89 e5 53 89 f3 <48> 8b 40 18 
40 0f b6 f6 e8 40 58 39 fd 80 fb 01 5b 5d 19 c0 83 e0
    kernel: RSP: 0018:ffffae3c0246bd68 EFLAGS: 00010002
    kernel: RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
    kernel: RDX: ffff8dd1af5a8560 RSI: 0000000000000000 RDI: ffff8dce8c160000
    kernel: RBP: ffffae3c0246bd70 R08: ffff8dd1af5985c0 R09: ffffae3c0246ba38
    kernel: R10: 0000000000000001 R11: 0000000000000001 R12: 0000000000000246
    kernel: R13: 0000000000000000 R14: 0000000000000003 R15: ffff8dce81490000
    kernel: FS:  00007f9303d8fa40(0000) GS:ffff8dd1af580000(0000) 
knlGS:0000000000000000
    kernel: CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    kernel: CR2: 0000000000000018 CR3: 0000000103cfa000 CR4: 0000000000350ee0
    kernel: Call Trace:
    kernel:  vga_arbiter_notify_clients.part.0+0x4a/0x80
    kernel:  vga_get+0x17f/0x1c0
    kernel:  vga_arb_write+0x121/0x6a0
    kernel:  ? apparmor_file_permission+0x1c/0x20
    kernel:  ? security_file_permission+0x30/0x180
    kernel:  vfs_write+0xca/0x280
    kernel:  ksys_write+0x67/0xe0
    kernel:  __x64_sys_write+0x1a/0x20
    kernel:  do_syscall_64+0x38/0x90
    kernel:  entry_SYSCALL_64_after_hwframe+0x44/0xae
    kernel: RIP: 0033:0x7f93041e02f7
    kernel: Code: 75 05 48 83 c4 58 c3 e8 f7 33 ff ff 0f 1f 80 00 00 00 00 f3 
0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 01 00 00 00 0f 05 <48> 3d 00 f0 
ff ff 77 51 c3 48 83 ec 28 48 89 54 24 18 48 89 74 24
    kernel: RSP: 002b:00007fff60e49b28 EFLAGS: 00000246 ORIG_RAX: 
0000000000000001
    kernel: RAX: ffffffffffffffda RBX: 000000000000000b RCX: 00007f93041e02f7
    kernel: RDX: 000000000000000b RSI: 00007fff60e49b40 RDI: 000000000000000f
    kernel: RBP: 00007fff60e49b40 R08: 00000000ffffffff R09: 00007fff60e499d0
    kernel: R10: 00007f93049350b5 R11: 0000000000000246 R12: 000056111d45e808
    kernel: R13: 0000000000000000 R14: 000056111d45e7f8 R15: 000056111d46c980
    kernel: Modules linked in: nls_iso8859_1 snd_hda_codec_realtek 
snd_hda_codec_generic ledtrig_audio snd_hda_codec_hdmi snd_hda_intel 
snd_intel_dspcfg snd_hda_codec snd_hwdep snd_hda_core snd_pcm snd_seq 
input_leds snd_seq_device snd_timer snd soundcore joydev kvm_amd serio_raw 
k10temp mac_hid hp_wmi ccp kvm sparse_keymap wmi_bmof ucsi_acpi efi_pstore 
typec_ucsi rapl typec video wmi sch_fq_codel parport_pc ppdev lp parport 
ip_tables x_tables autofs4 btrfs blake2b_generic zstd_compress raid10 raid456 
async_raid6_recov async_memcpy async_pq async_xor async_tx libcrc32c xor 
raid6_pq raid1 raid0 multipath linear dm_mirror dm_region_hash dm_log 
hid_generic usbhid hid amdgpu drm_ttm_helper ttm iommu_v2 gpu_sched 
i2c_algo_bit drm_kms_helper syscopyarea sysfillrect crct10dif_pclmul sysimgblt 
crc32_pclmul fb_sys_fops ghash_clmulni_intel cec rc_core aesni_intel 
crypto_simd psmouse cryptd r8169 i2c_piix4 drm ahci xhci_pci realtek libahci 
xhci_pci_renesas gpio_amdpt gpio_generic
    kernel: CR2: 0000000000000018
    kernel: ---[ end trace 76d04313d4214c51 ]---
    
    Commit 4192f7b57689 ("drm/amdgpu: unmap register bar on device init
    failure") makes amdgpu_driver_unload_kms() skips amdgpu_device_fini(),
    so the VGA clients remain registered. So when
    vga_arbiter_notify_clients() iterates over registered clients, it causes
    NULL pointer dereference.
    
    Since there's no reason to register VGA clients that early, so solve
    the issue by putting them after all the goto cleanups.
    
    v2:
     - Remove redundant vga_switcheroo cleanup in failed: label.
    
    Fixes: 4192f7b57689 ("drm/amdgpu: unmap register bar on device init 
failure")
    Signed-off-by: Kai-Heng Feng <kai.heng.f...@canonical.com>
    Signed-off-by: Alex Deucher <alexander.deuc...@amd.com>

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index b4ad1c055c70..7d3b54615147 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3410,19 +3410,6 @@ int amdgpu_device_init(struct amdgpu_device *adev,
        /* doorbell bar mapping and doorbell index init*/
        amdgpu_device_doorbell_init(adev);
 
-       /* if we have > 1 VGA cards, then disable the amdgpu VGA resources */
-       /* this will fail for cards that aren't VGA class devices, just
-        * ignore it */
-       if ((adev->pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
-               vga_client_register(adev->pdev, adev, NULL, 
amdgpu_device_vga_set_decode);
-
-       if (amdgpu_device_supports_px(ddev)) {
-               px = true;
-               vga_switcheroo_register_client(adev->pdev,
-                                              &amdgpu_switcheroo_ops, px);
-               vga_switcheroo_init_domain_pm_ops(adev->dev, 
&adev->vga_pm_domain);
-       }
-
        if (amdgpu_emu_mode == 1) {
                /* post the asic on emulation mode */
                emu_soc_asic_init(adev);
@@ -3619,6 +3606,19 @@ fence_driver_init:
        if (amdgpu_device_cache_pci_state(adev->pdev))
                pci_restore_state(pdev);
 
+       /* if we have > 1 VGA cards, then disable the amdgpu VGA resources */
+       /* this will fail for cards that aren't VGA class devices, just
+        * ignore it */
+       if ((adev->pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
+               vga_client_register(adev->pdev, adev, NULL, 
amdgpu_device_vga_set_decode);
+
+       if (amdgpu_device_supports_px(ddev)) {
+               px = true;
+               vga_switcheroo_register_client(adev->pdev,
+                                              &amdgpu_switcheroo_ops, px);
+               vga_switcheroo_init_domain_pm_ops(adev->dev, 
&adev->vga_pm_domain);
+       }
+
        if (adev->gmc.xgmi.pending_reset)
                queue_delayed_work(system_wq, &mgpu_info.delayed_reset_work,
                                   msecs_to_jiffies(AMDGPU_RESUME_MS));
@@ -3630,8 +3630,6 @@ release_ras_con:
 
 failed:
        amdgpu_vf_error_trans_all(adev);
-       if (px)
-               vga_switcheroo_fini_domain_pm_ops(adev->dev);
 
 failed_unmap:
        iounmap(adev->rmmio);
commit b45aeb2dea9142d4d32fa3a117ba381d84f27065
Author: Pavan Kumar Ramayanam <pavan.ramaya...@amd.com>
Date:   Tue Apr 27 10:21:18 2021 +0530

    drm/amdgpu: Handling of amdgpu_device_resume return value for graceful 
teardown
    
    The runtime resume PM op disregards the return value from
    amdgpu_device_resume(), masking errors for failed resumes at the PM
    layer.
    
    Reviewed-by: Alex Deucher <alexander.deuc...@amd.com>
    Signed-off-by: Pavan Kumar Ramayanam <pavan.ramaya...@amd.com>
    Signed-off-by: Alex Deucher <alexander.deuc...@amd.com>

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index d8f131ed10cb..b0378cfe2218 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -1573,6 +1573,9 @@ static int amdgpu_pmops_runtime_resume(struct device *dev)
                amdgpu_device_baco_exit(drm_dev);
        }
        ret = amdgpu_device_resume(drm_dev, false);
+       if (ret)
+               return ret;
+
        if (amdgpu_device_supports_px(drm_dev))
                drm_dev->switch_power_state = DRM_SWITCH_POWER_ON;
        adev->in_runpm = false;
commit 4b12ee6f426e5e36396501a58f3a1af5b92a7e06
Author: Victor Zhao <victor.z...@amd.com>
Date:   Tue Apr 27 17:52:56 2021 +0800

    drm/amdgpu: fix r initial values
    
    Sriov gets suspend of IP block <dce_virtual> failed as return
    value was not initialized.
    
    v2: return 0 directly to align original code semantic before this
    was broken out into a separate helper function instead of setting
    initial values
    
    Signed-off-by: Victor Zhao <victor.z...@amd.com>
    Reviewed-by: Alex Deucher <alexander.deuc...@amd.com>
    Signed-off-by: Alex Deucher <alexander.deuc...@amd.com>
    Cc: sta...@vger.kernel.org

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index 9a2f811450ed..4fbae20839b7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -1399,7 +1399,7 @@ int amdgpu_display_suspend_helper(struct amdgpu_device 
*adev)
                        }
                }
        }
-       return r;
+       return 0;
 }
 
 int amdgpu_display_resume_helper(struct amdgpu_device *adev)
commit 3cbae5abfa8ebc8bc2b445dbe392b6987cd15483
Author: Mikita Lipski <mikita.lip...@amd.com>
Date:   Wed Apr 14 14:15:52 2021 -0400

    drm/amd/display: fix wrong statement in mst hpd debugfs
    
    [why]
    Previous statement would always evaluate to true
    making it meaningless
    [how]
    Just check if a connector is MST by checking if its port exists.
    
    Fixes: 41efcd3879b1df ("drm/amd/display: Add MST capability to 
trigger_hotplug interface")
    Reported-by: kernel test robot <l...@intel.com>
    Signed-off-by: Mikita Lipski <mikita.lip...@amd.com>
    Reviewed-by: Nicholas Kazlauskas <nicholas.kazlaus...@amd.com>
    Acked-by: Wayne Lin <wayne...@amd.com>
    Tested-by: Daniel Wheeler <daniel.whee...@amd.com>
    Signed-off-by: Alex Deucher <alexander.deuc...@amd.com>

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 9a13f47022df..2cfee7d6bb4d 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
@@ -3012,7 +3012,7 @@ static int trigger_hpd_mst_set(void *data, u64 val)
                        if (!aconnector->dc_link)
                                continue;
 
-                       if (!(aconnector->port && 
&aconnector->mst_port->mst_mgr))
+                       if (!aconnector->mst_port)
                                continue;
 
                        link = aconnector->dc_link;
commit d7b4a6077ec38763a1f6fed2b2f6a0113028eea7
Author: Darren Powell <darren.pow...@amd.com>
Date:   Wed Apr 7 18:40:34 2021 -0400

    amdgpu/pm: set pp_dpm_dcefclk to readonly on NAVI10 and newer gpus
    
    v2 : change condition to apply to all chips after NAVI10
    
    Writing to dcefclk causes the gpu to become unresponsive, and requires a 
reboot.
    Patch prevents user from successfully writing to file pp_dpm_dcefclk on 
parts
    NAVI10 and newer, and gives better user feedback that this operation is not 
allowed.
    
    Signed-off-by: Darren Powell <darren.pow...@amd.com>
    Reviewed-by: Kenneth Feng <kenneth.f...@amd.com>
    Signed-off-by: Alex Deucher <alexander.deuc...@amd.com>

diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c 
b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
index 204e34549013..a8d6cc2525b2 100644
--- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
@@ -1891,6 +1891,14 @@ static int default_attr_update(struct amdgpu_device 
*adev, struct amdgpu_device_
                }
        }
 
+       if (DEVICE_ATTR_IS(pp_dpm_dcefclk)) {
+               /* SMU MP1 does not support dcefclk level setting */
+               if (asic_type >= CHIP_NAVI10) {
+                       dev_attr->attr.mode &= ~S_IWUGO;
+                       dev_attr->store = NULL;
+               }
+       }
+
 #undef DEVICE_ATTR_IS
 
        return 0;
commit b117b3964f38a988cb79825950dbd607c02237f3
Author: Darren Powell <darren.pow...@amd.com>
Date:   Wed Apr 7 00:34:35 2021 -0400

    amdgpu/pm: Prevent force of DCEFCLK on NAVI10 and SIENNA_CICHLID
    
    Writing to dcefclk causes the gpu to become unresponsive, and requires a 
reboot.
    Patch ignores a .force_clk_levels(SMU_DCEFCLK) call and issues an
    info message.
    
    Signed-off-by: Darren Powell <darren.pow...@amd.com>
    Reviewed-by: Kenneth Feng <kenneth.f...@amd.com>
    Signed-off-by: Alex Deucher <alexander.deuc...@amd.com>

diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c 
b/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c
index f827096dc849..ac13042672ea 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c
@@ -1443,7 +1443,6 @@ static int navi10_force_clk_levels(struct smu_context 
*smu,
        case SMU_SOCCLK:
        case SMU_MCLK:
        case SMU_UCLK:
-       case SMU_DCEFCLK:
        case SMU_FCLK:
                /* There is only 2 levels for fine grained DPM */
                if (navi10_is_support_fine_grained_dpm(smu, clk_type)) {
@@ -1463,6 +1462,10 @@ static int navi10_force_clk_levels(struct smu_context 
*smu,
                if (ret)
                        return size;
                break;
+       case SMU_DCEFCLK:
+               dev_info(smu->adev->dev,"Setting DCEFCLK min/max dpm level is 
not supported!\n");
+               break;
+
        default:
                break;
        }
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c 
b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c
index 72d9c1be1835..d2fd44b903ca 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c
@@ -1127,7 +1127,6 @@ static int sienna_cichlid_force_clk_levels(struct 
smu_context *smu,
        case SMU_SOCCLK:
        case SMU_MCLK:
        case SMU_UCLK:
-       case SMU_DCEFCLK:
        case SMU_FCLK:
                /* There is only 2 levels for fine grained DPM */
                if (sienna_cichlid_is_support_fine_grained_dpm(smu, clk_type)) {
@@ -1147,6 +1146,9 @@ static int sienna_cichlid_force_clk_levels(struct 
smu_context *smu,
                if (ret)
                        goto forec_level_out;
                break;
+       case SMU_DCEFCLK:
+               dev_info(smu->adev->dev,"Setting DCEFCLK min/max dpm level is 
not supported!\n");
+               break;
        default:
                break;
        }
commit 20a5f5a98e1bb3d40acd97e89299e8c2d22784be
Author: Christian König <christian.koe...@amd.com>
Date:   Thu Apr 22 13:11:39 2021 +0200

    drm/amdgpu: fix concurrent VM flushes on Vega/Navi v2
    
    Starting with Vega the hardware supports concurrent flushes
    of VMID which can be used to implement per process VMID
    allocation.
    
    But concurrent flushes are mutual exclusive with back to
    back VMID allocations, fix this to avoid a VMID used in
    two ways at the same time.
    
    v2: don't set ring to NULL
    
    Signed-off-by: Christian König <christian.koe...@amd.com>
    Reviewed-by: James Zhu <james....@amd.com>
    Tested-by: James Zhu <james....@amd.com>
    Signed-off-by: Alex Deucher <alexander.deuc...@amd.com>
    Cc: sta...@vger.kernel.org

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c
index 94b069630db3..b4971e90b98c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c
@@ -215,7 +215,11 @@ static int amdgpu_vmid_grab_idle(struct amdgpu_vm *vm,
        /* Check if we have an idle VMID */
        i = 0;
        list_for_each_entry((*idle), &id_mgr->ids_lru, list) {
-               fences[i] = amdgpu_sync_peek_fence(&(*idle)->active, ring);
+               /* Don't use per engine and per process VMID at the same time */
+               struct amdgpu_ring *r = adev->vm_manager.concurrent_flush ?
+                       NULL : ring;
+
+               fences[i] = amdgpu_sync_peek_fence(&(*idle)->active, r);
                if (!fences[i])
                        break;
                ++i;
@@ -281,7 +285,7 @@ static int amdgpu_vmid_grab_reserved(struct amdgpu_vm *vm,
        if (updates && (*id)->flushed_updates &&
            updates->context == (*id)->flushed_updates->context &&
            !dma_fence_is_later(updates, (*id)->flushed_updates))
-           updates = NULL;
+               updates = NULL;
 
        if ((*id)->owner != vm->immediate.fence_context ||
            job->vm_pd_addr != (*id)->pd_gpu_addr ||
@@ -290,6 +294,10 @@ static int amdgpu_vmid_grab_reserved(struct amdgpu_vm *vm,
             !dma_fence_is_signaled((*id)->last_flush))) {
                struct dma_fence *tmp;
 
+               /* Don't use per engine and per process VMID at the same time */
+               if (adev->vm_manager.concurrent_flush)
+                       ring = NULL;
+
                /* to prevent one context starved by another context */
                (*id)->pd_gpu_addr = 0;
                tmp = amdgpu_sync_peek_fence(&(*id)->active, ring);
@@ -365,12 +373,7 @@ static int amdgpu_vmid_grab_used(struct amdgpu_vm *vm,
                if (updates && (!flushed || dma_fence_is_later(updates, 
flushed)))
                        needs_flush = true;
 
-               /* Concurrent flushes are only possible starting with Vega10 and
-                * are broken on Navi10 and Navi14.
-                */
-               if (needs_flush && (adev->asic_type < CHIP_VEGA10 ||
-                                   adev->asic_type == CHIP_NAVI10 ||
-                                   adev->asic_type == CHIP_NAVI14))
+               if (needs_flush && !adev->vm_manager.concurrent_flush)
                        continue;
 
                /* Good, we can use this VMID. Remember this submission as
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 0ffdf847cad0..9acee4a5b2ba 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -3148,6 +3148,12 @@ void amdgpu_vm_manager_init(struct amdgpu_device *adev)
 {
        unsigned i;
 
+       /* Concurrent flushes are only possible starting with Vega10 and
+        * are broken on Navi10 and Navi14.
+        */
+       adev->vm_manager.concurrent_flush = !(adev->asic_type < CHIP_VEGA10 ||
+                                             adev->asic_type == CHIP_NAVI10 ||
+                                             adev->asic_type == CHIP_NAVI14);
        amdgpu_vmid_mgr_init(adev);
 
        adev->vm_manager.fence_context =
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
index 976a12e5a8b9..4e140288159c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
@@ -331,6 +331,7 @@ struct amdgpu_vm_manager {
        /* Handling of VMIDs */
        struct amdgpu_vmid_mgr                  id_mgr[AMDGPU_MAX_VMHUBS];
        unsigned int                            first_kfd_vmid;
+       bool                                    concurrent_flush;
 
        /* Handling of VM fences */
        u64                                     fence_context;
commit d89f6048bdcb6a56abb396c584747d5eeae650db
Author: Harry Wentland <harry.wentl...@amd.com>
Date:   Thu Apr 22 19:10:52 2021 -0400

    drm/amd/display: Reject non-zero src_y and src_x for video planes
    
    [Why]
    This hasn't been well tested and leads to complete system hangs on DCN1
    based systems, possibly others.
    
    The system hang can be reproduced by gesturing the video on the YouTube
    Android app on ChromeOS into full screen.
    
    [How]
    Reject atomic commits with non-zero drm_plane_state.src_x or src_y values.
    
    v2:
     - Add code comment describing the reason we're rejecting non-zero
       src_x and src_y
     - Drop gerrit Change-Id
     - Add stable CC
     - Based on amd-staging-drm-next
    
    v3: removed trailing whitespace
    
    Signed-off-by: Harry Wentland <harry.wentl...@amd.com>
    Cc: sta...@vger.kernel.org
    Cc: nicholas.kazlaus...@amd.com
    Cc: amd-...@lists.freedesktop.org
    Cc: alexander.deuc...@amd.com
    Cc: roman...@amd.com
    Cc: hersenxs...@amd.com
    Cc: danny.w...@amd.com
    Reviewed-by: Nicholas Kazlauskas <nicholas.kazlaus...@amd.com>
    Acked-by: Christian König <christian.koe...@amd.com>
    Reviewed-by: Hersen Wu <hersenxs...@amd.com>
    Signed-off-by: Alex Deucher <alexander.deuc...@amd.com>
    Cc: sta...@vger.kernel.org

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 a0c8c41e4e57..deec7e0466da 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -4008,6 +4008,23 @@ static int fill_dc_scaling_info(const struct 
drm_plane_state *state,
        scaling_info->src_rect.x = state->src_x >> 16;
        scaling_info->src_rect.y = state->src_y >> 16;
 
+       /*
+        * For reasons we don't (yet) fully understand a non-zero
+        * src_y coordinate into an NV12 buffer can cause a
+        * system hang. To avoid hangs (and maybe be overly cautious)
+        * let's reject both non-zero src_x and src_y.
+        *
+        * We currently know of only one use-case to reproduce a
+        * scenario with non-zero src_x and src_y for NV12, which
+        * is to gesture the YouTube Android app into full screen
+        * on ChromeOS.
+        */
+       if (state->fb &&
+           state->fb->format->format == DRM_FORMAT_NV12 &&
+           (scaling_info->src_rect.x != 0 ||
+            scaling_info->src_rect.y != 0))
+               return -EINVAL;
+
        scaling_info->src_rect.width = state->src_w >> 16;
        if (scaling_info->src_rect.width == 0)
                return -EINVAL;
_______________________________________________
openchrome-devel mailing list
openchrome-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/openchrome-devel

Reply via email to