From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA57BC2BB55 for ; Sun, 12 Apr 2020 14:18:58 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CA069206E9 for ; Sun, 12 Apr 2020 14:18:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CA069206E9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ravnborg.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 96E4F6E40B; Sun, 12 Apr 2020 14:18:57 +0000 (UTC) Received: from asavdk4.altibox.net (asavdk4.altibox.net [109.247.116.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 570B96E40B for ; Sun, 12 Apr 2020 14:18:56 +0000 (UTC) Received: from ravnborg.org (unknown [158.248.194.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by asavdk4.altibox.net (Postfix) with ESMTPS id 835BC804A3; Sun, 12 Apr 2020 16:18:49 +0200 (CEST) Date: Sun, 12 Apr 2020 16:18:42 +0200 From: Sam Ravnborg To: Tian Tao Subject: Re: [PATCH] drm/hisilicon: Add the shutdown for hibmc_pci_driver Message-ID: <20200412141842.GA12313@ravnborg.org> References: <1586573370-41945-1-git-send-email-tiantao6@hisilicon.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1586573370-41945-1-git-send-email-tiantao6@hisilicon.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.3 cv=XpTUx2N9 c=1 sm=1 tr=0 a=UWs3HLbX/2nnQ3s7vZ42gw==:117 a=UWs3HLbX/2nnQ3s7vZ42gw==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=kj9zAlcOel0A:10 a=BTeA3XvPAAAA:8 a=e5mUnYsNAAAA:8 a=AGzG8Xd3EExtzCPMGWIA:9 a=CjuIK1q_8ugA:10 a=tafbbOV3vt1XuEhzTjGK:22 a=Vxmtnl_E_bksehYqCbjh:22 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: airlied@linux.ie, puck.chen@hisilicon.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linuxarm@huawei.com, xinliang.liu@linaro.org, kraxel@redhat.com, tzimmermann@suse.de, alexander.deucher@amd.com, tglx@linutronix.de Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Hi Tian. On Sat, Apr 11, 2020 at 10:49:30AM +0800, Tian Tao wrote: > add the shutdown function to release the resource. > Why it the release of the memory required in the shutdown method? The memory is allocated using devm_ioremap() which will let device management handle the release of the resources when he driver is released. The patch also introduces a pci_disable_device() The better approch would be to use pcim_enable_device() so you let the device management about releasing the resources. Sam > Signed-off-by: Tian Tao > --- > drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 23 +++++++++++++++++++++++ > 1 file changed, 23 insertions(+) > > diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c > index a6fd0c2..126d4f4 100644 > --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c > +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c > @@ -232,6 +232,21 @@ static int hibmc_hw_map(struct hibmc_drm_private *priv) > return 0; > } > > +static void hibmc_hw_unmap(struct hibmc_drm_private *priv) > +{ > + struct drm_device *dev = priv->dev; > + > + if (priv->mmio) { > + devm_iounmap(dev->dev, priv->mmio); > + priv->mmio = NULL; > + } > + > + if (priv->fb_map) { > + devm_iounmap(dev->dev, priv->fb_map); > + priv->fb_map = NULL; > + } > +} > + > static int hibmc_hw_init(struct hibmc_drm_private *priv) > { > int ret; > @@ -258,6 +273,7 @@ static int hibmc_unload(struct drm_device *dev) > > hibmc_kms_fini(priv); > hibmc_mm_fini(priv); > + hibmc_hw_unmap(priv); > dev->dev_private = NULL; > return 0; > } > @@ -374,6 +390,12 @@ static void hibmc_pci_remove(struct pci_dev *pdev) > drm_dev_unregister(dev); > hibmc_unload(dev); > drm_dev_put(dev); > + pci_disable_device(pdev); > +} > + > +static void hibmc_pci_shutdown(struct pci_dev *pdev) > +{ > + hibmc_pci_remove(pdev); > } > > static struct pci_device_id hibmc_pci_table[] = { > @@ -386,6 +408,7 @@ static struct pci_driver hibmc_pci_driver = { > .id_table = hibmc_pci_table, > .probe = hibmc_pci_probe, > .remove = hibmc_pci_remove, > + .shutdown = hibmc_pci_shutdown, > .driver.pm = &hibmc_pm_ops, > }; > > -- > 2.7.4 > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel