Merge tag 'drm-misc-fixes-2022-11-17' of git://anongit.freedesktop.org/drm/drm-misc...
authorDave Airlie <airlied@redhat.com>
Thu, 17 Nov 2022 21:08:56 +0000 (07:08 +1000)
committerDave Airlie <airlied@redhat.com>
Thu, 17 Nov 2022 21:08:57 +0000 (07:08 +1000)
drm-misc-fixes for v6.1-rc6:
- Fix error handling in vc4_atomic_commit_tail()
- Set bpc for logictechno panels.
- Fix potential memory leak in drm_dev_init()
- Fix potential null-ptr-deref in drm_vblank_destroy_worker()
- Set lima's clkname corrrectly when regulator is missing.
- Small amdgpu fix to gang submission.
- Revert hiding unregistered connectors from userspace, as it breaks on DP-MST.
- Add workaround for DP++ dual mode adaptors that don't support
  i2c subaddressing.

Signed-off-by: Dave Airlie <airlied@redhat.com>
From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/c7d02936-c550-199b-6cb7-cbf6cf104e4a@linux.intel.com
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.h
drivers/gpu/drm/display/drm_dp_dual_mode_helper.c
drivers/gpu/drm/drm_drv.c
drivers/gpu/drm/drm_internal.h
drivers/gpu/drm/drm_mode_config.c
drivers/gpu/drm/lima/lima_devfreq.c
drivers/gpu/drm/panel/panel-simple.c
drivers/gpu/drm/vc4/vc4_kms.c

index d371000a5727e704acc5e0f31eecf95a829759b2..de5cb056c9ad77d6326a060c13b51270b7263b74 100644 (file)
@@ -109,6 +109,7 @@ static int amdgpu_cs_p1_ib(struct amdgpu_cs_parser *p,
                return r;
 
        ++(num_ibs[r]);
+       p->gang_leader_idx = r;
        return 0;
 }
 
@@ -300,7 +301,7 @@ static int amdgpu_cs_pass1(struct amdgpu_cs_parser *p,
                if (ret)
                        goto free_all_kdata;
        }
-       p->gang_leader = p->jobs[p->gang_size - 1];
+       p->gang_leader = p->jobs[p->gang_leader_idx];
 
        if (p->ctx->vram_lost_counter != p->gang_leader->vram_lost_counter) {
                ret = -ECANCELED;
@@ -1195,16 +1196,18 @@ static int amdgpu_cs_sync_rings(struct amdgpu_cs_parser *p)
                        return r;
        }
 
-       for (i = 0; i < p->gang_size - 1; ++i) {
+       for (i = 0; i < p->gang_size; ++i) {
+               if (p->jobs[i] == leader)
+                       continue;
+
                r = amdgpu_sync_clone(&leader->sync, &p->jobs[i]->sync);
                if (r)
                        return r;
        }
 
-       r = amdgpu_ctx_wait_prev_fence(p->ctx, p->entities[p->gang_size - 1]);
+       r = amdgpu_ctx_wait_prev_fence(p->ctx, p->entities[p->gang_leader_idx]);
        if (r && r != -ERESTARTSYS)
                DRM_ERROR("amdgpu_ctx_wait_prev_fence failed.\n");
-
        return r;
 }
 
@@ -1238,9 +1241,12 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
        for (i = 0; i < p->gang_size; ++i)
                drm_sched_job_arm(&p->jobs[i]->base);
 
-       for (i = 0; i < (p->gang_size - 1); ++i) {
+       for (i = 0; i < p->gang_size; ++i) {
                struct dma_fence *fence;
 
+               if (p->jobs[i] == leader)
+                       continue;
+
                fence = &p->jobs[i]->base.s_fence->scheduled;
                r = amdgpu_sync_fence(&leader->sync, fence);
                if (r)
@@ -1276,7 +1282,10 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
        list_for_each_entry(e, &p->validated, tv.head) {
 
                /* Everybody except for the gang leader uses READ */
-               for (i = 0; i < (p->gang_size - 1); ++i) {
+               for (i = 0; i < p->gang_size; ++i) {
+                       if (p->jobs[i] == leader)
+                               continue;
+
                        dma_resv_add_fence(e->tv.bo->base.resv,
                                           &p->jobs[i]->base.s_fence->finished,
                                           DMA_RESV_USAGE_READ);
@@ -1286,7 +1295,7 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
                e->tv.num_shared = 0;
        }
 
-       seq = amdgpu_ctx_add_fence(p->ctx, p->entities[p->gang_size - 1],
+       seq = amdgpu_ctx_add_fence(p->ctx, p->entities[p->gang_leader_idx],
                                   p->fence);
        amdgpu_cs_post_dependencies(p);
 
index cbaa19b2b8a30b45bc11fc37135937a31cf9c77c..f80adf9069ecd5007938c0411d47f57c89f02fff 100644 (file)
@@ -54,6 +54,7 @@ struct amdgpu_cs_parser {
 
        /* scheduler job objects */
        unsigned int            gang_size;
+       unsigned int            gang_leader_idx;
        struct drm_sched_entity *entities[AMDGPU_CS_GANG_SIZE];
        struct amdgpu_job       *jobs[AMDGPU_CS_GANG_SIZE];
        struct amdgpu_job       *gang_leader;
index 3ea53bb67d3bdd316138c423925d24c72c1d1175..bd61e20770a5be20b8978be47a3ba2eaae0c3289 100644 (file)
 ssize_t drm_dp_dual_mode_read(struct i2c_adapter *adapter,
                              u8 offset, void *buffer, size_t size)
 {
+       u8 zero = 0;
+       char *tmpbuf = NULL;
+       /*
+        * As sub-addressing is not supported by all adaptors,
+        * always explicitly read from the start and discard
+        * any bytes that come before the requested offset.
+        * This way, no matter whether the adaptor supports it
+        * or not, we'll end up reading the proper data.
+        */
        struct i2c_msg msgs[] = {
                {
                        .addr = DP_DUAL_MODE_SLAVE_ADDRESS,
                        .flags = 0,
                        .len = 1,
-                       .buf = &offset,
+                       .buf = &zero,
                },
                {
                        .addr = DP_DUAL_MODE_SLAVE_ADDRESS,
                        .flags = I2C_M_RD,
-                       .len = size,
+                       .len = size + offset,
                        .buf = buffer,
                },
        };
        int ret;
 
+       if (offset) {
+               tmpbuf = kmalloc(size + offset, GFP_KERNEL);
+               if (!tmpbuf)
+                       return -ENOMEM;
+
+               msgs[1].buf = tmpbuf;
+       }
+
        ret = i2c_transfer(adapter, msgs, ARRAY_SIZE(msgs));
+       if (tmpbuf)
+               memcpy(buffer, tmpbuf + offset, size);
+
+       kfree(tmpbuf);
+
        if (ret < 0)
                return ret;
        if (ret != ARRAY_SIZE(msgs))
@@ -208,18 +230,6 @@ enum drm_dp_dual_mode_type drm_dp_dual_mode_detect(const struct drm_device *dev,
        if (ret)
                return DRM_DP_DUAL_MODE_UNKNOWN;
 
-       /*
-        * Sigh. Some (maybe all?) type 1 adaptors are broken and ack
-        * the offset but ignore it, and instead they just always return
-        * data from the start of the HDMI ID buffer. So for a broken
-        * type 1 HDMI adaptor a single byte read will always give us
-        * 0x44, and for a type 1 DVI adaptor it should give 0x00
-        * (assuming it implements any registers). Fortunately neither
-        * of those values will match the type 2 signature of the
-        * DP_DUAL_MODE_ADAPTOR_ID register so we can proceed with
-        * the type 2 adaptor detection safely even in the presence
-        * of broken type 1 adaptors.
-        */
        ret = drm_dp_dual_mode_read(adapter, DP_DUAL_MODE_ADAPTOR_ID,
                                    &adaptor_id, sizeof(adaptor_id));
        drm_dbg_kms(dev, "DP dual mode adaptor ID: %02x (err %zd)\n", adaptor_id, ret);
@@ -233,11 +243,10 @@ enum drm_dp_dual_mode_type drm_dp_dual_mode_detect(const struct drm_device *dev,
                                return DRM_DP_DUAL_MODE_TYPE2_DVI;
                }
                /*
-                * If neither a proper type 1 ID nor a broken type 1 adaptor
-                * as described above, assume type 1, but let the user know
-                * that we may have misdetected the type.
+                * If not a proper type 1 ID, still assume type 1, but let
+                * the user know that we may have misdetected the type.
                 */
-               if (!is_type1_adaptor(adaptor_id) && adaptor_id != hdmi_id[0])
+               if (!is_type1_adaptor(adaptor_id))
                        drm_err(dev, "Unexpected DP dual mode adaptor ID %02x\n", adaptor_id);
 
        }
@@ -343,10 +352,8 @@ EXPORT_SYMBOL(drm_dp_dual_mode_get_tmds_output);
  * @enable: enable (as opposed to disable) the TMDS output buffers
  *
  * Set the state of the TMDS output buffers in the adaptor. For
- * type2 this is set via the DP_DUAL_MODE_TMDS_OEN register. As
- * some type 1 adaptors have problems with registers (see comments
- * in drm_dp_dual_mode_detect()) we avoid touching the register,
- * making this function a no-op on type 1 adaptors.
+ * type2 this is set via the DP_DUAL_MODE_TMDS_OEN register.
+ * Type1 adaptors do not support any register writes.
  *
  * Returns:
  * 0 on success, negative error code on failure
index 8214a0b1ab7f18e52d6f58631897b67200d2c7f7..203bf8d6c34c4a5f9c015c602142868c8bf7052f 100644 (file)
@@ -615,7 +615,7 @@ static int drm_dev_init(struct drm_device *dev,
        mutex_init(&dev->clientlist_mutex);
        mutex_init(&dev->master_mutex);
 
-       ret = drmm_add_action(dev, drm_dev_init_release, NULL);
+       ret = drmm_add_action_or_reset(dev, drm_dev_init_release, NULL);
        if (ret)
                return ret;
 
index 7bb98e6a446d08311e9714536f7397bfc7511c7b..5ea5e260118c2f8c08e280cc2d5f20e368bbf4d2 100644 (file)
@@ -104,7 +104,8 @@ static inline void drm_vblank_flush_worker(struct drm_vblank_crtc *vblank)
 
 static inline void drm_vblank_destroy_worker(struct drm_vblank_crtc *vblank)
 {
-       kthread_destroy_worker(vblank->worker);
+       if (vblank->worker)
+               kthread_destroy_worker(vblank->worker);
 }
 
 int drm_vblank_worker_init(struct drm_vblank_crtc *vblank);
index 939d621c9ad4bf845391ad03c90d2fef9b307228..688c8afe0bf174af2430659b5c3b49ef825c0dc3 100644 (file)
@@ -151,9 +151,6 @@ int drm_mode_getresources(struct drm_device *dev, void *data,
        count = 0;
        connector_id = u64_to_user_ptr(card_res->connector_id_ptr);
        drm_for_each_connector_iter(connector, &conn_iter) {
-               if (connector->registration_state != DRM_CONNECTOR_REGISTERED)
-                       continue;
-
                /* only expose writeback connectors if userspace understands them */
                if (!file_priv->writeback_connectors &&
                    (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK))
index 011be7ff51e1aa44756d743e07417bc75fb55289..bc8fb4e38d0a7279cc038d086869f0345ca418da 100644 (file)
@@ -112,11 +112,6 @@ int lima_devfreq_init(struct lima_device *ldev)
        unsigned long cur_freq;
        int ret;
        const char *regulator_names[] = { "mali", NULL };
-       const char *clk_names[] = { "core", NULL };
-       struct dev_pm_opp_config config = {
-               .regulator_names = regulator_names,
-               .clk_names = clk_names,
-       };
 
        if (!device_property_present(dev, "operating-points-v2"))
                /* Optional, continue without devfreq */
@@ -124,7 +119,15 @@ int lima_devfreq_init(struct lima_device *ldev)
 
        spin_lock_init(&ldevfreq->lock);
 
-       ret = devm_pm_opp_set_config(dev, &config);
+       /*
+        * clkname is set separately so it is not affected by the optional
+        * regulator setting which may return error.
+        */
+       ret = devm_pm_opp_set_clkname(dev, "core");
+       if (ret)
+               return ret;
+
+       ret = devm_pm_opp_set_regulators(dev, regulator_names);
        if (ret) {
                /* Continue if the optional regulator is missing */
                if (ret != -ENODEV)
index 2944228a8e2c4e0666c745f2b032e3ea0f9bc400..8a3b685c2fcc05796d581a52dd19fd2a2b0665e0 100644 (file)
@@ -2500,6 +2500,7 @@ static const struct display_timing logictechno_lt161010_2nh_timing = {
 static const struct panel_desc logictechno_lt161010_2nh = {
        .timings = &logictechno_lt161010_2nh_timing,
        .num_timings = 1,
+       .bpc = 6,
        .size = {
                .width = 154,
                .height = 86,
@@ -2529,6 +2530,7 @@ static const struct display_timing logictechno_lt170410_2whc_timing = {
 static const struct panel_desc logictechno_lt170410_2whc = {
        .timings = &logictechno_lt170410_2whc_timing,
        .num_timings = 1,
+       .bpc = 8,
        .size = {
                .width = 217,
                .height = 136,
index 4419e810103de3e77525163226d7bbd7270d5b9b..0a6347c05df491f72546fedcf43766de10af3b42 100644 (file)
@@ -197,8 +197,8 @@ vc4_hvs_get_new_global_state(struct drm_atomic_state *state)
        struct drm_private_state *priv_state;
 
        priv_state = drm_atomic_get_new_private_obj_state(state, &vc4->hvs_channels);
-       if (IS_ERR(priv_state))
-               return ERR_CAST(priv_state);
+       if (!priv_state)
+               return ERR_PTR(-EINVAL);
 
        return to_vc4_hvs_state(priv_state);
 }
@@ -210,8 +210,8 @@ vc4_hvs_get_old_global_state(struct drm_atomic_state *state)
        struct drm_private_state *priv_state;
 
        priv_state = drm_atomic_get_old_private_obj_state(state, &vc4->hvs_channels);
-       if (IS_ERR(priv_state))
-               return ERR_CAST(priv_state);
+       if (!priv_state)
+               return ERR_PTR(-EINVAL);
 
        return to_vc4_hvs_state(priv_state);
 }