Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2491909ybb; Sun, 12 Apr 2020 07:20:14 -0700 (PDT) X-Google-Smtp-Source: APiQypKwipP6sG5RN+RR0IVNWkOTUYMroU7QFlqpw4On026QQb9qurzTQHCa4pmEg2eClny6qYZL X-Received: by 2002:ac8:6c57:: with SMTP id z23mr7556737qtu.359.1586701214530; Sun, 12 Apr 2020 07:20:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586701214; cv=none; d=google.com; s=arc-20160816; b=bz9OJKneWVeAFM6TBeBQFo7oemjhE/GGaJoU7woSISfKQxqc3H43tUArLUxjc7tdJT O2tW0VIOr2tUq3yle1kvuUZT1LvRP8VfP3w6dQCvZuQGLZOjMHAY2NV/HvMeItC6GHTG Hvx9fOS0PuYKcofgqB7xDMON3ES89Qc+wwfDtoubYrYWDMcOsOYyEQ71hIW3z3UtTnD/ V4SyaR+SenMGjxwHK8Pf2cz58IFeCS6ELbTT5tLHMbTfFRoWZzBQHLJrpclOc5eUC2Vt MkmaLUeS0mR4rU/+Qu5SZTbPsJm8eeH7uqDh2DK1fLVn3wnaE8s6hxPvb8YY9f/w8NN7 Bgwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=E35IYWATXnVARRDmHjwnp5DWhNgwyIgfsV6qyx0WtFQ=; b=EiF67fcKakjM1+lrq65fBVnS+rl4Ggmc9IRzsbUWoCBj14SXwqfHZVrXeeANhp/UW3 urbf/o6P5X1+j68DpiC+ASeic3SvFw0TIV+QENtq+ZiQZYWcEpcmi4KpCMq1WoWeR8XL mvMIQKwgJMwgebFzFItyRagq2cRs+LVMytXDlFRhvSHFyCwwhCQwOMBr8ytTPyBMqFMh sFjET0R8IpchTvhmVhz4tnb53s49ah0ON50ede/qPJy0zapec4I2CSQVFqFwmmtxocm+ /0Cv0+pOPUDB0FFVYa1H82+2riDjNNzUHmoqSRNqGkRsOZnDUELO9U70wDfgwVM5rzCf cOtQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u44si4389848qtb.5.2020.04.12.07.19.59; Sun, 12 Apr 2020 07:20:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727049AbgDLOS4 (ORCPT + 99 others); Sun, 12 Apr 2020 10:18:56 -0400 Received: from asavdk4.altibox.net ([109.247.116.15]:57146 "EHLO asavdk4.altibox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726805AbgDLOS4 (ORCPT ); Sun, 12 Apr 2020 10:18:56 -0400 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 Cc: puck.chen@hisilicon.com, airlied@linux.ie, daniel@ffwll.ch, tzimmermann@suse.de, kraxel@redhat.com, alexander.deucher@amd.com, tglx@linutronix.de, dri-devel@lists.freedesktop.org, xinliang.liu@linaro.org, linux-kernel@vger.kernel.org, linuxarm@huawei.com 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-Type: text/plain; charset=us-ascii 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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