]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
fbmem, drm/nouveau: kick firmware framebuffers as soon as possible
authorMarcin Slusarz <marcin.slusarz@gmail.com>
Sun, 16 May 2010 15:29:56 +0000 (17:29 +0200)
committerDave Airlie <airlied@redhat.com>
Tue, 18 May 2010 06:19:28 +0000 (16:19 +1000)
Currently vesafb/efifb/... is kicked when hardware driver is registering
framebuffer. To do it hardware must be fully functional, so there's a short
window between start of initialisation and framebuffer registration when
two drivers touch the hardware. Unfortunately sometimes it breaks nouveau
initialisation.

Fix it by kicking firmware driver(s) before we start touching the hardware.

Reported-by: Didier Spaier <didier.spaier@epsm.fr>
Tested-by: Didier Spaier <didier.spaier@epsm.fr>
Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: Peter Jones <pjones@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/nouveau/nouveau_drv.h
drivers/gpu/drm/nouveau/nouveau_fbcon.c
drivers/gpu/drm/nouveau/nouveau_state.c
drivers/video/fbmem.c
include/linux/fb.h

index 5b47b79f45e809d4b08d387c96bb55ccf99ee041..94d8dd27bde858f2475a2b1cd8a9e24716282609 100644 (file)
@@ -624,6 +624,7 @@ struct drm_nouveau_private {
        } debugfs;
 
        struct nouveau_fbdev *nfbdev;
+       struct apertures_struct *apertures;
 };
 
 static inline struct drm_nouveau_private *
index 292c7ff951057a0ab9896f6925a6f902eaa92146..2c2199329cc1ebd9772b852793ba70b7ed16b69f 100644 (file)
@@ -183,7 +183,6 @@ nouveau_fbcon_create(struct nouveau_fbdev *nfbdev,
        struct drm_mode_fb_cmd mode_cmd;
        struct pci_dev *pdev = dev->pdev;
        struct device *device = &pdev->dev;
-       struct apertures_struct *aper;
        int size, ret;
 
        mode_cmd.width = sizes->surface_width;
@@ -267,28 +266,12 @@ nouveau_fbcon_create(struct nouveau_fbdev *nfbdev,
        info->fix.mmio_len = pci_resource_len(pdev, 1);
 
        /* Set aperture base/size for vesafb takeover */
-       aper = info->apertures = alloc_apertures(3);
+       info->apertures = dev_priv->apertures;
        if (!info->apertures) {
                ret = -ENOMEM;
                goto out_unref;
        }
 
-       aper->ranges[0].base = pci_resource_start(pdev, 1);
-       aper->ranges[0].size = pci_resource_len(pdev, 1);
-       aper->count = 1;
-
-       if (pci_resource_len(pdev, 2)) {
-               aper->ranges[aper->count].base = pci_resource_start(pdev, 2);
-               aper->ranges[aper->count].size = pci_resource_len(pdev, 2);
-               aper->count++;
-       }
-
-       if (pci_resource_len(pdev, 3)) {
-               aper->ranges[aper->count].base = pci_resource_start(pdev, 3);
-               aper->ranges[aper->count].size = pci_resource_len(pdev, 3);
-               aper->count++;
-       }
-
        info->pixmap.size = 64*1024;
        info->pixmap.buf_align = 8;
        info->pixmap.access_align = 32;
index 92100a9678bac98637bb71d144e3d71c7bca19b1..75c5c465e08ec4e9a4425218849e52bff9dd3276 100644 (file)
@@ -639,6 +639,43 @@ static void nouveau_OF_copy_vbios_to_ramin(struct drm_device *dev)
 #endif
 }
 
+static struct apertures_struct *nouveau_get_apertures(struct drm_device *dev)
+{
+       struct pci_dev *pdev = dev->pdev;
+       struct apertures_struct *aper = alloc_apertures(3);
+       if (!aper)
+               return NULL;
+
+       aper->ranges[0].base = pci_resource_start(pdev, 1);
+       aper->ranges[0].size = pci_resource_len(pdev, 1);
+       aper->count = 1;
+
+       if (pci_resource_len(pdev, 2)) {
+               aper->ranges[aper->count].base = pci_resource_start(pdev, 2);
+               aper->ranges[aper->count].size = pci_resource_len(pdev, 2);
+               aper->count++;
+       }
+
+       if (pci_resource_len(pdev, 3)) {
+               aper->ranges[aper->count].base = pci_resource_start(pdev, 3);
+               aper->ranges[aper->count].size = pci_resource_len(pdev, 3);
+               aper->count++;
+       }
+
+       return aper;
+}
+
+static int nouveau_remove_conflicting_drivers(struct drm_device *dev)
+{
+       struct drm_nouveau_private *dev_priv = dev->dev_private;
+       dev_priv->apertures = nouveau_get_apertures(dev);
+       if (!dev_priv->apertures)
+               return -ENOMEM;
+
+       remove_conflicting_framebuffers(dev_priv->apertures, "nouveaufb");
+       return 0;
+}
+
 int nouveau_load(struct drm_device *dev, unsigned long flags)
 {
        struct drm_nouveau_private *dev_priv;
@@ -726,6 +763,12 @@ int nouveau_load(struct drm_device *dev, unsigned long flags)
        NV_INFO(dev, "Detected an NV%2x generation card (0x%08x)\n",
                dev_priv->card_type, reg0);
 
+       if (drm_core_check_feature(dev, DRIVER_MODESET)) {
+               int ret = nouveau_remove_conflicting_drivers(dev);
+               if (ret)
+                       return ret;
+       }
+
        /* map larger RAMIN aperture on NV40 cards */
        dev_priv->ramin  = NULL;
        if (dev_priv->card_type >= NV_40) {
index 03f2dc2470b531c30cca5d60ba04a2cfd0a4413d..7cfcd716fd5f2544cdc609125284d54c08b954a0 100644 (file)
@@ -1479,11 +1479,10 @@ static bool apertures_overlap(struct aperture *gen, struct aperture *hw)
        return false;
 }
 
-static bool fb_do_apertures_overlap(struct fb_info *gen, struct fb_info *hw)
+static bool fb_do_apertures_overlap(struct apertures_struct *gena,
+                                   struct apertures_struct *hwa)
 {
        int i, j;
-       struct apertures_struct *hwa = hw->apertures;
-       struct apertures_struct *gena = gen->apertures;
        if (!hwa || !gena)
                return false;
 
@@ -1501,6 +1500,28 @@ static bool fb_do_apertures_overlap(struct fb_info *gen, struct fb_info *hw)
        return false;
 }
 
+void remove_conflicting_framebuffers(struct apertures_struct *a, const char *name)
+{
+       int i;
+
+       /* check all firmware fbs and kick off if the base addr overlaps */
+       for (i = 0 ; i < FB_MAX; i++) {
+               if (!registered_fb[i])
+                       continue;
+
+               if (!(registered_fb[i]->flags & FBINFO_MISC_FIRMWARE))
+                       continue;
+
+               if (fb_do_apertures_overlap(registered_fb[i]->apertures, a)) {
+                       printk(KERN_ERR "fb: conflicting fb hw usage "
+                              "%s vs %s - removing generic driver\n",
+                              name, registered_fb[i]->fix.id);
+                       unregister_framebuffer(registered_fb[i]);
+               }
+       }
+}
+EXPORT_SYMBOL(remove_conflicting_framebuffers);
+
 /**
  *     register_framebuffer - registers a frame buffer device
  *     @fb_info: frame buffer info structure
@@ -1524,21 +1545,7 @@ register_framebuffer(struct fb_info *fb_info)
        if (fb_check_foreignness(fb_info))
                return -ENOSYS;
 
-       /* check all firmware fbs and kick off if the base addr overlaps */
-       for (i = 0 ; i < FB_MAX; i++) {
-               if (!registered_fb[i])
-                       continue;
-
-               if (registered_fb[i]->flags & FBINFO_MISC_FIRMWARE) {
-                       if (fb_do_apertures_overlap(registered_fb[i], fb_info)) {
-                               printk(KERN_ERR "fb: conflicting fb hw usage "
-                                      "%s vs %s - removing generic driver\n",
-                                      fb_info->fix.id,
-                                      registered_fb[i]->fix.id);
-                               unregister_framebuffer(registered_fb[i]);
-                       }
-               }
-       }
+       remove_conflicting_framebuffers(fb_info->apertures, fb_info->fix.id);
 
        num_registered_fb++;
        for (i = 0 ; i < FB_MAX; i++)
index de5ff5fa8380eb55068a47426917f65dd2f2e96a..f88e2549123d02f31a394f20b7fc6999765a5748 100644 (file)
@@ -971,6 +971,7 @@ extern ssize_t fb_sys_write(struct fb_info *info, const char __user *buf,
 /* drivers/video/fbmem.c */
 extern int register_framebuffer(struct fb_info *fb_info);
 extern int unregister_framebuffer(struct fb_info *fb_info);
+extern void remove_conflicting_framebuffers(struct apertures_struct *a, const char *name);
 extern int fb_prepare_logo(struct fb_info *fb_info, int rotate);
 extern int fb_show_logo(struct fb_info *fb_info, int rotate);
 extern char* fb_get_buffer_offset(struct fb_info *info, struct fb_pixmap *buf, u32 size);