From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752148AbdGRUNI (ORCPT ); Tue, 18 Jul 2017 16:13:08 -0400 Received: from anholt.net ([50.246.234.109]:49908 "EHLO anholt.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751602AbdGRUNH (ORCPT ); Tue, 18 Jul 2017 16:13:07 -0400 From: Eric Anholt To: Archit Taneja , dri-devel@lists.freedesktop.org, Andrzej Hajda , Laurent Pinchart , Thierry Reding Cc: linux-kernel@vger.kernel.org, Boris Brezillon Subject: Re: [PATCH 6/8] drm: Allow DSI devices to be registered before the host registers. In-Reply-To: References: <20170627195839.3338-1-eric@anholt.net> <20170627195839.3338-7-eric@anholt.net> <6fbaa797-1040-48e8-c361-dad4363cd30d@codeaurora.org> <87vamu7hi4.fsf@eliezer.anholt.net> User-Agent: Notmuch/0.22.2+1~gb0bcfaa (http://notmuchmail.org) Emacs/24.5.1 (x86_64-pc-linux-gnu) Date: Tue, 18 Jul 2017 13:13:04 -0700 Message-ID: <87mv81bj1r.fsf@eliezer.anholt.net> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Archit Taneja writes: > On 07/15/2017 04:28 AM, Eric Anholt wrote: >> Archit Taneja writes: >>=20 >>> On 06/28/2017 01:28 AM, Eric Anholt wrote: >>>> When a mipi_dsi_host is registered, the DT is walked to find any child >>>> nodes with compatible strings. Those get registered as DSI devices, >>>> and most DSI panel drivers are mipi_dsi_drivers that attach to those n= odes. >>>> >>>> There is one special case currently, the adv7533 bridge, where the >>>> bridge probes on I2C, and during the bridge attach step it looks up >>>> the mipi_dsi_host and registers the mipi_dsi_device (for its own stub >>>> mipi_dsi_driver). >>>> >>>> For the Raspberry Pi panel, though, we also need to attach on I2C (our >>>> control bus), but don't have a bridge driver. The lack of a bridge's >>>> attach() step like adv7533 uses means that we aren't able to delay the >>>> mipi_dsi_device creation until the mipi_dsi_host is present. >>>> >>>> To fix this, we extend mipi_dsi_device_register_full() to allow being >>>> called with a NULL host, which puts the device on a queue waiting for >>>> a host to appear. When a new host is registered, we fill in the host >>>> value and finish the device creation process. >>> >>> This is quite a nice idea. The only bothering thing is the info.of_node= usage >>> varies between child nodes (mipi_dsi_devs) and non-child nodes (i2c con= trol >>> bus). >>> >>> For DSI children expressed in DT, the of_node in info holds the DT node >>> corresponding to the DSI child itself. For non-DT ones, this patch assu= mes >>> that info.of_node stores the DSI host DT node. I think it should be oka= y as >>> long as we mention the usage in a comment somewhere. The other option i= s to >>> have a new info.host_node field to keep a track of the host DT node. >>=20 >> I think maybe you misread the patch? We're using >> of_get_parent(dsi->dev.node), which came from info->node, to compare to >> host->dev->of_node(). > > I think I did misread it. > > Although, I'm not entirely clear what we should be setting info.node to. > In patch #8, info.node is set by: > > endpoint =3D of_graph_get_next_endpoint(dev->of_node, NULL); > info.node =3D of_graph_get_remote_port(endpoint); > > Looking at the dt bindings in patch #7, it looks like info.node is set > to the 'port' device node in dsi@7e700000, is that right? Yeah. > I suppose 'port' here seems like a reasonable representation of > dsi->dev.node, I wonder how it would work if the dsi host had multiple > ports underneath it. I.e: > > dsi@7e700000 { > ... > ... > ports { > port@0 { > ... > dsi_out_port: endpoint { > remote-endpoint =3D <&panel_dsi_port>; > }; > }; > port@1 { > ... > ... > }; > }; > }; > > Here, we would need to set info.node to the 'ports' node, so that > of_get_parent(dsi->dev.of_node) equals host->dev->of_node. That doesn't > seem correct. > > Ideally, a dev's 'of_node' should be left to NULL if we don't have a > corresponding OF node. We're sort of overriding it here since we don't > have any other place to store this information in the mipi_dsi_device > struct. > > Maybe we could add a 'host_node' entry in mipi_dsi_device itself, which > is exclusively used cases where the DSI device doesn't have a DT node. > Our check in mipi_dsi_host_register() could then be something like: I think instead of extending the struct, we can just walk to the parent similarly to how of_graph_get_remove_port_parent() does. And fix some node refcounting at the same time: diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c index ed3d505dc203..77d439254da6 100644 =2D-- a/drivers/gpu/drm/drm_mipi_dsi.c +++ b/drivers/gpu/drm/drm_mipi_dsi.c @@ -313,7 +313,12 @@ int mipi_dsi_host_register(struct mipi_dsi_host *host) * connect our host to it and probe them now. */ list_for_each_entry_safe(dsi, temp, &unattached_device_list, list) { =2D if (of_get_parent(dsi->dev.of_node) =3D=3D host->dev->of_= node) { + struct device_node *host_node =3D of_get_parent(dsi->dev.of= _node); + + if (!of_node_cmp(host_node->name, "ports")) + host_node =3D of_get_next_parent(host_node); + + if (host_node =3D=3D host->dev->of_node) { dsi->host =3D host; dsi->dev.parent =3D host->dev; device_initialize(&dsi->dev); @@ -321,6 +326,8 @@ int mipi_dsi_host_register(struct mipi_dsi_host *host) mipi_dsi_device_add(dsi); list_del_init(&dsi->list); } + + of_node_put(host_node); } mutex_unlock(&host_lock); =20 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE/JuuFDWp9/ZkuCBXtdYpNtH8nugFAllua9AACgkQtdYpNtH8 nujy5xAAteTABZij7hJDi8xQu9TUo+SmXyoR1MyDvlBV8pVoCxMmlwpl8eeJX8xS axlH4hyFYRIfQj1Vf/4oIWn7R2Q8/yjwsGFHFb3AAXqJPrk8wOUEANm7UWSW3fnl E9d5P+CjuRpQLbaqexnYLY/jOPRYrDRxFVLjXfJWyvSlXn6HphE4ZUMcIWu8WZwP eXIOntaoZezIj0Q/ftMip5u8QDHl3l9EmZmMns5L2Q8WVf8jBSWbGXynSF4lF+8a RKQBu7MSjxb6H7kUpkM0lyE6m8tiWSdex880ItJ6ZTbQwEyWLQ5PD5OC+yPAC6FA dJpEchwaej5ySPc7Ph7F/tMJfxIbYzIKrWOe+fg5ptseXS5LCkySqUE9YrJQGJSH G31JI85s9ywkG2en4J+JdybPhmZICdDjIlPjiwhm1TWLvLm31Tcp/T3mGf0wTjKx HETHXtaIxqsZE8hHqhUA63QDOmxrOsuv5+JxdtMWqI2bP/ruWGP11hUHnKeHAVnd Nt2i0x2kLsBfw7wldAOx11odhoc6JkLUt29pyeAWFCbgDCTKylDZM8gJVL046l/W xLtNYs6QrGFWmygKcD/STCGSptKm/XgkVbU/oy+2WkfzRAAW05aASAHYo8V5keqc x7U+uDkrM/SPmgi1hK9d8cB2IgOyHG4t2eAfyWt2HKGungTFomg= =R930 -----END PGP SIGNATURE----- --=-=-=-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Anholt Subject: Re: [PATCH 6/8] drm: Allow DSI devices to be registered before the host registers. Date: Tue, 18 Jul 2017 13:13:04 -0700 Message-ID: <87mv81bj1r.fsf@eliezer.anholt.net> References: <20170627195839.3338-1-eric@anholt.net> <20170627195839.3338-7-eric@anholt.net> <6fbaa797-1040-48e8-c361-dad4363cd30d@codeaurora.org> <87vamu7hi4.fsf@eliezer.anholt.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0942753660==" Return-path: Received: from anholt.net (anholt.net [50.246.234.109]) by gabe.freedesktop.org (Postfix) with ESMTP id B887289B9E for ; Tue, 18 Jul 2017 20:13:06 +0000 (UTC) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Archit Taneja , dri-devel@lists.freedesktop.org, Andrzej Hajda , Laurent Pinchart , Thierry Reding Cc: Boris Brezillon , linux-kernel@vger.kernel.org List-Id: dri-devel@lists.freedesktop.org --===============0942753660== Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Archit Taneja writes: > On 07/15/2017 04:28 AM, Eric Anholt wrote: >> Archit Taneja writes: >>=20 >>> On 06/28/2017 01:28 AM, Eric Anholt wrote: >>>> When a mipi_dsi_host is registered, the DT is walked to find any child >>>> nodes with compatible strings. Those get registered as DSI devices, >>>> and most DSI panel drivers are mipi_dsi_drivers that attach to those n= odes. >>>> >>>> There is one special case currently, the adv7533 bridge, where the >>>> bridge probes on I2C, and during the bridge attach step it looks up >>>> the mipi_dsi_host and registers the mipi_dsi_device (for its own stub >>>> mipi_dsi_driver). >>>> >>>> For the Raspberry Pi panel, though, we also need to attach on I2C (our >>>> control bus), but don't have a bridge driver. The lack of a bridge's >>>> attach() step like adv7533 uses means that we aren't able to delay the >>>> mipi_dsi_device creation until the mipi_dsi_host is present. >>>> >>>> To fix this, we extend mipi_dsi_device_register_full() to allow being >>>> called with a NULL host, which puts the device on a queue waiting for >>>> a host to appear. When a new host is registered, we fill in the host >>>> value and finish the device creation process. >>> >>> This is quite a nice idea. The only bothering thing is the info.of_node= usage >>> varies between child nodes (mipi_dsi_devs) and non-child nodes (i2c con= trol >>> bus). >>> >>> For DSI children expressed in DT, the of_node in info holds the DT node >>> corresponding to the DSI child itself. For non-DT ones, this patch assu= mes >>> that info.of_node stores the DSI host DT node. I think it should be oka= y as >>> long as we mention the usage in a comment somewhere. The other option i= s to >>> have a new info.host_node field to keep a track of the host DT node. >>=20 >> I think maybe you misread the patch? We're using >> of_get_parent(dsi->dev.node), which came from info->node, to compare to >> host->dev->of_node(). > > I think I did misread it. > > Although, I'm not entirely clear what we should be setting info.node to. > In patch #8, info.node is set by: > > endpoint =3D of_graph_get_next_endpoint(dev->of_node, NULL); > info.node =3D of_graph_get_remote_port(endpoint); > > Looking at the dt bindings in patch #7, it looks like info.node is set > to the 'port' device node in dsi@7e700000, is that right? Yeah. > I suppose 'port' here seems like a reasonable representation of > dsi->dev.node, I wonder how it would work if the dsi host had multiple > ports underneath it. I.e: > > dsi@7e700000 { > ... > ... > ports { > port@0 { > ... > dsi_out_port: endpoint { > remote-endpoint =3D <&panel_dsi_port>; > }; > }; > port@1 { > ... > ... > }; > }; > }; > > Here, we would need to set info.node to the 'ports' node, so that > of_get_parent(dsi->dev.of_node) equals host->dev->of_node. That doesn't > seem correct. > > Ideally, a dev's 'of_node' should be left to NULL if we don't have a > corresponding OF node. We're sort of overriding it here since we don't > have any other place to store this information in the mipi_dsi_device > struct. > > Maybe we could add a 'host_node' entry in mipi_dsi_device itself, which > is exclusively used cases where the DSI device doesn't have a DT node. > Our check in mipi_dsi_host_register() could then be something like: I think instead of extending the struct, we can just walk to the parent similarly to how of_graph_get_remove_port_parent() does. And fix some node refcounting at the same time: diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c index ed3d505dc203..77d439254da6 100644 =2D-- a/drivers/gpu/drm/drm_mipi_dsi.c +++ b/drivers/gpu/drm/drm_mipi_dsi.c @@ -313,7 +313,12 @@ int mipi_dsi_host_register(struct mipi_dsi_host *host) * connect our host to it and probe them now. */ list_for_each_entry_safe(dsi, temp, &unattached_device_list, list) { =2D if (of_get_parent(dsi->dev.of_node) =3D=3D host->dev->of_= node) { + struct device_node *host_node =3D of_get_parent(dsi->dev.of= _node); + + if (!of_node_cmp(host_node->name, "ports")) + host_node =3D of_get_next_parent(host_node); + + if (host_node =3D=3D host->dev->of_node) { dsi->host =3D host; dsi->dev.parent =3D host->dev; device_initialize(&dsi->dev); @@ -321,6 +326,8 @@ int mipi_dsi_host_register(struct mipi_dsi_host *host) mipi_dsi_device_add(dsi); list_del_init(&dsi->list); } + + of_node_put(host_node); } mutex_unlock(&host_lock); =20 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE/JuuFDWp9/ZkuCBXtdYpNtH8nugFAllua9AACgkQtdYpNtH8 nujy5xAAteTABZij7hJDi8xQu9TUo+SmXyoR1MyDvlBV8pVoCxMmlwpl8eeJX8xS axlH4hyFYRIfQj1Vf/4oIWn7R2Q8/yjwsGFHFb3AAXqJPrk8wOUEANm7UWSW3fnl E9d5P+CjuRpQLbaqexnYLY/jOPRYrDRxFVLjXfJWyvSlXn6HphE4ZUMcIWu8WZwP eXIOntaoZezIj0Q/ftMip5u8QDHl3l9EmZmMns5L2Q8WVf8jBSWbGXynSF4lF+8a RKQBu7MSjxb6H7kUpkM0lyE6m8tiWSdex880ItJ6ZTbQwEyWLQ5PD5OC+yPAC6FA dJpEchwaej5ySPc7Ph7F/tMJfxIbYzIKrWOe+fg5ptseXS5LCkySqUE9YrJQGJSH G31JI85s9ywkG2en4J+JdybPhmZICdDjIlPjiwhm1TWLvLm31Tcp/T3mGf0wTjKx HETHXtaIxqsZE8hHqhUA63QDOmxrOsuv5+JxdtMWqI2bP/ruWGP11hUHnKeHAVnd Nt2i0x2kLsBfw7wldAOx11odhoc6JkLUt29pyeAWFCbgDCTKylDZM8gJVL046l/W xLtNYs6QrGFWmygKcD/STCGSptKm/XgkVbU/oy+2WkfzRAAW05aASAHYo8V5keqc x7U+uDkrM/SPmgi1hK9d8cB2IgOyHG4t2eAfyWt2HKGungTFomg= =R930 -----END PGP SIGNATURE----- --=-=-=-- --===============0942753660== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vZHJpLWRldmVsCg== --===============0942753660==--