aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/lguest/boot.c
diff options
context:
space:
mode:
authorPaul Bolle <pebolle@tiscali.nl>2016-03-03 07:01:41 -0500
committerThomas Gleixner <tglx@linutronix.de>2016-06-10 05:39:09 -0400
commitcf2cf0f50c14e86e04cda2c684357eed77922666 (patch)
tree813cf2759a4d5174ee0ce847af3713e4a817d47e /arch/x86/lguest/boot.c
parent7faf90ef995ea470f32f43810266ece8ac8ba6c7 (diff)
lguest: Read offset of device_cap later
Read the offset of the capability with type VIRTIO_PCI_CAP_DEVICE_CFG only when we're sure we're going to need it. Which is when all checks have passed and we know we have a virtio console with an emerg_wr field. Signed-off-by: Paul Bolle <pebolle@tiscali.nl> Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: lguest@lists.ozlabs.org Link: http://lkml.kernel.org/r/1457006501-5377-3-git-send-email-pebolle@tiscali.nl Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/lguest/boot.c')
-rw-r--r--arch/x86/lguest/boot.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
index 146d11c8cf78..25da5bc8d83d 100644
--- a/arch/x86/lguest/boot.c
+++ b/arch/x86/lguest/boot.c
@@ -1233,8 +1233,6 @@ static void write_bar_via_cfg(u32 cfg_offset, u32 off, u32 val)
1233static void probe_pci_console(void) 1233static void probe_pci_console(void)
1234{ 1234{
1235 u8 cap, common_cap = 0, device_cap = 0; 1235 u8 cap, common_cap = 0, device_cap = 0;
1236 /* Offset within BAR0 */
1237 u32 device_offset;
1238 u32 device_len; 1236 u32 device_len;
1239 1237
1240 /* Avoid recursive printk into here. */ 1238 /* Avoid recursive printk into here. */
@@ -1258,21 +1256,16 @@ static void probe_pci_console(void)
1258 u8 vndr = read_pci_config_byte(0, 1, 0, cap); 1256 u8 vndr = read_pci_config_byte(0, 1, 0, cap);
1259 if (vndr == PCI_CAP_ID_VNDR) { 1257 if (vndr == PCI_CAP_ID_VNDR) {
1260 u8 type, bar; 1258 u8 type, bar;
1261 u32 offset;
1262 1259
1263 type = read_pci_config_byte(0, 1, 0, 1260 type = read_pci_config_byte(0, 1, 0,
1264 cap + offsetof(struct virtio_pci_cap, cfg_type)); 1261 cap + offsetof(struct virtio_pci_cap, cfg_type));
1265 bar = read_pci_config_byte(0, 1, 0, 1262 bar = read_pci_config_byte(0, 1, 0,
1266 cap + offsetof(struct virtio_pci_cap, bar)); 1263 cap + offsetof(struct virtio_pci_cap, bar));
1267 offset = read_pci_config(0, 1, 0,
1268 cap + offsetof(struct virtio_pci_cap, offset));
1269 1264
1270 switch (type) { 1265 switch (type) {
1271 case VIRTIO_PCI_CAP_DEVICE_CFG: 1266 case VIRTIO_PCI_CAP_DEVICE_CFG:
1272 if (bar == 0) { 1267 if (bar == 0)
1273 device_cap = cap; 1268 device_cap = cap;
1274 device_offset = offset;
1275 }
1276 break; 1269 break;
1277 case VIRTIO_PCI_CAP_PCI_CFG: 1270 case VIRTIO_PCI_CAP_PCI_CFG:
1278 console_access_cap = cap; 1271 console_access_cap = cap;
@@ -1302,7 +1295,8 @@ static void probe_pci_console(void)
1302 return; 1295 return;
1303 } 1296 }
1304 1297
1305 console_cfg_offset = device_offset; 1298 console_cfg_offset = read_pci_config(0, 1, 0,
1299 device_cap + offsetof(struct virtio_pci_cap, offset));
1306 printk(KERN_INFO "lguest: Console via virtio-pci emerg_wr\n"); 1300 printk(KERN_INFO "lguest: Console via virtio-pci emerg_wr\n");
1307} 1301}
1308 1302