From: Tomi Valkeinen Subject: Re: [PATCH v2 2/2] drm/omap: Major omap_modeset_init() cleanup Date: Tue, 21 Mar 2017 09:44:38 +0200 Message-ID: References: <450bdea2e841dbfe495d0481fad110c683a134dd.1490025512.git.jsarha@ti.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0333285685==" Return-path: Received: from lelnx193.ext.ti.com (lelnx193.ext.ti.com [198.47.27.77]) by gabe.freedesktop.org (Postfix) with ESMTPS id A37886E07C for ; Tue, 21 Mar 2017 07:44:45 +0000 (UTC) In-Reply-To: <450bdea2e841dbfe495d0481fad110c683a134dd.1490025512.git.jsarha@ti.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Jyri Sarha , dri-devel@lists.freedesktop.org Cc: laurent.pinchart@ideasonboard.com List-Id: dri-devel@lists.freedesktop.org --===============0333285685== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="qGcgFQGVWQHv0E1GKK2rXaXfHhX3Se421" --qGcgFQGVWQHv0E1GKK2rXaXfHhX3Se421 Content-Type: multipart/mixed; boundary="ic7MWLUDteWVVF1gmQPT8UGwNvi6sckvq"; protected-headers="v1" From: Tomi Valkeinen To: Jyri Sarha , dri-devel@lists.freedesktop.org Cc: airlied@linux.ie, daniel@ffwll.ch, laurent.pinchart@ideasonboard.com Message-ID: Subject: Re: [PATCH v2 2/2] drm/omap: Major omap_modeset_init() cleanup References: <450bdea2e841dbfe495d0481fad110c683a134dd.1490025512.git.jsarha@ti.com> In-Reply-To: <450bdea2e841dbfe495d0481fad110c683a134dd.1490025512.git.jsarha@ti.com> --ic7MWLUDteWVVF1gmQPT8UGwNvi6sckvq Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 20/03/17 18:06, Jyri Sarha wrote: > Cleanup overly complex omap_modeset_init(). The function is trying to > support many unusual configuration, that have never been tested and > are not supported by other parts of the dirver. >=20 > After cleanup the init function creates exactly one connector, > encoder, crtc, and primary plane per each connected dss-device. Each > connector->encoder->crtc chain is expected to be separate and each > crtc is connect to a single dss-channel. If the configuration does not > match the expectations or exceeds the available resources, the > configuration is rejected. >=20 > Signed-off-by: Jyri Sarha > --- > drivers/gpu/drm/omapdrm/omap_crtc.c | 23 ++++- > drivers/gpu/drm/omapdrm/omap_drv.c | 173 +++++++++------------------= -------- > drivers/gpu/drm/omapdrm/omap_drv.h | 2 +- > drivers/gpu/drm/omapdrm/omap_plane.c | 3 + > 4 files changed, 68 insertions(+), 133 deletions(-) >=20 > diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c b/drivers/gpu/drm/omap= drm/omap_crtc.c > index 2fe735c..4bafc7b 100644 > --- a/drivers/gpu/drm/omapdrm/omap_crtc.c > +++ b/drivers/gpu/drm/omapdrm/omap_crtc.c > @@ -521,6 +521,11 @@ static int omap_crtc_atomic_get_property(struct dr= m_crtc *crtc, > =20 > void omap_crtc_pre_init(void) > { > + int i; > + > + for (i =3D 0; i < ARRAY_SIZE(omap_crtcs); i++) > + omap_crtcs[i] =3D NULL; > + Use memset to clear. > @@ -318,9 +279,9 @@ static int omap_modeset_init(struct drm_device *dev= ) > int num_ovls =3D dss_feat_get_num_ovls(); > int num_mgrs =3D dss_feat_get_num_mgrs(); > int num_crtcs =3D 0; > - int i, id =3D 0; > + int crtc_idx =3D 0, plane_idx =3D 0; In a bit longer function it's usually better to initialize the variables near to the place where they are first used, so that you will see the initial value when looking at the code in question. > diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/oma= pdrm/omap_plane.c > index 386d90a..8fc1f4a 100644 > --- a/drivers/gpu/drm/omapdrm/omap_plane.c > +++ b/drivers/gpu/drm/omapdrm/omap_plane.c > @@ -371,6 +371,9 @@ struct drm_plane *omap_plane_init(struct drm_device= *dev, > return plane; > =20 > error: > + dev_err(dev->dev, "%s(): could not create plane: %s\n", > + __func__, plane_names[id]); > + > kfree(omap_plane); > return NULL; > } omap_plane_init() still uses "id" instead of "idx", and it's stored in struct omap_plane as 'id', and there's no explicit mapping of the DRM idx to the DSS plane id. This is confusing as the DRM plane idx is not strictly tied to the DSS plane id. So, call it "idx" when it's about the DRM plane index and call it something else when it's about the dss plane id (it's "enum omap_plane" in dss, but that clashes with drm's struct omap_plane. So... 'dss_plane'?). And create a function that maps the DRM plane idx to DSS plane id (for now it can be just a direct map). This change should probably be an additional patch. Otherwise I think this looks good, much cleaner than the current confusio= n. Tomi --ic7MWLUDteWVVF1gmQPT8UGwNvi6sckvq-- --qGcgFQGVWQHv0E1GKK2rXaXfHhX3Se421 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJY0NnmAAoJEPo9qoy8lh71elwP/2DFryrU/n9UcnqgTGBvRyfJ 22t1tM2zE4u8dW/0IuHig0Kn+l5omN2M4netkNvnAFVCfZYEMHOYyNHIGqWFDCD3 vHll0Bs0nvUPB7nCHlsWhDIAlq103xgu/kcilxlGx+xlVkrp29e1DMUod0535XCy CtedqW/jJH2anFsZAJszR14lyUWGNFbTWoVWRMnEBn3ciV2+HjoCNTomgCofBol6 d/FBsBLkEdrHYKiyd61s68CZ2YyGz4WAVlLiE2AQX6myQJGAJC2V0hypiqiYWGwb lOodXVDllmt5BhyjgEYKlEmwkR5hW+rC2zBni7G6Cuc1W6aDs8kXA5UIW60/XwZC 1f2zbJuWukVDhafrIjJpExegwyDb2v8o5QNx/gdR4BVKHpjmaFBGQS+rN3X7yK1T Q4hy1suPn4A+nElM71fXhtnk/DsIxd4d2JpmsdBAAml0a569z9iPBGVLPPEKEf9p xkL7ZZCOETX9lEOfl2xLtK6A3RdSpQbtgl3qUaJ5CWnVoRMatx09xhstSGDj1q4O QGUrM6S7uhu7Hlv7JvpFFNR3pe9fS1myTW5vXs3BS164FANQG38pGi3UM//gn+sX CjTH2qVnQaLapZU4yGFIx9SqVLVEf+/GQ8TTB4N7BQ6UUxg9FoSFJwKArPyDgnJd /eYQpNR1fReJ1ERhEvy8 =bXrV -----END PGP SIGNATURE----- --qGcgFQGVWQHv0E1GKK2rXaXfHhX3Se421-- --===============0333285685== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vZHJpLWRldmVsCg== --===============0333285685==--