[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <31aaa735-9c46-4507-9289-171a5d80a149@huawei.com>
Date: Fri, 1 Aug 2025 17:21:17 +0800
From: Yongbang Shi <shiyongbang@...wei.com>
To: Dmitry Baryshkov <dmitry.baryshkov@....qualcomm.com>
CC: <xinliang.liu@...aro.org>, <tiantao6@...ilicon.com>,
<maarten.lankhorst@...ux.intel.com>, <mripard@...nel.org>,
<tzimmermann@...e.de>, <airlied@...il.com>, <daniel@...ll.ch>,
<kong.kongxinwei@...ilicon.com>, <liangjian010@...wei.com>,
<chenjianmin@...wei.com>, <fengsheng5@...wei.com>, <libaihan@...wei.com>,
<shenjian15@...wei.com>, <shaojijie@...wei.com>,
<jani.nikula@...ux.intel.com>, <dri-devel@...ts.freedesktop.org>,
<linux-kernel@...r.kernel.org>, <shiyongbang@...wei.com>
Subject: Re: [PATCH v3 drm-dp 02/11] drm/hisilicon/hibmc: fix dp
probabilistical detect errors after HPD irq
> On Fri, Jul 18, 2025 at 02:51:16PM +0800, Yongbang Shi wrote:
>> From: Baihan Li <libaihan@...wei.com>
>>
>> The debouncing when HPD pulled out still remains sometimes, 200ms still can
>> not ensure helper_detect() is correct. Add hibmc_dp_detect_link() in
>> detect_ctx(), which is to try dp link training.
> I'm not sure if I follow the commit message. Anyway, link training
> should be a part of atomic_(pre)_enable, not a detect_ctx.
Okay, I will change it. thanks for your advice!
The problem is that when I unpluged the connector, sometimes the drm_connector_helper_detect_from_ddc()
return connected in dp's detect_ctx().
>> Fixes: 3c7623fb5bb6 ("drm/hisilicon/hibmc: Enable this hot plug detect of irq feature")
>> Signed-off-by: Baihan Li <libaihan@...wei.com>
>> Signed-off-by: Yongbang Shi <shiyongbang@...wei.com>
>> ---
>> drivers/gpu/drm/hisilicon/hibmc/dp/dp_hw.c | 27 +++++++++++++++----
>> drivers/gpu/drm/hisilicon/hibmc/dp/dp_hw.h | 2 ++
>> .../gpu/drm/hisilicon/hibmc/hibmc_drm_dp.c | 10 ++++---
>> 3 files changed, 30 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/hisilicon/hibmc/dp/dp_hw.c b/drivers/gpu/drm/hisilicon/hibmc/dp/dp_hw.c
>> index 8f0daec7d174..2d2fb6e759c3 100644
>> --- a/drivers/gpu/drm/hisilicon/hibmc/dp/dp_hw.c
>> +++ b/drivers/gpu/drm/hisilicon/hibmc/dp/dp_hw.c
>> @@ -3,6 +3,7 @@
>>
>> #include <linux/io.h>
>> #include <linux/delay.h>
>> +#include <drm/drm_managed.h>
>> #include "dp_config.h"
>> #include "dp_comm.h"
>> #include "dp_reg.h"
>> @@ -162,6 +163,8 @@ int hibmc_dp_hw_init(struct hibmc_dp *dp)
>>
>> mutex_init(&dp_dev->lock);
>>
>> + drmm_mutex_init(drm_dev, &dp->link_train_mutex);
>> +
>> dp->dp_dev = dp_dev;
>>
>> dp_dev->dev = drm_dev;
>> @@ -238,19 +241,33 @@ void hibmc_dp_display_en(struct hibmc_dp *dp, bool enable)
>> msleep(50);
>> }
>>
>> -int hibmc_dp_mode_set(struct hibmc_dp *dp, struct drm_display_mode *mode)
>> +int hibmc_dp_detect_link(struct hibmc_dp *dp)
>> {
>> struct hibmc_dp_dev *dp_dev = dp->dp_dev;
>> - int ret;
>> + int ret = 0;
>> +
>> + mutex_lock(&dp->link_train_mutex);
>>
>> if (!dp_dev->link.status.channel_equalized) {
>> ret = hibmc_dp_link_training(dp_dev);
>> - if (ret) {
>> + if (ret)
>> drm_err(dp->drm_dev, "dp link training failed, ret: %d\n", ret);
>> - return ret;
>> - }
>> }
>>
>> + mutex_unlock(&dp->link_train_mutex);
>> +
>> + return ret;
>> +}
>> +
>> +int hibmc_dp_mode_set(struct hibmc_dp *dp, struct drm_display_mode *mode)
>> +{
>> + struct hibmc_dp_dev *dp_dev = dp->dp_dev;
>> + int ret;
>> +
>> + ret = hibmc_dp_detect_link(dp);
>> + if (ret)
>> + return ret;
>> +
>> hibmc_dp_display_en(dp, false);
>> hibmc_dp_link_cfg(dp_dev, mode);
>>
>> diff --git a/drivers/gpu/drm/hisilicon/hibmc/dp/dp_hw.h b/drivers/gpu/drm/hisilicon/hibmc/dp/dp_hw.h
>> index 665f5b166dfb..9b45e88e47e4 100644
>> --- a/drivers/gpu/drm/hisilicon/hibmc/dp/dp_hw.h
>> +++ b/drivers/gpu/drm/hisilicon/hibmc/dp/dp_hw.h
>> @@ -50,9 +50,11 @@ struct hibmc_dp {
>> struct drm_dp_aux aux;
>> struct hibmc_dp_cbar_cfg cfg;
>> u32 irq_status;
>> + struct mutex link_train_mutex; /* link training mutex */
>> };
>>
>> int hibmc_dp_hw_init(struct hibmc_dp *dp);
>> +int hibmc_dp_detect_link(struct hibmc_dp *dp);
>> int hibmc_dp_mode_set(struct hibmc_dp *dp, struct drm_display_mode *mode);
>> void hibmc_dp_display_en(struct hibmc_dp *dp, bool enable);
>> void hibmc_dp_set_cbar(struct hibmc_dp *dp, const struct hibmc_dp_cbar_cfg *cfg);
>> diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_dp.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_dp.c
>> index d06832e62e96..354e18bb2998 100644
>> --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_dp.c
>> +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_dp.c
>> @@ -34,9 +34,12 @@ static int hibmc_dp_connector_get_modes(struct drm_connector *connector)
>> static int hibmc_dp_detect(struct drm_connector *connector,
>> struct drm_modeset_acquire_ctx *ctx, bool force)
>> {
>> - mdelay(200);
>> + struct hibmc_drm_private *priv = to_hibmc_drm_private(connector->dev);
>>
>> - return drm_connector_helper_detect_from_ddc(connector, ctx, force);
>> + if (!hibmc_dp_detect_link(&priv->dp))
>> + return connector_status_connected;
>> +
>> + return connector_status_disconnected;
>> }
>>
>> static const struct drm_connector_helper_funcs hibmc_dp_conn_helper_funcs = {
>> @@ -128,8 +131,7 @@ irqreturn_t hibmc_dp_hpd_isr(int irq, void *arg)
>> hibmc_dp_reset_link(&priv->dp);
>> }
>>
>> - if (dev->registered)
>> - drm_connector_helper_hpd_irq_event(&priv->dp.connector);
>> + drm_connector_helper_hpd_irq_event(&priv->dp.connector);
>>
>> drm_dev_exit(idx);
>>
>> --
>> 2.33.0
>>
Powered by blists - more mailing lists