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 = {
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))
* 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;
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;
{
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))
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);