Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4842782ybl; Tue, 4 Feb 2020 03:02:59 -0800 (PST) X-Google-Smtp-Source: APXvYqy0uAOfMAv6KK2dNNExxCNQ0EmsDo4O5RRArVNpQinVH3ve5nXDw3w6h6oBhlrWvpC2YVQm X-Received: by 2002:a9d:7f11:: with SMTP id j17mr22386805otq.281.1580814179529; Tue, 04 Feb 2020 03:02:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580814179; cv=none; d=google.com; s=arc-20160816; b=f11SGOMUXyJ1680y9FyjX8aMwFSG5wJD+I46Kme1264HXSx7uUwOM7BaLjxsm38/VB rWyaf6qHH+0FoeAAt3iH5JYYp0WOFptnKdoL0CK5emCkmQKwmE5uYbeREFdSbQKIWkme l4NsMTsfZlMYccSy2uJ6g1PScOT84STsE/UIIscWmXTcKPRkiR4SEXmVOE5nmlSIocTB gh3pYcgD4TybMCaC62IobeR3iJqbZtMm9oJVLXl53favGGSfU5lk5HlHtkK8pHTlgQEk sHFaqF65q8227H1jCcrd2IkoO5ZA7DgQLLW/HKLkdsb07rXe8RjtjCLcMDpZmvd/OxH0 latA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=aEabL2qRUn55z6lyX/Z+Th/5uhuWx8TzOkCmYLG9NR0=; b=cVpbZrKYUh0bTUZ+L5mkqL+ZvTaGUpxEi0IhpB0I1qu27+3PaEPBKn+qGiU05gqeAj k4al72g15dwz+HmS5tGQSiRobZHFbi0EbHc8MVlSGiZVD4Kwbdim08XUX0NTjFEemwh8 PMcxh9ERS/2rAdgbkFnMKHCqZx4a4IBGzYXkNqhgBsxdqo2NzhXNUaDkp5aIS5a4Dbck Go+yr9Wy3bf3dxvtGHTIvlnBhqOmBAVgPdWlJoDe4FzrPHW+qzzIr4HwvfzTQ8OzJ14l fydaQezLKe3F7cMQIb/sAyfwVqfFRbn4d1ROl7e7qnNgw0/+epx0lyHs3UytC/IXzufl jz6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="bAd/Qs1z"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b18si4588581otp.17.2020.02.04.03.02.45; Tue, 04 Feb 2020 03:02:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="bAd/Qs1z"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726975AbgBDLB2 (ORCPT + 99 others); Tue, 4 Feb 2020 06:01:28 -0500 Received: from mail-qt1-f194.google.com ([209.85.160.194]:40113 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726832AbgBDLB2 (ORCPT ); Tue, 4 Feb 2020 06:01:28 -0500 Received: by mail-qt1-f194.google.com with SMTP id v25so13949366qto.7 for ; Tue, 04 Feb 2020 03:01:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=aEabL2qRUn55z6lyX/Z+Th/5uhuWx8TzOkCmYLG9NR0=; b=bAd/Qs1zd6OYkFiCldTJkNTW2ygBCRZcODtrNNYGJJuAICh9W92ClTa8ZRuBmuIOAs To1rQRtdIgeW5suGCxPuijnvD2RTyhPieJyomszvrbn11hP5By947HNPKvhNQ4jb7+Xg fWZfTk08E0qMRKdpwvbZ9siEYCw3Oa4uSPEyXNvheXJgj4OcQi8ToP+iG448Z0mYBEFU +NLKeiYarVPOpEtZ3i2va2oP1qDcJlJ0DMRZ0djwTjTE2ZuK68HWyR5EzCk9M6bDdegX Y3yjoJSFyIQgmNUxEc333skJ2ZlGKSBgBiXDrtSa+glHbsBQp3QtEyMX8BuaUsJcalMk y1Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=aEabL2qRUn55z6lyX/Z+Th/5uhuWx8TzOkCmYLG9NR0=; b=iLQnGubRffhQXvUseETxFJPaQeg+c0KwBTip3dgbWG8aY7Ux1Q0WJPDwKZ4t72QyKC 9JnVbogKrBph2g1j8ysFOJEhrXJgQka920G20WYdVHkCRqtBZ/yYXhnTVURGO5RU3ct3 JSLeEFDUapnXwMMzVA9mfnEU/g+ehrpPaHVXtlxyZ1SCBOB9VFLkKeYl8+ShXugRFfvO ezixU8AJpYS77DkkYJpnzAfl2zfvziCgJZhWt8eRCitwk6zpf0DSHZkzWqhgronOICB/ yowN7arJt2Kk3EQCcZsAhHytdrCmaEKOap+9lAgfuNeaK6bhZO40MRBu8ky1rPmOZgRt BGjA== X-Gm-Message-State: APjAAAXlZU0LPA8ICfxTpTaJXVU6wDelMBhywgQueceDyUUVYLhTYxJy Kt8/BhNGyIxyFJmpd9lnNKgKGQv48KBCNzyLPNOC/A== X-Received: by 2002:ac8:42c6:: with SMTP id g6mr28287189qtm.250.1580814087238; Tue, 04 Feb 2020 03:01:27 -0800 (PST) MIME-Version: 1.0 References: <1579601673-7111-1-git-send-email-yannick.fertre@st.com> <882271f1-5b91-f4c9-4619-fbdb70a32a46@st.com> In-Reply-To: <882271f1-5b91-f4c9-4619-fbdb70a32a46@st.com> From: Benjamin Gaignard Date: Tue, 4 Feb 2020 12:01:16 +0100 Message-ID: Subject: Re: [PATCH] drm/stm: ltdc: check number of endpoints To: Philippe CORNU Cc: Yannick FERTRE , Benjamin GAIGNARD , David Airlie , Daniel Vetter , Maxime Coquelin , Alexandre TORGUE , "dri-devel@lists.freedesktop.org" , "linux-stm32@st-md-mailman.stormreply.com" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le jeu. 23 janv. 2020 =C3=A0 10:51, Philippe CORNU = a =C3=A9crit : > > Dear Yannick, > Thank you for your patch, > > Acked-by: Philippe Cornu > > Philippe :-) > > On 1/21/20 11:14 AM, Yannick Fertre wrote: > > Number of endpoints could exceed the fix value MAX_ENDPOINTS(2). > > Instead of increase simply this value, the number of endpoint > > could be read from device tree. Load sequence has been a little > > rework to take care of several panel or bridge which can be > > connected/disconnected or enable/disable. This patch doesn't apply on drm-misc-next. Yannick could you rebase is on top of drm-misc-next and resend it ? Thanks, Benjamin > > > > Signed-off-by: Yannick Fertr=C3=A9 > > --- > > drivers/gpu/drm/stm/ltdc.c | 104 ++++++++++++++++++++++--------------= --------- > > 1 file changed, 52 insertions(+), 52 deletions(-) > > > > diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c > > index c2815e8..dba8e7f 100644 > > --- a/drivers/gpu/drm/stm/ltdc.c > > +++ b/drivers/gpu/drm/stm/ltdc.c > > @@ -42,8 +42,6 @@ > > > > #define MAX_IRQ 4 > > > > -#define MAX_ENDPOINTS 2 > > - > > #define HWVER_10200 0x010200 > > #define HWVER_10300 0x010300 > > #define HWVER_20101 0x020101 > > @@ -1190,36 +1188,20 @@ int ltdc_load(struct drm_device *ddev) > > struct ltdc_device *ldev =3D ddev->dev_private; > > struct device *dev =3D ddev->dev; > > struct device_node *np =3D dev->of_node; > > - struct drm_bridge *bridge[MAX_ENDPOINTS] =3D {NULL}; > > - struct drm_panel *panel[MAX_ENDPOINTS] =3D {NULL}; > > + struct drm_bridge *bridge; > > + struct drm_panel *panel; > > struct drm_crtc *crtc; > > struct reset_control *rstc; > > struct resource *res; > > - int irq, ret, i, endpoint_not_ready =3D -ENODEV; > > + int irq, i, nb_endpoints; > > + int ret =3D -ENODEV; > > > > DRM_DEBUG_DRIVER("\n"); > > > > - /* Get endpoints if any */ > > - for (i =3D 0; i < MAX_ENDPOINTS; i++) { > > - ret =3D drm_of_find_panel_or_bridge(np, 0, i, &panel[i], > > - &bridge[i]); > > - > > - /* > > - * If at least one endpoint is -EPROBE_DEFER, defer probi= ng, > > - * else if at least one endpoint is ready, continue probi= ng. > > - */ > > - if (ret =3D=3D -EPROBE_DEFER) > > - return ret; > > - else if (!ret) > > - endpoint_not_ready =3D 0; > > - } > > - > > - if (endpoint_not_ready) > > - return endpoint_not_ready; > > - > > - rstc =3D devm_reset_control_get_exclusive(dev, NULL); > > - > > - mutex_init(&ldev->err_lock); > > + /* Get number of endpoints */ > > + nb_endpoints =3D of_graph_get_endpoint_count(np); > > + if (!nb_endpoints) > > + return -ENODEV; > > > > ldev->pixel_clk =3D devm_clk_get(dev, "lcd"); > > if (IS_ERR(ldev->pixel_clk)) { > > @@ -1233,6 +1215,43 @@ int ltdc_load(struct drm_device *ddev) > > return -ENODEV; > > } > > > > + /* Get endpoints if any */ > > + for (i =3D 0; i < nb_endpoints; i++) { > > + ret =3D drm_of_find_panel_or_bridge(np, 0, i, &panel, &br= idge); > > + > > + /* > > + * If at least one endpoint is -ENODEV, continue probing, > > + * else if at least one endpoint returned an error > > + * (ie -EPROBE_DEFER) then stop probing. > > + */ > > + if (ret =3D=3D -ENODEV) > > + continue; > > + else if (ret) > > + goto err; > > + > > + if (panel) { > > + bridge =3D drm_panel_bridge_add_typed(panel, > > + DRM_MODE_CONN= ECTOR_DPI); > > + if (IS_ERR(bridge)) { > > + DRM_ERROR("panel-bridge endpoint %d\n", i= ); > > + ret =3D PTR_ERR(bridge); > > + goto err; > > + } > > + } > > + > > + if (bridge) { > > + ret =3D ltdc_encoder_init(ddev, bridge); > > + if (ret) { > > + DRM_ERROR("init encoder endpoint %d\n", i= ); > > + goto err; > > + } > > + } > > + } > > + > > + rstc =3D devm_reset_control_get_exclusive(dev, NULL); > > + > > + mutex_init(&ldev->err_lock); > > + > > if (!IS_ERR(rstc)) { > > reset_control_assert(rstc); > > usleep_range(10, 20); > > @@ -1268,7 +1287,6 @@ int ltdc_load(struct drm_device *ddev) > > } > > } > > > > - > > ret =3D ltdc_get_caps(ddev); > > if (ret) { > > DRM_ERROR("hardware identifier (0x%08x) not supported!\n"= , > > @@ -1278,27 +1296,6 @@ int ltdc_load(struct drm_device *ddev) > > > > DRM_DEBUG_DRIVER("ltdc hw version 0x%08x\n", ldev->caps.hw_versio= n); > > > > - /* Add endpoints panels or bridges if any */ > > - for (i =3D 0; i < MAX_ENDPOINTS; i++) { > > - if (panel[i]) { > > - bridge[i] =3D drm_panel_bridge_add_typed(panel[i]= , > > - DRM_MODE_C= ONNECTOR_DPI); > > - if (IS_ERR(bridge[i])) { > > - DRM_ERROR("panel-bridge endpoint %d\n", i= ); > > - ret =3D PTR_ERR(bridge[i]); > > - goto err; > > - } > > - } > > - > > - if (bridge[i]) { > > - ret =3D ltdc_encoder_init(ddev, bridge[i]); > > - if (ret) { > > - DRM_ERROR("init encoder endpoint %d\n", i= ); > > - goto err; > > - } > > - } > > - } > > - > > crtc =3D devm_kzalloc(dev, sizeof(*crtc), GFP_KERNEL); > > if (!crtc) { > > DRM_ERROR("Failed to allocate crtc\n"); > > @@ -1331,8 +1328,8 @@ int ltdc_load(struct drm_device *ddev) > > > > return 0; > > err: > > - for (i =3D 0; i < MAX_ENDPOINTS; i++) > > - drm_panel_bridge_remove(bridge[i]); > > + for (i =3D 0; i < nb_endpoints; i++) > > + drm_of_panel_bridge_remove(ddev->dev->of_node, 0, i); > > > > clk_disable_unprepare(ldev->pixel_clk); > > > > @@ -1341,11 +1338,14 @@ int ltdc_load(struct drm_device *ddev) > > > > void ltdc_unload(struct drm_device *ddev) > > { > > - int i; > > + struct device *dev =3D ddev->dev; > > + int nb_endpoints, i; > > > > DRM_DEBUG_DRIVER("\n"); > > > > - for (i =3D 0; i < MAX_ENDPOINTS; i++) > > + nb_endpoints =3D of_graph_get_endpoint_count(dev->of_node); > > + > > + for (i =3D 0; i < nb_endpoints; i++) > > drm_of_panel_bridge_remove(ddev->dev->of_node, 0, i); > > > > pm_runtime_disable(ddev->dev); > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel