x86: Change pci option rom area MTRR setting to cacheable
PATCH 1/10 x86: Change pci option rom area MTRR setting to cacheable
In reply to a message not in the archiveTurn on cache on the pci option rom area to improve the performance.
---
arch/x86/cpu/cpu.c | 27 ++++++++++++++++++++------- arch/x86/include/asm/mtrr.h | 2 ++ 2 files changed, 22 insertions(+), 7 deletions(-)
arch/x86/cpu/cpu.c +20 -7
@@ -363,13 +363,26 @@ int x86_cpu_init_f(void) mtrr_cap =native_read_msr (MTRR_CAP_MSR );if (mtrr_cap &MTRR_CAP_FIX ) {/* Mark the VGA RAM area as uncacheable */ -native_write_msr (MTRR_FIX_16K_A0000_MSR ,0 ,0 ); - -/* Mark the PCI ROM area as uncacheable */ -native_write_msr (MTRR_FIX_4K_C0000_MSR ,0 ,0 ); -native_write_msr (MTRR_FIX_4K_C8000_MSR ,0 ,0 ); -native_write_msr (MTRR_FIX_4K_D0000_MSR ,0 ,0 ); -native_write_msr (MTRR_FIX_4K_D8000_MSR ,0 ,0 ); +native_write_msr (MTRR_FIX_16K_A0000_MSR , +MTRR_FIX_TYPE (MTRR_TYPE_UNCACHEABLE ), +MTRR_FIX_TYPE (MTRR_TYPE_UNCACHEABLE )); + +/* +* Mark the PCI ROM area as cacheable to improve ROM +* execution performance. +*/ +native_write_msr (MTRR_FIX_4K_C0000_MSR , +MTRR_FIX_TYPE (MTRR_TYPE_WRBACK ), +MTRR_FIX_TYPE (MTRR_TYPE_WRBACK )); +native_write_msr (MTRR_FIX_4K_C8000_MSR , +MTRR_FIX_TYPE (MTRR_TYPE_WRBACK ), +MTRR_FIX_TYPE (MTRR_TYPE_WRBACK )); +native_write_msr (MTRR_FIX_4K_D0000_MSR , +MTRR_FIX_TYPE (MTRR_TYPE_WRBACK ), +MTRR_FIX_TYPE (MTRR_TYPE_WRBACK )); +native_write_msr (MTRR_FIX_4K_D8000_MSR , +MTRR_FIX_TYPE (MTRR_TYPE_WRBACK ), +MTRR_FIX_TYPE (MTRR_TYPE_WRBACK ));/* Enable the fixed range MTRRs */ msr_setbits_64 (MTRR_DEF_TYPE_MSR ,MTRR_DEF_TYPE_FIX_EN );
arch/x86/include/asm/mtrr.h +2 -0
@@ -55,6 +55,8 @@#define MTRR_FIX_4K_F0000_MSR 0x26e#define MTRR_FIX_4K_F8000_MSR 0x26f +#define MTRR_FIX_TYPE (t) ((t << 24) | (t << 16) | (t << 8) | t) +#if !defined(__ASSEMBLER__)/**
Signature · 1 line
1.8.2.1
PATCH 2/10 x86: Enable DM RTC support for all x86 boards
In reply to a message not in the archiveAdd a RTC node in the device tree to enable DM RTC support.
---
arch/x86/dts/chromebook_link.dts | 1 + arch/x86/dts/chromebox_panther.dts | 1 + arch/x86/dts/galileo.dts | 1 + arch/x86/dts/minnowmax.dts | 1 + arch/x86/dts/qemu-x86_i440fx.dts | 1 + arch/x86/dts/qemu-x86_q35.dts | 1 + configs/chromebook_link_defconfig | 1 + configs/chromebox_panther_defconfig | 1 + configs/galileo_defconfig | 1 + configs/minnowmax_defconfig | 1 + configs/qemu-x86_defconfig | 1 + 11 files changed, 11 insertions(+)
arch/x86/dts/chromebook_link.dts +1 -0
@@ -2,6 +2,7 @@ /include/ "skeleton.dtsi" /include/ "serial.dtsi" +/include/ "rtc.dtsi" / { model = "Google Link";
arch/x86/dts/chromebox_panther.dts +1 -0
@@ -2,6 +2,7 @@ /include/ "skeleton.dtsi" /include/ "serial.dtsi" +/include/ "rtc.dtsi" / { model = "Google Panther";
arch/x86/dts/galileo.dts +1 -0
@@ -10,6 +10,7 @@ #include <dt-bindings/interrupt-router/intel-irq.h> /include/ "skeleton.dtsi" +/include/ "rtc.dtsi" / { model = "Intel Galileo";
arch/x86/dts/minnowmax.dts +1 -0
@@ -10,6 +10,7 @@ /include/ "skeleton.dtsi" /include/ "serial.dtsi" +/include/ "rtc.dtsi" / { model = "Intel Minnowboard Max";
arch/x86/dts/qemu-x86_i440fx.dts +1 -0
@@ -10,6 +10,7 @@ /include/ "skeleton.dtsi" /include/ "serial.dtsi" +/include/ "rtc.dtsi" / { model = "QEMU x86 (I440FX)";
arch/x86/dts/qemu-x86_q35.dts +1 -0
@@ -20,6 +20,7 @@ /include/ "skeleton.dtsi" /include/ "serial.dtsi" +/include/ "rtc.dtsi" / { model = "QEMU x86 (Q35)";
configs/chromebook_link_defconfig +1 -0
@@ -17,5 +17,6 @@ CONFIG_SPI_FLASH=y CONFIG_VIDEO_VESA=y CONFIG_FRAMEBUFFER_SET_VESA_MODE=y CONFIG_FRAMEBUFFER_VESA_MODE_11A=y +CONFIG_DM_RTC=y CONFIG_USE_PRIVATE_LIBGCC=y CONFIG_SYS_VSNPRINTF=y
configs/chromebox_panther_defconfig +1 -0
@@ -17,5 +17,6 @@ CONFIG_SPI_FLASH=y CONFIG_VIDEO_VESA=y CONFIG_FRAMEBUFFER_SET_VESA_MODE=y CONFIG_FRAMEBUFFER_VESA_MODE_11A=y +CONFIG_DM_RTC=y CONFIG_USE_PRIVATE_LIBGCC=y CONFIG_SYS_VSNPRINTF=y
configs/galileo_defconfig +1 -0
@@ -15,5 +15,6 @@ CONFIG_SPL_DISABLE_OF_CONTROL=y CONFIG_SPI_FLASH=y CONFIG_NETDEVICES=y CONFIG_ETH_DESIGNWARE=y +CONFIG_DM_RTC=y CONFIG_USE_PRIVATE_LIBGCC=y CONFIG_SYS_VSNPRINTF=y
configs/minnowmax_defconfig +1 -0
@@ -21,5 +21,6 @@ CONFIG_SPI_FLASH=y CONFIG_VIDEO_VESA=y CONFIG_FRAMEBUFFER_SET_VESA_MODE=y CONFIG_FRAMEBUFFER_VESA_MODE_11A=y +CONFIG_DM_RTC=y CONFIG_USE_PRIVATE_LIBGCC=y CONFIG_SYS_VSNPRINTF=y
configs/qemu-x86_defconfig +1 -0
@@ -13,5 +13,6 @@ CONFIG_SPI_FLASH=y CONFIG_VIDEO_VESA=y CONFIG_FRAMEBUFFER_SET_VESA_MODE=y CONFIG_FRAMEBUFFER_VESA_MODE_111=y +CONFIG_DM_RTC=y CONFIG_USE_PRIVATE_LIBGCC=y CONFIG_SYS_VSNPRINTF=y
Signature · 1 line
1.8.2.1
PATCH 3/10 x86: pci: Assign pci irqs to all functions
In reply to a message not in the archiveWe need walk through all functions within a PCI device and assign their IRQs accordingly.
---
arch/x86/cpu/pci.c | 27 +++++++++++++++++---------- arch/x86/include/asm/pci.h | 3 +-- arch/x86/lib/pirq_routing.c | 3 +-- 3 files changed, 19 insertions(+), 14 deletions(-)
arch/x86/cpu/pci.c +17 -10
@@ -152,23 +152,30 @@ int pci_x86_write_config(struct udevice *bus, pci_dev_t bdf, uint offset,return 0 ; } -void pci_assign_irqs (int bus,int device,int func,u8 irq[4 ]) +void pci_assign_irqs (int bus,int device,u8 irq[4 ]) {pci_dev_t bdf; +int func; +u16 vendor;u8 pin, line; - bdf =PCI_BDF (bus, device, func); +for (func =0 ; func <8 ; func++) { + bdf =PCI_BDF (bus, device, func); + vendor =x86_pci_read_config16 (bdf,PCI_VENDOR_ID ); +if (vendor ==0xffff || vendor ==0x0000 ) +continue ; - pin =x86_pci_read_config8 (bdf,PCI_INTERRUPT_PIN ); + pin =x86_pci_read_config8 (bdf,PCI_INTERRUPT_PIN ); -/* PCI spec says all values except 1..4 are reserved */ -if ((pin <1 ) || (pin >4 )) -return ; +/* PCI spec says all values except 1..4 are reserved */ +if ((pin <1 ) || (pin >4 )) +continue ; - line = irq[pin -1 ]; + line = irq[pin -1 ]; -debug ("Assigning IRQ %d to PCI device %d.%x.%d (INT%c)\n" , - line, bus, device, func,'A' + pin -1 ); +debug ("Assigning IRQ %d to PCI device %d.%x.%d (INT%c)\n" , + line, bus, device, func,'A' + pin -1 ); -x86_pci_write_config8 (bdf,PCI_INTERRUPT_LINE , line); +x86_pci_write_config8 (bdf,PCI_INTERRUPT_LINE , line); + } }
arch/x86/include/asm/pci.h +1 -2
@@ -72,11 +72,10 @@ int pci_x86_write_config(struct udevice *bus, pci_dev_t bdf, uint offset,* * @bus: PCI bus number * @device: PCI device number -* @func: PCI function number * @irq: An array of IRQ numbers that are assigned to INTA through * INTD of this PCI device. */ -void pci_assign_irqs (int bus,int device,int func,u8 irq[4 ]); +void pci_assign_irqs (int bus,int device,u8 irq[4 ]);#endif /* __ASSEMBLY__ */
arch/x86/lib/pirq_routing.c +1 -2
@@ -98,8 +98,7 @@ void pirq_route_irqs(struct irq_info *irq, int num) }/* Bus, device, slots IRQs for {A,B,C,D} */ -pci_assign_irqs (irq->bus, irq->devfn >>3 , irq->devfn &7 , - irq_slot); +pci_assign_irqs (irq->bus, irq->devfn >>3 , irq_slot); irq++; }
Signature · 1 line
1.8.2.1
PATCH 4/10 x86: pci: Do not assign irq 0 to pci device
In reply to a message not in the archiveIRQ 0 is reserved and should not be assigned to pci device.
---
arch/x86/cpu/pci.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/cpu/pci.c +2 -0
@@ -172,6 +172,8 @@ void pci_assign_irqs(int bus, int device, u8 irq[4])continue ; line = irq[pin -1 ]; +if (!line) +continue ;debug ("Assigning IRQ %d to PCI device %d.%x.%d (INT%c)\n" , line, bus, device, func,'A' + pin -1 );
Signature · 1 line
1.8.2.1
PATCH 5/10 x86: mpspec: Allow platform to determine how PIRQ is connected to I/O APIC
In reply to a message not in the archiveCurrently during writing MP table I/O interrupt assignment entry, we assume the PIRQ is directly mapped to I/O APIC INTPIN#16-23, which however is not always the case on some platforms.
---
arch/x86/include/asm/mpspec.h | 17 +++++++++++++++++ arch/x86/lib/mpspec.c | 23 ++++++++++++++++------- 2 files changed, 33 insertions(+), 7 deletions(-)
arch/x86/include/asm/mpspec.h +17 -0
@@ -432,6 +432,23 @@ void mp_write_compat_address_space(struct mp_config_table *mc, int busid,u32 mptable_finalize (struct mp_config_table *mc);/** +* mp_determine_pci_dstirq() - Determine PCI device's int pin on the I/O APIC +* +* This determines a PCI device's interrupt pin number on the I/O APIC. +* +* This can be implemented by platform codes to handle specifal cases, which +* do not conform to the normal chipset/board design where PIRQ[A-H] are mapped +* directly to I/O APIC INTPIN#16-23. +* +* @bus: bus number of the pci device +* @dev: device number of the pci device +* @func: function number of the pci device +* @pirq: PIRQ number the PCI device's interrupt pin is routed to +* @return: interrupt pin number on the I/O APIC +*/ +int mp_determine_pci_dstirq (int bus,int dev,int func,int pirq); + +/** * write_mp_table() - Write MP table * * This writes MP table at a given address.
arch/x86/lib/mpspec.c +16 -7
@@ -269,6 +269,12 @@ static bool check_dup_entry(struct mpc_config_intsrc *intsrc_base,return (i == entry_num) ? false : true; } +__weak int mp_determine_pci_dstirq (int bus,int dev,int func,int pirq) +{ +/* PIRQ[A-H] are connected to I/O APIC INTPIN#16-23 */ +return pirq +16 ; +} +static int mptable_add_intsrc (struct mp_config_table *mc,int bus_isa,int apicid) {
@@ -304,24 +310,27 @@ static int mptable_add_intsrc(struct mp_config_table *mc,for (i =0 ; i < count; i++) {struct pirq_routing pr; +int bus, dev, func; +int dstirq; pr.bdf =fdt_addr_to_cpu (cell[0 ]); pr.pin =fdt_addr_to_cpu (cell[1 ]); pr.pirq =fdt_addr_to_cpu (cell[2 ]); + bus =PCI_BUS (pr.bdf); + dev =PCI_DEV (pr.bdf); + func =PCI_FUNC (pr.bdf);if (check_dup_entry (intsrc_base, intsrc_entries, -PCI_BUS (pr.bdf),PCI_DEV (pr.bdf), pr.pin)) { + bus, dev, pr.pin)) {debug ("found entry for bus %d device %d INT%c, skipping\n" , -PCI_BUS (pr.bdf),PCI_DEV (pr.bdf), -'A' + pr.pin -1 ); + bus, dev,'A' + pr.pin -1 ); cell +=sizeof (struct pirq_routing ) /sizeof (u32);continue ; } -/* PIRQ[A-H] are always connected to I/O APIC INTPIN#16-23 */ -mp_write_pci_intsrc (mc,MP_INT ,PCI_BUS (pr.bdf), -PCI_DEV (pr.bdf), pr.pin, apicid, - pr.pirq +16 ); + dstirq =mp_determine_pci_dstirq (bus, dev, func, pr.pirq); +mp_write_pci_intsrc (mc,MP_INT , bus, dev, pr.pin, + apicid, dstirq); intsrc_entries++; cell +=sizeof (struct pirq_routing ) /sizeof (u32); }
Signature · 1 line
1.8.2.1
PATCH 6/10 x86: mpspec: Move writing ISA interrupt entry after PCI
In reply to a message not in the archiveOn some platforms the I/O APIC interrupt pin#0-15 may be connected to platform pci devices' interrupt pin. In such cases the legacy ISA IRQ is not available so we should not write ISA interrupt entry if it is already occupied.
---
arch/x86/lib/mpspec.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)
arch/x86/lib/mpspec.c +21 -5
@@ -21,6 +21,8 @@DECLARE_GLOBAL_DATA_PTR ; +static bool isa_irq_occupied[16 ]; +struct mp_config_table *mp_write_floating_table (struct mp_floating_table *mf) {u32 mc;
@@ -243,10 +245,18 @@ static void mptable_add_isa_interrupts(struct mp_config_table *mc, int bus_isa,MP_IRQ_TRIGGER_EDGE |MP_IRQ_POLARITY_HIGH , bus_isa, 0, apicid, 2); -for (i =3 ; i <16 ; i++) +for (i =3 ; i <16 ; i++) { +/* +* Do not write ISA interrupt entry if it is already occupied +* by the platform devices. +*/ +if (isa_irq_occupied[i]) +continue ; +mp_write_intsrc (mc,MP_INT ,MP_IRQ_TRIGGER_EDGE |MP_IRQ_POLARITY_HIGH , bus_isa, i, apicid, i); + } }/*
@@ -286,10 +296,6 @@ static int mptable_add_intsrc(struct mp_config_table *mc,const u32 *cell;int i; -/* Legacy Interrupts */ -debug ("Writing ISA IRQs\n" ); -mptable_add_isa_interrupts (mc, bus_isa, apicid,0 ); -/* Get I/O interrupt information from device tree */ node =fdtdec_next_compatible (blob,0 ,COMPAT_INTEL_IRQ_ROUTER );if (node <0 ) {
@@ -329,12 +335,22 @@ static int mptable_add_intsrc(struct mp_config_table *mc, } dstirq =mp_determine_pci_dstirq (bus, dev, func, pr.pirq); +/* +* For PIRQ which is connected to I/O APIC interrupt pin#0-15, +* mark it as occupied so that we can skip it later. +*/ +if (dstirq <16 ) + isa_irq_occupied[dstirq] = true;mp_write_pci_intsrc (mc,MP_INT , bus, dev, pr.pin, apicid, dstirq); intsrc_entries++; cell +=sizeof (struct pirq_routing ) /sizeof (u32); } +/* Legacy Interrupts */ +debug ("Writing ISA IRQs\n" ); +mptable_add_isa_interrupts (mc, bus_isa, apicid,0 ); +return 0 ; }
Signature · 1 line
1.8.2.1
PATCH 7/10 x86: qemu: Enable I/O APIC chip select on PIIX3
In reply to a message not in the archiveThe PIIX3 chipset does not integrate an I/O APIC, instead it supports connecting to an external I/O APIC which needs to be enabled manually.
---
arch/x86/cpu/qemu/pci.c | 7 ++++++- arch/x86/include/asm/arch-qemu/qemu.h | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-)
arch/x86/cpu/qemu/pci.c +6 -1
@@ -50,7 +50,7 @@ void board_pci_setup_hose(struct pci_controller *hose)int board_pci_post_scan (struct pci_controller *hose) {int ret =0 ; -u16 device; +u16 device, xbcs;int pam, i;pci_dev_t vga;ulong start;
@@ -82,6 +82,11 @@ int board_pci_post_scan(struct pci_controller *hose)*/ x86_pci_write_config16 (PIIX_IDE ,IDE0_TIM ,IDE_DECODE_EN );x86_pci_write_config16 (PIIX_IDE ,IDE1_TIM ,IDE_DECODE_EN ); + +/* Enable I/O APIC */ + xbcs =x86_pci_read_config16 (PIIX_ISA ,XBCS ); + xbcs |=APIC_EN ; +x86_pci_write_config16 (PIIX_ISA ,XBCS , xbcs); }/*
arch/x86/include/asm/arch-qemu/qemu.h +5 -1
@@ -13,10 +13,14 @@#define PAM_NUM 7#define PAM_RW 0x33 +/* X-Bus Chip Select Register */ +#define XBCS 0x4e +#define APIC_EN (1 << 8) +/* IDE Timing Register */ #define IDE0_TIM 0x40#define IDE1_TIM 0x42 -#define IDE_DECODE_EN 0x8000 +#define IDE_DECODE_EN (1 << 15)/* I/O Ports */ #define CMOS_ADDR_PORT 0x70
Signature · 1 line
1.8.2.1
PATCH 8/10 x86: qemu: Add MP initialization
In reply to a message not in the archiveThe existing MP initialization process works on QEMU multicore, except that we need increase delay time for BSP to wait APs to show up online. Use a Kconfig option to control the delay time factor to the normal one.
---
arch/x86/cpu/mp_init.c | 4 ++++ arch/x86/cpu/qemu/Kconfig | 11 +++++++++++ arch/x86/dts/qemu-x86_i440fx.dts | 20 ++++++++++++++++++++ arch/x86/dts/qemu-x86_q35.dts | 20 ++++++++++++++++++++ configs/qemu-x86_defconfig | 4 ++++ doc/README.x86 | 5 +++++ 6 files changed, 64 insertions(+)
arch/x86/cpu/mp_init.c +4 -0
@@ -75,6 +75,10 @@ static int wait_for_aps(atomic_t *val, int target, int total_delay,int timeout =0 ;int delayed =0 ; +#ifdef CONFIG_QEMU + total_delay *=CONFIG_MPINIT_DELAY_FACTOR ; +#endif +while (atomic_read (val) != target) {udelay (delay_step); delayed += delay_step;
arch/x86/cpu/qemu/Kconfig +11 -0
@@ -18,4 +18,15 @@ config SYS_CAR_SIZE hex default 0x10000 +config MPINIT_DELAY_FACTOR + int "QEMU multicore initialization delay factor" + depends on SMP + default 100 + help + During multicore initialization after BSP sends SIPI to wake up APs, + U-Boot needs to wait some time for AP to show up online. The delay + time is good for real hardware, but seems not enough for QEMU. The + value of this option will be used as the multiplier to the normal + delay time. + endif
arch/x86/dts/qemu-x86_i440fx.dts +20 -0
@@ -24,6 +24,26 @@ stdout-path = "/serial"; }; + cpus { + #address-cells = <1>; + #size-cells = <0>; + + cpu at 0 { + device_type = "cpu"; + compatible = "cpu-x86"; + reg = <0>; + intel,apic-id = <0>; + }; + + cpu at 1 { + device_type = "cpu"; + compatible = "cpu-x86"; + reg = <1>; + intel,apic-id = <1>; + }; + + }; + pci { compatible = "pci-x86"; #address-cells = <3>;
arch/x86/dts/qemu-x86_q35.dts +20 -0
@@ -35,6 +35,26 @@ stdout-path = "/serial"; }; + cpus { + #address-cells = <1>; + #size-cells = <0>; + + cpu at 0 { + device_type = "cpu"; + compatible = "cpu-x86"; + reg = <0>; + intel,apic-id = <0>; + }; + + cpu at 1 { + device_type = "cpu"; + compatible = "cpu-x86"; + reg = <1>; + intel,apic-id = <1>; + }; + + }; + pci { compatible = "pci-x86"; #address-cells = <3>;
configs/qemu-x86_defconfig +4 -0
@@ -1,6 +1,9 @@ CONFIG_X86=y CONFIG_DEFAULT_DEVICE_TREE="qemu-x86_i440fx" +CONFIG_SMP=y +CONFIG_MAX_CPUS=2 CONFIG_GENERATE_PIRQ_TABLE=y +CONFIG_CMD_CPU=y # CONFIG_CMD_IMLS is not set # CONFIG_CMD_FLASH is not set # CONFIG_CMD_SETEXPR is not set
@@ -9,6 +12,7 @@ CONFIG_BOOTSTAGE=y CONFIG_BOOTSTAGE_REPORT=y CONFIG_CMD_BOOTSTAGE=y CONFIG_OF_CONTROL=y +CONFIG_CPU=y CONFIG_SPI_FLASH=y CONFIG_VIDEO_VESA=y CONFIG_FRAMEBUFFER_SET_VESA_MODE=y
doc/README.x86 +5 -0
@@ -281,6 +281,11 @@ QEMU emulates a graphic card which U-Boot supports. Removing '-nographic' will show QEMU's VGA console window. Note this will disable QEMU's serial output. If you want to check both consoles, use '-serial stdio'. +Multicore is also supported by QEMU via '-smp n' where n is the number of cores +to instantiate. Currently the default U-Boot built for QEMU supports 2 cores. +In order to support more cores, you need add additional cpu nodes in the device +tree and change CONFIG_MAX_CPUS accordingly. + CPU Microcode ------------- Modern CPUs usually require a special bit stream called microcode [8] to be
Signature · 1 line
1.8.2.1
PATCH 9/10 x86: qemu: Enable writing MP table
In reply to a message not in the archiveEnable writing MP table for QEMU boads (i440fx and q35).
---
arch/x86/cpu/qemu/pci.c | 34 +++++++++++++++++++++++++++++++--- configs/qemu-x86_defconfig | 1 + 2 files changed, 32 insertions(+), 3 deletions(-)
arch/x86/cpu/qemu/pci.c +31 -3
@@ -13,6 +13,8 @@DECLARE_GLOBAL_DATA_PTR ; +static bool i440fx; +void board_pci_setup_hose (struct pci_controller *hose) { hose->first_busno =0 ;
@@ -61,7 +63,8 @@ int board_pci_post_scan(struct pci_controller *hose)* PCI device ID. */ device =x86_pci_read_config16 (PCI_BDF (0 ,0 ,0 ),PCI_DEVICE_ID ); - pam = (device ==PCI_DEVICE_ID_INTEL_82441 ) ?I440FX_PAM :Q35_PAM ; + i440fx = (device ==PCI_DEVICE_ID_INTEL_82441 ); + pam = i440fx ?I440FX_PAM :Q35_PAM ;/* * Initialize Programmable Attribute Map (PAM) Registers
@@ -71,7 +74,7 @@ int board_pci_post_scan(struct pci_controller *hose)for (i =0 ; i <PAM_NUM ; i++)x86_pci_write_config8 (PCI_BDF (0 ,0 ,0 ), pam + i,PAM_RW ); -if (device ==PCI_DEVICE_ID_INTEL_82441 ) { +if (i440fx) {/* * Enable legacy IDE I/O ports decode *
@@ -97,10 +100,35 @@ int board_pci_post_scan(struct pci_controller *hose)* board, it shows as device 2, while for Q35 and ICH9 chipset board, * it shows as device 1. */ - vga = (device ==PCI_DEVICE_ID_INTEL_82441 ) ?I440FX_VGA :Q35_VGA ; + vga = i440fx ?I440FX_VGA :Q35_VGA ; start =get_timer (0 ); ret =pci_run_vga_bios (vga,NULL ,PCI_ROM_USE_NATIVE );debug ("BIOS ran in %lums\n" ,get_timer (start));return ret; } + +#ifdef CONFIG_GENERATE_MP_TABLE +int mp_determine_pci_dstirq (int bus,int dev,int func,int pirq) +{ +u8 irq; + +if (i440fx) { +/* +* Not like most x86 platforms, the PIRQ[A-D] on PIIX3 are not +* connected to I/O APIC INTPIN#16-19. Instead they are routed +* to an irq number controled by the PIRQ routing register. +*/ + irq =x86_pci_read_config8 (PCI_BDF (bus, dev, func), +PCI_INTERRUPT_LINE ); + }else { +/* +* ICH9's PIRQ[A-H] are not consecutive numbers from 0 to 7. +* PIRQ[A-D] still maps to [0-3] but PIRQ[E-H] maps to [8-11]. +*/ + irq = pirq <8 ? pirq +16 : pirq +12 ; + } + +return irq; +} +#endif
configs/qemu-x86_defconfig +1 -0
@@ -3,6 +3,7 @@ CONFIG_DEFAULT_DEVICE_TREE="qemu-x86_i440fx" CONFIG_SMP=y CONFIG_MAX_CPUS=2 CONFIG_GENERATE_PIRQ_TABLE=y +CONFIG_GENERATE_MP_TABLE=y CONFIG_CMD_CPU=y # CONFIG_CMD_IMLS is not set # CONFIG_CMD_FLASH is not set
Signature · 1 line
1.8.2.1
PATCH 10/10 x86: qemu: Turn on PCIe ECAM address range decoding on Q35
In reply to a message not in the archiveTurn on PCIe ECAM address range decoding on Q35.
---
arch/x86/cpu/qemu/pci.c | 4 ++++ arch/x86/include/asm/arch-qemu/qemu.h | 4 ++++ 2 files changed, 8 insertions(+)
arch/x86/cpu/qemu/pci.c +4 -0
@@ -90,6 +90,10 @@ int board_pci_post_scan(struct pci_controller *hose) xbcs =x86_pci_read_config16 (PIIX_ISA ,XBCS ); xbcs |=APIC_EN ;x86_pci_write_config16 (PIIX_ISA ,XBCS , xbcs); + }else { +/* Configure PCIe ECAM base address */ +x86_pci_write_config32 (PCI_BDF (0 ,0 ,0 ),PCIEX_BAR , +CONFIG_PCIE_ECAM_BASE |BAR_EN ); }/*
arch/x86/include/asm/arch-qemu/qemu.h +4 -0
@@ -22,6 +22,10 @@#define IDE1_TIM 0x42#define IDE_DECODE_EN (1 << 15) +/* PCIe ECAM Base Address Register */ +#define PCIEX_BAR 0x60 +#define BAR_EN (1 << 0) +/* I/O Ports */ #define CMOS_ADDR_PORT 0x70#define CMOS_DATA_PORT 0x71
Signature · 1 line
1.8.2.1
PATCH 1/10 x86: Change pci option rom area MTRR setting to cacheable
In reply to Bin MengQuoted 8 lines · Bin Meng
Turn on cache on the pci option rom area to improve the performance.
Signed-off-by Bin Meng <[email protected]>---
arch/x86/cpu/cpu.c | 27 ++++++++++++++++++++------- arch/x86/include/asm/mtrr.h | 2 ++ 2 files changed, 22 insertions(+), 7 deletions(-)
PATCH 2/10 x86: Enable DM RTC support for all x86 boards
In reply to Bin MengQuoted 5 lines · Bin Meng
Add a RTC node in the device tree to enable DM RTC support.
Signed-off-by Bin Meng <[email protected]>---
Quoted 12 lines
arch/x86/dts/chromebook_link.dts | 1 + arch/x86/dts/chromebox_panther.dts | 1 + arch/x86/dts/galileo.dts | 1 + arch/x86/dts/minnowmax.dts | 1 + arch/x86/dts/qemu-x86_i440fx.dts | 1 + arch/x86/dts/qemu-x86_q35.dts | 1 + configs/chromebook_link_defconfig | 1 + configs/chromebox_panther_defconfig | 1 + configs/galileo_defconfig | 1 + configs/minnowmax_defconfig | 1 + configs/qemu-x86_defconfig | 1 + 11 files changed, 11 insertions(+)
PATCH 3/10 x86: pci: Assign pci irqs to all functions
In reply to Bin MengQuoted 10 lines · Bin Meng
We need walk through all functions within a PCI device and assign their IRQs accordingly.
Signed-off-by Bin Meng <[email protected]>---
arch/x86/cpu/pci.c | 27 +++++++++++++++++---------- arch/x86/include/asm/pci.h | 3 +-- arch/x86/lib/pirq_routing.c | 3 +-- 3 files changed, 19 insertions(+), 14 deletions(-)
PATCH 4/10 x86: pci: Do not assign irq 0 to pci device
In reply to Bin MengQuoted 7 lines · Bin Meng
IRQ 0 is reserved and should not be assigned to pci device.
Signed-off-by Bin Meng <[email protected]>---
arch/x86/cpu/pci.c | 2 ++ 1 file changed, 2 insertions(+)
PATCH 6/10 x86: mpspec: Move writing ISA interrupt entry after PCI
In reply to Bin MengQuoted 10 lines · Bin Meng
On some platforms the I/O APIC interrupt pin#0-15 may be connected to platform pci devices' interrupt pin. In such cases the legacy ISA IRQ is not available so we should not write ISA interrupt entry if it is already occupied.
Signed-off-by Bin Meng <[email protected]>---
arch/x86/lib/mpspec.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)
PATCH 7/10 x86: qemu: Enable I/O APIC chip select on PIIX3
In reply to Bin MengQuoted 9 lines · Bin Meng
The PIIX3 chipset does not integrate an I/O APIC, instead it supports connecting to an external I/O APIC which needs to be enabled manually.
Signed-off-by Bin Meng <[email protected]>---
arch/x86/cpu/qemu/pci.c | 7 ++++++- arch/x86/include/asm/arch-qemu/qemu.h | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-)
PATCH 8/10 x86: qemu: Add MP initialization
In reply to Bin MengHi Bin,
Quoted 8 lines · Bin Meng
The existing MP initialization process works on QEMU multicore, except that we need increase delay time for BSP to wait APs to show up online. Use a
Kconfigoption to control the delay time factor to the normal one.Signed-off-by Bin Meng <[email protected]>---
Quoted 7 lines
arch/x86/cpu/mp_init.c | 4 ++++ arch/x86/cpu/qemu/Kconfig | 11 +++++++++++ arch/x86/dts/qemu-x86_i440fx.dts | 20 ++++++++++++++++++++ arch/x86/dts/qemu-x86_q35.dts | 20 ++++++++++++++++++++ configs/qemu-x86_defconfig | 4 ++++ doc/README.x86 | 5 +++++ 6 files changed, 64 insertions(+)
Why does qemu need a longer delay? Can we put this in as a property of the /cpus node instead?
Regards,
Simon
PATCH 10/10 x86: qemu: Turn on PCIe ECAM address range decoding on Q35
In reply to Bin MengQuoted 9 lines · Bin Meng
Turn on PCIe ECAM address range decoding on Q35.
Signed-off-by Bin Meng <[email protected]>---
arch/x86/cpu/qemu/pci.c | 4 ++++ arch/x86/include/asm/arch-qemu/qemu.h | 4 ++++ 2 files changed, 8 insertions(+)
PATCH 5/10 x86: mpspec: Allow platform to determine how PIRQ is connected to I/O APIC
In reply to Bin MengHi Bin,
Quoted 44 lines · Bin Meng
Currently during writing MP table I/O interrupt assignment entry, we assume the PIRQ is directly mapped to I/O APIC INTPIN#16-23, which however is not always the case on some platforms.
Signed-off-by Bin Meng <[email protected]>---
arch/x86/include/asm/mpspec.h | 17 +++++++++++++++++ arch/x86/lib/mpspec.c | 23 ++++++++++++++++------- 2 files changed, 33 insertions(+), 7 deletions(-)arch/x86/include/asm/mpspec.h +17
-0@@ -432,6 +432,23 @@ void mp_write_compat_address_space(struct mp_config_table *mc, int busid,u32 mptable_finalize (struct mp_config_table *mc);/** +* mp_determine_pci_dstirq() - Determine PCI device's int pin on the I/O APIC +* +* This determines a PCI device's interrupt pin number on the I/O APIC. +* +* This can be implemented by platform codes to handle specifal cases, which +* do not conform to the normal chipset/board design where PIRQ[A-H] are mapped +* directly to I/O APIC INTPIN#16-23. +* +* @bus: bus number of the pci device +* @dev: device number of the pci device +* @func: function number of the pci device +* @pirq: PIRQ number the PCI device's interrupt pin is routed to +* @return: interrupt pin number on the I/O APIC +*/ +int mp_determine_pci_dstirq (int bus,int dev,int func,int pirq); + +/** * write_mp_table() - Write MP table * * This writes MP table at a given address. arch/x86/lib/mpspec.c +0
-0
arch/x86/lib/mpspec.c static bool check_dup_entry(struct mpc_config_intsrc *intsrc_base, · line 272
Quoted 4 lines
arch/x86/lib/mpspec.c +1
-0@@ -269,6 +269,12 @@ static bool check_dup_entry(struct mpc_config_intsrc *intsrc_base,return (i == entry_num) ? false : true; } +__weak int mp_determine_pci_dstirq (int bus,int dev,int func,int pirq)
I'd like to avoid using weak functions. Can we use device tree or driver model instead?
In principle we should be able to build all of the code in and boot an image on multiple boards. These sorts of things make it harder to understand and follow the code IMO.
Quoted 44 lines
arch/x86/lib/mpspec.c +15
-8+{ +/* PIRQ[A-H] are connected to I/O APIC INTPIN#16-23 */ +return pirq +16 ; +} +static int mptable_add_intsrc (struct mp_config_table *mc,int bus_isa,int apicid) {@@ -304,24 +310,27 @@ static int mptable_add_intsrc(struct mp_config_table *mc,for (i =0 ; i < count; i++) {struct pirq_routing pr; +int bus, dev, func; +int dstirq; pr.bdf =fdt_addr_to_cpu (cell[0 ]); pr.pin =fdt_addr_to_cpu (cell[1 ]); pr.pirq =fdt_addr_to_cpu (cell[2 ]); + bus =PCI_BUS (pr.bdf); + dev =PCI_DEV (pr.bdf); + func =PCI_FUNC (pr.bdf);if (check_dup_entry (intsrc_base, intsrc_entries, -PCI_BUS (pr.bdf),PCI_DEV (pr.bdf), pr.pin)) { + bus, dev, pr.pin)) {debug ("found entry for bus %d device %d INT%c, skipping\n" , -PCI_BUS (pr.bdf),PCI_DEV (pr.bdf), -'A' + pr.pin -1 ); + bus, dev,'A' + pr.pin -1 ); cell +=sizeof (struct pirq_routing ) /sizeof (u32);continue ; } -/* PIRQ[A-H] are always connected to I/O APIC INTPIN#16-23 */ -mp_write_pci_intsrc (mc,MP_INT ,PCI_BUS (pr.bdf), -PCI_DEV (pr.bdf), pr.pin, apicid, - pr.pirq +16 ); + dstirq =mp_determine_pci_dstirq (bus, dev, func, pr.pirq); +mp_write_pci_intsrc (mc,MP_INT , bus, dev, pr.pin, + apicid, dstirq); intsrc_entries++; cell +=sizeof (struct pirq_routing ) /sizeof (u32); } --
Quoted 2 lines
1.8.2.1
Regards,
Simon
PATCH 8/10 x86: qemu: Add MP initialization
In reply to Simon GlassHi Simon,
Quoted 19 lines · Simon Glass
Hi Bin,
Quoted 8 lines · Bin Meng
The existing MP initialization process works on QEMU multicore, except that we need increase delay time for BSP to wait APs to show up online. Use a
Kconfigoption to control the delay time factor to the normal one.Signed-off-by Bin Meng <[email protected]>---
Quoted 7 lines
arch/x86/cpu/mp_init.c | 4 ++++ arch/x86/cpu/qemu/Kconfig | 11 +++++++++++ arch/x86/dts/qemu-x86_i440fx.dts | 20 ++++++++++++++++++++ arch/x86/dts/qemu-x86_q35.dts | 20 ++++++++++++++++++++ configs/qemu-x86_defconfig | 4 ++++ doc/README.x86 | 5 +++++ 6 files changed, 64 insertions(+)
Quoted 3 lines
Why does qemu need a longer delay? Can we put this in as a property of the /cpus node instead?
I have no idea. I suspect it is caused by QEMU's multicore simulation is not real paralleled. Yep, we can define a parameter in the /cpus node to control this.
Regards,
Bin
PATCH 5/10 x86: mpspec: Allow platform to determine how PIRQ is connected to I/O APIC
In reply to Simon GlassHi Simon,
Quoted 50 lines · Simon Glass
Hi Bin,
Quoted 47 lines · Bin Meng
Currently during writing MP table I/O interrupt assignment entry, we assume the PIRQ is directly mapped to I/O APIC INTPIN#16-23, which however is not always the case on some platforms.
Signed-off-by Bin Meng <[email protected]>---
arch/x86/include/asm/mpspec.h | 17 +++++++++++++++++ arch/x86/lib/mpspec.c | 23 ++++++++++++++++------- 2 files changed, 33 insertions(+), 7 deletions(-)arch/x86/include/asm/mpspec.h +17
-0@@ -432,6 +432,23 @@ void mp_write_compat_address_space(struct mp_config_table *mc, int busid,u32 mptable_finalize (struct mp_config_table *mc);/** +* mp_determine_pci_dstirq() - Determine PCI device's int pin on the I/O APIC +* +* This determines a PCI device's interrupt pin number on the I/O APIC. +* +* This can be implemented by platform codes to handle specifal cases, which +* do not conform to the normal chipset/board design where PIRQ[A-H] are mapped +* directly to I/O APIC INTPIN#16-23. +* +* @bus: bus number of the pci device +* @dev: device number of the pci device +* @func: function number of the pci device +* @pirq: PIRQ number the PCI device's interrupt pin is routed to +* @return: interrupt pin number on the I/O APIC +*/ +int mp_determine_pci_dstirq (int bus,int dev,int func,int pirq); + +/** * write_mp_table() - Write MP table * * This writes MP table at a given address. arch/x86/lib/mpspec.c +0
-0@@ -269,6 +269,12 @@ static bool check_dup_entry(struct mpc_config_intsrc *intsrc_base,return (i == entry_num) ? false : true; }
Quoted 5 lines
arch/x86/lib/mpspec.c static bool check_dup_entry(struct mpc_config_intsrc *intsrc_base, · line 272
Quoted 1 line
arch/x86/lib/mpspec.c +1
-0+__weak int mp_determine_pci_dstirq (int bus,int dev,int func,int pirq)I'd like to avoid using weak functions. Can we use device tree or driver model instead?
As you can see in this patch
http://patchwork.ozlabs.org/patch/495524/, that the return value of this function (dstirq) relies on the runtime value, so we cannot describe it in the device tree. As for driver model, I am not sure if if it suits. I will need think about it. If we do driver model, we might be able to consolidate PIRQ and MP table codes. Can we leave this to a possible future work?
Quoted 4 lines
In principle we should be able to build all of the code in and boot an image on multiple boards. These sorts of things make it harder to understand and follow the code IMO.
Yep, ideally although I don't know how practical for now :-)
[snip]
Regards,
Bin
PATCH 5/10 x86: mpspec: Allow platform to determine how PIRQ is connected to I/O APIC
Hi Bin,
Quoted 59 lines · Bin Meng
Hi Simon,
Quoted 50 lines · Simon Glass
Hi Bin,
Quoted 47 lines · Bin Meng
Currently during writing MP table I/O interrupt assignment entry, we assume the PIRQ is directly mapped to I/O APIC INTPIN#16-23, which however is not always the case on some platforms.
Signed-off-by Bin Meng <[email protected]>---
arch/x86/include/asm/mpspec.h | 17 +++++++++++++++++ arch/x86/lib/mpspec.c | 23 ++++++++++++++++------- 2 files changed, 33 insertions(+), 7 deletions(-)arch/x86/include/asm/mpspec.h +17
-0@@ -432,6 +432,23 @@ void mp_write_compat_address_space(struct mp_config_table *mc, int busid,u32 mptable_finalize (struct mp_config_table *mc);/** +* mp_determine_pci_dstirq() - Determine PCI device's int pin on the I/O APIC +* +* This determines a PCI device's interrupt pin number on the I/O APIC. +* +* This can be implemented by platform codes to handle specifal cases, which +* do not conform to the normal chipset/board design where PIRQ[A-H] are mapped +* directly to I/O APIC INTPIN#16-23. +* +* @bus: bus number of the pci device +* @dev: device number of the pci device +* @func: function number of the pci device +* @pirq: PIRQ number the PCI device's interrupt pin is routed to +* @return: interrupt pin number on the I/O APIC +*/ +int mp_determine_pci_dstirq (int bus,int dev,int func,int pirq); + +/** * write_mp_table() - Write MP table * * This writes MP table at a given address. arch/x86/lib/mpspec.c +0
-0@@ -269,6 +269,12 @@ static bool check_dup_entry(struct mpc_config_intsrc *intsrc_base,return (i == entry_num) ? false : true; }Quoted 5 lines
arch/x86/lib/mpspec.c static bool check_dup_entry(struct mpc_config_intsrc *intsrc_base, · line 272
Quoted 1 line
arch/x86/lib/mpspec.c +1
-0+__weak int mp_determine_pci_dstirq (int bus,int dev,int func,int pirq)I'd like to avoid using weak functions. Can we use device tree or driver model instead?
Quoted 7 lines
As you can see in this patch
http://patchwork.ozlabs.org/patch/495524/, that the return value of this function (dstirq) relies on the runtime value, so we cannot describe it in the device tree. As for driver model, I am not sure if if it suits. I will need think about it. If we do driver model, we might be able to consolidate PIRQ and MP table codes. Can we leave this to a possible future work?
OK. Please add a TODO for now.
Quoted 9 lines
Quoted 5 lines
In principle we should be able to build all of the code in and boot an image on multiple boards. These sorts of things make it harder to understand and follow the code IMO.
Yep, ideally although I don't know how practical for now :-)
[snip]
Well Rome wasn't built in a day. Let's get this in as is while you figure it out.
Regards,
Simon
PATCH 1/10 x86: Change pci option rom area MTRR setting to cacheable
In reply to Simon GlassQuoted 11 lines · Simon Glass
Quoted 8 lines · Bin Meng
Turn on cache on the pci option rom area to improve the performance.
Signed-off-by Bin Meng <[email protected]>---
arch/x86/cpu/cpu.c | 27 ++++++++++++++++++++------- arch/x86/include/asm/mtrr.h | 2 ++ 2 files changed, 22 insertions(+), 7 deletions(-)Acked-by Simon Glass <[email protected]>
Applied to u-boot-x86, thanks!
PATCH 2/10 x86: Enable DM RTC support for all x86 boards
In reply to Simon GlassQuoted 19 lines · Simon Glass
Quoted 5 lines · Bin Meng
Add a RTC node in the device tree to enable DM RTC support.
Signed-off-by Bin Meng <[email protected]>---
Quoted 12 lines
arch/x86/dts/chromebook_link.dts | 1 + arch/x86/dts/chromebox_panther.dts | 1 + arch/x86/dts/galileo.dts | 1 + arch/x86/dts/minnowmax.dts | 1 + arch/x86/dts/qemu-x86_i440fx.dts | 1 + arch/x86/dts/qemu-x86_q35.dts | 1 + configs/chromebook_link_defconfig | 1 + configs/chromebox_panther_defconfig | 1 + configs/galileo_defconfig | 1 + configs/minnowmax_defconfig | 1 + configs/qemu-x86_defconfig | 1 + 11 files changed, 11 insertions(+)
Quoted 1 line
Acked-by Simon Glass <[email protected]>
Applied to u-boot-x86, thanks!
PATCH 3/10 x86: pci: Assign pci irqs to all functions
In reply to Simon GlassQuoted 7 lines · Simon Glass
Quoted 6 lines · Bin Meng
We need walk through all functions within a PCI device and assign their IRQs accordingly.
Signed-off-by Bin Meng <[email protected]>---
Quoted 6 lines
Quoted 4 lines
arch/x86/cpu/pci.c | 27 +++++++++++++++++---------- arch/x86/include/asm/pci.h | 3 +-- arch/x86/lib/pirq_routing.c | 3 +-- 3 files changed, 19 insertions(+), 14 deletions(-)Acked-by Simon Glass <[email protected]>
Applied to u-boot-x86, thanks!
PATCH 4/10 x86: pci: Do not assign irq 0 to pci device
In reply to Simon GlassQuoted 10 lines · Simon Glass
Quoted 7 lines · Bin Meng
IRQ 0 is reserved and should not be assigned to pci device.
Signed-off-by Bin Meng <[email protected]>---
arch/x86/cpu/pci.c | 2 ++ 1 file changed, 2 insertions(+)Acked-by Simon Glass <[email protected]>
Applied to u-boot-x86, thanks!