Commit 5c0f6ee7 authored by Alex Williamson's avatar Alex Williamson Committed by Daniel Vetter

vgaarb: Fix VGA decodes changes

When VGA decodes change we need to do a bit more evaluation of exactly what
has changed.  We don't necessarily give up all the old owns resources and
we need to account for resources with locks.  The new algorithm is: If
something is added, update decodes.  If legacy resources were added and
none were there before, we have a new participant.  If something is
removed, update decodes.  If we previously owned it, we no longer own it.
If it was previously locked, invalidate all locks and release it.  If
legacy resources were removed and none are left, remove the participant
from VGA arbitration.

Previously we updated decodes, released ownership of everything that was
previously decoded, ignored all locks, and went off looking for another
device to transfer VGA to.  In a test case where Intel IGD removes only
legacy VGA memory decoding, this left the arbiter switching to discrete
graphics without actually disabling legacy VGA IO from the IGD.  As a
bonus, we bumped up the count of VGA arbitration participants for no
good reason.
Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
Cc: Dave Airlie <airlied@redhat.com>
Acked-by: default avatarDave Airlie <airlied@redhat.com>
Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
[danvet: Kill now unused variables, reported by the 0-day kernel
builtbot.]
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent f22d776f
...@@ -644,10 +644,12 @@ static bool vga_arbiter_del_pci_device(struct pci_dev *pdev) ...@@ -644,10 +644,12 @@ static bool vga_arbiter_del_pci_device(struct pci_dev *pdev)
static inline void vga_update_device_decodes(struct vga_device *vgadev, static inline void vga_update_device_decodes(struct vga_device *vgadev,
int new_decodes) int new_decodes)
{ {
int old_decodes; int old_decodes, decodes_removed, decodes_unlocked;
struct vga_device *new_vgadev, *conflict;
old_decodes = vgadev->decodes; old_decodes = vgadev->decodes;
decodes_removed = ~new_decodes & old_decodes;
decodes_unlocked = vgadev->locks & decodes_removed;
vgadev->owns &= ~decodes_removed;
vgadev->decodes = new_decodes; vgadev->decodes = new_decodes;
pr_info("vgaarb: device changed decodes: PCI:%s,olddecodes=%s,decodes=%s:owns=%s\n", pr_info("vgaarb: device changed decodes: PCI:%s,olddecodes=%s,decodes=%s:owns=%s\n",
...@@ -656,31 +658,22 @@ static inline void vga_update_device_decodes(struct vga_device *vgadev, ...@@ -656,31 +658,22 @@ static inline void vga_update_device_decodes(struct vga_device *vgadev,
vga_iostate_to_str(vgadev->decodes), vga_iostate_to_str(vgadev->decodes),
vga_iostate_to_str(vgadev->owns)); vga_iostate_to_str(vgadev->owns));
/* if we removed locked decodes, lock count goes to zero, and release */
/* if we own the decodes we should move them along to if (decodes_unlocked) {
another card */ if (decodes_unlocked & VGA_RSRC_LEGACY_IO)
if ((vgadev->owns & old_decodes) && (vga_count > 1)) { vgadev->io_lock_cnt = 0;
/* set us to own nothing */ if (decodes_unlocked & VGA_RSRC_LEGACY_MEM)
vgadev->owns &= ~old_decodes; vgadev->mem_lock_cnt = 0;
list_for_each_entry(new_vgadev, &vga_list, list) { __vga_put(vgadev, decodes_unlocked);
if ((new_vgadev != vgadev) &&
(new_vgadev->decodes & VGA_RSRC_LEGACY_MASK)) {
pr_info("vgaarb: transferring owner from PCI:%s to PCI:%s\n", pci_name(vgadev->pdev), pci_name(new_vgadev->pdev));
conflict = __vga_tryget(new_vgadev, VGA_RSRC_LEGACY_MASK);
if (!conflict)
__vga_put(new_vgadev, VGA_RSRC_LEGACY_MASK);
break;
}
}
} }
/* change decodes counter */ /* change decodes counter */
if (old_decodes != new_decodes) { if (old_decodes & VGA_RSRC_LEGACY_MASK &&
if (new_decodes & (VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM)) !(new_decodes & VGA_RSRC_LEGACY_MASK))
vga_decode_count++;
else
vga_decode_count--; vga_decode_count--;
} if (!(old_decodes & VGA_RSRC_LEGACY_MASK) &&
new_decodes & VGA_RSRC_LEGACY_MASK)
vga_decode_count++;
pr_debug("vgaarb: decoding count now is: %d\n", vga_decode_count); pr_debug("vgaarb: decoding count now is: %d\n", vga_decode_count);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment