From: Thomas Zimmermann <tzimmermann@suse.de>
To: patrik.r.jakobsson@gmail.com, airlied@gmail.com, daniel@ffwll.ch
Cc: Thomas Zimmermann <tzimmermann@suse.de>, dri-devel@lists.freedesktop.org
Subject: [PATCH 7/7] drm/gma500: Pass fb_info to psb_fbdev_vm_fault()
Date: Thu, 23 Feb 2023 13:17:33 +0100 [thread overview]
Message-ID: <20230223121733.12549-8-tzimmermann@suse.de> (raw)
In-Reply-To: <20230223121733.12549-1-tzimmermann@suse.de>
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.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/gpu/drm/gma500/fbdev.c | 39 ++++++++++++----------------------
1 file changed, 14 insertions(+), 25 deletions(-)
diff --git a/drivers/gpu/drm/gma500/fbdev.c b/drivers/gpu/drm/gma500/fbdev.c
index a70ca4c5013f..c8dbcb33ddb5 100644
--- a/drivers/gpu/drm/gma500/fbdev.c
+++ b/drivers/gpu/drm/gma500/fbdev.c
@@ -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;
--
2.39.2
next prev parent reply other threads:[~2023-02-23 12:17 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-23 12:17 [PATCH 0/7] drm/gma500: Convert fbdev to DRM client Thomas Zimmermann
2023-02-23 12:17 ` [PATCH 1/7] drm/gma500: Remove unnecessary include statements Thomas Zimmermann
2023-02-23 12:17 ` [PATCH 2/7] drm/gma500: Move fbdev code into separate source file Thomas Zimmermann
2023-02-27 7:10 ` Patrik Jakobsson
2023-02-27 7:40 ` Thomas Zimmermann
2023-02-27 7:48 ` Patrik Jakobsson
2023-03-06 14:51 ` Patrik Jakobsson
2023-02-23 12:17 ` [PATCH 3/7] drm/gma500: Remove fbdev vma open and close callbacks Thomas Zimmermann
2023-02-23 12:17 ` [PATCH 4/7] drm/gma500: Fix naming in fb_ops Thomas Zimmermann
2023-02-23 12:17 ` [PATCH 5/7] drm/gma500: Inline psbfb_create() into psbfb_probe() Thomas Zimmermann
2023-03-06 14:51 ` Patrik Jakobsson
2023-02-23 12:17 ` [PATCH 6/7] drm/gma500: Implement client-based fbdev emulation Thomas Zimmermann
2023-02-23 19:01 ` kernel test robot
2023-02-24 7:58 ` Thomas Zimmermann
2023-02-23 19:22 ` kernel test robot
2023-02-23 21:04 ` kernel test robot
2023-02-23 12:17 ` Thomas Zimmermann [this message]
2023-03-06 14:52 ` [PATCH 7/7] drm/gma500: Pass fb_info to psb_fbdev_vm_fault() Patrik Jakobsson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230223121733.12549-8-tzimmermann@suse.de \
--to=tzimmermann@suse.de \
--cc=airlied@gmail.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=patrik.r.jakobsson@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox