]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
drm/gma500: Pass fb_info to psb_fbdev_vm_fault()
authorThomas Zimmermann <tzimmermann@suse.de>
Mon, 13 Mar 2023 15:16:10 +0000 (16:16 +0100)
committerThomas Zimmermann <tzimmermann@suse.de>
Mon, 20 Mar 2023 10:19:22 +0000 (11:19 +0100)
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.
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.

v2:
* remove unused struct drm_psb_private.fb_base (Patrik)

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230313151610.14367-8-tzimmermann@suse.de
drivers/gpu/drm/gma500/fbdev.c
drivers/gpu/drm/gma500/framebuffer.c
drivers/gpu/drm/gma500/psb_drv.h

index 0433392c7fbf17408477bce66681cea343b8a217..62287407e717326fb851b32e6198b628910de7f9 100644 (file)
 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;
        vm_flags_set(vma, VM_IO | VM_MIXEDMAP | VM_DONTEXPAND | VM_DONTDUMP);
 
        return 0;
@@ -235,7 +224,7 @@ static int psb_fbdev_fb_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;
index f5c3bae95eb5d8053d3aa4fbbc4ed1fde6b933be..1a374702b696034d302c82fb686042f9d27e17f6 100644 (file)
@@ -186,7 +186,6 @@ void psb_modeset_init(struct drm_device *dev)
 {
        struct drm_psb_private *dev_priv = to_drm_psb_private(dev);
        struct psb_intel_mode_device *mode_dev = &dev_priv->mode_dev;
-       struct pci_dev *pdev = to_pci_dev(dev->dev);
        int i;
 
        if (drmm_mode_config_init(dev))
@@ -197,10 +196,6 @@ void psb_modeset_init(struct drm_device *dev)
 
        dev->mode_config.funcs = &psb_mode_funcs;
 
-       /* set memory base */
-       /* Oaktrail and Poulsbo should use BAR 2*/
-       pci_read_config_dword(pdev, PSB_BSM, (u32 *)&(dev_priv->fb_base));
-
        /* num pipes is 2 for PSB but 1 for Mrst */
        for (i = 0; i < dev_priv->num_pipe; i++)
                psb_intel_crtc_init(dev, i, mode_dev);
index 931f62c1d942b1f3529e233d7849abc13027ab2d..f7f709df99b49880f07499acc3e81505f8915883 100644 (file)
@@ -520,8 +520,6 @@ struct drm_psb_private {
        uint32_t blc_adj1;
        uint32_t blc_adj2;
 
-       resource_size_t fb_base;
-
        bool dsr_enable;
        u32 dsr_fb_update;
        bool dpi_panel_on[3];