linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/hisilicon: Fixed pcie resource conflict between drm and firmware
@ 2020-02-19  7:57 Tian Tao
  2020-02-19  8:15 ` Thomas Zimmermann
  0 siblings, 1 reply; 2+ messages in thread
From: Tian Tao @ 2020-02-19  7:57 UTC (permalink / raw)
  To: puck.chen, airlied, daniel, tzimmermann, kraxel,
	alexander.deucher, tglx, dri-devel, xinliang.liu, linux-kernel
  Cc: linuxarm

remove the framebuffer initialized by fireware/bootloader,which will use
hibmc's pcie resource, and may cause conflict.

Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
Signed-off-by: Gong junjie <gongjunjie2@huawei.com>
---
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
index 5f612f6..7ebe831 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
@@ -47,6 +47,22 @@ static irqreturn_t hibmc_drm_interrupt(int irq, void *arg)
 	return IRQ_HANDLED;
 }
 
+static void hibmc_remove_framebuffers(struct pci_dev *pdev)
+{
+	struct apertures_struct *ap;
+
+	ap = alloc_apertures(1);
+	if (!ap)
+		return;
+
+	ap->ranges[0].base = pci_resource_start(pdev, 0);
+	ap->ranges[0].size = pci_resource_len(pdev, 0);
+
+	drm_fb_helper_remove_conflicting_framebuffers(ap, "hibmcdrmfb", false);
+
+	kfree(ap);
+}
+
 static struct drm_driver hibmc_driver = {
 	.driver_features	= DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
 	.fops			= &hibmc_fops,
@@ -327,6 +343,8 @@ static int hibmc_pci_probe(struct pci_dev *pdev,
 	struct drm_device *dev;
 	int ret;
 
+	hibmc_remove_framebuffers(pdev);
+
 	dev = drm_dev_alloc(&hibmc_driver, &pdev->dev);
 	if (IS_ERR(dev)) {
 		DRM_ERROR("failed to allocate drm_device\n");
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm/hisilicon: Fixed pcie resource conflict between drm and firmware
  2020-02-19  7:57 [PATCH] drm/hisilicon: Fixed pcie resource conflict between drm and firmware Tian Tao
@ 2020-02-19  8:15 ` Thomas Zimmermann
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Zimmermann @ 2020-02-19  8:15 UTC (permalink / raw)
  To: Tian Tao, puck.chen, airlied, daniel, kraxel, alexander.deucher,
	tglx, dri-devel, xinliang.liu, linux-kernel
  Cc: linuxarm


[-- Attachment #1.1: Type: text/plain, Size: 1997 bytes --]

Hi

Am 19.02.20 um 08:57 schrieb Tian Tao:
> remove the framebuffer initialized by fireware/bootloader,which will use
> hibmc's pcie resource, and may cause conflict.
> 
> Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
> Signed-off-by: Gong junjie <gongjunjie2@huawei.com>
> ---
>  drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
> index 5f612f6..7ebe831 100644
> --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
> +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
> @@ -47,6 +47,22 @@ static irqreturn_t hibmc_drm_interrupt(int irq, void *arg)
>  	return IRQ_HANDLED;
>  }
>  
> +static void hibmc_remove_framebuffers(struct pci_dev *pdev)
> +{
> +	struct apertures_struct *ap;
> +
> +	ap = alloc_apertures(1);
> +	if (!ap)
> +		return;
> +
> +	ap->ranges[0].base = pci_resource_start(pdev, 0);
> +	ap->ranges[0].size = pci_resource_len(pdev, 0);
> +
> +	drm_fb_helper_remove_conflicting_framebuffers(ap, "hibmcdrmfb", false);
> +
> +	kfree(ap);
> +}
> +
>  static struct drm_driver hibmc_driver = {
>  	.driver_features	= DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
>  	.fops			= &hibmc_fops,
> @@ -327,6 +343,8 @@ static int hibmc_pci_probe(struct pci_dev *pdev,
>  	struct drm_device *dev;
>  	int ret;
>  
> +	hibmc_remove_framebuffers(pdev);

Instead of rolling your own, you should try
drm_fb_helper_remove_conflicting_pci_framebuffers(). It releases any I/O
memory resource of the device.

Best regards
Thomas

> +
>  	dev = drm_dev_alloc(&hibmc_driver, &pdev->dev);
>  	if (IS_ERR(dev)) {
>  		DRM_ERROR("failed to allocate drm_device\n");
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-02-19  8:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-19  7:57 [PATCH] drm/hisilicon: Fixed pcie resource conflict between drm and firmware Tian Tao
2020-02-19  8:15 ` Thomas Zimmermann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).