mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yongbang Shi <shiyongbang@huawei.com>
To: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Cc: <xinliang.liu@linaro.org>, <tiantao6@hisilicon.com>,
	<maarten.lankhorst@linux.intel.com>, <mripard@kernel.org>,
	<tzimmermann@suse.de>, <airlied@gmail.com>, <daniel@ffwll.ch>,
	<kong.kongxinwei@hisilicon.com>, <liangjian010@huawei.com>,
	<chenjianmin@huawei.com>, <fengsheng5@huawei.com>,
	<libaihan@huawei.com>, <shenjian15@huawei.com>,
	<shaojijie@huawei.com>, <jani.nikula@linux.intel.com>,
	<dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>,
	<shiyongbang@huawei.com>
Subject: Re: [PATCH v3 drm-dp 02/11] drm/hisilicon/hibmc: fix dp probabilistical detect errors after HPD irq
Date: Fri, 1 Aug 2025 17:21:17 +0800	[thread overview]
Message-ID: <31aaa735-9c46-4507-9289-171a5d80a149@huawei.com> (raw)
In-Reply-To: <f7co2accpkvt4b5jy7ar4j6jqiytmysd3ki32hvhg7w2ohqoo6@nwwxeif6f73q>


> On Fri, Jul 18, 2025 at 02:51:16PM +0800, Yongbang Shi wrote:
>> From: Baihan Li <libaihan@huawei.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@huawei.com>
>> Signed-off-by: Yongbang Shi <shiyongbang@huawei.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
>>

  reply	other threads:[~2025-08-01  9:21 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-18  6:51 [PATCH v3 drm-dp 00/11] Fix hibmc driver bugs Yongbang Shi
2025-07-18  6:51 ` [PATCH v3 drm-dp 01/11] drm/hisilicon/hibmc: fix the i2c device resource leak when vdac init failed Yongbang Shi
2025-07-18  6:51 ` [PATCH v3 drm-dp 02/11] drm/hisilicon/hibmc: fix dp probabilistical detect errors after HPD irq Yongbang Shi
2025-07-26 15:03   ` Dmitry Baryshkov
2025-08-01  9:21     ` Yongbang Shi [this message]
2025-07-18  6:51 ` [PATCH v3 drm-dp 03/11] drm/hisilicon/hibmc: fix irq_request()'s irq name variable is local Yongbang Shi
2025-07-18  6:51 ` [PATCH v3 drm-dp 04/11] drm/hisilicon/hibmc: fix the hibmc loaded failed bug Yongbang Shi
2025-07-18  6:51 ` [PATCH v3 drm-dp 05/11] drm/hisilicon/hibmc: fix rare monitors cannot display problem Yongbang Shi
2025-07-26 15:09   ` Dmitry Baryshkov
2025-08-01  9:22     ` Yongbang Shi
2025-07-18  6:51 ` [PATCH v3 drm-dp 06/11] drm/hisilicon/hibmc: add dp mode valid check Yongbang Shi
2025-07-26 15:56   ` Dmitry Baryshkov
2025-08-01  9:22     ` Yongbang Shi
2025-07-18  6:51 ` [PATCH v3 drm-dp 07/11] drm/hisilicon/hibmc: fix dp and vga cannot show together Yongbang Shi
2025-07-18  6:51 ` [PATCH v3 drm-dp 08/11] drm/hisilicon/hibmc: fix no showing when no connectors connected Yongbang Shi
2025-07-26 16:03   ` Dmitry Baryshkov
2025-08-01  9:24     ` Yongbang Shi
2025-07-18  6:51 ` [PATCH v3 drm-dp 09/11] drm/hisilicon/hibmc: fix no showing problem with loading hibmc manually Yongbang Shi
2025-07-26 16:04   ` Dmitry Baryshkov
2025-07-18  6:51 ` [PATCH v3 drm-dp 10/11] drm/hisilicon/hibmc: adapting modification for the former commit Yongbang Shi
2025-07-26 16:05   ` Dmitry Baryshkov
2025-08-01  9:25     ` Yongbang Shi
2025-07-18  6:51 ` [PATCH v3 drm-dp 11/11] drm/hisilicon/hibmc: " Yongbang Shi
2025-07-25  9:16 ` [PATCH v3 drm-dp 00/11] Fix hibmc driver bugs Yongbang Shi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=31aaa735-9c46-4507-9289-171a5d80a149@huawei.com \
    --to=shiyongbang@huawei.com \
    --cc=airlied@gmail.com \
    --cc=chenjianmin@huawei.com \
    --cc=daniel@ffwll.ch \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=fengsheng5@huawei.com \
    --cc=jani.nikula@linux.intel.com \
    --cc=kong.kongxinwei@hisilicon.com \
    --cc=liangjian010@huawei.com \
    --cc=libaihan@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=shaojijie@huawei.com \
    --cc=shenjian15@huawei.com \
    --cc=tiantao6@hisilicon.com \
    --cc=tzimmermann@suse.de \
    --cc=xinliang.liu@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®