VirtualBox

Changeset 64830 in vbox for trunk/src/VBox/Additions


Ignore:
Timestamp:
Dec 12, 2016 9:55:37 AM (8 years ago)
Author:
vboxsync
Message:

bugref:8677: Additions/Graphics/Wayland: Fedora 25 issues: remove functionality from the vboxvideo drm driver for moving unused buffers in video RAM to system RAM. This was copied and pasted from the driver for the memory-strapped AST driver, and not so relevant for us. However it was having the unintended consequence that when GNOME Shell page-flipped in a new buffer it was ending up at the same video RAM address as the old one (I unfortunately currently do not understand the details), leading the graphics card to think that nothing had changed on-screen. Now unaccelerated updates are working correctly in multi-monitor Fedora 25 guests, though probably still not very efficiently.

Location:
trunk/src/VBox/Additions/linux/drm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/linux/drm/vbox_drv.h

    r64172 r64830  
    183183    struct drm_fb_helper helper;
    184184    struct vbox_framebuffer afb;
    185     void *sysram;
    186185    int size;
    187186    struct ttm_bo_kmap_obj mapping;
  • trunk/src/VBox/Additions/linux/drm/vbox_fb.c

    r64337 r64830  
    7575                 int x, int y, int width, int height)
    7676{
    77     int i;
    78 
    7977    struct drm_gem_object *obj;
    8078    struct vbox_bo *bo;
    81     int src_offset, dst_offset;
    82     int bpp = (fbdev->afb.base.bits_per_pixel + 7)/8;
    8379    int ret = -EBUSY;
    84     bool unmap = false;
    8580    bool store_for_later = false;
    8681    int x2, y2;
     
    131126    spin_unlock_irqrestore(&fbdev->dirty_lock, flags);
    132127
    133     if (!bo->kmap.virtual) {
    134         ret = ttm_bo_kmap(&bo->bo, 0, bo->bo.num_pages, &bo->kmap);
    135         if (ret) {
    136             DRM_ERROR("failed to kmap fb updates\n");
    137             vbox_bo_unreserve(bo);
    138             return;
    139         }
    140         unmap = true;
    141     }
    142     for (i = y; i <= y2; i++) {
    143         /* assume equal stride for now */
    144         src_offset = dst_offset = i * fbdev->afb.base.pitches[0] + (x * bpp);
    145         memcpy_toio(bo->kmap.virtual + src_offset, (char *)fbdev->sysram + src_offset, (x2 - x + 1) * bpp);
    146     }
    147128    /* Not sure why the original code subtracted 1 here, but I will keep it that
    148129     * way to avoid unnecessary differences. */
     
    152133    rect.y2 = y2 + 1;
    153134    vbox_framebuffer_dirty_rectangles(&fbdev->afb.base, &rect, 1);
    154     if (unmap)
    155         ttm_bo_kunmap(&bo->kmap);
    156135
    157136    vbox_bo_unreserve(bo);
     
    271250    int size, ret;
    272251    struct device *device = &dev->pdev->dev;
    273     void *sysram;
    274252    struct drm_gem_object *gobj = NULL;
    275253    struct vbox_bo *bo = NULL;
     
    294272        return ret;
    295273    }
     274
     275    ret = vbox_framebuffer_init(dev, &fbdev->afb, &mode_cmd, gobj);
     276    if (ret)
     277        return ret;
     278
    296279    bo = gem_to_vbox_bo(gobj);
    297280
    298     sysram = vmalloc(size);
    299     if (!sysram)
     281    ret = vbox_bo_reserve(bo, false);
     282    if (ret)
     283        return ret;
     284
     285    ret = vbox_bo_pin(bo, TTM_PL_FLAG_VRAM, NULL);
     286    if (ret) {
     287        vbox_bo_unreserve(bo);
     288        return ret;
     289    }
     290
     291    ret = ttm_bo_kmap(&bo->bo, 0, bo->bo.num_pages, &bo->kmap);
     292    vbox_bo_unreserve(bo);
     293    if (ret) {
     294        DRM_ERROR("failed to kmap fbcon\n");
     295        return ret;
     296    }
     297
     298    info = framebuffer_alloc(0, device);
     299    if (!info)
    300300        return -ENOMEM;
    301 
    302     info = framebuffer_alloc(0, device);
    303     if (!info) {
    304         ret = -ENOMEM;
    305         goto out;
    306     }
    307301    info->par = fbdev;
    308302
    309     ret = vbox_framebuffer_init(dev, &fbdev->afb, &mode_cmd, gobj);
    310     if (ret)
    311         goto out;
    312 
    313     fbdev->sysram = sysram;
    314303    fbdev->size = size;
    315304
     
    327316
    328317    ret = fb_alloc_cmap(&info->cmap, 256, 0);
    329     if (ret) {
    330         ret = -ENOMEM;
    331         goto out;
    332     }
     318    if (ret)
     319        return -ENOMEM;
    333320
    334321    /* This seems to be done for safety checking that the framebuffer is not
    335322     * registered twice by different drivers. */
    336323    info->apertures = alloc_apertures(1);
    337     if (!info->apertures) {
    338         ret = -ENOMEM;
    339         goto out;
    340     }
     324    if (!info->apertures)
     325        return -ENOMEM;
    341326    info->apertures->ranges[0].base = pci_resource_start(dev->pdev, 0);
    342327    info->apertures->ranges[0].size = pci_resource_len(dev->pdev, 0);
     
    345330    drm_fb_helper_fill_var(info, &fbdev->helper, sizes->fb_width, sizes->fb_height);
    346331
    347     info->screen_base = sysram;
     332    info->screen_base = bo->kmap.virtual;
    348333    info->screen_size = size;
    349334
     
    359344
    360345    return 0;
    361 out:
    362     return ret;
    363346}
    364347
     
    397380
    398381    if (afb->obj) {
     382        struct vbox_bo *bo = gem_to_vbox_bo(afb->obj);
     383        if (!vbox_bo_reserve(bo, false)) {
     384            if (bo->kmap.virtual)
     385                ttm_bo_kunmap(&bo->kmap);
     386            /* QXL does this, but is it really needed before freeing? */
     387            if (bo->pin_count)
     388                vbox_bo_unpin(bo);
     389            vbox_bo_unreserve(bo);
     390        }
    399391        drm_gem_object_unreference_unlocked(afb->obj);
    400392        afb->obj = NULL;
     
    402394    drm_fb_helper_fini(&fbdev->helper);
    403395
    404     vfree(fbdev->sysram);
    405396#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)
    406397    drm_framebuffer_unregister_private(&afb->base);
  • trunk/src/VBox/Additions/linux/drm/vbox_mode.c

    r64400 r64830  
    171171}
    172172
    173 /* We move buffers which are not in active use out of VRAM to save memory. */
    174173static int vbox_crtc_do_set_base(struct drm_crtc *crtc,
    175                 struct drm_framebuffer *fb,
    176                 int x, int y, int atomic)
     174                struct drm_framebuffer *old_fb,
     175                int x, int y)
    177176{
    178177    struct vbox_private *vbox = crtc->dev->dev_private;
     
    184183    u64 gpu_addr;
    185184
    186     /* push the previous fb to system ram */
    187     if (!atomic && fb) {
    188         vbox_fb = to_vbox_framebuffer(fb);
     185    /* Unpin the previous fb. */
     186    if (old_fb) {
     187        vbox_fb = to_vbox_framebuffer(old_fb);
    189188        obj = vbox_fb->obj;
    190189        bo = gem_to_vbox_bo(obj);
     
    192191        if (ret)
    193192            return ret;
    194         vbox_bo_push_sysram(bo);
     193        vbox_bo_unpin(bo);
    195194        vbox_bo_unreserve(bo);
    196195    }
     
    210209    }
    211210
    212     if (&vbox->fbdev->afb == vbox_fb) {
    213         /* if pushing console in kmap it */
    214         ret = ttm_bo_kmap(&bo->bo, 0, bo->bo.num_pages, &bo->kmap);
    215         if (ret)
    216             DRM_ERROR("failed to kmap fbcon\n");
    217         else
    218             vbox_fbdev_set_base(vbox, gpu_addr);
    219     }
     211    if (&vbox->fbdev->afb == vbox_fb)
     212        vbox_fbdev_set_base(vbox, gpu_addr);
    220213    vbox_bo_unreserve(bo);
    221214
     
    232225                 struct drm_framebuffer *old_fb)
    233226{
    234     return vbox_crtc_do_set_base(crtc, old_fb, x, y, 0);
     227    return vbox_crtc_do_set_base(crtc, old_fb, x, y);
    235228}
    236229
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette