Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1184454lqp; Fri, 22 Mar 2024 07:50:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVtMmWPTEFB7+vc/aEE8NylsC1HSsRJMfRfHwIV3E61x/8/K5uVuDC//7MAsnxv85QcuHiBcJVc7CrH8NNLWJe2x8N6GMet2pNDeSBnhA== X-Google-Smtp-Source: AGHT+IHTayo8VA1W4gDKAimw9e8FH8BXYUec13Qu3hHqvkE4J6IOKjMWaQcY9WCIYMdCp/USzy9P X-Received: by 2002:a17:906:57d6:b0:a47:31c8:81f5 with SMTP id u22-20020a17090657d600b00a4731c881f5mr1299633ejr.47.1711119052051; Fri, 22 Mar 2024 07:50:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711119052; cv=pass; d=google.com; s=arc-20160816; b=zAR//XnyF/ze93S8U5HKjAfXFGBi0i7cPG8QPTUwCFRrkEj8TcyeOsOwmY9kwpBduu +kcJQ9G7j1qIFwJr1ElIbQpMUVbnho67oPttOLNTBdmIJwItxDP5VpX/Z3lfkvDmnCLM kZ0VEvv+8S5YjS3T660SsC0uA3lWjVnJBv5ztkMXE33Pc1z7ii++0o/hxzXBhPlivAfu lRxrPIbRbNCrwnlVJaPD7wFXI9K1Esa6s2RPLlZ5FdApH0nVulxB8RGM+q5D/Xzajpb6 rPuV+OoXpwdXK4q0Z/PlWO0UFBgAOe7Bu8hND0UHdDSM4NROl+jo2UeLhqu2oouDYCsj Es4w== 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=xOjzipgBiJTcHiIGzKfcwrF5y6PFP6qN/2US1X8P970=; fh=Q+aCsR1VRH9f6E+ZWTfCZ3+2CGee2eOEe3vT80sopto=; b=SdD02cdZ9GCdrhgERyrDEXW9K6IQQRCfmrdXhFtauzR6AQTMYu0WLuxVVzVh+a7umA 2w0F/SWtTqMsdiTsQSFkZze9iueHeAtmX3oOb89k0m5zj4QQOeBx7PhlnNfYtaZn4Zv7 RjwM5erqprGOm1IzzDFarj/l4z4rF/DOFiX0Jx4y4M4sxla85OI6J0zicTE4llHdZ2bR KA8/B+pek9kqdqrFzDrGyAF5au2IiP3JpWhzW7iPFtE02p2NnmgrD+o/hvAyuzj20/1k adODcCCvFufohYPIc/FvMnyj9s6Fgfb334AxJQt2jdXzihgHojUuyUIN/Qpx+CQ0yKug ZTaQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="vllKlS3/"; 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-111650-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111650-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id c16-20020a170906341000b00a46eaf7cff2si999596ejb.853.2024.03.22.07.50.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 07:50:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-111650-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="vllKlS3/"; 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-111650-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111650-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 92DB41F212F3 for ; Fri, 22 Mar 2024 14:50:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 601FE4AEC3; Fri, 22 Mar 2024 14:50:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="vllKlS3/" Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) (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 7A78A487BE for ; Fri, 22 Mar 2024 14:50:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711119042; cv=none; b=PgyKET1+OC3YOHHAdiO+91qKn/sZnJZ+AeCM3pLknm6ZE5PVzZuMFyaUbOZ6xNmD2kqJf0OqOq8dOZ2A7R+1ZQ/cJpOiulAEWE9SIc+4mRqfF+8pKGUUVGxqMpRdGmKF6eWmyqChTUanwTAMyZ6qAqngYTlp9o32jaLPsPVbNqg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711119042; c=relaxed/simple; bh=JeKVlRNsd5JdTk2RGk+ZVjcfLwsCqMGanl0BnUS12TE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qJoidHZ8AjW9QS6nvSVXArvnqgjAo/wZpnd+xYRF/EjGCIZpEmn7DjchyaxU3meOpu/7c5qTWTxl8coHc3KYtoc2YFA8K/a4OYhgWvyTmZG56P4M5ynjfWDI3uEEbBvniTwXc8dmdMQkLNjtT1O6Ny1mvmR8evskHqCHE25b2Tc= 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=vllKlS3/; arc=none smtp.client-ip=209.85.208.43 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-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-56be32b9775so961758a12.1 for ; Fri, 22 Mar 2024 07:50:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711119039; x=1711723839; 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=xOjzipgBiJTcHiIGzKfcwrF5y6PFP6qN/2US1X8P970=; b=vllKlS3/328EZs/VD2+WyKzDcZQ/ZY+9RxQDam4Vjw9e4PNgwnxLmCDG8zeosnw/Yp 5Q3hU3hC8KP36chFklf7dNXbnGIYXYhUIYDK+Raxg5NDGUKNXuZ7OtXMOKZ8X83cJdz3 pF9BrMgdNhG9JtS57InCvYF2i3Ab+KGw0SCB8obzS2LpBksLwgamQDxAUJ2OCh8dwC2A JNKOITLshjAFGgU+oE58wy08rFaAt1u9Bf2Mmj6z/3SEgro2hz7lhB5/qtvPMCxxYkoj xTGxLhVo8wf4rWeUCVXI/4P9SWvHr2SUv0zdeFOwBMJDpTUfvkPSAPeosv/bbAl6OnU7 +HSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711119039; x=1711723839; 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=xOjzipgBiJTcHiIGzKfcwrF5y6PFP6qN/2US1X8P970=; b=SiO2zFOYmfdrnypx7jNqxyCVae5vu4Mg03eBRnDtFBDXG1HV7dGTZiS/eg6RRoqEc7 rEtAzG7EUfBcbY5EVOH8wpWyXcRaWza6l+AQ69qBQs0RyT0LWFh/1ZWAxjQwJ1QpOlpU VVmDCvhsxMwIgmyzzHIfr8daBa0iuOPWlfGLBCkQ2SS+83dx0vfuJeC7/rMXICZb06G0 9TFQ3Gqgxk4QaXYoZ4ev3es5D0ojN3emSF64S9TUFeWG8ftwi7ABtLNBKJC2REDUlgPK tRBxDSAsWEzctCqk3a5uKQABwA6TlCP+fEEMH04911fsai0J/YQBpaNzpHcAGc+8Ovpe 5ajQ== X-Forwarded-Encrypted: i=1; AJvYcCX9PI1TCpbOVj8jDWTkU6bT4w5ZYiXgUcqNI3A9hKKgmwdbxSvButFp5NawGBtIRTr2ZVjjsXDwLHVnAJSutG6GOefnkfierqgkFqvd X-Gm-Message-State: AOJu0YybQVJwheanj2WwakGM1S4iVM8GpyCT36AkhXyk6dzd13LkfmeR Ua1MNkvM+W1futfcrOWpog16lqmbLcOy+9V6lpzLJHzEIhPkFKanGmYu747D4DI= X-Received: by 2002:a17:907:119b:b0:a47:935:f9c6 with SMTP id uz27-20020a170907119b00b00a470935f9c6mr1637941ejb.22.1711119038485; Fri, 22 Mar 2024 07:50:38 -0700 (PDT) Received: from linaro.org ([79.114.172.194]) by smtp.gmail.com with ESMTPSA id oz27-20020a170906cd1b00b00a473490aae8sm522081ejb.24.2024.03.22.07.50.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 07:50:38 -0700 (PDT) Date: Fri, 22 Mar 2024 16:50:36 +0200 From: Abel Vesa To: Bjorn Andersson Cc: Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , David Airlie , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kuogee Hsieh , Konrad Dybcio , Johan Hovold , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 1/2] drm/msm/dp: Add support for determining the eDP/DP mode from DT Message-ID: References: <20240322-x1e80100-display-refactor-connector-v3-0-af14c29af665@linaro.org> <20240322-x1e80100-display-refactor-connector-v3-1-af14c29af665@linaro.org> 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: On 24-03-22 09:30:21, Bjorn Andersson wrote: > On Fri, Mar 22, 2024 at 03:22:22PM +0200, Abel Vesa wrote: > > Instead of relying on different compatibles for eDP and DP, lookup > > the panel node in devicetree to figure out the connector type and > > then pass on that information to the PHY. External DP is not described > > in DT, therefore, assume it's eDP if panel node is present. > > > > Signed-off-by: Abel Vesa > > --- > > drivers/gpu/drm/msm/dp/dp_display.c | 43 +++++++++++++++++++++++++++++++++---- > > 1 file changed, 39 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c > > index c4cb82af5c2f..c9763f77c832 100644 > > --- a/drivers/gpu/drm/msm/dp/dp_display.c > > +++ b/drivers/gpu/drm/msm/dp/dp_display.c > > @@ -726,6 +726,14 @@ static int dp_init_sub_modules(struct dp_display_private *dp) > > if (IS_ERR(phy)) > > return PTR_ERR(phy); > > > > + rc = phy_set_mode_ext(phy, PHY_MODE_DP, > > + dp->dp_display.is_edp ? PHY_SUBMODE_EDP : PHY_SUBMODE_DP); > > + if (rc) { > > + DRM_ERROR("failed to set phy submode, rc = %d\n", rc); > > + dp->catalog = NULL; > > + goto error; > > + } > > + > > dp->catalog = dp_catalog_get(dev); > > if (IS_ERR(dp->catalog)) { > > rc = PTR_ERR(dp->catalog); > > @@ -734,9 +742,7 @@ static int dp_init_sub_modules(struct dp_display_private *dp) > > goto error; > > } > > > > - dp->aux = dp_aux_get(dev, dp->catalog, > > - phy, > > - dp->dp_display.is_edp); > > + dp->aux = dp_aux_get(dev, dp->catalog, phy, dp->dp_display.is_edp); > > if (IS_ERR(dp->aux)) { > > rc = PTR_ERR(dp->aux); > > DRM_ERROR("failed to initialize aux, rc = %d\n", rc); > > @@ -1241,6 +1247,35 @@ static int dp_auxbus_done_probe(struct drm_dp_aux *aux) > > return dp_display_probe_tail(aux->dev); > > } > > > > +static int dp_display_get_connector_type(struct platform_device *pdev, > > + const struct msm_dp_desc *desc) > > +{ > > + struct device *dev = &pdev->dev; > > + struct device_node *aux_bus; > > + struct device_node *panel; > > + int ret = DRM_MODE_CONNECTOR_DisplayPort; > > + > > + /* legacy platforms specify connector type in match data */ > > + if (desc->connector_type == DRM_MODE_CONNECTOR_eDP || > > + desc->connector_type == DRM_MODE_CONNECTOR_DisplayPort) > > + return desc->connector_type; > > + > > + aux_bus = of_get_child_by_name(dev->of_node, "aux-bus"); > > + if (!aux_bus) > > + goto out; > > My compiler warns that if we take this code path, then you will > of_node_put() below. > > > + > > + panel = of_get_child_by_name(aux_bus, "panel"); > > + if (!panel) > > + goto out; > > + > > + ret = DRM_MODE_CONNECTOR_eDP; > > My brain read this function as: > check something > if (error) > bailout! > > check something > if (error) > bailout! > > ret should be edp > > I then have to scan the code again to figure out what ret is otherwise, > and convince myself that the error path is never an error, but a totally > normal case. > > > If you instead rely on the fact that both of_get_child_by_name() and > of_node_put() can be passed NULL, you can write this as: > > static int fn(..) { > aux_bus = of_get_child_by_name(dev->of_node, "aux-bus"); > panel = of_get_child_by_name(aux_bus, "panel"); > > if (panel) > connector_type = DRM_MODE_CONNECTOR_eDP; > else > connector_type = DRM_MODE_CONNECTOR_DisplayPort; > > of_node_put(panel); > of_node_put(aux_bus); > > return connector_type; > } > > Much easier to read, and you don't even have to zero-initialize panel to > avoid that compiler warning. > Fair enough, will do that instead. > Regards, > Bjorn > > > + > > +out: > > + of_node_put(panel); > > + of_node_put(aux_bus); > > + return ret; > > +} > > + > > static int dp_display_probe(struct platform_device *pdev) > > { > > int rc = 0; > > @@ -1263,7 +1298,7 @@ static int dp_display_probe(struct platform_device *pdev) > > dp->dp_display.pdev = pdev; > > dp->name = "drm_dp"; > > dp->id = desc->id; > > - dp->dp_display.connector_type = desc->connector_type; > > + dp->dp_display.connector_type = dp_display_get_connector_type(pdev, desc); > > dp->wide_bus_supported = desc->wide_bus_supported; > > dp->dp_display.is_edp = > > (dp->dp_display.connector_type == DRM_MODE_CONNECTOR_eDP); > > > > -- > > 2.34.1 > >