Skip to contentSkip to conversation

x86: Moving probe_roms_32 to probe_roms

RFC PATCH In review Dan Williams 2 participants 5 messages Feb 22, 2011 – Feb 25, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 x86: Moving probe_roms_32 to probe_roms

From: Dave Jiang <[email protected]>

Moving the probe_roms_32 code to probe_roms and make available for all x86. The end result adapter roms data structure is made available read-only to drivers. The Intel isci SAS driver needs to scan the OROM memory in order to pull OEM parameters from the OROM.

---

We could just export adapter_rom_resources directly and be done with it, but it seemed reasonable to have a compile time catch for drivers that try to modify the resources, and that drivers should not assume the number of available adapter roms.

--
Dan

 arch/x86/include/asm/probe_roms.h |    7 +++++++
 arch/x86/include/asm/setup.h      |    3 ++-
 arch/x86/kernel/Makefile          |    2 +-
 arch/x86/kernel/head32.c          |    1 -
 arch/x86/kernel/probe_roms.c      |   13 +++++++++++++
 arch/x86/kernel/x86_init.c        |    2 +-
 6 files changed, 24 insertions(+), 4 deletions(-)
 create mode 100644 arch/x86/include/asm/probe_roms.h
 rename arch/x86/kernel/{probe_roms_32.c => probe_roms.c} (93%)
arch/x86/include/asm/probe_roms.h new file +7 -0
new file mode 100644
index 0000000..3e9ea6d
@@ -0,0 +1,7 @@
+#ifndef _PROBE_ROMS_H_
+#define _PROBE_ROMS_H_
+
+extern const struct resource *x86_adapter_rom_resources(void);
+extern int x86_num_adapter_roms(void);
+
+#endif
arch/x86/include/asm/setup.h +2 -1
index ef292c7..52edb6d 100644
@@ -93,10 +93,11 @@ void *extend_brk(size_t size, size_t align);
 			: : "i" (sz));					\
 	}
 
+extern void probe_roms(void);
+
 #ifdef __i386__
 
 void __init i386_start_kernel(void);
-extern void probe_roms(void);
 
 #else
 void __init x86_64_start_kernel(char *real_mode);
arch/x86/kernel/Makefile +1 -1
index fedf32a..f31ae9b 100644
@@ -36,7 +36,7 @@ obj-y			+= traps.o irq.o irq_$(BITS).o dumpstack_$(BITS).o
 obj-y			+= time.o ioport.o ldt.o dumpstack.o
 obj-y			+= setup.o x86_init.o i8259.o irqinit.o
 obj-$(CONFIG_X86_VISWS)	+= visws_quirks.o
-obj-$(CONFIG_X86_32)	+= probe_roms_32.o
+obj-y			+= probe_roms.o
 obj-$(CONFIG_X86_32)	+= sys_i386_32.o i386_ksyms_32.o
 obj-$(CONFIG_X86_64)	+= sys_x86_64.o x8664_ksyms_64.o
 obj-$(CONFIG_X86_64)	+= syscall_64.o vsyscall_64.o
arch/x86/kernel/head32.c +0 -1
index 784360c..e7605ed 100644
@@ -21,7 +21,6 @@
 static void __init i386_default_early_setup(void)
 {
 	/* Initialize 32bit specific setup functions */
-	x86_init.resources.probe_roms = probe_roms;
 	x86_init.resources.reserve_resources = i386_reserve_resources;
 	x86_init.mpparse.setup_ioapic_ids = setup_ioapic_ids_from_mpc;
 
arch/x86/kernel/probe_roms.c renamed from arch/x86/kernel/probe_roms_32.c +13 -0
similarity index 93%
rename from arch/x86/kernel/probe_roms_32.c
rename to arch/x86/kernel/probe_roms.c
index 071e7fe..5dcf53f 100644
@@ -73,6 +73,19 @@ static struct resource video_rom_resource = {
 	.flags	= IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
 };
 
+/* grant modules read only access to the adapter rom table */
+const struct resource *x86_adapter_rom_resources(void)
+{
+	return adapter_rom_resources;
+}
+EXPORT_SYMBOL(x86_adapter_rom_resources);
+
+int x86_num_adapter_roms(void)
+{
+	return ARRAY_SIZE(adapter_rom_resources);
+}
+EXPORT_SYMBOL(x86_num_adapter_roms);
+
 #define ROMSIGNATURE 0xaa55
 
 static int __init romsignature(const unsigned char *rom)
arch/x86/kernel/x86_init.c +1 -1
index cd6da6b..1bc104f 100644
@@ -33,7 +33,7 @@ void iommu_shutdown_noop(void) { }
 struct x86_init_ops x86_init __initdata = {
 
 	.resources = {
-		.probe_roms		= x86_init_noop,
+		.probe_roms		= probe_roms,
 		.reserve_resources	= reserve_standard_io_resources,
 		.memory_setup		= default_machine_specific_memory_setup,
 	},
#1 lore raw
Quoted 7 lines · Dan Williams

From: Dave Jiang <[email protected]>

Moving the probe_roms_32 code to probe_roms and make available for all x86. The end result adapter roms data structure is made available read-only to drivers. The Intel isci SAS driver needs to scan the OROM memory in order to pull OEM parameters from the OROM.

Quoted 9 lines

---

We could just export adapter_rom_resources directly and be done with it, but it seemed reasonable to have a compile time catch for drivers that try to modify the resources, and that drivers should not assume the number of available adapter roms.

Ping? The "RFC" was probably not needed, just wanted clarification if the interface for modules to retrieve the adapter rom data was in good taste.

Thanks,
Dan

#2 lore raw
Quoted 18 lines · Dan Williams
Quoted 7 lines · Dan Williams

From: Dave Jiang <[email protected]>

Moving the probe_roms_32 code to probe_roms and make available for all x86. The end result adapter roms data structure is made available read-only to drivers. The Intel isci SAS driver needs to scan the OROM memory in order to pull OEM parameters from the OROM.

Quoted 9 lines

---

We could just export adapter_rom_resources directly and be done with it, but it seemed reasonable to have a compile time catch for drivers that try to modify the resources, and that drivers should not assume the number of available adapter roms.

Quoted 4 lines

Ping? The "RFC" was probably not needed, just wanted clarification if the interface for modules to retrieve the adapter rom data was in good taste.

Rather than exporting the array -- which is functionally what you're doing -- I would prefer if the actual probing code can be generalized and put into probe_roms.c. Extra bonus if it can be unified with the existing probing code.

-hpa

#3 lore raw
Quoted 24 lines · H. Peter Anvin
Quoted 18 lines · Dan Williams
Quoted 7 lines · Dan Williams

From: Dave Jiang <[email protected]>

Moving the probe_roms_32 code to probe_roms and make available for all x86. The end result adapter roms data structure is made available read-only to drivers. The Intel isci SAS driver needs to scan the OROM memory in order to pull OEM parameters from the OROM.

Quoted 9 lines

---

We could just export adapter_rom_resources directly and be done with it, but it seemed reasonable to have a compile time catch for drivers that try to modify the resources, and that drivers should not assume the number of available adapter roms.

Quoted 4 lines

Ping? The "RFC" was probably not needed, just wanted clarification if the interface for modules to retrieve the adapter rom data was in good taste.

Quoted 4 lines

Rather than exporting the array -- which is functionally what you're doing -- I would prefer if the actual probing code can be generalized and put into probe_roms.c. Extra bonus if it can be unified with the existing probing code.

Ok, we will still end up searching for a magic string at a random location in the rom image, but how about the following generic interface for at least getting us to our correct option-rom. pci_map_biosrom() returns the option-rom that matches the given pci device or matches any device id that the device's driver supports.

arch/x86/include/asm/probe_roms.h +5 -2
index 3e9ea6d..f113ad2 100644
@@ -1,7 +1,10 @@
 #ifndef _PROBE_ROMS_H_
 #define _PROBE_ROMS_H_
 
-extern const struct resource *x86_adapter_rom_resources(void);
-extern int x86_num_adapter_roms(void);
+struct pci_dev;
+
+extern void __iomem *pci_map_biosrom(struct pci_dev *pdev);
+extern void pci_unmap_biosrom(void __iomem *rom);
+extern size_t pci_biosrom_size(struct pci_dev *pdev); 
 
 #endif
arch/x86/kernel/probe_roms.c +95 -7

113 lines not on this page · raw message

#4 lore raw

On 02/25/2011 02:13 AM, Williams, Dan J wrote:
[..]

arch/x86/kernel/probe_roms.c static struct resource video_rom_resource = { · line 141

Quoted 2 lines
arch/x86/kernel/probe_roms.c +2 -0
+		if (probe_kernel_address(rom + offset + 0x8, list) != 0 &&
+		    probe_kernel_address(rom + offset + 0xc, rev) != 0 &&

These should be "== 0", but you get the idea...

arch/x86/kernel/probe_roms.c static struct resource video_rom_resource = { · line 147

Quoted 6 lines
arch/x86/kernel/probe_roms.c +6 -0
+		    rev>= 3&&  list&&
+		    probe_list(pdev, vendor, rom + offset + list)) {
+			oprom = res;
+			break;
+		}
+	}

--
Dan