Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp201737lqe; Fri, 5 Apr 2024 19:15:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWcs4myYRH1BZVqWi1dhGtb6PaNrj4Sb2AzuIxyNrRWmA2bmmGPRf5+2F3UBSP/ed8RMqE5IGl2RUsc7zgqj6dUaMPG8iuWMHntrP4U6A== X-Google-Smtp-Source: AGHT+IFWKQffKuJhsNx8ZgGTeoSu1jjw6LfYAy0f1bBjQLklhOd7VWxXkukbkXaKlaOmXvQj29uK X-Received: by 2002:a05:622a:1aa6:b0:432:e7ae:16ec with SMTP id s38-20020a05622a1aa600b00432e7ae16ecmr3337911qtc.43.1712369720776; Fri, 05 Apr 2024 19:15:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712369720; cv=pass; d=google.com; s=arc-20160816; b=C4wil4lBWSzOaXSV58vsPra/jti38GGqiTMkv4/ZjDR+5K2YZCo60L9Ozxx1Djf+4G 0UL/Tqibo6hdmmNBQbXEJw85nV8BTt1vC3i5UsIcaEWxoqUyo68dPIE+2VWor2cc3guZ yhCf5MzErXkUM2qtWR2W8BDK+3lQf28PmsEEJXMCaoxGjf0qm+RpuW9quQcVt5mSrrDg nF8FIaEKW88hCbI4YZXpVqw1fqt6N2ykW10BExRvzJfFhU1y+oociGfR+wCQ/OllINJT WsIcCvYo4G0cYefoelgcDm1LEOxLGcxQ5lRnhmaWynURmEVO8EIzGWmfrnkhwhwzc3fE HQQg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=XhDrNzBi3oiG43zRalXwXnBhsTSPwZRL2FZ33nSnVdw=; fh=xO3mwtIpapNeLM3EQFFnRmGAA/30GPWt7VHQZ+GDd5U=; b=ZdO/dwUapJdlu8zC8G8duk/UsMOa/h+5GL2Grfc00KwFHfuBGiDlOkAnWM6v5K3N8D zi7ni4zeENchxAvjpJImrrJUD8j8eR6gW+862+7v3pAkp28tKvGTC6hGL1asVQFnmtMV Qt3R9yXtQrZdJ/EJUwXTrLZMJysTNFE1VMfcXiP1m/MnXSKZpbiDyDT+rWQbdRSrqlyr GCMlwLtou44oe9eNXDxI8i8bp6bWJoX8kiRpW97yNf1Vmu+70Y2uQ4PfrzxjzaU0PC1e uxhW3kWJB3vI2Ug0itKeWST3+F6kBxn/rH1C0gjGeddCP6vRUIMHgL2kglxSsoHLLx03 G65Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vVkSe1Ex; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-133770-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133770-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id v8-20020a05622a014800b00432093a43bdsi3269750qtw.53.2024.04.05.19.15.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 19:15:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-133770-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vVkSe1Ex; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-133770-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133770-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 726831C20BD3 for ; Sat, 6 Apr 2024 02:15:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 53268125DC; Sat, 6 Apr 2024 02:15:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="vVkSe1Ex" Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 52BA3F4FB for ; Sat, 6 Apr 2024 02:15:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712369711; cv=none; b=IgNbQWF7fHsxn6RST0xpbDYlLd9cBGFTw+ju/8DCOV88dXrXjbBdpoDhrqMXskA0cddPaXCzrh944R2zhUTgifSwCQzDCUpX4XT43/XD507nO8CLVf6NjDrxoxXHYOCG626WLZV+y7jINOlqbnOTFkosssJOs75YowABHN/Yqec= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712369711; c=relaxed/simple; bh=O4/3HNR38idF4BH2OJeB+ylGTsLaPdApSICTUeXxz8A=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=M8kB90rthkwnE7jJI341/g8k6MYXWO2gBZcWwqRSKuOSE/5Djk/81RP7Ahbl/+2CxWuU30AGiSjgqgsUsTdGs8x5DCb5JbC9I43AWpHWvAbFbnWPvzWEZ6hpOhLbM0WURlgMzsMht6v7nxmbZuPXVmU/tGDAQJdJNayTfhw3P44= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=vVkSe1Ex; arc=none smtp.client-ip=209.85.208.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-lj1-f181.google.com with SMTP id 38308e7fff4ca-2d094bc2244so28779201fa.1 for ; Fri, 05 Apr 2024 19:15:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712369707; x=1712974507; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=XhDrNzBi3oiG43zRalXwXnBhsTSPwZRL2FZ33nSnVdw=; b=vVkSe1ExgSBDXWEjv1pgOhnsCaJaOjAodNHf+3A6nH/eva2zDxhMYfzFqJH/ERxNCT luLcbspMCSCPfgEuTtqBGNacmE7LkM8d0SxfqtDHTaco0ob6iQQyTUcEqTzVn0cAngmX EwpDurmKQqFlUm+3hXbn4vh1LHiEidYMoVacTHv5M8/BtsJe+OeZhEAtFaq2y1Xv8/AL yyeVrflFjsP59FZ+oarcdJgJQetGtXw9cVr3Lnnl9zrW72Y5ELmHdjtysD9YgTGkWKqz dwcKm717YOIRwnXaJ0M+b0tQVEAFkhlQyg9idBBcARpVBs/7xwJdjldNQGUSOLSlllZS OjFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712369707; x=1712974507; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=XhDrNzBi3oiG43zRalXwXnBhsTSPwZRL2FZ33nSnVdw=; b=oellSfLpK6i2/GbyQ3nzZL/1hEAeHL8iZhNEG/CZWTwQUciZ9Bg7OHNdhDZHWn2n04 kTs2RDGEX0UDl/1QyIkiMKT0fw4JBylQ+93lr+phNx0qkciXMU9ZbmBUhShX59Xq1Ulz L+Nh9UaMcoXcISCTKR+vBAJ7+KtoxxfANZuN9TL5udiNXVVGZxzLLKSI4zXkmmuG8EDn 6aw3wfe4ubT9viuf2vrEHqIhmYEzwTVcAz9HfjjDXj+H8t1IL1I1QJ6rd34qcxa9cz6N cT9la0SeQIatC9TkWFvUCWKSrryft3SSc0l2XjlTQdxLd95u+xs8cNjRN0/Rzwpkvk7e pwQw== X-Forwarded-Encrypted: i=1; AJvYcCUqEH1UNoREEZnZ1qolJdAHC/N/MkKWhDoLI/p7wBZMBEODs2yXfh/ceWD5I6dhAqVhf52c++mLBcqr8ujUTCfSwJz9RooE56sv6ICA X-Gm-Message-State: AOJu0YyfpN12dsYiuAxJ56T6rfKLnadprJn0XzgDK0IAjeOnEwWf5ZCs 2GEMmTRezErIrVbbCIo+C67Zi4rmjQH5xFsiY4f/eH40AZiYVV3CgTJ1jwv38TA= X-Received: by 2002:a2e:7219:0:b0:2d8:6a04:6ac4 with SMTP id n25-20020a2e7219000000b002d86a046ac4mr2399047ljc.28.1712369707253; Fri, 05 Apr 2024 19:15:07 -0700 (PDT) Received: from eriador.lumag.spb.ru (dzyjmhyyyyyyyyyyyykxt-3.rev.dnainternet.fi. [2001:14ba:a00e:a300::227]) by smtp.gmail.com with ESMTPSA id f16-20020a2eb5b0000000b002d816c0500asm333494ljn.118.2024.04.05.19.15.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 19:15:06 -0700 (PDT) Date: Sat, 6 Apr 2024 05:15:04 +0300 From: Dmitry Baryshkov To: Abhinav Kumar Cc: freedreno@lists.freedesktop.org, Rob Clark , Sean Paul , Marijn Suijten , David Airlie , Daniel Vetter , Bjorn Andersson , Kuogee Hsieh , dri-devel@lists.freedesktop.org, seanpaul@chromium.org, swboyd@chromium.org, quic_jesszhan@quicinc.com, quic_bjorande@quicinc.com, johan@kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] drm/msm/dp: call dp_hpd_plug_handle()/unplug_handle() directly for external HPD Message-ID: References: <20240406001715.8181-1-quic_abhinavk@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240406001715.8181-1-quic_abhinavk@quicinc.com> On Fri, Apr 05, 2024 at 05:17:14PM -0700, Abhinav Kumar wrote: > From: Kuogee Hsieh > > In the external HPD case, hotplug event is delivered by pmic glink to DP driver > using drm_aux_hpd_bridge_notify(). There can be other drivers in front of the DP chain. For example, altmode driver uses drm_connector_oob_hotplug_event() to deliver HPD events. > > The stacktrace showing the sequence of events is below: > > dp_bridge_hpd_notify+0x18/0x70 [msm] > drm_bridge_connector_detect+0x60/0xe8 [drm_kms_helper] > drm_helper_probe_detect+0x94/0xc0 [drm_kms_helper] > drm_helper_probe_single_connector_modes+0x43c/0x53c [drm_kms_helper] > drm_client_modeset_probe+0x240/0x1114 [drm] > drm_fb_helper_hotplug_event.part.26+0x9c/0xe8 [drm_kms_helper] > drm_fb_helper_hotplug_event+0x24/0x38 [drm_kms_helper] > msm_fbdev_client_hotplug+0x24/0xd4 [msm] > drm_client_dev_hotplug+0xd8/0x148 [drm] > drm_kms_helper_connector_hotplug_event+0x30/0x3c [drm_kms_helper] > drm_bridge_connector_handle_hpd+0x84/0x94 [drm_kms_helper] > drm_bridge_connector_hpd_cb+0xc/0x14 [drm_kms_helper] > drm_bridge_hpd_notify+0x38/0x50 [drm] > drm_aux_hpd_bridge_notify+0x14/0x20 [aux_hpd_bridge] > pmic_glink_altmode_worker+0xec/0x27c [pmic_glink_altmode] > process_scheduled_works+0x17c/0x2cc > worker_thread+0x2ac/0x2d0 > kthread+0xfc/0x120 > > There are three notifications delivered to DP driver for each notification event. > > 1) From the drm_aux_hpd_bridge_notify() itself as shown above > > 2) From output_poll_execute() thread which arises due to > drm_helper_probe_single_connector_modes() call of the above stacktrace > as shown in more detail here. > > dp_bridge_hpd_notify+0x18/0x70 [msm] > drm_bridge_connector_detect+0x60/0xe8 [drm_kms_helper] > drm_helper_probe_detect+0x94/0xc0 [drm_kms_helper] > drm_helper_probe_single_connector_modes+0x43c/0x53c [drm_kms_helper] > drm_client_modeset_probe+0x240/0x1114 [drm] > drm_fb_helper_hotplug_event.part.26+0x9c/0xe8 [drm_kms_helper] > drm_fb_helper_hotplug_event+0x24/0x38 [drm_kms_helper] > msm_fbdev_client_hotplug+0x24/0xd4 [msm] > drm_client_dev_hotplug+0xd8/0x148 [drm] > drm_kms_helper_hotplug_event+0x30/0x3c [drm_kms_helper] > output_poll_execute+0xe0/0x210 [drm_kms_helper] > > 3) From the DP driver as the dp_bridge_hpd_notify() callback today triggers > the hpd_event_thread for connect and disconnect events respectively via below stack > > dp_bridge_hpd_notify+0x18/0x70 [msm] > drm_bridge_connector_detect+0x60/0xe8 [drm_kms_helper] > drm_helper_probe_detect_ctx+0x98/0x110 [drm_kms_helper] > check_connector_changed+0x4c/0x20c [drm_kms_helper] > drm_helper_hpd_irq_event+0x98/0x120 [drm_kms_helper] > hpd_event_thread+0x478/0x5bc [msm] > > We have to address why we end up with 3 events for every single event so something > is broken with how we work with the drm_bridge_connector. > > But, the dp_bridge_hpd_notify() delivered from output_poll_execute() thread will > return the incorrect HPD status DP driver because the .detect() returns the value > of link_ready and not the HPD status currently. > > And because the HPD event thread has not run yet and this results in the two complementary > events. > > To fix this problem lets have dp_bridge_hpd_notify() call > dp_hpd_plug_handle/unplug_handle() directly instead of going through the > event thread. > > Then the following .detect() called by drm_kms_helper_connector_hotplug_event() > will return correct value of HPD status since it uses the correct link_ready value. > > With this change, the HPD status delivered by both drm_bridge_connector_hpd_notify() > and drm_kms_helper_connector_hotplug_event() will match each other consistently. Please take a look at Documentation/process/submitting-patches.rst With the commit message fixed, the change LGTM. Thanks a lot for describing the call chains leading to this issue. I must admit, initially I thought that the change should be rejected on a basis of being a band-aid, but after studying the call graphs and the locking within the DP driver, the change looks correct to me. > > changes in v2: > - Fix the commit message to explain the scenario > - Fix the subject a little as well > > Fixes: 542b37efc20e ("drm/msm/dp: Implement hpd_notify()") > Signed-off-by: Kuogee Hsieh > Signed-off-by: Abhinav Kumar > --- > drivers/gpu/drm/msm/dp/dp_display.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c > index d80f89581760..dfb10584ff97 100644 > --- a/drivers/gpu/drm/msm/dp/dp_display.c > +++ b/drivers/gpu/drm/msm/dp/dp_display.c > @@ -1665,7 +1665,8 @@ void dp_bridge_hpd_notify(struct drm_bridge *bridge, > return; > > if (!dp_display->link_ready && status == connector_status_connected) > - dp_add_event(dp, EV_HPD_PLUG_INT, 0, 0); > + dp_hpd_plug_handle(dp, 0); > else if (dp_display->link_ready && status == connector_status_disconnected) > - dp_add_event(dp, EV_HPD_UNPLUG_INT, 0, 0); > + dp_hpd_unplug_handle(dp, 0); > + > } > -- > 2.43.2 > -- With best wishes Dmitry