Message ID | 20240217183941.1752463-1-megi@xff.cz |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-70016-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp459819dyc; Sat, 17 Feb 2024 10:40:11 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUnmVFon5H3S4MXdGtJCUZufyGkRDSJwD79JjoXEDheLyUHAx4XVeOx6EzSHCb85eA8lpPXvjHWMbWpPcgtC/vvEjk5xw== X-Google-Smtp-Source: AGHT+IGi1Iz0ML7GBaC1ArPolRaRppPlK2xVDtqqyTjJl/Sl/OQEijm0SgowGy+fKg8HfHkOZQSf X-Received: by 2002:aa7:c491:0:b0:561:fe3f:695c with SMTP id m17-20020aa7c491000000b00561fe3f695cmr5048703edq.36.1708195211155; Sat, 17 Feb 2024 10:40:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708195211; cv=pass; d=google.com; s=arc-20160816; b=gQFEZBM9J6AvaQS296cYKGWUc3Qj+dKwhL3rt76Ij3w06vUXHGJs6Bpd38+2JE8oX4 2h5RS0Nqoxj9ozlnYhJa8hEpT77/2nZ253XPWKKW2gnYQ6whi+iJ84QqrKbBmaZ2arZh 651y57MK1ctrsPBsmviYV9I64vPDeKVzTjoeykRSf3RntnJqRroqjfJZ4dG6QnaXmbOQ hHUVU+QOv0LXCXNA3HMKSzNaxqU7Lu22YVLeSuxC6XURsKGrA11x2V3VmpiryBr3vhLw bzAvsSIEX1iPakBvI71/JB30sGWst2wkmOXZKDT8BZOHcoBwMp++NDce3y/iMBNiixpv kvBw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=WwhQYt8UVRR7Q+fcYwtUHkcV/rlUKtbcQwjgUjGu0SY=; fh=K/ZzRTF/PQ3C1bylR3z+17TS5qDhG8qPVnq0n479jhw=; b=IjFJ7qnQBabeZd0FqWOMG+4Cleny/0SzmZXh3pJoGhW1TJcpjJj/zxsEFhQgegh+Ed JG1vgK5HjLoVz3x8a6O4WldCDokXvC3GNcLJGSJE18gkWOQWd0N57o7MeLUEjDQuoxtj HGGreq3BVsK4zHook1Z3jV3CbIIRiU+r6DL9EVqe/G1PoGZnzybN80H3L0omqkuNR7ZF 4LzSyKWutDpDK4FT8jx1NnqGzPWDU81zY8pRSpAcXNJyBcy3i9ENGDG/bKTACCvd1DH/ o2H2iaUm0E+1639gjaAOkaKtQdLgnLi+gb8Q3FbfaHmgQvy+P5eeuAxnWz0ulVFEocg1 VBDg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=uvw3HgWW; arc=pass (i=1 spf=pass spfdomain=xff.cz dkim=pass dkdomain=xff.cz dmarc=pass fromdomain=xff.cz); spf=pass (google.com: domain of linux-kernel+bounces-70016-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70016-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id z25-20020aa7cf99000000b005640f8529d1si990065edx.288.2024.02.17.10.40.10 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 10:40:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70016-ouuuleilei=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=@xff.cz header.s=mail header.b=uvw3HgWW; arc=pass (i=1 spf=pass spfdomain=xff.cz dkim=pass dkdomain=xff.cz dmarc=pass fromdomain=xff.cz); spf=pass (google.com: domain of linux-kernel+bounces-70016-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70016-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz 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 8A02E1F231B3 for <ouuuleilei@gmail.com>; Sat, 17 Feb 2024 18:40:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 103757E119; Sat, 17 Feb 2024 18:39:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b="uvw3HgWW" Received: from vps.xff.cz (vps.xff.cz [195.181.215.36]) (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 8ED4A1D681 for <linux-kernel@vger.kernel.org>; Sat, 17 Feb 2024 18:39:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.181.215.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708195195; cv=none; b=BHS2yekYW1YqdzA4COUgKbgPuoi+6zGqblu7PYNil9aBa0fOdXn2ByQDoq+vwOd2r1lkUqPQl6wVlMg85sau68YD1uzEtSrOvO1JmNQ/HK/mHZvYXBELsqmi97B/aU6pqy7/v8bGcPrq7QJqzYZxi8NTcjERcyxOUQcWK0KljjY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708195195; c=relaxed/simple; bh=RGT4BBgnm1LR3lAuyD4pvnFiAKoTJKy/hJEE6iV4fGM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=CaR3M1D6CZBBqfntptrlpJpSZMoq+iW49I6XaRiXGqDD/CuPtb9X/XryZ7Q/PhfIylzAjmResPmt6dGk2iGFxyUvg6PkWQJpTUMeWPtoYCM/cavWSU29DKvV4oRd226qouhMDCOfvDHd1DK3AueZTtK01WCaKH8Kk8zdBWuGo68= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=xff.cz; spf=pass smtp.mailfrom=xff.cz; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b=uvw3HgWW; arc=none smtp.client-ip=195.181.215.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=xff.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xff.cz DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xff.cz; s=mail; t=1708195188; bh=RGT4BBgnm1LR3lAuyD4pvnFiAKoTJKy/hJEE6iV4fGM=; h=From:To:Cc:Subject:Date:From; b=uvw3HgWWmY7+Xkbi4vxj22xCzuVWwCZ39hTQkerpKso/6Ibs1WEJS6+0wQH1pQlGF OddB8sxShAxmi6ngu4OMAuvttfPFJotsZuSXhLlOm5AD6V+wU+BL3+SyC3eSg5S1JS QiStiQtoBi5I88joo1223xC97L8PRTi8hW263ePA= From: =?utf-8?q?Ond=C5=99ej_Jirman?= <megi@xff.cz> To: linux-kernel@vger.kernel.org Cc: Ondrej Jirman <megi@xff.cz>, Sandy Huang <hjc@rock-chips.com>, =?utf-8?q?Heiko_St=C3=BCbner?= <heiko@sntech.de>, Andy Yan <andy.yan@rock-chips.com>, Maarten Lankhorst <maarten.lankhorst@linux.intel.com>, Maxime Ripard <mripard@kernel.org>, Thomas Zimmermann <tzimmermann@suse.de>, David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>, dri-devel@lists.freedesktop.org (open list:DRM DRIVERS FOR ROCKCHIP), linux-arm-kernel@lists.infradead.org (moderated list:ARM/Rockchip SoC support), linux-rockchip@lists.infradead.org (open list:ARM/Rockchip SoC support) Subject: [PATCH] drm: rockchip: Don't require MIPI DSI device when it's used for ISP Date: Sat, 17 Feb 2024 19:39:40 +0100 Message-ID: <20240217183941.1752463-1-megi@xff.cz> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791172501785732697 X-GMAIL-MSGID: 1791172501785732697 |
Series |
drm: rockchip: Don't require MIPI DSI device when it's used for ISP
|
|
Commit Message
Ondřej Jirman
Feb. 17, 2024, 6:39 p.m. UTC
From: Ondrej Jirman <megi@xff.cz> On RK3399 one MIPI DSI device can be alternatively used with the ISP1, to provide RX DPHY. When this is the case (ISP1 is enabled in device tree), probe success of DRM is tied to probe success of ISP1 connected camera sensor. This can fail if the user is able to killswitch the camera power, like on Pinephone Pro. Detect use of MIPI DSI controller by ISP, and don't include it in component match list in that case. Signed-off-by: Ondrej Jirman <megi@xff.cz> --- drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 47 +++++++++++++++++++++ 1 file changed, 47 insertions(+)
Comments
Hi, On 2/18/24 02:39, Ondřej Jirman wrote: > From: Ondrej Jirman <megi@xff.cz> > > On RK3399 one MIPI DSI device can be alternatively used with the ISP1, > to provide RX DPHY. When this is the case (ISP1 is enabled in device > tree), probe success of DRM is tied to probe success of ISP1 connected > camera sensor. This can fail if the user is able to killswitch the camera > power, like on Pinephone Pro. > > Detect use of MIPI DSI controller by ISP, and don't include it in > component match list in that case. > Isn't this supposed to be taken care of within the dts? Since DPHY1 should exclusively used by MIPI DSI1 and ISP1, then if a device want to use ISP1, the DSI1 should be disabled in dts. > Signed-off-by: Ondrej Jirman <megi@xff.cz> > --- > drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 47 +++++++++++++++++++++ > 1 file changed, 47 insertions(+) > > diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c > index ab55d7132550..f47de94ad576 100644 > --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c > +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c > @@ -354,6 +354,43 @@ static void rockchip_drm_match_remove(struct device *dev) > device_link_del(link); > } > > +/* > + * Check if ISP block linked to a mipi-dsi device via phys phandle is > + * enabled in device tree. > + */ > +static bool rockchip_drm_is_mipi1_and_used_by_isp(struct device *dev) > +{ > + struct device_node *np = NULL, *phy_np; > + > + if (!of_device_is_compatible(dev->of_node, "rockchip,rk3399-mipi-dsi")) > + return false; > + > + while (true) { > + np = of_find_compatible_node(np, NULL, "rockchip,rk3399-cif-isp"); > + if (!np) > + break; > + > + if (!of_device_is_available(np)) { > + of_node_put(np); > + continue; > + } > + > + phy_np = of_parse_phandle(np, "phys", 0); > + if (!phy_np) { > + of_node_put(np); > + continue; > + } > + > + of_node_put(phy_np); > + of_node_put(np); > + > + if (phy_np == dev->of_node) > + return true; > + } > + > + return false; > +} > + > static struct component_match *rockchip_drm_match_add(struct device *dev) > { > struct component_match *match = NULL; > @@ -371,6 +408,16 @@ static struct component_match *rockchip_drm_match_add(struct device *dev) > if (!d) > break; > > + /* > + * If mipi1 is connected to ISP, we don't want to wait for mipi1 component, > + * because it will not be used by DRM anyway, to not tie success of camera > + * driver probe to display pipeline initialization. > + */ > + if (rockchip_drm_is_mipi1_and_used_by_isp(d)) { > + dev_info(d, "used by ISP1, skipping from DRM\n"); > + continue; > + } > + > device_link_add(dev, d, DL_FLAG_STATELESS); > component_match_add(dev, &match, component_compare_dev, d); > } while (true);
Hi Andy, On Sun, Feb 18, 2024 at 07:14:56PM +0800, Andy Yan wrote: > Hi, > > On 2/18/24 02:39, Ondřej Jirman wrote: > > From: Ondrej Jirman <megi@xff.cz> > > > > On RK3399 one MIPI DSI device can be alternatively used with the ISP1, > > to provide RX DPHY. When this is the case (ISP1 is enabled in device > > tree), probe success of DRM is tied to probe success of ISP1 connected > > camera sensor. This can fail if the user is able to killswitch the camera > > power, like on Pinephone Pro. > > > > Detect use of MIPI DSI controller by ISP, and don't include it in > > component match list in that case. > > > > Isn't this supposed to be taken care of within the dts? > Since DPHY1 should exclusively used by MIPI DSI1 and ISP1, then if > a device want to use ISP1, the DSI1 should be disabled in dts. DSI1 can't be disabled, because it provides PHY device for ISP1 in this scenario. The problem is that in this scenario DRM keeps waiting for DSI1 device, despite it just being used for PHY for ISP1 and not as a component for rockchip DRM driver. See: isp1: isp1@ff920000 { compatible = "rockchip,rk3399-cif-isp"; reg = <0x0 0xff920000 0x0 0x4000>; interrupts = <GIC_SPI 44 IRQ_TYPE_LEVEL_HIGH 0>; clocks = <&cru SCLK_ISP1>, <&cru ACLK_ISP1_WRAPPER>, <&cru HCLK_ISP1_WRAPPER>; clock-names = "isp", "aclk", "hclk"; iommus = <&isp1_mmu>; phys = <&mipi_dsi1>; <--------- phy-names = "dphy"; power-domains = <&power RK3399_PD_ISP1>; status = "disabled"; If mipi_dsi1 is disabled, isp1 will never probe. It's a consequence of this special dual use of mipi_dsi1. kind regards, o. > > Signed-off-by: Ondrej Jirman <megi@xff.cz> > > --- > > drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 47 +++++++++++++++++++++ > > 1 file changed, 47 insertions(+) > > > > diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c > > index ab55d7132550..f47de94ad576 100644 > > --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c > > +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c > > @@ -354,6 +354,43 @@ static void rockchip_drm_match_remove(struct device *dev) > > device_link_del(link); > > } > > +/* > > + * Check if ISP block linked to a mipi-dsi device via phys phandle is > > + * enabled in device tree. > > + */ > > +static bool rockchip_drm_is_mipi1_and_used_by_isp(struct device *dev) > > +{ > > + struct device_node *np = NULL, *phy_np; > > + > > + if (!of_device_is_compatible(dev->of_node, "rockchip,rk3399-mipi-dsi")) > > + return false; > > + > > + while (true) { > > + np = of_find_compatible_node(np, NULL, "rockchip,rk3399-cif-isp"); > > + if (!np) > > + break; > > + > > + if (!of_device_is_available(np)) { > > + of_node_put(np); > > + continue; > > + } > > + > > + phy_np = of_parse_phandle(np, "phys", 0); > > + if (!phy_np) { > > + of_node_put(np); > > + continue; > > + } > > + > > + of_node_put(phy_np); > > + of_node_put(np); > > + > > + if (phy_np == dev->of_node) > > + return true; > > + } > > + > > + return false; > > +} > > + > > static struct component_match *rockchip_drm_match_add(struct device *dev) > > { > > struct component_match *match = NULL; > > @@ -371,6 +408,16 @@ static struct component_match *rockchip_drm_match_add(struct device *dev) > > if (!d) > > break; > > + /* > > + * If mipi1 is connected to ISP, we don't want to wait for mipi1 component, > > + * because it will not be used by DRM anyway, to not tie success of camera > > + * driver probe to display pipeline initialization. > > + */ > > + if (rockchip_drm_is_mipi1_and_used_by_isp(d)) { > > + dev_info(d, "used by ISP1, skipping from DRM\n"); > > + continue; > > + } > > + > > device_link_add(dev, d, DL_FLAG_STATELESS); > > component_match_add(dev, &match, component_compare_dev, d); > > } while (true);
Hi Ondrej: On 2/18/24 23:17, Ondřej Jirman wrote: > Hi Andy, > > On Sun, Feb 18, 2024 at 07:14:56PM +0800, Andy Yan wrote: >> Hi, >> >> On 2/18/24 02:39, Ondřej Jirman wrote: >>> From: Ondrej Jirman <megi@xff.cz> >>> >>> On RK3399 one MIPI DSI device can be alternatively used with the ISP1, >>> to provide RX DPHY. When this is the case (ISP1 is enabled in device >>> tree), probe success of DRM is tied to probe success of ISP1 connected >>> camera sensor. This can fail if the user is able to killswitch the camera >>> power, like on Pinephone Pro. >>> >>> Detect use of MIPI DSI controller by ISP, and don't include it in >>> component match list in that case. >>> >> >> Isn't this supposed to be taken care of within the dts? >> Since DPHY1 should exclusively used by MIPI DSI1 and ISP1, then if >> a device want to use ISP1, the DSI1 should be disabled in dts. > > DSI1 can't be disabled, because it provides PHY device for ISP1 in this > scenario. > > The problem is that in this scenario DRM keeps waiting for DSI1 device, > despite it just being used for PHY for ISP1 and not as a component for > rockchip DRM driver. Oh, get it. With a quick look, seems that Heiko has already take this scenario into consideration when add PHY function in the dsi drivers[0] Does this mean the current drivers does not work as expected? [0]https://patchwork.freedesktop.org/patch/420386/ > > See: > > isp1: isp1@ff920000 { > compatible = "rockchip,rk3399-cif-isp"; > reg = <0x0 0xff920000 0x0 0x4000>; > interrupts = <GIC_SPI 44 IRQ_TYPE_LEVEL_HIGH 0>; > clocks = <&cru SCLK_ISP1>, > <&cru ACLK_ISP1_WRAPPER>, > <&cru HCLK_ISP1_WRAPPER>; > clock-names = "isp", "aclk", "hclk"; > iommus = <&isp1_mmu>; > phys = <&mipi_dsi1>; <--------- > phy-names = "dphy"; > power-domains = <&power RK3399_PD_ISP1>; > status = "disabled"; > > If mipi_dsi1 is disabled, isp1 will never probe. > > It's a consequence of this special dual use of mipi_dsi1. > > kind regards, > o. > >>> Signed-off-by: Ondrej Jirman <megi@xff.cz> >>> --- >>> drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 47 +++++++++++++++++++++ >>> 1 file changed, 47 insertions(+) >>> >>> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c >>> index ab55d7132550..f47de94ad576 100644 >>> --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c >>> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c >>> @@ -354,6 +354,43 @@ static void rockchip_drm_match_remove(struct device *dev) >>> device_link_del(link); >>> } >>> +/* >>> + * Check if ISP block linked to a mipi-dsi device via phys phandle is >>> + * enabled in device tree. >>> + */ >>> +static bool rockchip_drm_is_mipi1_and_used_by_isp(struct device *dev) >>> +{ >>> + struct device_node *np = NULL, *phy_np; >>> + >>> + if (!of_device_is_compatible(dev->of_node, "rockchip,rk3399-mipi-dsi")) >>> + return false; >>> + >>> + while (true) { >>> + np = of_find_compatible_node(np, NULL, "rockchip,rk3399-cif-isp"); >>> + if (!np) >>> + break; >>> + >>> + if (!of_device_is_available(np)) { >>> + of_node_put(np); >>> + continue; >>> + } >>> + >>> + phy_np = of_parse_phandle(np, "phys", 0); >>> + if (!phy_np) { >>> + of_node_put(np); >>> + continue; >>> + } >>> + >>> + of_node_put(phy_np); >>> + of_node_put(np); >>> + >>> + if (phy_np == dev->of_node) >>> + return true; >>> + } >>> + >>> + return false; >>> +} >>> + >>> static struct component_match *rockchip_drm_match_add(struct device *dev) >>> { >>> struct component_match *match = NULL; >>> @@ -371,6 +408,16 @@ static struct component_match *rockchip_drm_match_add(struct device *dev) >>> if (!d) >>> break; >>> + /* >>> + * If mipi1 is connected to ISP, we don't want to wait for mipi1 component, >>> + * because it will not be used by DRM anyway, to not tie success of camera >>> + * driver probe to display pipeline initialization. >>> + */ >>> + if (rockchip_drm_is_mipi1_and_used_by_isp(d)) { >>> + dev_info(d, "used by ISP1, skipping from DRM\n"); >>> + continue; >>> + } >>> + >>> device_link_add(dev, d, DL_FLAG_STATELESS); >>> component_match_add(dev, &match, component_compare_dev, d); >>> } while (true);
On Mon, Feb 19, 2024 at 11:02:01AM +0800, Andy Yan wrote: > Hi Ondrej: > > On 2/18/24 23:17, Ondřej Jirman wrote: > > Hi Andy, > > > > On Sun, Feb 18, 2024 at 07:14:56PM +0800, Andy Yan wrote: > > > Hi, > > > > > > On 2/18/24 02:39, Ondřej Jirman wrote: > > > > From: Ondrej Jirman <megi@xff.cz> > > > > > > > > On RK3399 one MIPI DSI device can be alternatively used with the ISP1, > > > > to provide RX DPHY. When this is the case (ISP1 is enabled in device > > > > tree), probe success of DRM is tied to probe success of ISP1 connected > > > > camera sensor. This can fail if the user is able to killswitch the camera > > > > power, like on Pinephone Pro. > > > > > > > > Detect use of MIPI DSI controller by ISP, and don't include it in > > > > component match list in that case. > > > > > > > > > > Isn't this supposed to be taken care of within the dts? > > > Since DPHY1 should exclusively used by MIPI DSI1 and ISP1, then if > > > a device want to use ISP1, the DSI1 should be disabled in dts. > > > > DSI1 can't be disabled, because it provides PHY device for ISP1 in this > > scenario. > > > > The problem is that in this scenario DRM keeps waiting for DSI1 device, > > despite it just being used for PHY for ISP1 and not as a component for > > rockchip DRM driver. > > > Oh, get it. > With a quick look, seems that Heiko has already take this scenario into consideration > when add PHY function in the dsi drivers[0] > Does this mean the current drivers does not work as expected? It didn't work anymore since some fw devlink changes that were added some time after 2021. But it might have got resolved since than. So please ignore this patch for now. kind regards, o. > [0]https://patchwork.freedesktop.org/patch/420386/ > > > > See: > > > > isp1: isp1@ff920000 { > > compatible = "rockchip,rk3399-cif-isp"; > > reg = <0x0 0xff920000 0x0 0x4000>; > > interrupts = <GIC_SPI 44 IRQ_TYPE_LEVEL_HIGH 0>; > > clocks = <&cru SCLK_ISP1>, > > <&cru ACLK_ISP1_WRAPPER>, > > <&cru HCLK_ISP1_WRAPPER>; > > clock-names = "isp", "aclk", "hclk"; > > iommus = <&isp1_mmu>; > > phys = <&mipi_dsi1>; <--------- > > phy-names = "dphy"; > > power-domains = <&power RK3399_PD_ISP1>; > > status = "disabled"; > > > > If mipi_dsi1 is disabled, isp1 will never probe. > > > > It's a consequence of this special dual use of mipi_dsi1. > > > > kind regards, > > o. > > > > > > Signed-off-by: Ondrej Jirman <megi@xff.cz> > > > > --- > > > > drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 47 +++++++++++++++++++++ > > > > 1 file changed, 47 insertions(+) > > > > > > > > diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c > > > > index ab55d7132550..f47de94ad576 100644 > > > > --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c > > > > +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c > > > > @@ -354,6 +354,43 @@ static void rockchip_drm_match_remove(struct device *dev) > > > > device_link_del(link); > > > > } > > > > +/* > > > > + * Check if ISP block linked to a mipi-dsi device via phys phandle is > > > > + * enabled in device tree. > > > > + */ > > > > +static bool rockchip_drm_is_mipi1_and_used_by_isp(struct device *dev) > > > > +{ > > > > + struct device_node *np = NULL, *phy_np; > > > > + > > > > + if (!of_device_is_compatible(dev->of_node, "rockchip,rk3399-mipi-dsi")) > > > > + return false; > > > > + > > > > + while (true) { > > > > + np = of_find_compatible_node(np, NULL, "rockchip,rk3399-cif-isp"); > > > > + if (!np) > > > > + break; > > > > + > > > > + if (!of_device_is_available(np)) { > > > > + of_node_put(np); > > > > + continue; > > > > + } > > > > + > > > > + phy_np = of_parse_phandle(np, "phys", 0); > > > > + if (!phy_np) { > > > > + of_node_put(np); > > > > + continue; > > > > + } > > > > + > > > > + of_node_put(phy_np); > > > > + of_node_put(np); > > > > + > > > > + if (phy_np == dev->of_node) > > > > + return true; > > > > + } > > > > + > > > > + return false; > > > > +} > > > > + > > > > static struct component_match *rockchip_drm_match_add(struct device *dev) > > > > { > > > > struct component_match *match = NULL; > > > > @@ -371,6 +408,16 @@ static struct component_match *rockchip_drm_match_add(struct device *dev) > > > > if (!d) > > > > break; > > > > + /* > > > > + * If mipi1 is connected to ISP, we don't want to wait for mipi1 component, > > > > + * because it will not be used by DRM anyway, to not tie success of camera > > > > + * driver probe to display pipeline initialization. > > > > + */ > > > > + if (rockchip_drm_is_mipi1_and_used_by_isp(d)) { > > > > + dev_info(d, "used by ISP1, skipping from DRM\n"); > > > > + continue; > > > > + } > > > > + > > > > device_link_add(dev, d, DL_FLAG_STATELESS); > > > > component_match_add(dev, &match, component_compare_dev, d); > > > > } while (true);
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c index ab55d7132550..f47de94ad576 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c @@ -354,6 +354,43 @@ static void rockchip_drm_match_remove(struct device *dev) device_link_del(link); } +/* + * Check if ISP block linked to a mipi-dsi device via phys phandle is + * enabled in device tree. + */ +static bool rockchip_drm_is_mipi1_and_used_by_isp(struct device *dev) +{ + struct device_node *np = NULL, *phy_np; + + if (!of_device_is_compatible(dev->of_node, "rockchip,rk3399-mipi-dsi")) + return false; + + while (true) { + np = of_find_compatible_node(np, NULL, "rockchip,rk3399-cif-isp"); + if (!np) + break; + + if (!of_device_is_available(np)) { + of_node_put(np); + continue; + } + + phy_np = of_parse_phandle(np, "phys", 0); + if (!phy_np) { + of_node_put(np); + continue; + } + + of_node_put(phy_np); + of_node_put(np); + + if (phy_np == dev->of_node) + return true; + } + + return false; +} + static struct component_match *rockchip_drm_match_add(struct device *dev) { struct component_match *match = NULL; @@ -371,6 +408,16 @@ static struct component_match *rockchip_drm_match_add(struct device *dev) if (!d) break; + /* + * If mipi1 is connected to ISP, we don't want to wait for mipi1 component, + * because it will not be used by DRM anyway, to not tie success of camera + * driver probe to display pipeline initialization. + */ + if (rockchip_drm_is_mipi1_and_used_by_isp(d)) { + dev_info(d, "used by ISP1, skipping from DRM\n"); + continue; + } + device_link_add(dev, d, DL_FLAG_STATELESS); component_match_add(dev, &match, component_compare_dev, d); } while (true);