diff options
Diffstat (limited to 'drivers/gpu/vga/vgaarb.c')
-rw-r--r-- | drivers/gpu/vga/vgaarb.c | 61 |
1 files changed, 41 insertions, 20 deletions
diff --git a/drivers/gpu/vga/vgaarb.c b/drivers/gpu/vga/vgaarb.c index 441e38c95a85..b87569e96b16 100644 --- a/drivers/gpu/vga/vgaarb.c +++ b/drivers/gpu/vga/vgaarb.c | |||
@@ -1,12 +1,32 @@ | |||
1 | /* | 1 | /* |
2 | * vgaarb.c | 2 | * vgaarb.c: Implements the VGA arbitration. For details refer to |
3 | * Documentation/vgaarbiter.txt | ||
4 | * | ||
3 | * | 5 | * |
4 | * (C) Copyright 2005 Benjamin Herrenschmidt <benh@kernel.crashing.org> | 6 | * (C) Copyright 2005 Benjamin Herrenschmidt <benh@kernel.crashing.org> |
5 | * (C) Copyright 2007 Paulo R. Zanoni <przanoni@gmail.com> | 7 | * (C) Copyright 2007 Paulo R. Zanoni <przanoni@gmail.com> |
6 | * (C) Copyright 2007, 2009 Tiago Vignatti <vignatti@freedesktop.org> | 8 | * (C) Copyright 2007, 2009 Tiago Vignatti <vignatti@freedesktop.org> |
7 | * | 9 | * |
8 | * Implements the VGA arbitration. For details refer to | 10 | * Permission is hereby granted, free of charge, to any person obtaining a |
9 | * Documentation/vgaarbiter.txt | 11 | * copy of this software and associated documentation files (the "Software"), |
12 | * to deal in the Software without restriction, including without limitation | ||
13 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
14 | * and/or sell copies of the Software, and to permit persons to whom the | ||
15 | * Software is furnished to do so, subject to the following conditions: | ||
16 | * | ||
17 | * The above copyright notice and this permission notice (including the next | ||
18 | * paragraph) shall be included in all copies or substantial portions of the | ||
19 | * Software. | ||
20 | * | ||
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
24 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
26 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
27 | * DEALINGS | ||
28 | * IN THE SOFTWARE. | ||
29 | * | ||
10 | */ | 30 | */ |
11 | 31 | ||
12 | #include <linux/module.h> | 32 | #include <linux/module.h> |
@@ -155,8 +175,8 @@ static struct vga_device *__vga_tryget(struct vga_device *vgadev, | |||
155 | (vgadev->decodes & VGA_RSRC_LEGACY_MEM)) | 175 | (vgadev->decodes & VGA_RSRC_LEGACY_MEM)) |
156 | rsrc |= VGA_RSRC_LEGACY_MEM; | 176 | rsrc |= VGA_RSRC_LEGACY_MEM; |
157 | 177 | ||
158 | pr_devel("%s: %d\n", __func__, rsrc); | 178 | pr_debug("%s: %d\n", __func__, rsrc); |
159 | pr_devel("%s: owns: %d\n", __func__, vgadev->owns); | 179 | pr_debug("%s: owns: %d\n", __func__, vgadev->owns); |
160 | 180 | ||
161 | /* Check what resources we need to acquire */ | 181 | /* Check what resources we need to acquire */ |
162 | wants = rsrc & ~vgadev->owns; | 182 | wants = rsrc & ~vgadev->owns; |
@@ -268,7 +288,7 @@ static void __vga_put(struct vga_device *vgadev, unsigned int rsrc) | |||
268 | { | 288 | { |
269 | unsigned int old_locks = vgadev->locks; | 289 | unsigned int old_locks = vgadev->locks; |
270 | 290 | ||
271 | pr_devel("%s\n", __func__); | 291 | pr_debug("%s\n", __func__); |
272 | 292 | ||
273 | /* Update our counters, and account for equivalent legacy resources | 293 | /* Update our counters, and account for equivalent legacy resources |
274 | * if we decode them | 294 | * if we decode them |
@@ -575,6 +595,7 @@ static inline void vga_update_device_decodes(struct vga_device *vgadev, | |||
575 | else | 595 | else |
576 | vga_decode_count--; | 596 | vga_decode_count--; |
577 | } | 597 | } |
598 | pr_debug("vgaarb: decoding count now is: %d\n", vga_decode_count); | ||
578 | } | 599 | } |
579 | 600 | ||
580 | void __vga_set_legacy_decoding(struct pci_dev *pdev, unsigned int decodes, bool userspace) | 601 | void __vga_set_legacy_decoding(struct pci_dev *pdev, unsigned int decodes, bool userspace) |
@@ -831,7 +852,7 @@ static ssize_t vga_arb_write(struct file *file, const char __user * buf, | |||
831 | curr_pos += 5; | 852 | curr_pos += 5; |
832 | remaining -= 5; | 853 | remaining -= 5; |
833 | 854 | ||
834 | pr_devel("client 0x%p called 'lock'\n", priv); | 855 | pr_debug("client 0x%p called 'lock'\n", priv); |
835 | 856 | ||
836 | if (!vga_str_to_iostate(curr_pos, remaining, &io_state)) { | 857 | if (!vga_str_to_iostate(curr_pos, remaining, &io_state)) { |
837 | ret_val = -EPROTO; | 858 | ret_val = -EPROTO; |
@@ -867,7 +888,7 @@ static ssize_t vga_arb_write(struct file *file, const char __user * buf, | |||
867 | curr_pos += 7; | 888 | curr_pos += 7; |
868 | remaining -= 7; | 889 | remaining -= 7; |
869 | 890 | ||
870 | pr_devel("client 0x%p called 'unlock'\n", priv); | 891 | pr_debug("client 0x%p called 'unlock'\n", priv); |
871 | 892 | ||
872 | if (strncmp(curr_pos, "all", 3) == 0) | 893 | if (strncmp(curr_pos, "all", 3) == 0) |
873 | io_state = VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM; | 894 | io_state = VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM; |
@@ -917,7 +938,7 @@ static ssize_t vga_arb_write(struct file *file, const char __user * buf, | |||
917 | curr_pos += 8; | 938 | curr_pos += 8; |
918 | remaining -= 8; | 939 | remaining -= 8; |
919 | 940 | ||
920 | pr_devel("client 0x%p called 'trylock'\n", priv); | 941 | pr_debug("client 0x%p called 'trylock'\n", priv); |
921 | 942 | ||
922 | if (!vga_str_to_iostate(curr_pos, remaining, &io_state)) { | 943 | if (!vga_str_to_iostate(curr_pos, remaining, &io_state)) { |
923 | ret_val = -EPROTO; | 944 | ret_val = -EPROTO; |
@@ -961,7 +982,7 @@ static ssize_t vga_arb_write(struct file *file, const char __user * buf, | |||
961 | 982 | ||
962 | curr_pos += 7; | 983 | curr_pos += 7; |
963 | remaining -= 7; | 984 | remaining -= 7; |
964 | pr_devel("client 0x%p called 'target'\n", priv); | 985 | pr_debug("client 0x%p called 'target'\n", priv); |
965 | /* if target is default */ | 986 | /* if target is default */ |
966 | if (!strncmp(curr_pos, "default", 7)) | 987 | if (!strncmp(curr_pos, "default", 7)) |
967 | pdev = pci_dev_get(vga_default_device()); | 988 | pdev = pci_dev_get(vga_default_device()); |
@@ -971,11 +992,11 @@ static ssize_t vga_arb_write(struct file *file, const char __user * buf, | |||
971 | ret_val = -EPROTO; | 992 | ret_val = -EPROTO; |
972 | goto done; | 993 | goto done; |
973 | } | 994 | } |
974 | pr_devel("vgaarb: %s ==> %x:%x:%x.%x\n", curr_pos, | 995 | pr_debug("vgaarb: %s ==> %x:%x:%x.%x\n", curr_pos, |
975 | domain, bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); | 996 | domain, bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); |
976 | 997 | ||
977 | pbus = pci_find_bus(domain, bus); | 998 | pbus = pci_find_bus(domain, bus); |
978 | pr_devel("vgaarb: pbus %p\n", pbus); | 999 | pr_debug("vgaarb: pbus %p\n", pbus); |
979 | if (pbus == NULL) { | 1000 | if (pbus == NULL) { |
980 | pr_err("vgaarb: invalid PCI domain and/or bus address %x:%x\n", | 1001 | pr_err("vgaarb: invalid PCI domain and/or bus address %x:%x\n", |
981 | domain, bus); | 1002 | domain, bus); |
@@ -983,7 +1004,7 @@ static ssize_t vga_arb_write(struct file *file, const char __user * buf, | |||
983 | goto done; | 1004 | goto done; |
984 | } | 1005 | } |
985 | pdev = pci_get_slot(pbus, devfn); | 1006 | pdev = pci_get_slot(pbus, devfn); |
986 | pr_devel("vgaarb: pdev %p\n", pdev); | 1007 | pr_debug("vgaarb: pdev %p\n", pdev); |
987 | if (!pdev) { | 1008 | if (!pdev) { |
988 | pr_err("vgaarb: invalid PCI address %x:%x\n", | 1009 | pr_err("vgaarb: invalid PCI address %x:%x\n", |
989 | bus, devfn); | 1010 | bus, devfn); |
@@ -993,7 +1014,7 @@ static ssize_t vga_arb_write(struct file *file, const char __user * buf, | |||
993 | } | 1014 | } |
994 | 1015 | ||
995 | vgadev = vgadev_find(pdev); | 1016 | vgadev = vgadev_find(pdev); |
996 | pr_devel("vgaarb: vgadev %p\n", vgadev); | 1017 | pr_debug("vgaarb: vgadev %p\n", vgadev); |
997 | if (vgadev == NULL) { | 1018 | if (vgadev == NULL) { |
998 | pr_err("vgaarb: this pci device is not a vga device\n"); | 1019 | pr_err("vgaarb: this pci device is not a vga device\n"); |
999 | pci_dev_put(pdev); | 1020 | pci_dev_put(pdev); |
@@ -1029,7 +1050,7 @@ static ssize_t vga_arb_write(struct file *file, const char __user * buf, | |||
1029 | } else if (strncmp(curr_pos, "decodes ", 8) == 0) { | 1050 | } else if (strncmp(curr_pos, "decodes ", 8) == 0) { |
1030 | curr_pos += 8; | 1051 | curr_pos += 8; |
1031 | remaining -= 8; | 1052 | remaining -= 8; |
1032 | pr_devel("vgaarb: client 0x%p called 'decodes'\n", priv); | 1053 | pr_debug("vgaarb: client 0x%p called 'decodes'\n", priv); |
1033 | 1054 | ||
1034 | if (!vga_str_to_iostate(curr_pos, remaining, &io_state)) { | 1055 | if (!vga_str_to_iostate(curr_pos, remaining, &io_state)) { |
1035 | ret_val = -EPROTO; | 1056 | ret_val = -EPROTO; |
@@ -1058,7 +1079,7 @@ static unsigned int vga_arb_fpoll(struct file *file, poll_table * wait) | |||
1058 | { | 1079 | { |
1059 | struct vga_arb_private *priv = file->private_data; | 1080 | struct vga_arb_private *priv = file->private_data; |
1060 | 1081 | ||
1061 | pr_devel("%s\n", __func__); | 1082 | pr_debug("%s\n", __func__); |
1062 | 1083 | ||
1063 | if (priv == NULL) | 1084 | if (priv == NULL) |
1064 | return -ENODEV; | 1085 | return -ENODEV; |
@@ -1071,7 +1092,7 @@ static int vga_arb_open(struct inode *inode, struct file *file) | |||
1071 | struct vga_arb_private *priv; | 1092 | struct vga_arb_private *priv; |
1072 | unsigned long flags; | 1093 | unsigned long flags; |
1073 | 1094 | ||
1074 | pr_devel("%s\n", __func__); | 1095 | pr_debug("%s\n", __func__); |
1075 | 1096 | ||
1076 | priv = kmalloc(sizeof(struct vga_arb_private), GFP_KERNEL); | 1097 | priv = kmalloc(sizeof(struct vga_arb_private), GFP_KERNEL); |
1077 | if (priv == NULL) | 1098 | if (priv == NULL) |
@@ -1101,7 +1122,7 @@ static int vga_arb_release(struct inode *inode, struct file *file) | |||
1101 | unsigned long flags; | 1122 | unsigned long flags; |
1102 | int i; | 1123 | int i; |
1103 | 1124 | ||
1104 | pr_devel("%s\n", __func__); | 1125 | pr_debug("%s\n", __func__); |
1105 | 1126 | ||
1106 | if (priv == NULL) | 1127 | if (priv == NULL) |
1107 | return -ENODEV; | 1128 | return -ENODEV; |
@@ -1112,7 +1133,7 @@ static int vga_arb_release(struct inode *inode, struct file *file) | |||
1112 | uc = &priv->cards[i]; | 1133 | uc = &priv->cards[i]; |
1113 | if (uc->pdev == NULL) | 1134 | if (uc->pdev == NULL) |
1114 | continue; | 1135 | continue; |
1115 | pr_devel("uc->io_cnt == %d, uc->mem_cnt == %d\n", | 1136 | pr_debug("uc->io_cnt == %d, uc->mem_cnt == %d\n", |
1116 | uc->io_cnt, uc->mem_cnt); | 1137 | uc->io_cnt, uc->mem_cnt); |
1117 | while (uc->io_cnt--) | 1138 | while (uc->io_cnt--) |
1118 | vga_put(uc->pdev, VGA_RSRC_LEGACY_IO); | 1139 | vga_put(uc->pdev, VGA_RSRC_LEGACY_IO); |
@@ -1165,7 +1186,7 @@ static int pci_notify(struct notifier_block *nb, unsigned long action, | |||
1165 | struct pci_dev *pdev = to_pci_dev(dev); | 1186 | struct pci_dev *pdev = to_pci_dev(dev); |
1166 | bool notify = false; | 1187 | bool notify = false; |
1167 | 1188 | ||
1168 | pr_devel("%s\n", __func__); | 1189 | pr_debug("%s\n", __func__); |
1169 | 1190 | ||
1170 | /* For now we're only intereted in devices added and removed. I didn't | 1191 | /* For now we're only intereted in devices added and removed. I didn't |
1171 | * test this thing here, so someone needs to double check for the | 1192 | * test this thing here, so someone needs to double check for the |