drm/gma500: Convert fbdev to DRM client
Subsystems (3)
Thomas Zimmermann
maintainercover drm/gma500: Convert fbdev to DRM client
Convert gma500's fbdev code to drm_client. Replace to the current ad-hoc integration. The conversion includes a number of cleanups. Only build fbdev support if the config option has been set.
Tested on Cedarview HW.
Thomas Zimmermann (7):
drm/gma500: Remove unnecessary include statements drm/gma500: Move fbdev code into separate source file drm/gma500: Remove fbdev vma open and close callbacks drm/gma500: Fix naming in fb_ops. drm/gma500: Inline psbfb_create() into psbfb_probe() drm/gma500: Implement client-based fbdev emulation drm/gma500: Pass fb_info to psb_fbdev_vm_fault()
drivers/gpu/drm/gma500/Makefile | 1 + drivers/gpu/drm/gma500/fbdev.c | 344 +++++++++++++++++++++++++++ drivers/gpu/drm/gma500/framebuffer.c | 336 +------------------------- drivers/gpu/drm/gma500/psb_drv.c | 5 +- drivers/gpu/drm/gma500/psb_drv.h | 17 +- 5 files changed, 363 insertions(+), 340 deletions(-) create mode 100644 drivers/gpu/drm/gma500/fbdev.c
Signature · 1 line
2.39.2
Thomas Zimmermann
maintainerPATCH 1/7 drm/gma500: Remove unnecessary include statements
Remove unnecessary include statements from framebuffer.c. No functional changes.
--- drivers/gpu/drm/gma500/framebuffer.c | 15 --------------- 1 file changed, 15 deletions(-)
drivers/gpu/drm/gma500/framebuffer.c +0 -15
@@ -5,23 +5,10 @@* **************************************************************************/ -#include <linux/console.h> -#include <linux/delay.h> -#include <linux/errno.h> -#include <linux/init.h> -#include <linux/kernel.h> -#include <linux/mm.h> -#include <linux/module.h> #include <linux/pfn_t.h> -#include <linux/slab.h> -#include <linux/string.h> -#include <linux/tty.h> -#include <drm/drm.h> -#include <drm/drm_crtc.h> #include <drm/drm_crtc_helper.h> #include <drm/drm_fb_helper.h> -#include <drm/drm_fourcc.h> #include <drm/drm_framebuffer.h> #include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_modeset_helper.h>
@@ -29,8 +16,6 @@#include "framebuffer.h" #include "gem.h" #include "psb_drv.h" -#include "psb_intel_drv.h" -#include "psb_intel_reg.h" static const struct drm_framebuffer_funcs psb_fb_funcs = { .destroy = drm_gem_fb_destroy,
Signature · 1 line
2.39.2
Thomas Zimmermann
maintainerPATCH 2/7 drm/gma500: Move fbdev code into separate source file
In reply to Thomas ZimmermannMove the fbdev emulation from framebuffer.c into fbdev.c. Only build the source code if the Kconfig symbol has been selected. Remaining in framebuffer.c is gma500's code for DRM frambuffers. No functional hanges.
--- drivers/gpu/drm/gma500/Makefile | 1 + drivers/gpu/drm/gma500/fbdev.c | 325 +++++++++++++++++++++++++++ drivers/gpu/drm/gma500/framebuffer.c | 318 +------------------------- drivers/gpu/drm/gma500/psb_drv.h | 17 ++ 4 files changed, 346 insertions(+), 315 deletions(-) create mode 100644 drivers/gpu/drm/gma500/fbdev.c
drivers/gpu/drm/gma500/Makefile +1 -0
@@ -38,5 +38,6 @@ gma500_gfx-y += \ psb_irq.o gma500_gfx-$(CONFIG_ACPI) += opregion.o +gma500_gfx-$(CONFIG_DRM_FBDEV_EMULATION) += fbdev.o obj-$(CONFIG_DRM_GMA500) += gma500_gfx.o
drivers/gpu/drm/gma500/fbdev.c new file +325 -0
325 lines not on this page · raw message
drivers/gpu/drm/gma500/framebuffer.c +3 -315
354 lines not on this page · raw message
drivers/gpu/drm/gma500/psb_drv.h +17 -0
@@ -610,7 +610,24 @@ extern void psb_lid_timer_takedown(struct drm_psb_private *dev_priv);/* modesetting */ extern void psb_modeset_init (struct drm_device *dev);extern void psb_modeset_cleanup (struct drm_device *dev); + +/* framebuffer */ +extern struct drm_framebuffer *psb_framebuffer_create (struct drm_device *dev, +const struct drm_mode_fb_cmd2 *mode_cmd, +struct drm_gem_object *obj); + +/* fbdev */ +#if defined(CONFIG_DRM_FBDEV_EMULATION )extern int psb_fbdev_init (struct drm_device *dev); +extern void psb_fbdev_fini (struct drm_device *dev); +#else +int psb_fbdev_init (struct drm_device *dev) +{ +return 0 ; +} +void psb_fbdev_fini (struct drm_device *dev) +{ } +#endif /* backlight.c */ int gma_backlight_init (struct drm_device *dev);
Signature · 1 line
2.39.2
Patrik Jakobsson
maintainerRe: [PATCH 2/7] drm/gma500: Move fbdev code into separate source file
Quoted 7 lines · Thomas Zimmermann
Move the fbdev emulation from
framebuffer.cintofbdev.c. Only build the source code if theKconfigsymbol has been selected. Remaining inframebuffer.cis gma500's code for DRM frambuffers. No functional hanges.Signed-off-by Thomas Zimmermann <[email protected]>
Hi Thomas, this patch doesn't apply to drm-misc. I seem to be missing drm_fb_helper_prepare/unprepare().
-Patrik
Quoted 745 lines
--- drivers/gpu/drm/gma500/Makefile | 1 + drivers/gpu/drm/gma500/fbdev.c | 325 +++++++++++++++++++++++++++ drivers/gpu/drm/gma500/framebuffer.c | 318 +------------------------- drivers/gpu/drm/gma500/psb_drv.h | 17 ++ 4 files changed, 346 insertions(+), 315 deletions(-) create mode 100644 drivers/gpu/drm/gma500/fbdev.cdrivers/gpu/drm/gma500/Makefile +1
-0@@ -38,5 +38,6 @@ gma500_gfx-y += \ psb_irq.o gma500_gfx-$(CONFIG_ACPI) += opregion.o +gma500_gfx-$(CONFIG_DRM_FBDEV_EMULATION) += fbdev.o obj-$(CONFIG_DRM_GMA500) += gma500_gfx.odrivers/gpu/drm/gma500/fbdev.c new file +325
-0@@ -0,0 +1,325 @@ +// SPDX-License-Identifier: GPL-2.0-only +/************************************************************************** +* Copyright (c) 2007-2011, Intel Corporation. +* All Rights Reserved. +* +**************************************************************************/ + +#include <linux/pfn_t.h> + +#include <drm/drm_crtc_helper.h> +#include <drm/drm_fb_helper.h> +#include <drm/drm_framebuffer.h> + +#include "gem.h" +#include "psb_drv.h" + +/* +* VM area struct +*/ + +static vm_fault_t psbfb_vm_fault (struct vm_fault *vmf) +{ +struct vm_area_struct *vma = vmf->vma; +struct drm_framebuffer *fb = vma->vm_private_data; +struct drm_device *dev = fb->dev; +struct drm_psb_private *dev_priv =to_drm_psb_private (dev); +struct psb_gem_object *pobj =to_psb_gem_object (fb->obj[0 ]); +int page_num; +int i; +unsigned long address; +vm_fault_t ret =VM_FAULT_SIGBUS ; +unsigned long pfn; +unsigned long phys_addr = (unsigned long )dev_priv->stolen_base + pobj->offset; + + page_num =vma_pages (vma); + address = vmf->address - (vmf->pgoff <<PAGE_SHIFT ); + + vma->vm_page_prot =pgprot_noncached (vma->vm_page_prot); + +for (i =0 ; i < page_num; i++) { + pfn = (phys_addr >>PAGE_SHIFT ); + + ret =vmf_insert_mixed (vma, address,__pfn_to_pfn_t (pfn,PFN_DEV )); +if (unlikely (ret &VM_FAULT_ERROR )) +break ; + address +=PAGE_SIZE ; + phys_addr +=PAGE_SIZE ; + } +return ret; +} + +static void psbfb_vm_open (struct vm_area_struct *vma) +{ } + +static void psbfb_vm_close (struct vm_area_struct *vma) +{ } + +static const struct vm_operations_struct psbfb_vm_ops = { + .fault = psbfb_vm_fault, + .open = psbfb_vm_open, + .close = psbfb_vm_close +}; + +/* +* struct fb_ops +*/ + +#define CMAP_TOHW (_val, _width) ((((_val) << (_width)) + 0x7FFF - (_val)) >> 16) + +static int psbfb_setcolreg (unsigned int regno, +unsigned int red,unsigned int green, +unsigned int blue,unsigned int transp, +struct fb_info *info) +{ +struct drm_fb_helper *fb_helper = info->par; +struct drm_framebuffer *fb = fb_helper->fb; +uint32_t v; + +if (!fb) +return -ENOMEM ; + +if (regno >255 ) +return 1 ; + + red =CMAP_TOHW (red, info->var.red.length); + blue =CMAP_TOHW (blue, info->var.blue.length); + green =CMAP_TOHW (green, info->var.green.length); + transp =CMAP_TOHW (transp, info->var.transp.length); + + v = (red << info->var.red.offset) | + (green << info->var.green.offset) | + (blue << info->var.blue.offset) | + (transp << info->var.transp.offset); + +if (regno <16 ) { +switch (fb->format->cpp[0 ] *8 ) { +case 16 : + ((uint32_t *) info->pseudo_palette)[regno] = v; +break ; +case 24 : +case 32 : + ((uint32_t *) info->pseudo_palette)[regno] = v; +break ; + } + } + +return 0 ; +} + +static int psbfb_mmap (struct fb_info *info,struct vm_area_struct *vma) +{ +struct drm_fb_helper *fb_helper = info->par; +struct drm_framebuffer *fb = fb_helper->fb; + +if (vma->vm_pgoff !=0 ) +return -EINVAL ; +if (vma->vm_pgoff > (~0UL >>PAGE_SHIFT )) +return -EINVAL ; + +/* +* If this is a GEM object then info->screen_base is the virtual +* kernel remapping of the object. FIXME: Review if this is +* suitable for our mmap work +*/ + vma->vm_ops = &psbfb_vm_ops; + vma->vm_private_data = (void *)fb; + vma->vm_flags |=VM_IO |VM_MIXEDMAP |VM_DONTEXPAND |VM_DONTDUMP ; + +return 0 ; +} + +static const struct fb_ops psbfb_unaccel_ops = { + .owner =THIS_MODULE , +DRM_FB_HELPER_DEFAULT_OPS , + .fb_setcolreg = psbfb_setcolreg, + .fb_read = drm_fb_helper_cfb_read, + .fb_write = drm_fb_helper_cfb_write, + .fb_fillrect = drm_fb_helper_cfb_fillrect, + .fb_copyarea = drm_fb_helper_cfb_copyarea, + .fb_imageblit = drm_fb_helper_cfb_imageblit, + .fb_mmap = psbfb_mmap, +}; + +/* +* struct drm_fb_helper_funcs +*/ + +static int psbfb_create (struct drm_fb_helper *fb_helper, +struct drm_fb_helper_surface_size *sizes) +{ +struct drm_device *dev = fb_helper->dev; +struct drm_psb_private *dev_priv =to_drm_psb_private (dev); +struct pci_dev *pdev =to_pci_dev (dev->dev); +struct fb_info *info; +struct drm_framebuffer *fb; +struct drm_mode_fb_cmd2 mode_cmd; +int size; +int ret; +struct psb_gem_object *backing; +struct drm_gem_object *obj; +u32 bpp, depth; + + mode_cmd.width = sizes->surface_width; + mode_cmd.height = sizes->surface_height; + bpp = sizes->surface_bpp; + depth = sizes->surface_depth; + +/* No 24bit packed */ +if (bpp ==24 ) + bpp =32 ; + + mode_cmd.pitches[0 ] =ALIGN (mode_cmd.width *DIV_ROUND_UP (bpp,8 ),64 ); + + size = mode_cmd.pitches[0 ] * mode_cmd.height; + size =ALIGN (size,PAGE_SIZE ); + +/* Allocate the framebuffer in the GTT with stolen page backing */ + backing =psb_gem_create (dev, size,"fb" , true,PAGE_SIZE ); +if (IS_ERR (backing)) +return PTR_ERR (backing); + obj = &backing->base; + +memset (dev_priv->vram_addr + backing->offset,0 , size); + + info =drm_fb_helper_alloc_info (fb_helper); +if (IS_ERR (info)) { + ret =PTR_ERR (info); + goto err_drm_gem_object_put; + } + + mode_cmd.pixel_format =drm_mode_legacy_fb_format (bpp, depth); + + fb =psb_framebuffer_create (dev, &mode_cmd, obj); +if (IS_ERR (fb)) { + ret =PTR_ERR (fb); + goto err_drm_gem_object_put; + } + + fb_helper->fb = fb; + + info->fbops = &psbfb_unaccel_ops; + + info->fix.smem_start = dev_priv->fb_base; + info->fix.smem_len = size; + info->fix.ywrapstep =0 ; + info->fix.ypanstep =0 ; + +/* Accessed stolen memory directly */ + info->screen_base = dev_priv->vram_addr + backing->offset; + info->screen_size = size; + +drm_fb_helper_fill_info (info, fb_helper, sizes); + + info->fix.mmio_start =pci_resource_start (pdev,0 ); + info->fix.mmio_len =pci_resource_len (pdev,0 ); + +/* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */ + +dev_dbg (dev->dev,"allocated %dx%d fb\n" , fb->width, fb->height); + +return 0 ; + +err_drm_gem_object_put: +drm_gem_object_put (obj); +return ret; +} + +static int psbfb_probe (struct drm_fb_helper *fb_helper, +struct drm_fb_helper_surface_size *sizes) +{ +struct drm_device *dev = fb_helper->dev; +struct drm_psb_private *dev_priv =to_drm_psb_private (dev); +unsigned int fb_size; +int bytespp; + + bytespp = sizes->surface_bpp /8 ; +if (bytespp ==3 )/* no 24bit packed */ + bytespp =4 ; + +/* +* If the mode will not fit in 32bit then switch to 16bit to get +* a console on full resolution. The X mode setting server will +* allocate its own 32bit GEM framebuffer +*/ + fb_size =ALIGN (sizes->surface_width * bytespp,64 ) * + sizes->surface_height; + fb_size =ALIGN (fb_size,PAGE_SIZE ); + +if (fb_size > dev_priv->vram_stolen_size) { + sizes->surface_bpp =16 ; + sizes->surface_depth =16 ; + } + +return psbfb_create (fb_helper, sizes); +} + +static const struct drm_fb_helper_funcs psb_fb_helper_funcs = { + .fb_probe = psbfb_probe, +}; + +static int psb_fbdev_destroy (struct drm_device *dev, +struct drm_fb_helper *fb_helper) +{ +struct drm_framebuffer *fb = fb_helper->fb; + +drm_fb_helper_unregister_info (fb_helper); + +drm_fb_helper_fini (fb_helper); +drm_framebuffer_unregister_private (fb); +drm_framebuffer_cleanup (fb); + +if (fb->obj[0 ]) +drm_gem_object_put (fb->obj[0 ]); +kfree (fb); + +return 0 ; +} + +int psb_fbdev_init (struct drm_device *dev) +{ +struct drm_fb_helper *fb_helper; +struct drm_psb_private *dev_priv =to_drm_psb_private (dev); +int ret; + + fb_helper =kzalloc (sizeof (*fb_helper),GFP_KERNEL ); +if (!fb_helper) +return -ENOMEM ; + + dev_priv->fb_helper = fb_helper; + +drm_fb_helper_prepare (dev, fb_helper,32 , &psb_fb_helper_funcs); + + ret =drm_fb_helper_init (dev, fb_helper); +if (ret) + goto free; + +/* disable all the possible outputs/crtcs before entering KMS mode */ +drm_helper_disable_unused_functions (dev); + + ret =drm_fb_helper_initial_config (fb_helper); +if (ret) + goto fini; + +return 0 ; + +fini: +drm_fb_helper_fini (fb_helper); +free: +drm_fb_helper_unprepare (fb_helper); +kfree (fb_helper); +return ret; +} + +void psb_fbdev_fini (struct drm_device *dev) +{ +struct drm_psb_private *dev_priv =to_drm_psb_private (dev); + +if (!dev_priv->fb_helper) +return ; + +psb_fbdev_destroy (dev, dev_priv->fb_helper); +drm_fb_helper_unprepare (dev_priv->fb_helper); +kfree (dev_priv->fb_helper); + dev_priv->fb_helper =NULL ; +}drivers/gpu/drm/gma500/framebuffer.c +3
-315@@ -5,16 +5,12 @@* **************************************************************************/ -#include <linux/pfn_t.h> - -#include <drm/drm_crtc_helper.h> #include <drm/drm_fb_helper.h> #include <drm/drm_framebuffer.h> #include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_modeset_helper.h> #include "framebuffer.h" -#include "gem.h" #include "psb_drv.h" static const struct drm_framebuffer_funcs psb_fb_funcs = {@@ -22,126 +18,6 @@ static const struct drm_framebuffer_funcs psb_fb_funcs = { .create_handle = drm_gem_fb_create_handle, }; -#define CMAP_TOHW (_val, _width) ((((_val) << (_width)) + 0x7FFF - (_val)) >> 16) - -static int psbfb_setcolreg (unsigned regno,unsigned red,unsigned green, -unsigned blue,unsigned transp, -struct fb_info *info) -{ -struct drm_fb_helper *fb_helper = info->par; -struct drm_framebuffer *fb = fb_helper->fb; -uint32_t v; - -if (!fb) -return -ENOMEM ; - -if (regno >255 ) -return 1 ; - - red =CMAP_TOHW (red, info->var.red.length); - blue =CMAP_TOHW (blue, info->var.blue.length); - green =CMAP_TOHW (green, info->var.green.length); - transp =CMAP_TOHW (transp, info->var.transp.length); - - v = (red << info->var.red.offset) | - (green << info->var.green.offset) | - (blue << info->var.blue.offset) | - (transp << info->var.transp.offset); - -if (regno <16 ) { -switch (fb->format->cpp[0 ] *8 ) { -case 16 : - ((uint32_t *) info->pseudo_palette)[regno] = v; -break ; -case 24 : -case 32 : - ((uint32_t *) info->pseudo_palette)[regno] = v; -break ; - } - } - -return 0 ; -} - -static vm_fault_t psbfb_vm_fault (struct vm_fault *vmf) -{ -struct vm_area_struct *vma = vmf->vma; -struct drm_framebuffer *fb = vma->vm_private_data; -struct drm_device *dev = fb->dev; -struct drm_psb_private *dev_priv =to_drm_psb_private (dev); -struct psb_gem_object *pobj =to_psb_gem_object (fb->obj[0 ]); -int page_num; -int i; -unsigned long address; -vm_fault_t ret =VM_FAULT_SIGBUS ; -unsigned long pfn; -unsigned long phys_addr = (unsigned long )dev_priv->stolen_base + pobj->offset; - - page_num =vma_pages (vma); - address = vmf->address - (vmf->pgoff <<PAGE_SHIFT ); - - vma->vm_page_prot =pgprot_noncached (vma->vm_page_prot); - -for (i =0 ; i < page_num; i++) { - pfn = (phys_addr >>PAGE_SHIFT ); - - ret =vmf_insert_mixed (vma, address, -__pfn_to_pfn_t (pfn,PFN_DEV )); -if (unlikely (ret &VM_FAULT_ERROR )) -break ; - address +=PAGE_SIZE ; - phys_addr +=PAGE_SIZE ; - } -return ret; -} - -static void psbfb_vm_open (struct vm_area_struct *vma) -{ -} - -static void psbfb_vm_close (struct vm_area_struct *vma) -{ -} - -static const struct vm_operations_struct psbfb_vm_ops = { - .fault = psbfb_vm_fault, - .open = psbfb_vm_open, - .close = psbfb_vm_close -}; - -static int psbfb_mmap (struct fb_info *info,struct vm_area_struct *vma) -{ -struct drm_fb_helper *fb_helper = info->par; -struct drm_framebuffer *fb = fb_helper->fb; - -if (vma->vm_pgoff !=0 ) -return -EINVAL ; -if (vma->vm_pgoff > (~0UL >>PAGE_SHIFT )) -return -EINVAL ; - -/* -* If this is a GEM object then info->screen_base is the virtual -* kernel remapping of the object. FIXME: Review if this is -* suitable for our mmap work -*/ - vma->vm_ops = &psbfb_vm_ops; - vma->vm_private_data = (void *)fb; - vma->vm_flags |=VM_IO |VM_MIXEDMAP |VM_DONTEXPAND |VM_DONTDUMP ; -return 0 ; -} - -static const struct fb_ops psbfb_unaccel_ops = { - .owner =THIS_MODULE , -DRM_FB_HELPER_DEFAULT_OPS , - .fb_setcolreg = psbfb_setcolreg, - .fb_read = drm_fb_helper_cfb_read, - .fb_write = drm_fb_helper_cfb_write, - .fb_fillrect = drm_fb_helper_cfb_fillrect, - .fb_copyarea = drm_fb_helper_cfb_copyarea, - .fb_imageblit = drm_fb_helper_cfb_imageblit, - .fb_mmap = psbfb_mmap, -}; -/** * psb_framebuffer_init - initialize a framebuffer * @dev: our DRM device @@ -192,11 +68,9 @@ static int psb_framebuffer_init(struct drm_device *dev,* * TODO: review object references */ - -static struct drm_framebuffer *psb_framebuffer_create - (struct drm_device *dev, -const struct drm_mode_fb_cmd2 *mode_cmd, -struct drm_gem_object *obj) +struct drm_framebuffer *psb_framebuffer_create (struct drm_device *dev, +const struct drm_mode_fb_cmd2 *mode_cmd, +struct drm_gem_object *obj) {struct drm_framebuffer *fb;int ret;@@ -213,93 +87,6 @@ static struct drm_framebuffer *psb_framebuffer_createreturn fb; } -/** -* psbfb_create - create a framebuffer -* @fb_helper: the framebuffer helper -* @sizes: specification of the layout -* -* Create a framebuffer to the specifications provided -*/ -static int psbfb_create (struct drm_fb_helper *fb_helper, -struct drm_fb_helper_surface_size *sizes) -{ -struct drm_device *dev = fb_helper->dev; -struct drm_psb_private *dev_priv =to_drm_psb_private (dev); -struct pci_dev *pdev =to_pci_dev (dev->dev); -struct fb_info *info; -struct drm_framebuffer *fb; -struct drm_mode_fb_cmd2 mode_cmd; -int size; -int ret; -struct psb_gem_object *backing; -struct drm_gem_object *obj; -u32 bpp, depth; - - mode_cmd.width = sizes->surface_width; - mode_cmd.height = sizes->surface_height; - bpp = sizes->surface_bpp; - depth = sizes->surface_depth; - -/* No 24bit packed */ -if (bpp ==24 ) - bpp =32 ; - - mode_cmd.pitches[0 ] =ALIGN (mode_cmd.width *DIV_ROUND_UP (bpp,8 ),64 ); - - size = mode_cmd.pitches[0 ] * mode_cmd.height; - size =ALIGN (size,PAGE_SIZE ); - -/* Allocate the framebuffer in the GTT with stolen page backing */ - backing =psb_gem_create (dev, size,"fb" , true,PAGE_SIZE ); -if (IS_ERR (backing)) -return PTR_ERR (backing); - obj = &backing->base; - -memset (dev_priv->vram_addr + backing->offset,0 , size); - - info =drm_fb_helper_alloc_info (fb_helper); -if (IS_ERR (info)) { - ret =PTR_ERR (info); - goto err_drm_gem_object_put; - } - - mode_cmd.pixel_format =drm_mode_legacy_fb_format (bpp, depth); - - fb =psb_framebuffer_create (dev, &mode_cmd, obj); -if (IS_ERR (fb)) { - ret =PTR_ERR (fb); - goto err_drm_gem_object_put; - } - - fb_helper->fb = fb; - - info->fbops = &psbfb_unaccel_ops; - - info->fix.smem_start = dev_priv->fb_base; - info->fix.smem_len = size; - info->fix.ywrapstep =0 ; - info->fix.ypanstep =0 ; - -/* Accessed stolen memory directly */ - info->screen_base = dev_priv->vram_addr + backing->offset; - info->screen_size = size; - -drm_fb_helper_fill_info (info, fb_helper, sizes); - - info->fix.mmio_start =pci_resource_start (pdev,0 ); - info->fix.mmio_len =pci_resource_len (pdev,0 ); - -/* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */ - -dev_dbg (dev->dev,"allocated %dx%d fb\n" , fb->width, fb->height); - -return 0 ; - -err_drm_gem_object_put: -drm_gem_object_put (obj); -return ret; -} -/** * psb_user_framebuffer_create - create framebuffer * @dev: our DRM device @@ -331,105 +118,6 @@ static struct drm_framebuffer *psb_user_framebuffer_createreturn fb; } -static int psbfb_probe (struct drm_fb_helper *fb_helper, -struct drm_fb_helper_surface_size *sizes) -{ -struct drm_device *dev = fb_helper->dev; -struct drm_psb_private *dev_priv =to_drm_psb_private (dev); -unsigned int fb_size; -int bytespp; - - bytespp = sizes->surface_bpp /8 ; -if (bytespp ==3 )/* no 24bit packed */ - bytespp =4 ; - -/* If the mode will not fit in 32bit then switch to 16bit to get -a console on full resolution. The X mode setting server will -allocate its own 32bit GEM framebuffer */ - fb_size =ALIGN (sizes->surface_width * bytespp,64 ) * - sizes->surface_height; - fb_size =ALIGN (fb_size,PAGE_SIZE ); - -if (fb_size > dev_priv->vram_stolen_size) { - sizes->surface_bpp =16 ; - sizes->surface_depth =16 ; - } - -return psbfb_create (fb_helper, sizes); -} - -static const struct drm_fb_helper_funcs psb_fb_helper_funcs = { - .fb_probe = psbfb_probe, -}; - -static int psb_fbdev_destroy (struct drm_device *dev, -struct drm_fb_helper *fb_helper) -{ -struct drm_framebuffer *fb = fb_helper->fb; - -drm_fb_helper_unregister_info (fb_helper); - -drm_fb_helper_fini (fb_helper); -drm_framebuffer_unregister_private (fb); -drm_framebuffer_cleanup (fb); - -if (fb->obj[0 ]) -drm_gem_object_put (fb->obj[0 ]); -kfree (fb); - -return 0 ; -} - -int psb_fbdev_init (struct drm_device *dev) -{ -struct drm_fb_helper *fb_helper; -struct drm_psb_private *dev_priv =to_drm_psb_private (dev); -int ret; - - fb_helper =kzalloc (sizeof (*fb_helper),GFP_KERNEL ); -if (!fb_helper) { -dev_err (dev->dev,"no memory\n" ); -return -ENOMEM ; - } - - dev_priv->fb_helper = fb_helper; - -drm_fb_helper_prepare (dev, fb_helper,32 , &psb_fb_helper_funcs); - - ret =drm_fb_helper_init (dev, fb_helper); -if (ret) - goto free; - -/* disable all the possible outputs/crtcs before entering KMS mode */ -drm_helper_disable_unused_functions (dev); - - ret =drm_fb_helper_initial_config (fb_helper); -if (ret) - goto fini; - -return 0 ; - -fini: -drm_fb_helper_fini (fb_helper); -free: -drm_fb_helper_unprepare (fb_helper); -kfree (fb_helper); -return ret; -} - -static void psb_fbdev_fini (struct drm_device *dev) -{ -struct drm_psb_private *dev_priv =to_drm_psb_private (dev); - -if (!dev_priv->fb_helper) -return ; - -psb_fbdev_destroy (dev, dev_priv->fb_helper); -drm_fb_helper_unprepare (dev_priv->fb_helper); -kfree (dev_priv->fb_helper); - dev_priv->fb_helper =NULL ; -} -static const struct drm_mode_config_funcs psb_mode_funcs = { .fb_create = psb_user_framebuffer_create, .output_poll_changed = drm_fb_helper_output_poll_changed,drivers/gpu/drm/gma500/psb_drv.h +17
-1@@ -610,7 +610,24 @@ extern void psb_lid_timer_takedown(struct drm_psb_private *dev_priv);/* modesetting */ extern void psb_modeset_init (struct drm_device *dev);extern void psb_modeset_cleanup (struct drm_device *dev); + +/* framebuffer */ +extern struct drm_framebuffer *psb_framebuffer_create (struct drm_device *dev, +const struct drm_mode_fb_cmd2 *mode_cmd, +struct drm_gem_object *obj); + +/* fbdev */ +#if defined(CONFIG_DRM_FBDEV_EMULATION )extern int psb_fbdev_init (struct drm_device *dev); +extern void psb_fbdev_fini (struct drm_device *dev); +#else +int psb_fbdev_init (struct drm_device *dev) +{ +return 0 ; +} +void psb_fbdev_fini (struct drm_device *dev) +{ } +#endif /* backlight.c */ int gma_backlight_init (struct drm_device *dev); --2.39.2
Thomas Zimmermann
maintainerRe: [PATCH 2/7] drm/gma500: Move fbdev code into separate source file
Hi
Am 27.02.23 um 08:10 schrieb Patrik Jakobsson:
Quoted 11 lines · Thomas Zimmermann
Quoted 7 lines
Move the fbdev emulation from
framebuffer.cintofbdev.c. Only build the source code if theKconfigsymbol has been selected. Remaining inframebuffer.cis gma500's code for DRM frambuffers. No functional hanges.Signed-off-by Thomas Zimmermann <[email protected]>Hi Thomas, this patch doesn't apply to drm-misc. I seem to be missing drm_fb_helper_prepare/unprepare().
Could be. I'm on drm-tip for development. And we're in the merge window, which is a bad time to sync-ing trees. Let me see if I can easiyl backmerge now. Or otherwise things should stabilize after -rc1 has been tagged.
Best regards
Thomas
Quoted 748 lines
-Patrik
Quoted 745 lines
--- drivers/gpu/drm/gma500/Makefile | 1 + drivers/gpu/drm/gma500/fbdev.c | 325 +++++++++++++++++++++++++++ drivers/gpu/drm/gma500/framebuffer.c | 318 +------------------------- drivers/gpu/drm/gma500/psb_drv.h | 17 ++ 4 files changed, 346 insertions(+), 315 deletions(-)create mode 100644
drivers/gpu/drm/gma500/fbdev.cdrivers/gpu/drm/gma500/Makefile +1
-0@@ -38,5 +38,6 @@ gma500_gfx-y += \ psb_irq.o gma500_gfx-$(CONFIG_ACPI) += opregion.o +gma500_gfx-$(CONFIG_DRM_FBDEV_EMULATION) += fbdev.o obj-$(CONFIG_DRM_GMA500) += gma500_gfx.odrivers/gpu/drm/gma500/fbdev.c new file +325
-0@@ -0,0 +1,325 @@ +// SPDX-License-Identifier: GPL-2.0-only +/************************************************************************** +* Copyright (c) 2007-2011, Intel Corporation. +* All Rights Reserved. +* +**************************************************************************/ + +#include <linux/pfn_t.h> + +#include <drm/drm_crtc_helper.h> +#include <drm/drm_fb_helper.h> +#include <drm/drm_framebuffer.h> + +#include "gem.h" +#include "psb_drv.h" + +/* +* VM area struct +*/ + +static vm_fault_t psbfb_vm_fault (struct vm_fault *vmf) +{ +struct vm_area_struct *vma = vmf->vma; +struct drm_framebuffer *fb = vma->vm_private_data; +struct drm_device *dev = fb->dev; +struct drm_psb_private *dev_priv =to_drm_psb_private (dev); +struct psb_gem_object *pobj =to_psb_gem_object (fb->obj[0 ]); +int page_num; +int i; +unsigned long address; +vm_fault_t ret =VM_FAULT_SIGBUS ; +unsigned long pfn; +unsigned long phys_addr = (unsigned long )dev_priv->stolen_base + pobj->offset; + + page_num =vma_pages (vma); + address = vmf->address - (vmf->pgoff <<PAGE_SHIFT ); + + vma->vm_page_prot =pgprot_noncached (vma->vm_page_prot); + +for (i =0 ; i < page_num; i++) { + pfn = (phys_addr >>PAGE_SHIFT ); + + ret =vmf_insert_mixed (vma, address,__pfn_to_pfn_t (pfn,PFN_DEV )); +if (unlikely (ret &VM_FAULT_ERROR )) +break ; + address +=PAGE_SIZE ; + phys_addr +=PAGE_SIZE ; + } +return ret; +} + +static void psbfb_vm_open (struct vm_area_struct *vma) +{ } + +static void psbfb_vm_close (struct vm_area_struct *vma) +{ } + +static const struct vm_operations_struct psbfb_vm_ops = { + .fault = psbfb_vm_fault, + .open = psbfb_vm_open, + .close = psbfb_vm_close +}; + +/* +* struct fb_ops +*/ + +#define CMAP_TOHW (_val, _width) ((((_val) << (_width)) + 0x7FFF - (_val)) >> 16) + +static int psbfb_setcolreg (unsigned int regno, +unsigned int red,unsigned int green, +unsigned int blue,unsigned int transp, +struct fb_info *info) +{ +struct drm_fb_helper *fb_helper = info->par; +struct drm_framebuffer *fb = fb_helper->fb; +uint32_t v; + +if (!fb) +return -ENOMEM ; + +if (regno >255 ) +return 1 ; + + red =CMAP_TOHW (red, info->var.red.length); + blue =CMAP_TOHW (blue, info->var.blue.length); + green =CMAP_TOHW (green, info->var.green.length); + transp =CMAP_TOHW (transp, info->var.transp.length); + + v = (red << info->var.red.offset) | + (green << info->var.green.offset) | + (blue << info->var.blue.offset) | + (transp << info->var.transp.offset); + +if (regno <16 ) { +switch (fb->format->cpp[0 ] *8 ) { +case 16 : + ((uint32_t *) info->pseudo_palette)[regno] = v; +break ; +case 24 : +case 32 : + ((uint32_t *) info->pseudo_palette)[regno] = v; +break ; + } + } + +return 0 ; +} + +static int psbfb_mmap (struct fb_info *info,struct vm_area_struct *vma) +{ +struct drm_fb_helper *fb_helper = info->par; +struct drm_framebuffer *fb = fb_helper->fb; + +if (vma->vm_pgoff !=0 ) +return -EINVAL ; +if (vma->vm_pgoff > (~0UL >>PAGE_SHIFT )) +return -EINVAL ; + +/* +* If this is a GEM object then info->screen_base is the virtual +* kernel remapping of the object. FIXME: Review if this is +* suitable for our mmap work +*/ + vma->vm_ops = &psbfb_vm_ops; + vma->vm_private_data = (void *)fb; + vma->vm_flags |=VM_IO |VM_MIXEDMAP |VM_DONTEXPAND |VM_DONTDUMP ; + +return 0 ; +} + +static const struct fb_ops psbfb_unaccel_ops = { + .owner =THIS_MODULE , +DRM_FB_HELPER_DEFAULT_OPS , + .fb_setcolreg = psbfb_setcolreg, + .fb_read = drm_fb_helper_cfb_read, + .fb_write = drm_fb_helper_cfb_write, + .fb_fillrect = drm_fb_helper_cfb_fillrect, + .fb_copyarea = drm_fb_helper_cfb_copyarea, + .fb_imageblit = drm_fb_helper_cfb_imageblit, + .fb_mmap = psbfb_mmap, +}; + +/* +* struct drm_fb_helper_funcs +*/ + +static int psbfb_create (struct drm_fb_helper *fb_helper, +struct drm_fb_helper_surface_size *sizes) +{ +struct drm_device *dev = fb_helper->dev; +struct drm_psb_private *dev_priv =to_drm_psb_private (dev); +struct pci_dev *pdev =to_pci_dev (dev->dev); +struct fb_info *info; +struct drm_framebuffer *fb; +struct drm_mode_fb_cmd2 mode_cmd; +int size; +int ret; +struct psb_gem_object *backing; +struct drm_gem_object *obj; +u32 bpp, depth; + + mode_cmd.width = sizes->surface_width; + mode_cmd.height = sizes->surface_height; + bpp = sizes->surface_bpp; + depth = sizes->surface_depth; + +/* No 24bit packed */ +if (bpp ==24 ) + bpp =32 ; + + mode_cmd.pitches[0 ] =ALIGN (mode_cmd.width *DIV_ROUND_UP (bpp,8 ),64 ); + + size = mode_cmd.pitches[0 ] * mode_cmd.height; + size =ALIGN (size,PAGE_SIZE ); + +/* Allocate the framebuffer in the GTT with stolen page backing */ + backing =psb_gem_create (dev, size,"fb" , true,PAGE_SIZE ); +if (IS_ERR (backing)) +return PTR_ERR (backing); + obj = &backing->base; + +memset (dev_priv->vram_addr + backing->offset,0 , size); + + info =drm_fb_helper_alloc_info (fb_helper); +if (IS_ERR (info)) { + ret =PTR_ERR (info); + goto err_drm_gem_object_put; + } + + mode_cmd.pixel_format =drm_mode_legacy_fb_format (bpp, depth); + + fb =psb_framebuffer_create (dev, &mode_cmd, obj); +if (IS_ERR (fb)) { + ret =PTR_ERR (fb); + goto err_drm_gem_object_put; + } + + fb_helper->fb = fb; + + info->fbops = &psbfb_unaccel_ops; + + info->fix.smem_start = dev_priv->fb_base; + info->fix.smem_len = size; + info->fix.ywrapstep =0 ; + info->fix.ypanstep =0 ; + +/* Accessed stolen memory directly */ + info->screen_base = dev_priv->vram_addr + backing->offset; + info->screen_size = size; + +drm_fb_helper_fill_info (info, fb_helper, sizes); + + info->fix.mmio_start =pci_resource_start (pdev,0 ); + info->fix.mmio_len =pci_resource_len (pdev,0 ); + +/* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */ + +dev_dbg (dev->dev,"allocated %dx%d fb\n" , fb->width, fb->height); + +return 0 ; + +err_drm_gem_object_put: +drm_gem_object_put (obj); +return ret; +} + +static int psbfb_probe (struct drm_fb_helper *fb_helper, +struct drm_fb_helper_surface_size *sizes) +{ +struct drm_device *dev = fb_helper->dev; +struct drm_psb_private *dev_priv =to_drm_psb_private (dev); +unsigned int fb_size; +int bytespp; + + bytespp = sizes->surface_bpp /8 ; +if (bytespp ==3 )/* no 24bit packed */ + bytespp =4 ; + +/* +* If the mode will not fit in 32bit then switch to 16bit to get +* a console on full resolution. The X mode setting server will +* allocate its own 32bit GEM framebuffer +*/ + fb_size =ALIGN (sizes->surface_width * bytespp,64 ) * + sizes->surface_height; + fb_size =ALIGN (fb_size,PAGE_SIZE ); + +if (fb_size > dev_priv->vram_stolen_size) { + sizes->surface_bpp =16 ; + sizes->surface_depth =16 ; + } + +return psbfb_create (fb_helper, sizes); +} + +static const struct drm_fb_helper_funcs psb_fb_helper_funcs = { + .fb_probe = psbfb_probe, +}; + +static int psb_fbdev_destroy (struct drm_device *dev, +struct drm_fb_helper *fb_helper) +{ +struct drm_framebuffer *fb = fb_helper->fb; + +drm_fb_helper_unregister_info (fb_helper); + +drm_fb_helper_fini (fb_helper); +drm_framebuffer_unregister_private (fb); +drm_framebuffer_cleanup (fb); + +if (fb->obj[0 ]) +drm_gem_object_put (fb->obj[0 ]); +kfree (fb); + +return 0 ; +} + +int psb_fbdev_init (struct drm_device *dev) +{ +struct drm_fb_helper *fb_helper; +struct drm_psb_private *dev_priv =to_drm_psb_private (dev); +int ret; + + fb_helper =kzalloc (sizeof (*fb_helper),GFP_KERNEL ); +if (!fb_helper) +return -ENOMEM ; + + dev_priv->fb_helper = fb_helper; + +drm_fb_helper_prepare (dev, fb_helper,32 , &psb_fb_helper_funcs); + + ret =drm_fb_helper_init (dev, fb_helper); +if (ret) + goto free; + +/* disable all the possible outputs/crtcs before entering KMS mode */ +drm_helper_disable_unused_functions (dev); + + ret =drm_fb_helper_initial_config (fb_helper); +if (ret) + goto fini; + +return 0 ; + +fini: +drm_fb_helper_fini (fb_helper); +free: +drm_fb_helper_unprepare (fb_helper); +kfree (fb_helper); +return ret; +} + +void psb_fbdev_fini (struct drm_device *dev) +{ +struct drm_psb_private *dev_priv =to_drm_psb_private (dev); + +if (!dev_priv->fb_helper) +return ; + +psb_fbdev_destroy (dev, dev_priv->fb_helper); +drm_fb_helper_unprepare (dev_priv->fb_helper); +kfree (dev_priv->fb_helper); + dev_priv->fb_helper =NULL ; +}drivers/gpu/drm/gma500/framebuffer.c +3
-315@@ -5,16 +5,12 @@* **************************************************************************/ -#include <linux/pfn_t.h> - -#include <drm/drm_crtc_helper.h> #include <drm/drm_fb_helper.h> #include <drm/drm_framebuffer.h> #include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_modeset_helper.h> #include "framebuffer.h" -#include "gem.h" #include "psb_drv.h" static const struct drm_framebuffer_funcs psb_fb_funcs = {@@ -22,126 +18,6 @@ static const struct drm_framebuffer_funcs psb_fb_funcs = { .create_handle = drm_gem_fb_create_handle, }; -#define CMAP_TOHW (_val, _width) ((((_val) << (_width)) + 0x7FFF - (_val)) >> 16) - -static int psbfb_setcolreg (unsigned regno,unsigned red,unsigned green, -unsigned blue,unsigned transp, -struct fb_info *info) -{ -struct drm_fb_helper *fb_helper = info->par; -struct drm_framebuffer *fb = fb_helper->fb; -uint32_t v; - -if (!fb) -return -ENOMEM ; - -if (regno >255 ) -return 1 ; - - red =CMAP_TOHW (red, info->var.red.length); - blue =CMAP_TOHW (blue, info->var.blue.length); - green =CMAP_TOHW (green, info->var.green.length); - transp =CMAP_TOHW (transp, info->var.transp.length); - - v = (red << info->var.red.offset) | - (green << info->var.green.offset) | - (blue << info->var.blue.offset) | - (transp << info->var.transp.offset); - -if (regno <16 ) { -switch (fb->format->cpp[0 ] *8 ) { -case 16 : - ((uint32_t *) info->pseudo_palette)[regno] = v; -break ; -case 24 : -case 32 : - ((uint32_t *) info->pseudo_palette)[regno] = v; -break ; - } - } - -return 0 ; -} - -static vm_fault_t psbfb_vm_fault (struct vm_fault *vmf) -{ -struct vm_area_struct *vma = vmf->vma; -struct drm_framebuffer *fb = vma->vm_private_data; -struct drm_device *dev = fb->dev; -struct drm_psb_private *dev_priv =to_drm_psb_private (dev); -struct psb_gem_object *pobj =to_psb_gem_object (fb->obj[0 ]); -int page_num; -int i; -unsigned long address; -vm_fault_t ret =VM_FAULT_SIGBUS ; -unsigned long pfn; -unsigned long phys_addr = (unsigned long )dev_priv->stolen_base + pobj->offset; - - page_num =vma_pages (vma); - address = vmf->address - (vmf->pgoff <<PAGE_SHIFT ); - - vma->vm_page_prot =pgprot_noncached (vma->vm_page_prot); - -for (i =0 ; i < page_num; i++) { - pfn = (phys_addr >>PAGE_SHIFT ); - - ret =vmf_insert_mixed (vma, address, -__pfn_to_pfn_t (pfn,PFN_DEV )); -if (unlikely (ret &VM_FAULT_ERROR )) -break ; - address +=PAGE_SIZE ; - phys_addr +=PAGE_SIZE ; - } -return ret; -} - -static void psbfb_vm_open (struct vm_area_struct *vma) -{ -} - -static void psbfb_vm_close (struct vm_area_struct *vma) -{ -} - -static const struct vm_operations_struct psbfb_vm_ops = { - .fault = psbfb_vm_fault, - .open = psbfb_vm_open, - .close = psbfb_vm_close -}; - -static int psbfb_mmap (struct fb_info *info,struct vm_area_struct *vma) -{ -struct drm_fb_helper *fb_helper = info->par; -struct drm_framebuffer *fb = fb_helper->fb; - -if (vma->vm_pgoff !=0 ) -return -EINVAL ; -if (vma->vm_pgoff > (~0UL >>PAGE_SHIFT )) -return -EINVAL ; - -/* -* If this is a GEM object then info->screen_base is the virtual -* kernel remapping of the object. FIXME: Review if this is -* suitable for our mmap work -*/ - vma->vm_ops = &psbfb_vm_ops; - vma->vm_private_data = (void *)fb; - vma->vm_flags |=VM_IO |VM_MIXEDMAP |VM_DONTEXPAND |VM_DONTDUMP ; -return 0 ; -} - -static const struct fb_ops psbfb_unaccel_ops = { - .owner =THIS_MODULE , -DRM_FB_HELPER_DEFAULT_OPS , - .fb_setcolreg = psbfb_setcolreg, - .fb_read = drm_fb_helper_cfb_read, - .fb_write = drm_fb_helper_cfb_write, - .fb_fillrect = drm_fb_helper_cfb_fillrect, - .fb_copyarea = drm_fb_helper_cfb_copyarea, - .fb_imageblit = drm_fb_helper_cfb_imageblit, - .fb_mmap = psbfb_mmap, -}; -/** * psb_framebuffer_init - initialize a framebuffer * @dev: our DRM device @@ -192,11 +68,9 @@ static int psb_framebuffer_init(struct drm_device *dev,* * TODO: review object references */ - -static struct drm_framebuffer *psb_framebuffer_create - (struct drm_device *dev, -const struct drm_mode_fb_cmd2 *mode_cmd, -struct drm_gem_object *obj) +struct drm_framebuffer *psb_framebuffer_create (struct drm_device *dev, +const struct drm_mode_fb_cmd2 *mode_cmd, +struct drm_gem_object *obj) {struct drm_framebuffer *fb;int ret;@@ -213,93 +87,6 @@ static struct drm_framebuffer *psb_framebuffer_createreturn fb; } -/** -* psbfb_create - create a framebuffer -* @fb_helper: the framebuffer helper -* @sizes: specification of the layout -* -* Create a framebuffer to the specifications provided -*/ -static int psbfb_create (struct drm_fb_helper *fb_helper, -struct drm_fb_helper_surface_size *sizes) -{ -struct drm_device *dev = fb_helper->dev; -struct drm_psb_private *dev_priv =to_drm_psb_private (dev); -struct pci_dev *pdev =to_pci_dev (dev->dev); -struct fb_info *info; -struct drm_framebuffer *fb; -struct drm_mode_fb_cmd2 mode_cmd; -int size; -int ret; -struct psb_gem_object *backing; -struct drm_gem_object *obj; -u32 bpp, depth; - - mode_cmd.width = sizes->surface_width; - mode_cmd.height = sizes->surface_height; - bpp = sizes->surface_bpp; - depth = sizes->surface_depth; - -/* No 24bit packed */ -if (bpp ==24 ) - bpp =32 ; - - mode_cmd.pitches[0 ] =ALIGN (mode_cmd.width *DIV_ROUND_UP (bpp,8 ),64 ); - - size = mode_cmd.pitches[0 ] * mode_cmd.height; - size =ALIGN (size,PAGE_SIZE ); - -/* Allocate the framebuffer in the GTT with stolen page backing */ - backing =psb_gem_create (dev, size,"fb" , true,PAGE_SIZE ); -if (IS_ERR (backing)) -return PTR_ERR (backing); - obj = &backing->base; - -memset (dev_priv->vram_addr + backing->offset,0 , size); - - info =drm_fb_helper_alloc_info (fb_helper); -if (IS_ERR (info)) { - ret =PTR_ERR (info); - goto err_drm_gem_object_put; - } - - mode_cmd.pixel_format =drm_mode_legacy_fb_format (bpp, depth); - - fb =psb_framebuffer_create (dev, &mode_cmd, obj); -if (IS_ERR (fb)) { - ret =PTR_ERR (fb); - goto err_drm_gem_object_put; - } - - fb_helper->fb = fb; - - info->fbops = &psbfb_unaccel_ops; - - info->fix.smem_start = dev_priv->fb_base; - info->fix.smem_len = size; - info->fix.ywrapstep =0 ; - info->fix.ypanstep =0 ; - -/* Accessed stolen memory directly */ - info->screen_base = dev_priv->vram_addr + backing->offset; - info->screen_size = size; - -drm_fb_helper_fill_info (info, fb_helper, sizes); - - info->fix.mmio_start =pci_resource_start (pdev,0 ); - info->fix.mmio_len =pci_resource_len (pdev,0 ); - -/* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */ - -dev_dbg (dev->dev,"allocated %dx%d fb\n" , fb->width, fb->height); - -return 0 ; - -err_drm_gem_object_put: -drm_gem_object_put (obj); -return ret; -} -/** * psb_user_framebuffer_create - create framebuffer * @dev: our DRM device @@ -331,105 +118,6 @@ static struct drm_framebuffer *psb_user_framebuffer_createreturn fb; } -static int psbfb_probe (struct drm_fb_helper *fb_helper, -struct drm_fb_helper_surface_size *sizes) -{ -struct drm_device *dev = fb_helper->dev; -struct drm_psb_private *dev_priv =to_drm_psb_private (dev); -unsigned int fb_size; -int bytespp; - - bytespp = sizes->surface_bpp /8 ; -if (bytespp ==3 )/* no 24bit packed */ - bytespp =4 ; - -/* If the mode will not fit in 32bit then switch to 16bit to get -a console on full resolution. The X mode setting server will -allocate its own 32bit GEM framebuffer */ - fb_size =ALIGN (sizes->surface_width * bytespp,64 ) * - sizes->surface_height; - fb_size =ALIGN (fb_size,PAGE_SIZE ); - -if (fb_size > dev_priv->vram_stolen_size) { - sizes->surface_bpp =16 ; - sizes->surface_depth =16 ; - } - -return psbfb_create (fb_helper, sizes); -} - -static const struct drm_fb_helper_funcs psb_fb_helper_funcs = { - .fb_probe = psbfb_probe, -}; - -static int psb_fbdev_destroy (struct drm_device *dev, -struct drm_fb_helper *fb_helper) -{ -struct drm_framebuffer *fb = fb_helper->fb; - -drm_fb_helper_unregister_info (fb_helper); - -drm_fb_helper_fini (fb_helper); -drm_framebuffer_unregister_private (fb); -drm_framebuffer_cleanup (fb); - -if (fb->obj[0 ]) -drm_gem_object_put (fb->obj[0 ]); -kfree (fb); - -return 0 ; -} - -int psb_fbdev_init (struct drm_device *dev) -{ -struct drm_fb_helper *fb_helper; -struct drm_psb_private *dev_priv =to_drm_psb_private (dev); -int ret; - - fb_helper =kzalloc (sizeof (*fb_helper),GFP_KERNEL ); -if (!fb_helper) { -dev_err (dev->dev,"no memory\n" ); -return -ENOMEM ; - } - - dev_priv->fb_helper = fb_helper; - -drm_fb_helper_prepare (dev, fb_helper,32 , &psb_fb_helper_funcs); - - ret =drm_fb_helper_init (dev, fb_helper); -if (ret) - goto free; - -/* disable all the possible outputs/crtcs before entering KMS mode */ -drm_helper_disable_unused_functions (dev); - - ret =drm_fb_helper_initial_config (fb_helper); -if (ret) - goto fini; - -return 0 ; - -fini: -drm_fb_helper_fini (fb_helper); -free: -drm_fb_helper_unprepare (fb_helper); -kfree (fb_helper); -return ret; -} - -static void psb_fbdev_fini (struct drm_device *dev) -{ -struct drm_psb_private *dev_priv =to_drm_psb_private (dev); - -if (!dev_priv->fb_helper) -return ; - -psb_fbdev_destroy (dev, dev_priv->fb_helper); -drm_fb_helper_unprepare (dev_priv->fb_helper); -kfree (dev_priv->fb_helper); - dev_priv->fb_helper =NULL ; -} -static const struct drm_mode_config_funcs psb_mode_funcs = { .fb_create = psb_user_framebuffer_create, .output_poll_changed = drm_fb_helper_output_poll_changed,drivers/gpu/drm/gma500/psb_drv.h +17
-1@@ -610,7 +610,24 @@ extern void psb_lid_timer_takedown(struct drm_psb_private *dev_priv);/* modesetting */ extern void psb_modeset_init (struct drm_device *dev);extern void psb_modeset_cleanup (struct drm_device *dev); + +/* framebuffer */ +extern struct drm_framebuffer *psb_framebuffer_create (struct drm_device *dev, +const struct drm_mode_fb_cmd2 *mode_cmd, +struct drm_gem_object *obj); + +/* fbdev */ +#if defined(CONFIG_DRM_FBDEV_EMULATION )extern int psb_fbdev_init (struct drm_device *dev); +extern void psb_fbdev_fini (struct drm_device *dev); +#else +int psb_fbdev_init (struct drm_device *dev) +{ +return 0 ; +} +void psb_fbdev_fini (struct drm_device *dev) +{ } +#endif /* backlight.c */ int gma_backlight_init (struct drm_device *dev); --2.39.2
Signature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Ivo Totev
Patrik Jakobsson
maintainerRe: [PATCH 2/7] drm/gma500: Move fbdev code into separate source file
Quoted 13 lines · Thomas Zimmermann
Hi
Am 27.02.23 um 08:10 schrieb Patrik Jakobsson:
Quoted 9 lines · Thomas Zimmermann
Quoted 7 lines
Move the fbdev emulation from
framebuffer.cintofbdev.c. Only build the source code if theKconfigsymbol has been selected. Remaining inframebuffer.cis gma500's code for DRM frambuffers. No functional hanges.Signed-off-by Thomas Zimmermann <[email protected]>
Quoted 7 lines
Quoted 2 lines
Hi Thomas, this patch doesn't apply to drm-misc. I seem to be missing drm_fb_helper_prepare/unprepare().
Could be. I'm on drm-tip for development. And we're in the merge window, which is a bad time to sync-ing trees. Let me see if I can easiyl backmerge now. Or otherwise things should stabilize after -rc1 has been tagged.
No worries, I'll just review this against drm-tip instead.
Quoted 760 lines
Best regards
ThomasQuoted 743 lines
-Patrik
Quoted 740 lines
--- drivers/gpu/drm/gma500/Makefile | 1 + drivers/gpu/drm/gma500/fbdev.c | 325 +++++++++++++++++++++++++++ drivers/gpu/drm/gma500/framebuffer.c | 318 +------------------------- drivers/gpu/drm/gma500/psb_drv.h | 17 ++ 4 files changed, 346 insertions(+), 315 deletions(-)create mode 100644
drivers/gpu/drm/gma500/fbdev.cdrivers/gpu/drm/gma500/Makefile +1
-0@@ -38,5 +38,6 @@ gma500_gfx-y += \ psb_irq.o gma500_gfx-$(CONFIG_ACPI) += opregion.o +gma500_gfx-$(CONFIG_DRM_FBDEV_EMULATION) += fbdev.o obj-$(CONFIG_DRM_GMA500) += gma500_gfx.odrivers/gpu/drm/gma500/fbdev.c new file +325
-0@@ -0,0 +1,325 @@ +// SPDX-License-Identifier: GPL-2.0-only +/************************************************************************** +* Copyright (c) 2007-2011, Intel Corporation. +* All Rights Reserved. +* +**************************************************************************/ + +#include <linux/pfn_t.h> + +#include <drm/drm_crtc_helper.h> +#include <drm/drm_fb_helper.h> +#include <drm/drm_framebuffer.h> + +#include "gem.h" +#include "psb_drv.h" + +/* +* VM area struct +*/ + +static vm_fault_t psbfb_vm_fault (struct vm_fault *vmf) +{ +struct vm_area_struct *vma = vmf->vma; +struct drm_framebuffer *fb = vma->vm_private_data; +struct drm_device *dev = fb->dev; +struct drm_psb_private *dev_priv =to_drm_psb_private (dev); +struct psb_gem_object *pobj =to_psb_gem_object (fb->obj[0 ]); +int page_num; +int i; +unsigned long address; +vm_fault_t ret =VM_FAULT_SIGBUS ; +unsigned long pfn; +unsigned long phys_addr = (unsigned long )dev_priv->stolen_base + pobj->offset; + + page_num =vma_pages (vma); + address = vmf->address - (vmf->pgoff <<PAGE_SHIFT ); + + vma->vm_page_prot =pgprot_noncached (vma->vm_page_prot); + +for (i =0 ; i < page_num; i++) { + pfn = (phys_addr >>PAGE_SHIFT ); + + ret =vmf_insert_mixed (vma, address,__pfn_to_pfn_t (pfn,PFN_DEV )); +if (unlikely (ret &VM_FAULT_ERROR )) +break ; + address +=PAGE_SIZE ; + phys_addr +=PAGE_SIZE ; + } +return ret; +} + +static void psbfb_vm_open (struct vm_area_struct *vma) +{ } + +static void psbfb_vm_close (struct vm_area_struct *vma) +{ } + +static const struct vm_operations_struct psbfb_vm_ops = { + .fault = psbfb_vm_fault, + .open = psbfb_vm_open, + .close = psbfb_vm_close +}; + +/* +* struct fb_ops +*/ + +#define CMAP_TOHW (_val, _width) ((((_val) << (_width)) + 0x7FFF - (_val)) >> 16) + +static int psbfb_setcolreg (unsigned int regno, +unsigned int red,unsigned int green, +unsigned int blue,unsigned int transp, +struct fb_info *info) +{ +struct drm_fb_helper *fb_helper = info->par; +struct drm_framebuffer *fb = fb_helper->fb; +uint32_t v; + +if (!fb) +return -ENOMEM ; + +if (regno >255 ) +return 1 ; + + red =CMAP_TOHW (red, info->var.red.length); + blue =CMAP_TOHW (blue, info->var.blue.length); + green =CMAP_TOHW (green, info->var.green.length); + transp =CMAP_TOHW (transp, info->var.transp.length); + + v = (red << info->var.red.offset) | + (green << info->var.green.offset) | + (blue << info->var.blue.offset) | + (transp << info->var.transp.offset); + +if (regno <16 ) { +switch (fb->format->cpp[0 ] *8 ) { +case 16 : + ((uint32_t *) info->pseudo_palette)[regno] = v; +break ; +case 24 : +case 32 : + ((uint32_t *) info->pseudo_palette)[regno] = v; +break ; + } + } + +return 0 ; +} + +static int psbfb_mmap (struct fb_info *info,struct vm_area_struct *vma) +{ +struct drm_fb_helper *fb_helper = info->par; +struct drm_framebuffer *fb = fb_helper->fb; + +if (vma->vm_pgoff !=0 ) +return -EINVAL ; +if (vma->vm_pgoff > (~0UL >>PAGE_SHIFT )) +return -EINVAL ; + +/* +* If this is a GEM object then info->screen_base is the virtual +* kernel remapping of the object. FIXME: Review if this is +* suitable for our mmap work +*/ + vma->vm_ops = &psbfb_vm_ops; + vma->vm_private_data = (void *)fb; + vma->vm_flags |=VM_IO |VM_MIXEDMAP |VM_DONTEXPAND |VM_DONTDUMP ; + +return 0 ; +} + +static const struct fb_ops psbfb_unaccel_ops = { + .owner =THIS_MODULE , +DRM_FB_HELPER_DEFAULT_OPS , + .fb_setcolreg = psbfb_setcolreg, + .fb_read = drm_fb_helper_cfb_read, + .fb_write = drm_fb_helper_cfb_write, + .fb_fillrect = drm_fb_helper_cfb_fillrect, + .fb_copyarea = drm_fb_helper_cfb_copyarea, + .fb_imageblit = drm_fb_helper_cfb_imageblit, + .fb_mmap = psbfb_mmap, +}; + +/* +* struct drm_fb_helper_funcs +*/ + +static int psbfb_create (struct drm_fb_helper *fb_helper, +struct drm_fb_helper_surface_size *sizes) +{ +struct drm_device *dev = fb_helper->dev; +struct drm_psb_private *dev_priv =to_drm_psb_private (dev); +struct pci_dev *pdev =to_pci_dev (dev->dev); +struct fb_info *info; +struct drm_framebuffer *fb; +struct drm_mode_fb_cmd2 mode_cmd; +int size; +int ret; +struct psb_gem_object *backing; +struct drm_gem_object *obj; +u32 bpp, depth; + + mode_cmd.width = sizes->surface_width; + mode_cmd.height = sizes->surface_height; + bpp = sizes->surface_bpp; + depth = sizes->surface_depth; + +/* No 24bit packed */ +if (bpp ==24 ) + bpp =32 ; + + mode_cmd.pitches[0 ] =ALIGN (mode_cmd.width *DIV_ROUND_UP (bpp,8 ),64 ); + + size = mode_cmd.pitches[0 ] * mode_cmd.height; + size =ALIGN (size,PAGE_SIZE ); + +/* Allocate the framebuffer in the GTT with stolen page backing */ + backing =psb_gem_create (dev, size,"fb" , true,PAGE_SIZE ); +if (IS_ERR (backing)) +return PTR_ERR (backing); + obj = &backing->base; + +memset (dev_priv->vram_addr + backing->offset,0 , size); + + info =drm_fb_helper_alloc_info (fb_helper); +if (IS_ERR (info)) { + ret =PTR_ERR (info); + goto err_drm_gem_object_put; + } + + mode_cmd.pixel_format =drm_mode_legacy_fb_format (bpp, depth); + + fb =psb_framebuffer_create (dev, &mode_cmd, obj); +if (IS_ERR (fb)) { + ret =PTR_ERR (fb); + goto err_drm_gem_object_put; + } + + fb_helper->fb = fb; + + info->fbops = &psbfb_unaccel_ops; + + info->fix.smem_start = dev_priv->fb_base; + info->fix.smem_len = size; + info->fix.ywrapstep =0 ; + info->fix.ypanstep =0 ; + +/* Accessed stolen memory directly */ + info->screen_base = dev_priv->vram_addr + backing->offset; + info->screen_size = size; + +drm_fb_helper_fill_info (info, fb_helper, sizes); + + info->fix.mmio_start =pci_resource_start (pdev,0 ); + info->fix.mmio_len =pci_resource_len (pdev,0 ); + +/* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */ + +dev_dbg (dev->dev,"allocated %dx%d fb\n" , fb->width, fb->height); + +return 0 ; + +err_drm_gem_object_put: +drm_gem_object_put (obj); +return ret; +} + +static int psbfb_probe (struct drm_fb_helper *fb_helper, +struct drm_fb_helper_surface_size *sizes) +{ +struct drm_device *dev = fb_helper->dev; +struct drm_psb_private *dev_priv =to_drm_psb_private (dev); +unsigned int fb_size; +int bytespp; + + bytespp = sizes->surface_bpp /8 ; +if (bytespp ==3 )/* no 24bit packed */ + bytespp =4 ; + +/* +* If the mode will not fit in 32bit then switch to 16bit to get +* a console on full resolution. The X mode setting server will +* allocate its own 32bit GEM framebuffer +*/ + fb_size =ALIGN (sizes->surface_width * bytespp,64 ) * + sizes->surface_height; + fb_size =ALIGN (fb_size,PAGE_SIZE ); + +if (fb_size > dev_priv->vram_stolen_size) { + sizes->surface_bpp =16 ; + sizes->surface_depth =16 ; + } + +return psbfb_create (fb_helper, sizes); +} + +static const struct drm_fb_helper_funcs psb_fb_helper_funcs = { + .fb_probe = psbfb_probe, +}; + +static int psb_fbdev_destroy (struct drm_device *dev, +struct drm_fb_helper *fb_helper) +{ +struct drm_framebuffer *fb = fb_helper->fb; + +drm_fb_helper_unregister_info (fb_helper); + +drm_fb_helper_fini (fb_helper); +drm_framebuffer_unregister_private (fb); +drm_framebuffer_cleanup (fb); + +if (fb->obj[0 ]) +drm_gem_object_put (fb->obj[0 ]); +kfree (fb); + +return 0 ; +} + +int psb_fbdev_init (struct drm_device *dev) +{ +struct drm_fb_helper *fb_helper; +struct drm_psb_private *dev_priv =to_drm_psb_private (dev); +int ret; + + fb_helper =kzalloc (sizeof (*fb_helper),GFP_KERNEL ); +if (!fb_helper) +return -ENOMEM ; + + dev_priv->fb_helper = fb_helper; + +drm_fb_helper_prepare (dev, fb_helper,32 , &psb_fb_helper_funcs); + + ret =drm_fb_helper_init (dev, fb_helper); +if (ret) + goto free; + +/* disable all the possible outputs/crtcs before entering KMS mode */ +drm_helper_disable_unused_functions (dev); + + ret =drm_fb_helper_initial_config (fb_helper); +if (ret) + goto fini; + +return 0 ; + +fini: +drm_fb_helper_fini (fb_helper); +free: +drm_fb_helper_unprepare (fb_helper); +kfree (fb_helper); +return ret; +} + +void psb_fbdev_fini (struct drm_device *dev) +{ +struct drm_psb_private *dev_priv =to_drm_psb_private (dev); + +if (!dev_priv->fb_helper) +return ; + +psb_fbdev_destroy (dev, dev_priv->fb_helper); +drm_fb_helper_unprepare (dev_priv->fb_helper); +kfree (dev_priv->fb_helper); + dev_priv->fb_helper =NULL ; +}drivers/gpu/drm/gma500/framebuffer.c +3
-315@@ -5,16 +5,12 @@* **************************************************************************/ -#include <linux/pfn_t.h> - -#include <drm/drm_crtc_helper.h> #include <drm/drm_fb_helper.h> #include <drm/drm_framebuffer.h> #include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_modeset_helper.h> #include "framebuffer.h" -#include "gem.h" #include "psb_drv.h" static const struct drm_framebuffer_funcs psb_fb_funcs = {@@ -22,126 +18,6 @@ static const struct drm_framebuffer_funcs psb_fb_funcs = { .create_handle = drm_gem_fb_create_handle, }; -#define CMAP_TOHW (_val, _width) ((((_val) << (_width)) + 0x7FFF - (_val)) >> 16) - -static int psbfb_setcolreg (unsigned regno,unsigned red,unsigned green, -unsigned blue,unsigned transp, -struct fb_info *info) -{ -struct drm_fb_helper *fb_helper = info->par; -struct drm_framebuffer *fb = fb_helper->fb; -uint32_t v; - -if (!fb) -return -ENOMEM ; - -if (regno >255 ) -return 1 ; - - red =CMAP_TOHW (red, info->var.red.length); - blue =CMAP_TOHW (blue, info->var.blue.length); - green =CMAP_TOHW (green, info->var.green.length); - transp =CMAP_TOHW (transp, info->var.transp.length); - - v = (red << info->var.red.offset) | - (green << info->var.green.offset) | - (blue << info->var.blue.offset) | - (transp << info->var.transp.offset); - -if (regno <16 ) { -switch (fb->format->cpp[0 ] *8 ) { -case 16 : - ((uint32_t *) info->pseudo_palette)[regno] = v; -break ; -case 24 : -case 32 : - ((uint32_t *) info->pseudo_palette)[regno] = v; -break ; - } - } - -return 0 ; -} - -static vm_fault_t psbfb_vm_fault (struct vm_fault *vmf) -{ -struct vm_area_struct *vma = vmf->vma; -struct drm_framebuffer *fb = vma->vm_private_data; -struct drm_device *dev = fb->dev; -struct drm_psb_private *dev_priv =to_drm_psb_private (dev); -struct psb_gem_object *pobj =to_psb_gem_object (fb->obj[0 ]); -int page_num; -int i; -unsigned long address; -vm_fault_t ret =VM_FAULT_SIGBUS ; -unsigned long pfn; -unsigned long phys_addr = (unsigned long )dev_priv->stolen_base + pobj->offset; - - page_num =vma_pages (vma); - address = vmf->address - (vmf->pgoff <<PAGE_SHIFT ); - - vma->vm_page_prot =pgprot_noncached (vma->vm_page_prot); - -for (i =0 ; i < page_num; i++) { - pfn = (phys_addr >>PAGE_SHIFT ); - - ret =vmf_insert_mixed (vma, address, -__pfn_to_pfn_t (pfn,PFN_DEV )); -if (unlikely (ret &VM_FAULT_ERROR )) -break ; - address +=PAGE_SIZE ; - phys_addr +=PAGE_SIZE ; - } -return ret; -} - -static void psbfb_vm_open (struct vm_area_struct *vma) -{ -} - -static void psbfb_vm_close (struct vm_area_struct *vma) -{ -} - -static const struct vm_operations_struct psbfb_vm_ops = { - .fault = psbfb_vm_fault, - .open = psbfb_vm_open, - .close = psbfb_vm_close -}; - -static int psbfb_mmap (struct fb_info *info,struct vm_area_struct *vma) -{ -struct drm_fb_helper *fb_helper = info->par; -struct drm_framebuffer *fb = fb_helper->fb; - -if (vma->vm_pgoff !=0 ) -return -EINVAL ; -if (vma->vm_pgoff > (~0UL >>PAGE_SHIFT )) -return -EINVAL ; - -/* -* If this is a GEM object then info->screen_base is the virtual -* kernel remapping of the object. FIXME: Review if this is -* suitable for our mmap work -*/ - vma->vm_ops = &psbfb_vm_ops; - vma->vm_private_data = (void *)fb; - vma->vm_flags |=VM_IO |VM_MIXEDMAP |VM_DONTEXPAND |VM_DONTDUMP ; -return 0 ; -} - -static const struct fb_ops psbfb_unaccel_ops = { - .owner =THIS_MODULE , -DRM_FB_HELPER_DEFAULT_OPS , - .fb_setcolreg = psbfb_setcolreg, - .fb_read = drm_fb_helper_cfb_read, - .fb_write = drm_fb_helper_cfb_write, - .fb_fillrect = drm_fb_helper_cfb_fillrect, - .fb_copyarea = drm_fb_helper_cfb_copyarea, - .fb_imageblit = drm_fb_helper_cfb_imageblit, - .fb_mmap = psbfb_mmap, -}; -/** * psb_framebuffer_init - initialize a framebuffer * @dev: our DRM device @@ -192,11 +68,9 @@ static int psb_framebuffer_init(struct drm_device *dev,* * TODO: review object references */ - -static struct drm_framebuffer *psb_framebuffer_create - (struct drm_device *dev, -const struct drm_mode_fb_cmd2 *mode_cmd, -struct drm_gem_object *obj) +struct drm_framebuffer *psb_framebuffer_create (struct drm_device *dev, +const struct drm_mode_fb_cmd2 *mode_cmd, +struct drm_gem_object *obj) {struct drm_framebuffer *fb;int ret;@@ -213,93 +87,6 @@ static struct drm_framebuffer *psb_framebuffer_createreturn fb; } -/** -* psbfb_create - create a framebuffer -* @fb_helper: the framebuffer helper -* @sizes: specification of the layout -* -* Create a framebuffer to the specifications provided -*/ -static int psbfb_create (struct drm_fb_helper *fb_helper, -struct drm_fb_helper_surface_size *sizes) -{ -struct drm_device *dev = fb_helper->dev; -struct drm_psb_private *dev_priv =to_drm_psb_private (dev); -struct pci_dev *pdev =to_pci_dev (dev->dev); -struct fb_info *info; -struct drm_framebuffer *fb; -struct drm_mode_fb_cmd2 mode_cmd; -int size; -int ret; -struct psb_gem_object *backing; -struct drm_gem_object *obj; -u32 bpp, depth; - - mode_cmd.width = sizes->surface_width; - mode_cmd.height = sizes->surface_height; - bpp = sizes->surface_bpp; - depth = sizes->surface_depth; - -/* No 24bit packed */ -if (bpp ==24 ) - bpp =32 ; - - mode_cmd.pitches[0 ] =ALIGN (mode_cmd.width *DIV_ROUND_UP (bpp,8 ),64 ); - - size = mode_cmd.pitches[0 ] * mode_cmd.height; - size =ALIGN (size,PAGE_SIZE ); - -/* Allocate the framebuffer in the GTT with stolen page backing */ - backing =psb_gem_create (dev, size,"fb" , true,PAGE_SIZE ); -if (IS_ERR (backing)) -return PTR_ERR (backing); - obj = &backing->base; - -memset (dev_priv->vram_addr + backing->offset,0 , size); - - info =drm_fb_helper_alloc_info (fb_helper); -if (IS_ERR (info)) { - ret =PTR_ERR (info); - goto err_drm_gem_object_put; - } - - mode_cmd.pixel_format =drm_mode_legacy_fb_format (bpp, depth); - - fb =psb_framebuffer_create (dev, &mode_cmd, obj); -if (IS_ERR (fb)) { - ret =PTR_ERR (fb); - goto err_drm_gem_object_put; - } - - fb_helper->fb = fb; - - info->fbops = &psbfb_unaccel_ops; - - info->fix.smem_start = dev_priv->fb_base; - info->fix.smem_len = size; - info->fix.ywrapstep =0 ; - info->fix.ypanstep =0 ; - -/* Accessed stolen memory directly */ - info->screen_base = dev_priv->vram_addr + backing->offset; - info->screen_size = size; - -drm_fb_helper_fill_info (info, fb_helper, sizes); - - info->fix.mmio_start =pci_resource_start (pdev,0 ); - info->fix.mmio_len =pci_resource_len (pdev,0 ); - -/* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */ - -dev_dbg (dev->dev,"allocated %dx%d fb\n" , fb->width, fb->height); - -return 0 ; - -err_drm_gem_object_put: -drm_gem_object_put (obj); -return ret; -} -/** * psb_user_framebuffer_create - create framebuffer * @dev: our DRM device @@ -331,105 +118,6 @@ static struct drm_framebuffer *psb_user_framebuffer_createreturn fb; } -static int psbfb_probe (struct drm_fb_helper *fb_helper, -struct drm_fb_helper_surface_size *sizes) -{ -struct drm_device *dev = fb_helper->dev; -struct drm_psb_private *dev_priv =to_drm_psb_private (dev); -unsigned int fb_size; -int bytespp; - - bytespp = sizes->surface_bpp /8 ; -if (bytespp ==3 )/* no 24bit packed */ - bytespp =4 ; - -/* If the mode will not fit in 32bit then switch to 16bit to get -a console on full resolution. The X mode setting server will -allocate its own 32bit GEM framebuffer */ - fb_size =ALIGN (sizes->surface_width * bytespp,64 ) * - sizes->surface_height; - fb_size =ALIGN (fb_size,PAGE_SIZE ); - -if (fb_size > dev_priv->vram_stolen_size) { - sizes->surface_bpp =16 ; - sizes->surface_depth =16 ; - } - -return psbfb_create (fb_helper, sizes); -} - -static const struct drm_fb_helper_funcs psb_fb_helper_funcs = { - .fb_probe = psbfb_probe, -}; - -static int psb_fbdev_destroy (struct drm_device *dev, -struct drm_fb_helper *fb_helper) -{ -struct drm_framebuffer *fb = fb_helper->fb; - -drm_fb_helper_unregister_info (fb_helper); - -drm_fb_helper_fini (fb_helper); -drm_framebuffer_unregister_private (fb); -drm_framebuffer_cleanup (fb); - -if (fb->obj[0 ]) -drm_gem_object_put (fb->obj[0 ]); -kfree (fb); - -return 0 ; -} - -int psb_fbdev_init (struct drm_device *dev) -{ -struct drm_fb_helper *fb_helper; -struct drm_psb_private *dev_priv =to_drm_psb_private (dev); -int ret; - - fb_helper =kzalloc (sizeof (*fb_helper),GFP_KERNEL ); -if (!fb_helper) { -dev_err (dev->dev,"no memory\n" ); -return -ENOMEM ; - } - - dev_priv->fb_helper = fb_helper; - -drm_fb_helper_prepare (dev, fb_helper,32 , &psb_fb_helper_funcs); - - ret =drm_fb_helper_init (dev, fb_helper); -if (ret) - goto free; - -/* disable all the possible outputs/crtcs before entering KMS mode */ -drm_helper_disable_unused_functions (dev); - - ret =drm_fb_helper_initial_config (fb_helper); -if (ret) - goto fini; - -return 0 ; - -fini: -drm_fb_helper_fini (fb_helper); -free: -drm_fb_helper_unprepare (fb_helper); -kfree (fb_helper); -return ret; -} - -static void psb_fbdev_fini (struct drm_device *dev) -{ -struct drm_psb_private *dev_priv =to_drm_psb_private (dev); - -if (!dev_priv->fb_helper) -return ; - -psb_fbdev_destroy (dev, dev_priv->fb_helper); -drm_fb_helper_unprepare (dev_priv->fb_helper); -kfree (dev_priv->fb_helper); - dev_priv->fb_helper =NULL ; -} -static const struct drm_mode_config_funcs psb_mode_funcs = { .fb_create = psb_user_framebuffer_create, .output_poll_changed = drm_fb_helper_output_poll_changed,drivers/gpu/drm/gma500/psb_drv.h +17
-0@@ -610,7 +610,24 @@ extern void psb_lid_timer_takedown(struct drm_psb_private *dev_priv);/* modesetting */ extern void psb_modeset_init (struct drm_device *dev);extern void psb_modeset_cleanup (struct drm_device *dev); + +/* framebuffer */ +extern struct drm_framebuffer *psb_framebuffer_create (struct drm_device *dev, +const struct drm_mode_fb_cmd2 *mode_cmd, +struct drm_gem_object *obj); + +/* fbdev */ +#if defined(CONFIG_DRM_FBDEV_EMULATION )extern int psb_fbdev_init (struct drm_device *dev); +extern void psb_fbdev_fini (struct drm_device *dev); +#else +int psb_fbdev_init (struct drm_device *dev) +{ +return 0 ; +} +void psb_fbdev_fini (struct drm_device *dev) +{ } +#endif Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/gma500/psb_drv.h +0
-1/* backlight.c */ int gma_backlight_init (struct drm_device *dev); --2.39.2
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev
Patrik Jakobsson
maintainerRe: [PATCH 2/7] drm/gma500: Move fbdev code into separate source file
In reply to Thomas ZimmermannQuoted 725 lines · Thomas Zimmermann
Move the fbdev emulation from
framebuffer.cintofbdev.c. Only build the source code if theKconfigsymbol has been selected. Remaining inframebuffer.cis gma500's code for DRM frambuffers. No functional hanges.Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/gma500/Makefile | 1 + drivers/gpu/drm/gma500/fbdev.c | 325 +++++++++++++++++++++++++++ drivers/gpu/drm/gma500/framebuffer.c | 318 +------------------------- drivers/gpu/drm/gma500/psb_drv.h | 17 ++ 4 files changed, 346 insertions(+), 315 deletions(-) create mode 100644 drivers/gpu/drm/gma500/fbdev.cdrivers/gpu/drm/gma500/Makefile +1
-0@@ -38,5 +38,6 @@ gma500_gfx-y += \ psb_irq.o gma500_gfx-$(CONFIG_ACPI) += opregion.o +gma500_gfx-$(CONFIG_DRM_FBDEV_EMULATION) += fbdev.o obj-$(CONFIG_DRM_GMA500) += gma500_gfx.odrivers/gpu/drm/gma500/fbdev.c new file +325
-0@@ -0,0 +1,325 @@ +// SPDX-License-Identifier: GPL-2.0-only +/************************************************************************** +* Copyright (c) 2007-2011, Intel Corporation. +* All Rights Reserved. +* +**************************************************************************/ + +#include <linux/pfn_t.h> + +#include <drm/drm_crtc_helper.h> +#include <drm/drm_fb_helper.h> +#include <drm/drm_framebuffer.h> + +#include "gem.h" +#include "psb_drv.h" + +/* +* VM area struct +*/ + +static vm_fault_t psbfb_vm_fault (struct vm_fault *vmf) +{ +struct vm_area_struct *vma = vmf->vma; +struct drm_framebuffer *fb = vma->vm_private_data; +struct drm_device *dev = fb->dev; +struct drm_psb_private *dev_priv =to_drm_psb_private (dev); +struct psb_gem_object *pobj =to_psb_gem_object (fb->obj[0 ]); +int page_num; +int i; +unsigned long address; +vm_fault_t ret =VM_FAULT_SIGBUS ; +unsigned long pfn; +unsigned long phys_addr = (unsigned long )dev_priv->stolen_base + pobj->offset; + + page_num =vma_pages (vma); + address = vmf->address - (vmf->pgoff <<PAGE_SHIFT ); + + vma->vm_page_prot =pgprot_noncached (vma->vm_page_prot); + +for (i =0 ; i < page_num; i++) { + pfn = (phys_addr >>PAGE_SHIFT ); + + ret =vmf_insert_mixed (vma, address,__pfn_to_pfn_t (pfn,PFN_DEV )); +if (unlikely (ret &VM_FAULT_ERROR )) +break ; + address +=PAGE_SIZE ; + phys_addr +=PAGE_SIZE ; + } +return ret; +} + +static void psbfb_vm_open (struct vm_area_struct *vma) +{ } + +static void psbfb_vm_close (struct vm_area_struct *vma) +{ } + +static const struct vm_operations_struct psbfb_vm_ops = { + .fault = psbfb_vm_fault, + .open = psbfb_vm_open, + .close = psbfb_vm_close +}; + +/* +* struct fb_ops +*/ + +#define CMAP_TOHW (_val, _width) ((((_val) << (_width)) + 0x7FFF - (_val)) >> 16) + +static int psbfb_setcolreg (unsigned int regno, +unsigned int red,unsigned int green, +unsigned int blue,unsigned int transp, +struct fb_info *info) +{ +struct drm_fb_helper *fb_helper = info->par; +struct drm_framebuffer *fb = fb_helper->fb; +uint32_t v; + +if (!fb) +return -ENOMEM ; + +if (regno >255 ) +return 1 ; + + red =CMAP_TOHW (red, info->var.red.length); + blue =CMAP_TOHW (blue, info->var.blue.length); + green =CMAP_TOHW (green, info->var.green.length); + transp =CMAP_TOHW (transp, info->var.transp.length); + + v = (red << info->var.red.offset) | + (green << info->var.green.offset) | + (blue << info->var.blue.offset) | + (transp << info->var.transp.offset); + +if (regno <16 ) { +switch (fb->format->cpp[0 ] *8 ) { +case 16 : + ((uint32_t *) info->pseudo_palette)[regno] = v; +break ; +case 24 : +case 32 : + ((uint32_t *) info->pseudo_palette)[regno] = v; +break ; + } + } + +return 0 ; +} + +static int psbfb_mmap (struct fb_info *info,struct vm_area_struct *vma) +{ +struct drm_fb_helper *fb_helper = info->par; +struct drm_framebuffer *fb = fb_helper->fb; + +if (vma->vm_pgoff !=0 ) +return -EINVAL ; +if (vma->vm_pgoff > (~0UL >>PAGE_SHIFT )) +return -EINVAL ; + +/* +* If this is a GEM object then info->screen_base is the virtual +* kernel remapping of the object. FIXME: Review if this is +* suitable for our mmap work +*/ + vma->vm_ops = &psbfb_vm_ops; + vma->vm_private_data = (void *)fb; + vma->vm_flags |=VM_IO |VM_MIXEDMAP |VM_DONTEXPAND |VM_DONTDUMP ; + +return 0 ; +} + +static const struct fb_ops psbfb_unaccel_ops = { + .owner =THIS_MODULE , +DRM_FB_HELPER_DEFAULT_OPS , + .fb_setcolreg = psbfb_setcolreg, + .fb_read = drm_fb_helper_cfb_read, + .fb_write = drm_fb_helper_cfb_write, + .fb_fillrect = drm_fb_helper_cfb_fillrect, + .fb_copyarea = drm_fb_helper_cfb_copyarea, + .fb_imageblit = drm_fb_helper_cfb_imageblit, + .fb_mmap = psbfb_mmap, +}; + +/* +* struct drm_fb_helper_funcs +*/ + +static int psbfb_create (struct drm_fb_helper *fb_helper, +struct drm_fb_helper_surface_size *sizes) +{ +struct drm_device *dev = fb_helper->dev; +struct drm_psb_private *dev_priv =to_drm_psb_private (dev); +struct pci_dev *pdev =to_pci_dev (dev->dev); +struct fb_info *info; +struct drm_framebuffer *fb; +struct drm_mode_fb_cmd2 mode_cmd; +int size; +int ret; +struct psb_gem_object *backing; +struct drm_gem_object *obj; +u32 bpp, depth; + + mode_cmd.width = sizes->surface_width; + mode_cmd.height = sizes->surface_height; + bpp = sizes->surface_bpp; + depth = sizes->surface_depth; + +/* No 24bit packed */ +if (bpp ==24 ) + bpp =32 ; + + mode_cmd.pitches[0 ] =ALIGN (mode_cmd.width *DIV_ROUND_UP (bpp,8 ),64 ); + + size = mode_cmd.pitches[0 ] * mode_cmd.height; + size =ALIGN (size,PAGE_SIZE ); + +/* Allocate the framebuffer in the GTT with stolen page backing */ + backing =psb_gem_create (dev, size,"fb" , true,PAGE_SIZE ); +if (IS_ERR (backing)) +return PTR_ERR (backing); + obj = &backing->base; + +memset (dev_priv->vram_addr + backing->offset,0 , size); + + info =drm_fb_helper_alloc_info (fb_helper); +if (IS_ERR (info)) { + ret =PTR_ERR (info); + goto err_drm_gem_object_put; + } + + mode_cmd.pixel_format =drm_mode_legacy_fb_format (bpp, depth); + + fb =psb_framebuffer_create (dev, &mode_cmd, obj); +if (IS_ERR (fb)) { + ret =PTR_ERR (fb); + goto err_drm_gem_object_put; + } + + fb_helper->fb = fb; + + info->fbops = &psbfb_unaccel_ops; + + info->fix.smem_start = dev_priv->fb_base; + info->fix.smem_len = size; + info->fix.ywrapstep =0 ; + info->fix.ypanstep =0 ; + +/* Accessed stolen memory directly */ + info->screen_base = dev_priv->vram_addr + backing->offset; + info->screen_size = size; + +drm_fb_helper_fill_info (info, fb_helper, sizes); + + info->fix.mmio_start =pci_resource_start (pdev,0 ); + info->fix.mmio_len =pci_resource_len (pdev,0 ); + +/* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */ + +dev_dbg (dev->dev,"allocated %dx%d fb\n" , fb->width, fb->height); + +return 0 ; + +err_drm_gem_object_put: +drm_gem_object_put (obj); +return ret; +} + +static int psbfb_probe (struct drm_fb_helper *fb_helper, +struct drm_fb_helper_surface_size *sizes) +{ +struct drm_device *dev = fb_helper->dev; +struct drm_psb_private *dev_priv =to_drm_psb_private (dev); +unsigned int fb_size; +int bytespp; + + bytespp = sizes->surface_bpp /8 ; +if (bytespp ==3 )/* no 24bit packed */ + bytespp =4 ; + +/* +* If the mode will not fit in 32bit then switch to 16bit to get +* a console on full resolution. The X mode setting server will +* allocate its own 32bit GEM framebuffer +*/ + fb_size =ALIGN (sizes->surface_width * bytespp,64 ) * + sizes->surface_height; + fb_size =ALIGN (fb_size,PAGE_SIZE ); + +if (fb_size > dev_priv->vram_stolen_size) { + sizes->surface_bpp =16 ; + sizes->surface_depth =16 ; + } + +return psbfb_create (fb_helper, sizes); +} + +static const struct drm_fb_helper_funcs psb_fb_helper_funcs = { + .fb_probe = psbfb_probe, +}; + +static int psb_fbdev_destroy (struct drm_device *dev, +struct drm_fb_helper *fb_helper) +{ +struct drm_framebuffer *fb = fb_helper->fb; + +drm_fb_helper_unregister_info (fb_helper); + +drm_fb_helper_fini (fb_helper); +drm_framebuffer_unregister_private (fb); +drm_framebuffer_cleanup (fb); + +if (fb->obj[0 ]) +drm_gem_object_put (fb->obj[0 ]); +kfree (fb); + +return 0 ; +} + +int psb_fbdev_init (struct drm_device *dev) +{ +struct drm_fb_helper *fb_helper; +struct drm_psb_private *dev_priv =to_drm_psb_private (dev); +int ret; + + fb_helper =kzalloc (sizeof (*fb_helper),GFP_KERNEL ); +if (!fb_helper) +return -ENOMEM ; + + dev_priv->fb_helper = fb_helper; + +drm_fb_helper_prepare (dev, fb_helper,32 , &psb_fb_helper_funcs); + + ret =drm_fb_helper_init (dev, fb_helper); +if (ret) + goto free; + +/* disable all the possible outputs/crtcs before entering KMS mode */ +drm_helper_disable_unused_functions (dev); + + ret =drm_fb_helper_initial_config (fb_helper); +if (ret) + goto fini; + +return 0 ; + +fini: +drm_fb_helper_fini (fb_helper); +free: +drm_fb_helper_unprepare (fb_helper); +kfree (fb_helper); +return ret; +} + +void psb_fbdev_fini (struct drm_device *dev) +{ +struct drm_psb_private *dev_priv =to_drm_psb_private (dev); + +if (!dev_priv->fb_helper) +return ; + +psb_fbdev_destroy (dev, dev_priv->fb_helper); +drm_fb_helper_unprepare (dev_priv->fb_helper); +kfree (dev_priv->fb_helper); + dev_priv->fb_helper =NULL ; +}drivers/gpu/drm/gma500/framebuffer.c +3
-315@@ -5,16 +5,12 @@* **************************************************************************/ -#include <linux/pfn_t.h> - -#include <drm/drm_crtc_helper.h> #include <drm/drm_fb_helper.h> #include <drm/drm_framebuffer.h> #include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_modeset_helper.h> #include "framebuffer.h" -#include "gem.h" #include "psb_drv.h" static const struct drm_framebuffer_funcs psb_fb_funcs = {@@ -22,126 +18,6 @@ static const struct drm_framebuffer_funcs psb_fb_funcs = { .create_handle = drm_gem_fb_create_handle, }; -#define CMAP_TOHW (_val, _width) ((((_val) << (_width)) + 0x7FFF - (_val)) >> 16) - -static int psbfb_setcolreg (unsigned regno,unsigned red,unsigned green, -unsigned blue,unsigned transp, -struct fb_info *info) -{ -struct drm_fb_helper *fb_helper = info->par; -struct drm_framebuffer *fb = fb_helper->fb; -uint32_t v; - -if (!fb) -return -ENOMEM ; - -if (regno >255 ) -return 1 ; - - red =CMAP_TOHW (red, info->var.red.length); - blue =CMAP_TOHW (blue, info->var.blue.length); - green =CMAP_TOHW (green, info->var.green.length); - transp =CMAP_TOHW (transp, info->var.transp.length); - - v = (red << info->var.red.offset) | - (green << info->var.green.offset) | - (blue << info->var.blue.offset) | - (transp << info->var.transp.offset); - -if (regno <16 ) { -switch (fb->format->cpp[0 ] *8 ) { -case 16 : - ((uint32_t *) info->pseudo_palette)[regno] = v; -break ; -case 24 : -case 32 : - ((uint32_t *) info->pseudo_palette)[regno] = v; -break ; - } - } - -return 0 ; -} - -static vm_fault_t psbfb_vm_fault (struct vm_fault *vmf) -{ -struct vm_area_struct *vma = vmf->vma; -struct drm_framebuffer *fb = vma->vm_private_data; -struct drm_device *dev = fb->dev; -struct drm_psb_private *dev_priv =to_drm_psb_private (dev); -struct psb_gem_object *pobj =to_psb_gem_object (fb->obj[0 ]); -int page_num; -int i; -unsigned long address; -vm_fault_t ret =VM_FAULT_SIGBUS ; -unsigned long pfn; -unsigned long phys_addr = (unsigned long )dev_priv->stolen_base + pobj->offset; - - page_num =vma_pages (vma); - address = vmf->address - (vmf->pgoff <<PAGE_SHIFT ); - - vma->vm_page_prot =pgprot_noncached (vma->vm_page_prot); - -for (i =0 ; i < page_num; i++) { - pfn = (phys_addr >>PAGE_SHIFT ); - - ret =vmf_insert_mixed (vma, address, -__pfn_to_pfn_t (pfn,PFN_DEV )); -if (unlikely (ret &VM_FAULT_ERROR )) -break ; - address +=PAGE_SIZE ; - phys_addr +=PAGE_SIZE ; - } -return ret; -} - -static void psbfb_vm_open (struct vm_area_struct *vma) -{ -} - -static void psbfb_vm_close (struct vm_area_struct *vma) -{ -} - -static const struct vm_operations_struct psbfb_vm_ops = { - .fault = psbfb_vm_fault, - .open = psbfb_vm_open, - .close = psbfb_vm_close -}; - -static int psbfb_mmap (struct fb_info *info,struct vm_area_struct *vma) -{ -struct drm_fb_helper *fb_helper = info->par; -struct drm_framebuffer *fb = fb_helper->fb; - -if (vma->vm_pgoff !=0 ) -return -EINVAL ; -if (vma->vm_pgoff > (~0UL >>PAGE_SHIFT )) -return -EINVAL ; - -/* -* If this is a GEM object then info->screen_base is the virtual -* kernel remapping of the object. FIXME: Review if this is -* suitable for our mmap work -*/ - vma->vm_ops = &psbfb_vm_ops; - vma->vm_private_data = (void *)fb; - vma->vm_flags |=VM_IO |VM_MIXEDMAP |VM_DONTEXPAND |VM_DONTDUMP ; -return 0 ; -} - -static const struct fb_ops psbfb_unaccel_ops = { - .owner =THIS_MODULE , -DRM_FB_HELPER_DEFAULT_OPS , - .fb_setcolreg = psbfb_setcolreg, - .fb_read = drm_fb_helper_cfb_read, - .fb_write = drm_fb_helper_cfb_write, - .fb_fillrect = drm_fb_helper_cfb_fillrect, - .fb_copyarea = drm_fb_helper_cfb_copyarea, - .fb_imageblit = drm_fb_helper_cfb_imageblit, - .fb_mmap = psbfb_mmap, -}; -/** * psb_framebuffer_init - initialize a framebuffer * @dev: our DRM device @@ -192,11 +68,9 @@ static int psb_framebuffer_init(struct drm_device *dev,* * TODO: review object references */ - -static struct drm_framebuffer *psb_framebuffer_create - (struct drm_device *dev, -const struct drm_mode_fb_cmd2 *mode_cmd, -struct drm_gem_object *obj) +struct drm_framebuffer *psb_framebuffer_create (struct drm_device *dev, +const struct drm_mode_fb_cmd2 *mode_cmd, +struct drm_gem_object *obj) {struct drm_framebuffer *fb;int ret;@@ -213,93 +87,6 @@ static struct drm_framebuffer *psb_framebuffer_createreturn fb; } -/** -* psbfb_create - create a framebuffer -* @fb_helper: the framebuffer helper -* @sizes: specification of the layout -* -* Create a framebuffer to the specifications provided -*/ -static int psbfb_create (struct drm_fb_helper *fb_helper, -struct drm_fb_helper_surface_size *sizes) -{ -struct drm_device *dev = fb_helper->dev; -struct drm_psb_private *dev_priv =to_drm_psb_private (dev); -struct pci_dev *pdev =to_pci_dev (dev->dev); -struct fb_info *info; -struct drm_framebuffer *fb; -struct drm_mode_fb_cmd2 mode_cmd; -int size; -int ret; -struct psb_gem_object *backing; -struct drm_gem_object *obj; -u32 bpp, depth; - - mode_cmd.width = sizes->surface_width; - mode_cmd.height = sizes->surface_height; - bpp = sizes->surface_bpp; - depth = sizes->surface_depth; - -/* No 24bit packed */ -if (bpp ==24 ) - bpp =32 ; - - mode_cmd.pitches[0 ] =ALIGN (mode_cmd.width *DIV_ROUND_UP (bpp,8 ),64 ); - - size = mode_cmd.pitches[0 ] * mode_cmd.height; - size =ALIGN (size,PAGE_SIZE ); - -/* Allocate the framebuffer in the GTT with stolen page backing */ - backing =psb_gem_create (dev, size,"fb" , true,PAGE_SIZE ); -if (IS_ERR (backing)) -return PTR_ERR (backing); - obj = &backing->base; - -memset (dev_priv->vram_addr + backing->offset,0 , size); - - info =drm_fb_helper_alloc_info (fb_helper); -if (IS_ERR (info)) { - ret =PTR_ERR (info); - goto err_drm_gem_object_put; - } - - mode_cmd.pixel_format =drm_mode_legacy_fb_format (bpp, depth); - - fb =psb_framebuffer_create (dev, &mode_cmd, obj); -if (IS_ERR (fb)) { - ret =PTR_ERR (fb); - goto err_drm_gem_object_put; - } - - fb_helper->fb = fb; - - info->fbops = &psbfb_unaccel_ops; - - info->fix.smem_start = dev_priv->fb_base; - info->fix.smem_len = size; - info->fix.ywrapstep =0 ; - info->fix.ypanstep =0 ; - -/* Accessed stolen memory directly */ - info->screen_base = dev_priv->vram_addr + backing->offset; - info->screen_size = size; - -drm_fb_helper_fill_info (info, fb_helper, sizes); - - info->fix.mmio_start =pci_resource_start (pdev,0 ); - info->fix.mmio_len =pci_resource_len (pdev,0 ); - -/* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */ - -dev_dbg (dev->dev,"allocated %dx%d fb\n" , fb->width, fb->height); - -return 0 ; - -err_drm_gem_object_put: -drm_gem_object_put (obj); -return ret; -} -/** * psb_user_framebuffer_create - create framebuffer * @dev: our DRM device @@ -331,105 +118,6 @@ static struct drm_framebuffer *psb_user_framebuffer_createreturn fb; } -static int psbfb_probe (struct drm_fb_helper *fb_helper, -struct drm_fb_helper_surface_size *sizes) -{ -struct drm_device *dev = fb_helper->dev; -struct drm_psb_private *dev_priv =to_drm_psb_private (dev); -unsigned int fb_size; -int bytespp; - - bytespp = sizes->surface_bpp /8 ; -if (bytespp ==3 )/* no 24bit packed */ - bytespp =4 ; - -/* If the mode will not fit in 32bit then switch to 16bit to get -a console on full resolution. The X mode setting server will -allocate its own 32bit GEM framebuffer */ - fb_size =ALIGN (sizes->surface_width * bytespp,64 ) * - sizes->surface_height; - fb_size =ALIGN (fb_size,PAGE_SIZE ); - -if (fb_size > dev_priv->vram_stolen_size) { - sizes->surface_bpp =16 ; - sizes->surface_depth =16 ; - } - -return psbfb_create (fb_helper, sizes); -} - -static const struct drm_fb_helper_funcs psb_fb_helper_funcs = { - .fb_probe = psbfb_probe, -}; - -static int psb_fbdev_destroy (struct drm_device *dev, -struct drm_fb_helper *fb_helper) -{ -struct drm_framebuffer *fb = fb_helper->fb; - -drm_fb_helper_unregister_info (fb_helper); - -drm_fb_helper_fini (fb_helper); -drm_framebuffer_unregister_private (fb); -drm_framebuffer_cleanup (fb); - -if (fb->obj[0 ]) -drm_gem_object_put (fb->obj[0 ]); -kfree (fb); - -return 0 ; -} - -int psb_fbdev_init (struct drm_device *dev) -{ -struct drm_fb_helper *fb_helper; -struct drm_psb_private *dev_priv =to_drm_psb_private (dev); -int ret; - - fb_helper =kzalloc (sizeof (*fb_helper),GFP_KERNEL ); -if (!fb_helper) { -dev_err (dev->dev,"no memory\n" ); -return -ENOMEM ; - } - - dev_priv->fb_helper = fb_helper; - -drm_fb_helper_prepare (dev, fb_helper,32 , &psb_fb_helper_funcs); - - ret =drm_fb_helper_init (dev, fb_helper); -if (ret) - goto free; - -/* disable all the possible outputs/crtcs before entering KMS mode */ -drm_helper_disable_unused_functions (dev); - - ret =drm_fb_helper_initial_config (fb_helper); -if (ret) - goto fini; - -return 0 ; - -fini: -drm_fb_helper_fini (fb_helper); -free: -drm_fb_helper_unprepare (fb_helper); -kfree (fb_helper); -return ret; -} - -static void psb_fbdev_fini (struct drm_device *dev) -{ -struct drm_psb_private *dev_priv =to_drm_psb_private (dev); - -if (!dev_priv->fb_helper) -return ; - -psb_fbdev_destroy (dev, dev_priv->fb_helper); -drm_fb_helper_unprepare (dev_priv->fb_helper); -kfree (dev_priv->fb_helper); - dev_priv->fb_helper =NULL ; -} -static const struct drm_mode_config_funcs psb_mode_funcs = { .fb_create = psb_user_framebuffer_create, .output_poll_changed = drm_fb_helper_output_poll_changed,drivers/gpu/drm/gma500/psb_drv.h +0
-0
drivers/gpu/drm/gma500/psb_drv.h extern void psb_lid_timer_takedown(struct drm_psb_private *dev_priv); · line 617
Quoted 8 lines
drivers/gpu/drm/gma500/psb_drv.h +5
-0@@ -610,7 +610,24 @@ extern void psb_lid_timer_takedown(struct drm_psb_private *dev_priv);/* modesetting */ extern void psb_modeset_init (struct drm_device *dev);extern void psb_modeset_cleanup (struct drm_device *dev); + +/* framebuffer */ +extern struct drm_framebuffer *psb_framebuffer_create (struct drm_device *dev, +const struct drm_mode_fb_cmd2 *mode_cmd, +struct drm_gem_object *obj);
Is extern needed here?
Quoted 19 lines
drivers/gpu/drm/gma500/psb_drv.h +12
-1+ +/* fbdev */ +#if defined(CONFIG_DRM_FBDEV_EMULATION )extern int psb_fbdev_init (struct drm_device *dev); +extern void psb_fbdev_fini (struct drm_device *dev); +#else +int psb_fbdev_init (struct drm_device *dev) +{ +return 0 ; +} +void psb_fbdev_fini (struct drm_device *dev) +{ } +#endif /* backlight.c */ int gma_backlight_init (struct drm_device *dev); --2.39.2
Thomas Zimmermann
maintainerPATCH 3/7 drm/gma500: Remove fbdev vma open and close callbacks
In reply to Thomas ZimmermannRemove fbdev emulations' open and close implementaitons for the VM. The functions are empty. Also update the naming of the VMA code.
--- drivers/gpu/drm/gma500/fbdev.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)
drivers/gpu/drm/gma500/fbdev.c +4 -12
@@ -18,7 +18,7 @@* VM area struct */ -static vm_fault_t psbfb_vm_fault (struct vm_fault *vmf) +static vm_fault_t psb_fbdev_vm_fault (struct vm_fault *vmf) {struct vm_area_struct *vma = vmf->vma;struct drm_framebuffer *fb = vma->vm_private_data;
@@ -49,16 +49,8 @@ static vm_fault_t psbfb_vm_fault(struct vm_fault *vmf)return ret; } -static void psbfb_vm_open (struct vm_area_struct *vma) -{ } - -static void psbfb_vm_close (struct vm_area_struct *vma) -{ } - -static const struct vm_operations_struct psbfb_vm_ops = { - .fault = psbfb_vm_fault, - .open = psbfb_vm_open, - .close = psbfb_vm_close +static const struct vm_operations_struct psb_fbdev_vm_ops = { + .fault = psb_fbdev_vm_fault, };/*
@@ -122,7 +114,7 @@ static int psbfb_mmap(struct fb_info *info, struct vm_area_struct *vma)* kernel remapping of the object. FIXME: Review if this is * suitable for our mmap work */ - vma->vm_ops = &psbfb_vm_ops; + vma->vm_ops = &psb_fbdev_vm_ops; vma->vm_private_data = (void *)fb; vma->vm_flags |=VM_IO |VM_MIXEDMAP |VM_DONTEXPAND |VM_DONTDUMP ;
Signature · 1 line
2.39.2
Thomas Zimmermann
maintainerPATCH 4/7 drm/gma500: Fix naming in fb_ops.
In reply to Thomas ZimmermannFix some names around struct fb_ops to better fit the overall naming conventions. No functional changes.
--- drivers/gpu/drm/gma500/fbdev.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/gpu/drm/gma500/fbdev.c +9 -9
@@ -59,10 +59,10 @@ static const struct vm_operations_struct psb_fbdev_vm_ops = {#define CMAP_TOHW (_val, _width) ((((_val) << (_width)) + 0x7FFF - (_val)) >> 16) -static int psbfb_setcolreg (unsigned int regno, -unsigned int red,unsigned int green, -unsigned int blue,unsigned int transp, -struct fb_info *info) +static int psb_fbdev_fb_setcolreg (unsigned int regno, +unsigned int red,unsigned int green, +unsigned int blue,unsigned int transp, +struct fb_info *info) {struct drm_fb_helper *fb_helper = info->par;struct drm_framebuffer *fb = fb_helper->fb;
@@ -99,7 +99,7 @@ static int psbfb_setcolreg(unsigned int regno,return 0 ; } -static int psbfb_mmap (struct fb_info *info,struct vm_area_struct *vma) +static int psb_fbdev_fb_mmap (struct fb_info *info,struct vm_area_struct *vma) {struct drm_fb_helper *fb_helper = info->par;struct drm_framebuffer *fb = fb_helper->fb;
@@ -121,16 +121,16 @@ static int psbfb_mmap(struct fb_info *info, struct vm_area_struct *vma)return 0 ; } -static const struct fb_ops psbfb_unaccel_ops = { +static const struct fb_ops psb_fbdev_ops = { .owner =THIS_MODULE ,DRM_FB_HELPER_DEFAULT_OPS , - .fb_setcolreg = psbfb_setcolreg, + .fb_setcolreg = psb_fbdev_fb_setcolreg, .fb_read = drm_fb_helper_cfb_read, .fb_write = drm_fb_helper_cfb_write, .fb_fillrect = drm_fb_helper_cfb_fillrect, .fb_copyarea = drm_fb_helper_cfb_copyarea, .fb_imageblit = drm_fb_helper_cfb_imageblit, - .fb_mmap = psbfb_mmap, + .fb_mmap = psb_fbdev_fb_mmap, };/*
@@ -190,7 +190,7 @@ static int psbfb_create(struct drm_fb_helper *fb_helper, fb_helper->fb = fb; - info->fbops = &psbfb_unaccel_ops; + info->fbops = &psb_fbdev_ops; info->fix.smem_start = dev_priv->fb_base; info->fix.smem_len = size;
Signature · 1 line
2.39.2
Thomas Zimmermann
maintainerPATCH 5/7 drm/gma500: Inline psbfb_create() into psbfb_probe()
In reply to Thomas ZimmermannInline psbfb_create() into its only caller psbfb_probe(). Streamline the color-depth selection.
--- drivers/gpu/drm/gma500/fbdev.c | 65 ++++++++++++++-------------------- 1 file changed, 26 insertions(+), 39 deletions(-)
drivers/gpu/drm/gma500/fbdev.c +26 -39
@@ -137,31 +137,49 @@ static const struct fb_ops psb_fbdev_ops = {* struct drm_fb_helper_funcs */ -static int psbfb_create (struct drm_fb_helper *fb_helper, -struct drm_fb_helper_surface_size *sizes) +static int psbfb_probe (struct drm_fb_helper *fb_helper, +struct drm_fb_helper_surface_size *sizes) {struct drm_device *dev = fb_helper->dev;struct drm_psb_private *dev_priv =to_drm_psb_private (dev);struct pci_dev *pdev =to_pci_dev (dev->dev);struct fb_info *info;struct drm_framebuffer *fb; -struct drm_mode_fb_cmd2 mode_cmd; +struct drm_mode_fb_cmd2 mode_cmd = { };int size;int ret;struct psb_gem_object *backing;struct drm_gem_object *obj;u32 bpp, depth; - mode_cmd.width = sizes->surface_width; - mode_cmd.height = sizes->surface_height; +/* No 24-bit packed mode */ +if (sizes->surface_bpp ==24 ) { + sizes->surface_bpp =32 ; + sizes->surface_depth =24 ; + } bpp = sizes->surface_bpp; depth = sizes->surface_depth; -/* No 24bit packed */ -if (bpp ==24 ) - bpp =32 ; +/* +* If the mode does not fit in 32 bit then switch to 16 bit to get +* a console on full resolution. The X mode setting server will +* allocate its own 32-bit GEM framebuffer. +*/ + size =ALIGN (sizes->surface_width *DIV_ROUND_UP (bpp,8 ),64 ) * + sizes->surface_height; + size =ALIGN (size,PAGE_SIZE ); + +if (size > dev_priv->vram_stolen_size) { + sizes->surface_bpp =16 ; + sizes->surface_depth =16 ; + } + bpp = sizes->surface_bpp; + depth = sizes->surface_depth; + mode_cmd.width = sizes->surface_width; + mode_cmd.height = sizes->surface_height; mode_cmd.pitches[0 ] =ALIGN (mode_cmd.width *DIV_ROUND_UP (bpp,8 ),64 ); + mode_cmd.pixel_format =drm_mode_legacy_fb_format (bpp, depth); size = mode_cmd.pitches[0 ] * mode_cmd.height; size =ALIGN (size,PAGE_SIZE );
@@ -180,8 +198,6 @@ static int psbfb_create(struct drm_fb_helper *fb_helper, goto err_drm_gem_object_put; } - mode_cmd.pixel_format =drm_mode_legacy_fb_format (bpp, depth); - fb =psb_framebuffer_create (dev, &mode_cmd, obj);if (IS_ERR (fb)) { ret =PTR_ERR (fb);
@@ -217,35 +233,6 @@ static int psbfb_create(struct drm_fb_helper *fb_helper,return ret; } -static int psbfb_probe (struct drm_fb_helper *fb_helper, -struct drm_fb_helper_surface_size *sizes) -{ -struct drm_device *dev = fb_helper->dev; -struct drm_psb_private *dev_priv =to_drm_psb_private (dev); -unsigned int fb_size; -int bytespp; - - bytespp = sizes->surface_bpp /8 ; -if (bytespp ==3 )/* no 24bit packed */ - bytespp =4 ; - -/* -* If the mode will not fit in 32bit then switch to 16bit to get -* a console on full resolution. The X mode setting server will -* allocate its own 32bit GEM framebuffer -*/ - fb_size =ALIGN (sizes->surface_width * bytespp,64 ) * - sizes->surface_height; - fb_size =ALIGN (fb_size,PAGE_SIZE ); - -if (fb_size > dev_priv->vram_stolen_size) { - sizes->surface_bpp =16 ; - sizes->surface_depth =16 ; - } - -return psbfb_create (fb_helper, sizes); -} -static const struct drm_fb_helper_funcs psb_fb_helper_funcs = { .fb_probe = psbfb_probe, };
Signature · 1 line
2.39.2
Patrik Jakobsson
maintainerRe: [PATCH 5/7] drm/gma500: Inline psbfb_create() into psbfb_probe()
Quoted 14 lines · Thomas Zimmermann
Inline
psbfb_create()into its only callerpsbfb_probe(). Streamline the color-depth selection.Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/gma500/fbdev.c | 65 ++++++++++++++-------------------- 1 file changed, 26 insertions(+), 39 deletions(-)drivers/gpu/drm/gma500/fbdev.c +0
-0
drivers/gpu/drm/gma500/fbdev.c static const struct fb_ops psb_fbdev_ops = { · line 140
Quoted 6 lines
drivers/gpu/drm/gma500/fbdev.c +1
-2@@ -137,31 +137,49 @@ static const struct fb_ops psb_fbdev_ops = {* struct drm_fb_helper_funcs */ -static int psbfb_create (struct drm_fb_helper *fb_helper, -struct drm_fb_helper_surface_size *sizes) +static int psbfb_probe(struct drm_fb_helper *fb_helper,
Should this now be psb_fbdev_probe() ?
Quoted 99 lines
drivers/gpu/drm/gma500/fbdev.c +25
-38+ struct drm_fb_helper_surface_size *sizes) {struct drm_device *dev = fb_helper->dev;struct drm_psb_private *dev_priv =to_drm_psb_private (dev);struct pci_dev *pdev =to_pci_dev (dev->dev);struct fb_info *info;struct drm_framebuffer *fb; -struct drm_mode_fb_cmd2 mode_cmd; +struct drm_mode_fb_cmd2 mode_cmd = { };int size;int ret;struct psb_gem_object *backing;struct drm_gem_object *obj;u32 bpp, depth; - mode_cmd.width = sizes->surface_width; - mode_cmd.height = sizes->surface_height; +/* No 24-bit packed mode */ +if (sizes->surface_bpp ==24 ) { + sizes->surface_bpp =32 ; + sizes->surface_depth =24 ; + } bpp = sizes->surface_bpp; depth = sizes->surface_depth; -/* No 24bit packed */ -if (bpp ==24 ) - bpp =32 ; +/* +* If the mode does not fit in 32 bit then switch to 16 bit to get +* a console on full resolution. The X mode setting server will +* allocate its own 32-bit GEM framebuffer. +*/ + size =ALIGN (sizes->surface_width *DIV_ROUND_UP (bpp,8 ),64 ) * + sizes->surface_height; + size =ALIGN (size,PAGE_SIZE ); + +if (size > dev_priv->vram_stolen_size) { + sizes->surface_bpp =16 ; + sizes->surface_depth =16 ; + } + bpp = sizes->surface_bpp; + depth = sizes->surface_depth; + mode_cmd.width = sizes->surface_width; + mode_cmd.height = sizes->surface_height; mode_cmd.pitches[0 ] =ALIGN (mode_cmd.width *DIV_ROUND_UP (bpp,8 ),64 ); + mode_cmd.pixel_format =drm_mode_legacy_fb_format (bpp, depth); size = mode_cmd.pitches[0 ] * mode_cmd.height; size =ALIGN (size,PAGE_SIZE );@@ -180,8 +198,6 @@ static int psbfb_create(struct drm_fb_helper *fb_helper, goto err_drm_gem_object_put; } - mode_cmd.pixel_format =drm_mode_legacy_fb_format (bpp, depth); - fb =psb_framebuffer_create (dev, &mode_cmd, obj);if (IS_ERR (fb)) { ret =PTR_ERR (fb);@@ -217,35 +233,6 @@ static int psbfb_create(struct drm_fb_helper *fb_helper,return ret; } -static int psbfb_probe (struct drm_fb_helper *fb_helper, -struct drm_fb_helper_surface_size *sizes) -{ -struct drm_device *dev = fb_helper->dev; -struct drm_psb_private *dev_priv =to_drm_psb_private (dev); -unsigned int fb_size; -int bytespp; - - bytespp = sizes->surface_bpp /8 ; -if (bytespp ==3 )/* no 24bit packed */ - bytespp =4 ; - -/* -* If the mode will not fit in 32bit then switch to 16bit to get -* a console on full resolution. The X mode setting server will -* allocate its own 32bit GEM framebuffer -*/ - fb_size =ALIGN (sizes->surface_width * bytespp,64 ) * - sizes->surface_height; - fb_size =ALIGN (fb_size,PAGE_SIZE ); - -if (fb_size > dev_priv->vram_stolen_size) { - sizes->surface_bpp =16 ; - sizes->surface_depth =16 ; - } - -return psbfb_create (fb_helper, sizes); -} -static const struct drm_fb_helper_funcs psb_fb_helper_funcs = { .fb_probe = psbfb_probe, }; --2.39.2
Thomas Zimmermann
maintainerPATCH 6/7 drm/gma500: Implement client-based fbdev emulation
In reply to Thomas ZimmermannImplement fbdevemulation on top of struct drm_client and its helpers. This ad-hoc interfaces for restoring and closing fbdev emulation with per-client callback for hotplugging, restoring and unregistering.
A single function, psb_fbdev_setup(), starts fbdev emulation after the DRM device has been registered. Hence, fbdev acts like a regular DRM client.
The setup call only prepares the fbdev emulation. It then implements connector hotplugging. The first successful hotplug event initializes fbdev emulation.
Unregistering depends on the hotplugging. Fully initialized emulation is cleaned up through drm_fb_helper_unregister_info() and fb_destroy. For prepared-only setups, unregistering unprepares the emulation and releases all resources. In both cases, fbdev emulation will be cleaned up.
--- drivers/gpu/drm/gma500/fbdev.c | 155 ++++++++++++++++++--------- drivers/gpu/drm/gma500/framebuffer.c | 3 - drivers/gpu/drm/gma500/psb_drv.c | 5 +- drivers/gpu/drm/gma500/psb_drv.h | 12 +-- 4 files changed, 107 insertions(+), 68 deletions(-)
drivers/gpu/drm/gma500/fbdev.c +103 -52
@@ -8,6 +8,7 @@#include <linux/pfn_t.h> #include <drm/drm_crtc_helper.h> +#include <drm/drm_drv.h> #include <drm/drm_fb_helper.h> #include <drm/drm_framebuffer.h>
@@ -121,7 +122,28 @@ static int psb_fbdev_fb_mmap(struct fb_info *info, struct vm_area_struct *vma)return 0 ; } -static const struct fb_ops psb_fbdev_ops = { +static void psb_fbdev_fb_destroy (struct fb_info *info) +{ +struct drm_fb_helper *fb_helper = info->par; +struct drm_framebuffer *fb = fb_helper->fb; +struct drm_gem_object *obj = fb->obj[0 ]; + +drm_fb_helper_fini (fb_helper); + +drm_framebuffer_unregister_private (fb); + fb->obj[0 ] =NULL ; +drm_framebuffer_cleanup (fb); +kfree (fb); + +drm_gem_object_put (obj); + +drm_client_release (&fb_helper->client); + +drm_fb_helper_unprepare (fb_helper); +kfree (fb_helper); +} + +static const struct fb_ops psb_fbdev_fb_ops = { .owner =THIS_MODULE ,DRM_FB_HELPER_DEFAULT_OPS , .fb_setcolreg = psb_fbdev_fb_setcolreg,
@@ -131,6 +153,7 @@ static const struct fb_ops psb_fbdev_ops = { .fb_copyarea = drm_fb_helper_cfb_copyarea, .fb_imageblit = drm_fb_helper_cfb_imageblit, .fb_mmap = psb_fbdev_fb_mmap, + .fb_destroy = psb_fbdev_fb_destroy, };/*
@@ -190,14 +213,6 @@ static int psbfb_probe(struct drm_fb_helper *fb_helper,return PTR_ERR (backing); obj = &backing->base; -memset (dev_priv->vram_addr + backing->offset,0 , size); - - info =drm_fb_helper_alloc_info (fb_helper); -if (IS_ERR (info)) { - ret =PTR_ERR (info); - goto err_drm_gem_object_put; - } - fb =psb_framebuffer_create (dev, &mode_cmd, obj);if (IS_ERR (fb)) { ret =PTR_ERR (fb);
@@ -206,28 +221,40 @@ static int psbfb_probe(struct drm_fb_helper *fb_helper, fb_helper->fb = fb; - info->fbops = &psb_fbdev_ops; - - info->fix.smem_start = dev_priv->fb_base; - info->fix.smem_len = size; - info->fix.ywrapstep =0 ; - info->fix.ypanstep =0 ; + info =drm_fb_helper_alloc_info (fb_helper); +if (IS_ERR (info)) { + ret =PTR_ERR (info); + goto err_drm_framebuffer_unregister_private; + } + info->fbops = &psb_fbdev_fb_ops; + info->flags =FBINFO_DEFAULT ;/* Accessed stolen memory directly */ info->screen_base = dev_priv->vram_addr + backing->offset; info->screen_size = size;drm_fb_helper_fill_info (info, fb_helper, sizes); + info->fix.smem_start = dev_priv->fb_base; + info->fix.smem_len = size; + info->fix.ywrapstep =0 ; + info->fix.ypanstep =0 ; info->fix.mmio_start =pci_resource_start (pdev,0 ); info->fix.mmio_len =pci_resource_len (pdev,0 ); +memset (info->screen_base,0 , info->screen_size); +/* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */ dev_dbg (dev->dev,"allocated %dx%d fb\n" , fb->width, fb->height);return 0 ; +err_drm_framebuffer_unregister_private: +drm_framebuffer_unregister_private (fb); + fb->obj[0 ] =NULL ; +drm_framebuffer_cleanup (fb); +kfree (fb); err_drm_gem_object_put:drm_gem_object_put (obj);return ret;
@@ -237,68 +264,92 @@ static const struct drm_fb_helper_funcs psb_fb_helper_funcs = { .fb_probe = psbfb_probe, }; -static int psb_fbdev_destroy (struct drm_device *dev, -struct drm_fb_helper *fb_helper) -{ -struct drm_framebuffer *fb = fb_helper->fb; - -drm_fb_helper_unregister_info (fb_helper); +/* +* struct drm_client_funcs and setup code +*/ -drm_fb_helper_fini (fb_helper); -drm_framebuffer_unregister_private (fb); -drm_framebuffer_cleanup (fb); +static void psb_fbdev_client_unregister (struct drm_client_dev *client) +{ +struct drm_fb_helper *fb_helper =drm_fb_helper_from_client (client); + +if (fb_helper->info) { +drm_fb_helper_unregister_info (fb_helper); + }else { +drm_fb_helper_unprepare (fb_helper); +drm_client_release (&fb_helper->client); +kfree (fb_helper); + } +} -if (fb->obj[0 ]) -drm_gem_object_put (fb->obj[0 ]); -kfree (fb); +static int psb_fbdev_client_restore (struct drm_client_dev *client) +{ +drm_fb_helper_lastclose (client->dev);return 0 ; } -int psb_fbdev_init (struct drm_device *dev) +static int psb_fbdev_client_hotplug (struct drm_client_dev *client) { -struct drm_fb_helper *fb_helper; -struct drm_psb_private *dev_priv =to_drm_psb_private (dev); +struct drm_fb_helper *fb_helper =drm_fb_helper_from_client (client); +struct drm_device *dev = client->dev;int ret; - fb_helper =kzalloc (sizeof (*fb_helper),GFP_KERNEL ); -if (!fb_helper) -return -ENOMEM ; - - dev_priv->fb_helper = fb_helper; - -drm_fb_helper_prepare (dev, fb_helper,32 , &psb_fb_helper_funcs); +if (dev->fb_helper) +return drm_fb_helper_hotplug_event (dev->fb_helper); ret =drm_fb_helper_init (dev, fb_helper);if (ret) - goto free; + goto err_drm_err; -/* disable all the possible outputs/crtcs before entering KMS mode */ -drm_helper_disable_unused_functions (dev); +if (!drm_drv_uses_atomic_modeset (dev)) +drm_helper_disable_unused_functions (dev); ret =drm_fb_helper_initial_config (fb_helper);if (ret) - goto fini; + goto err_drm_fb_helper_fini;return 0 ; -fini: +err_drm_fb_helper_fini:drm_fb_helper_fini (fb_helper); -free: -drm_fb_helper_unprepare (fb_helper); -kfree (fb_helper); +err_drm_err: +drm_err (dev,"Failed to setup gma500 fbdev emulation (ret=%d)\n" , ret);return ret; } -void psb_fbdev_fini (struct drm_device *dev) +static const struct drm_client_funcs psb_fbdev_client_funcs = { + .owner =THIS_MODULE , + .unregister = psb_fbdev_client_unregister, + .restore = psb_fbdev_client_restore, + .hotplug = psb_fbdev_client_hotplug, +}; + +void psb_fbdev_setup (struct drm_psb_private *dev_priv) { -struct drm_psb_private *dev_priv =to_drm_psb_private (dev); +struct drm_device *dev = &dev_priv->dev; +struct drm_fb_helper *fb_helper; +int ret; -if (!dev_priv->fb_helper) + fb_helper =kzalloc (sizeof (*fb_helper),GFP_KERNEL ); +if (!fb_helper)return ; +drm_fb_helper_prepare (dev, fb_helper,32 , &psb_fb_helper_funcs); + + ret =drm_client_init (dev, &fb_helper->client,"fbdev-gma500" , &psb_fbdev_client_funcs); +if (ret) { +drm_err (dev,"Failed to register client: %d\n" , ret); + goto err_drm_fb_helper_unprepare; + } + + ret =psb_fbdev_client_hotplug (&fb_helper->client); +if (ret) +drm_dbg_kms (dev,"client hotplug ret=%d\n" , ret); + +drm_client_register (&fb_helper->client); + +return ; -psb_fbdev_destroy (dev, dev_priv->fb_helper); -drm_fb_helper_unprepare (dev_priv->fb_helper); -kfree (dev_priv->fb_helper); - dev_priv->fb_helper =NULL ; +err_drm_fb_helper_unprepare: +drm_fb_helper_unprepare (fb_helper); +kfree (fb_helper); }
drivers/gpu/drm/gma500/framebuffer.c +0 -3
@@ -5,7 +5,6 @@* **************************************************************************/ -#include <drm/drm_fb_helper.h> #include <drm/drm_framebuffer.h> #include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_modeset_helper.h>
@@ -120,7 +119,6 @@ static struct drm_framebuffer *psb_user_framebuffer_createstatic const struct drm_mode_config_funcs psb_mode_funcs = { .fb_create = psb_user_framebuffer_create, - .output_poll_changed = drm_fb_helper_output_poll_changed, };static void psb_setup_outputs (struct drm_device *dev)
@@ -223,6 +221,5 @@ void psb_modeset_cleanup(struct drm_device *dev)struct drm_psb_private *dev_priv =to_drm_psb_private (dev);if (dev_priv->modeset) {drm_kms_helper_poll_fini (dev); -psb_fbdev_fini (dev); } }
drivers/gpu/drm/gma500/psb_drv.c +2 -3
@@ -21,7 +21,6 @@#include <drm/drm.h> #include <drm/drm_aperture.h> #include <drm/drm_drv.h> -#include <drm/drm_fb_helper.h> #include <drm/drm_file.h> #include <drm/drm_ioctl.h> #include <drm/drm_pciids.h>
@@ -387,7 +386,6 @@ static int psb_driver_load(struct drm_device *dev, unsigned long flags) dev->max_vblank_count =0xffffff ;/* only 24 bits of frame count */ psb_modeset_init (dev); -psb_fbdev_init (dev);drm_kms_helper_poll_init (dev);/* Only add backlight support if we have LVDS or MIPI output */
@@ -452,6 +450,8 @@ static int psb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)if (ret)return ret; +psb_fbdev_setup (dev_priv); +return 0 ; }
@@ -477,7 +477,6 @@ static const struct file_operations psb_gem_fops = {static const struct drm_driver driver = { .driver_features =DRIVER_MODESET |DRIVER_GEM , - .lastclose = drm_fb_helper_lastclose, .num_ioctls =ARRAY_SIZE (psb_ioctls),
drivers/gpu/drm/gma500/psb_drv.h +2 -10
@@ -193,8 +193,6 @@#define KSEL_BYPASS_25 6#define KSEL_BYPASS_83_100 7 -struct drm_fb_helper ; -struct opregion_header ;struct opregion_acpi ;struct opregion_swsci ;
@@ -522,7 +520,6 @@ struct drm_psb_private {uint32_t blc_adj1;uint32_t blc_adj2; -struct drm_fb_helper *fb_helper;resource_size_t fb_base;bool dsr_enable;
@@ -618,14 +615,9 @@ extern struct drm_framebuffer *psb_framebuffer_create(struct drm_device *dev,/* fbdev */ #if defined(CONFIG_DRM_FBDEV_EMULATION ) -extern int psb_fbdev_init (struct drm_device *dev); -extern void psb_fbdev_fini (struct drm_device *dev); +void psb_fbdev_setup (struct drm_psb_private *dev_priv);#else -int psb_fbdev_init (struct drm_device *dev) -{ -return 0 ; -} -void psb_fbdev_fini (struct drm_device *dev) +void psb_fbdev_setup (struct drm_psb_private *dev_priv) { }#endif
Signature · 1 line
2.39.2
kernel test robot
build botRe: [PATCH 6/7] drm/gma500: Implement client-based fbdev emulation
I love your patch! Perhaps something to improve:
Hi Thomas,
I love your patch! Perhaps something to improve:
[auto build test WARNING on linus/master]
[cannot apply to drm-misc/drm-misc-next v6.2 v6.2-rc8 v6.2-rc7 next-20230223 v6.2 next-20230223] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Thomas-Zimmermann/drm-gma500-Remove-unnecessary-include-statements/20230223-202205 patch link: https://lore.kernel.org/r/20230223121733.12549-7-tzimmermann%40suse.de patch subject: [PATCH 6/7] drm/gma500: Implement client-based fbdev emulation config: i386-randconfig-a004 (https://download.01.org/0day-ci/archive/20230224/[email protected]/config) compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/d1c984af29e0c5219d353a4772527d233d1c1bcc
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Thomas-Zimmermann/drm-gma500-Remove-unnecessary-include-statements/20230223-202205 git checkout d1c984af29e0c5219d353a4772527d233d1c1bcc
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/gpu/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
In file included from drivers/gpu/drm/gma500/backlight.c:14:
>> drivers/gpu/drm/gma500/psb_drv.h:620:6: warning: no previous prototype for function 'psb_fbdev_setup' [-Wmissing-prototypes]
void psb_fbdev_setup(struct drm_psb_private *dev_priv)
^ drivers/gpu/drm/gma500/psb_drv.h:620:1: note: declare 'static' if the function is not intended to be used outside of this translation unit void psb_fbdev_setup(struct drm_psb_private *dev_priv)
^
static
1 warning generated.
--
In file included from drivers/gpu/drm/gma500/psb_irq.c:15:
>> drivers/gpu/drm/gma500/psb_drv.h:620:6: warning: no previous prototype for function 'psb_fbdev_setup' [-Wmissing-prototypes]
void psb_fbdev_setup(struct drm_psb_private *dev_priv)
^
drivers/gpu/drm/gma500/psb_drv.h:620:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
void psb_fbdev_setup(struct drm_psb_private *dev_priv)
^
static
drivers/gpu/drm/gma500/psb_irq.c:35:19: warning: unused function 'gma_pipe_event' [-Wunused-function]
static inline u32 gma_pipe_event(int pipe)
^2 warnings generated.
vim +/psb_fbdev_setup +620 drivers/gpu/drm/gma500/psb_drv.h
610
611 /* framebuffer */
612 extern struct drm_framebuffer *psb_framebuffer_create(struct drm_device *dev,
613 const struct drm_mode_fb_cmd2 *mode_cmd,
614 struct drm_gem_object *obj);
615
616 /* fbdev */
617 #if defined(CONFIG_DRM_FBDEV_EMULATION)
618 void psb_fbdev_setup(struct drm_psb_private *dev_priv);
619 #else
> 620 void psb_fbdev_setup(struct drm_psb_private *dev_priv)
621 { }
622 #endif
623
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
Thomas Zimmermann
maintainerRe: [PATCH 6/7] drm/gma500: Implement client-based fbdev emulation
Missing 'static inline'. Will be fixed in next rev.
Am 23.02.23 um 20:01 schrieb kernel test robot:
Quoted 74 lines
Hi Thomas,
I love your patch! Perhaps something to improve:
[auto build test WARNING on linus/master]
[cannot apply to drm-misc/drm-misc-next v6.2 v6.2-rc8 v6.2-rc7 next-20230223 v6.2 next-20230223] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]url: https://github.com/intel-lab-lkp/linux/commits/Thomas-Zimmermann/drm-gma500-Remove-unnecessary-include-statements/20230223-202205 patch link: https://lore.kernel.org/r/20230223121733.12549-7-tzimmermann%40suse.de patch subject: [PATCH 6/7] drm/gma500: Implement client-based fbdev emulation config: i386-randconfig-a004 (https://download.01.org/0day-ci/archive/20230224/[email protected]/config) compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/d1c984af29e0c5219d353a4772527d233d1c1bcc
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Thomas-Zimmermann/drm-gma500-Remove-unnecessary-include-statements/20230223-202205 git checkoutd1c984af29e0c5219d353a4772527d233d1c1bcc
# save the config file
mkdirbuild_dir&& cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bashdrivers/gpu/If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/All warnings (new ones prefixed by >>):
In file included from
drivers/gpu/drm/gma500/backlight.c:14:Quoted 1 line
Quoted 1 line
drivers/gpu/drm/gma500/psb_drv.h:620:6: warning: no previous prototype for function 'psb_fbdev_setup' [-Wmissing-prototypes]void
psb_fbdev_setup(struct drm_psb_private *dev_priv)
^
drivers/gpu/drm/gma500/psb_drv.h:620:1: note: declare 'static' if the function is not intended to be used outside of this translation unit voidpsb_fbdev_setup(struct drm_psb_private *dev_priv)
^
static
1 warning generated.
--
In file included fromdrivers/gpu/drm/gma500/psb_irq.c:15:Quoted 1 line
Quoted 1 line
drivers/gpu/drm/gma500/psb_drv.h:620:6: warning: no previous prototype for function 'psb_fbdev_setup' [-Wmissing-prototypes]void
psb_fbdev_setup(struct drm_psb_private *dev_priv)
^
drivers/gpu/drm/gma500/psb_drv.h:620:1: note: declare 'static' if the function is not intended to be used outside of this translation unit voidpsb_fbdev_setup(struct drm_psb_private *dev_priv)
^
static
drivers/gpu/drm/gma500/psb_irq.c:35:19: warning: unused function 'gma_pipe_event' [-Wunused-function]
static inline u32gma_pipe_event(int pipe)
^
2 warnings generated.vim +/psb_fbdev_setup +620
drivers/gpu/drm/gma500/psb_drv.h610 611 /* framebuffer */ 612 extern struct drm_framebuffer *psb_framebuffer_create(struct drm_device *dev, 613 const struct drm_mode_fb_cmd2 *mode_cmd, 614 struct drm_gem_object *obj); 615 616 /* fbdev */ 617 #if defined(CONFIG_DRM_FBDEV_EMULATION) 618 void psb_fbdev_setup(struct drm_psb_private *dev_priv); 619 #elseQuoted 1 line
620 void
psb_fbdev_setup(struct drm_psb_private *dev_priv)621 { } 622 #endif 623
Signature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Ivo Totev
kernel test robot
build botRe: [PATCH 6/7] drm/gma500: Implement client-based fbdev emulation
In reply to Thomas ZimmermannI love your patch! Yet something to improve:
Hi Thomas,
I love your patch! Yet something to improve:
[auto build test ERROR on linus/master]
[cannot apply to drm-misc/drm-misc-next v6.2 v6.2-rc8 v6.2-rc7 next-20230223 v6.2 next-20230223] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Thomas-Zimmermann/drm-gma500-Remove-unnecessary-include-statements/20230223-202205 patch link: https://lore.kernel.org/r/20230223121733.12549-7-tzimmermann%40suse.de patch subject: [PATCH 6/7] drm/gma500: Implement client-based fbdev emulation config: x86_64-randconfig-a004 (https://download.01.org/0day-ci/archive/20230224/[email protected]/config) compiler: gcc-11 (Debian 11.3.0-8) 11.3.0 reproduce (this is a W=1 build): # https://github.com/intel-lab-lkp/linux/commit/d1c984af29e0c5219d353a4772527d233d1c1bcc git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Thomas-Zimmermann/drm-gma500-Remove-unnecessary-include-statements/20230223-202205 git checkout d1c984af29e0c5219d353a4772527d233d1c1bcc # save the config file mkdir build_dir && cp config build_dir/.config make W=1 O=build_dir ARCH=x86_64 olddefconfig make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All error/warnings (new ones prefixed by >>):
ld: drivers/gpu/drm/gma500/cdv_device.o: in function `psb_fbdev_setup':
>> drivers/gpu/drm/gma500/psb_drv.h:621: multiple definition of `psb_fbdev_setup'; drivers/gpu/drm/gma500/backlight.o:drivers/gpu/drm/gma500/psb_drv.h:621: first defined here ld: drivers/gpu/drm/gma500/cdv_intel_crt.o: in function `psb_fbdev_setup': >> drivers/gpu/drm/gma500/psb_drv.h:621: multiple definition of `psb_fbdev_setup'; drivers/gpu/drm/gma500/backlight.o:drivers/gpu/drm/gma500/psb_drv.h:621: first defined here ld: drivers/gpu/drm/gma500/cdv_intel_display.o: in function `psb_fbdev_setup': >> drivers/gpu/drm/gma500/psb_drv.h:621: multiple definition of `psb_fbdev_setup'; drivers/gpu/drm/gma500/backlight.o:drivers/gpu/drm/gma500/psb_drv.h:621: first defined here ld: drivers/gpu/drm/gma500/cdv_intel_dp.o: in function `psb_fbdev_setup': >> drivers/gpu/drm/gma500/psb_drv.h:621: multiple definition of `psb_fbdev_setup'; drivers/gpu/drm/gma500/backlight.o:drivers/gpu/drm/gma500/psb_drv.h:621: first defined here ld: drivers/gpu/drm/gma500/cdv_intel_hdmi.o: in function `psb_fbdev_setup': >> drivers/gpu/drm/gma500/psb_drv.h:621: multiple definition of `psb_fbdev_setup'; drivers/gpu/drm/gma500/backlight.o:drivers/gpu/drm/gma500/psb_drv.h:621: first defined here ld: drivers/gpu/drm/gma500/cdv_intel_lvds.o: in function `psb_fbdev_setup': >> drivers/gpu/drm/gma500/psb_drv.h:621: multiple definition of `psb_fbdev_setup'; drivers/gpu/drm/gma500/backlight.o:drivers/gpu/drm/gma500/psb_drv.h:621: first defined here ld: drivers/gpu/drm/gma500/framebuffer.o: in function `psb_fbdev_setup': drivers/gpu/drm/gma500/framebuffer.c:621: multiple definition of `psb_fbdev_setup'; drivers/gpu/drm/gma500/backlight.o:drivers/gpu/drm/gma500/psb_drv.h:621: first defined here ld: drivers/gpu/drm/gma500/gem.o: in function `psb_fbdev_setup': >> drivers/gpu/drm/gma500/psb_drv.h:621: multiple definition of `psb_fbdev_setup'; drivers/gpu/drm/gma500/backlight.o:drivers/gpu/drm/gma500/psb_drv.h:621: first defined here ld: drivers/gpu/drm/gma500/gma_device.o: in function `psb_fbdev_setup': drivers/gpu/drm/gma500/gma_device.c:621: multiple definition of `psb_fbdev_setup'; drivers/gpu/drm/gma500/backlight.o:drivers/gpu/drm/gma500/psb_drv.h:621: first defined here ld: drivers/gpu/drm/gma500/gma_display.o: in function `psb_fbdev_setup': >> drivers/gpu/drm/gma500/psb_drv.h:621: multiple definition of `psb_fbdev_setup'; drivers/gpu/drm/gma500/backlight.o:drivers/gpu/drm/gma500/psb_drv.h:621: first defined here ld: drivers/gpu/drm/gma500/gtt.o: in function `psb_fbdev_setup': >> drivers/gpu/drm/gma500/psb_drv.h:621: multiple definition of `psb_fbdev_setup'; drivers/gpu/drm/gma500/backlight.o:drivers/gpu/drm/gma500/psb_drv.h:621: first defined here ld: drivers/gpu/drm/gma500/intel_bios.o: in function `psb_fbdev_setup': >> drivers/gpu/drm/gma500/psb_drv.h:621: multiple definition of `psb_fbdev_setup'; drivers/gpu/drm/gma500/backlight.o:drivers/gpu/drm/gma500/psb_drv.h:621: first defined here ld: drivers/gpu/drm/gma500/intel_gmbus.o: in function `psb_fbdev_setup': >> drivers/gpu/drm/gma500/psb_drv.h:621: multiple definition of `psb_fbdev_setup'; drivers/gpu/drm/gma500/backlight.o:drivers/gpu/drm/gma500/psb_drv.h:621: first defined here ld: drivers/gpu/drm/gma500/intel_i2c.o: in function `psb_fbdev_setup': >> drivers/gpu/drm/gma500/psb_drv.h:621: multiple definition of `psb_fbdev_setup'; drivers/gpu/drm/gma500/backlight.o:drivers/gpu/drm/gma500/psb_drv.h:621: first defined here ld: drivers/gpu/drm/gma500/mid_bios.o: in function `psb_fbdev_setup': >> drivers/gpu/drm/gma500/psb_drv.h:621: multiple definition of `psb_fbdev_setup'; drivers/gpu/drm/gma500/backlight.o:drivers/gpu/drm/gma500/psb_drv.h:621: first defined here ld: drivers/gpu/drm/gma500/mmu.o: in function `psb_fbdev_setup': >> drivers/gpu/drm/gma500/psb_drv.h:621: multiple definition of `psb_fbdev_setup'; drivers/gpu/drm/gma500/backlight.o:drivers/gpu/drm/gma500/psb_drv.h:621: first defined here ld: drivers/gpu/drm/gma500/oaktrail_device.o: in function `psb_fbdev_setup': >> drivers/gpu/drm/gma500/psb_drv.h:621: multiple definition of `psb_fbdev_setup'; drivers/gpu/drm/gma500/backlight.o:drivers/gpu/drm/gma500/psb_drv.h:621: first defined here ld: drivers/gpu/drm/gma500/oaktrail_crtc.o: in function `psb_fbdev_setup': >> drivers/gpu/drm/gma500/psb_drv.h:621: multiple definition of `psb_fbdev_setup'; drivers/gpu/drm/gma500/backlight.o:drivers/gpu/drm/gma500/psb_drv.h:621: first defined here ld: drivers/gpu/drm/gma500/oaktrail_hdmi.o: in function `psb_fbdev_setup': >> drivers/gpu/drm/gma500/psb_drv.h:621: multiple definition of `psb_fbdev_setup'; drivers/gpu/drm/gma500/backlight.o:drivers/gpu/drm/gma500/psb_drv.h:621: first defined here ld: drivers/gpu/drm/gma500/oaktrail_hdmi_i2c.o: in function `psb_fbdev_setup': >> drivers/gpu/drm/gma500/psb_drv.h:621: multiple definition of `psb_fbdev_setup'; drivers/gpu/drm/gma500/backlight.o:drivers/gpu/drm/gma500/psb_drv.h:621: first defined here ld: drivers/gpu/drm/gma500/oaktrail_lvds.o: in function `psb_fbdev_setup': >> drivers/gpu/drm/gma500/psb_drv.h:621: multiple definition of `psb_fbdev_setup'; drivers/gpu/drm/gma500/backlight.o:drivers/gpu/drm/gma500/psb_drv.h:621: first defined here ld: drivers/gpu/drm/gma500/oaktrail_lvds_i2c.o: in function `psb_fbdev_setup': >> drivers/gpu/drm/gma500/psb_drv.h:621: multiple definition of `psb_fbdev_setup'; drivers/gpu/drm/gma500/backlight.o:drivers/gpu/drm/gma500/psb_drv.h:621: first defined here
ld: drivers/gpu/drm/gma500/power.o: in function `psb_fbdev_setup':
power.c:(.text+0x40): multiple definition of `psb_fbdev_setup'; drivers/gpu/drm/gma500/backlight.o:drivers/gpu/drm/gma500/psb_drv.h:621: first defined here
ld: drivers/gpu/drm/gma500/psb_device.o: in function `psb_fbdev_setup':
drivers/gpu/drm/gma500/psb_drv.h:621: multiple definition of `psb_fbdev_setup'; drivers/gpu/drm/gma500/backlight.o:drivers/gpu/drm/gma500/psb_drv.h:621: first defined here
ld: drivers/gpu/drm/gma500/psb_drv.o: in function `psb_fbdev_setup':
drivers/gpu/drm/gma500/psb_drv.h:621: multiple definition of `psb_fbdev_setup'; drivers/gpu/drm/gma500/backlight.o:drivers/gpu/drm/gma500/psb_drv.h:621: first defined here
ld: drivers/gpu/drm/gma500/psb_intel_display.o: in function `psb_fbdev_setup':
drivers/gpu/drm/gma500/psb_drv.h:621: multiple definition of `psb_fbdev_setup'; drivers/gpu/drm/gma500/backlight.o:drivers/gpu/drm/gma500/psb_drv.h:621: first defined here
ld: drivers/gpu/drm/gma500/psb_intel_lvds.o: in function `psb_fbdev_setup':
drivers/gpu/drm/gma500/psb_drv.h:621: multiple definition of `psb_fbdev_setup'; drivers/gpu/drm/gma500/backlight.o:drivers/gpu/drm/gma500/psb_drv.h:621: first defined here
ld: drivers/gpu/drm/gma500/psb_intel_sdvo.o: in function `psb_fbdev_setup':
drivers/gpu/drm/gma500/psb_drv.h:621: multiple definition of `psb_fbdev_setup'; drivers/gpu/drm/gma500/backlight.o:drivers/gpu/drm/gma500/psb_drv.h:621: first defined here
ld: drivers/gpu/drm/gma500/psb_lid.o: in function `psb_fbdev_setup':
drivers/gpu/drm/gma500/psb_drv.h:621: multiple definition of `psb_fbdev_setup'; drivers/gpu/drm/gma500/backlight.o:drivers/gpu/drm/gma500/psb_drv.h:621: first defined here
ld: drivers/gpu/drm/gma500/psb_irq.o: in function `psb_fbdev_setup':
drivers/gpu/drm/gma500/psb_drv.h:621: multiple definition of `psb_fbdev_setup'; drivers/gpu/drm/gma500/backlight.o:drivers/gpu/drm/gma500/psb_drv.h:621: first defined here
ld: drivers/gpu/drm/gma500/opregion.o: in function `psb_fbdev_setup':
drivers/gpu/drm/gma500/psb_drv.h:621: multiple definition of `psb_fbdev_setup'; drivers/gpu/drm/gma500/backlight.o:drivers/gpu/drm/gma500/psb_drv.h:621: first defined here
--
In file included from drivers/gpu/drm/gma500/backlight.c:14:
>> drivers/gpu/drm/gma500/psb_drv.h:620:6: warning: no previous prototype for 'psb_fbdev_setup' [-Wmissing-prototypes]
620 | void psb_fbdev_setup(struct drm_psb_private *dev_priv)
| ^~~~~~~~~~~~~~~
vim +621 drivers/gpu/drm/gma500/psb_drv.h
b0f256f81e3ff9 Thomas Zimmermann 2023-02-23 610
b0f256f81e3ff9 Thomas Zimmermann 2023-02-23 611 /* framebuffer */
b0f256f81e3ff9 Thomas Zimmermann 2023-02-23 612 extern struct drm_framebuffer *psb_framebuffer_create(struct drm_device *dev,
b0f256f81e3ff9 Thomas Zimmermann 2023-02-23 613 const struct drm_mode_fb_cmd2 *mode_cmd,
b0f256f81e3ff9 Thomas Zimmermann 2023-02-23 614 struct drm_gem_object *obj);
b0f256f81e3ff9 Thomas Zimmermann 2023-02-23 615
b0f256f81e3ff9 Thomas Zimmermann 2023-02-23 616 /* fbdev */
b0f256f81e3ff9 Thomas Zimmermann 2023-02-23 617 #if defined(CONFIG_DRM_FBDEV_EMULATION)
d1c984af29e0c5 Thomas Zimmermann 2023-02-23 618 void psb_fbdev_setup(struct drm_psb_private *dev_priv);
b0f256f81e3ff9 Thomas Zimmermann 2023-02-23 619 #else
d1c984af29e0c5 Thomas Zimmermann 2023-02-23 @620 void psb_fbdev_setup(struct drm_psb_private *dev_priv)
b0f256f81e3ff9 Thomas Zimmermann 2023-02-23 @621 { }
b0f256f81e3ff9 Thomas Zimmermann 2023-02-23 622 #endif5c49fd3aa0ab02 Alan Cox 2011-11-03 623
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
kernel test robot
build botRe: [PATCH 6/7] drm/gma500: Implement client-based fbdev emulation
In reply to Thomas ZimmermannI love your patch! Yet something to improve:
Hi Thomas,
I love your patch! Yet something to improve:
[auto build test ERROR on linus/master]
[cannot apply to drm-misc/drm-misc-next v6.2 v6.2-rc8 v6.2-rc7 next-20230223 v6.2 next-20230223] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Thomas-Zimmermann/drm-gma500-Remove-unnecessary-include-statements/20230223-202205 patch link: https://lore.kernel.org/r/20230223121733.12549-7-tzimmermann%40suse.de patch subject: [PATCH 6/7] drm/gma500: Implement client-based fbdev emulation config: i386-randconfig-a004 (https://download.01.org/0day-ci/archive/20230224/[email protected]/config) compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/d1c984af29e0c5219d353a4772527d233d1c1bcc
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Thomas-Zimmermann/drm-gma500-Remove-unnecessary-include-statements/20230223-202205 git checkout d1c984af29e0c5219d353a4772527d233d1c1bcc
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> ld.lld: error: duplicate symbol: psb_fbdev_setup >>> defined at psb_drv.h:621 (drivers/gpu/drm/gma500/psb_drv.h:621) >>> drivers/gpu/drm/gma500/backlight.o:(psb_fbdev_setup) in archive vmlinux.a >>> defined at psb_drv.h:621 (drivers/gpu/drm/gma500/psb_drv.h:621) >>> drivers/gpu/drm/gma500/cdv_device.o:(.text+0x0) in archive vmlinux.a -- >> ld.lld: error: duplicate symbol: psb_fbdev_setup >>> defined at psb_drv.h:621 (drivers/gpu/drm/gma500/psb_drv.h:621) >>> drivers/gpu/drm/gma500/backlight.o:(psb_fbdev_setup) in archive vmlinux.a >>> defined at psb_drv.h:621 (drivers/gpu/drm/gma500/psb_drv.h:621) >>> drivers/gpu/drm/gma500/cdv_intel_crt.o:(.text+0x0) in archive vmlinux.a -- >> ld.lld: error: duplicate symbol: psb_fbdev_setup >>> defined at psb_drv.h:621 (drivers/gpu/drm/gma500/psb_drv.h:621) >>> drivers/gpu/drm/gma500/backlight.o:(psb_fbdev_setup) in archive vmlinux.a >>> defined at psb_drv.h:621 (drivers/gpu/drm/gma500/psb_drv.h:621) >>> drivers/gpu/drm/gma500/gtt.o:(.text+0x0) in archive vmlinux.a -- >> ld.lld: error: duplicate symbol: psb_fbdev_setup >>> defined at psb_drv.h:621 (drivers/gpu/drm/gma500/psb_drv.h:621) >>> drivers/gpu/drm/gma500/backlight.o:(psb_fbdev_setup) in archive vmlinux.a >>> defined at psb_drv.h:621 (drivers/gpu/drm/gma500/psb_drv.h:621) >>> drivers/gpu/drm/gma500/intel_bios.o:(.text+0x0) in archive vmlinux.a -- >> ld.lld: error: duplicate symbol: psb_fbdev_setup >>> defined at psb_drv.h:621 (drivers/gpu/drm/gma500/psb_drv.h:621) >>> drivers/gpu/drm/gma500/backlight.o:(psb_fbdev_setup) in archive vmlinux.a >>> defined at psb_drv.h:621 (drivers/gpu/drm/gma500/psb_drv.h:621) >>> drivers/gpu/drm/gma500/intel_gmbus.o:(.text+0x0) in archive vmlinux.a -- >> ld.lld: error: duplicate symbol: psb_fbdev_setup >>> defined at psb_drv.h:621 (drivers/gpu/drm/gma500/psb_drv.h:621) >>> drivers/gpu/drm/gma500/backlight.o:(psb_fbdev_setup) in archive vmlinux.a >>> defined at psb_drv.h:621 (drivers/gpu/drm/gma500/psb_drv.h:621) >>> drivers/gpu/drm/gma500/intel_i2c.o:(.text+0x0) in archive vmlinux.a -- >> ld.lld: error: duplicate symbol: psb_fbdev_setup >>> defined at psb_drv.h:621 (drivers/gpu/drm/gma500/psb_drv.h:621) >>> drivers/gpu/drm/gma500/backlight.o:(psb_fbdev_setup) in archive vmlinux.a >>> defined at psb_drv.h:621 (drivers/gpu/drm/gma500/psb_drv.h:621) >>> drivers/gpu/drm/gma500/mid_bios.o:(.text+0x0) in archive vmlinux.a -- >> ld.lld: error: duplicate symbol: psb_fbdev_setup >>> defined at psb_drv.h:621 (drivers/gpu/drm/gma500/psb_drv.h:621) >>> drivers/gpu/drm/gma500/backlight.o:(psb_fbdev_setup) in archive vmlinux.a >>> defined at psb_drv.h:621 (drivers/gpu/drm/gma500/psb_drv.h:621) >>> drivers/gpu/drm/gma500/mmu.o:(.text+0x0) in archive vmlinux.a -- >> ld.lld: error: duplicate symbol: psb_fbdev_setup >>> defined at psb_drv.h:621 (drivers/gpu/drm/gma500/psb_drv.h:621) >>> drivers/gpu/drm/gma500/backlight.o:(psb_fbdev_setup) in archive vmlinux.a >>> defined at psb_drv.h:621 (drivers/gpu/drm/gma500/psb_drv.h:621) >>> drivers/gpu/drm/gma500/oaktrail_device.o:(.text+0x0) in archive vmlinux.a -- >> ld.lld: error: duplicate symbol: psb_fbdev_setup >>> defined at psb_drv.h:621 (drivers/gpu/drm/gma500/psb_drv.h:621) >>> drivers/gpu/drm/gma500/backlight.o:(psb_fbdev_setup) in archive vmlinux.a >>> defined at psb_drv.h:621 (drivers/gpu/drm/gma500/psb_drv.h:621) >>> drivers/gpu/drm/gma500/oaktrail_crtc.o:(.text+0x0) in archive vmlinux.a -- >> ld.lld: error: duplicate symbol: psb_fbdev_setup >>> defined at psb_drv.h:621 (drivers/gpu/drm/gma500/psb_drv.h:621) >>> drivers/gpu/drm/gma500/backlight.o:(psb_fbdev_setup) in archive vmlinux.a >>> defined at psb_drv.h:621 (drivers/gpu/drm/gma500/psb_drv.h:621) >>> drivers/gpu/drm/gma500/oaktrail_hdmi.o:(.text+0x0) in archive vmlinux.a
..
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
Thomas Zimmermann
maintainerPATCH 7/7 drm/gma500: Pass fb_info to psb_fbdev_vm_fault()
In reply to Thomas ZimmermannInstead of the DRM framebuffer, pass the FB info strcuture to the fbdev page-fault handler psb_fbdev_vm_fault(). The framebuffer is a high-level data structure and does not belong into fault handling. The fb_info has all necessary information. Also set fix.smem_start to the correct value (the beginning of the framebuffer in physical address space) and streamline the page-fault handler.
--- drivers/gpu/drm/gma500/fbdev.c | 39 ++++++++++++---------------------- 1 file changed, 14 insertions(+), 25 deletions(-)
drivers/gpu/drm/gma500/fbdev.c +14 -25
@@ -22,32 +22,24 @@static vm_fault_t psb_fbdev_vm_fault (struct vm_fault *vmf) {struct vm_area_struct *vma = vmf->vma; -struct drm_framebuffer *fb = vma->vm_private_data; -struct drm_device *dev = fb->dev; -struct drm_psb_private *dev_priv =to_drm_psb_private (dev); -struct psb_gem_object *pobj =to_psb_gem_object (fb->obj[0 ]); -int page_num; -int i; -unsigned long address; -vm_fault_t ret =VM_FAULT_SIGBUS ; -unsigned long pfn; -unsigned long phys_addr = (unsigned long )dev_priv->stolen_base + pobj->offset; - - page_num =vma_pages (vma); - address = vmf->address - (vmf->pgoff <<PAGE_SHIFT ); +struct fb_info *info = vma->vm_private_data; +unsigned long address = vmf->address - (vmf->pgoff <<PAGE_SHIFT ); +unsigned long pfn = info->fix.smem_start >>PAGE_SHIFT ; +vm_fault_t err =VM_FAULT_SIGBUS ; +unsigned long page_num =vma_pages (vma); +unsigned long i; vma->vm_page_prot =pgprot_noncached (vma->vm_page_prot); -for (i =0 ; i < page_num; i++) { - pfn = (phys_addr >>PAGE_SHIFT ); - - ret =vmf_insert_mixed (vma, address,__pfn_to_pfn_t (pfn,PFN_DEV )); -if (unlikely (ret &VM_FAULT_ERROR )) +for (i =0 ; i < page_num; ++i) { + err =vmf_insert_mixed (vma, address,__pfn_to_pfn_t (pfn,PFN_DEV )); +if (unlikely (err &VM_FAULT_ERROR ))break ; address +=PAGE_SIZE ; - phys_addr +=PAGE_SIZE ; + ++pfn; } -return ret; + +return err; }static const struct vm_operations_struct psb_fbdev_vm_ops = {
@@ -102,9 +94,6 @@ static int psb_fbdev_fb_setcolreg(unsigned int regno,static int psb_fbdev_fb_mmap (struct fb_info *info,struct vm_area_struct *vma) { -struct drm_fb_helper *fb_helper = info->par; -struct drm_framebuffer *fb = fb_helper->fb; -if (vma->vm_pgoff !=0 )return -EINVAL ;if (vma->vm_pgoff > (~0UL >>PAGE_SHIFT ))
@@ -116,7 +105,7 @@ static int psb_fbdev_fb_mmap(struct fb_info *info, struct vm_area_struct *vma)* suitable for our mmap work */ vma->vm_ops = &psb_fbdev_vm_ops; - vma->vm_private_data = (void *)fb; + vma->vm_private_data = info; vma->vm_flags |=VM_IO |VM_MIXEDMAP |VM_DONTEXPAND |VM_DONTDUMP ;return 0 ;
@@ -235,7 +224,7 @@ static int psbfb_probe(struct drm_fb_helper *fb_helper,drm_fb_helper_fill_info (info, fb_helper, sizes); - info->fix.smem_start = dev_priv->fb_base; + info->fix.smem_start = dev_priv->stolen_base + backing->offset; info->fix.smem_len = size; info->fix.ywrapstep =0 ; info->fix.ypanstep =0 ;
Signature · 1 line
2.39.2
Patrik Jakobsson
maintainerRe: [PATCH 7/7] drm/gma500: Pass fb_info to psb_fbdev_vm_fault()
Quoted 82 lines · Thomas Zimmermann
Instead of the DRM framebuffer, pass the FB info strcuture to the fbdev page-fault handler
psb_fbdev_vm_fault(). The framebuffer is a high-level data structure and does not belong into fault handling. Thefb_infohas all necessary information. Also set fix.smem_start to the correct value (the beginning of the framebuffer in physical address space) and streamline the page-fault handler.Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/gma500/fbdev.c | 39 ++++++++++++---------------------- 1 file changed, 14 insertions(+), 25 deletions(-)drivers/gpu/drm/gma500/fbdev.c +13
-24@@ -22,32 +22,24 @@static vm_fault_t psb_fbdev_vm_fault (struct vm_fault *vmf) {struct vm_area_struct *vma = vmf->vma; -struct drm_framebuffer *fb = vma->vm_private_data; -struct drm_device *dev = fb->dev; -struct drm_psb_private *dev_priv =to_drm_psb_private (dev); -struct psb_gem_object *pobj =to_psb_gem_object (fb->obj[0 ]); -int page_num; -int i; -unsigned long address; -vm_fault_t ret =VM_FAULT_SIGBUS ; -unsigned long pfn; -unsigned long phys_addr = (unsigned long )dev_priv->stolen_base + pobj->offset; - - page_num =vma_pages (vma); - address = vmf->address - (vmf->pgoff <<PAGE_SHIFT ); +struct fb_info *info = vma->vm_private_data; +unsigned long address = vmf->address - (vmf->pgoff <<PAGE_SHIFT ); +unsigned long pfn = info->fix.smem_start >>PAGE_SHIFT ; +vm_fault_t err =VM_FAULT_SIGBUS ; +unsigned long page_num =vma_pages (vma); +unsigned long i; vma->vm_page_prot =pgprot_noncached (vma->vm_page_prot); -for (i =0 ; i < page_num; i++) { - pfn = (phys_addr >>PAGE_SHIFT ); - - ret =vmf_insert_mixed (vma, address,__pfn_to_pfn_t (pfn,PFN_DEV )); -if (unlikely (ret &VM_FAULT_ERROR )) +for (i =0 ; i < page_num; ++i) { + err =vmf_insert_mixed (vma, address,__pfn_to_pfn_t (pfn,PFN_DEV )); +if (unlikely (err &VM_FAULT_ERROR ))break ; address +=PAGE_SIZE ; - phys_addr +=PAGE_SIZE ; + ++pfn; } -return ret; + +return err; }static const struct vm_operations_struct psb_fbdev_vm_ops = {@@ -102,9 +94,6 @@ static int psb_fbdev_fb_setcolreg(unsigned int regno,static int psb_fbdev_fb_mmap (struct fb_info *info,struct vm_area_struct *vma) { -struct drm_fb_helper *fb_helper = info->par; -struct drm_framebuffer *fb = fb_helper->fb; -if (vma->vm_pgoff !=0 )return -EINVAL ;if (vma->vm_pgoff > (~0UL >>PAGE_SHIFT ))@@ -116,7 +105,7 @@ static int psb_fbdev_fb_mmap(struct fb_info *info, struct vm_area_struct *vma)* suitable for our mmap work */ vma->vm_ops = &psb_fbdev_vm_ops; - vma->vm_private_data = (void *)fb; + vma->vm_private_data = info; vma->vm_flags |=VM_IO |VM_MIXEDMAP |VM_DONTEXPAND |VM_DONTDUMP ;return 0 ;
drivers/gpu/drm/gma500/fbdev.c static int psbfb_probe(struct drm_fb_helper *fb_helper, · line 227
Quoted 5 lines
drivers/gpu/drm/gma500/fbdev.c +1
-1@@ -235,7 +224,7 @@ static int psbfb_probe(struct drm_fb_helper *fb_helper,drm_fb_helper_fill_info (info, fb_helper, sizes); - info->fix.smem_start = dev_priv->fb_base; + info->fix.smem_start = dev_priv->stolen_base + backing->offset;
With this change, ->fb_base is no longer used and can be removed. We already store PSB_BSM (base of stolen memory) in ->stolen_base so no need to keep fb_base.
Quoted 6 lines
drivers/gpu/drm/gma500/fbdev.c +0
-1info->fix.smem_len = size; info->fix.ywrapstep =0 ; info->fix.ypanstep =0 ; --2.39.2