public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
From: daniel@ffwll•ch (Daniel Vetter)
To: linux-arm-kernel@lists•infradead.org
Subject: [PATCH v3 04/13] fbdev: add remove_conflicting_pci_framebuffers()
Date: Mon, 3 Sep 2018 18:16:23 +0200	[thread overview]
Message-ID: <20180903161623.GH21634@phenom.ffwll.local> (raw)
In-Reply-To: <7db1c278276de420eb45a1b71d06b5eb6bbd49ef.1535810304.git.mirq-linux@rere.qmqm.pl>

On Sat, Sep 01, 2018 at 04:08:45PM +0200, Micha? Miros?aw wrote:
> Almost all PCI drivers using remove_conflicting_framebuffers() wrap it
> with the same code.
> 
> ---

This cuts away the sob. Just fyi.
-Daniel

> v2: add kerneldoc for DRM helper
> v3: propagate remove_conflicting_framebuffers() return value
>   + move kerneldoc to where function is implemented
> 
> Signed-off-by: Micha? Miros?aw <mirq-linux@rere•qmqm.pl>
> ---
>  drivers/video/fbdev/core/fbmem.c | 35 ++++++++++++++++++++++++++++++++
>  include/drm/drm_fb_helper.h      | 12 +++++++++++
>  include/linux/fb.h               |  2 ++
>  3 files changed, 49 insertions(+)
> 
> diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
> index 2de93b5014e3..cd96b1c62bbe 100644
> --- a/drivers/video/fbdev/core/fbmem.c
> +++ b/drivers/video/fbdev/core/fbmem.c
> @@ -34,6 +34,7 @@
>  #include <linux/fb.h>
>  #include <linux/fbcon.h>
>  #include <linux/mem_encrypt.h>
> +#include <linux/pci.h>
>  
>  #include <asm/fb.h>
>  
> @@ -1812,6 +1813,40 @@ int remove_conflicting_framebuffers(struct apertures_struct *a,
>  }
>  EXPORT_SYMBOL(remove_conflicting_framebuffers);
>  
> +/**
> + * remove_conflicting_pci_framebuffers - remove firmware-configured framebuffers for PCI devices
> + * @pdev: PCI device
> + * @resource_id: index of PCI BAR configuring framebuffer memory
> + * @name: requesting driver name
> + *
> + * This function removes framebuffer devices (eg. initialized by firmware)
> + * using memory range configured for @pdev's BAR @resource_id.
> + *
> + * The function assumes that PCI device with shadowed ROM drives a primary
> + * display and so kicks out vga16fb.
> + */
> +int remove_conflicting_pci_framebuffers(struct pci_dev *pdev, int res_id, const char *name)
> +{
> +	struct apertures_struct *ap;
> +	bool primary = false;
> +	int err;
> +
> +	ap = alloc_apertures(1);
> +	if (!ap)
> +		return -ENOMEM;
> +
> +	ap->ranges[0].base = pci_resource_start(pdev, res_id);
> +	ap->ranges[0].size = pci_resource_len(pdev, res_id);
> +#ifdef CONFIG_X86
> +	primary = pdev->resource[PCI_ROM_RESOURCE].flags &
> +					IORESOURCE_ROM_SHADOW;
> +#endif
> +	err = remove_conflicting_framebuffers(ap, name, primary);
> +	kfree(ap);
> +	return err;
> +}
> +EXPORT_SYMBOL(remove_conflicting_pci_framebuffers);
> +
>  /**
>   *	register_framebuffer - registers a frame buffer device
>   *	@fb_info: frame buffer info structure
> diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
> index b069433e7fc1..20ea856db900 100644
> --- a/include/drm/drm_fb_helper.h
> +++ b/include/drm/drm_fb_helper.h
> @@ -577,4 +577,16 @@ drm_fb_helper_remove_conflicting_framebuffers(struct apertures_struct *a,
>  #endif
>  }
>  
> +static inline int
> +drm_fb_helper_remove_conflicting_pci_framebuffers(struct pci_dev *pdev,
> +						  int resource_id,
> +						  const char *name)
> +{
> +#if IS_REACHABLE(CONFIG_FB)
> +	return remove_conflicting_pci_framebuffers(pdev, resource_id, name);
> +#else
> +	return 0;
> +#endif
> +}
> +
>  #endif
> diff --git a/include/linux/fb.h b/include/linux/fb.h
> index aa74a228bb92..abeffd55b66a 100644
> --- a/include/linux/fb.h
> +++ b/include/linux/fb.h
> @@ -632,6 +632,8 @@ extern ssize_t fb_sys_write(struct fb_info *info, const char __user *buf,
>  extern int register_framebuffer(struct fb_info *fb_info);
>  extern int unregister_framebuffer(struct fb_info *fb_info);
>  extern int unlink_framebuffer(struct fb_info *fb_info);
> +extern int remove_conflicting_pci_framebuffers(struct pci_dev *pdev, int res_id,
> +					       const char *name);
>  extern int remove_conflicting_framebuffers(struct apertures_struct *a,
>  					   const char *name, bool primary);
>  extern int fb_prepare_logo(struct fb_info *fb_info, int rotate);
> -- 
> 2.18.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

  reply	other threads:[~2018-09-03 16:16 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1511544782.git.mirq-linux@rere.qmqm.pl>
2018-08-30 21:00 ` [PATCH v2 00/12] remove_conflicting_framebuffers() cleanup Michał Mirosław
2018-08-30 21:00   ` [PATCH v2 01/12] fbdev: show fbdev number for debugging Michał Mirosław
2018-08-30 21:00   ` [PATCH v2 02/12] fbdev: allow apertures == NULL in remove_conflicting_framebuffers() Michał Mirosław
2018-08-31  8:56     ` Daniel Vetter
2018-08-31  9:01       ` Daniel Vetter
2018-08-30 21:00   ` [PATCH v2 03/12] fbdev: add remove_conflicting_pci_framebuffers() Michał Mirosław
2018-08-30 21:00   ` [PATCH v2 04/12] drm/amdgpu: use simpler remove_conflicting_pci_framebuffers() Michał Mirosław
2018-08-30 21:00   ` [PATCH v2 05/12] drm/bochs: " Michał Mirosław
2018-08-30 21:00   ` [PATCH v2 06/12] drm/cirrus: " Michał Mirosław
2018-08-30 21:00   ` [PATCH v2 07/12] drm/mgag200: " Michał Mirosław
2018-08-30 21:00   ` [PATCH v2 08/12] drm/radeon: " Michał Mirosław
2018-08-30 21:00   ` [PATCH v2 09/12] drm/virtio: " Michał Mirosław
2018-08-30 21:00   ` [PATCH v2 10/12] drm/vc4: use simpler remove_conflicting_framebuffers(NULL) Michał Mirosław
2018-08-30 21:00   ` [PATCH v2 11/12] drm/sun4i: " Michał Mirosław
2018-08-30 21:00   ` [PATCH v2 12/12] drm/tegra: kick out simplefb Michał Mirosław
2018-08-31  9:04   ` [PATCH v2 00/12] remove_conflicting_framebuffers() cleanup Daniel Vetter
2018-08-31  9:07     ` Chris Wilson
2018-09-01 13:45       ` Michał Mirosław
2018-09-01 14:08   ` [PATCH v3 00/13] " Michał Mirosław
2018-09-01 14:08     ` [PATCH v3 01/13] fbdev: show fbdev number for debugging Michał Mirosław
2018-09-01 14:08     ` [PATCH v3 02/13] fbdev: allow apertures == NULL in remove_conflicting_framebuffers() Michał Mirosław
2018-09-01 14:08     ` [PATCH v3 04/13] fbdev: add remove_conflicting_pci_framebuffers() Michał Mirosław
2018-09-03 16:16       ` Daniel Vetter [this message]
2018-09-04 15:40       ` kbuild test robot
2018-09-01 14:08     ` [PATCH v3 03/13] fbdev: add kerneldoc do remove_conflicting_framebuffers() Michał Mirosław
2018-09-05 11:02       ` Paul Menzel
2018-09-01 14:08     ` [PATCH v3 05/13] drm/amdgpu: use simpler remove_conflicting_pci_framebuffers() Michał Mirosław
2018-09-01 14:08     ` [PATCH v3 06/13] drm/bochs: " Michał Mirosław
2018-09-01 14:08     ` [PATCH v3 07/13] drm/cirrus: " Michał Mirosław
2018-09-01 14:08     ` [PATCH v3 08/13] drm/mgag200: " Michał Mirosław
2018-09-01 14:08     ` [PATCH v3 09/13] drm/radeon: " Michał Mirosław
2018-09-01 14:08     ` [PATCH v3 10/13] drm/virtio: " Michał Mirosław
2018-09-01 14:08     ` [PATCH v3 11/13] drm/vc4: use simpler remove_conflicting_framebuffers(NULL) Michał Mirosław
2018-09-01 14:08     ` [PATCH v3 12/13] drm/sun4i: " Michał Mirosław
2018-09-01 14:08     ` [PATCH v3 13/13] drm/tegra: kick out simplefb Michał Mirosław
2018-09-03  7:43     ` [PATCH v3 00/13] remove_conflicting_framebuffers() cleanup Daniel Vetter
2018-09-03 11:31       ` Bartlomiej Zolnierkiewicz
2018-09-03 16:26         ` Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180903161623.GH21634@phenom.ffwll.local \
    --to=daniel@ffwll$(echo .)ch \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox