From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A0C131E7C24 for ; Wed, 5 Mar 2025 07:29:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741159768; cv=none; b=bcRHJm/uDH9PXmnvkPb2yrEWHlYXFNQpELc0cEQd8VHeqfnjVnHqNJC9OlLm4O+EoJ/6MnpNMpCK/ZHhY0Z1Zcz+Ue1jp7uL4ZOufaGbXspxYBobarmAPKaVaz46N0qc5+N/dK848VZjz8w5+wA63/Xxhj0kdPLJcGmtfSmbMck= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741159768; c=relaxed/simple; bh=dL91SWKnEZjOraH/5fYynpDNo7ylhpRiQrWVJ4bX2yU=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=cEvLPoPg+eFLPYFu/OonHubCdYqGt+yonpj4e//dUQqEZGFJT0ox1zEkylPsFLfb+i6CBjdL9ffkKaTFWeoemZ1+flYzLWVNFI8tDe5rHLI78uZfpo4pTlVg81fTTw6mS08BGSjhq6dsRNaidxYHih3WT++2O2+7JkYb4OmCsLo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Z73xB3NpGzvWqF; Wed, 5 Mar 2025 15:25:34 +0800 (CST) Received: from kwepemd500013.china.huawei.com (unknown [7.221.188.12]) by mail.maildlp.com (Postfix) with ESMTPS id E501A14022D; Wed, 5 Mar 2025 15:29:21 +0800 (CST) Received: from [10.159.166.136] (10.159.166.136) by kwepemd500013.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Wed, 5 Mar 2025 15:29:20 +0800 Message-ID: <3465ce51-a844-4c77-8e80-179d5ca279cc@huawei.com> Date: Wed, 5 Mar 2025 15:29:19 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 drm-dp 7/8] drm/hisilicon/hibmc: Enable this hot plug detect of irq feature To: Dmitry Baryshkov CC: , , , , , , , , , , , , , , , , References: <4hicem4rbz5l7wnzaaz3krrl3euh2dmvlah2rb7errrdq5fann@44dvdxirkuzh> <6506e448-3851-436f-9354-42f9ef844d27@huawei.com> <6e54c88f-dfaf-462d-b66b-c237d19faec6@huawei.com> From: Yongbang Shi In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemd500013.china.huawei.com (7.221.188.12) > On Tue, Mar 04, 2025 at 10:23:14AM +0800, Yongbang Shi wrote: >>> On Mon, Mar 03, 2025 at 01:02:44PM +0800, Yongbang Shi wrote: >>>>> On Sat, 1 Mar 2025 at 11:54, Yongbang Shi wrote: >>>>>>> On Sat, Mar 01, 2025 at 04:45:40PM +0800, Yongbang Shi wrote: >>>>>>>>> On Thu, Feb 27, 2025 at 09:46:10PM +0800, Yongbang Shi wrote: >>>>>>>>>>> On Tue, Feb 25, 2025 at 09:57:17PM +0800, Yongbang Shi wrote: >>>>>>>>>>>>> On Mon, 24 Feb 2025 at 16:03, Yongbang Shi wrote: >>>>>>>>>>>>>>> On Sat, Feb 22, 2025 at 06:35:48PM +0800, Yongbang Shi wrote: >>>>>>>>>>>>>>>>>> +static int hibmc_dp_hpd_event(struct drm_client_dev *client) >>>>>>>>>>>>>>>>>> +{ >>>>>>>>>>>>>>>>>> + struct hibmc_dp *dp = container_of(client, struct hibmc_dp, client); >>>>>>>>>>>>>>>>>> + struct hibmc_drm_private *priv = to_hibmc_drm_private(dp->drm_dev); >>>>>>>>>>>>>>>>>> + struct drm_display_mode *mode = &priv->crtc.state->adjusted_mode; >>>>>>>>>>>>>>>>>> + int ret; >>>>>>>>>>>>>>>>>> + >>>>>>>>>>>>>>>>>> + if (dp->hpd_status) { >>>>>>>>>>>>>>>>>> + hibmc_dp_hpd_cfg(&priv->dp); >>>>>>>>>>>>>>>>>> + ret = hibmc_dp_prepare(dp, mode); >>>>>>>>>>>>>>>>>> + if (ret) >>>>>>>>>>>>>>>>>> + return ret; >>>>>>>>>>>>>>>>>> + >>>>>>>>>>>>>>>>>> + hibmc_dp_display_en(dp, true); >>>>>>>>>>>>>>>>>> + } else { >>>>>>>>>>>>>>>>>> + hibmc_dp_display_en(dp, false); >>>>>>>>>>>>>>>>>> + hibmc_dp_reset_link(&priv->dp); >>>>>>>>>>>>>>>>>> + } >>>>>>>>>>>>>>>>> If I understand this correctly, you are using a separate drm_client to >>>>>>>>>>>>>>>>> enable and disable the link & display. Why is it necessary? Existing >>>>>>>>>>>>>>>>> drm_clients and userspace compositors use drm framework, they should be >>>>>>>>>>>>>>>>> able to turn the display on and off as required. >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Thanks for your asking, there are cfg/reset process when the connector 's pluging in/out. >>>>>>>>>>>>>>>> We want to cfg DP registers again when the connector changes. Not only dp link training, but also cfg >>>>>>>>>>>>>>>> the different video modes into DP registers. >>>>>>>>>>>>>>> Why? The link training and mode programming should happen during >>>>>>>>>>>>>>> pre_enable / enable stage (legacy or atomic). >>>>>>>>>>>>>> Hi Dmitry, >>>>>>>>>>>>>> >>>>>>>>>>>>>> Right, that's what I'm curious about. It won't call encoder enble/disable functions when I triggered HPD. >>>>>>>>>>>>>> And I'm sure the drm_connector_helper_hpd_irq_event() is called. So I add a drm_client for it.I >>>>>>>>>>>>> It should be userspace, who triggers the enable/disable (or it should >>>>>>>>>>>>> be the in-kernel fbdev / fbcon, which interface through the generic >>>>>>>>>>>>> drm_fbdev client). >>>>>>>>>>>> Right, I knew it. When I insmode my driver firstly (or restart display service), it will call disable, modeset and enable, >>>>>>>>>>>> by user, but it won't call when HPD triggered . >>>>>>>>>>> - Is HPD even properly delivered to userspace? What kind of compsitor >>>>>>>>>>> are you using? Is .detect working properly and reporting a correct >>>>>>>>>>> plug-in state? >>>>>>>>>> Thanks for your answering. I'm not very good understanding about userspace in framework. In my opinion, when I call >>>>>>>>>> this drm_connector_helper_hpd_irq_event(), the HPD will deliver to userspace. >>>>>>>>>> I use Xorg, and the display service is GDM. >>>>>>>>>> The .detect is called and the getting modes info is correct. >>>>>>>>>> I find that it would only trigger(disable, modeset and enable), when I changed resolutions, restart display service and insmod driver. >>>>>>>>> You can go to the display settings in GDM. It would be interesting to >>>>>>>>> observe if it notes the second monitor or not. Last, but not least, you >>>>>>>>> can use a simple tool like 'xrandr' under your XOrg session to set the >>>>>>>>> display resolution. >>>>>>>> Thank you for your advice! >>>>>>>> Right, there are DP and VGA two monitors. I tried to totally remove the vga connector in driver, the problem is gone. >>>>>>>> So do I need to clear the vga connector, if dp is plugged in? >>>>>>> Unless your hardware can not manage two outputs at the same time, no, >>>>>>> you don't have to. Just check how it behaves on x86 systems. Ideally >>>>>>> your driver should have the same behaviour. >>>>>> Our hardware cannot support two outputs with different timing, so I used the one crtc and one plane that DP and VGA share. And just add a new DP connector >>>>>> with a encoder, just like the previous VGA's code logic. But the HPD problem makes me feel confused, should I change the framwork structure to slove this problem? >>>>> I think registering a single CRTC is a correct way. Then it is logical >>>>> that there is no mode set on the DP when you connect it. The userspace >>>>> can not output any data. However if you disconnect VGA and connect DP >>>>> then it should become active and should output your desktop >>>>> environment. >>>> Okay, Thank you for your guidance. So I need to disconnect VGA when I get the HPD (plugged in) , then >>>> userapce will active and enanble DP, right? >>> Yes. >> I'm sorry for that, just wanna make sure one more thing. I found if I only set the VGA connector's status to disconnected when HPD plugged in, it won't be active. > Huh? You should implement hibmc_connector_funcs.detect() or > .detect_ctx() to report VGA connector's status. Use > ast_vga_connector_helper_detect_ctx() as an inspiration. Okay, thanks for your correcting, I'll try to add drm_connector_helper_detect_from_ddc() in VGA's detect_ctx. And also, I wanna make sure that do I need to unplug the VGA monitor manually when I plug in DP, or just set the status of VGA connector to disconnected in interrupt handler. >> And If I add drm_cleanup_connector() for VGA, it work. So is this okay that I use this cleanup in HPD? > drm_connector_cleanup() should only be callsed if the connector is going > to be destroyed. You should not be callign that function. > >> >>>>>> And also, I will check whether this driver works good on the x86 server. Right now, I'm testing on arm64 server. >>>>>> >>>>>>>> And also, I used xrandr to set modes after 'startx'. Changing resolutions works, >>>>>>>> but there are errs when set some low resolutions. >>>>>>> That's a separate topic, most likely related to timing or to some other >>>>>>> issues. You can fix that separately (but please do, switching modes >>>>>>> should work). >>>>>> Okay! >>>>>> >>>>>>