Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp713040pxu; Wed, 2 Dec 2020 01:08:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJygAv+7U/V27HdPAAwsoMYacYYEmmp0nYMDIVL8+OHgt+QtudcbNMZZfpkV+vYbFUhvlvkk X-Received: by 2002:a17:906:a4b:: with SMTP id x11mr1350014ejf.11.1606900081711; Wed, 02 Dec 2020 01:08:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606900081; cv=none; d=google.com; s=arc-20160816; b=l35xqx9rh0Qxq7sDcQMcYEt1z6CZVKQzv1uG69FJJXyihm6VQLrl5QDopdBv7XQU2R V68PVwHpPh4IGhiLixuAGHmY+r58vYOmjnhb1rH+a2HqZavw/BTyNB6s6oEzz1ooc8su p2IiXGPFdbvTaLtRaZqV4cft7grdwx5z8vbwEVxvzkYxL/2BPWUr6s8o7MRXr6/syMsv 9AW7SIyTuQ+IwqvSerdEGX9sYUQqj2iD5gbr7tvGBWQNmklCzBTTJdnKBWwXBYELqSE4 qwEDSqfs27wBHGM4YTI0tgJEKgwQ1nR5yBQT5LTn8ZoJQZC8hqAXKUK+jLYPK2ZxfHDc 61Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=LOOjdRISOkHAyDCMs1wOblHjxSyj6iq0fvQoNVCPang=; b=PYPC9M7u9X11Vr4UN+rDP8uYBfkED6zzqLBJAbemMWKIg/KYs6mKRj3+Ta594ZU8kh 9jzNg0QX5ihrL2PZvi3KWdX+6JktJ8FcpKkhp6z4ipHD9RmEtUOSmHsz4YxyTURj+L+7 ZpZsz8dZ8dae38dkYUnydpO9aPFrnnMDVFEZzfKbjh6/qbj/ulYxk1QQT8CSue4ygyIM twhCSO4x3SME0ClSLh+qpdYiIV+pafWDs/x0Sf+raYqdbEbVJC3FAV8+lETLcYyejCFt H2fBpL59JeLY709hhD1lCItgr51vWhZp3a4SevU+7x3LPIr/28CKikw9BGhz6MvS4Ino 1KlQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u18si667196edy.420.2020.12.02.01.07.37; Wed, 02 Dec 2020 01:08:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387943AbgLBJDY (ORCPT + 99 others); Wed, 2 Dec 2020 04:03:24 -0500 Received: from mx2.suse.de ([195.135.220.15]:40762 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728480AbgLBJDX (ORCPT ); Wed, 2 Dec 2020 04:03:23 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 65228AD6B; Wed, 2 Dec 2020 09:02:41 +0000 (UTC) Subject: Re: [PATCH drm/hisilicon 1/3] drm/hisilicon: Code refactoring for hibmc_drm_drv To: Tian Tao , airlied@linux.ie, daniel@ffwll.ch, kraxel@redhat.com, alexander.deucher@amd.com, tglx@linutronix.de, dri-devel@lists.freedesktop.org, xinliang.liu@linaro.org, maarten.lankhorst@linux.intel.com, mripard@kernel.org Cc: linux-kernel@vger.kernel.org References: <1606898835-40775-1-git-send-email-tiantao6@hisilicon.com> <1606898835-40775-2-git-send-email-tiantao6@hisilicon.com> From: Thomas Zimmermann Message-ID: Date: Wed, 2 Dec 2020 10:02:39 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <1606898835-40775-2-git-send-email-tiantao6@hisilicon.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="AbhEZOftm6WrJ77dVLizq5s8n885JMqqg" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --AbhEZOftm6WrJ77dVLizq5s8n885JMqqg Content-Type: multipart/mixed; boundary="zt6zkTPzu4MAG0Ir5xMeJLvbCCn3g5BBB"; protected-headers="v1" From: Thomas Zimmermann To: Tian Tao , airlied@linux.ie, daniel@ffwll.ch, kraxel@redhat.com, alexander.deucher@amd.com, tglx@linutronix.de, dri-devel@lists.freedesktop.org, xinliang.liu@linaro.org, maarten.lankhorst@linux.intel.com, mripard@kernel.org Cc: linux-kernel@vger.kernel.org Message-ID: Subject: Re: [PATCH drm/hisilicon 1/3] drm/hisilicon: Code refactoring for hibmc_drm_drv References: <1606898835-40775-1-git-send-email-tiantao6@hisilicon.com> <1606898835-40775-2-git-send-email-tiantao6@hisilicon.com> In-Reply-To: <1606898835-40775-2-git-send-email-tiantao6@hisilicon.com> --zt6zkTPzu4MAG0Ir5xMeJLvbCCn3g5BBB Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable Am 02.12.20 um 09:47 schrieb Tian Tao: > Use the devm_drm_dev_alloc provided by the drm framework to alloc > a structure hibmc_drm_private. >=20 > Signed-off-by: Tian Tao This looks good now. Thanks for sticking to it. Acked-by: Thomas Zimmermann > --- > drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c | 2 +- > drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 46 +++++++++++----= --------- > drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h | 4 +-- > drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c | 2 +- > drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c | 8 +++-- > 5 files changed, 30 insertions(+), 32 deletions(-) >=20 > diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c b/drivers/g= pu/drm/hisilicon/hibmc/hibmc_drm_de.c > index ea962ac..096eea9 100644 > --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c > +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c > @@ -499,7 +499,7 @@ static const struct drm_crtc_helper_funcs hibmc_crt= c_helper_funcs =3D { > =20 > int hibmc_de_init(struct hibmc_drm_private *priv) > { > - struct drm_device *dev =3D priv->dev; > + struct drm_device *dev =3D &priv->dev; > struct drm_crtc *crtc =3D &priv->crtc; > struct drm_plane *plane =3D &priv->primary_plane; > int ret; > diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c b/drivers/= gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c > index d845657..13e8a28 100644 > --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c > +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c > @@ -79,31 +79,32 @@ static const struct dev_pm_ops hibmc_pm_ops =3D { > =20 > static int hibmc_kms_init(struct hibmc_drm_private *priv) > { > + struct drm_device *dev =3D &priv->dev; > int ret; > =20 > - drm_mode_config_init(priv->dev); > + drm_mode_config_init(dev); > priv->mode_config_initialized =3D true; > =20 > - priv->dev->mode_config.min_width =3D 0; > - priv->dev->mode_config.min_height =3D 0; > - priv->dev->mode_config.max_width =3D 1920; > - priv->dev->mode_config.max_height =3D 1200; > + dev->mode_config.min_width =3D 0; > + dev->mode_config.min_height =3D 0; > + dev->mode_config.max_width =3D 1920; > + dev->mode_config.max_height =3D 1200; > =20 > - priv->dev->mode_config.fb_base =3D priv->fb_base; > - priv->dev->mode_config.preferred_depth =3D 32; > - priv->dev->mode_config.prefer_shadow =3D 1; > + dev->mode_config.fb_base =3D priv->fb_base; > + dev->mode_config.preferred_depth =3D 32; > + dev->mode_config.prefer_shadow =3D 1; > =20 > - priv->dev->mode_config.funcs =3D (void *)&hibmc_mode_funcs; > + dev->mode_config.funcs =3D (void *)&hibmc_mode_funcs; > =20 > ret =3D hibmc_de_init(priv); > if (ret) { > - drm_err(priv->dev, "failed to init de: %d\n", ret); > + drm_err(dev, "failed to init de: %d\n", ret); > return ret; > } > =20 > ret =3D hibmc_vdac_init(priv); > if (ret) { > - drm_err(priv->dev, "failed to init vdac: %d\n", ret); > + drm_err(dev, "failed to init vdac: %d\n", ret); > return ret; > } > =20 > @@ -113,7 +114,7 @@ static int hibmc_kms_init(struct hibmc_drm_private = *priv) > static void hibmc_kms_fini(struct hibmc_drm_private *priv) > { > if (priv->mode_config_initialized) { > - drm_mode_config_cleanup(priv->dev); > + drm_mode_config_cleanup(&priv->dev); > priv->mode_config_initialized =3D false; > } > } > @@ -202,7 +203,7 @@ static void hibmc_hw_config(struct hibmc_drm_privat= e *priv) > =20 > static int hibmc_hw_map(struct hibmc_drm_private *priv) > { > - struct drm_device *dev =3D priv->dev; > + struct drm_device *dev =3D &priv->dev; > struct pci_dev *pdev =3D dev->pdev; > resource_size_t addr, size, ioaddr, iosize; > =20 > @@ -258,17 +259,9 @@ static int hibmc_unload(struct drm_device *dev) > =20 > static int hibmc_load(struct drm_device *dev) > { > - struct hibmc_drm_private *priv; > + struct hibmc_drm_private *priv =3D to_hibmc_drm_private(dev); > int ret; > =20 > - priv =3D drmm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); > - if (!priv) { > - drm_err(dev, "no memory to allocate for hibmc_drm_private\n"); > - return -ENOMEM; > - } > - dev->dev_private =3D priv; > - priv->dev =3D dev; > - > ret =3D hibmc_hw_init(priv); > if (ret) > goto err; > @@ -310,6 +303,7 @@ static int hibmc_load(struct drm_device *dev) > static int hibmc_pci_probe(struct pci_dev *pdev, > const struct pci_device_id *ent) > { > + struct hibmc_drm_private *priv; > struct drm_device *dev; > int ret; > =20 > @@ -318,12 +312,14 @@ static int hibmc_pci_probe(struct pci_dev *pdev, > if (ret) > return ret; > =20 > - dev =3D drm_dev_alloc(&hibmc_driver, &pdev->dev); > - if (IS_ERR(dev)) { > + priv =3D devm_drm_dev_alloc(&pdev->dev, &hibmc_driver, > + struct hibmc_drm_private, dev); > + if (IS_ERR(priv)) { > DRM_ERROR("failed to allocate drm_device\n"); > - return PTR_ERR(dev); > + return PTR_ERR(priv); > } > =20 > + dev =3D &priv->dev; > dev->pdev =3D pdev; > pci_set_drvdata(pdev, dev); > =20 > diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h b/drivers/= gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h > index f310a83..7e0c756 100644 > --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h > +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h > @@ -37,7 +37,7 @@ struct hibmc_drm_private { > resource_size_t fb_size; > =20 > /* drm */ > - struct drm_device *dev; > + struct drm_device dev; > struct drm_plane primary_plane; > struct drm_crtc crtc; > struct drm_encoder encoder; > @@ -52,7 +52,7 @@ static inline struct hibmc_connector *to_hibmc_connec= tor(struct drm_connector *c > =20 > static inline struct hibmc_drm_private *to_hibmc_drm_private(struct d= rm_device *dev) > { > - return dev->dev_private; > + return container_of(dev, struct hibmc_drm_private, dev); > } > =20 > void hibmc_set_power_mode(struct hibmc_drm_private *priv, > diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c b/drivers= /gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c > index 74e26c2..d35548d 100644 > --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c > +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c > @@ -96,7 +96,7 @@ static const struct drm_encoder_funcs hibmc_encoder_f= uncs =3D { > =20 > int hibmc_vdac_init(struct hibmc_drm_private *priv) > { > - struct drm_device *dev =3D priv->dev; > + struct drm_device *dev =3D &priv->dev; > struct hibmc_connector *hibmc_connector =3D &priv->connector; > struct drm_encoder *encoder =3D &priv->encoder; > struct drm_connector *connector =3D &hibmc_connector->base; > diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c b/drivers/gpu/= drm/hisilicon/hibmc/hibmc_ttm.c > index 602ece1..e84fb81 100644 > --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c > +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c > @@ -25,7 +25,7 @@ int hibmc_mm_init(struct hibmc_drm_private *hibmc) > { > struct drm_vram_mm *vmm; > int ret; > - struct drm_device *dev =3D hibmc->dev; > + struct drm_device *dev =3D &hibmc->dev; > =20 > vmm =3D drm_vram_helper_alloc_mm(dev, > pci_resource_start(dev->pdev, 0), > @@ -41,10 +41,12 @@ int hibmc_mm_init(struct hibmc_drm_private *hibmc) > =20 > void hibmc_mm_fini(struct hibmc_drm_private *hibmc) > { > - if (!hibmc->dev->vram_mm) > + struct drm_device *dev =3D &hibmc->dev; > + > + if (!dev->vram_mm) > return; > =20 > - drm_vram_helper_release_mm(hibmc->dev); > + drm_vram_helper_release_mm(dev); > } > =20 > int hibmc_dumb_create(struct drm_file *file, struct drm_device *dev, >=20 --=20 Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 N=C3=BCrnberg, Germany (HRB 36809, AG N=C3=BCrnberg) Gesch=C3=A4ftsf=C3=BChrer: Felix Imend=C3=B6rffer --zt6zkTPzu4MAG0Ir5xMeJLvbCCn3g5BBB-- --AbhEZOftm6WrJ77dVLizq5s8n885JMqqg Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature" -----BEGIN PGP SIGNATURE----- wsF5BAABCAAjFiEExndm/fpuMUdwYFFolh/E3EQov+AFAl/HWC8FAwAAAAAACgkQlh/E3EQov+D1 nRAAvVR06sxKEasI0jqbOUzm13e9yc3ej9DChGJJ8xsI8jcxGKW668EFlGdCatl9FW/wshDFr2rv 8NooUd3pXjUw/lp/ufMmK6I2zVNP5a8cvQp0Uq4IA9jpzdC3aRK+8UssJP8553YB/o985Hiirl0F AsElrQCmK6d5A+hhUVfMm/MR7FX17FfH0pm0wykvhG/7TDgDiIZaI33lNUH3YMjbwt+B7m/8lbTa +5McanOTU4HsUtNYD07i8CxG3LW4nl2sSz4S9JBVn8t77fSBLTZ4G3eAIXjO0Yhlus5yt+Jdu+jg 9U6v4X4oz+t1wzxTWHtxMLf4fM/0eJHHizkafBIkYx6hHl4tyMgPi5ku+kDNulc9QOFSgaq4CFYI z4j9ZU24ulHqArUz90cRcEUwTE6aQxKS3h1PwU2mEZmlOsdBFZxeHr87qVBg6UttUHeSv6Cjh+A9 xK3U4n8lF/iGLtpn2nI9cGsxwrUI9Chefuq1yQuVcPOM1Jl2wUgxWQFoOh9ayloGkHUpb6mOFcxr wxn5v0qWDV3cyFgpoKh/iI5uh3zyC0rt4SHZl5rx0fzkP3zLbnxzSgXy1Wlw4IOmeNy/Q1bGyngb EjVLwCsU0HU5cnnlAgKA7hVPczOa6RJBJQZijNecFFoFgL8fY9lV8j/3KVpgiDISMwzn8y7hA0yi YVM= =n4Zv -----END PGP SIGNATURE----- --AbhEZOftm6WrJ77dVLizq5s8n885JMqqg--