x86: Add initial support for apollolake
Subsystems (16)
cover x86: Add initial support for apollolake
Apollolake is an Intel SoC generation aimed at relatively low-end embedded systems. It was released in 2016 but has become more popular recently with some embedded boards using it.
This series adds support for apollolake. As an example it adds an implementation of chromebook_coral (a large range of Chromebooks released in 2017).
The series provides only enough to boot to a prompt. It does not include display, storage, USB, etc. But it does include the major part of the plumbing.
Since this is the first time U-Boot has used FSP2 there is quite a bit of refactoring needed. Some of this is in previous series, but much of it is here.
Some further clean-up is needed with this series and it needs more documentation, but it is ready for review.
This series is available at u-boot-dm/coral-working
Simon Glass (126):
dm: core: Use U-Boot logging instead of pr_debug()
dm: core: Correct low cell in ofnode_read_pci_addr()
dm: core: Drop a few early returns
dm: core: Add documentation on how to debug driver model
dm: core: Don't include ofnode functions with of-platdata
dm: core: Correct bad cast in ofnode_get_addr_size_index()
dm: test: Fix running of multiple test from command line
dm: test: Don't fail when tests are skipped due to build
dm: core: Call ofdata_to_platdata() with of-platdata
dm: doc: Correct of-platdata CONFIG_IS_ENABLED() condition
dm: core: Correct the return value for uclass_find_first_device()
dm: core: Add device_foreach_child()
dm: test: Correct a stray backslash in dm_test_destroy()
fdt: Show the preprocessed .dts file on error
sandbox: spmi: Add ranges property for address translation
sandbox: mmc: Fix up MMC emulator for valgrind
sandbox: Rename PCI ID for swap_case to be more specific
sandbox: Add support for clrsetio_32() and friends
sandbox: swap_case: Use statics where possible
sandbox: pci: Drop the get_devfn() method
sandbox: net: Suppress the MAC-address warnings
sandbox: pci: Move pci_offset_to_barnum() to pci.h
sandbox: Add a -T flag to use the test device tree
sandbox: pci: Increase the memory space
sandbox: Allow use of real I/O with readl(), etc.
pci: sandbox: Move the emulators into their own node
pci: sandbox: Probe PCI emulation devices when used
pci: Show the result of binding a device
pci: Disable autoconfig in SPL
pci: Correct 'specifified' and 'Plese' typos
pci: Add more debug detail when resources are exhausted
pci: Show a message if PCI autoconfig fails
dm: pci: Add a function to read a PCI BAR
serial: ns16550: Add a PCI device/function field
binman: Allow verbose output with all commands
binman: Add a base implementation of Entry.ReadChildData()
binman: Handle reading data for end-at-4gb sections
binman: Take account of skip-at-start with image-header
log: Add log_nop() to avoid unused-variable warnings
cros_ec: Add MEC_EMI_BASE and size to the header file
iod: Enhance to support display of multiple values
arm: mxs: Correct CONFIG_SPL_NO_CPU_SUPPORT option
spl: Allow tiny printf() to be controlled in SPL and TPL
spl: Convert CONFIG_SPL_LIMIT to hex
spl: Add a size check for TPL
spl: Allow distinguishing between two phases in U-Boot
spl: Allow SPL/TPL to use of-platdata without libfdt
x86: Move acpi_s3.h to a common location
x86: pci: Drop the first parameter in pci_x86_r/w_config()
x86: timer: Reduce timer code size in TPL on Intel CPUs
x86: Use a common definition of MSR_IA32_PERF_CTL
x86: Add a common function to set CPU thermal target
x86: Use a common bus clock for Intel CPUs
x86: Add common functions for TDP and perf control
x86: Tidy up some duplicate MSR defines
x86: Add new common CPU functions for turbo/burst mode
dm: core: Drop fdtdec_get_pci_addr()
sandbox: pci: Create a new sandbox_pci_read_bar() function
x86: Allow the PCH and LPC uclasses to work with of-platdata
x86: timer: Set up the timer in timer_early_get_count()
x86: Refactor mtrr_commit() to allow for shared code
x86: Add a function to set variable MTRRs
x86: pci: Add a function to decode a PCI BDF
x86: cpu: Don't include the cpu driver in TPL
x86: Use mtrr_commit() with FSP2
x86: spl: Support init of a PUNIT
x86: Panic when SPL or TPL fail
x86: tpl: Add a fake PCI bus
sandbox: pci: Remember the device being emulated
x86: power: Add a PMC uclass
x86: sandbox: Add a PMC emulator and test
x86: power: Add a 'pmc' command
trace: Remove the const from write functions
pci: Add support for p2sb uclass
sandbox: Add PCI driver and test for p2sb
x86: Add a uclass for ITSS
sandbox: Add a test for ITSS
x86: Define the SPL image start
x86: Reduce mrccache record alignment size
x86: Add a function to find the size of an mrccache record
x86: Correct mrccache find_next_mrc_cache() calculation
x86: Adjust mrccache_get_region() to use livetree
x86: Add a new global_data member for the cache record
x86: Tidy up error handling in mrccache_save()
x86: Update mrccache to support multiple caches
x86: Add mrccache support for a 'variable' cache
x86: Move fsp_prepare_mrc_cache() to fsp1 directory
x86: Set the DRAM banks to reflect real location
x86: Set up the MTRR for SDRAM
x86: Update Kconfig options for FSP1
x86: Don't imply TPL_OF_LIBFDT
x86: Allow removal of standard PCH drivers
x86: Allow interrupt to happen once
x86: Add FSP2 base support
x86: Don't include the BIOS emulator in TPL
x86: Add an option to include a FIT
x86: Add support for newer CAR schemes
x86: Drop RESET_BASE
x86: Drop RESET_SEG_SIZE
x86: Disable microcode section for FSP2
x86: Use fsp command with FSP1
x86: Update .dtsi file for FSP2
x86: Add an option to control the position of U-Boot
x86: Add an option to control the position of SPL
x86: Reduce resetvec size
x86: Add an fdtmap and image-header
x86: Don't repeat microcode in U-Boot if not needed
x86: apollolake: Add basic IO addresses
x86: apollolake: Add PMC driver
x86: apollolake: Add UART driver
x86: apollolake: Add GPIO driver
x86: apollolake: Add defintions for the Intel Fast SPI interface
x86: apollolake: Add systemagent driver
x86: apollolake: Add hostbridge driver
x86: apollolake: Add ITSS driver
x86: apollolake: Add LPC driver
x86: apollolake: Add PCH driver
x86: apollolake: Add PUNIT driver
x86: apollolake: Add SPL loaders
x86: apollolake: Add a CPU driver
x86: apollolake: Add SPL/TPL init
x86: apollolake: Add P2SB driver
x86: apollolake: Add Kconfig and Makefile
x86: apollolake: Add FSP structures
x86: Add chromebook_coral
RFC: x86: coral: Add binary MRC data
Kconfig | 9 +-
Makefile | 20 +-
arch/Kconfig | 4 +-
arch/arm/Kconfig | 2 +-
arch/arm/cpu/arm926ejs/Makefile | 2 +-
arch/arm/mach-omap2/Kconfig | 6 +-
arch/arm/mach-rmobile/Kconfig | 2 +-
arch/arm/mach-rmobile/Kconfig.32 | 14 +-
arch/arm/mach-socfpga/Kconfig | 6 +-
arch/arm/mach-uniphier/pinctrl-glue.c | 4 +-
arch/sandbox/cpu/cpu.c | 51 ++
arch/sandbox/cpu/start.c | 25 +
arch/sandbox/cpu/state.c | 1 +
arch/sandbox/dts/sandbox.dtsi | 25 +-
arch/sandbox/dts/test.dts | 78 +-
arch/sandbox/include/asm/io.h | 69 +-
arch/sandbox/include/asm/state.h | 1 +
arch/sandbox/include/asm/test.h | 28 +-
arch/sandbox/lib/pci_io.c | 12 +-
arch/x86/Kconfig | 100 ++-
arch/x86/cpu/Makefile | 8 +-
arch/x86/cpu/apollolake/Kconfig | 68 ++
arch/x86/cpu/apollolake/Makefile | 21 +
arch/x86/cpu/apollolake/cpu.c | 51 ++
arch/x86/cpu/apollolake/cpu_spl.c | 272 +++++++
arch/x86/cpu/apollolake/gpio.c | 742 ++++++++++++++++++
arch/x86/cpu/apollolake/hostbridge.c | 127 +++
arch/x86/cpu/apollolake/itss.c | 129 +++
arch/x86/cpu/apollolake/lpc.c | 155 ++++
arch/x86/cpu/apollolake/p2sb.c | 167 ++++
arch/x86/cpu/apollolake/pch.c | 29 +
arch/x86/cpu/apollolake/pmc.c | 216 +++++
arch/x86/cpu/apollolake/punit.c | 121 +++
arch/x86/cpu/apollolake/spl.c | 122 +++
arch/x86/cpu/apollolake/systemagent.c | 19 +
arch/x86/cpu/apollolake/uart.c | 157 ++++
arch/x86/cpu/baytrail/acpi.c | 2 +-
arch/x86/cpu/baytrail/cpu.c | 6 +-
arch/x86/cpu/broadwell/cpu.c | 18 +-
arch/x86/cpu/broadwell/cpu_full.c | 41 +-
arch/x86/cpu/broadwell/sdram.c | 8 +-
arch/x86/cpu/config.mk | 2 -
arch/x86/cpu/cpu.c | 2 +-
arch/x86/cpu/intel_common/Kconfig | 18 +
arch/x86/cpu/intel_common/Makefile | 8 +
arch/x86/cpu/intel_common/car2.S | 490 ++++++++++++
arch/x86/cpu/intel_common/car2_uninit.S | 87 ++
arch/x86/cpu/intel_common/cpu.c | 104 ++-
arch/x86/cpu/intel_common/fast_spi.c | 3 +-
arch/x86/cpu/ivybridge/cpu.c | 3 +-
arch/x86/cpu/ivybridge/model_206ax.c | 52 +-
arch/x86/cpu/ivybridge/northbridge.c | 2 +-
arch/x86/cpu/ivybridge/sdram.c | 8 +-
arch/x86/cpu/mtrr.c | 57 +-
arch/x86/cpu/pci.c | 38 +-
arch/x86/cpu/quark/dram.c | 8 +-
arch/x86/cpu/resetvec.S | 3 -
arch/x86/cpu/turbo.c | 10 +-
arch/x86/cpu/u-boot-spl.lds | 5 +-
arch/x86/cpu/wakeup.S | 2 +-
arch/x86/dts/Makefile | 1 +
arch/x86/dts/chromebook_coral.dts | 298 +++++++
arch/x86/dts/u-boot.dtsi | 89 ++-
arch/x86/include/asm/arch-apollolake/cpu.h | 21 +
.../include/asm/arch-apollolake/fast_spi.h | 176 +++++
.../asm/arch-apollolake/fsp/fsp_configs.h | 13 +
.../asm/arch-apollolake/fsp/fsp_m_upd.h | 127 +++
.../include/asm/arch-apollolake/fsp/fsp_vpd.h | 11 +
arch/x86/include/asm/arch-apollolake/gpio.h | 156 ++++
.../include/asm/arch-apollolake/gpio_apl.h | 491 ++++++++++++
.../include/asm/arch-apollolake/gpio_defs.h | 398 ++++++++++
arch/x86/include/asm/arch-apollolake/iomap.h | 28 +
arch/x86/include/asm/arch-apollolake/itss.h | 43 +
arch/x86/include/asm/arch-apollolake/lpc.h | 61 ++
arch/x86/include/asm/arch-apollolake/pch.h | 9 +
arch/x86/include/asm/arch-apollolake/pm.h | 19 +
.../include/asm/arch-apollolake/systemagent.h | 31 +
arch/x86/include/asm/arch-apollolake/uart.h | 17 +
arch/x86/include/asm/arch-broadwell/cpu.h | 3 -
arch/x86/include/asm/arch-broadwell/pch.h | 3 -
.../include/asm/arch-ivybridge/model_206ax.h | 5 +-
arch/x86/include/asm/cpu.h | 1 +
arch/x86/include/asm/cpu_common.h | 83 +-
arch/x86/include/asm/fsp/fsp_support.h | 7 -
arch/x86/include/asm/fsp2/fsp_api.h | 38 +
arch/x86/include/asm/fsp2/fsp_internal.h | 16 +
arch/x86/include/asm/global_data.h | 21 +-
arch/x86/include/asm/mrccache.h | 14 +-
arch/x86/include/asm/msr-index.h | 106 +--
arch/x86/include/asm/mtrr.h | 12 +
arch/x86/include/asm/pci.h | 37 +-
arch/x86/lib/Makefile | 2 +
arch/x86/lib/acpi_s3.c | 2 +-
arch/x86/lib/coreboot_table.c | 2 +-
arch/x86/lib/fsp/fsp_common.c | 22 +-
arch/x86/lib/fsp/fsp_dram.c | 35 +-
arch/x86/lib/fsp1/fsp_common.c | 22 +-
arch/x86/lib/fsp1/fsp_dram.c | 8 +-
arch/x86/lib/fsp2/Makefile | 7 +
arch/x86/lib/fsp2/fsp_dram.c | 73 ++
arch/x86/lib/fsp2/fsp_meminit.c | 344 ++++++++
arch/x86/lib/fsp2/fsp_support.c | 109 +++
arch/x86/lib/init_helpers.c | 22 +-
arch/x86/lib/lpc-uclass.c | 2 +
arch/x86/lib/mrccache.c | 186 +++--
arch/x86/lib/spl.c | 42 +-
arch/x86/lib/tpl.c | 27 +-
board/google/Kconfig | 15 +
board/google/chromebook_coral/Kconfig | 43 +
board/google/chromebook_coral/MAINTAINERS | 6 +
board/google/chromebook_coral/Makefile | 5 +
board/google/chromebook_coral/coral.c | 18 +
board/google/chromebook_coral/rw-mrc-cache | Bin 0 -> 65536 bytes
.../google/chromebook_coral/rw-var-mrc-cache | Bin 0 -> 4096 bytes
cmd/Kconfig | 8 +
cmd/Makefile | 1 +
cmd/io.c | 84 +-
cmd/pmc.c | 81 ++
cmd/x86/Makefile | 2 +-
common/iotrace.c | 6 +-
common/spl/Kconfig | 12 +-
common/xyzModem.c | 2 +-
configs/am335x_pdu001_defconfig | 2 +-
configs/chromebook_coral_defconfig | 95 +++
configs/chromebook_samus_tpl_defconfig | 1 +
configs/evb-rk3288_defconfig | 2 +-
configs/ls1043ardb_nand_SECURE_BOOT_defconfig | 2 +-
configs/ls1043ardb_nand_defconfig | 2 +-
.../ls1043ardb_sdcard_SECURE_BOOT_defconfig | 2 +-
configs/ls1043ardb_sdcard_defconfig | 2 +-
configs/sandbox_defconfig | 2 +
configs/sandbox_spl_defconfig | 3 +-
configs/tinker-rk3288_defconfig | 2 +-
doc/arch/sandbox.rst | 9 +
doc/board/google/chromebook_coral.rst | 25 +
doc/driver-model/debugging.rst | 62 ++
doc/driver-model/of-plat.rst | 2 +-
doc/driver-model/pci-info.rst | 25 +-
drivers/Makefile | 2 +
drivers/block/blk-uclass.c | 4 +-
drivers/core/Makefile | 4 +-
drivers/core/device.c | 3 +-
drivers/core/fdtaddr.c | 30 +
drivers/core/lists.c | 20 +-
drivers/core/ofnode.c | 9 +-
drivers/core/read.c | 11 +
drivers/core/uclass.c | 16 +-
drivers/gpio/gpio-uclass.c | 4 +-
drivers/gpio/pm8916_gpio.c | 12 +-
drivers/misc/Kconfig | 42 +
drivers/misc/Makefile | 7 +-
drivers/misc/itss-uclass.c | 34 +
drivers/misc/itss_sandbox.c | 44 ++
drivers/misc/p2sb-uclass.c | 199 +++++
drivers/misc/p2sb_emul.c | 272 +++++++
drivers/misc/p2sb_sandbox.c | 44 ++
drivers/misc/sandbox_adder.c | 60 ++
drivers/misc/swap_case.c | 48 +-
drivers/mmc/mmc.c | 2 +-
drivers/mmc/sandbox_mmc.c | 4 +
drivers/mtd/spi/sf-uclass.c | 2 +-
drivers/nvme/nvme.h | 4 +-
drivers/pch/Kconfig | 18 +
drivers/pch/Makefile | 4 +-
drivers/pch/pch-uclass.c | 2 +
drivers/pci/pci-emul-uclass.c | 74 +-
drivers/pci/pci-uclass.c | 5 +-
drivers/pci/pci_auto.c | 12 +-
drivers/pci/pci_auto_common.c | 3 +-
drivers/pci/pci_rom.c | 2 +-
drivers/pci/pci_sandbox.c | 1 +
drivers/pci/pci_x86.c | 16 +-
drivers/power/Kconfig | 2 +
drivers/power/power_mgr/Kconfig | 34 +
drivers/power/power_mgr/Makefile | 6 +
drivers/power/power_mgr/pmc_emul.c | 246 ++++++
drivers/power/power_mgr/power-mgr-uclass.c | 242 ++++++
drivers/power/power_mgr/sandbox.c | 97 +++
drivers/serial/ns16550.c | 31 +-
drivers/serial/sandbox.c | 2 +
drivers/sysreset/sysreset_x86.c | 2 +-
drivers/timer/Kconfig | 29 +-
drivers/timer/tsc_timer.c | 9 +-
{arch/x86/include/asm => include}/acpi_s3.h | 0
include/configs/chromebook_coral.h | 29 +
include/configs/mxs.h | 2 +-
include/dm/device.h | 9 +
include/dm/fdtaddr.h | 8 +
include/dm/read.h | 28 +-
include/dm/uclass-id.h | 4 +
include/dm/uclass-internal.h | 4 +-
include/ec_commands.h | 4 +
include/fdtdec.h | 17 -
include/iotrace.h | 13 +-
include/itss.h | 56 ++
include/log.h | 33 +-
include/ns16550.h | 4 +
include/p2sb.h | 127 +++
include/pci.h | 33 +-
include/power/power_mgr.h | 177 +++++
include/spl.h | 16 +-
lib/Kconfig | 24 +-
lib/Makefile | 2 +-
lib/fdtdec.c | 54 --
net/eth-uclass.c | 34 +-
scripts/Makefile.lib | 4 +-
scripts/config_whitelist.txt | 1 -
test/dm/Makefile | 3 +
test/dm/core.c | 3 +-
test/dm/itss.c | 29 +
test/dm/p2sb.c | 28 +
test/dm/pci.c | 51 +-
test/dm/pmc.c | 33 +
test/dm/test-main.c | 16 +-
tools/binman/control.py | 36 +-
tools/binman/entry.py | 18 +
tools/binman/etype/image_header.py | 1 +
tools/binman/etype/section.py | 16 +-
tools/binman/image.py | 2 +
219 files changed, 9447 insertions(+), 787 deletions(-)
create mode 100644 arch/x86/cpu/apollolake/Kconfig
create mode 100644 arch/x86/cpu/apollolake/Makefile
create mode 100644 arch/x86/cpu/apollolake/cpu.c
create mode 100644 arch/x86/cpu/apollolake/cpu_spl.c
create mode 100644 arch/x86/cpu/apollolake/gpio.c
create mode 100644 arch/x86/cpu/apollolake/hostbridge.c
create mode 100644 arch/x86/cpu/apollolake/itss.c
create mode 100644 arch/x86/cpu/apollolake/lpc.c
create mode 100644 arch/x86/cpu/apollolake/p2sb.c
create mode 100644 arch/x86/cpu/apollolake/pch.c
create mode 100644 arch/x86/cpu/apollolake/pmc.c
create mode 100644 arch/x86/cpu/apollolake/punit.c
create mode 100644 arch/x86/cpu/apollolake/spl.c
create mode 100644 arch/x86/cpu/apollolake/systemagent.c
create mode 100644 arch/x86/cpu/apollolake/uart.c
create mode 100644 arch/x86/cpu/intel_common/Kconfig
create mode 100644 arch/x86/cpu/intel_common/car2.S
create mode 100644 arch/x86/cpu/intel_common/car2_uninit.S
create mode 100644 arch/x86/dts/chromebook_coral.dts
create mode 100644 arch/x86/include/asm/arch-apollolake/cpu.h
create mode 100644 arch/x86/include/asm/arch-apollolake/fast_spi.h
create mode 100644 arch/x86/include/asm/arch-apollolake/fsp/fsp_configs.h
create mode 100644 arch/x86/include/asm/arch-apollolake/fsp/fsp_m_upd.h
create mode 100644 arch/x86/include/asm/arch-apollolake/fsp/fsp_vpd.h
create mode 100644 arch/x86/include/asm/arch-apollolake/gpio.h
create mode 100644 arch/x86/include/asm/arch-apollolake/gpio_apl.h
create mode 100644 arch/x86/include/asm/arch-apollolake/gpio_defs.h
create mode 100644 arch/x86/include/asm/arch-apollolake/iomap.h
create mode 100644 arch/x86/include/asm/arch-apollolake/itss.h
create mode 100644 arch/x86/include/asm/arch-apollolake/lpc.h
create mode 100644 arch/x86/include/asm/arch-apollolake/pch.h
create mode 100644 arch/x86/include/asm/arch-apollolake/pm.h
create mode 100644 arch/x86/include/asm/arch-apollolake/systemagent.h
create mode 100644 arch/x86/include/asm/arch-apollolake/uart.h
create mode 100644 arch/x86/include/asm/fsp2/fsp_api.h
create mode 100644 arch/x86/include/asm/fsp2/fsp_internal.h
create mode 100644 arch/x86/lib/fsp2/Makefile
create mode 100644 arch/x86/lib/fsp2/fsp_dram.c
create mode 100644 arch/x86/lib/fsp2/fsp_meminit.c
create mode 100644 arch/x86/lib/fsp2/fsp_support.c
create mode 100644 board/google/chromebook_coral/Kconfig
create mode 100644 board/google/chromebook_coral/MAINTAINERS
create mode 100644 board/google/chromebook_coral/Makefile
create mode 100644 board/google/chromebook_coral/coral.c
create mode 100644 board/google/chromebook_coral/rw-mrc-cache
create mode 100644 board/google/chromebook_coral/rw-var-mrc-cache
create mode 100644 cmd/pmc.c
create mode 100644 configs/chromebook_coral_defconfig
create mode 100644 doc/board/google/chromebook_coral.rst
create mode 100644 doc/driver-model/debugging.rst
create mode 100644 drivers/misc/itss-uclass.c
create mode 100644 drivers/misc/itss_sandbox.c
create mode 100644 drivers/misc/p2sb-uclass.c
create mode 100644 drivers/misc/p2sb_emul.c
create mode 100644 drivers/misc/p2sb_sandbox.c
create mode 100644 drivers/misc/sandbox_adder.c
create mode 100644 drivers/power/power_mgr/Kconfig
create mode 100644 drivers/power/power_mgr/Makefile
create mode 100644 drivers/power/power_mgr/pmc_emul.c
create mode 100644 drivers/power/power_mgr/power-mgr-uclass.c
create mode 100644 drivers/power/power_mgr/sandbox.c
rename {arch/x86/include/asm => include}/acpi_s3.h (100%)
create mode 100644 include/configs/chromebook_coral.h
create mode 100644 include/itss.h
create mode 100644 include/p2sb.h
create mode 100644 include/power/power_mgr.h
create mode 100644 test/dm/itss.c
create mode 100644 test/dm/p2sb.c
create mode 100644 test/dm/pmc.cSignature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 1/126 dm: core: Use U-Boot logging instead of pr_debug()
The pr_debug() functions do not response to setting the log level and in fact have their own separate log level. Use U-Boot logging instead.
Perhaps we should make these options redirect to log_debug(), etc.?
---
drivers/core/lists.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
drivers/core/lists.c +12 -8
@@ -6,6 +6,8 @@* Marek Vasut <[email protected]> */ +#define LOG_CATEGORY LOGC_DM +#include <common.h> #include <errno.h> #include <dm/device.h>
@@ -139,13 +141,13 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,if (devp) *devp =NULL ; name =ofnode_get_name (node); -pr_debug ("bind node %s\n" , name); +log_debug ("bind node %s\n" , name); compat_list =ofnode_get_property (node,"compatible" , &compat_length);if (!compat_list) {if (compat_length == -FDT_ERR_NOTFOUND ) { -pr_debug ("Device '%s' has no compatible string\n" , - name); +log_debug ("Device '%s' has no compatible string\n" , + name);return 0 ; }
@@ -160,8 +162,8 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,*/ for (i =0 ; i < compat_length; i +=strlen (compat) +1 ) { compat = compat_list + i; -pr_debug (" - attempt to match compatible string '%s'\n" , - compat); +log_debug (" - attempt to match compatible string '%s'\n" , + compat);for (entry = driver; entry != driver + n_ents; entry++) { ret = driver_check_compatible(entry->of_match, &id,
@@ -178,11 +180,13 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,return 0 ; } -pr_debug (" - found match at '%s'\n" , entry->name); +log_debug (" - found match at '%s': '%s' matches '%s'\n" , + entry->name, entry->of_match->compatible, + id->compatible); ret =device_bind_with_driver_data (parent, entry, name, id->data, node, &dev);if (ret == -ENODEV ) { -pr_debug ("Driver '%s' refuses to bind\n" , entry->name); +log_debug ("Driver '%s' refuses to bind\n" , entry->name);continue ; }if (ret) {
@@ -198,7 +202,7 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp, }if (!found && !result && ret != -ENODEV ) -pr_debug ("No match for node '%s'\n" , name); +log_debug ("No match for node '%s'\n" , name);return result; }
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 1/126 dm: core: Use U-Boot logging instead of pr_debug()
Quoted 4 lines · Simon Glass
The
pr_debug()functions do not response to setting the log level and in fact have their own separate log level. Use U-Boot logging instead.
Quoted 8 lines
Perhaps we should make these options redirect to
log_debug(), etc.?Signed-off-by Simon Glass <[email protected]>---
drivers/core/lists.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
PATCH 1/126 dm: core: Use U-Boot logging instead of pr_debug()
Quoted 8 lines · Bin Meng
Quoted 6 lines · Simon Glass
The
pr_debug()functions do not response to setting the log level and in fact have their own separate log level. Use U-Boot logging instead.Perhaps we should make these options redirect to
log_debug(), etc.?
Quoted 8 lines
Quoted 6 lines
Signed-off-by Simon Glass <[email protected]>---
drivers/core/lists.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)Reviewed-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 2/126 dm: core: Correct low cell in ofnode_read_pci_addr()
In reply to Simon GlassThis reads the low cell of the PCI address from the wrong cell. Fix it. Also fix the function that this code came from.
---
I can't work out why the existing code is correct, but I suppose it might be for some obscure reason that needs a comment.
The original patch is here: http://patchwork.ozlabs.org/patch/525853/
drivers/core/ofnode.c | 2 +- lib/fdtdec.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/core/ofnode.c +1 -1
@@ -617,7 +617,7 @@ int ofnode_read_pci_addr(ofnode node, enum fdt_pci_space type,if ((fdt32_to_cpu (*cell) & type) == type) { addr->phys_hi =fdt32_to_cpu (cell[0 ]); addr->phys_mid =fdt32_to_cpu (cell[1 ]); - addr->phys_lo =fdt32_to_cpu (cell[1 ]); + addr->phys_lo =fdt32_to_cpu (cell[2 ]);break ; }
lib/fdtdec.c +1 -1
@@ -217,7 +217,7 @@ int fdtdec_get_pci_addr(const void *blob, int node, enum fdt_pci_space type,if ((fdt32_to_cpu (*cell) & type) == type) { addr->phys_hi =fdt32_to_cpu (cell[0 ]); addr->phys_mid =fdt32_to_cpu (cell[1 ]); - addr->phys_lo =fdt32_to_cpu (cell[1 ]); + addr->phys_lo =fdt32_to_cpu (cell[2 ]);break ; }
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 2/126 dm: core: Correct low cell in ofnode_read_pci_addr()
Quoted 11 lines · Simon Glass
This reads the low cell of the PCI address from the wrong cell. Fix it. Also fix the function that this code came from.
Fixes 9e51204527 (dm: core: Add operations on device tree references)Fixes 4ea5243a3a (fdt: fix fdtdec_get_pci_addr() for CONFIG_PHYS_64BIT)Signed-off-by Simon Glass <[email protected]>---
I can't work out why the existing code is correct, but I suppose it might be for some obscure reason that needs a comment.The original patch is here: http://patchwork.ozlabs.org/patch/525853/
This makes sense. I am not sure how the original code worked; I can only assume the mid/low values were always both set to 0, or unused, or something?
PATCH 2/126 dm: core: Correct low cell in ofnode_read_pci_addr()
In reply to Simon GlassQuoted 11 lines · Simon Glass
This reads the low cell of the PCI address from the wrong cell. Fix it. Also fix the function that this code came from.
Fixes 9e51204527 (dm: core: Add operations on device tree references)Fixes 4ea5243a3a (fdt: fix fdtdec_get_pci_addr() for CONFIG_PHYS_64BIT)Signed-off-by Simon Glass <[email protected]>---
I can't work out why the existing code is correct, but I suppose it might be for some obscure reason that needs a comment.
Quoted 6 lines
The original patch is here: http://patchwork.ozlabs.org/patch/525853/
drivers/core/ofnode.c | 2 +- lib/fdtdec.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
I think this should go in v2019.10.
Tom, I will prepare a PR soon.
Regards,
Bin
PATCH 2/126 dm: core: Correct low cell in ofnode_read_pci_addr()
Quoted 20 lines · Bin Meng
Quoted 11 lines · Simon Glass
This reads the low cell of the PCI address from the wrong cell. Fix it. Also fix the function that this code came from.
Fixes 9e51204527 (dm: core: Add operations on device tree references)Fixes 4ea5243a3a (fdt: fix fdtdec_get_pci_addr() for CONFIG_PHYS_64BIT)Signed-off-by Simon Glass <[email protected]>---
I can't work out why the existing code is correct, but I suppose it might be for some obscure reason that needs a comment.Quoted 6 lines
The original patch is here: http://patchwork.ozlabs.org/patch/525853/
drivers/core/ofnode.c | 2 +- lib/fdtdec.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Quoted 5 lines
Reviewed-by Bin Meng <[email protected]>I think this should go in v2019.10.
Tom, I will prepare a PR soon.
applied to u-boot-x86, thanks!
PATCH 3/126 dm: core: Drop a few early returns
In reply to Simon GlassTwo functions in this file return early for no good reason. Adjust the code to match the standard DM style of returning 0 at the end of the function on success.
Oddly enough this save 12 bytes of code size on ARM.
---
drivers/core/uclass.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/core/uclass.c +10 -4
@@ -714,8 +714,11 @@ int uclass_pre_probe_device(struct udevice *dev)if (!dev->parent)return 0 ; uc_drv = dev->parent->uclass->uc_drv; -if (uc_drv->child_pre_probe) -return uc_drv->child_pre_probe (dev); +if (uc_drv->child_pre_probe) { + ret = uc_drv->child_pre_probe (dev); +if (ret) +return ret; + }return 0 ; }
@@ -735,8 +738,11 @@ int uclass_post_probe_device(struct udevice *dev) } uc_drv = dev->uclass->uc_drv; -if (uc_drv->post_probe) -return uc_drv->post_probe (dev); +if (uc_drv->post_probe) { + ret = uc_drv->post_probe (dev); +if (ret) +return ret; + }return 0 ; }
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 3/126 dm: core: Drop a few early returns
Quoted 5 lines · Simon Glass
Two functions in this file return early for no good reason. Adjust the code to match the standard DM style of returning 0 at the end of the function on success.
Quoted 8 lines
Oddly enough this save 12 bytes of code size on ARM.
Signed-off-by Simon Glass <[email protected]>---
drivers/core/uclass.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
PATCH 3/126 dm: core: Drop a few early returns
Quoted 9 lines · Bin Meng
Quoted 7 lines · Simon Glass
Two functions in this file return early for no good reason. Adjust the code to match the standard DM style of returning 0 at the end of the function on success.
Oddly enough this save 12 bytes of code size on ARM.
Quoted 8 lines
Quoted 6 lines
Signed-off-by Simon Glass <[email protected]>---
drivers/core/uclass.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)Reviewed-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 4/126 dm: core: Add documentation on how to debug driver model
In reply to Simon GlassSometimes devices don't appear and it can be confusing. Add a few notes to help with this situation.
---
doc/driver-model/debugging.rst | 62 ++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 doc/driver-model/debugging.rst
doc/driver-model/debugging.rst new file +62 -0
@@ -0,0 +1,62 @@ +.. SPDX-License-Identifier: GPL-2.0+ +.. sectionauthor:: Simon Glass <[email protected]> + +Debugging driver model +====================== + +This document aims to provide help when you cannot work out why driver model is +not doing what you expect. + + +Useful techniques in general +---------------------------- + +Here are some useful debugging features generally. + + - If you are writing a new feature, consider doing it in sandbox instead of + on your board. Sandbox has no limits, allows each debugging (e.g. gdb) and + you can writing emulators for most common devices. + - Put '#define DEBUG' at the top of a file, to activate all the debug() and + log_debug() statements in that file. + - Where logging is used, change the logging level, e.g. in SPL with + CONFIG_SPL_LOG_MAX_LEVEL=7 (which is LOGL_DEBUG) and + CONFIG_LOG_DEFAULT_LEVEL=7 + - Where logging of return values is implemented with log_msg_ret(), set + CONFIG_LOG_ERROR_RETURN=y to see exactly where the error is happening + - Make sure you have a debug UART enabled - see CONFIG_DEBUG_UART. With this + you can get serial output (printf(), etc.) before the serial driver is + running. + - Use a JTAG emulator to set breakpoints and single-step through code + +Not that most of these increase code/data size somewhat when enabled. + + +Failure to locate a device +-------------------------- + +Let's say you have uclass_first_device_err() and it is not finding anything. + +If it is returning an error, then that gives you a clue. Look up linux/errno.h +to see errors. Common ones are: + + - -ENOMEM which indicates that memory is short. If it happens in SPL or + before relocation in U-Boot, check CONFIG_SPL_SYS_MALLOC_F_LEN and + CONFIG_SYS_MALLOC_F_LEN as they may need to be larger. Add '#define DEBUG' + at the very top of malloc_simple.c to get an idea of where your memory is + going. + - -EINVAL which typically indicates that something was missing or wrong in + the device tree node. Check that everything is correct and look at the + ofdata_to_platdata() method in the driver. + +If there is no error, you should check if the device is actually bound. Call +dm_dump_all() just before you locate the device to make sure it exists. + +If it does not exist, check your device tree compatible strings match up with +what the driver expects (in the struct udevice_id array). + +If you are using of-platdata (e.g. CONFIG_SPL_OF_PLATDATA), check that the +driver name is the same as the first compatible string in the device tree (with +invalid-variable characters converted to underscore). + +If you are really stuck, #define DEBUG at the top of lists.c should show you +what is going on.
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 4/126 dm: core: Add documentation on how to debug driver model
Quoted 8 lines · Simon Glass
Sometimes devices don't appear and it can be confusing. Add a few notes to help with this situation.
Signed-off-by Simon Glass <[email protected]>---
doc/driver-model/debugging.rst | 62 ++++++++++++++++++++++++++++++++++
missed updating index.rst to include this doc.
I can fix this when applying.
Quoted 16 lines
1 file changed, 62 insertions(+) create mode 100644 doc/driver-model/debugging.rstdoc/driver-model/debugging.rst new file +7
-0@@ -0,0 +1,62 @@ +.. SPDX-License-Identifier: GPL-2.0+ +.. sectionauthor:: Simon Glass <[email protected]> + +Debugging driver model +====================== + +This document aims to provide help when you cannot work out why driver model is
doc/driver-model/debugging.rst line 17
Quoted 10 lines
doc/driver-model/debugging.rst new file +10
-0+not doing what you expect. + + +Useful techniques in general +---------------------------- + +Here are some useful debugging features generally. + + - If you are writing a new feature, consider doing it in sandbox instead of + on your board. Sandbox has no limits, allows each debugging (e.g. gdb) and
easy debugging
doc/driver-model/debugging.rst line 18
Quoted 1 line
doc/driver-model/debugging.rst new file +1
-0+ you can writing emulators for most common devices.
write
Quoted 35 lines
doc/driver-model/debugging.rst new file +35
-0+ - Put '#define DEBUG' at the top of a file, to activate all the debug() and + log_debug() statements in that file. + - Where logging is used, change the logging level, e.g. in SPL with + CONFIG_SPL_LOG_MAX_LEVEL=7 (which is LOGL_DEBUG) and + CONFIG_LOG_DEFAULT_LEVEL=7 + - Where logging of return values is implemented with log_msg_ret(), set + CONFIG_LOG_ERROR_RETURN=y to see exactly where the error is happening + - Make sure you have a debug UART enabled - see CONFIG_DEBUG_UART. With this + you can get serial output (printf(), etc.) before the serial driver is + running. + - Use a JTAG emulator to set breakpoints and single-step through code + +Not that most of these increase code/data size somewhat when enabled. + + +Failure to locate a device +-------------------------- + +Let's say you have uclass_first_device_err() and it is not finding anything. + +If it is returning an error, then that gives you a clue. Look up linux/errno.h +to see errors. Common ones are: + + - -ENOMEM which indicates that memory is short. If it happens in SPL or + before relocation in U-Boot, check CONFIG_SPL_SYS_MALLOC_F_LEN and + CONFIG_SYS_MALLOC_F_LEN as they may need to be larger. Add '#define DEBUG' + at the very top of malloc_simple.c to get an idea of where your memory is + going. + - -EINVAL which typically indicates that something was missing or wrong in + the device tree node. Check that everything is correct and look at the + ofdata_to_platdata() method in the driver. + +If there is no error, you should check if the device is actually bound. Call +dm_dump_all() just before you locate the device to make sure it exists. +
doc/driver-model/debugging.rst
Quoted 10 lines
doc/driver-model/debugging.rst new file +9
-1+If it does not exist, check your device tree compatible strings match up with +what the driver expects (in the struct udevice_id array). + +If you are using of-platdata (e.g. CONFIG_SPL_OF_PLATDATA), check that the +driver name is the same as the first compatible string in the device tree (with +invalid-variable characters converted to underscore). + +If you are really stuck, #define DEBUG at the top of lists.c should show you +what is going on. --
Other than that,
PATCH 4/126 dm: core: Add documentation on how to debug driver model
Quoted 44 lines · Bin Meng
Quoted 8 lines · Simon Glass
Sometimes devices don't appear and it can be confusing. Add a few notes to help with this situation.
Signed-off-by Simon Glass <[email protected]>---
doc/driver-model/debugging.rst | 62 ++++++++++++++++++++++++++++++++++missed updating
index.rstto include this doc.I can fix this when applying.
Quoted 16 lines
1 file changed, 62 insertions(+) create mode 100644 doc/driver-model/debugging.rstdoc/driver-model/debugging.rst new file +7
-0@@ -0,0 +1,62 @@ +.. SPDX-License-Identifier: GPL-2.0+ +.. sectionauthor:: Simon Glass <[email protected]> + +Debugging driver model +====================== + +This document aims to provide help when you cannot work out why driver model isdoc/driver-model/debugging.rst line 17
Quoted 10 lines
doc/driver-model/debugging.rst new file +10
-0+not doing what you expect. + + +Useful techniques in general +---------------------------- + +Here are some useful debugging features generally. + + - If you are writing a new feature, consider doing it in sandbox instead of + on your board. Sandbox has no limits, allows each debugging (e.g. gdb) andeasy debugging
Quoted 3 lines
doc/driver-model/debugging.rst line 18
Quoted 1 line
doc/driver-model/debugging.rst new file +1
-0+ you can writing emulators for most common devices.write
Fixed these issues, and
Quoted 49 lines
Quoted 36 lines
doc/driver-model/debugging.rst new file +35
-0+ - Put '#define DEBUG' at the top of a file, to activate all the debug() and + log_debug() statements in that file. + - Where logging is used, change the logging level, e.g. in SPL with + CONFIG_SPL_LOG_MAX_LEVEL=7 (which is LOGL_DEBUG) and + CONFIG_LOG_DEFAULT_LEVEL=7 + - Where logging of return values is implemented with log_msg_ret(), set + CONFIG_LOG_ERROR_RETURN=y to see exactly where the error is happening + - Make sure you have a debug UART enabled - see CONFIG_DEBUG_UART. With this + you can get serial output (printf(), etc.) before the serial driver is + running. + - Use a JTAG emulator to set breakpoints and single-step through code + +Not that most of these increase code/data size somewhat when enabled. + + +Failure to locate a device +-------------------------- + +Let's say you have uclass_first_device_err() and it is not finding anything. + +If it is returning an error, then that gives you a clue. Look up linux/errno.h +to see errors. Common ones are: + + - -ENOMEM which indicates that memory is short. If it happens in SPL or + before relocation in U-Boot, check CONFIG_SPL_SYS_MALLOC_F_LEN and + CONFIG_SYS_MALLOC_F_LEN as they may need to be larger. Add '#define DEBUG' + at the very top of malloc_simple.c to get an idea of where your memory is + going. + - -EINVAL which typically indicates that something was missing or wrong in + the device tree node. Check that everything is correct and look at the + ofdata_to_platdata() method in the driver. + +If there is no error, you should check if the device is actually bound. Call +dm_dump_all() just before you locate the device to make sure it exists. +doc/driver-model/debugging.rst
Quoted 10 lines
doc/driver-model/debugging.rst new file +9
-1+If it does not exist, check your device tree compatible strings match up with +what the driver expects (in the struct udevice_id array). + +If you are using of-platdata (e.g. CONFIG_SPL_OF_PLATDATA), check that the +driver name is the same as the first compatible string in the device tree (with +invalid-variable characters converted to underscore). + +If you are really stuck, #define DEBUG at the top of lists.c should show you +what is going on. --Other than that,
Quoted 2 lines
Reviewed-by Bin Meng <[email protected]>Tested-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 5/126 dm: core: Don't include ofnode functions with of-platdata
In reply to Simon GlassThese functions cannot work with of-platdata since libfdt is not available. At present when dev_read_...() functions are used it produces error messages about ofnode which is confusing.
Adjust the Makefile and header to produce an error message for the actual dev_read...() function which is called. This makes it easier to see what code needs to be converted for use with of-platdata.
---
drivers/core/Makefile | 4 +++- include/dm/read.h | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/core/Makefile +3 -1
@@ -13,6 +13,8 @@ obj-$(CONFIG_OF_LIVE) += of_access.o of_addr.o ifndef CONFIG_DM_DEV_READ_INLINE obj-$(CONFIG_OF_CONTROL) += read.o endif -obj-$(CONFIG_OF_CONTROL) += of_extra.o ofnode.o read_extra.o +ifdef CONFIG_$(SPL_TPL_)OF_LIBFDT +obj-$(CONFIG_$(SPL_TPL_)OF_CONTROL) += of_extra.o ofnode.o read_extra.o +endif ccflags-$(CONFIG_DM_DEBUG) += -DDEBUG
include/dm/read.h +1 -2
@@ -43,8 +43,7 @@ static inline bool dev_of_valid(struct udevice *dev)return ofnode_valid (dev_ofnode (dev)); } -#ifndef CONFIG_DM_DEV_READ_INLINE - +#if !defined(CONFIG_DM_DEV_READ_INLINE ) ||CONFIG_IS_ENABLED (OF_PLATDATA )/** * dev_read_u32() - read a 32-bit integer from a device's DT property *
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 5/126 dm: core: Don't include ofnode functions with of-platdata
Quoted 9 lines · Simon Glass
These functions cannot work with of-platdata since libfdt is not available. At present when dev_read_...() functions are used it produces error messages about ofnode which is confusing.
Adjust the
Makefileand header to produce an error message for the actual dev_read...() function which is called. This makes it easier to see what code needs to be converted for use with of-platdata.
Quoted 7 lines
Signed-off-by Simon Glass <[email protected]>---
drivers/core/Makefile | 4 +++- include/dm/read.h | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-)
PATCH 5/126 dm: core: Don't include ofnode functions with of-platdata
Quoted 14 lines · Bin Meng
Quoted 12 lines · Simon Glass
These functions cannot work with of-platdata since libfdt is not available. At present when dev_read_...() functions are used it produces error messages about ofnode which is confusing.
Adjust the
Makefileand header to produce an error message for the actual dev_read...() function which is called. This makes it easier to see what code needs to be converted for use with of-platdata.Signed-off-by Simon Glass <[email protected]>---
Quoted 6 lines
Quoted 4 lines
drivers/core/Makefile | 4 +++- include/dm/read.h | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-)Reviewed-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 5/126 dm: core: Don't include ofnode functions with of-platdata
Hi Simon,
Quoted 5 lines · Bin Meng
Quoted 3 lines · Bin Meng
Quoted 1 line · Simon Glass
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
These functions cannot work with of-platdata since libfdt is not available. At present when dev_read_...() functions are used it produces error messages about ofnode which is confusing.
Adjust the
Makefileand header to produce an error message for the actual dev_read...() function which is called. This makes it easier to see what code needs to be converted for use with of-platdata.
As this commit message says, with this patch now it causes a large number of ARM boards build break. See:
https://gitlab.denx.de/u-boot/custodians/u-boot-x86/-/jobs/16696
https://gitlab.denx.de/u-boot/custodians/u-boot-x86/-/jobs/16697
So this is intentional, but I think we should provide the build fix at the same time to make gitlab-CI happy.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Signed-off-by Simon Glass <[email protected]>---
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
drivers/core/Makefile | 4 +++- include/dm/read.h | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-)Reviewed-by Bin Meng <[email protected]>applied to u-boot-x86/next, thanks!
I will have to drop this patch from the queue.
Regards,
Bin
PATCH 5/126 dm: core: Don't include ofnode functions with of-platdata
Hi Bin,
Quoted 17 lines · Bin Meng
Hi Simon,
Quoted 5 lines · Bin Meng
Quoted 3 lines · Bin Meng
Quoted 1 line · Simon Glass
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
These functions cannot work with of-platdata since libfdt is not available. At present when dev_read_...() functions are used it produces error messages about ofnode which is confusing.
Adjust the
Makefileand header to produce an error message for the actual dev_read...() function which is called. This makes it easier to see what code needs to be converted for use with of-platdata.
Quoted 7 lines
As this commit message says, with this patch now it causes a large number of ARM boards build break. See:
https://gitlab.denx.de/u-boot/custodians/u-boot-x86/-/jobs/16696
https://gitlab.denx.de/u-boot/custodians/u-boot-x86/-/jobs/16697So this is intentional, but I think we should provide the build fix at the same time to make gitlab-CI happy.
Yes that makes sense. In fact I think I'll pull this out into a separate series since it is better done with multiple patches.
Regards,
Simon
PATCH 6/126 dm: core: Correct bad cast in ofnode_get_addr_size_index()
In reply to Simon GlassAt present this code passes an fdt_addr_t pointer as a u64 pointer which is not save, since sizeof(fdt_addr_t) may be 4, e.g. with sandbox. Correct this to avoid a stack corruption problem.
---
drivers/core/ofnode.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/core/ofnode.c +5 -2
@@ -261,12 +261,15 @@ fdt_addr_t ofnode_get_addr_size_index(ofnode node, int index, fdt_size_t *size)if (ofnode_is_np (node)) {const __be32 *prop_val; +u64 size64;uint flags; - prop_val =of_get_address (ofnode_to_np (node), index, - (u64 *)size, &flags); + prop_val =of_get_address (ofnode_to_np (node), index, &size64, + &flags);if (!prop_val)return FDT_ADDR_T_NONE ; +if (size) + *size = size64; ns =of_n_size_cells (ofnode_to_np (node));
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 6/126 dm: core: Correct bad cast in ofnode_get_addr_size_index()
Quoted 3 lines · Simon Glass
At present this code passes an
fdt_addr_tpointer as a u64 pointer which is not save, sincesizeof(fdt_addr_t)may be 4, e.g. with sandbox. Correct
not safe
Quoted 9 lines
this to avoid a stack corruption problem.
Fixes e679d03b08 (core: ofnode: Add ofnode_get_addr_size_index)Signed-off-by Simon Glass <[email protected]>---
drivers/core/ofnode.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
I think this should go in v2019.10.
Tom, I will prepare a PR soon.
Regards,
Bin
PATCH 6/126 dm: core: Correct bad cast in ofnode_get_addr_size_index()
Quoted 7 lines · Bin Meng
Quoted 3 lines · Simon Glass
At present this code passes an
fdt_addr_tpointer as a u64 pointer which is not save, sincesizeof(fdt_addr_t)may be 4, e.g. with sandbox. Correctnot safe
Fixed this typo, and
Quoted 11 lines
Quoted 10 lines
this to avoid a stack corruption problem.
Fixes e679d03b08 (core: ofnode: Add ofnode_get_addr_size_index)Signed-off-by Simon Glass <[email protected]>---
drivers/core/ofnode.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
Quoted 5 lines
Reviewed-by Bin Meng <[email protected]>I think this should go in v2019.10.
Tom, I will prepare a PR soon.
applied to u-boot-x86, thanks!
PATCH 7/126 dm: test: Fix running of multiple test from command line
In reply to Simon GlassAt present when multiple 'ut dm' commands are executed, all but the first is run with a flat tree, even if live tree is enabled. This is because the live tree node pointer is set to NULL and never restored.
This does not affect normal test running, which just runs all the test in one go, but can be confusing when several individual tests are run during the same U-Boot run.
Correct this by restoring the pointer.
---
test/dm/test-main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
test/dm/test-main.c +5 -1
@@ -188,8 +188,12 @@ static int dm_test_main(const char *test_name)else printf ("Failures: %d\n" , uts->fail_count); +/* Put everything back to normal so that sandbox works as expected */ +#ifdef CONFIG_OF_LIVE + gd->of_root = uts->of_root; +#endif gd->dm_root =NULL ; -ut_assertok (dm_init (false)); +ut_assertok (dm_init (IS_ENABLED (CONFIG_OF_LIVE )));dm_scan_platdata (false);dm_scan_fdt (gd->fdt_blob, false);
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 7/126 dm: test: Fix running of multiple test from command line
Quoted 9 lines · Simon Glass
At present when multiple 'ut dm' commands are executed, all but the first is run with a flat tree, even if live tree is enabled. This is because the live tree node pointer is set to NULL and never restored.
This does not affect normal test running, which just runs all the test in one go, but can be confusing when several individual tests are run during the same U-Boot run.
Quoted 9 lines
Correct this by restoring the pointer.
Fixes c166c47ba3 (dm: test: Add support for running tests with livetree)Signed-off-by Simon Glass <[email protected]>---
test/dm/test-main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
PATCH 7/126 dm: test: Fix running of multiple test from command line
Quoted 17 lines · Bin Meng
Quoted 15 lines · Simon Glass
At present when multiple 'ut dm' commands are executed, all but the first is run with a flat tree, even if live tree is enabled. This is because the live tree node pointer is set to NULL and never restored.
This does not affect normal test running, which just runs all the test in one go, but can be confusing when several individual tests are run during the same U-Boot run.
Correct this by restoring the pointer.
Fixes c166c47ba3 (dm: test: Add support for running tests with livetree)Signed-off-by Simon Glass <[email protected]>---
Quoted 6 lines
Quoted 3 lines
test/dm/test-main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)Reviewed-by Bin Meng <[email protected]>Tested-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 8/126 dm: test: Don't fail when tests are skipped due to build
In reply to Simon GlassAt present tests that are marked as only for livetree fail when executed on sandbox_flattree. They cannot actually be executed, but we should not resport them as 'not found', since this causes errors. Instead, they should be silently skipped.
---
test/dm/test-main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
test/dm/test-main.c +4 -4
@@ -130,7 +130,7 @@ static int dm_test_main(const char *test_name) const int n_ents = ll_entry_count(struct unit_test, dm_test);struct unit_test_state *uts = &global_dm_test_state;struct unit_test *test; -int run_count; +int found; uts->priv = &_global_priv_dm_test_state; uts->fail_count =0 ;
@@ -148,7 +148,7 @@ static int dm_test_main(const char *test_name)if (!test_name)printf ("Running %d driver model tests\n" , n_ents); - run_count =0 ; + found =0 ;#ifdef CONFIG_OF_LIVE uts->of_root = gd->of_root;#endif
@@ -180,10 +180,10 @@ static int dm_test_main(const char *test_name)ut_assertok (dm_do_test (uts, test, false)); runs++; } - run_count += runs; + found++; } -if (test_name && !run_count) +if (test_name && !found)printf ("Test '%s' not found\n" , test_name);else printf ("Failures: %d\n" , uts->fail_count);
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 8/126 dm: test: Don't fail when tests are skipped due to build
Quoted 6 lines · Simon Glass
At present tests that are marked as only for livetree fail when executed on
sandbox_flattree. They cannot actually be executed, but we should not resport them as 'not found', since this causes errors. Instead, they should be silently skipped.
Quoted 6 lines
Signed-off-by Simon Glass <[email protected]>---
test/dm/test-main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
PATCH 8/126 dm: test: Don't fail when tests are skipped due to build
Quoted 8 lines · Bin Meng
Quoted 6 lines · Simon Glass
At present tests that are marked as only for livetree fail when executed on
sandbox_flattree. They cannot actually be executed, but we should not resport them as 'not found', since this causes errors. Instead, they should be silently skipped.
Quoted 8 lines
Quoted 6 lines
Signed-off-by Simon Glass <[email protected]>---
test/dm/test-main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)Reviewed-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 9/126 dm: core: Call ofdata_to_platdata() with of-platdata
In reply to Simon GlassAt present this function is never called when of-platdata is enabled since we never have a device tree. However, this function is responsible for copying over the of-platdata, so we must call it. Otherwise the probe() method would have to be used.
Correct this and fix the sandbox serial driver to not read from the device tree and try to write to what is read-only platdata on some platforms.
---
drivers/core/device.c | 3 ++- drivers/serial/sandbox.c | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/core/device.c +2 -1
@@ -404,7 +404,8 @@ int device_probe(struct udevice *dev) goto fail; } -if (drv->ofdata_to_platdata &&dev_has_of_node (dev)) { +if (drv->ofdata_to_platdata && + (CONFIG_IS_ENABLED (OF_PLATDATA ) ||dev_has_of_node (dev))) { ret = drv->ofdata_to_platdata (dev);if (ret) goto fail;
drivers/serial/sandbox.c +2 -0
@@ -220,6 +220,8 @@ static int sandbox_serial_ofdata_to_platdata(struct udevice *dev)const char *colour;int i; +if (CONFIG_IS_ENABLED (OF_PLATDATA )) +return 0 ; plat->colour =-1 ; colour =fdt_getprop (gd->fdt_blob,dev_of_offset (dev),"sandbox,text-colour" ,NULL );
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 9/126 dm: core: Call ofdata_to_platdata() with of-platdata
Quoted 9 lines · Simon Glass
At present this function is never called when of-platdata is enabled since we never have a device tree. However, this function is responsible for copying over the of-platdata, so we must call it. Otherwise the
probe()method would have to be used.Correct this and fix the sandbox serial driver to not read from the device tree and try to write to what is read-only platdata on some platforms.
Quoted 8 lines
Fixes 396e343b3d (dm: core: Allow binding a device from a live tree)Signed-off-by Simon Glass <[email protected]>---
drivers/core/device.c | 3 ++- drivers/serial/sandbox.c | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-)
PATCH 9/126 dm: core: Call ofdata_to_platdata() with of-platdata
Quoted 15 lines · Bin Meng
Quoted 13 lines · Simon Glass
At present this function is never called when of-platdata is enabled since we never have a device tree. However, this function is responsible for copying over the of-platdata, so we must call it. Otherwise the
probe()method would have to be used.Correct this and fix the sandbox serial driver to not read from the device tree and try to write to what is read-only platdata on some platforms.
Fixes 396e343b3d (dm: core: Allow binding a device from a live tree)Signed-off-by Simon Glass <[email protected]>---
Quoted 6 lines
Quoted 4 lines
drivers/core/device.c | 3 ++- drivers/serial/sandbox.c | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-)Reviewed-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 10/126 dm: doc: Correct of-platdata CONFIG_IS_ENABLED() condition
In reply to Simon GlassThis condition is not correct since it should not include an SPL_ prefix. Fix it and also add a note about the driver name in the same file.
---
doc/driver-model/of-plat.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
doc/driver-model/of-plat.rst +1 -1
@@ -269,7 +269,7 @@ For example: }; U_BOOT_DRIVER(mmc_drv) = { - .name = "mmc", + .name = "vendor_mmc", /* matches compatible string */ .id = UCLASS_MMC, .of_match = mmc_ids, .ofdata_to_platdata = mmc_ofdata_to_platdata,
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 10/126 dm: doc: Correct of-platdata CONFIG_IS_ENABLED() condition
Hi Simon,
Quoted 15 lines · Simon Glass
This condition is not correct since it should not include an
SPL_prefix. Fix it and also add a note about the driver name in the same file.Signed-off-by Simon Glass <[email protected]>---
doc/driver-model/of-plat.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)doc/driver-model/of-plat.rst +0
-0
doc/driver-model/of-plat.rst For example: · line 272
Quoted 5 lines
doc/driver-model/of-plat.rst +1
-1@@ -269,7 +269,7 @@ For example: }; U_BOOT_DRIVER(mmc_drv) = { - .name = "mmc", + .name = "vendor_mmc", /* matches compatible string */
This single line change only does half of what the commit message says. Where is the other half?
doc/driver-model/of-plat.rst For example:
Quoted 4 lines
doc/driver-model/of-plat.rst +0
-1.id = UCLASS_MMC, .of_match = mmc_ids, .ofdata_to_platdata = mmc_ofdata_to_platdata, --
Regards,
Bin
PATCH 10/126 dm: doc: Correct of-platdata CONFIG_IS_ENABLED() condition
Hi Bin,
Quoted 21 lines · Bin Meng
Hi Simon,
Quoted 17 lines · Simon Glass
This condition is not correct since it should not include an
SPL_prefix. Fix it and also add a note about the driver name in the same file.Signed-off-by Simon Glass <[email protected]>---
doc/driver-model/of-plat.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)doc/driver-model/of-plat.rst +0
-0@@ -269,7 +269,7 @@ For example: };
Quoted 6 lines
doc/driver-model/of-plat.rst For example: · line 272
Quoted 3 lines
doc/driver-model/of-plat.rst +1
-1U_BOOT_DRIVER(mmc_drv) = { - .name = "mmc", + .name = "vendor_mmc", /* matches compatible string */This single line change only does half of what the commit message says. Where is the other half?
Yes this part was fixed by someone else's patch and I forgot about it. I'll update the patch.
Quoted 5 lines
doc/driver-model/of-plat.rst For example:
Quoted 5 lines
doc/driver-model/of-plat.rst +0
-1.id = UCLASS_MMC, .of_match = mmc_ids, .ofdata_to_platdata = mmc_ofdata_to_platdata, --
Regards,
Simon
PATCH 11/126 dm: core: Correct the return value for uclass_find_first_device()
In reply to Simon GlassThis function returns -ENODEV when there is no device. This is inconsistent with other functions, such as uclass_find_next_device(), which returns 0.
Update it and tidy up the incorrect '-1' values in the comments.
---
drivers/core/uclass.c | 2 +- include/dm/uclass-internal.h | 4 ++-- test/dm/core.c | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-)
drivers/core/uclass.c +1 -1
@@ -225,7 +225,7 @@ int uclass_find_first_device(enum uclass_id id, struct udevice **devp)if (ret)return ret;if (list_empty (&uc->dev_head)) -return -ENODEV ; +return 0 ; *devp = list_first_entry(&uc->dev_head, struct udevice, uclass_node);
include/dm/uclass-internal.h +2 -2
@@ -69,7 +69,7 @@ int uclass_find_device(enum uclass_id id, int index, struct udevice **devp);* The device is not prepared for use - this is an internal function. * The function uclass_get_device_tail() can be used to probe the device. * -* @return 0 if OK (found or not found), -1 on error +* @return 0 if OK (found or not found), -ve on error */ int uclass_find_first_device (enum uclass_id id,struct udevice **devp);
@@ -81,7 +81,7 @@ int uclass_find_first_device(enum uclass_id id, struct udevice **devp);* The device is not prepared for use - this is an internal function. * The function uclass_get_device_tail() can be used to probe the device. * -* @return 0 if OK (found or not found), -1 on error +* @return 0 if OK (found or not found), -ve on error */ int uclass_find_next_device (struct udevice **devp);
test/dm/core.c +1 -2
@@ -749,8 +749,7 @@ static int dm_test_uclass_devices_find(struct unit_test_state *uts)ut_assert (dev); } - ret =uclass_find_first_device (UCLASS_TEST_DUMMY , &dev); -ut_assert (ret == -ENODEV ); +ut_assertok (uclass_find_first_device (UCLASS_TEST_DUMMY , &dev));ut_assert (!dev);return 0 ;
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 11/126 dm: core: Correct the return value for uclass_find_first_device()
Quoted 7 lines · Simon Glass
This function returns
-ENODEVwhen there is no device. This is inconsistent with other functions, such asuclass_find_next_device(), which returns 0.Update it and tidy up the incorrect '-1' values in the comments.
Quoted 8 lines
Signed-off-by Simon Glass <[email protected]>---
drivers/core/uclass.c | 2 +- include/dm/uclass-internal.h | 4 ++-- test/dm/core.c | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-)
PATCH 11/126 dm: core: Correct the return value for uclass_find_first_device()
Quoted 12 lines · Bin Meng
Quoted 10 lines · Simon Glass
This function returns
-ENODEVwhen there is no device. This is inconsistent with other functions, such asuclass_find_next_device(), which returns 0.Update it and tidy up the incorrect '-1' values in the comments.
Signed-off-by Simon Glass <[email protected]>---
Quoted 8 lines
Quoted 5 lines
drivers/core/uclass.c | 2 +- include/dm/uclass-internal.h | 4 ++-- test/dm/core.c | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-)Reviewed-by Bin Meng <[email protected]>Tested-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 12/126 dm: core: Add device_foreach_child()
In reply to Simon GlassWe have a 'safe' version of this function but sometimes it is not needed. Add a normal version too and update a few places that can use it.
---
arch/arm/mach-uniphier/pinctrl-glue.c | 4 ++-- drivers/block/blk-uclass.c | 4 ++-- include/dm/device.h | 9 +++++++++ 3 files changed, 13 insertions(+), 4 deletions(-)
arch/arm/mach-uniphier/pinctrl-glue.c +2 -2
@@ -13,14 +13,14 @@int uniphier_pin_init (const char *pinconfig_name) { -struct udevice *pctldev, *config, *next; +struct udevice *pctldev, *config;int ret; ret =uclass_first_device (UCLASS_PINCTRL , &pctldev);if (ret)return ret; - device_foreach_child_safe(config, next, pctldev) { + device_foreach_child(config, pctldev) {if (strcmp (config->name, pinconfig_name))continue ;
drivers/block/blk-uclass.c +2 -2
@@ -142,9 +142,9 @@ struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)*/ struct blk_desc *blk_get_by_device (struct udevice *dev) { -struct udevice *child_dev, *next; +struct udevice *child_dev; - device_foreach_child_safe(child_dev, next, dev) { + device_foreach_child(child_dev, dev) {if (device_get_uclass_id (child_dev) !=UCLASS_BLK )continue ;
include/dm/device.h +9 -0
@@ -679,6 +679,15 @@ static inline bool device_is_on_pci_bus(struct udevice *dev)#define device_foreach_child_safe (pos, next, parent) \ list_for_each_entry_safe(pos, next, &parent->child_head, sibling_node) +/** +* device_foreach_child() - iterate through child devices +* +* @pos: struct udevice * for the current device +* @parent: parent device to scan +*/ +#define device_foreach_child (pos, parent) \ + list_for_each_entry(pos, &parent->child_head, sibling_node) +/** * dm_scan_fdt_dev() - Bind child device in a the device tree *
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 12/126 dm: core: Add device_foreach_child()
Quoted 4 lines · Simon Glass
We have a 'safe' version of this function but sometimes it is not needed. Add a normal version too and update a few places that can use it.
Quoted 8 lines
Signed-off-by Simon Glass <[email protected]>---
arch/arm/mach-uniphier/pinctrl-glue.c | 4 ++-- drivers/block/blk-uclass.c | 4 ++-- include/dm/device.h | 9 +++++++++ 3 files changed, 13 insertions(+), 4 deletions(-)
PATCH 12/126 dm: core: Add device_foreach_child()
Quoted 9 lines · Bin Meng
Quoted 7 lines · Simon Glass
We have a 'safe' version of this function but sometimes it is not needed. Add a normal version too and update a few places that can use it.
Signed-off-by Simon Glass <[email protected]>---
Quoted 7 lines
Quoted 5 lines
arch/arm/mach-uniphier/pinctrl-glue.c | 4 ++-- drivers/block/blk-uclass.c | 4 ++-- include/dm/device.h | 9 +++++++++ 3 files changed, 13 insertions(+), 4 deletions(-)Reviewed-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 13/126 dm: test: Correct a stray backslash in dm_test_destroy()
In reply to Simon GlassThis should perhaps be a period but it is not necessary. Remove it.
---
test/dm/test-main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
test/dm/test-main.c +1 -1
@@ -64,7 +64,7 @@ static int dm_test_destroy(struct unit_test_state *uts)/* * If the uclass doesn't exist we don't want to create it. So -* check that here before we call uclass_find_device()/ +* check that here before we call uclass_find_device() */ uc =uclass_find (id);if (!uc)
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 13/126 dm: test: Correct a stray backslash in dm_test_destroy()
Quoted 14 lines · Simon Glass
This should perhaps be a period but it is not necessary. Remove it.
Signed-off-by Simon Glass <[email protected]>---
test/dm/test-main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)test/dm/test-main.c +0
-0
test/dm/test-main.c static int dm_test_destroy(struct unit_test_state *uts) · line 67
Quoted 5 lines
test/dm/test-main.c +1
-1@@ -64,7 +64,7 @@ static int dm_test_destroy(struct unit_test_state *uts)/* * If the uclass doesn't exist we don't want to create it. So -* check that here before we call uclass_find_device()/ +* check that here before we call uclass_find_device()
I tend to use a period since it's a complete sentence.
test/dm/test-main.c static int dm_test_destroy(struct unit_test_state *uts)
Quoted 4 lines
test/dm/test-main.c +0
-1*/ uc =uclass_find (id);if (!uc) --
PATCH 13/126 dm: test: Correct a stray backslash in dm_test_destroy()
Quoted 17 lines · Bin Meng
Quoted 15 lines · Simon Glass
This should perhaps be a period but it is not necessary. Remove it.
Signed-off-by Simon Glass <[email protected]>---
test/dm/test-main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)test/dm/test-main.c +0
-0@@ -64,7 +64,7 @@ static int dm_test_destroy(struct unit_test_state *uts)
Quoted 6 lines
test/dm/test-main.c static int dm_test_destroy(struct unit_test_state *uts) · line 67
Quoted 4 lines
test/dm/test-main.c +1
-1/* * If the uclass doesn't exist we don't want to create it. So -* check that here before we call uclass_find_device()/ +* check that here before we call uclass_find_device() I tend to use a period since it's a complete sentence.
Added the ending period, reworded the commit message, and
Quoted 7 lines
test/dm/test-main.c static int dm_test_destroy(struct unit_test_state *uts)
Quoted 5 lines
test/dm/test-main.c +0
-1*/ uc =uclass_find (id);if (!uc) --Reviewed-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 14/126 fdt: Show the preprocessed .dts file on error
In reply to Simon GlassWhen device-tree compilation fails it is sometimes tricky to see which line is broken, since the input file to dtc is a pre-processed version of the device tree.
Add a line that points to the file that needs to be checked:
Output is something like this:
Error: arch/x86/dts/.chromebook_coral.dtb.pre.tmp:170.15-16 syntax error FATAL ERROR: Unable to parse input tree
Check /tmp/b/chromebook_coral/arch/x86/dts/.chromebook_coral.dtb.pre.tmp
for errors
---
scripts/Makefile.lib | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/Makefile.lib +3 -1
@@ -300,7 +300,9 @@ cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \ $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $(pre-tmp) ; \ $(DTC) -O dtb -o $@ -b 0 \ -i $(dir $<) $(DTC_FLAGS) \ - -d $(depfile).dtc.tmp $(dtc-tmp) ; \ + -d $(depfile).dtc.tmp $(dtc-tmp) || \ + (echo "Check $(shell pwd)/$(pre-tmp) for errors" && false) \ + ; \ cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile) ; \ sed -i "s:$(pre-tmp):$(<):" $(depfile)
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 14/126 fdt: Show the preprocessed .dts file on error
Hi Simon,
Quoted 10 lines · Simon Glass
When device-tree compilation fails it is sometimes tricky to see which line is broken, since the input file to dtc is a pre-processed version of the device tree.
Add a line that points to the file that needs to be checked:
Output is something like this:
Error: arch/x86/dts/.chromebook_coral.dtb.pre.tmp:170.15-16 syntax error
This line already provides information that you need.
Quoted 2 lines
FATAL ERROR: Unable to parse input tree
Check/tmp/b/chromebook_coral/arch/x86/dts/.chromebook_coral.dtb.pre.tmp
I don't understand why we need another line that provides the same information.
Quoted 8 lines
for errors
Signed-off-by Simon Glass <[email protected]>---
scripts/Makefile.lib | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Regards,
Bin
PATCH 14/126 fdt: Show the preprocessed .dts file on error
Hi Bin,
Quoted 13 lines · Bin Meng
Hi Simon,
Quoted 9 lines · Simon Glass
When device-tree compilation fails it is sometimes tricky to see which line is broken, since the input file to dtc is a pre-processed version of the device tree.
Add a line that points to the file that needs to be checked:
Output is something like this:
Quoted 8 lines
Quoted 1 line
Error: arch/x86/dts/.chromebook_coral.dtb.pre.tmp:170.15-16 syntax error
This line already provides information that you need.
Quoted 2 lines
FATAL ERROR: Unable to parse input tree
Check/tmp/b/chromebook_coral/arch/x86/dts/.chromebook_coral.dtb.pre.tmpI don't understand why we need another line that provides the same information.
Yes that is a bad example, I will update it. If a .dtsi has a CONFIG it is not possible from the source file to work one what when wrong.
Quoted 9 lines
Quoted 9 lines
for errors
Signed-off-by Simon Glass <[email protected]>---
scripts/Makefile.lib | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Regards,
Simon
PATCH 15/126 sandbox: spmi: Add ranges property for address translation
In reply to Simon GlassAt present address translation does not work since there is no ranges property in the spmi nodes. Add empty ranges properties and a little more logging so that this shows the error:
/tmp/b/sandbox/u-boot -d /tmp/b/sandbox/arch/sandbox/dts/test.dtb \
-c "ut dm spmi_access_peripheral" -L7 -v
...
pm8916_gpio_probe() bad address: returning err=-22
---
arch/sandbox/dts/test.dts | 2 ++ drivers/gpio/pm8916_gpio.c | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-)
arch/sandbox/dts/test.dts +2 -0
@@ -717,11 +717,13 @@ compatible = "sandbox,spmi"; #address-cells = <0x1>; #size-cells = <0x1>; + ranges; pm8916 at 0 { compatible = "qcom,spmi-pmic"; reg = <0x0 0x1>; #address-cells = <0x1>; #size-cells = <0x1>; + ranges; spmi_gpios: gpios at c000 { compatible = "qcom,pm8916-gpio";
drivers/gpio/pm8916_gpio.c +6 -6
@@ -172,16 +172,16 @@ static int pm8916_gpio_probe(struct udevice *dev) priv->pid =dev_read_addr (dev);if (priv->pid ==FDT_ADDR_T_NONE ) -return -EINVAL ; +return log_msg_ret ("bad address" , -EINVAL );/* Do a sanity check */ reg =pmic_reg_read (dev->parent, priv->pid +REG_TYPE );if (reg !=0x10 ) -return -ENODEV ; +return log_msg_ret ("bad type" , -ENXIO ); reg =pmic_reg_read (dev->parent, priv->pid +REG_SUBTYPE );if (reg !=0x5 && reg !=0x1 ) -return -ENODEV ; +return log_msg_ret ("bad subtype" , -ENXIO );return 0 ; }
@@ -257,16 +257,16 @@ static int pm8941_pwrkey_probe(struct udevice *dev) priv->pid =devfdt_get_addr (dev);if (priv->pid ==FDT_ADDR_T_NONE ) -return -EINVAL ; +return log_msg_ret ("bad address" , -EINVAL );/* Do a sanity check */ reg =pmic_reg_read (dev->parent, priv->pid +REG_TYPE );if (reg !=0x1 ) -return -ENODEV ; +return log_msg_ret ("bad type" , -ENXIO ); reg =pmic_reg_read (dev->parent, priv->pid +REG_SUBTYPE );if (reg !=0x1 ) -return -ENODEV ; +return log_msg_ret ("bad subtype" , -ENXIO );return 0 ; }
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 15/126 sandbox: spmi: Add ranges property for address translation
Quoted 10 lines · Simon Glass
At present address translation does not work since there is no ranges property in the spmi nodes. Add empty ranges properties and a little more logging so that this shows the error:
/tmp/b/sandbox/u-boot -d /tmp/b/sandbox/arch/sandbox/dts/test.dtb \ -c "ut dm spmi_access_peripheral" -L7 -v ... pm8916_gpio_probe() bad address: returning err=-22
Quoted 7 lines
Signed-off-by Simon Glass <[email protected]>---
arch/sandbox/dts/test.dts | 2 ++ drivers/gpio/pm8916_gpio.c | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-)
PATCH 15/126 sandbox: spmi: Add ranges property for address translation
Quoted 15 lines · Bin Meng
Quoted 13 lines · Simon Glass
At present address translation does not work since there is no ranges property in the spmi nodes. Add empty ranges properties and a little more logging so that this shows the error:
/tmp/b/sandbox/u-boot -d /tmp/b/sandbox/arch/sandbox/dts/test.dtb \ -c "ut dm spmi_access_peripheral" -L7 -v ... pm8916_gpio_probe() bad address: returning err=-22Signed-off-by Simon Glass <[email protected]>---
Quoted 7 lines
Quoted 4 lines
arch/sandbox/dts/test.dts | 2 ++ drivers/gpio/pm8916_gpio.c | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-)Reviewed-by Bin Meng <[email protected]>Tested-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 16/126 sandbox: mmc: Fix up MMC emulator for valgrind
In reply to Simon GlassAt present running sandbox with valgrind produces some warnings due to the MMC emulator not filling in all the expected fields. Fix it.
---
drivers/mmc/sandbox_mmc.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/mmc/sandbox_mmc.c +4 -0
@@ -27,6 +27,7 @@ static int sandbox_mmc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd, {switch (cmd->cmdidx) {case MMC_CMD_ALL_SEND_CID : +memset (cmd->response,'\0' ,16 );break ;case SD_CMD_SEND_RELATIVE_ADDR : cmd->response[0 ] =0 <<16 ;/* mmc->rca */
@@ -43,11 +44,14 @@ static int sandbox_mmc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd,case MMC_CMD_SEND_CSD : cmd->response[0 ] =0 ; cmd->response[1 ] =10 <<16 ;/* 1 << block_len */ + cmd->response[2 ] =0 ; + cmd->response[3 ] =0 ;break ;case SD_CMD_SWITCH_FUNC : {if (!data)break ;u32 *resp = (u32 *)data->dest; + resp[3 ] =0 ; resp[7 ] =cpu_to_be32 (SD_HIGHSPEED_BUSY );if ((cmd->cmdarg &0xF ) ==UHS_SDR12_BUS_SPEED ) resp[4 ] = (cmd->cmdarg &0xF ) <<24 ;
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 16/126 sandbox: mmc: Fix up MMC emulator for valgrind
Quoted 15 lines · Simon Glass
At present running sandbox with valgrind produces some warnings due to the MMC emulator not filling in all the expected fields. Fix it.
Signed-off-by Simon Glass <[email protected]>---
drivers/mmc/sandbox_mmc.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/mmc/sandbox_mmc.c +0
-0
drivers/mmc/sandbox_mmc.c static int sandbox_mmc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd, · line 30
Quoted 4 lines
drivers/mmc/sandbox_mmc.c +1
-0@@ -27,6 +27,7 @@ static int sandbox_mmc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd, {switch (cmd->cmdidx) {case MMC_CMD_ALL_SEND_CID : +memset (cmd->response,'\0' ,16 );
sizeof(cmd->response)
Quoted 9 lines
drivers/mmc/sandbox_mmc.c +2
-0break ;case SD_CMD_SEND_RELATIVE_ADDR : cmd->response[0 ] =0 <<16 ;/* mmc->rca */ @@ -43,11 +44,14 @@ static int sandbox_mmc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd,case MMC_CMD_SEND_CSD : cmd->response[0 ] =0 ; cmd->response[1 ] =10 <<16 ;/* 1 << block_len */ + cmd->response[2 ] =0 ; + cmd->response[3 ] =0 ;
drivers/mmc/sandbox_mmc.c static int sandbox_mmc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd,
Quoted 10 lines
drivers/mmc/sandbox_mmc.c +1
-1break ;case SD_CMD_SWITCH_FUNC : {if (!data)break ;u32 *resp = (u32 *)data->dest; + resp[3 ] =0 ; resp[7 ] =cpu_to_be32 (SD_HIGHSPEED_BUSY );if ((cmd->cmdarg &0xF ) ==UHS_SDR12_BUS_SPEED ) resp[4 ] = (cmd->cmdarg &0xF ) <<24 ; --
PATCH 16/126 sandbox: mmc: Fix up MMC emulator for valgrind
Quoted 12 lines · Bin Meng
Quoted 10 lines · Simon Glass
At present running sandbox with valgrind produces some warnings due to the MMC emulator not filling in all the expected fields. Fix it.
Signed-off-by Simon Glass <[email protected]>---
drivers/mmc/sandbox_mmc.c | 4 ++++ 1 file changed, 4 insertions(+)
Quoted 11 lines
drivers/mmc/sandbox_mmc.c static int sandbox_mmc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd, · line 30
Quoted 9 lines
drivers/mmc/sandbox_mmc.c +1
-0@@ -27,6 +27,7 @@ static int sandbox_mmc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd, {switch (cmd->cmdidx) {case MMC_CMD_ALL_SEND_CID : +memset (cmd->response,'\0' ,16 );
sizeof(cmd->response)
Changed to use sizeof(), and
Quoted 15 lines
Quoted 15 lines
drivers/mmc/sandbox_mmc.c +2
-0break ;case SD_CMD_SEND_RELATIVE_ADDR : cmd->response[0 ] =0 <<16 ;/* mmc->rca */ @@ -43,11 +44,14 @@ static int sandbox_mmc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd,case MMC_CMD_SEND_CSD : cmd->response[0 ] =0 ; cmd->response[1 ] =10 <<16 ;/* 1 << block_len */ + cmd->response[2 ] =0 ; + cmd->response[3 ] =0 ;break ;case SD_CMD_SWITCH_FUNC : {if (!data)break ;u32 *resp = (u32 *)data->dest;
Quoted 8 lines
drivers/mmc/sandbox_mmc.c static int sandbox_mmc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd,
Quoted 5 lines
drivers/mmc/sandbox_mmc.c +1
-1+ resp[3 ] =0 ; resp[7 ] =cpu_to_be32 (SD_HIGHSPEED_BUSY );if ((cmd->cmdarg &0xF ) ==UHS_SDR12_BUS_SPEED ) resp[4 ] = (cmd->cmdarg &0xF ) <<24 ; --Reviewed-by Bin Meng <[email protected]>Tested-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 17/126 sandbox: Rename PCI ID for swap_case to be more specific
In reply to Simon GlassRename this ID to SANDBOX_PCI_SWAP_CASE_EMUL_ID since it is more descriptive and allows us to add new PCI emulators without any conflict or confusion.
---
arch/sandbox/include/asm/test.h | 2 +- drivers/misc/swap_case.c | 5 +++-- test/dm/pci.c | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-)
arch/sandbox/include/asm/test.h +1 -1
@@ -12,7 +12,7 @@#define SANDBOX_I2C_TEST_ADDR 0x59#define SANDBOX_PCI_VENDOR_ID 0x1234 -#define SANDBOX_PCI_DEVICE_ID 0x5678 +#define SANDBOX_PCI_SWAP_CASE_EMUL_ID 0x5678#define SANDBOX_PCI_CLASS_CODE PCI_CLASS_CODE_COMM#define SANDBOX_PCI_CLASS_SUB_CODE PCI_CLASS_SUB_CODE_COMM_SERIAL
drivers/misc/swap_case.c +3 -2
@@ -129,7 +129,7 @@ static int sandbox_swap_case_read_config(struct udevice *emul, uint offset, *valuep =SANDBOX_PCI_VENDOR_ID ;break ;case PCI_DEVICE_ID : - *valuep =SANDBOX_PCI_DEVICE_ID ; + *valuep =SANDBOX_PCI_SWAP_CASE_EMUL_ID ;break ;case PCI_CLASS_DEVICE :if (size ==PCI_SIZE_8 ) {
@@ -417,7 +417,8 @@ U_BOOT_DRIVER(sandbox_swap_case_emul) = { };static struct pci_device_id sandbox_swap_case_supported[] = { - {PCI_VDEVICE (SANDBOX ,SANDBOX_PCI_DEVICE_ID ),SWAP_CASE_DRV_DATA }, + {PCI_VDEVICE (SANDBOX ,SANDBOX_PCI_SWAP_CASE_EMUL_ID ), +SWAP_CASE_DRV_DATA }, {}, };
test/dm/pci.c +3 -3
@@ -38,7 +38,7 @@ static int dm_test_pci_busdev(struct unit_test_state *uts)ut_assertok (dm_pci_bus_find_bdf (PCI_BDF (0 ,0x1f ,0 ), &swap)); device =0 ;ut_assertok (dm_pci_read_config16 (swap,PCI_DEVICE_ID , &device)); -ut_asserteq (SANDBOX_PCI_DEVICE_ID , device); +ut_asserteq (SANDBOX_PCI_SWAP_CASE_EMUL_ID , device);/* Test bus#1 and its devices */ ut_assertok (uclass_get_device_by_seq (UCLASS_PCI ,1 , &bus));
@@ -50,7 +50,7 @@ static int dm_test_pci_busdev(struct unit_test_state *uts)ut_assertok (dm_pci_bus_find_bdf (PCI_BDF (1 ,0x0c ,0 ), &swap)); device =0 ;ut_assertok (dm_pci_read_config16 (swap,PCI_DEVICE_ID , &device)); -ut_asserteq (SANDBOX_PCI_DEVICE_ID , device); +ut_asserteq (SANDBOX_PCI_SWAP_CASE_EMUL_ID , device);return 0 ; }
@@ -170,7 +170,7 @@ static int dm_test_pci_mixed(struct unit_test_state *uts)ut_assertok (dm_pci_bus_find_bdf (PCI_BDF (2 ,0x1f ,0 ), &swap)); device =0 ;ut_assertok (dm_pci_read_config16 (swap,PCI_DEVICE_ID , &device)); -ut_asserteq (SANDBOX_PCI_DEVICE_ID , device); +ut_asserteq (SANDBOX_PCI_SWAP_CASE_EMUL_ID , device);/* First test I/O */ io_addr =dm_pci_read_bar32 (swap,0 );
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 17/126 sandbox: Rename PCI ID for swap_case to be more specific
Quoted 5 lines · Simon Glass
Rename this ID to
SANDBOX_PCI_SWAP_CASE_EMUL_IDsince it is more descriptive and allows us to add new PCI emulators without any conflict or confusion.
Quoted 8 lines
Signed-off-by Simon Glass <[email protected]>---
arch/sandbox/include/asm/test.h | 2 +- drivers/misc/swap_case.c | 5 +++-- test/dm/pci.c | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-)
PATCH 17/126 sandbox: Rename PCI ID for swap_case to be more specific
Quoted 10 lines · Bin Meng
Quoted 8 lines · Simon Glass
Rename this ID to
SANDBOX_PCI_SWAP_CASE_EMUL_IDsince it is more descriptive and allows us to add new PCI emulators without any conflict or confusion.Signed-off-by Simon Glass <[email protected]>---
Quoted 7 lines
Quoted 5 lines
arch/sandbox/include/asm/test.h | 2 +- drivers/misc/swap_case.c | 5 +++-- test/dm/pci.c | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-)Reviewed-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 18/126 sandbox: Add support for clrsetio_32() and friends
In reply to Simon GlassThese functions are available on x86 but not sandbox. They are useful shortcuts and clarify the code, so add them to sandbox.
---
arch/sandbox/include/asm/io.h | 42 ++++++++++++++++++++++++++++++----- arch/sandbox/lib/pci_io.c | 12 +++++----- 2 files changed, 42 insertions(+), 12 deletions(-)
arch/sandbox/include/asm/io.h +36 -6
@@ -110,13 +110,21 @@ phys_addr_t map_to_sysmem(const void *ptr);#define clrsetbits_8 (addr, clear, set) clrsetbits(8, addr, clear, set)/* I/O access functions */ -int inl (unsigned int addr); -int inw (unsigned int addr); -int inb (unsigned int addr); +int _inl (unsigned int addr); +int _inw (unsigned int addr); +int _inb (unsigned int addr); -void outl (unsigned int value,unsigned int addr); -void outw (unsigned int value,unsigned int addr); -void outb (unsigned int value,unsigned int addr); +void _outl (unsigned int value,unsigned int addr); +void _outw (unsigned int value,unsigned int addr); +void _outb (unsigned int value,unsigned int addr); + +#define inb (port) _inb((uintptr_t)(port)) +#define inw (port) _inw((uintptr_t)(port)) +#define inl (port) _inl((uintptr_t)(port)) + +#define outb (val, port) _outb(val, (uintptr_t)(port)) +#define outw (val, port) _outw(val, (uintptr_t)(port)) +#define outl (val, port) _outl(val, (uintptr_t)(port))#define out_arch (type,endian,a,v) write##type(cpu_to_##endian(v),a)#define in_arch (type,endian,a) endian##_to_cpu(read##type(a))
@@ -188,6 +196,28 @@ static inline void memcpy_toio(volatile void *dst, const void *src, int count)#define insw (port, buf, ns) _insw((u16 *)port, buf, ns)#define outsw (port, buf, ns) _outsw((u16 *)port, buf, ns) +/* IO space accessors */ +#define clrio (type, addr, clear) \ + out##type(in##type(addr) & ~(clear), (addr)) + +#define setio (type, addr, set) \ + out##type(in##type(addr) | (set), (addr)) + +#define clrsetio (type, addr, clear, set) \ + out##type((in##type(addr) & ~(clear)) | (set), (addr)) + +#define clrio_32 (addr, clear) clrio(l, addr, clear) +#define clrio_16 (addr, clear) clrio(w, addr, clear) +#define clrio_8 (addr, clear) clrio(b, addr, clear) + +#define setio_32 (addr, set) setio(l, addr, set) +#define setio_16 (addr, set) setio(w, addr, set) +#define setio_8 (addr, set) setio(b, addr, set) + +#define clrsetio_32 (addr, clear, set) clrsetio(l, addr, clear, set) +#define clrsetio_16 (addr, clear, set) clrsetio(w, addr, clear, set) +#define clrsetio_8 (addr, clear, set) clrsetio(b, addr, clear, set) +#include <iotrace.h> #include <asm/types.h>
arch/sandbox/lib/pci_io.c +6 -6
@@ -91,7 +91,7 @@ static int pci_io_write(unsigned int addr, ulong value, pci_size_t size)return -ENOSYS ; } -int inl (unsigned int addr) +int _inl (unsigned int addr) {unsigned long value;int ret;
@@ -101,7 +101,7 @@ int inl(unsigned int addr)return ret ?0 : value; } -int inw (unsigned int addr) +int _inw (unsigned int addr) {unsigned long value;int ret;
@@ -111,7 +111,7 @@ int inw(unsigned int addr)return ret ?0 : value; } -int inb (unsigned int addr) +int _inb (unsigned int addr) {unsigned long value;int ret;
@@ -121,17 +121,17 @@ int inb(unsigned int addr)return ret ?0 : value; } -void outl (unsigned int value,unsigned int addr) +void _outl (unsigned int value,unsigned int addr) {pci_io_write (addr, value,PCI_SIZE_32 ); } -void outw (unsigned int value,unsigned int addr) +void _outw (unsigned int value,unsigned int addr) {pci_io_write (addr, value,PCI_SIZE_16 ); } -void outb (unsigned int value,unsigned int addr) +void _outb (unsigned int value,unsigned int addr) {pci_io_write (addr, value,PCI_SIZE_8 ); }
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 18/126 sandbox: Add support for clrsetio_32() and friends
Quoted 11 lines · Simon Glass
These functions are available on x86 but not sandbox. They are useful shortcuts and clarify the code, so add them to sandbox.
Signed-off-by Simon Glass <[email protected]>---
arch/sandbox/include/asm/io.h | 42 ++++++++++++++++++++++++++++++----- arch/sandbox/lib/pci_io.c | 12 +++++----- 2 files changed, 42 insertions(+), 12 deletions(-)
PATCH 18/126 sandbox: Add support for clrsetio_32() and friends
Quoted 9 lines · Bin Meng
Quoted 7 lines · Simon Glass
These functions are available on x86 but not sandbox. They are useful shortcuts and clarify the code, so add them to sandbox.
Signed-off-by Simon Glass <[email protected]>---
Quoted 6 lines
Quoted 4 lines
arch/sandbox/include/asm/io.h | 42 ++++++++++++++++++++++++++++++----- arch/sandbox/lib/pci_io.c | 12 +++++----- 2 files changed, 42 insertions(+), 12 deletions(-)Reviewed-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 19/126 sandbox: swap_case: Use statics where possible
In reply to Simon GlassSome functions and a struct should be marked static since they are not used outside this file. Update them.
---
drivers/misc/swap_case.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/misc/swap_case.c +5 -5
@@ -286,8 +286,8 @@ static void sandbox_swap_case_do_op(enum swap_case_op op, char *str, int len) } } -int sandbox_swap_case_read_io (struct udevice *dev,unsigned int addr, -ulong *valuep,enum pci_size_t size) +static int sandbox_swap_case_read_io (struct udevice *dev,unsigned int addr, +ulong *valuep,enum pci_size_t size) {struct swap_case_priv *priv =dev_get_priv (dev);unsigned int offset;
@@ -304,8 +304,8 @@ int sandbox_swap_case_read_io(struct udevice *dev, unsigned int addr,return 0 ; } -int sandbox_swap_case_write_io (struct udevice *dev,unsigned int addr, -ulong value,enum pci_size_t size) +static int sandbox_swap_case_write_io (struct udevice *dev,unsigned int addr, +ulong value,enum pci_size_t size) {struct swap_case_priv *priv =dev_get_priv (dev);unsigned int offset;
@@ -392,7 +392,7 @@ static int sandbox_swap_case_unmap_physmem(struct udevice *dev,return 0 ; } -struct dm_pci_emul_ops sandbox_swap_case_emul_ops = { +static struct dm_pci_emul_ops sandbox_swap_case_emul_ops = { .get_devfn = sandbox_swap_case_get_devfn, .read_config = sandbox_swap_case_read_config, .write_config = sandbox_swap_case_write_config,
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 19/126 sandbox: swap_case: Use statics where possible
Quoted 10 lines · Simon Glass
Some functions and a struct should be marked static since they are not used outside this file. Update them.
Signed-off-by Simon Glass <[email protected]>---
drivers/misc/swap_case.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
PATCH 19/126 sandbox: swap_case: Use statics where possible
Quoted 6 lines · Bin Meng
Quoted 4 lines · Simon Glass
Some functions and a struct should be marked static since they are not used outside this file. Update them.
Quoted 8 lines
Quoted 6 lines
Signed-off-by Simon Glass <[email protected]>---
drivers/misc/swap_case.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)Reviewed-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 20/126 sandbox: pci: Drop the get_devfn() method
In reply to Simon GlassThis method is not used anymore since the bus/device/function of PCI devices can be obtained from their (parent's per-child) platform data. Drop it.
---
drivers/misc/swap_case.c | 8 -------- include/pci.h | 7 ------- 2 files changed, 15 deletions(-)
drivers/misc/swap_case.c +0 -8
@@ -54,13 +54,6 @@ struct swap_case_priv {char mem_text[MEM_TEXT_SIZE ]; }; -static int sandbox_swap_case_get_devfn (struct udevice *dev) -{ -struct pci_child_platdata *plat =dev_get_parent_platdata (dev); - -return plat->devfn; -} -static int sandbox_swap_case_use_ea (struct udevice *dev) {return !!ofnode_get_property (dev->node,"use-ea" ,NULL );
@@ -393,7 +386,6 @@ static int sandbox_swap_case_unmap_physmem(struct udevice *dev, }static struct dm_pci_emul_ops sandbox_swap_case_emul_ops = { - .get_devfn = sandbox_swap_case_get_devfn, .read_config = sandbox_swap_case_read_config, .write_config = sandbox_swap_case_write_config, .read_io = sandbox_swap_case_read_io,
include/pci.h +0 -7
@@ -1490,13 +1490,6 @@ int dm_pci_find_class(uint find_class, int index, struct udevice **devp);* struct dm_pci_emul_ops - PCI device emulator operations */ struct dm_pci_emul_ops { -/** -* get_devfn(): Check which device and function this emulators -* -* @dev: device to check -* @return the device and function this emulates, or -ve on error -*/ -int (*get_devfn)(struct udevice *dev);/** * read_config() - Read a PCI configuration value *
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 20/126 sandbox: pci: Drop the get_devfn() method
Quoted 5 lines · Simon Glass
This method is not used anymore since the bus/device/function of PCI devices can be obtained from their (parent's per-child) platform data. Drop it.
Quoted 7 lines
Signed-off-by Simon Glass <[email protected]>---
drivers/misc/swap_case.c | 8 -------- include/pci.h | 7 ------- 2 files changed, 15 deletions(-)
PATCH 20/126 sandbox: pci: Drop the get_devfn() method
Quoted 10 lines · Bin Meng
Quoted 8 lines · Simon Glass
This method is not used anymore since the bus/device/function of PCI devices can be obtained from their (parent's per-child) platform data. Drop it.
Signed-off-by Simon Glass <[email protected]>---
Quoted 6 lines
Quoted 4 lines
drivers/misc/swap_case.c | 8 -------- include/pci.h | 7 ------- 2 files changed, 15 deletions(-)Reviewed-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 21/126 sandbox: net: Suppress the MAC-address warnings
In reply to Simon GlassThese warnings appear every thing sandbox is run (see below) and dwarf the actual useful output. Suppress them.
Hopefully at some point a way can be found to fix the root cause.
U-Boot 2019.10-rc2
Model: sandbox DRAM: 128 MiB
Warning: host_lo MAC addresses don't match:
Address in ROM is a6:28:b7:47:28:93
Address in environment is 00:00:11:22:33:44
Warning: host_enp5s0 MAC addresses don't match:
Address in ROM is a6:28:b7:47:28:93
Address in environment is 00:00:11:22:33:45
Warning: host_eth6 using MAC address from ROM
Warning: host_docker0 MAC addresses don't match:
Address in ROM is a6:28:b7:47:28:93
Address in environment is 00:00:11:22:33:46
Warning: host_docker_gwbridge using MAC address from ROM
Warning: host_veth1118e68 MAC addresses don't match:
Address in ROM is a6:28:b7:47:28:93
Address in environment is 00:00:11:22:33:47
WDT: Not found!
MMC:
In: cros-ec-keyb Out: vidconsole Err: vidconsole Model: sandbox SCSI: Net: eth0: host_lo, eth1: host_enp5s0, eth2: host_eth6, eth3: host_docker0, eth4: host_docker_gwbridge, eth5: host_veth1118e68 Error: eth at 10002000 address not set.
, eth-1: eth at 10002000
Test 'pmc_base' not found
Warning: host_lo MAC addresses don't match:
Address in ROM is 2a:24:9a:31:90:f8
Address in environment is 00:00:11:22:33:44
Warning: host_enp5s0 MAC addresses don't match:
Address in ROM is ce:23:d9:74:6f:6c
Address in environment is 00:00:11:22:33:45
Warning: host_eth6 using MAC address from ROM
Warning: host_docker0 MAC addresses don't match:
Address in ROM is ee:22:1c:3b:be:bc
Address in environment is 00:00:11:22:33:46
Warning: host_docker_gwbridge using MAC address from ROM
Warning: host_veth1118e68 MAC addresses don't match:
Address in ROM is ae:20:9e:3d:a4:9f
Address in environment is 00:00:11:22:33:47
---
net/eth-uclass.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-)
net/eth-uclass.c +22 -12
@@ -485,6 +485,12 @@ static int eth_post_probe(struct udevice *dev)struct eth_device_priv *priv = dev->uclass_priv;struct eth_pdata *pdata = dev->platdata;unsigned char env_enetaddr[ARP_HLEN ]; +/* +* These warnings always appear on sandbox and are not useful. They have +* been here for some time and the issue has not been resolved. So for +* now, disable them. +*/ +bool show_warnings = !IS_ENABLED (CONFIG_SANDBOX );#if defined(CONFIG_NEEDS_MANUAL_RELOC )struct eth_ops *ops =eth_get_ops (dev);
@@ -526,29 +532,33 @@ static int eth_post_probe(struct udevice *dev)if (!is_zero_ethaddr (env_enetaddr)) {if (!is_zero_ethaddr (pdata->enetaddr) &&memcmp (pdata->enetaddr, env_enetaddr,ARP_HLEN )) { -printf ("\nWarning: %s MAC addresses don't match:\n" , - dev->name); -printf ("Address in ROM is %pM\n" , - pdata->enetaddr); -printf ("Address in environment is %pM\n" , - env_enetaddr); +if (show_warnings) { +printf ("\nWarning: %s MAC addresses don't match:\n" , + dev->name); +printf ("Address in ROM is %pM\n" , + pdata->enetaddr); +printf ("Address in environment is %pM\n" , + env_enetaddr); + } }/* Override the ROM MAC address */ memcpy (pdata->enetaddr, env_enetaddr,ARP_HLEN ); }else if (is_valid_ethaddr (pdata->enetaddr)) {eth_env_set_enetaddr_by_index ("eth" , dev->seq, pdata->enetaddr); -printf ("\nWarning: %s using MAC address from ROM\n" , - dev->name); +if (show_warnings) +printf ("\nWarning: %s using MAC address from ROM\n" , + dev->name); }else if (is_zero_ethaddr (pdata->enetaddr) || !is_valid_ethaddr (pdata->enetaddr)) {#ifdef CONFIG_NET_RANDOM_ETHADDR net_random_ethaddr (pdata->enetaddr); -printf ("\nWarning: %s (eth%d) using random MAC address - %pM\n" , - dev->name, dev->seq, pdata->enetaddr); +if (show_warnings) +printf ("\nWarning: %s (eth%d) using random MAC address - %pM\n" , + dev->name, dev->seq, pdata->enetaddr);#else -printf ("\nError: %s address not set.\n" , - dev->name); +if (show_warnings) +printf ("\nError: %s address not set.\n" , dev->name);return -EINVAL ;#endif }
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 21/126 sandbox: net: Suppress the MAC-address warnings
Quoted 19 lines · Simon Glass
These warnings appear every thing sandbox is run (see below) and dwarf the actual useful output. Suppress them.
Hopefully at some point a way can be found to fix the root cause.
U-Boot 2019.10-rc2
Model: sandbox DRAM: 128 MiBWarning:
host_loMAC addresses don't match:
Address in ROM is a6:28:b7:47:28:93
Address in environment is 00:00:11:22:33:44Warning:
host_enp5s0MAC addresses don't match:
Address in ROM is a6:28:b7:47:28:93
Address in environment is 00:00:11:22:33:45
Quoted 7 lines
Warning:
host_eth6using MAC address from ROMWarning:
host_docker0MAC addresses don't match:
Address in ROM is a6:28:b7:47:28:93
Address in environment is 00:00:11:22:33:46Warning:
host_docker_gwbridgeusing MAC address from ROM
I am not sure how to reproduce this. Joe, do you know anything?
Quoted 36 lines
Warning:
host_veth1118e68MAC addresses don't match:
Address in ROM is a6:28:b7:47:28:93
Address in environment is 00:00:11:22:33:47
WDT: Not found!
MMC:In: cros-ec-keyb Out: vidconsole Err: vidconsole Model: sandbox SCSI: Net: eth0: host_lo, eth1: host_enp5s0, eth2: host_eth6, eth3: host_docker0, eth4: host_docker_gwbridge, eth5: host_veth1118e68 Error: eth at 10002000 address not set., eth-1: eth at 10002000
Test 'pmc_base' not foundWarning:
host_loMAC addresses don't match:
Address in ROM is 2a:24:9a:31:90:f8
Address in environment is 00:00:11:22:33:44Warning:
host_enp5s0MAC addresses don't match:
Address in ROM is ce:23:d9:74:6f:6c
Address in environment is 00:00:11:22:33:45Warning:
host_eth6using MAC address from ROMWarning:
host_docker0MAC addresses don't match:
Address in ROM is ee:22:1c:3b:be:bc
Address in environment is 00:00:11:22:33:46Warning:
host_docker_gwbridgeusing MAC address from ROMWarning:
host_veth1118e68MAC addresses don't match:
Address in ROM is ae:20:9e:3d:a4:9f
Address in environment is 00:00:11:22:33:47
Quoted 6 lines
Signed-off-by Simon Glass <[email protected]>---
net/eth-uclass.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-)
Regards,
Bin
PATCH 21/126 sandbox: net: Suppress the MAC-address warnings
In reply to Simon GlassHi Simon,
Quoted 5 lines · Simon Glass
These warnings appear every thing sandbox is run (see below) and dwarf the actual useful output. Suppress them.
Hopefully at some point a way can be found to fix the root cause.
Does removing ethaddr env from SANDBOX_ETH_SETTINGS in sandbox.h fix this problem?
Quoted 57 lines
U-Boot 2019.10-rc2
Model: sandbox DRAM: 128 MiBWarning:
host_loMAC addresses don't match:
Address in ROM is a6:28:b7:47:28:93
Address in environment is 00:00:11:22:33:44Warning:
host_enp5s0MAC addresses don't match:
Address in ROM is a6:28:b7:47:28:93
Address in environment is 00:00:11:22:33:45Warning:
host_eth6using MAC address from ROMWarning:
host_docker0MAC addresses don't match:
Address in ROM is a6:28:b7:47:28:93
Address in environment is 00:00:11:22:33:46Warning:
host_docker_gwbridgeusing MAC address from ROMWarning:
host_veth1118e68MAC addresses don't match:
Address in ROM is a6:28:b7:47:28:93
Address in environment is 00:00:11:22:33:47
WDT: Not found!
MMC:In: cros-ec-keyb Out: vidconsole Err: vidconsole Model: sandbox SCSI: Net: eth0: host_lo, eth1: host_enp5s0, eth2: host_eth6, eth3: host_docker0, eth4: host_docker_gwbridge, eth5: host_veth1118e68 Error: eth at 10002000 address not set., eth-1: eth at 10002000
Test 'pmc_base' not foundWarning:
host_loMAC addresses don't match:
Address in ROM is 2a:24:9a:31:90:f8
Address in environment is 00:00:11:22:33:44Warning:
host_enp5s0MAC addresses don't match:
Address in ROM is ce:23:d9:74:6f:6c
Address in environment is 00:00:11:22:33:45Warning:
host_eth6using MAC address from ROMWarning:
host_docker0MAC addresses don't match:
Address in ROM is ee:22:1c:3b:be:bc
Address in environment is 00:00:11:22:33:46Warning:
host_docker_gwbridgeusing MAC address from ROMWarning:
host_veth1118e68MAC addresses don't match:
Address in ROM is ae:20:9e:3d:a4:9f
Address in environment is 00:00:11:22:33:47
Quoted 6 lines
Signed-off-by Simon Glass <[email protected]>---
net/eth-uclass.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-)
Regards,
Bin
PATCH 21/126 sandbox: net: Suppress the MAC-address warnings
Hi Simon,
Quoted 5 lines · Bin Meng
Hi Simon,
Quoted 1 line · Simon Glass
Quoted 7 lines
Quoted 4 lines
These warnings appear every thing sandbox is run (see below) and dwarf the actual useful output. Suppress them.
Hopefully at some point a way can be found to fix the root cause.
Does removing ethaddr env from
SANDBOX_ETH_SETTINGSinsandbox.hfix this problem?
I was able to reproduce this, and confirmed that removing ethaddr* envs from SANDBOX_ETH_SETTINGS in sandbox.h could fix the issue you were seeing.
Regards,
Bin
PATCH 21/126 sandbox: net: Suppress the MAC-address warnings
Hi Bin,
Quoted 12 lines · Bin Meng
Hi Simon,
Quoted 8 lines · Bin Meng
Hi Simon,
Quoted 4 lines · Simon Glass
These warnings appear every thing sandbox is run (see below) and dwarf the actual useful output. Suppress them.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Hopefully at some point a way can be found to fix the root cause.
Does removing ethaddr env from
SANDBOX_ETH_SETTINGSinsandbox.hfix this problem?I was able to reproduce this, and confirmed that removing ethaddr* envs from
SANDBOX_ETH_SETTINGSinsandbox.hcould fix the issue you were seeing.
While that fixes the issue, it also breaks the unit tests.
Quoted 6 lines
Regards,
Bin
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
PATCH 21/126 sandbox: net: Suppress the MAC-address warnings
Hi Joe,
Quoted 18 lines · Joe Hershberger
Hi Bin,
Quoted 14 lines · Bin Meng
Hi Simon,
Quoted 10 lines · Bin Meng
Hi Simon,
Quoted 5 lines · Simon Glass
These warnings appear every thing sandbox is run (see below) and dwarf the actual useful output. Suppress them.
Hopefully at some point a way can be found to fix the root cause.
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines
Does removing ethaddr env from
SANDBOX_ETH_SETTINGSinsandbox.hfix this problem?I was able to reproduce this, and confirmed that removing ethaddr* envs from
SANDBOX_ETH_SETTINGSinsandbox.hcould fix the issue you were seeing.While that fixes the issue, it also breaks the unit tests.
Yes, it fixes sandbox with "-D" but fails with "-T".
Regards,
Bin
PATCH 21/126 sandbox: net: Suppress the MAC-address warnings
Hi Bin,
Quoted 25 lines · Bin Meng
Hi Joe,
Quoted 21 lines · Joe Hershberger
Hi Bin,
Quoted 17 lines · Bin Meng
Hi Simon,
Quoted 12 lines · Bin Meng
Hi Simon,
Quoted 5 lines · Simon Glass
These warnings appear every thing sandbox is run (see below) and dwarf the actual useful output. Suppress them.
Hopefully at some point a way can be found to fix the root cause.
Does removing ethaddr env from
SANDBOX_ETH_SETTINGSinsandbox.hfix this problem?
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
I was able to reproduce this, and confirmed that removing ethaddr* envs from
SANDBOX_ETH_SETTINGSinsandbox.hcould fix the issue you were seeing.While that fixes the issue, it also breaks the unit tests.
Yes, it fixes sandbox with "-D" but fails with "-T".
Maybe we can make it work for both by removing them from the header, but then setting the needed ethaddr's in the unit tests.
-Joe
Quoted 6 lines
Regards,
Bin
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
PATCH 21/126 sandbox: net: Suppress the MAC-address warnings
Hi,
Quoted 33 lines · Joe Hershberger
Hi Bin,
Quoted 29 lines · Bin Meng
Hi Joe,
Quoted 25 lines · Joe Hershberger
Hi Bin,
Quoted 20 lines · Bin Meng
Hi Simon,
Quoted 5 lines · Bin Meng
Hi Simon,
Quoted 1 line · Simon Glass
Quoted 7 lines
Quoted 4 lines
These warnings appear every thing sandbox is run (see below) and dwarf the actual useful output. Suppress them.
Hopefully at some point a way can be found to fix the root cause.
Does removing ethaddr env from
SANDBOX_ETH_SETTINGSinsandbox.hfix this problem?I was able to reproduce this, and confirmed that removing ethaddr* envs from
SANDBOX_ETH_SETTINGSinsandbox.hcould fix the issue you were seeing.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
While that fixes the issue, it also breaks the unit tests.
Yes, it fixes sandbox with "-D" but fails with "-T".
Maybe we can make it work for both by removing them from the header, but then setting the needed ethaddr's in the unit tests.
It looks like I can get most of the way there with this change, but I still need to supress one warning.
Plus it breaks the tests, perhaps because the env vars are set after net is inited.
WIll send an updated patch.
Regards,
Simon
PATCH 22/126 sandbox: pci: Move pci_offset_to_barnum() to pci.h
In reply to Simon GlassThis function is useful in PCI emulators. More it into the header file to avoid duplicating it in other drivers.
---
drivers/misc/swap_case.c | 7 ++----- include/pci.h | 4 ++++ 2 files changed, 6 insertions(+), 5 deletions(-)
drivers/misc/swap_case.c +2 -5
@@ -24,9 +24,6 @@ struct swap_case_platdata {u32 bar[6 ]; }; -#define offset_to_barnum (offset) \ - (((offset) - PCI_BASE_ADDRESS_0) / sizeof(u32)) -enum {MEM_TEXT_SIZE =0x100 , };
@@ -144,7 +141,7 @@ static int sandbox_swap_case_read_config(struct udevice *emul, uint offset,int barnum;u32 *bar, result; - barnum =offset_to_barnum (offset); + barnum =pci_offset_to_barnum (offset); bar = &plat->bar[barnum]; result = *bar;
@@ -224,7 +221,7 @@ static int sandbox_swap_case_write_config(struct udevice *emul, uint offset,int barnum;u32 *bar; - barnum =offset_to_barnum (offset); + barnum =pci_offset_to_barnum (offset); bar = &plat->bar[barnum];debug ("w bar %d=%lx\n" , barnum, value);
include/pci.h +4 -0
@@ -215,6 +215,10 @@#define PCI_BASE_ADDRESS_IO_MASK (~0x03ULL)/* bit 1 is reserved if address_space = 1 */ +/* Convert a regsister address (e.g. PCI_BASE_ADDRESS_1) to a bar # (e.g. 1) */ +#define pci_offset_to_barnum (offset) \ + (((offset) - PCI_BASE_ADDRESS_0) / sizeof(u32)) +/* Header type 0 (normal devices) */ #define PCI_CARDBUS_CIS 0x28#define PCI_SUBSYSTEM_VENDOR_ID 0x2c
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 22/126 sandbox: pci: Move pci_offset_to_barnum() to pci.h
Quoted 11 lines · Simon Glass
This function is useful in PCI emulators. More it into the header file to avoid duplicating it in other drivers.
Signed-off-by Simon Glass <[email protected]>---
drivers/misc/swap_case.c | 7 ++----- include/pci.h | 4 ++++ 2 files changed, 6 insertions(+), 5 deletions(-)
PATCH 22/126 sandbox: pci: Move pci_offset_to_barnum() to pci.h
Quoted 9 lines · Bin Meng
Quoted 7 lines · Simon Glass
This function is useful in PCI emulators. More it into the header file to avoid duplicating it in other drivers.
Signed-off-by Simon Glass <[email protected]>---
Quoted 6 lines
Quoted 4 lines
drivers/misc/swap_case.c | 7 ++----- include/pci.h | 4 ++++ 2 files changed, 6 insertions(+), 5 deletions(-)Reviewed-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 23/126 sandbox: Add a -T flag to use the test device tree
In reply to Simon GlassU-Boot already supports using -D to indicate that it should use the normal device tree. It is sometimes useful to run with the test device tree, e.g. when running a test. Add a -T option for this along with some documentation.
It can be used like this:
/tmp/b/sandbox/u-boot -T -c "ut dm pci_busdev"
(this will use /tmp/b/sandbox/arch/sandbox/dts/test.dtb as the DT)
---
arch/sandbox/cpu/start.c | 25 +++++++++++++++++++++++++ doc/arch/sandbox.rst | 9 +++++++++ 2 files changed, 34 insertions(+)
arch/sandbox/cpu/start.c +25 -0
@@ -147,6 +147,31 @@ static int sandbox_cmdline_cb_default_fdt(struct sandbox_state *state,SANDBOX_CMDLINE_OPT_SHORT (default_fdt,'D' ,0 ,"Use the default u-boot.dtb control FDT in U-Boot directory" ); +static int sandbox_cmdline_cb_test_fdt (struct sandbox_state *state, +const char *arg) +{ +const char *fmt ="/arch/sandbox/dts/test.dtb" ; +char *p; +char *fname; +int len; + + len =strlen (state->argv[0 ]) +strlen (fmt) +1 ; + fname =os_malloc (len); +if (!fname) +return -ENOMEM ; +strcpy (fname, state->argv[0 ]); + p =strrchr (fname,'/' ); +if (!p) + p = fname +strlen (fname); + len -= p - fname; +snprintf (p, len, fmt, p); + state->fdt_fname = fname; + +return 0 ; +} +SANDBOX_CMDLINE_OPT_SHORT (test_fdt,'T' ,0 , +"Use the test.dtb control FDT in U-Boot directory" ); +static int sandbox_cmdline_cb_interactive (struct sandbox_state *state,const char *arg) {
doc/arch/sandbox.rst +9 -0
@@ -103,6 +103,8 @@ A device tree binary file can be provided with -d. If you edit the source (it is stored at arch/sandbox/dts/sandbox.dts) you must rebuild U-Boot to recreate the binary file. +To use the default device tree, use -D. To use the test device tree, use -T. + To execute commands directly, use the -c option. You can specify a single command, or multiple commands separated by a semicolon, as is normal in U-Boot. Be careful with quoting as the shell will normally process and
@@ -499,6 +501,13 @@ run natively on your board if desired (and enabled). To run all tests use "make check". +To run a single test in an existing sandbox build, you can use -T to use the +test device tree, and -c to select the test: + + /tmp/b/sandbox/u-boot -T -c "ut dm pci_busdev" + +This runs dm_test_pci_busdev() which is in test/dm/pci.c + Memory Map ----------
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 23/126 sandbox: Add a -T flag to use the test device tree
Quoted 10 lines · Simon Glass
U-Boot already supports using -D to indicate that it should use the normal device tree. It is sometimes useful to run with the test device tree, e.g. when running a test. Add a -T option for this along with some documentation.
It can be used like this:
/tmp/b/sandbox/u-boot-T -c "ut dmpci_busdev"
Quoted 9 lines
(this will use
/tmp/b/sandbox/arch/sandbox/dts/test.dtbas the DT)Signed-off-by Simon Glass <[email protected]>---
arch/sandbox/cpu/start.c | 25 +++++++++++++++++++++++++ doc/arch/sandbox.rst | 9 +++++++++ 2 files changed, 34 insertions(+)
PATCH 23/126 sandbox: Add a -T flag to use the test device tree
Quoted 17 lines · Bin Meng
Quoted 15 lines · Simon Glass
U-Boot already supports using -D to indicate that it should use the normal device tree. It is sometimes useful to run with the test device tree, e.g. when running a test. Add a -T option for this along with some documentation.
It can be used like this:
/tmp/b/sandbox/u-boot-T -c "ut dmpci_busdev"(this will use
/tmp/b/sandbox/arch/sandbox/dts/test.dtbas the DT)Signed-off-by Simon Glass <[email protected]>---
Quoted 7 lines
Quoted 4 lines
arch/sandbox/cpu/start.c | 25 +++++++++++++++++++++++++ doc/arch/sandbox.rst | 9 +++++++++ 2 files changed, 34 insertions(+)Reviewed-by Bin Meng <[email protected]>Tested-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 24/126 sandbox: pci: Increase the memory space
In reply to Simon GlassIncrease the memory space so we can support the p2sb bus which needs multiples of 1MB.
---
arch/sandbox/dts/test.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sandbox/dts/test.dts +1 -1
@@ -447,7 +447,7 @@ device_type = "pci"; #address-cells = <3>; #size-cells = <2>; - ranges = <0x02000000 0 0x10000000 0x10000000 0 0x2000 + ranges = <0x02000000 0 0x10000000 0x10000000 0 0x2000000 0x01000000 0 0x20000000 0x20000000 0 0x2000>; pci at 0,0 { compatible = "pci-generic";
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 24/126 sandbox: pci: Increase the memory space
Quoted 10 lines · Simon Glass
Increase the memory space so we can support the p2sb bus which needs multiples of 1MB.
Signed-off-by Simon Glass <[email protected]>---
arch/sandbox/dts/test.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
PATCH 24/126 sandbox: pci: Increase the memory space
Quoted 6 lines · Bin Meng
Quoted 4 lines · Simon Glass
Increase the memory space so we can support the p2sb bus which needs multiples of 1MB.
Quoted 8 lines
Quoted 6 lines
Signed-off-by Simon Glass <[email protected]>---
arch/sandbox/dts/test.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Reviewed-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 25/126 sandbox: Allow use of real I/O with readl(), etc.
In reply to Simon GlassAt present these functions are stubbed out. For more comprehensive testing with PCI devices it is useful to be able to fully emulate I/O access. Add simple implementations for these.
---
arch/sandbox/cpu/cpu.c | 51 ++++++++++++++++++++++++++++++++ arch/sandbox/include/asm/io.h | 27 +++++++++++------ arch/sandbox/include/asm/state.h | 1 + drivers/nvme/nvme.h | 4 +-- 4 files changed, 72 insertions(+), 11 deletions(-)
arch/sandbox/cpu/cpu.c +51 -0
@@ -225,6 +225,57 @@ phys_addr_t map_to_sysmem(const void *ptr)return mentry->tag; } +unsigned int sandbox_read (const void *addr,enum sandboxio_size_t size) +{ +struct sandbox_state *state =state_get_current (); + +if (!state->allow_memio) +return 0 ; + +switch (size) { +case SB_SIZE_8 : +return *(u8 *)addr; +case SB_SIZE_16 : +return *(u16 *)addr; +case SB_SIZE_32 : +return *(u32 *)addr; +case SB_SIZE_64 : +return *(u64 *)addr; + } + +return 0 ; +} + +void sandbox_write (void *addr,unsigned int val,enum sandboxio_size_t size) +{ +struct sandbox_state *state =state_get_current (); + +if (!state->allow_memio) +return ; + +switch (size) { +case SB_SIZE_8 : + *(u8 *)addr = val; +break ; +case SB_SIZE_16 : + *(u16 *)addr = val; +break ; +case SB_SIZE_32 : + *(u32 *)addr = val; +break ; +case SB_SIZE_64 : + *(u64 *)addr = val; +break ; + } +} + +void sandbox_set_enable_memio (bool enable) +{ +struct sandbox_state *state =state_get_current (); + + state->allow_memio = enable; +} +void sandbox_set_enable_pci_map (int enable) { enable_pci_map = enable;
arch/sandbox/include/asm/io.h +18 -9
@@ -6,6 +6,13 @@#ifndef __SANDBOX_ASM_IO_H#define __SANDBOX_ASM_IO_H +enum sandboxio_size_t { +SB_SIZE_8 , +SB_SIZE_16 , +SB_SIZE_32 , +SB_SIZE_64 , +}; +void *phys_to_virt (phys_addr_t paddr);#define phys_to_virt phys_to_virt
@@ -38,18 +45,20 @@ static inline void unmap_sysmem(const void *vaddr)/* Map from a pointer to our RAM buffer */ phys_addr_t map_to_sysmem (const void *ptr); -/* Define nops for sandbox I/O access */ -#define readb (addr) ((void)addr, 0) -#define readw (addr) ((void)addr, 0) -#define readl (addr) ((void)addr, 0) +unsigned int sandbox_read (const void *addr,enum sandboxio_size_t size); +void sandbox_write (void *addr,unsigned int val,enum sandboxio_size_t size); + +#define readb (addr) sandbox_read(addr, SB_SIZE_8) +#define readw (addr) sandbox_read(addr, SB_SIZE_16) +#define readl (addr) sandbox_read(addr, SB_SIZE_32)#ifdef CONFIG_SANDBOX64 -#define readq (addr) ((void)addr, 0) +#define readq (addr) sandbox_read(addr, SB_SIZE_64)#endif -#define writeb (v, addr) ((void)addr) -#define writew (v, addr) ((void)addr) -#define writel (v, addr) ((void)addr) +#define writeb (v, addr) sandbox_write(addr, v, SB_SIZE_8) +#define writew (v, addr) sandbox_write(addr, v, SB_SIZE_16) +#define writel (v, addr) sandbox_write(addr, v, SB_SIZE_32)#ifdef CONFIG_SANDBOX64 -#define writeq (v, addr) ((void)addr) +#define writeq (v, addr) sandbox_write(addr, v, SB_SIZE_64)#endif /*
arch/sandbox/include/asm/state.h +1 -0
@@ -102,6 +102,7 @@ struct sandbox_state {ulong next_tag;/* Next address tag to allocate */ struct list_head mapmem_head;/* struct sandbox_mapmem_entry */ bool hwspinlock;/* Hardware Spinlock status */ +bool allow_memio;/* Allow readl() etc. to work */ /* * This struct is getting large.
drivers/nvme/nvme.h +2 -2
@@ -536,7 +536,7 @@ struct nvme_completion {static inline u64 nvme_readq (__le64 volatile *regs) {#if BITS_PER_LONG ==64 -return readq (regs); +return readq ((__le64 *)regs);#else __u32 *ptr = (__u32 *)regs;u64 val_lo =readl (ptr);
@@ -549,7 +549,7 @@ static inline u64 nvme_readq(__le64 volatile *regs)static inline void nvme_writeq (const u64 val,__le64 volatile *regs) {#if BITS_PER_LONG ==64 -writeq (val, regs); +writeq (val, (__le64 *)regs);#else __u32 *ptr = (__u32 *)regs;u32 val_lo =lower_32_bits (val);
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 25/126 sandbox: Allow use of real I/O with readl(), etc.
Quoted 34 lines · Simon Glass
At present these functions are stubbed out. For more comprehensive testing with PCI devices it is useful to be able to fully emulate I/O access. Add simple implementations for these.
Signed-off-by Simon Glass <[email protected]>---
arch/sandbox/cpu/cpu.c | 51 ++++++++++++++++++++++++++++++++ arch/sandbox/include/asm/io.h | 27 +++++++++++------ arch/sandbox/include/asm/state.h | 1 + drivers/nvme/nvme.h | 4 +-- 4 files changed, 72 insertions(+), 11 deletions(-)arch/sandbox/cpu/cpu.c +12
-0@@ -225,6 +225,57 @@ phys_addr_t map_to_sysmem(const void *ptr)return mentry->tag; } +unsigned int sandbox_read (const void *addr,enum sandboxio_size_t size) +{ +struct sandbox_state *state =state_get_current (); + +if (!state->allow_memio) +return 0 ; + +switch (size) { +case SB_SIZE_8 : +return *(u8 *)addr; +case SB_SIZE_16 : +return *(u16 *)addr;
arch/sandbox/cpu/cpu.c phys_addr_t map_to_sysmem(const void *ptr) · line 249
Quoted 10 lines
arch/sandbox/cpu/cpu.c +10
-0+case SB_SIZE_32 : +return *(u32 *)addr; +case SB_SIZE_64 : +return *(u64 *)addr; + } + +return 0 ; +} + +void sandbox_write (void *addr,unsigned int val,enum sandboxio_size_t size)
const void *addr
Quoted 97 lines
arch/sandbox/cpu/cpu.c +29
-0+{ +struct sandbox_state *state =state_get_current (); + +if (!state->allow_memio) +return ; + +switch (size) { +case SB_SIZE_8 : + *(u8 *)addr = val; +break ; +case SB_SIZE_16 : + *(u16 *)addr = val; +break ; +case SB_SIZE_32 : + *(u32 *)addr = val; +break ; +case SB_SIZE_64 : + *(u64 *)addr = val; +break ; + } +} + +void sandbox_set_enable_memio (bool enable) +{ +struct sandbox_state *state =state_get_current (); + + state->allow_memio = enable; +} +void sandbox_set_enable_pci_map (int enable) { enable_pci_map = enable;arch/sandbox/include/asm/io.h +18
-9@@ -6,6 +6,13 @@#ifndef __SANDBOX_ASM_IO_H#define __SANDBOX_ASM_IO_H +enum sandboxio_size_t { +SB_SIZE_8 , +SB_SIZE_16 , +SB_SIZE_32 , +SB_SIZE_64 , +}; +void *phys_to_virt (phys_addr_t paddr);#define phys_to_virt phys_to_virt@@ -38,18 +45,20 @@ static inline void unmap_sysmem(const void *vaddr)/* Map from a pointer to our RAM buffer */ phys_addr_t map_to_sysmem (const void *ptr); -/* Define nops for sandbox I/O access */ -#define readb (addr) ((void)addr, 0) -#define readw (addr) ((void)addr, 0) -#define readl (addr) ((void)addr, 0) +unsigned int sandbox_read (const void *addr,enum sandboxio_size_t size); +void sandbox_write (void *addr,unsigned int val,enum sandboxio_size_t size); + +#define readb (addr) sandbox_read(addr, SB_SIZE_8) +#define readw (addr) sandbox_read(addr, SB_SIZE_16) +#define readl (addr) sandbox_read(addr, SB_SIZE_32)#ifdef CONFIG_SANDBOX64 -#define readq (addr) ((void)addr, 0) +#define readq (addr) sandbox_read(addr, SB_SIZE_64)#endif -#define writeb (v, addr) ((void)addr) -#define writew (v, addr) ((void)addr) -#define writel (v, addr) ((void)addr) +#define writeb (v, addr) sandbox_write(addr, v, SB_SIZE_8) +#define writew (v, addr) sandbox_write(addr, v, SB_SIZE_16) +#define writel (v, addr) sandbox_write(addr, v, SB_SIZE_32)#ifdef CONFIG_SANDBOX64 -#define writeq (v, addr) ((void)addr) +#define writeq (v, addr) sandbox_write(addr, v, SB_SIZE_64)#endif /* arch/sandbox/include/asm/state.h +1
-0@@ -102,6 +102,7 @@ struct sandbox_state {ulong next_tag;/* Next address tag to allocate */ struct list_head mapmem_head;/* struct sandbox_mapmem_entry */ bool hwspinlock;/* Hardware Spinlock status */ +bool allow_memio;/* Allow readl() etc. to work */ /* * This struct is getting large. drivers/nvme/nvme.h +0
-0
drivers/nvme/nvme.h struct nvme_completion { · line 539
Quoted 5 lines
drivers/nvme/nvme.h +1
-1@@ -536,7 +536,7 @@ struct nvme_completion {static inline u64 nvme_readq (__le64 volatile *regs) {#if BITS_PER_LONG ==64 -return readq (regs); +return readq ((__le64 *)regs);
This cast is not needed
drivers/nvme/nvme.h static inline u64 nvme_readq(__le64 volatile *regs) · line 552
Quoted 9 lines
drivers/nvme/nvme.h +1
-1#else __u32 *ptr = (__u32 *)regs;u64 val_lo =readl (ptr);@@ -549,7 +549,7 @@ static inline u64 nvme_readq(__le64 volatile *regs)static inline void nvme_writeq (const u64 val,__le64 volatile *regs) {#if BITS_PER_LONG ==64 -writeq (val, regs); +writeq (val, (__le64 *)regs);
Ditto
drivers/nvme/nvme.h static inline u64 nvme_readq(__le64 volatile *regs)
Quoted 4 lines
drivers/nvme/nvme.h +0
-1#else __u32 *ptr = (__u32 *)regs;u32 val_lo =lower_32_bits (val); --
Other than above,
PATCH 25/126 sandbox: Allow use of real I/O with readl(), etc.
Quoted 40 lines · Bin Meng
Quoted 38 lines · Simon Glass
At present these functions are stubbed out. For more comprehensive testing with PCI devices it is useful to be able to fully emulate I/O access. Add simple implementations for these.
Signed-off-by Simon Glass <[email protected]>---
arch/sandbox/cpu/cpu.c | 51 ++++++++++++++++++++++++++++++++ arch/sandbox/include/asm/io.h | 27 +++++++++++------ arch/sandbox/include/asm/state.h | 1 + drivers/nvme/nvme.h | 4 +-- 4 files changed, 72 insertions(+), 11 deletions(-)arch/sandbox/cpu/cpu.c +16
-0@@ -225,6 +225,57 @@ phys_addr_t map_to_sysmem(const void *ptr)return mentry->tag; } +unsigned int sandbox_read (const void *addr,enum sandboxio_size_t size) +{ +struct sandbox_state *state =state_get_current (); + +if (!state->allow_memio) +return 0 ; + +switch (size) { +case SB_SIZE_8 : +return *(u8 *)addr; +case SB_SIZE_16 : +return *(u16 *)addr; +case SB_SIZE_32 : +return *(u32 *)addr; +case SB_SIZE_64 : +return *(u64 *)addr;
Quoted 8 lines
arch/sandbox/cpu/cpu.c phys_addr_t map_to_sysmem(const void *ptr) · line 249
Quoted 6 lines
arch/sandbox/cpu/cpu.c +6
-0+ } + +return 0 ; +} + +void sandbox_write (void *addr,unsigned int val,enum sandboxio_size_t size)const void *addr
Fixed this, and
Quoted 91 lines
Quoted 91 lines
arch/sandbox/cpu/cpu.c +29
-0+{ +struct sandbox_state *state =state_get_current (); + +if (!state->allow_memio) +return ; + +switch (size) { +case SB_SIZE_8 : + *(u8 *)addr = val; +break ; +case SB_SIZE_16 : + *(u16 *)addr = val; +break ; +case SB_SIZE_32 : + *(u32 *)addr = val; +break ; +case SB_SIZE_64 : + *(u64 *)addr = val; +break ; + } +} + +void sandbox_set_enable_memio (bool enable) +{ +struct sandbox_state *state =state_get_current (); + + state->allow_memio = enable; +} +void sandbox_set_enable_pci_map (int enable) { enable_pci_map = enable;arch/sandbox/include/asm/io.h +18
-9@@ -6,6 +6,13 @@#ifndef __SANDBOX_ASM_IO_H#define __SANDBOX_ASM_IO_H +enum sandboxio_size_t { +SB_SIZE_8 , +SB_SIZE_16 , +SB_SIZE_32 , +SB_SIZE_64 , +}; +void *phys_to_virt (phys_addr_t paddr);#define phys_to_virt phys_to_virt@@ -38,18 +45,20 @@ static inline void unmap_sysmem(const void *vaddr)/* Map from a pointer to our RAM buffer */ phys_addr_t map_to_sysmem (const void *ptr); -/* Define nops for sandbox I/O access */ -#define readb (addr) ((void)addr, 0) -#define readw (addr) ((void)addr, 0) -#define readl (addr) ((void)addr, 0) +unsigned int sandbox_read (const void *addr,enum sandboxio_size_t size); +void sandbox_write (void *addr,unsigned int val,enum sandboxio_size_t size); + +#define readb (addr) sandbox_read(addr, SB_SIZE_8) +#define readw (addr) sandbox_read(addr, SB_SIZE_16) +#define readl (addr) sandbox_read(addr, SB_SIZE_32)#ifdef CONFIG_SANDBOX64 -#define readq (addr) ((void)addr, 0) +#define readq (addr) sandbox_read(addr, SB_SIZE_64)#endif -#define writeb (v, addr) ((void)addr) -#define writew (v, addr) ((void)addr) -#define writel (v, addr) ((void)addr) +#define writeb (v, addr) sandbox_write(addr, v, SB_SIZE_8) +#define writew (v, addr) sandbox_write(addr, v, SB_SIZE_16) +#define writel (v, addr) sandbox_write(addr, v, SB_SIZE_32)#ifdef CONFIG_SANDBOX64 -#define writeq (v, addr) ((void)addr) +#define writeq (v, addr) sandbox_write(addr, v, SB_SIZE_64)#endif /* arch/sandbox/include/asm/state.h +1
-0@@ -102,6 +102,7 @@ struct sandbox_state {ulong next_tag;/* Next address tag to allocate */ struct list_head mapmem_head;/* struct sandbox_mapmem_entry */ bool hwspinlock;/* Hardware Spinlock status */ +bool allow_memio;/* Allow readl() etc. to work */
Quoted 14 lines
drivers/nvme/nvme.h struct nvme_completion { · line 539
Quoted 12 lines
arch/sandbox/include/asm/state.h +0
-0/* * This struct is getting large. drivers/nvme/nvme.h +1
-1@@ -536,7 +536,7 @@ struct nvme_completion {static inline u64 nvme_readq (__le64 volatile *regs) {#if BITS_PER_LONG ==64 -return readq (regs); +return readq ((__le64 *)regs);This cast is not needed
Removed the cast, and
Quoted 18 lines
drivers/nvme/nvme.h static inline u64 nvme_readq(__le64 volatile *regs) · line 552
Quoted 10 lines
drivers/nvme/nvme.h +1
-1#else __u32 *ptr = (__u32 *)regs;u64 val_lo =readl (ptr);@@ -549,7 +549,7 @@ static inline u64 nvme_readq(__le64 volatile *regs)static inline void nvme_writeq (const u64 val,__le64 volatile *regs) {#if BITS_PER_LONG ==64 -writeq (val, regs); +writeq (val, (__le64 *)regs);Ditto
drivers/nvme/nvme.h static inline u64 nvme_readq(__le64 volatile *regs)
Quoted 4 lines
drivers/nvme/nvme.h +0
-1#else __u32 *ptr = (__u32 *)regs;u32 val_lo =lower_32_bits (val); --
Quoted 4 lines
Other than above,
Reviewed-by Bin Meng <[email protected]>Tested-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 25/126 sandbox: Allow use of real I/O with readl(), etc.
Quoted 159 lines · Bin Meng
Quoted 40 lines · Bin Meng
Quoted 38 lines · Simon Glass
At present these functions are stubbed out. For more comprehensive testing with PCI devices it is useful to be able to fully emulate I/O access. Add simple implementations for these.
Signed-off-by Simon Glass <[email protected]>---
arch/sandbox/cpu/cpu.c | 51 ++++++++++++++++++++++++++++++++ arch/sandbox/include/asm/io.h | 27 +++++++++++------ arch/sandbox/include/asm/state.h | 1 + drivers/nvme/nvme.h | 4 +-- 4 files changed, 72 insertions(+), 11 deletions(-)arch/sandbox/cpu/cpu.c +16
-0@@ -225,6 +225,57 @@ phys_addr_t map_to_sysmem(const void *ptr)return mentry->tag; } +unsigned int sandbox_read (const void *addr,enum sandboxio_size_t size) +{ +struct sandbox_state *state =state_get_current (); + +if (!state->allow_memio) +return 0 ; + +switch (size) { +case SB_SIZE_8 : +return *(u8 *)addr; +case SB_SIZE_16 : +return *(u16 *)addr; +case SB_SIZE_32 : +return *(u32 *)addr; +case SB_SIZE_64 : +return *(u64 *)addr;Quoted 8 lines
arch/sandbox/cpu/cpu.c phys_addr_t map_to_sysmem(const void *ptr) · line 249
Quoted 6 lines
arch/sandbox/cpu/cpu.c +6
-0+ } + +return 0 ; +} + +void sandbox_write (void *addr,unsigned int val,enum sandboxio_size_t size)const void *addr
Fixed this, and
Quoted 91 lines
Quoted 91 lines
arch/sandbox/cpu/cpu.c +29
-0+{ +struct sandbox_state *state =state_get_current (); + +if (!state->allow_memio) +return ; + +switch (size) { +case SB_SIZE_8 : + *(u8 *)addr = val; +break ; +case SB_SIZE_16 : + *(u16 *)addr = val; +break ; +case SB_SIZE_32 : + *(u32 *)addr = val; +break ; +case SB_SIZE_64 : + *(u64 *)addr = val; +break ; + } +} + +void sandbox_set_enable_memio (bool enable) +{ +struct sandbox_state *state =state_get_current (); + + state->allow_memio = enable; +} +void sandbox_set_enable_pci_map (int enable) { enable_pci_map = enable;arch/sandbox/include/asm/io.h +18
-9@@ -6,6 +6,13 @@#ifndef __SANDBOX_ASM_IO_H#define __SANDBOX_ASM_IO_H +enum sandboxio_size_t { +SB_SIZE_8 , +SB_SIZE_16 , +SB_SIZE_32 , +SB_SIZE_64 , +}; +void *phys_to_virt (phys_addr_t paddr);#define phys_to_virt phys_to_virt@@ -38,18 +45,20 @@ static inline void unmap_sysmem(const void *vaddr)/* Map from a pointer to our RAM buffer */ phys_addr_t map_to_sysmem (const void *ptr); -/* Define nops for sandbox I/O access */ -#define readb (addr) ((void)addr, 0) -#define readw (addr) ((void)addr, 0) -#define readl (addr) ((void)addr, 0) +unsigned int sandbox_read (const void *addr,enum sandboxio_size_t size); +void sandbox_write (void *addr,unsigned int val,enum sandboxio_size_t size); + +#define readb (addr) sandbox_read(addr, SB_SIZE_8) +#define readw (addr) sandbox_read(addr, SB_SIZE_16) +#define readl (addr) sandbox_read(addr, SB_SIZE_32)#ifdef CONFIG_SANDBOX64 -#define readq (addr) ((void)addr, 0) +#define readq (addr) sandbox_read(addr, SB_SIZE_64)#endif -#define writeb (v, addr) ((void)addr) -#define writew (v, addr) ((void)addr) -#define writel (v, addr) ((void)addr) +#define writeb (v, addr) sandbox_write(addr, v, SB_SIZE_8) +#define writew (v, addr) sandbox_write(addr, v, SB_SIZE_16) +#define writel (v, addr) sandbox_write(addr, v, SB_SIZE_32)#ifdef CONFIG_SANDBOX64 -#define writeq (v, addr) ((void)addr) +#define writeq (v, addr) sandbox_write(addr, v, SB_SIZE_64)#endif /* arch/sandbox/include/asm/state.h +1
-0@@ -102,6 +102,7 @@ struct sandbox_state {ulong next_tag;/* Next address tag to allocate */ struct list_head mapmem_head;/* struct sandbox_mapmem_entry */ bool hwspinlock;/* Hardware Spinlock status */ +bool allow_memio;/* Allow readl() etc. to work */ Quoted 14 lines
drivers/nvme/nvme.h struct nvme_completion { · line 539
Quoted 12 lines
arch/sandbox/include/asm/state.h +0
-0/* * This struct is getting large. drivers/nvme/nvme.h +1
-1@@ -536,7 +536,7 @@ struct nvme_completion {static inline u64 nvme_readq (__le64 volatile *regs) {#if BITS_PER_LONG ==64 -return readq (regs); +return readq ((__le64 *)regs);This cast is not needed
Quoted 1 line
Removed the cast, and
So it turns out the cast here was to eliminate the build warnings for sandbox64_defconfig. However, we really should fix the build warning by do the cast in the arch/sandbox/include/asm/io.h below, instead of touching nvme.h:
arch/sandbox/include/asm/io.h +0 -0
@@ -49,17 +49,17 @@ unsigned int sandbox_read(const void *addr, enum
sandboxio_size_t size);
void sandbox_write(const void *addr, unsigned int val,
enum sandboxio_size_t size);
-#define readb(addr) sandbox_read(addr, SB_SIZE_8)
-#define readw(addr) sandbox_read(addr, SB_SIZE_16)
-#define readl(addr) sandbox_read(addr, SB_SIZE_32)
+#define readb(addr) sandbox_read((const void *)addr, SB_SIZE_8) +#define readw(addr) sandbox_read((const void *)addr, SB_SIZE_16) +#define readl(addr) sandbox_read((const void *)addr, SB_SIZE_32)
#ifdef CONFIG_SANDBOX64
-#define readq(addr) sandbox_read(addr, SB_SIZE_64)
+#define readq(addr) sandbox_read((const void *)addr, SB_SIZE_64)
#endif
-#define writeb(v, addr) sandbox_write(addr, v, SB_SIZE_8) -#define writew(v, addr) sandbox_write(addr, v, SB_SIZE_16) -#define writel(v, addr) sandbox_write(addr, v, SB_SIZE_32) +#define writeb(v, addr) sandbox_write((const void *)addr, v, SB_SIZE_8) +#define writew(v, addr) sandbox_write((const void *)addr, v, SB_SIZE_16) +#define writel(v, addr) sandbox_write((const void *)addr, v, SB_SIZE_32)
#ifdef CONFIG_SANDBOX64
-#define writeq(v, addr) sandbox_write(addr, v, SB_SIZE_64) +#define writeq(v, addr) sandbox_write((const void *)addr, v, SB_SIZE_64)
#endif
Applied the above fix to the same commit, and now in u-boot-x86/next.
Regards,
Bin
PATCH 26/126 pci: sandbox: Move the emulators into their own node
In reply to Simon GlassSandbox i2c works using emulation drivers which are currently children of the i2c device:
pci-controller {
pci at 1f,0 {
compatible = "pci-generic";
reg = <0xf800 0 0 0 0>;
emul at 1f,0 {
compatible = "sandbox,swap-case";
};
};
};In this case the emulation device is attached to pci device on address f800 (device 1f, function 0) and provides the swap-case functionality.
However this is not ideal, since every device on a PCI bus has a child device. This is only really the case for sandbox, but we want to avoid special-case code for sandbox.
Worse, child devices cannot be probed before their parents. This forces us to use 'find' rather than 'get' to obtain the emulator device. In fact the emulator devices are never probed. There is code in sandbox_pci_emul_post_probe() which tries to track when emulators are active, but at present this does not work.
A better approach seems to be to add a separate node elsewhere in the device tree, an 'emulation parent'. This could be given a bogus address (such as -1) to hide the emulators away from the 'pci' command, but it seems better to keep it at the root node to avoid such hacks.
Then we can use a phandle to point from the evice to the correct emulator, and only on sandbox. The code to find an emulator does not interfere with normal pci operation.
Add a new UCLASS_PCI_EMUL_PARENT uclass which allows finding an emulator given a bus, and finding a bus given an emulator. Update the existing device trees and the code for finding an emulator.
This brings PCI emulators more into line with I2C.
---
arch/sandbox/dts/sandbox.dtsi | 11 +++++++--- arch/sandbox/dts/test.dts | 38 +++++++++++++++++++++++------------ doc/driver-model/pci-info.rst | 23 +++++++++++---------- drivers/pci/pci-emul-uclass.c | 37 ++++++++++++++++++++++++++++------ include/dm/uclass-id.h | 1 + 5 files changed, 77 insertions(+), 33 deletions(-)
arch/sandbox/dts/sandbox.dtsi +8 -3
@@ -103,9 +103,14 @@ pci at 1f,0 { compatible = "pci-generic"; reg = <0xf800 0 0 0 0>; - emul at 1f,0 { - compatible = "sandbox,swap-case"; - }; + sandbox,emul = <&swap_case_emul>; + }; + }; + + emul { + compatible = "sandbox,pci-emul-parent"; + swap_case_emul: emul at 1f,0 { + compatible = "sandbox,swap-case"; }; };
arch/sandbox/dts/test.dts +25 -13
@@ -452,24 +452,31 @@ pci at 0,0 { compatible = "pci-generic"; reg = <0x0000 0 0 0 0>; - emul at 0,0 { - compatible = "sandbox,swap-case"; - }; + sandbox,emul = <&swap_case_emul0>; }; pci at 1,0 { compatible = "pci-generic"; reg = <0x0800 0 0 0 0>; - emul at 0,0 { - compatible = "sandbox,swap-case"; - use-ea; - }; + sandbox,emul = <&swap_case_emul1>; }; pci at 1f,0 { compatible = "pci-generic"; reg = <0xf800 0 0 0 0>; - emul at 1f,0 { - compatible = "sandbox,swap-case"; - }; + sandbox,emul = <&swap_case_emul1f>; + }; + }; + + pci-emul0 { + compatible = "sandbox,pci-emul-parent"; + swap_case_emul0: emul at 0,0 { + compatible = "sandbox,swap-case"; + }; + swap_case_emul1: emul at 1,0 { + compatible = "sandbox,swap-case"; + use-ea; + }; + swap_case_emul1f: emul at 1f,0 { + compatible = "sandbox,swap-case"; }; };
@@ -499,9 +506,14 @@ pci at 1f,0 { compatible = "pci-generic"; reg = <0xf800 0 0 0 0>; - emul at 1f,0 { - compatible = "sandbox,swap-case"; - }; + sandbox,emul = <&swap_case_emul2_1f>; + }; + }; + + pci-emul2 { + compatible = "sandbox,pci-emul-parent"; + swap_case_emul2_1f: emul2 at 1f,0 { + compatible = "sandbox,swap-case"; }; };
doc/driver-model/pci-info.rst +12 -11
@@ -113,14 +113,17 @@ Sandbox ------- With sandbox we need a device emulator for each device on the bus since there -is no real PCI bus. This works by looking in the device tree node for a -driver. For example:: - +is no real PCI bus. This works by looking in the device tree node for an +emulator driver. For example:: pci at 1f,0 { compatible = "pci-generic"; reg = <0xf800 0 0 0 0>; - emul at 1f,0 { + sandbox,emul = <&emul_1f>; + }; + pci-emul { + compatible = "sandbox,pci-emul-parent"; + emul_1f: emul at 1f,0 { compatible = "sandbox,swap-case"; }; };
@@ -130,14 +133,16 @@ Note that the first cell in the 'reg' value is the bus/device/function. See PCI_BDF() for the encoding (it is also specified in the IEEE Std 1275-1994 PCI bus binding document, v2.1) +The pci-emul node should go outside the pci bus node, since otherwise it will +be scanned as a PCI device, causing confusion. + When this bus is scanned we will end up with something like this:: `- * pci-controller @ 05c660c8, 0 `- pci at 1f,0 @ 05c661c8, 63488 - `- emul at 1f,0 @ 05c662c8 + `- emul at 1f,0 @ 05c662c8 -When accesses go to the pci at 1f,0 device they are forwarded to its child, the -emulator. +When accesses go to the pci at 1f,0 device they are forwarded to its emulator. The sandbox PCI drivers also support dynamic driver binding, allowing device driver to declare the driver binding information via U_BOOT_PCI_DEVICE(),
@@ -164,7 +169,3 @@ When this bus is scanned we will end up with something like this:: pci [ + ] pci_sandbo |-- pci-controller1 pci_emul [ ] sandbox_sw | |-- sandbox_swap_case_emul pci_emul [ ] sandbox_sw | `-- sandbox_swap_case_emul - -Note the difference from the statically declared device nodes is that the -device is directly attached to the host controller, instead of via a container -device like pci at 1f,0.
drivers/pci/pci-emul-uclass.c +31 -6
@@ -10,6 +10,7 @@#include <linux/libfdt.h> #include <pci.h> #include <dm/lists.h> +#include <dm/uclass-internal.h> struct sandbox_pci_emul_priv {int dev_count;
@@ -30,13 +31,15 @@ int sandbox_pci_get_emul(struct udevice *bus, pci_dev_t find_devfn, } *containerp = dev; -if (device_get_uclass_id (dev) ==UCLASS_PCI_GENERIC ) { - ret =device_find_first_child (dev, emulp); -if (ret) -return ret; - }else { +/* +* TODO(sjg at chromium.org): This code needs a comment as I'm not sure +* why UCLASS_PCI_GENERIC devices end up being their own emulators. I +* left this code as is. +*/ + ret =uclass_find_device_by_phandle (UCLASS_PCI_EMUL , dev, +"sandbox,emul" , emulp); +if (ret &&device_get_uclass_id (dev) !=UCLASS_PCI_GENERIC ) *emulp = dev; - }return *emulp ?0 : -ENODEV ; }
@@ -68,3 +71,25 @@ UCLASS_DRIVER(pci_emul) = { .pre_remove = sandbox_pci_emul_pre_remove, .priv_auto_alloc_size = sizeof(struct sandbox_pci_emul_priv), }; + +/* +* This uclass is a child of the pci bus. Its platdata is not defined here so +* is defined by its parent, UCLASS_PCI, which uses struct pci_child_platdata. +* See per_child_platdata_auto_alloc_size in UCLASS_DRIVER(pci). +*/ +UCLASS_DRIVER (pci_emul_parent) = { + .id =UCLASS_PCI_EMUL_PARENT , + .name ="pci_emul_parent" , + .post_bind = dm_scan_fdt_dev, +}; + +static const struct udevice_id pci_emul_parent_ids[] = { + { .compatible ="sandbox,pci-emul-parent" }, + { } +}; + +U_BOOT_DRIVER (pci_emul_parent_drv) = { + .name ="pci_emul_parent_drv" , + .id =UCLASS_PCI_EMUL_PARENT , + .of_match = pci_emul_parent_ids, +};
include/dm/uclass-id.h +1 -0
@@ -23,6 +23,7 @@ enum uclass_id {UCLASS_I2C_EMUL ,/* sandbox I2C device emulator */ UCLASS_I2C_EMUL_PARENT ,/* parent for I2C device emulators */ UCLASS_PCI_EMUL ,/* sandbox PCI device emulator */ +UCLASS_PCI_EMUL_PARENT ,/* parent for PCI device emulators */ UCLASS_USB_EMUL ,/* sandbox USB bus device emulator */ UCLASS_AXI_EMUL, /* sandbox AXI bus device emulator */
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 26/126 pci: sandbox: Move the emulators into their own node
Quoted 2 lines · Simon Glass
Sandbox i2c works using emulation drivers which are currently children of
pci
Quoted 1 line
the i2c device:
pci
Quoted 24 lines
pci-controller { pci at 1f,0 { compatible = "pci-generic"; reg = <0xf800 0 0 0 0>; emul at 1f,0 { compatible = "sandbox,swap-case"; }; }; };In this case the emulation device is attached to pci device on address f800 (device 1f, function 0) and provides the swap-case functionality.
However this is not ideal, since every device on a PCI bus has a child device. This is only really the case for sandbox, but we want to avoid special-case code for sandbox.
Worse, child devices cannot be probed before their parents. This forces us to use 'find' rather than 'get' to obtain the emulator device. In fact the emulator devices are never probed. There is code in
sandbox_pci_emul_post_probe()which tries to track when emulators are active, but at present this does not work.
Quoted 6 lines
A better approach seems to be to add a separate node elsewhere in the device tree, an 'emulation parent'. This could be given a bogus address (such as -1) to hide the emulators away from the 'pci' command, but it seems better to keep it at the root node to avoid such hacks.
Then we can use a phandle to point from the evice to the correct
typo: device
Quoted 46 lines
emulator, and only on sandbox. The code to find an emulator does not interfere with normal pci operation.
Add a new
UCLASS_PCI_EMUL_PARENTuclass which allows finding an emulator given a bus, and finding a bus given an emulator. Update the existing device trees and the code for finding an emulator.This brings PCI emulators more into line with I2C.
Signed-off-by Simon Glass <[email protected]>---
arch/sandbox/dts/sandbox.dtsi | 11 +++++++--- arch/sandbox/dts/test.dts | 38 +++++++++++++++++++++++------------ doc/driver-model/pci-info.rst | 23 +++++++++++---------- drivers/pci/pci-emul-uclass.c | 37 ++++++++++++++++++++++++++++------ include/dm/uclass-id.h | 1 + 5 files changed, 77 insertions(+), 33 deletions(-)arch/sandbox/dts/sandbox.dtsi +8
-3@@ -103,9 +103,14 @@ pci at 1f,0 { compatible = "pci-generic"; reg = <0xf800 0 0 0 0>; - emul at 1f,0 { - compatible = "sandbox,swap-case"; - }; + sandbox,emul = <&swap_case_emul>; + }; + }; + + emul { + compatible = "sandbox,pci-emul-parent"; + swap_case_emul: emul at 1f,0 { + compatible = "sandbox,swap-case"; }; };arch/sandbox/dts/test.dts +0
-0
arch/sandbox/dts/test.dts line 455
Quoted 7 lines
arch/sandbox/dts/test.dts +1
-3@@ -452,24 +452,31 @@ pci at 0,0 { compatible = "pci-generic"; reg = <0x0000 0 0 0 0>; - emul at 0,0 { - compatible = "sandbox,swap-case"; - }; + sandbox,emul = <&swap_case_emul0>;
&swap_case_emul0_0
arch/sandbox/dts/test.dts line 460
Quoted 9 lines
arch/sandbox/dts/test.dts +1
-4}; pci at 1,0 { compatible = "pci-generic"; reg = <0x0800 0 0 0 0>; - emul at 0,0 { - compatible = "sandbox,swap-case"; - use-ea; - }; + sandbox,emul = <&swap_case_emul1>;
&swap_case_emul0_1
arch/sandbox/dts/test.dts line 465
Quoted 8 lines
arch/sandbox/dts/test.dts +1
-3}; pci at 1f,0 { compatible = "pci-generic"; reg = <0xf800 0 0 0 0>; - emul at 1f,0 { - compatible = "sandbox,swap-case"; - }; + sandbox,emul = <&swap_case_emul1f>;
&swap_case_emul0_1f
Quoted 105 lines
arch/sandbox/dts/test.dts +22
-3+ }; + }; + + pci-emul0 { + compatible = "sandbox,pci-emul-parent"; + swap_case_emul0: emul at 0,0 { + compatible = "sandbox,swap-case"; + }; + swap_case_emul1: emul at 1,0 { + compatible = "sandbox,swap-case"; + use-ea; + }; + swap_case_emul1f: emul at 1f,0 { + compatible = "sandbox,swap-case"; }; };@@ -499,9 +506,14 @@ pci at 1f,0 { compatible = "pci-generic"; reg = <0xf800 0 0 0 0>; - emul at 1f,0 { - compatible = "sandbox,swap-case"; - }; + sandbox,emul = <&swap_case_emul2_1f>; + }; + }; + + pci-emul2 { + compatible = "sandbox,pci-emul-parent"; + swap_case_emul2_1f: emul2 at 1f,0 { + compatible = "sandbox,swap-case"; }; };doc/driver-model/pci-info.rst +12
-11@@ -113,14 +113,17 @@ Sandbox ------- With sandbox we need a device emulator for each device on the bus since there -is no real PCI bus. This works by looking in the device tree node for a -driver. For example:: - +is no real PCI bus. This works by looking in the device tree node for an +emulator driver. For example:: pci at 1f,0 { compatible = "pci-generic"; reg = <0xf800 0 0 0 0>; - emul at 1f,0 { + sandbox,emul = <&emul_1f>; + }; + pci-emul { + compatible = "sandbox,pci-emul-parent"; + emul_1f: emul at 1f,0 { compatible = "sandbox,swap-case"; }; };@@ -130,14 +133,16 @@ Note that the first cell in the 'reg' value is the bus/device/function. See PCI_BDF() for the encoding (it is also specified in the IEEE Std 1275-1994 PCI bus binding document, v2.1) +The pci-emul node should go outside the pci bus node, since otherwise it will +be scanned as a PCI device, causing confusion. + When this bus is scanned we will end up with something like this:: `- * pci-controller @ 05c660c8, 0 `- pci at 1f,0 @ 05c661c8, 63488 - `- emul at 1f,0 @ 05c662c8 + `- emul at 1f,0 @ 05c662c8 -When accesses go to the pci at 1f,0 device they are forwarded to its child, the -emulator. +When accesses go to the pci at 1f,0 device they are forwarded to its emulator. The sandbox PCI drivers also support dynamic driver binding, allowing device driver to declare the driver binding information via U_BOOT_PCI_DEVICE(),@@ -164,7 +169,3 @@ When this bus is scanned we will end up with something like this:: pci [ + ] pci_sandbo |-- pci-controller1 pci_emul [ ] sandbox_sw | |-- sandbox_swap_case_emul pci_emul [ ] sandbox_sw | `-- sandbox_swap_case_emul - -Note the difference from the statically declared device nodes is that the -device is directly attached to the host controller, instead of via a container -device like pci at 1f,0.drivers/pci/pci-emul-uclass.c +1
-0@@ -10,6 +10,7 @@#include <linux/libfdt.h> #include <pci.h> #include <dm/lists.h> +#include <dm/uclass-internal.h> struct sandbox_pci_emul_priv {int dev_count;@@ -30,13 +31,15 @@ int sandbox_pci_get_emul(struct udevice *bus, pci_dev_t find_devfn, } *containerp = dev;
drivers/pci/pci-emul-uclass.c int sandbox_pci_get_emul(struct udevice *bus, pci_dev_t find_devfn, · line 38
Quoted 10 lines
drivers/pci/pci-emul-uclass.c +5
-5-if (device_get_uclass_id (dev) ==UCLASS_PCI_GENERIC ) { - ret =device_find_first_child (dev, emulp); -if (ret) -return ret; - }else { +/* +* TODO(sjg at chromium.org): This code needs a comment as I'm not sure +* why UCLASS_PCI_GENERIC devices end up being their own emulators. I +* left this code as is. +*/
This code comes from:
commit 4345998ae9dfad7ba0beb54ad4322134557504a9
Author: Bin Meng <[email protected]> Date: Fri Aug 3 01:14:45 2018 -0700
pci: sandbox: Support dynamically binding device driver
I think the comments can be removed :)
Quoted 39 lines
drivers/pci/pci-emul-uclass.c +25
-1+ ret =uclass_find_device_by_phandle (UCLASS_PCI_EMUL , dev, +"sandbox,emul" , emulp); +if (ret &&device_get_uclass_id (dev) !=UCLASS_PCI_GENERIC ) *emulp = dev; - }return *emulp ?0 : -ENODEV ; }@@ -68,3 +71,25 @@ UCLASS_DRIVER(pci_emul) = { .pre_remove = sandbox_pci_emul_pre_remove, .priv_auto_alloc_size = sizeof(struct sandbox_pci_emul_priv), }; + +/* +* This uclass is a child of the pci bus. Its platdata is not defined here so +* is defined by its parent, UCLASS_PCI, which uses struct pci_child_platdata. +* See per_child_platdata_auto_alloc_size in UCLASS_DRIVER(pci). +*/ +UCLASS_DRIVER (pci_emul_parent) = { + .id =UCLASS_PCI_EMUL_PARENT , + .name ="pci_emul_parent" , + .post_bind = dm_scan_fdt_dev, +}; + +static const struct udevice_id pci_emul_parent_ids[] = { + { .compatible ="sandbox,pci-emul-parent" }, + { } +}; + +U_BOOT_DRIVER (pci_emul_parent_drv) = { + .name ="pci_emul_parent_drv" , + .id =UCLASS_PCI_EMUL_PARENT , + .of_match = pci_emul_parent_ids, +};include/dm/uclass-id.h +0
-0
include/dm/uclass-id.h enum uclass_id {
Quoted 8 lines
include/dm/uclass-id.h +1
-1@@ -23,6 +23,7 @@ enum uclass_id {UCLASS_I2C_EMUL ,/* sandbox I2C device emulator */ UCLASS_I2C_EMUL_PARENT ,/* parent for I2C device emulators */ UCLASS_PCI_EMUL ,/* sandbox PCI device emulator */ +UCLASS_PCI_EMUL_PARENT ,/* parent for PCI device emulators */ UCLASS_USB_EMUL ,/* sandbox USB bus device emulator */ UCLASS_AXI_EMUL, /* sandbox AXI bus device emulator */ --
Other than the issues above,
PATCH 26/126 pci: sandbox: Move the emulators into their own node
Quoted 10 lines · Bin Meng
Quoted 2 lines · Simon Glass
Sandbox i2c works using emulation drivers which are currently children of
pci
Quoted 1 line
the i2c device:
pci
Fixed these, and
Quoted 25 lines
Quoted 25 lines
pci-controller { pci at 1f,0 { compatible = "pci-generic"; reg = <0xf800 0 0 0 0>; emul at 1f,0 { compatible = "sandbox,swap-case"; }; }; };In this case the emulation device is attached to pci device on address f800 (device 1f, function 0) and provides the swap-case functionality.
However this is not ideal, since every device on a PCI bus has a child device. This is only really the case for sandbox, but we want to avoid special-case code for sandbox.
Worse, child devices cannot be probed before their parents. This forces us to use 'find' rather than 'get' to obtain the emulator device. In fact the emulator devices are never probed. There is code in
sandbox_pci_emul_post_probe()which tries to track when emulators are active, but at present this does not work.
Quoted 8 lines
Quoted 6 lines
A better approach seems to be to add a separate node elsewhere in the device tree, an 'emulation parent'. This could be given a bogus address (such as -1) to hide the emulators away from the 'pci' command, but it seems better to keep it at the root node to avoid such hacks.
Then we can use a phandle to point from the evice to the correct
typo: device
Fixed this, and
Quoted 79 lines
Quoted 48 lines
emulator, and only on sandbox. The code to find an emulator does not interfere with normal pci operation.
Add a new
UCLASS_PCI_EMUL_PARENTuclass which allows finding an emulator given a bus, and finding a bus given an emulator. Update the existing device trees and the code for finding an emulator.This brings PCI emulators more into line with I2C.
Signed-off-by Simon Glass <[email protected]>---
arch/sandbox/dts/sandbox.dtsi | 11 +++++++--- arch/sandbox/dts/test.dts | 38 +++++++++++++++++++++++------------ doc/driver-model/pci-info.rst | 23 +++++++++++---------- drivers/pci/pci-emul-uclass.c | 37 ++++++++++++++++++++++++++++------ include/dm/uclass-id.h | 1 + 5 files changed, 77 insertions(+), 33 deletions(-)arch/sandbox/dts/sandbox.dtsi +8
-3@@ -103,9 +103,14 @@ pci at 1f,0 { compatible = "pci-generic"; reg = <0xf800 0 0 0 0>; - emul at 1f,0 { - compatible = "sandbox,swap-case"; - }; + sandbox,emul = <&swap_case_emul>; + }; + }; + + emul { + compatible = "sandbox,pci-emul-parent"; + swap_case_emul: emul at 1f,0 { + compatible = "sandbox,swap-case"; }; };arch/sandbox/dts/test.dts +0
-0arch/sandbox/dts/test.dts line 455
Quoted 7 lines
arch/sandbox/dts/test.dts +1
-3@@ -452,24 +452,31 @@ pci at 0,0 { compatible = "pci-generic"; reg = <0x0000 0 0 0 0>; - emul at 0,0 { - compatible = "sandbox,swap-case"; - }; + sandbox,emul = <&swap_case_emul0>;
&swap_case_emul0_0arch/sandbox/dts/test.dts line 460
Quoted 9 lines
arch/sandbox/dts/test.dts +1
-4}; pci at 1,0 { compatible = "pci-generic"; reg = <0x0800 0 0 0 0>; - emul at 0,0 { - compatible = "sandbox,swap-case"; - use-ea; - }; + sandbox,emul = <&swap_case_emul1>;
&swap_case_emul0_1arch/sandbox/dts/test.dts line 465
Quoted 8 lines
arch/sandbox/dts/test.dts +1
-3}; pci at 1f,0 { compatible = "pci-generic"; reg = <0xf800 0 0 0 0>; - emul at 1f,0 { - compatible = "sandbox,swap-case"; - }; + sandbox,emul = <&swap_case_emul1f>;
Quoted 1 line
&swap_case_emul0_1f
Fixed the label names, and
Quoted 119 lines
Quoted 106 lines
arch/sandbox/dts/test.dts +22
-3+ }; + }; + + pci-emul0 { + compatible = "sandbox,pci-emul-parent"; + swap_case_emul0: emul at 0,0 { + compatible = "sandbox,swap-case"; + }; + swap_case_emul1: emul at 1,0 { + compatible = "sandbox,swap-case"; + use-ea; + }; + swap_case_emul1f: emul at 1f,0 { + compatible = "sandbox,swap-case"; }; };@@ -499,9 +506,14 @@ pci at 1f,0 { compatible = "pci-generic"; reg = <0xf800 0 0 0 0>; - emul at 1f,0 { - compatible = "sandbox,swap-case"; - }; + sandbox,emul = <&swap_case_emul2_1f>; + }; + }; + + pci-emul2 { + compatible = "sandbox,pci-emul-parent"; + swap_case_emul2_1f: emul2 at 1f,0 { + compatible = "sandbox,swap-case"; }; };doc/driver-model/pci-info.rst +12
-11@@ -113,14 +113,17 @@ Sandbox ------- With sandbox we need a device emulator for each device on the bus since there -is no real PCI bus. This works by looking in the device tree node for a -driver. For example:: - +is no real PCI bus. This works by looking in the device tree node for an +emulator driver. For example:: pci at 1f,0 { compatible = "pci-generic"; reg = <0xf800 0 0 0 0>; - emul at 1f,0 { + sandbox,emul = <&emul_1f>; + }; + pci-emul { + compatible = "sandbox,pci-emul-parent"; + emul_1f: emul at 1f,0 { compatible = "sandbox,swap-case"; }; };@@ -130,14 +133,16 @@ Note that the first cell in the 'reg' value is the bus/device/function. See PCI_BDF() for the encoding (it is also specified in the IEEE Std 1275-1994 PCI bus binding document, v2.1) +The pci-emul node should go outside the pci bus node, since otherwise it will +be scanned as a PCI device, causing confusion. + When this bus is scanned we will end up with something like this:: `- * pci-controller @ 05c660c8, 0 `- pci at 1f,0 @ 05c661c8, 63488 - `- emul at 1f,0 @ 05c662c8 + `- emul at 1f,0 @ 05c662c8 -When accesses go to the pci at 1f,0 device they are forwarded to its child, the -emulator. +When accesses go to the pci at 1f,0 device they are forwarded to its emulator. The sandbox PCI drivers also support dynamic driver binding, allowing device driver to declare the driver binding information via U_BOOT_PCI_DEVICE(),@@ -164,7 +169,3 @@ When this bus is scanned we will end up with something like this:: pci [ + ] pci_sandbo |-- pci-controller1 pci_emul [ ] sandbox_sw | |-- sandbox_swap_case_emul pci_emul [ ] sandbox_sw | `-- sandbox_swap_case_emul - -Note the difference from the statically declared device nodes is that the -device is directly attached to the host controller, instead of via a container -device like pci at 1f,0.drivers/pci/pci-emul-uclass.c +1
-0@@ -10,6 +10,7 @@#include <linux/libfdt.h> #include <pci.h> #include <dm/lists.h> +#include <dm/uclass-internal.h> struct sandbox_pci_emul_priv {int dev_count;@@ -30,13 +31,15 @@ int sandbox_pci_get_emul(struct udevice *bus, pci_dev_t find_devfn, } *containerp = dev;drivers/pci/pci-emul-uclass.c int sandbox_pci_get_emul(struct udevice *bus, pci_dev_t find_devfn, · line 38
Quoted 10 lines
drivers/pci/pci-emul-uclass.c +5
-5-if (device_get_uclass_id (dev) ==UCLASS_PCI_GENERIC ) { - ret =device_find_first_child (dev, emulp); -if (ret) -return ret; - }else { +/* +* TODO(sjg at chromium.org): This code needs a comment as I'm not sure +* why UCLASS_PCI_GENERIC devices end up being their own emulators. I +* left this code as is. +*/ This code comes from:
Quoted 7 lines
commit
4345998ae9dfad7ba0beb54ad4322134557504a9Author: Bin Meng <[email protected]> Date: Fri Aug 3 01:14:45 2018 -0700pci: sandbox: Support dynamically binding device driver
I think the comments can be removed :)
Updated the comment to mention commit4345998ae9dfad7ba0beb54ad4322134557504a9, and
Quoted 47 lines
Quoted 47 lines
drivers/pci/pci-emul-uclass.c +25
-1+ ret =uclass_find_device_by_phandle (UCLASS_PCI_EMUL , dev, +"sandbox,emul" , emulp); +if (ret &&device_get_uclass_id (dev) !=UCLASS_PCI_GENERIC ) *emulp = dev; - }return *emulp ?0 : -ENODEV ; }@@ -68,3 +71,25 @@ UCLASS_DRIVER(pci_emul) = { .pre_remove = sandbox_pci_emul_pre_remove, .priv_auto_alloc_size = sizeof(struct sandbox_pci_emul_priv), }; + +/* +* This uclass is a child of the pci bus. Its platdata is not defined here so +* is defined by its parent, UCLASS_PCI, which uses struct pci_child_platdata. +* See per_child_platdata_auto_alloc_size in UCLASS_DRIVER(pci). +*/ +UCLASS_DRIVER (pci_emul_parent) = { + .id =UCLASS_PCI_EMUL_PARENT , + .name ="pci_emul_parent" , + .post_bind = dm_scan_fdt_dev, +}; + +static const struct udevice_id pci_emul_parent_ids[] = { + { .compatible ="sandbox,pci-emul-parent" }, + { } +}; + +U_BOOT_DRIVER (pci_emul_parent_drv) = { + .name ="pci_emul_parent_drv" , + .id =UCLASS_PCI_EMUL_PARENT , + .of_match = pci_emul_parent_ids, +};include/dm/uclass-id.h +1
-0@@ -23,6 +23,7 @@ enum uclass_id {UCLASS_I2C_EMUL ,/* sandbox I2C device emulator */ UCLASS_I2C_EMUL_PARENT ,/* parent for I2C device emulators */ UCLASS_PCI_EMUL ,/* sandbox PCI device emulator */ +UCLASS_PCI_EMUL_PARENT ,/* parent for PCI device emulators */ UCLASS_USB_EMUL ,/* sandbox USB bus device emulator */ UCLASS_AXI_EMUL, /* sandbox AXI bus device emulator */
Quoted 6 lines
Quoted 1 line
--
Other than the issues above,
Reviewed-by Bin Meng <[email protected]>Tested-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 27/126 pci: sandbox: Probe PCI emulation devices when used
In reply to Simon GlassAt present PCI emulation devices are not probed before use, since they used to be children of the device that used them, and children cannot be probed before their parents.
Now that PCI emulation devices are attached to the root node, we can simply probe them, and avoid using the internal function.
---
drivers/pci/pci-emul-uclass.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/pci/pci-emul-uclass.c +2 -3
@@ -10,7 +10,6 @@#include <linux/libfdt.h> #include <pci.h> #include <dm/lists.h> -#include <dm/uclass-internal.h> struct sandbox_pci_emul_priv {int dev_count;
@@ -36,8 +35,8 @@ int sandbox_pci_get_emul(struct udevice *bus, pci_dev_t find_devfn,* why UCLASS_PCI_GENERIC devices end up being their own emulators. I * left this code as is. */ - ret =uclass_find_device_by_phandle (UCLASS_PCI_EMUL , dev, -"sandbox,emul" , emulp); + ret =uclass_get_device_by_phandle (UCLASS_PCI_EMUL , dev,"sandbox,emul" , + emulp);if (ret &&device_get_uclass_id (dev) !=UCLASS_PCI_GENERIC ) *emulp = dev;
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 27/126 pci: sandbox: Probe PCI emulation devices when used
Quoted 5 lines · Simon Glass
At present PCI emulation devices are not probed before use, since they used to be children of the device that used them, and children cannot be probed before their parents.
Quoted 9 lines
Now that PCI emulation devices are attached to the root node, we can simply probe them, and avoid using the internal function.
Signed-off-by Simon Glass <[email protected]>---
drivers/pci/pci-emul-uclass.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
PATCH 27/126 pci: sandbox: Probe PCI emulation devices when used
Quoted 13 lines · Bin Meng
Quoted 11 lines · Simon Glass
At present PCI emulation devices are not probed before use, since they used to be children of the device that used them, and children cannot be probed before their parents.
Now that PCI emulation devices are attached to the root node, we can simply probe them, and avoid using the internal function.
Signed-off-by Simon Glass <[email protected]>---
Quoted 6 lines
Quoted 3 lines
drivers/pci/pci-emul-uclass.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)Reviewed-by Bin Meng <[email protected]>Tested-by Bin Meng <[email protected]>
Rebased the patch against u-boot-x86/next to get it applied cleanly, and
applied to u-boot-x86/next, thanks!
PATCH 28/126 pci: Show the result of binding a device
In reply to Simon GlassUpdate the debugging info a little to show the result of trying to bind a PCI device.
---
drivers/pci/pci-uclass.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pci/pci-uclass.c +2 -1
@@ -790,7 +790,7 @@ int pci_bind_bus_devices(struct udevice *bus)if (!PCI_FUNC (bdf)) found_multi = header_type &0x80 ; -debug ("%s: bus %d/%s: found device %x, function %d\n" , __func__, +debug ("%s: bus %d/%s: found device %x, function %d" , __func__, bus->seq, bus->name,PCI_DEV (bdf),PCI_FUNC (bdf));pci_bus_read_config (bus, bdf,PCI_DEVICE_ID , &device,PCI_SIZE_16 );
@@ -800,6 +800,7 @@ int pci_bind_bus_devices(struct udevice *bus)/* Find this device in the device tree */ ret =pci_bus_find_devfn (bus,PCI_MASK_BUS (bdf), &dev); +debug (": find ret=%d\n" , ret);/* If nothing in the device tree, bind a device */ if (ret == -ENODEV ) {
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 28/126 pci: Show the result of binding a device
Quoted 10 lines · Simon Glass
Update the debugging info a little to show the result of trying to bind a PCI device.
Signed-off-by Simon Glass <[email protected]>---
drivers/pci/pci-uclass.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
PATCH 28/126 pci: Show the result of binding a device
Quoted 6 lines · Bin Meng
Quoted 4 lines · Simon Glass
Update the debugging info a little to show the result of trying to bind a PCI device.
Quoted 8 lines
Quoted 6 lines
Signed-off-by Simon Glass <[email protected]>---
drivers/pci/pci-uclass.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)Reviewed-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 29/126 pci: Disable autoconfig in SPL
In reply to Simon GlassAt present U-Boot runs autoconfig in SPL but this is best left to U-Boot proper. For TPL and SPL we can normally used fixed BARs and save code size and time.
---
drivers/pci/pci-uclass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/pci-uclass.c +1 -1
@@ -983,7 +983,7 @@ static int pci_uclass_post_probe(struct udevice *bus)if (ret)return ret; -#ifdef CONFIG_PCI_PNP +#if CONFIG_IS_ENABLED (PCI_PNP ) ret =pci_auto_config_devices (bus);if (ret <0 )return ret;
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 29/126 pci: Disable autoconfig in SPL
Quoted 11 lines · Simon Glass
At present U-Boot runs autoconfig in SPL but this is best left to U-Boot proper. For TPL and SPL we can normally used fixed BARs and save code size and time.
Signed-off-by Simon Glass <[email protected]>---
drivers/pci/pci-uclass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
PATCH 29/126 pci: Disable autoconfig in SPL
Quoted 7 lines · Bin Meng
Quoted 5 lines · Simon Glass
At present U-Boot runs autoconfig in SPL but this is best left to U-Boot proper. For TPL and SPL we can normally used fixed BARs and save code size and time.
Quoted 8 lines
Quoted 6 lines
Signed-off-by Simon Glass <[email protected]>---
drivers/pci/pci-uclass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Reviewed-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 30/126 pci: Correct 'specifified' and 'Plese' typos
In reply to Simon GlassFix these spelling errors the header file and documentation.
Fix a small typo in the PCI documentation.
---
doc/driver-model/pci-info.rst | 2 +- include/pci.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
doc/driver-model/pci-info.rst +1 -1
@@ -103,7 +103,7 @@ in each of these nodes. If PCI devices are not listed in the device tree, U_BOOT_PCI_DEVICE can be used to specify the driver to use for the device. The device tree takes precedence -over U_BOOT_PCI_DEVICE. Plese note with U_BOOT_PCI_DEVICE, only drivers with +over U_BOOT_PCI_DEVICE. Please note with U_BOOT_PCI_DEVICE, only drivers with DM_FLAG_PRE_RELOC will be bound before relocation. If neither device tree nor U_BOOT_PCI_DEVICE is provided, the built-in driver (either pci_bridge_drv or pci_generic_drv) will be used.
include/pci.h +1 -1
@@ -1595,7 +1595,7 @@ int sandbox_pci_get_emul(struct udevice *bus, pci_dev_t find_devfn,/** * pci_get_devfn() - Extract the devfn from fdt_pci_addr of the device * -* Get devfn from fdt_pci_addr of the specifified device +* Get devfn from fdt_pci_addr of the specified device * * @dev: PCI device * @return devfn in bits 15...8 if found, -ENODEV if not found
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 30/126 pci: Correct 'specifified' and 'Plese' typos
Quoted 2 lines · Simon Glass
Fix these spelling errors the header file and documentation.
in the header
Quoted 10 lines
Fix a small typo in the PCI documentation.
Signed-off-by Simon Glass <[email protected]>---
doc/driver-model/pci-info.rst | 2 +- include/pci.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
PATCH 30/126 pci: Correct 'specifified' and 'Plese' typos
Quoted 13 lines · Bin Meng
Quoted 2 lines · Simon Glass
Fix these spelling errors the header file and documentation.
in the header
Quoted 6 lines
Fix a small typo in the PCI documentation.
Signed-off-by Simon Glass <[email protected]>---
Quoted 6 lines
Quoted 4 lines
doc/driver-model/pci-info.rst | 2 +- include/pci.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)Reviewed-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 31/126 pci: Add more debug detail when resources are exhausted
In reply to Simon GlassIf PCI auto-config runs out of memory, show a few more details to help diagnose the problem.
---
drivers/pci/pci_auto_common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pci/pci_auto_common.c +2 -1
@@ -45,7 +45,8 @@ int pciauto_region_allocate(struct pci_region *res, pci_size_t size, addr = ((res->bus_lower -1 ) | (size -1 )) +1 ;if (addr - res->bus_start + size > res->size) { -debug ("No room in resource" ); +debug ("No room in resource, avail start=%x / size=%x, need=%x\n" , + res->bus_lower, res->size, size); goto error; }
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 31/126 pci: Add more debug detail when resources are exhausted
Quoted 10 lines · Simon Glass
If PCI auto-config runs out of memory, show a few more details to help diagnose the problem.
Signed-off-by Simon Glass <[email protected]>---
drivers/pci/pci_auto_common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
PATCH 31/126 pci: Add more debug detail when resources are exhausted
Quoted 6 lines · Bin Meng
Quoted 4 lines · Simon Glass
If PCI auto-config runs out of memory, show a few more details to help diagnose the problem.
Quoted 8 lines
Quoted 6 lines
Signed-off-by Simon Glass <[email protected]>---
drivers/pci/pci_auto_common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)Reviewed-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 31/126 pci: Add more debug detail when resources are exhausted
Quoted 11 lines · Bin Meng
Quoted 9 lines · Bin Meng
Quoted 7 lines · Simon Glass
If PCI auto-config runs out of memory, show a few more details to help diagnose the problem.
Signed-off-by Simon Glass <[email protected]>---
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
drivers/pci/pci_auto_common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)Reviewed-by Bin Meng <[email protected]>applied to u-boot-x86/next, thanks!
It turns out we need do the following to eliminate build warnings on some boards:
drivers/pci/pci_auto_common.c +0 -0
@@ -45,8 +45,9 @@ int pciauto_region_allocate(struct pci_region *res,
pci_size_t size,
addr = ((res->bus_lower - 1) | (size - 1)) + 1;
if (addr - res->bus_start + size > res->size) {- debug("No room in resource, avail start=%x / size=%x,
need=%x\n",
- res->bus_lower, res->size, size);
+ debug("No room in resource, avail start=%llx / size=%llx, "
+ "need=%llx\n", (unsigned long long)res->bus_lower,
+ (unsigned long long)res->size, (unsigned long long)size);
goto error;
}Applied the above fix in the same commit, and now in u-boot-x86/next.
Regards,
Bin
PATCH 32/126 pci: Show a message if PCI autoconfig fails
In reply to Simon GlassAt present this fails silently which can be confusing since some devices on the PCI bus may not work correctly. Show a message in this case
---
drivers/pci/pci_auto.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/pci/pci_auto.c +9 -3
@@ -39,6 +39,8 @@ void dm_pciauto_setup_device(struct udevice *dev, int bars_num,for (bar =PCI_BASE_ADDRESS_0 ; bar <PCI_BASE_ADDRESS_0 + (bars_num *4 ); bar +=4 ) { +int ret =0 ; +/* Tickle the BAR and get the response */ if (!enum_only)dm_pci_write_config32 (dev, bar,0xffffffff );
@@ -97,9 +99,13 @@ void dm_pciauto_setup_device(struct udevice *dev, int bars_num, (unsigned long long)bar_size); } -if (!enum_only &&pciauto_region_allocate (bar_res, bar_size, - &bar_value, - found_mem64) ==0 ) { +if (!enum_only) { + ret =pciauto_region_allocate (bar_res, bar_size, + &bar_value, found_mem64); +if (ret) +printf ("PCI: Failed autoconfig bar %x" , bar); + } +if (!enum_only && !ret) {/* Write it out and update our limit */ dm_pci_write_config32 (dev, bar, (u32 )bar_value);
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 32/126 pci: Show a message if PCI autoconfig fails
Quoted 3 lines · Simon Glass
At present this fails silently which can be confusing since some devices on the PCI bus may not work correctly. Show a message in this case
nits: missing . after case
Quoted 22 lines
Signed-off-by Simon Glass <[email protected]>---
drivers/pci/pci_auto.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)drivers/pci/pci_auto.c +2
-0@@ -39,6 +39,8 @@ void dm_pciauto_setup_device(struct udevice *dev, int bars_num,for (bar =PCI_BASE_ADDRESS_0 ; bar <PCI_BASE_ADDRESS_0 + (bars_num *4 ); bar +=4 ) { +int ret =0 ; +/* Tickle the BAR and get the response */ if (!enum_only)dm_pci_write_config32 (dev, bar,0xffffffff );@@ -97,9 +99,13 @@ void dm_pciauto_setup_device(struct udevice *dev, int bars_num, (unsigned long long)bar_size);
drivers/pci/pci_auto.c void dm_pciauto_setup_device(struct udevice *dev, int bars_num, · line 106
Quoted 10 lines
drivers/pci/pci_auto.c +5
-3} -if (!enum_only &&pciauto_region_allocate (bar_res, bar_size, - &bar_value, - found_mem64) ==0 ) { +if (!enum_only) { + ret =pciauto_region_allocate (bar_res, bar_size, + &bar_value, found_mem64); +if (ret) +printf ("PCI: Failed autoconfig bar %x" , bar);
nits: should have a '\n'
drivers/pci/pci_auto.c void dm_pciauto_setup_device(struct udevice *dev, int bars_num,
Quoted 6 lines
drivers/pci/pci_auto.c +2
-1+ } +if (!enum_only && !ret) {/* Write it out and update our limit */ dm_pci_write_config32 (dev, bar, (u32 )bar_value); --
Other than above,
PATCH 32/126 pci: Show a message if PCI autoconfig fails
Quoted 7 lines · Bin Meng
Quoted 3 lines · Simon Glass
At present this fails silently which can be confusing since some devices on the PCI bus may not work correctly. Show a message in this case
nits: missing . after case
Fixed, and
Quoted 25 lines
Quoted 25 lines
Signed-off-by Simon Glass <[email protected]>---
drivers/pci/pci_auto.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)drivers/pci/pci_auto.c +2
-0@@ -39,6 +39,8 @@ void dm_pciauto_setup_device(struct udevice *dev, int bars_num,for (bar =PCI_BASE_ADDRESS_0 ; bar <PCI_BASE_ADDRESS_0 + (bars_num *4 ); bar +=4 ) { +int ret =0 ; +/* Tickle the BAR and get the response */ if (!enum_only)dm_pci_write_config32 (dev, bar,0xffffffff );@@ -97,9 +99,13 @@ void dm_pciauto_setup_device(struct udevice *dev, int bars_num, (unsigned long long)bar_size); }
Quoted 10 lines
drivers/pci/pci_auto.c void dm_pciauto_setup_device(struct udevice *dev, int bars_num, · line 106
Quoted 8 lines
drivers/pci/pci_auto.c +5
-3-if (!enum_only &&pciauto_region_allocate (bar_res, bar_size, - &bar_value, - found_mem64) ==0 ) { +if (!enum_only) { + ret =pciauto_region_allocate (bar_res, bar_size, + &bar_value, found_mem64); +if (ret) +printf ("PCI: Failed autoconfig bar %x" , bar);nits: should have a '\n'
Added a '\n', and
Quoted 10 lines
drivers/pci/pci_auto.c void dm_pciauto_setup_device(struct udevice *dev, int bars_num,
Quoted 7 lines
drivers/pci/pci_auto.c +2
-1+ } +if (!enum_only && !ret) {/* Write it out and update our limit */ dm_pci_write_config32 (dev, bar, (u32 )bar_value); --Other than above,
Reviewed-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 33/126 dm: pci: Add a function to read a PCI BAR
In reply to Simon GlassAt present PCI address transaction is not supported so drivers must manually read the correct BAR after reading the device tree info. The ns16550 has a suitable implementation, so move this code into the core DM support.
Note that there is no live-tree equivalent at present.
---
arch/sandbox/dts/test.dts | 7 ++++-- drivers/core/fdtaddr.c | 33 ++++++++++++++++++++++++++++ drivers/core/read.c | 11 ++++++++++ drivers/serial/ns16550.c | 31 +-------------------------- include/dm/fdtaddr.h | 8 +++++++ include/dm/read.h | 25 ++++++++++++++++++++++ test/dm/pci.c | 45 +++++++++++++++++++++++++++++++++++++++ 7 files changed, 128 insertions(+), 32 deletions(-)
arch/sandbox/dts/test.dts +5 -2
@@ -456,12 +456,15 @@ }; pci at 1,0 { compatible = "pci-generic"; - reg = <0x0800 0 0 0 0>; + /* BAR0 is at 0x14, using FDT_PCI_SPACE_MEM32 */ + reg = <0x02000814 0 0 0 0 + 0x0100f810 0 0 0 0>; sandbox,emul = <&swap_case_emul1>; }; pci at 1f,0 { compatible = "pci-generic"; - reg = <0xf800 0 0 0 0>; + /* BAR1 is at 0x10, using FDT_PCI_SPACE_IO */ + reg = <0x0100f810 0 0 0 0>; sandbox,emul = <&swap_case_emul1f>; }; };
drivers/core/fdtaddr.c +33 -0
@@ -190,3 +190,36 @@ void *devfdt_map_physmem(struct udevice *dev, unsigned long size)return map_physmem (addr, size,MAP_NOCACHE ); } + +fdt_addr_t devfdt_get_addr_pci (struct udevice *dev) +{ +ulong addr; + + addr =devfdt_get_addr (dev); +if (CONFIG_IS_ENABLED (PCI ) &&IS_ENABLED (CONFIG_DM_PCI ) && + addr ==FDT_ADDR_T_NONE ) { +struct fdt_pci_addr pci_addr; +u32 bar; +int ret; + + ret =fdtdec_get_pci_addr (gd->fdt_blob, +dev_of_offset (dev), +FDT_PCI_SPACE_MEM32 ,"reg" , + &pci_addr); +if (ret) { +/* try if there is any i/o-mapped register */ + ret =fdtdec_get_pci_addr (gd->fdt_blob, +dev_of_offset (dev), +FDT_PCI_SPACE_IO ,"reg" , + &pci_addr); +if (ret) +return FDT_ADDR_T_NONE ; + } + ret =fdtdec_get_pci_bar32 (dev, &pci_addr, &bar); +if (ret) +return FDT_ADDR_T_NONE ; + addr = bar; + } + +return addr; +}
drivers/core/read.c +11 -0
@@ -307,3 +307,14 @@ int dev_read_alias_highest_id(const char *stem)return fdtdec_get_alias_highest_id (gd->fdt_blob, stem); } + +fdt_addr_t dev_read_addr_pci (struct udevice *dev) +{ +ulong addr; + + addr =dev_read_addr (dev); +if (addr ==FDT_ADDR_T_NONE && !of_live_active ()) + addr =devfdt_get_addr_pci (dev); + +return addr; +}
drivers/serial/ns16550.c +1 -30
@@ -440,36 +440,7 @@ int ns16550_serial_ofdata_to_platdata(struct udevice *dev)int err;/* try Processor Local Bus device first */ - addr =dev_read_addr (dev); -#if CONFIG_IS_ENABLED (PCI ) && defined(CONFIG_DM_PCI ) -if (addr ==FDT_ADDR_T_NONE ) { -/* then try pci device */ -struct fdt_pci_addr pci_addr; -u32 bar; -int ret; - -/* we prefer to use a memory-mapped register */ - ret =fdtdec_get_pci_addr (gd->fdt_blob,dev_of_offset (dev), -FDT_PCI_SPACE_MEM32 ,"reg" , - &pci_addr); -if (ret) { -/* try if there is any i/o-mapped register */ - ret =fdtdec_get_pci_addr (gd->fdt_blob, -dev_of_offset (dev), -FDT_PCI_SPACE_IO , -"reg" , &pci_addr); -if (ret) -return ret; - } - - ret =fdtdec_get_pci_bar32 (dev, &pci_addr, &bar); -if (ret) -return ret; - - addr = bar; - } -#endif - + addr =dev_read_addr_pci (dev);if (addr ==FDT_ADDR_T_NONE )return -EINVAL ;
include/dm/fdtaddr.h +8 -0
@@ -138,4 +138,12 @@ fdt_addr_t devfdt_get_addr_name(struct udevice *dev, const char *name);fdt_addr_t devfdt_get_addr_size_name (struct udevice *dev,const char *name,fdt_size_t *size); +/** +* devfdt_get_addr_pci() - Read an address and handle PCI address translation +* +* @dev: Device to read from +* @return address or FDT_ADDR_T_NONE if not found +*/ +fdt_addr_t devfdt_get_addr_pci (struct udevice *dev); +#endif
include/dm/read.h +25 -0
@@ -247,6 +247,26 @@ fdt_addr_t dev_read_addr(struct udevice *dev);*/ void *dev_read_addr_ptr (struct udevice *dev); +/** +* dev_read_addr_pci() - Read an address and handle PCI address translation +* +* At present U-Boot does not have address translation logic for PCI in the +* livetree implementation (of_addr.c). This special function supports this for +* the flat tree implementation. +* +* This function should be removed (and code should use dev_read() instead) +* once: +* +* 1. PCI address translation is added; and either +* 2. everything uses livetree where PCI translation is used (which is feasible +* in SPL and U-Boot proper) or PCI address translation is added to +* fdtdec_get_addr() and friends. +* +* @dev: Device to read from +* @return address or FDT_ADDR_T_NONE if not found +*/ +fdt_addr_t dev_read_addr_pci (struct udevice *dev); +/** * dev_remap_addr() - Get the reg property of a device as a * memory-mapped I/O pointer
@@ -690,6 +710,11 @@ static inline void *dev_read_addr_ptr(struct udevice *dev)return devfdt_get_addr_ptr (dev); } +static inline fdt_addr_t dev_read_addr_pci (struct udevice *dev) +{ +return devfdt_get_addr_pci (dev); +} +static inline void *dev_remap_addr (struct udevice *dev) {return devfdt_remap_addr (dev);
test/dm/pci.c +45 -0
48 lines not on this page · raw message
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 33/126 dm: pci: Add a function to read a PCI BAR
Quoted 25 lines · Simon Glass
At present PCI address transaction is not supported so drivers must manually read the correct BAR after reading the device tree info. The ns16550 has a suitable implementation, so move this code into the core DM support.
Note that there is no live-tree equivalent at present.
Signed-off-by Simon Glass <[email protected]>---
arch/sandbox/dts/test.dts | 7 ++++-- drivers/core/fdtaddr.c | 33 ++++++++++++++++++++++++++++ drivers/core/read.c | 11 ++++++++++ drivers/serial/ns16550.c | 31 +-------------------------- include/dm/fdtaddr.h | 8 +++++++ include/dm/read.h | 25 ++++++++++++++++++++++ test/dm/pci.c | 45 +++++++++++++++++++++++++++++++++++++++ 7 files changed, 128 insertions(+), 32 deletions(-)arch/sandbox/dts/test.dts +0
-0
arch/sandbox/dts/test.dts line 459
Quoted 5 lines
arch/sandbox/dts/test.dts +1
-1@@ -456,12 +456,15 @@ }; pci at 1,0 { compatible = "pci-generic"; - reg = <0x0800 0 0 0 0>; + /* BAR0 is at 0x14, using FDT_PCI_SPACE_MEM32 */
reg 0
arch/sandbox/dts/test.dts line 461
Quoted 2 lines
arch/sandbox/dts/test.dts +2
-0+ reg = <0x02000814 0 0 0 0 + 0x0100f810 0 0 0 0>;
it should be 0x01000810, and should have a similar comment like reg 0
arch/sandbox/dts/test.dts line 466
Quoted 6 lines
arch/sandbox/dts/test.dts +1
-1sandbox,emul = <&swap_case_emul1>; }; pci at 1f,0 { compatible = "pci-generic"; - reg = <0xf800 0 0 0 0>; + /* BAR1 is at 0x10, using FDT_PCI_SPACE_IO */
reg 0
Quoted 210 lines
arch/sandbox/dts/test.dts +1
-0+ reg = <0x0100f810 0 0 0 0>; sandbox,emul = <&swap_case_emul1f>; }; };drivers/core/fdtaddr.c +33
-0@@ -190,3 +190,36 @@ void *devfdt_map_physmem(struct udevice *dev, unsigned long size)return map_physmem (addr, size,MAP_NOCACHE ); } + +fdt_addr_t devfdt_get_addr_pci (struct udevice *dev) +{ +ulong addr; + + addr =devfdt_get_addr (dev); +if (CONFIG_IS_ENABLED (PCI ) &&IS_ENABLED (CONFIG_DM_PCI ) && + addr ==FDT_ADDR_T_NONE ) { +struct fdt_pci_addr pci_addr; +u32 bar; +int ret; + + ret =fdtdec_get_pci_addr (gd->fdt_blob, +dev_of_offset (dev), +FDT_PCI_SPACE_MEM32 ,"reg" , + &pci_addr); +if (ret) { +/* try if there is any i/o-mapped register */ + ret =fdtdec_get_pci_addr (gd->fdt_blob, +dev_of_offset (dev), +FDT_PCI_SPACE_IO ,"reg" , + &pci_addr); +if (ret) +return FDT_ADDR_T_NONE ; + } + ret =fdtdec_get_pci_bar32 (dev, &pci_addr, &bar); +if (ret) +return FDT_ADDR_T_NONE ; + addr = bar; + } + +return addr; +}drivers/core/read.c +11
-0@@ -307,3 +307,14 @@ int dev_read_alias_highest_id(const char *stem)return fdtdec_get_alias_highest_id (gd->fdt_blob, stem); } + +fdt_addr_t dev_read_addr_pci (struct udevice *dev) +{ +ulong addr; + + addr =dev_read_addr (dev); +if (addr ==FDT_ADDR_T_NONE && !of_live_active ()) + addr =devfdt_get_addr_pci (dev); + +return addr; +}drivers/serial/ns16550.c +1
-30@@ -440,36 +440,7 @@ int ns16550_serial_ofdata_to_platdata(struct udevice *dev)int err;/* try Processor Local Bus device first */ - addr =dev_read_addr (dev); -#if CONFIG_IS_ENABLED (PCI ) && defined(CONFIG_DM_PCI ) -if (addr ==FDT_ADDR_T_NONE ) { -/* then try pci device */ -struct fdt_pci_addr pci_addr; -u32 bar; -int ret; - -/* we prefer to use a memory-mapped register */ - ret =fdtdec_get_pci_addr (gd->fdt_blob,dev_of_offset (dev), -FDT_PCI_SPACE_MEM32 ,"reg" , - &pci_addr); -if (ret) { -/* try if there is any i/o-mapped register */ - ret =fdtdec_get_pci_addr (gd->fdt_blob, -dev_of_offset (dev), -FDT_PCI_SPACE_IO , -"reg" , &pci_addr); -if (ret) -return ret; - } - - ret =fdtdec_get_pci_bar32 (dev, &pci_addr, &bar); -if (ret) -return ret; - - addr = bar; - } -#endif - + addr =dev_read_addr_pci (dev);if (addr ==FDT_ADDR_T_NONE )return -EINVAL ;include/dm/fdtaddr.h +8
-0@@ -138,4 +138,12 @@ fdt_addr_t devfdt_get_addr_name(struct udevice *dev, const char *name);fdt_addr_t devfdt_get_addr_size_name (struct udevice *dev,const char *name,fdt_size_t *size); +/** +* devfdt_get_addr_pci() - Read an address and handle PCI address translation +* +* @dev: Device to read from +* @return address or FDT_ADDR_T_NONE if not found +*/ +fdt_addr_t devfdt_get_addr_pci (struct udevice *dev); +#endif include/dm/read.h +25
-0@@ -247,6 +247,26 @@ fdt_addr_t dev_read_addr(struct udevice *dev);*/ void *dev_read_addr_ptr (struct udevice *dev); +/** +* dev_read_addr_pci() - Read an address and handle PCI address translation +* +* At present U-Boot does not have address translation logic for PCI in the +* livetree implementation (of_addr.c). This special function supports this for +* the flat tree implementation. +* +* This function should be removed (and code should use dev_read() instead) +* once: +* +* 1. PCI address translation is added; and either +* 2. everything uses livetree where PCI translation is used (which is feasible +* in SPL and U-Boot proper) or PCI address translation is added to +* fdtdec_get_addr() and friends. +* +* @dev: Device to read from +* @return address or FDT_ADDR_T_NONE if not found +*/ +fdt_addr_t dev_read_addr_pci (struct udevice *dev); +/** * dev_remap_addr() - Get the reg property of a device as a * memory-mapped I/O pointer @@ -690,6 +710,11 @@ static inline void *dev_read_addr_ptr(struct udevice *dev)return devfdt_get_addr_ptr (dev); } +static inline fdt_addr_t dev_read_addr_pci (struct udevice *dev) +{ +return devfdt_get_addr_pci (dev); +} +static inline void *dev_remap_addr (struct udevice *dev) {return devfdt_remap_addr (dev);test/dm/pci.c +36
-0@@ -294,3 +294,48 @@ static int dm_test_pci_ea(struct unit_test_state *uts)return 0 ; }DM_TEST (dm_test_pci_ea,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT ); + +/* Test the dev_read_addr_pci() function */ +static int dm_test_pci_addr_flat (struct unit_test_state *uts) +{ +struct udevice *swap1f, *swap1; +ulong io_addr, mem_addr; + +ut_assertok (dm_pci_bus_find_bdf (PCI_BDF (0 ,0x1f ,0 ), &swap1f)); + io_addr =dm_pci_read_bar32 (swap1f,0 ); +ut_asserteq (io_addr,dev_read_addr_pci (swap1f)); + +/* +* This device has both I/O and MEM spaces but the MEM space appears +* first +*/ +ut_assertok (dm_pci_bus_find_bdf (PCI_BDF (0 ,0x1 ,0 ), &swap1)); + mem_addr =dm_pci_read_bar32 (swap1,1 ); +ut_asserteq (mem_addr,dev_read_addr_pci (swap1)); + +return 0 ; +} +DM_TEST (dm_test_pci_addr_flat,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT | +DM_TESTF_FLAT_TREE ); + +/* +* Test the dev_read_addr_pci() function with livetree. That function is +* not currently fully implemented, in that it fails to return the BAR address. +* Once that is implemented this test can be removed and dm_test_pci_addr_flat() +* can be used for both flattree and livetree by removing the DM_TESTF_FLAT_TREE +* flag above. +*/ +static int dm_test_pci_addr_live (struct unit_test_state *uts) +{ +struct udevice *swap1f, *swap1; + +ut_assertok (dm_pci_bus_find_bdf (PCI_BDF (0 ,0x1f ,0 ), &swap1f));
test/dm/pci.c static int dm_test_pci_ea(struct unit_test_state *uts)
Quoted 10 lines
test/dm/pci.c +9
-1+ut_asserteq (FDT_ADDR_T_NONE ,dev_read_addr_pci (swap1f)); + +ut_assertok (dm_pci_bus_find_bdf (PCI_BDF (0 ,0x1 ,0 ), &swap1)); +ut_asserteq (FDT_ADDR_T_NONE ,dev_read_addr_pci (swap1)); + +return 0 ; +} +DM_TEST (dm_test_pci_addr_live,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT | +DM_TESTF_LIVE_TREE ); --
Other than above,
PATCH 33/126 dm: pci: Add a function to read a PCI BAR
Quoted 40 lines · Bin Meng
Quoted 25 lines · Simon Glass
At present PCI address transaction is not supported so drivers must manually read the correct BAR after reading the device tree info. The ns16550 has a suitable implementation, so move this code into the core DM support.
Note that there is no live-tree equivalent at present.
Signed-off-by Simon Glass <[email protected]>---
arch/sandbox/dts/test.dts | 7 ++++-- drivers/core/fdtaddr.c | 33 ++++++++++++++++++++++++++++ drivers/core/read.c | 11 ++++++++++ drivers/serial/ns16550.c | 31 +-------------------------- include/dm/fdtaddr.h | 8 +++++++ include/dm/read.h | 25 ++++++++++++++++++++++ test/dm/pci.c | 45 +++++++++++++++++++++++++++++++++++++++ 7 files changed, 128 insertions(+), 32 deletions(-)arch/sandbox/dts/test.dts +0
-0arch/sandbox/dts/test.dts line 459
Quoted 5 lines
arch/sandbox/dts/test.dts +1
-1@@ -456,12 +456,15 @@ }; pci at 1,0 { compatible = "pci-generic"; - reg = <0x0800 0 0 0 0>; + /* BAR0 is at 0x14, using FDT_PCI_SPACE_MEM32 */reg 0
arch/sandbox/dts/test.dts line 461
Quoted 2 lines
arch/sandbox/dts/test.dts +2
-0+ reg = <0x02000814 0 0 0 0 + 0x0100f810 0 0 0 0>;it should be
0x01000810, and should have a similar comment like reg 0
Quoted 8 lines
arch/sandbox/dts/test.dts line 466
Quoted 6 lines
arch/sandbox/dts/test.dts +1
-1sandbox,emul = <&swap_case_emul1>; }; pci at 1f,0 { compatible = "pci-generic"; - reg = <0xf800 0 0 0 0>; + /* BAR1 is at 0x10, using FDT_PCI_SPACE_IO */reg 0
Corrected the above comments, and
Quoted 223 lines
Quoted 211 lines
arch/sandbox/dts/test.dts +1
-0+ reg = <0x0100f810 0 0 0 0>; sandbox,emul = <&swap_case_emul1f>; }; };drivers/core/fdtaddr.c +33
-0@@ -190,3 +190,36 @@ void *devfdt_map_physmem(struct udevice *dev, unsigned long size)return map_physmem (addr, size,MAP_NOCACHE ); } + +fdt_addr_t devfdt_get_addr_pci (struct udevice *dev) +{ +ulong addr; + + addr =devfdt_get_addr (dev); +if (CONFIG_IS_ENABLED (PCI ) &&IS_ENABLED (CONFIG_DM_PCI ) && + addr ==FDT_ADDR_T_NONE ) { +struct fdt_pci_addr pci_addr; +u32 bar; +int ret; + + ret =fdtdec_get_pci_addr (gd->fdt_blob, +dev_of_offset (dev), +FDT_PCI_SPACE_MEM32 ,"reg" , + &pci_addr); +if (ret) { +/* try if there is any i/o-mapped register */ + ret =fdtdec_get_pci_addr (gd->fdt_blob, +dev_of_offset (dev), +FDT_PCI_SPACE_IO ,"reg" , + &pci_addr); +if (ret) +return FDT_ADDR_T_NONE ; + } + ret =fdtdec_get_pci_bar32 (dev, &pci_addr, &bar); +if (ret) +return FDT_ADDR_T_NONE ; + addr = bar; + } + +return addr; +}drivers/core/read.c +11
-0@@ -307,3 +307,14 @@ int dev_read_alias_highest_id(const char *stem)return fdtdec_get_alias_highest_id (gd->fdt_blob, stem); } + +fdt_addr_t dev_read_addr_pci (struct udevice *dev) +{ +ulong addr; + + addr =dev_read_addr (dev); +if (addr ==FDT_ADDR_T_NONE && !of_live_active ()) + addr =devfdt_get_addr_pci (dev); + +return addr; +}drivers/serial/ns16550.c +1
-30@@ -440,36 +440,7 @@ int ns16550_serial_ofdata_to_platdata(struct udevice *dev)int err;/* try Processor Local Bus device first */ - addr =dev_read_addr (dev); -#if CONFIG_IS_ENABLED (PCI ) && defined(CONFIG_DM_PCI ) -if (addr ==FDT_ADDR_T_NONE ) { -/* then try pci device */ -struct fdt_pci_addr pci_addr; -u32 bar; -int ret; - -/* we prefer to use a memory-mapped register */ - ret =fdtdec_get_pci_addr (gd->fdt_blob,dev_of_offset (dev), -FDT_PCI_SPACE_MEM32 ,"reg" , - &pci_addr); -if (ret) { -/* try if there is any i/o-mapped register */ - ret =fdtdec_get_pci_addr (gd->fdt_blob, -dev_of_offset (dev), -FDT_PCI_SPACE_IO , -"reg" , &pci_addr); -if (ret) -return ret; - } - - ret =fdtdec_get_pci_bar32 (dev, &pci_addr, &bar); -if (ret) -return ret; - - addr = bar; - } -#endif - + addr =dev_read_addr_pci (dev);if (addr ==FDT_ADDR_T_NONE )return -EINVAL ;include/dm/fdtaddr.h +8
-0@@ -138,4 +138,12 @@ fdt_addr_t devfdt_get_addr_name(struct udevice *dev, const char *name);fdt_addr_t devfdt_get_addr_size_name (struct udevice *dev,const char *name,fdt_size_t *size); +/** +* devfdt_get_addr_pci() - Read an address and handle PCI address translation +* +* @dev: Device to read from +* @return address or FDT_ADDR_T_NONE if not found +*/ +fdt_addr_t devfdt_get_addr_pci (struct udevice *dev); +#endif include/dm/read.h +25
-0@@ -247,6 +247,26 @@ fdt_addr_t dev_read_addr(struct udevice *dev);*/ void *dev_read_addr_ptr (struct udevice *dev); +/** +* dev_read_addr_pci() - Read an address and handle PCI address translation +* +* At present U-Boot does not have address translation logic for PCI in the +* livetree implementation (of_addr.c). This special function supports this for +* the flat tree implementation. +* +* This function should be removed (and code should use dev_read() instead) +* once: +* +* 1. PCI address translation is added; and either +* 2. everything uses livetree where PCI translation is used (which is feasible +* in SPL and U-Boot proper) or PCI address translation is added to +* fdtdec_get_addr() and friends. +* +* @dev: Device to read from +* @return address or FDT_ADDR_T_NONE if not found +*/ +fdt_addr_t dev_read_addr_pci (struct udevice *dev); +/** * dev_remap_addr() - Get the reg property of a device as a * memory-mapped I/O pointer @@ -690,6 +710,11 @@ static inline void *dev_read_addr_ptr(struct udevice *dev)return devfdt_get_addr_ptr (dev); } +static inline fdt_addr_t dev_read_addr_pci (struct udevice *dev) +{ +return devfdt_get_addr_pci (dev); +} +static inline void *dev_remap_addr (struct udevice *dev) {return devfdt_remap_addr (dev);test/dm/pci.c +36
-0@@ -294,3 +294,48 @@ static int dm_test_pci_ea(struct unit_test_state *uts)return 0 ; }DM_TEST (dm_test_pci_ea,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT ); + +/* Test the dev_read_addr_pci() function */ +static int dm_test_pci_addr_flat (struct unit_test_state *uts) +{ +struct udevice *swap1f, *swap1; +ulong io_addr, mem_addr; + +ut_assertok (dm_pci_bus_find_bdf (PCI_BDF (0 ,0x1f ,0 ), &swap1f)); + io_addr =dm_pci_read_bar32 (swap1f,0 ); +ut_asserteq (io_addr,dev_read_addr_pci (swap1f)); + +/* +* This device has both I/O and MEM spaces but the MEM space appears +* first +*/ +ut_assertok (dm_pci_bus_find_bdf (PCI_BDF (0 ,0x1 ,0 ), &swap1)); + mem_addr =dm_pci_read_bar32 (swap1,1 ); +ut_asserteq (mem_addr,dev_read_addr_pci (swap1)); + +return 0 ; +} +DM_TEST (dm_test_pci_addr_flat,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT | +DM_TESTF_FLAT_TREE ); + +/* +* Test the dev_read_addr_pci() function with livetree. That function is +* not currently fully implemented, in that it fails to return the BAR address. +* Once that is implemented this test can be removed and dm_test_pci_addr_flat() +* can be used for both flattree and livetree by removing the DM_TESTF_FLAT_TREE +* flag above. +*/ +static int dm_test_pci_addr_live (struct unit_test_state *uts) +{ +struct udevice *swap1f, *swap1; + +ut_assertok (dm_pci_bus_find_bdf (PCI_BDF (0 ,0x1f ,0 ), &swap1f));test/dm/pci.c static int dm_test_pci_ea(struct unit_test_state *uts)
Quoted 10 lines
test/dm/pci.c +9
-1+ut_asserteq (FDT_ADDR_T_NONE ,dev_read_addr_pci (swap1f)); + +ut_assertok (dm_pci_bus_find_bdf (PCI_BDF (0 ,0x1 ,0 ), &swap1)); +ut_asserteq (FDT_ADDR_T_NONE ,dev_read_addr_pci (swap1)); + +return 0 ; +} +DM_TEST (dm_test_pci_addr_live,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT | +DM_TESTF_LIVE_TREE ); --Other than above,
Quoted 2 lines
Reviewed-by Bin Meng <[email protected]>Tested-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 34/126 serial: ns16550: Add a PCI device/function field
In reply to Simon GlassWhen this UART is used early in boot (before PCI is set up) it is convenient to store the PCI BDF of the UART so that it can be manually configured. This is useful when it is used as a debug UART, for example.
Add a new field to hold this information, so that drivers can simply use the existing platform data.
---
include/ns16550.h | 4 ++++ 1 file changed, 4 insertions(+)
include/ns16550.h +4 -0
@@ -52,6 +52,7 @@* @reg_width: IO accesses size of registers (in bytes) * @reg_shift: Shift size of registers (0=byte, 1=16bit, 2=32bit...) * @clock: UART base clock speed in Hz +* @bdf: PCI slot/function (pci_dev_t) */ struct ns16550_platdata {unsigned long base;
@@ -60,6 +61,9 @@ struct ns16550_platdata {int reg_offset;int clock;u32 fcr; +#if defined(CONFIG_PCI ) && defined(CONFIG_SPL ) +int bdf; +#endif };struct udevice ;
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 34/126 serial: ns16550: Add a PCI device/function field
Quoted 5 lines · Simon Glass
When this UART is used early in boot (before PCI is set up) it is convenient to store the PCI BDF of the UART so that it can be manually configured. This is useful when it is used as a debug UART, for example.
Quoted 9 lines
Add a new field to hold this information, so that drivers can simply use the existing platform data.
Signed-off-by Simon Glass <[email protected]>---
include/ns16550.h | 4 ++++ 1 file changed, 4 insertions(+)
PATCH 34/126 serial: ns16550: Add a PCI device/function field
Quoted 10 lines · Bin Meng
Quoted 8 lines · Simon Glass
When this UART is used early in boot (before PCI is set up) it is convenient to store the PCI BDF of the UART so that it can be manually configured. This is useful when it is used as a debug UART, for example.
Add a new field to hold this information, so that drivers can simply use the existing platform data.
Quoted 8 lines
Quoted 6 lines
Signed-off-by Simon Glass <[email protected]>---
include/ns16550.h | 4 ++++ 1 file changed, 4 insertions(+)Reviewed-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 35/126 binman: Allow verbose output with all commands
In reply to Simon GlassAt present the verbose flag only works for the 'build' command. This is not intended, nor is it useful. Update the code to support the verbose flag and make use of a command exception handler.
---
tools/binman/control.py | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-)
tools/binman/control.py +15 -21
@@ -475,29 +475,23 @@ def Binman(args): from image import Image import state - if args.cmd == 'ls': + if args.cmd in ['ls', 'extract', 'replace']: try: + tout.Init(args.verbosity) tools.PrepareOutputDir(None) - ListEntries(args.image, args.paths) - finally: - tools.FinaliseOutputDir() - return 0 - - if args.cmd == 'extract': - try: - tools.PrepareOutputDir(None) - ExtractEntries(args.image, args.filename, args.outdir, args.paths, - not args.uncompressed) - finally: - tools.FinaliseOutputDir() - return 0 - - if args.cmd == 'replace': - try: - tools.PrepareOutputDir(None) - ReplaceEntries(args.image, args.filename, args.indir, args.paths, - do_compress=not args.compressed, - allow_resize=not args.fix_size, write_map=args.map) + if args.cmd == 'ls': + ListEntries(args.image, args.paths) + + if args.cmd == 'extract': + ExtractEntries(args.image, args.filename, args.outdir, args.paths, + not args.uncompressed) + + if args.cmd == 'replace': + ReplaceEntries(args.image, args.filename, args.indir, args.paths, + do_compress=not args.compressed, + allow_resize=not args.fix_size, write_map=args.map) + except: + raise finally: tools.FinaliseOutputDir() return 0
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 35/126 binman: Allow verbose output with all commands
Quoted 11 lines · Simon Glass
At present the verbose flag only works for the 'build' command. This is not intended, nor is it useful. Update the code to support the verbose flag and make use of a command exception handler.
Signed-off-by Simon Glass <[email protected]>---
tools/binman/control.py | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-)
PATCH 35/126 binman: Allow verbose output with all commands
Quoted 7 lines · Bin Meng
Quoted 5 lines · Simon Glass
At present the verbose flag only works for the 'build' command. This is not intended, nor is it useful. Update the code to support the verbose flag and make use of a command exception handler.
Quoted 8 lines
Quoted 6 lines
Signed-off-by Simon Glass <[email protected]>---
tools/binman/control.py | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-)Reviewed-by Bin Meng <[email protected]>
Rebased the patch against u-boot-x86/next to get it applied cleanly, and
applied to u-boot-x86/next, thanks!
PATCH 36/126 binman: Add a base implementation of Entry.ReadChildData()
In reply to Simon GlassAt present this function is not present in the Entry base class so it is hard to find the documentation for it. Move the docs from the section class and expand it a little.
---
tools/binman/entry.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
tools/binman/entry.py +16 -0
@@ -720,6 +720,22 @@ features to produce new behaviours. data = self.section.ReadChildData(self, decomp) return data + def ReadChildData(self, child, decomp=True): + """Read the data for a particular child + + This reads data from the parent and extracts the piece that relates to + the given child. + + Args: + child: Child to read (must be valid) + decomp: True to decompress any compressed data before returning it; + False to return the raw, uncompressed data + + Returns: + Data for the child (bytes) + """ + pass + def LoadData(self, decomp=True): data = self.ReadData(decomp) self.contents_size = len(data)
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 36/126 binman: Add a base implementation of Entry.ReadChildData()
Quoted 11 lines · Simon Glass
At present this function is not present in the Entry base class so it is hard to find the documentation for it. Move the docs from the section class and expand it a little.
Signed-off-by Simon Glass <[email protected]>---
tools/binman/entry.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
PATCH 36/126 binman: Add a base implementation of Entry.ReadChildData()
Quoted 7 lines · Bin Meng
Quoted 5 lines · Simon Glass
At present this function is not present in the Entry base class so it is hard to find the documentation for it. Move the docs from the section class and expand it a little.
Quoted 8 lines
Quoted 6 lines
Signed-off-by Simon Glass <[email protected]>---
tools/binman/entry.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)Reviewed-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 37/126 binman: Handle reading data for end-at-4gb sections
In reply to Simon GlassSome x86 sections have special offsets which currently result in empty data being returned from the 'extract' command. Fix this by taking account of the skip-at-start property.
Add a little more debugging while we are here.
---
tools/binman/entry.py | 6 ++++-- tools/binman/etype/section.py | 16 +++++----------- tools/binman/image.py | 2 ++ 3 files changed, 11 insertions(+), 13 deletions(-)
tools/binman/entry.py +4 -2
@@ -717,17 +717,19 @@ features to produce new behaviours. """ # Use True here so that we get an uncompressed section to work from, # although compressed sections are currently not supported + tout.Debug("ReadChildData section '%s', entry '%s'" % + (self.section.GetPath(), self.GetPath())) data = self.section.ReadChildData(self, decomp) return data def ReadChildData(self, child, decomp=True): - """Read the data for a particular child + """Read the data for a particular child entry This reads data from the parent and extracts the piece that relates to the given child. Args: - child: Child to read (must be valid) + child: Child entry to read data for (must be valid) decomp: True to decompress any compressed data before returning it; False to return the raw, uncompressed data
tools/binman/etype/section.py +5 -11
@@ -508,18 +508,12 @@ class Entry_section(Entry): return data def ReadChildData(self, child, decomp=True): - """Read the data for a particular child entry - - Args: - child: Child entry to read data for - decomp: True to return uncompressed data, False to leave the data - compressed if it is compressed - - Returns: - Data contents of entry - """ + tout.Debug("ReadChildData for child '%s'" % child.GetPath()) parent_data = self.ReadData(True) - data = parent_data[child.offset:child.offset + child.size] + offset = child.offset - self._skip_at_start + tout.Debug("Extract for child '%s': offset %#x, skip_at_start %#x, result %#x" % + (child.GetPath(), child.offset, self._skip_at_start, offset)) + data = parent_data[offset:offset + child.size] if decomp: indata = data data = tools.Decompress(indata, child.compress)
tools/binman/image.py +2 -0
@@ -201,6 +201,8 @@ class Image(section.Entry_section): return entry def ReadData(self, decomp=True): + tout.Debug("Image '%s' ReadData(), size=%#x" % + (self.GetPath(), len(self._data))) return self._data def GetListEntries(self, entry_paths):
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 37/126 binman: Handle reading data for end-at-4gb sections
Quoted 7 lines · Simon Glass
Some x86 sections have special offsets which currently result in empty data being returned from the 'extract' command. Fix this by taking account of the skip-at-start property.
Add a little more debugging while we are here.
Quoted 8 lines
Signed-off-by Simon Glass <[email protected]>---
tools/binman/entry.py | 6 ++++-- tools/binman/etype/section.py | 16 +++++----------- tools/binman/image.py | 2 ++ 3 files changed, 11 insertions(+), 13 deletions(-)
PATCH 37/126 binman: Handle reading data for end-at-4gb sections
Quoted 12 lines · Bin Meng
Quoted 10 lines · Simon Glass
Some x86 sections have special offsets which currently result in empty data being returned from the 'extract' command. Fix this by taking account of the skip-at-start property.
Add a little more debugging while we are here.
Signed-off-by Simon Glass <[email protected]>---
Quoted 7 lines
Quoted 5 lines
tools/binman/entry.py | 6 ++++-- tools/binman/etype/section.py | 16 +++++----------- tools/binman/image.py | 2 ++ 3 files changed, 11 insertions(+), 13 deletions(-)Acked-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 38/126 binman: Take account of skip-at-start with image-header
In reply to Simon GlassThe image-header currently sets it offset assuming that skip-at-start is zero. This does not work on x86 where offsets end at 4GB. Add in this value so that the offset is correct.
---
tools/binman/etype/image_header.py | 1 + 1 file changed, 1 insertion(+)
tools/binman/etype/image_header.py +1 -0
@@ -100,6 +100,7 @@ class Entry_image_header(Entry): offset = offset else: offset = image_size - IMAGE_HEADER_LEN + offset += self.section.GetStartOffset() return Entry.Pack(self, offset) def ProcessContents(self):
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 38/126 binman: Take account of skip-at-start with image-header
Quoted 11 lines · Simon Glass
The image-header currently sets it offset assuming that skip-at-start is zero. This does not work on x86 where offsets end at 4GB. Add in this value so that the offset is correct.
Signed-off-by Simon Glass <[email protected]>---
tools/binman/etype/image_header.py | 1 + 1 file changed, 1 insertion(+)
PATCH 38/126 binman: Take account of skip-at-start with image-header
Quoted 7 lines · Bin Meng
Quoted 5 lines · Simon Glass
The image-header currently sets it offset assuming that skip-at-start is zero. This does not work on x86 where offsets end at 4GB. Add in this value so that the offset is correct.
Quoted 8 lines
Quoted 6 lines
Signed-off-by Simon Glass <[email protected]>---
tools/binman/etype/image_header.py | 1 + 1 file changed, 1 insertion(+)Acked-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 39/126 log: Add log_nop() to avoid unused-variable warnings
In reply to Simon GlassIf a log statement includes a variable and logging is disabled, this can generate warnings about unused variables. Add a bit more complexity to the macros to avoid this for the common case.
---
include/log.h | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-)
include/log.h +26 -7
@@ -76,6 +76,18 @@ int _log(enum log_category_t cat, enum log_level_t level, const char *file, int line, const char *func, const char *fmt, ...) __attribute__ ((format (__printf__, 6, 7))); +static inline int _log_nop (enum log_category_t cat,enum log_level_t level, +const char *file,int line,const char *func, +const char *fmt, ...) + __attribute__ ((format (__printf__,6 ,7 ))); + +static inline int _log_nop (enum log_category_t cat,enum log_level_t level, +const char *file,int line,const char *func, +const char *fmt, ...) +{ +return 0 ; +} +/* Define this at the top of a file to add a prefix to debug messages */ #ifndef pr_fmt#define pr_fmt (fmt) fmt
@@ -101,13 +113,14 @@ int _log(enum log_category_t cat, enum log_level_t level, const char *file, #define log_io(_fmt...) log(LOG_CATEGORY, LOGL_DEBUG_IO, ##_fmt)#else #define _LOG_MAX_LEVEL LOGL_INFO -#define log_err(_fmt...) -#define log_warning(_fmt...) -#define log_notice(_fmt...) -#define log_info(_fmt...) -#define log_debug(_fmt...) -#define log_content(_fmt...) -#define log_io(_fmt...) +#define log_err(_fmt...) log_nop(LOG_CATEGORY, LOGL_ERR, ##_fmt) +#define log_warning(_fmt...) log_nop(LOG_CATEGORY, LOGL_WARNING, ##_fmt) +#define log_notice(_fmt...) log_nop(LOG_CATEGORY, LOGL_NOTICE, ##_fmt) +#define log_info(_fmt...) log_nop(LOG_CATEGORY, LOGL_INFO, ##_fmt) +#define log_debug(_fmt...) log_nop(LOG_CATEGORY, LOGL_DEBUG, ##_fmt) +#define log_content(_fmt...) log_nop(LOG_CATEGORY, \ + LOGL_DEBUG_CONTENT, ##_fmt) +#define log_io(_fmt...) log_nop(LOG_CATEGORY, LOGL_DEBUG_IO, ##_fmt)#endif #if CONFIG_IS_ENABLED (LOG )
@@ -129,6 +142,12 @@ int _log(enum log_category_t cat, enum log_level_t level, const char *file, #define log(_cat, _level, _fmt, _args...)#endif +#define log_nop(_cat, _level, _fmt, _args...) ({ \ + int _l = _level; \ + _log_nop((enum log_category_t)(_cat), _l, __FILE__, __LINE__, \ + __func__, pr_fmt(_fmt), ##_args); \ +}) +#ifdef DEBUG #define _DEBUG 1#else
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 39/126 log: Add log_nop() to avoid unused-variable warnings
Quoted 11 lines · Simon Glass
If a log statement includes a variable and logging is disabled, this can generate warnings about unused variables. Add a bit more complexity to the macros to avoid this for the common case.
Signed-off-by Simon Glass <[email protected]>---
include/log.h | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-)
PATCH 39/126 log: Add log_nop() to avoid unused-variable warnings
Quoted 7 lines · Bin Meng
Quoted 5 lines · Simon Glass
If a log statement includes a variable and logging is disabled, this can generate warnings about unused variables. Add a bit more complexity to the macros to avoid this for the common case.
Quoted 8 lines
Quoted 6 lines
Signed-off-by Simon Glass <[email protected]>---
include/log.h | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-)Reviewed-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 40/126 cros_ec: Add MEC_EMI_BASE and size to the header file
In reply to Simon GlassProvide these values which are part of the EC interface now.
---
include/ec_commands.h | 4 ++++ 1 file changed, 4 insertions(+)
include/ec_commands.h +4 -0
@@ -71,6 +71,10 @@#define EC_LPC_CMDR_SCI (1 << 5)/* SCI event is pending */ #define EC_LPC_CMDR_SMI (1 << 6)/* SMI event is pending */ +/* MEC uses 0x800/0x804 as register/index pair, thus an 8-byte resource */ +#define MEC_EMI_BASE 0x800 +#define MEC_EMI_SIZE 8 +#define EC_LPC_ADDR_MEMMAP 0x900#define EC_MEMMAP_SIZE 255/* ACPI IO buffer max is 255 bytes */ #define EC_MEMMAP_TEXT_MAX 8/* Size of a string in the memory map */
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 40/126 cros_ec: Add MEC_EMI_BASE and size to the header file
Quoted 9 lines · Simon Glass
Provide these values which are part of the EC interface now.
Signed-off-by Simon Glass <[email protected]>---
include/ec_commands.h | 4 ++++ 1 file changed, 4 insertions(+)
PATCH 40/126 cros_ec: Add MEC_EMI_BASE and size to the header file
Quoted 5 lines · Bin Meng
Quoted 3 lines · Simon Glass
Provide these values which are part of the EC interface now.
Quoted 8 lines
Quoted 6 lines
Signed-off-by Simon Glass <[email protected]>---
include/ec_commands.h | 4 ++++ 1 file changed, 4 insertions(+)Reviewed-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 41/126 iod: Enhance to support display of multiple values
In reply to Simon GlassAt present the 'iod' command differs from 'md' in that it only shows a single value. It is useful to see a dump of multiple values, particularly when x86 peripherals contain register sets accessible via I/O ports.
Enhance the command to match md.
---
cmd/io.c | 84 +++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 65 insertions(+), 19 deletions(-)
cmd/io.c +65 -19
@@ -11,6 +11,15 @@#include <command.h> #include <asm/io.h> +/* Display values from last command. +* Memory modify remembered values are different from display memory. +*/ +static ulong last_addr, last_size; +static ulong last_length =0x40 ; +static ulong base_address; + +#define DISP_LINE_LEN 16 +/* * IO Display *
@@ -19,26 +28,63 @@*/ int do_io_iod (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) { -ulong addr; -int size; - -if (argc !=2 ) +ulong addr, length, bytes; +u8 buf[DISP_LINE_LEN ]; +int size, todo; + +/* We use the last specified parameters, unless new ones are +* entered. +*/ + addr = last_addr; + size = last_size; + length = last_length; + +if (argc <2 )return CMD_RET_USAGE ; - size =cmd_get_data_size (argv[0 ],4 ); -if (size <0 ) -return 1 ; - - addr =simple_strtoul (argv[1 ],NULL ,16 ); - -printf ("%04x: " , (u16 ) addr); - -if (size ==4 ) -printf ("%08x\n" ,inl (addr)); -else if (size ==2 ) -printf ("%04x\n" ,inw (addr)); -else -printf ("%02x\n" ,inb (addr)); +if ((flag &CMD_FLAG_REPEAT ) ==0 ) { +/* New command specified. Check for a size specification. +* Defaults to long if no or incorrect specification. +*/ + size =cmd_get_data_size (argv[0 ],4 ); +if (size <0 ) +return 1 ; + +/* Address is specified since argc > 1 */ + addr =simple_strtoul (argv[1 ],NULL ,16 ); + addr += base_address; + +/* If another parameter, it is the length to display. +* Length is the number of objects, not number of bytes. +*/ +if (argc >2 ) + length =simple_strtoul (argv[2 ],NULL ,16 ); + } + + bytes = size * length; + +/* Print the lines */ +for (; bytes >0 ; addr += todo) { +u8 *ptr = buf; +int i; + + todo =min (bytes, (ulong )DISP_LINE_LEN ); +for (i =0 ; i < todo; i += size, ptr += size) { +if (size ==4 ) + *(u32 *)ptr =inl (addr + i); +else if (size ==2 ) + *(u16 *)ptr =inw (addr + i); +else + *ptr =inb (addr + i); + } +print_buffer (addr, buf, size, todo / size, +DISP_LINE_LEN / size); + bytes -= todo; + } + + last_addr = addr; + last_length = length; + last_size = size;return 0 ; }
@@ -69,7 +115,7 @@ int do_io_iow(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) }/**************************************************/ -U_BOOT_CMD (iod,2 ,0 , do_io_iod, +U_BOOT_CMD (iod,3 ,1 , do_io_iod,"IO space display" ,"[.b, .w, .l] address" ); U_BOOT_CMD(iow, 3, 0, do_io_iow,
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 41/126 iod: Enhance to support display of multiple values
Quoted 18 lines · Simon Glass
At present the 'iod' command differs from 'md' in that it only shows a single value. It is useful to see a dump of multiple values, particularly when x86 peripherals contain register sets accessible via I/O ports.
Enhance the command to match md.
Signed-off-by Simon Glass <[email protected]>---
cmd/io.c | 84 +++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 65 insertions(+), 19 deletions(-)cmd/io.c +0
-0
cmd/io.c line 14
Quoted 4 lines
cmd/io.c +1
-0@@ -11,6 +11,15 @@#include <command.h> #include <asm/io.h> +/* Display values from last command.
nits: wrong multi-line comment format
cmd/io.c line 15
Quoted 1 line
cmd/io.c +1
-0+* Memory modify remembered values are different from display memory.
This comment does not apply as there is no "memory modify" in this context.
Quoted 13 lines
cmd/io.c +7
-0+*/ +static ulong last_addr, last_size; +static ulong last_length =0x40 ; +static ulong base_address; + +#define DISP_LINE_LEN 16 +/* * IO Display * @@ -19,26 +28,63 @@*/ int do_io_iod (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[])
cmd/io.c line 35
Quoted 10 lines
cmd/io.c +5
-4{ -ulong addr; -int size; - -if (argc !=2 ) +ulong addr, length, bytes; +u8 buf[DISP_LINE_LEN ]; +int size, todo; + +/* We use the last specified parameters, unless new ones are
nits: wrong multi-line comment format
Quoted 15 lines
cmd/io.c +7
-6+* entered. +*/ + addr = last_addr; + size = last_size; + length = last_length; + +if (argc <2 )return CMD_RET_USAGE ; - size =cmd_get_data_size (argv[0 ],4 ); -if (size <0 ) -return 1 ; - - addr =simple_strtoul (argv[1 ],NULL ,16 ); -
cmd/io.c line 46
Quoted 10 lines
cmd/io.c +2
-8-printf ("%04x: " , (u16 ) addr); - -if (size ==4 ) -printf ("%08x\n" ,inl (addr)); -else if (size ==2 ) -printf ("%04x\n" ,inw (addr)); -else -printf ("%02x\n" ,inb (addr)); +if ((flag &CMD_FLAG_REPEAT ) ==0 ) { +/* New command specified. Check for a size specification.
nits: wrong multi-line comment format
cmd/io.c line 57
Quoted 11 lines
cmd/io.c +11
-0+* Defaults to long if no or incorrect specification. +*/ + size =cmd_get_data_size (argv[0 ],4 ); +if (size <0 ) +return 1 ; + +/* Address is specified since argc > 1 */ + addr =simple_strtoul (argv[1 ],NULL ,16 ); + addr += base_address; + +/* If another parameter, it is the length to display.
nits: wrong multi-line comment format
Quoted 34 lines
cmd/io.c +30
-0+* Length is the number of objects, not number of bytes. +*/ +if (argc >2 ) + length =simple_strtoul (argv[2 ],NULL ,16 ); + } + + bytes = size * length; + +/* Print the lines */ +for (; bytes >0 ; addr += todo) { +u8 *ptr = buf; +int i; + + todo =min (bytes, (ulong )DISP_LINE_LEN ); +for (i =0 ; i < todo; i += size, ptr += size) { +if (size ==4 ) + *(u32 *)ptr =inl (addr + i); +else if (size ==2 ) + *(u16 *)ptr =inw (addr + i); +else + *ptr =inb (addr + i); + } +print_buffer (addr, buf, size, todo / size, +DISP_LINE_LEN / size); + bytes -= todo; + } + + last_addr = addr; + last_length = length; + last_size = size;return 0 ; }
cmd/io.c int do_io_iow(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
Quoted 9 lines
cmd/io.c +1
-2@@ -69,7 +115,7 @@ int do_io_iow(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) }/**************************************************/ -U_BOOT_CMD (iod,2 ,0 , do_io_iod, +U_BOOT_CMD (iod,3 ,1 , do_io_iod,"IO space display" ,"[.b, .w, .l] address" ); U_BOOT_CMD(iow, 3, 0, do_io_iow, --
Other than above issues,
PATCH 41/126 iod: Enhance to support display of multiple values
Quoted 85 lines · Bin Meng
Quoted 18 lines · Simon Glass
At present the 'iod' command differs from 'md' in that it only shows a single value. It is useful to see a dump of multiple values, particularly when x86 peripherals contain register sets accessible via I/O ports.
Enhance the command to match md.
Signed-off-by Simon Glass <[email protected]>---
cmd/io.c | 84 +++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 65 insertions(+), 19 deletions(-)cmd/io.c +0
-0cmd/io.c line 14
Quoted 4 lines
cmd/io.c +1
-0@@ -11,6 +11,15 @@#include <command.h> #include <asm/io.h> +/* Display values from last command. nits: wrong multi-line comment format
cmd/io.c line 15
Quoted 1 line
cmd/io.c +1
-0+* Memory modify remembered values are different from display memory. This comment does not apply as there is no "memory modify" in this context.
Quoted 13 lines
cmd/io.c +7
-0+*/ +static ulong last_addr, last_size; +static ulong last_length =0x40 ; +static ulong base_address; + +#define DISP_LINE_LEN 16 +/* * IO Display * @@ -19,26 +28,63 @@*/ int do_io_iod (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[])cmd/io.c line 35
Quoted 10 lines
cmd/io.c +5
-4{ -ulong addr; -int size; - -if (argc !=2 ) +ulong addr, length, bytes; +u8 buf[DISP_LINE_LEN ]; +int size, todo; + +/* We use the last specified parameters, unless new ones are nits: wrong multi-line comment format
Quoted 15 lines
cmd/io.c +7
-6+* entered. +*/ + addr = last_addr; + size = last_size; + length = last_length; + +if (argc <2 )return CMD_RET_USAGE ; - size =cmd_get_data_size (argv[0 ],4 ); -if (size <0 ) -return 1 ; - - addr =simple_strtoul (argv[1 ],NULL ,16 ); -cmd/io.c line 46
Quoted 10 lines
cmd/io.c +2
-8-printf ("%04x: " , (u16 ) addr); - -if (size ==4 ) -printf ("%08x\n" ,inl (addr)); -else if (size ==2 ) -printf ("%04x\n" ,inw (addr)); -else -printf ("%02x\n" ,inb (addr)); +if ((flag &CMD_FLAG_REPEAT ) ==0 ) { +/* New command specified. Check for a size specification. nits: wrong multi-line comment format
Quoted 13 lines
cmd/io.c line 57
Quoted 11 lines
cmd/io.c +11
-0+* Defaults to long if no or incorrect specification. +*/ + size =cmd_get_data_size (argv[0 ],4 ); +if (size <0 ) +return 1 ; + +/* Address is specified since argc > 1 */ + addr =simple_strtoul (argv[1 ],NULL ,16 ); + addr += base_address; + +/* If another parameter, it is the length to display. nits: wrong multi-line comment format
Corrected these wrong multi-line comment format, and
Quoted 42 lines
Quoted 42 lines
cmd/io.c +31
-1+* Length is the number of objects, not number of bytes. +*/ +if (argc >2 ) + length =simple_strtoul (argv[2 ],NULL ,16 ); + } + + bytes = size * length; + +/* Print the lines */ +for (; bytes >0 ; addr += todo) { +u8 *ptr = buf; +int i; + + todo =min (bytes, (ulong )DISP_LINE_LEN ); +for (i =0 ; i < todo; i += size, ptr += size) { +if (size ==4 ) + *(u32 *)ptr =inl (addr + i); +else if (size ==2 ) + *(u16 *)ptr =inw (addr + i); +else + *ptr =inb (addr + i); + } +print_buffer (addr, buf, size, todo / size, +DISP_LINE_LEN / size); + bytes -= todo; + } + + last_addr = addr; + last_length = length; + last_size = size;return 0 ; }@@ -69,7 +115,7 @@ int do_io_iow(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) }/**************************************************/ -U_BOOT_CMD (iod,2 ,0 , do_io_iod, +U_BOOT_CMD (iod,3 ,1 , do_io_iod,"IO space display" ,"[.b, .w, .l] address" );
Quoted 7 lines
cmd/io.c int do_io_iow(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
Quoted 2 lines
cmd/io.c +0
-1U_BOOT_CMD(iow, 3, 0, do_io_iow, --Other than above issues,
Reviewed-by Bin Meng <[email protected]>Tested-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 42/126 arm: mxs: Correct CONFIG_SPL_NO_CPU_SUPPORT option
In reply to Simon GlassAt present this is defined in Kconfig but there is a separate one in the CONFIG whitelist. It looks like these are duplicates.
Rename the non-Kconfig one and remove it from the whitelist.
---
arch/arm/cpu/arm926ejs/Makefile | 2 +- include/configs/mxs.h | 2 +- scripts/config_whitelist.txt | 1 - 3 files changed, 2 insertions(+), 3 deletions(-)
arch/arm/cpu/arm926ejs/Makefile +1 -1
@@ -7,7 +7,7 @@ extra-y = start.o obj-y = cpu.o cache.o ifdef CONFIG_SPL_BUILD -ifdef CONFIG_SPL_NO_CPU_SUPPORT_CODE +ifdef CONFIG_SPL_NO_CPU_SUPPORT extra-y := endif endif
include/configs/mxs.h +1 -1
@@ -45,7 +45,7 @@/* SPL */ #ifndef CONFIG_SPL_FRAMEWORK -#define CONFIG_SPL_NO_CPU_SUPPORT_CODE +#define CONFIG_SPL_NO_CPU_SUPPORT #define CONFIG_SPL_START_S_PATH "arch/arm/cpu/arm926ejs/mxs"#endif
scripts/config_whitelist.txt +0 -1
@@ -1728,7 +1728,6 @@ CONFIG_SPL_NAND_MINIMAL CONFIG_SPL_NAND_RAW_ONLY CONFIG_SPL_NAND_SOFTECC CONFIG_SPL_NAND_WORKSPACE -CONFIG_SPL_NO_CPU_SUPPORT_CODE CONFIG_SPL_PAD_TO CONFIG_SPL_PANIC_ON_RAW_IMAGE CONFIG_SPL_PBL_PAD
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 42/126 arm: mxs: Correct CONFIG_SPL_NO_CPU_SUPPORT option
Quoted 6 lines · Simon Glass
At present this is defined in
Kconfigbut there is a separate one in the CONFIG whitelist. It looks like these are duplicates.Rename the non-Kconfig one and remove it from the whitelist.
Quoted 8 lines
Signed-off-by Simon Glass <[email protected]>---
arch/arm/cpu/arm926ejs/Makefile | 2 +- include/configs/mxs.h | 2 +- scripts/config_whitelist.txt | 1 - 3 files changed, 2 insertions(+), 3 deletions(-)
PATCH 42/126 arm: mxs: Correct CONFIG_SPL_NO_CPU_SUPPORT option
Quoted 11 lines · Bin Meng
Quoted 9 lines · Simon Glass
At present this is defined in
Kconfigbut there is a separate one in the CONFIG whitelist. It looks like these are duplicates.Rename the non-Kconfig one and remove it from the whitelist.
Signed-off-by Simon Glass <[email protected]>---
Quoted 7 lines
Quoted 5 lines
arch/arm/cpu/arm926ejs/Makefile | 2 +- include/configs/mxs.h | 2 +- scripts/config_whitelist.txt | 1 - 3 files changed, 2 insertions(+), 3 deletions(-)Reviewed-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 43/126 spl: Allow tiny printf() to be controlled in SPL and TPL
In reply to Simon GlassAt present there is only one control for this and it is used for both SPL and TPL. But SPL might have a lot more space than TPL so the extra cost of a full printf() might be acceptable.
Split the option into two, providing separate SPL and TPL controls. The TPL setting defaults to the same as SPL.
---
arch/arm/Kconfig | 2 +- arch/arm/mach-omap2/Kconfig | 6 +++--- arch/arm/mach-rmobile/Kconfig | 2 +- arch/arm/mach-rmobile/Kconfig.32 | 14 ++++++------- arch/arm/mach-socfpga/Kconfig | 4 ++-- common/spl/Kconfig | 2 +- common/xyzModem.c | 2 +- configs/am335x_pdu001_defconfig | 2 +- configs/ls1043ardb_nand_SECURE_BOOT_defconfig | 2 +- configs/ls1043ardb_nand_defconfig | 2 +- .../ls1043ardb_sdcard_SECURE_BOOT_defconfig | 2 +- configs/ls1043ardb_sdcard_defconfig | 2 +- configs/sandbox_spl_defconfig | 2 +- drivers/gpio/gpio-uclass.c | 4 ++-- drivers/mmc/mmc.c | 2 +- drivers/mtd/spi/sf-uclass.c | 2 +- lib/Kconfig | 20 +++++++++++++++---- lib/Makefile | 2 +- 18 files changed, 43 insertions(+), 31 deletions(-)
arch/arm/Kconfig +1 -1
@@ -954,7 +954,7 @@ config ARCH_SUNXI select USB if DISTRO_DEFAULTS select USB_KEYBOARD if DISTRO_DEFAULTS select USB_STORAGE if DISTRO_DEFAULTS - select USE_TINY_PRINTF + select SPL_USE_TINY_PRINTF imply CMD_DM imply CMD_GPT imply CMD_UBI if NAND
arch/arm/mach-omap2/Kconfig +3 -3
@@ -11,7 +11,7 @@ config OMAP34XX select ARM_ERRATA_454179 select ARM_ERRATA_621766 select ARM_ERRATA_725233 - select USE_TINY_PRINTF if SPL + select SPL_USE_TINY_PRINTF if SPL imply NAND_OMAP_GPMC imply SPL_FS_EXT4 imply SPL_FS_FAT
@@ -31,7 +31,7 @@ config OMAP34XX config OMAP44XX bool "OMAP44XX SoC" - select USE_TINY_PRINTF + select SPL_USE_TINY_PRINTF imply NAND_OMAP_ELM imply NAND_OMAP_GPMC imply SPL_DISPLAY_PRINT
@@ -124,7 +124,7 @@ config AM33XX imply SPL_NAND_SUPPORT imply SYS_I2C_OMAP24XX imply SYS_THUMB_BUILD - imply USE_TINY_PRINTF + imply SPL_USE_TINY_PRINTF help Support for AM335x SOC from Texas Instruments. The AM335x high performance SOC features a Cortex-A8
arch/arm/mach-rmobile/Kconfig +1 -1
@@ -32,7 +32,7 @@ config RCAR_GEN3 imply SPL_SYS_MALLOC_SIMPLE imply SPL_TINY_MEMSET imply SPL_YMODEM_SUPPORT - imply USE_TINY_PRINTF + imply SPL_USE_TINY_PRINTF config RZA1 prompt "Renesas ARM SoCs RZ/A1 (32bit)"
arch/arm/mach-rmobile/Kconfig.32 +7 -7
@@ -65,7 +65,7 @@ config TARGET_GOSE select DM_SERIAL select SPL_TINY_MEMSET select SUPPORT_SPL - select USE_TINY_PRINTF + select SPL_USE_TINY_PRINTF imply CMD_DM config TARGET_KOELSCH
@@ -74,7 +74,7 @@ config TARGET_KOELSCH select DM_SERIAL select SPL_TINY_MEMSET select SUPPORT_SPL - select USE_TINY_PRINTF + select SPL_USE_TINY_PRINTF imply CMD_DM config TARGET_LAGER
@@ -83,7 +83,7 @@ config TARGET_LAGER select DM_SERIAL select SPL_TINY_MEMSET select SUPPORT_SPL - select USE_TINY_PRINTF + select SPL_USE_TINY_PRINTF imply CMD_DM config TARGET_KZM9G
@@ -95,7 +95,7 @@ config TARGET_ALT select DM_SERIAL select SPL_TINY_MEMSET select SUPPORT_SPL - select USE_TINY_PRINTF + select SPL_USE_TINY_PRINTF imply CMD_DM config TARGET_SILK
@@ -104,7 +104,7 @@ config TARGET_SILK select DM_SERIAL select SPL_TINY_MEMSET select SUPPORT_SPL - select USE_TINY_PRINTF + select SPL_USE_TINY_PRINTF imply CMD_DM config TARGET_PORTER
@@ -113,7 +113,7 @@ config TARGET_PORTER select DM_SERIAL select SPL_TINY_MEMSET select SUPPORT_SPL - select USE_TINY_PRINTF + select SPL_USE_TINY_PRINTF imply CMD_DM config TARGET_STOUT
@@ -122,7 +122,7 @@ config TARGET_STOUT select DM_SERIAL select SPL_TINY_MEMSET select SUPPORT_SPL - select USE_TINY_PRINTF + select SPL_USE_TINY_PRINTF imply CMD_DM endchoice
arch/arm/mach-socfpga/Kconfig +2 -2
@@ -45,7 +45,7 @@ config TARGET_SOCFPGA_ARRIA10 select SPL_SYSCON if SPL select ETH_DESIGNWARE_SOCFPGA imply FPGA_SOCFPGA - imply USE_TINY_PRINTF + imply SPL_USE_TINY_PRINTF config TARGET_SOCFPGA_CYCLONE5 bool
@@ -59,7 +59,7 @@ config TARGET_SOCFPGA_GEN5 imply SPL_SIZE_LIMIT_SUBTRACT_MALLOC imply SPL_STACK_R imply SPL_SYS_MALLOC_SIMPLE - imply USE_TINY_PRINTF + imply SPL_USE_TINY_PRINTF config TARGET_SOCFPGA_STRATIX10 bool
common/spl/Kconfig +1 -1
@@ -963,7 +963,7 @@ config SPL_SERIAL_SUPPORT for displaying messages while SPL is running. It also brings in printf() and panic() functions. This should normally be enabled unless there are space reasons not to. Even then, consider - enabling USE_TINY_PRINTF which is a small printf() version. + enabling SPL_USE_TINY_PRINTF which is a small printf() version. config SPL_SPI_FLASH_SUPPORT bool "Support SPI flash drivers"
common/xyzModem.c +1 -1
@@ -173,7 +173,7 @@ parse_num (char *s, unsigned long *val, char **es, char *delim) } -#if defined(DEBUG ) && !defined(CONFIG_USE_TINY_PRINTF ) +#if defined(DEBUG ) && !CONFIG_IS_ENABLED (USE_TINY_PRINTF )/* * Note: this debug setup works by storing the strings in a fixed buffer */
configs/am335x_pdu001_defconfig +1 -1
@@ -51,5 +51,5 @@ CONFIG_SPL_DM_REGULATOR=y CONFIG_DM_REGULATOR_FIXED=y CONFIG_DM_REGULATOR_TPS65910=y CONFIG_CONS_INDEX=4 -# CONFIG_USE_TINY_PRINTF is not set +# CONFIG_SPL_USE_TINY_PRINTF is not set # CONFIG_EFI_LOADER is not set
configs/ls1043ardb_nand_SECURE_BOOT_defconfig +1 -1
@@ -67,7 +67,7 @@ CONFIG_USB=y CONFIG_DM_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y -# CONFIG_USE_TINY_PRINTF is not set +# CONFIG_SPL_USE_TINY_PRINTF is not set CONFIG_RSA=y CONFIG_SPL_RSA=y CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
configs/ls1043ardb_nand_defconfig +1 -1
@@ -67,5 +67,5 @@ CONFIG_USB=y CONFIG_DM_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y -# CONFIG_USE_TINY_PRINTF is not set +# CONFIG_SPL_USE_TINY_PRINTF is not set CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
configs/ls1043ardb_sdcard_SECURE_BOOT_defconfig +1 -1
@@ -65,7 +65,7 @@ CONFIG_USB=y CONFIG_DM_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y -# CONFIG_USE_TINY_PRINTF is not set +# CONFIG_SPL_USE_TINY_PRINTF is not set CONFIG_RSA=y CONFIG_SPL_RSA=y CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
configs/ls1043ardb_sdcard_defconfig +1 -1
@@ -65,5 +65,5 @@ CONFIG_USB=y CONFIG_DM_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y -# CONFIG_USE_TINY_PRINTF is not set +# CONFIG_SPL_USE_TINY_PRINTF is not set CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
configs/sandbox_spl_defconfig +1 -1
@@ -191,7 +191,7 @@ CONFIG_OSD=y CONFIG_SANDBOX_OSD=y CONFIG_FS_CBFS=y CONFIG_FS_CRAMFS=y -# CONFIG_USE_TINY_PRINTF is not set +# CONFIG_SPL_USE_TINY_PRINTF is not set CONFIG_CMD_DHRYSTONE=y CONFIG_TPM=y CONFIG_LZ4=y
drivers/gpio/gpio-uclass.c +2 -2
@@ -294,7 +294,7 @@ int dm_gpio_request(struct gpio_desc *desc, const char *label)static int dm_gpio_requestf (struct gpio_desc *desc,const char *fmt, ...) { -#if !defined(CONFIG_SPL_BUILD ) || !defined(CONFIG_USE_TINY_PRINTF ) +#if !defined(CONFIG_SPL_BUILD ) || !CONFIG_IS_ENABLED (USE_TINY_PRINTF )va_list args;char buf[40 ];
@@ -343,7 +343,7 @@ int gpio_request(unsigned gpio, const char *label)*/ int gpio_requestf (unsigned gpio,const char *fmt, ...) { -#if !defined(CONFIG_SPL_BUILD ) || !defined(CONFIG_USE_TINY_PRINTF ) +#if !defined(CONFIG_SPL_BUILD ) || !CONFIG_IS_ENABLED (USE_TINY_PRINTF )va_list args;char buf[40 ];
drivers/mmc/mmc.c +1 -1
@@ -2577,7 +2577,7 @@ static int mmc_startup(struct mmc *mmc) bdesc->lba =lldiv (mmc->capacity, mmc->read_bl_len);#if !defined(CONFIG_SPL_BUILD ) || \ (defined(CONFIG_SPL_LIBCOMMON_SUPPORT ) && \ - !defined(CONFIG_USE_TINY_PRINTF )) + !CONFIG_IS_ENABLED (USE_TINY_PRINTF ))sprintf (bdesc->vendor,"Man %06x Snr %04x%04x" , mmc->cid[0 ] >>24 , (mmc->cid[2 ] &0xffff ), (mmc->cid[3 ] >>16 ) &0xffff );
drivers/mtd/spi/sf-uclass.c +1 -1
@@ -77,7 +77,7 @@ int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs,char *str;int ret; -#if defined(CONFIG_SPL_BUILD ) && defined(CONFIG_USE_TINY_PRINTF ) +#if defined(CONFIG_SPL_BUILD ) &&CONFIG_IS_ENABLED (USE_TINY_PRINTF ) str ="spi_flash" ;#else char name[30 ];
lib/Kconfig +16 -4
@@ -40,12 +40,12 @@ config PRINTF config SPL_PRINTF bool select SPL_SPRINTF - select SPL_STRTO if !USE_TINY_PRINTF + select SPL_STRTO if !SPL_USE_TINY_PRINTF config TPL_PRINTF bool select TPL_SPRINTF - select TPL_STRTO if !USE_TINY_PRINTF + select TPL_STRTO if !TPL_USE_TINY_PRINTF config SPRINTF bool
@@ -95,9 +95,9 @@ config SYS_HZ get_timer() must operate in milliseconds and this option must be set to 1000. -config USE_TINY_PRINTF +config SPL_USE_TINY_PRINTF bool "Enable tiny printf() version" - depends on SPL || TPL + depends on SPL default y help This option enables a tiny, stripped down printf version.
@@ -107,6 +107,18 @@ config USE_TINY_PRINTF The supported format specifiers are %c, %s, %u/%d and %x. +config TPL_USE_TINY_PRINTF + bool "Enable tiny printf() version" + depends on TPL + default y if SPL_USE_TINY_PRINTF + help + This option enables a tiny, stripped down printf version. + This should only be used in space limited environments, + like SPL versions with hard memory limits. This version + reduces the code size by about 2.5KiB on armv7. + + The supported format specifiers are %c, %s, %u/%d and %x. + config PANIC_HANG bool "Do not reset the system on fatal error" help
lib/Makefile +1 -1
@@ -106,7 +106,7 @@ obj-y += panic.o ifeq ($(CONFIG_$(SPL_TPL_)BUILD),y) # SPL U-Boot may use full-printf, tiny-printf or none at all -ifdef CONFIG_USE_TINY_PRINTF +ifdef CONFIG_$(SPL_TPL_)USE_TINY_PRINTF obj-$(CONFIG_$(SPL_TPL_)SPRINTF) += tiny-printf.o else obj-$(CONFIG_$(SPL_TPL_)SPRINTF) += vsprintf.o strmhz.o
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 43/126 spl: Allow tiny printf() to be controlled in SPL and TPL
Quoted 22 lines · Simon Glass
At present there is only one control for this and it is used for both SPL and TPL. But SPL might have a lot more space than TPL so the extra cost of a full
printf()might be acceptable.Split the option into two, providing separate SPL and TPL controls. The TPL setting defaults to the same as SPL.
Signed-off-by Simon Glass <[email protected]>---
arch/arm/Kconfig | 2 +- arch/arm/mach-omap2/Kconfig | 6 +++--- arch/arm/mach-rmobile/Kconfig | 2 +- arch/arm/mach-rmobile/Kconfig.32 | 14 ++++++------- arch/arm/mach-socfpga/Kconfig | 4 ++-- common/spl/Kconfig | 2 +- common/xyzModem.c | 2 +- configs/am335x_pdu001_defconfig | 2 +- configs/ls1043ardb_nand_SECURE_BOOT_defconfig | 2 +- configs/ls1043ardb_nand_defconfig | 2 +- .../ls1043ardb_sdcard_SECURE_BOOT_defconfig | 2 +-
Quoted 9 lines
configs/ls1043ardb_sdcard_defconfig | 2 +- configs/sandbox_spl_defconfig | 2 +- drivers/gpio/gpio-uclass.c | 4 ++-- drivers/mmc/mmc.c | 2 +- drivers/mtd/spi/sf-uclass.c | 2 +- lib/Kconfig | 20 +++++++++++++++---- lib/Makefile | 2 +- 18 files changed, 43 insertions(+), 31 deletions(-)
PATCH 43/126 spl: Allow tiny printf() to be controlled in SPL and TPL
Quoted 34 lines · Bin Meng
Quoted 22 lines · Simon Glass
At present there is only one control for this and it is used for both SPL and TPL. But SPL might have a lot more space than TPL so the extra cost of a full
printf()might be acceptable.Split the option into two, providing separate SPL and TPL controls. The TPL setting defaults to the same as SPL.
Signed-off-by Simon Glass <[email protected]>---
arch/arm/Kconfig | 2 +- arch/arm/mach-omap2/Kconfig | 6 +++--- arch/arm/mach-rmobile/Kconfig | 2 +- arch/arm/mach-rmobile/Kconfig.32 | 14 ++++++------- arch/arm/mach-socfpga/Kconfig | 4 ++-- common/spl/Kconfig | 2 +- common/xyzModem.c | 2 +- configs/am335x_pdu001_defconfig | 2 +- configs/ls1043ardb_nand_SECURE_BOOT_defconfig | 2 +- configs/ls1043ardb_nand_defconfig | 2 +- .../ls1043ardb_sdcard_SECURE_BOOT_defconfig | 2 +-Quoted 9 lines
configs/ls1043ardb_sdcard_defconfig | 2 +- configs/sandbox_spl_defconfig | 2 +- drivers/gpio/gpio-uclass.c | 4 ++-- drivers/mmc/mmc.c | 2 +- drivers/mtd/spi/sf-uclass.c | 2 +- lib/Kconfig | 20 +++++++++++++++---- lib/Makefile | 2 +- 18 files changed, 43 insertions(+), 31 deletions(-)
Quoted 1 line
Reviewed-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 44/126 spl: Convert CONFIG_SPL_LIMIT to hex
In reply to Simon GlassThis is currently a decimal value which is not as convenient or meaningful. Also U-Boot tends to use hex everywhere.
Convert this option to hex and add a comment for the size_check macro.
---
Makefile | 10 +++++++--- arch/arm/mach-socfpga/Kconfig | 2 +- common/spl/Kconfig | 2 +- configs/evb-rk3288_defconfig | 2 +- configs/tinker-rk3288_defconfig | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-)
Makefile +7 -3
@@ -337,14 +337,18 @@ endif # KBUILD_MODULES := 1 #endif +# Check ths size of a binary: +# Args: +# $1: File to check +# #2: Size limit in bytes (decimal or 0xhex) define size_check actual=$$( wc -c $1 | awk '{print $$1}'); \ limit=$$( printf "%d" $2 ); \ if test $$actual -gt $$limit; then \ echo "$1 exceeds file size limit:" >&2; \ - echo " limit: $$limit bytes" >&2; \ - echo " actual: $$actual bytes" >&2; \ - echo " excess: $$((actual - limit)) bytes" >&2; \ + echo " limit: $$(printf %#x bytes $$limit) bytes" >&2; \ + echo " actual: $$(printf %#x $$actual) bytes" >&2; \ + echo " excess: $$(printf %#x $$((actual - limit))) bytes" >&2;\ exit 1; \ fi endef
arch/arm/mach-socfpga/Kconfig +1 -1
@@ -4,7 +4,7 @@ config NR_DRAM_BANKS default 1 config SPL_SIZE_LIMIT - default 65536 if TARGET_SOCFPGA_GEN5 + default 0x10000 if TARGET_SOCFPGA_GEN5 config SPL_SIZE_LIMIT_PROVIDE_STACK default 0x200 if TARGET_SOCFPGA_GEN5
common/spl/Kconfig +1 -1
@@ -26,7 +26,7 @@ config SPL_FRAMEWORK and the Linux Kernel. If unsure, say Y. config SPL_SIZE_LIMIT - int "Maximum size of SPL image" + hex "Maximum size of SPL image" depends on SPL default 69632 if ARCH_MX6 default 0
configs/evb-rk3288_defconfig +1 -1
@@ -4,7 +4,7 @@ CONFIG_SYS_TEXT_BASE=0x01000000 CONFIG_ROCKCHIP_RK3288=y CONFIG_TARGET_EVB_RK3288=y CONFIG_NR_DRAM_BANKS=1 -CONFIG_SPL_SIZE_LIMIT=307200 +CONFIG_SPL_SIZE_LIMIT=0x4b000 CONFIG_SPL_STACK_R_ADDR=0x80000 CONFIG_DEBUG_UART_BASE=0xff690000 CONFIG_DEBUG_UART_CLOCK=24000000
configs/tinker-rk3288_defconfig +1 -1
@@ -5,7 +5,7 @@ CONFIG_SPL_GPIO_SUPPORT=y CONFIG_ROCKCHIP_RK3288=y CONFIG_TARGET_TINKER_RK3288=y CONFIG_NR_DRAM_BANKS=1 -CONFIG_SPL_SIZE_LIMIT=307200 +CONFIG_SPL_SIZE_LIMIT=0x4b000 CONFIG_SPL_STACK_R_ADDR=0x80000 CONFIG_DEBUG_UART_BASE=0xff690000 CONFIG_DEBUG_UART_CLOCK=24000000
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 44/126 spl: Convert CONFIG_SPL_LIMIT to hex
You've got the config name wrong in the summary (forgot '_SIZE' in the middle).
Quoted 11 lines · Simon Glass
This is currently a decimal value which is not as convenient or meaningful. Also U-Boot tends to use hex everywhere.
Convert this option to hex and add a comment for the
size_checkmacro.Signed-off-by Simon Glass <[email protected]>---
Makefile | 10 +++++++--- arch/arm/mach-socfpga/Kconfig | 2 +-
I would have expected to be on CC for this file?
Otherwise:
Regards,
Simon
Quoted 90 lines
common/spl/Kconfig | 2 +- configs/evb-rk3288_defconfig | 2 +- configs/tinker-rk3288_defconfig | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-)Makefile +7
-3@@ -337,14 +337,18 @@ endif # KBUILD_MODULES := 1 #endif +# Check ths size of a binary: +# Args: +# $1: File to check +# #2: Size limit in bytes (decimal or 0xhex) define size_check actual=$$( wc -c $1 | awk '{print $$1}'); \ limit=$$( printf "%d" $2 ); \ if test $$actual -gt $$limit; then \ echo "$1 exceeds file size limit:" >&2; \ - echo " limit: $$limit bytes" >&2; \ - echo " actual: $$actual bytes" >&2; \ - echo " excess: $$((actual - limit)) bytes" >&2; \ + echo " limit: $$(printf %#x bytes $$limit) bytes" >&2; \ + echo " actual: $$(printf %#x $$actual) bytes" >&2; \ + echo " excess: $$(printf %#x $$((actual - limit))) bytes" >&2;\ exit 1; \ fi endefarch/arm/mach-socfpga/Kconfig +1
-1@@ -4,7 +4,7 @@ config NR_DRAM_BANKS default 1 config SPL_SIZE_LIMIT - default 65536 if TARGET_SOCFPGA_GEN5 + default 0x10000 if TARGET_SOCFPGA_GEN5 config SPL_SIZE_LIMIT_PROVIDE_STACK default 0x200 if TARGET_SOCFPGA_GEN5common/spl/Kconfig +1
-1@@ -26,7 +26,7 @@ config SPL_FRAMEWORK and the Linux Kernel. If unsure, say Y. config SPL_SIZE_LIMIT - int "Maximum size of SPL image" + hex "Maximum size of SPL image" depends on SPL default 69632 if ARCH_MX6 default 0configs/evb-rk3288_defconfig +1
-1@@ -4,7 +4,7 @@ CONFIG_SYS_TEXT_BASE=0x01000000 CONFIG_ROCKCHIP_RK3288=y CONFIG_TARGET_EVB_RK3288=y CONFIG_NR_DRAM_BANKS=1 -CONFIG_SPL_SIZE_LIMIT=307200 +CONFIG_SPL_SIZE_LIMIT=0x4b000 CONFIG_SPL_STACK_R_ADDR=0x80000 CONFIG_DEBUG_UART_BASE=0xff690000 CONFIG_DEBUG_UART_CLOCK=24000000configs/tinker-rk3288_defconfig +1
-2@@ -5,7 +5,7 @@ CONFIG_SPL_GPIO_SUPPORT=y CONFIG_ROCKCHIP_RK3288=y CONFIG_TARGET_TINKER_RK3288=y CONFIG_NR_DRAM_BANKS=1 -CONFIG_SPL_SIZE_LIMIT=307200 +CONFIG_SPL_SIZE_LIMIT=0x4b000 CONFIG_SPL_STACK_R_ADDR=0x80000 CONFIG_DEBUG_UART_BASE=0xff690000 CONFIG_DEBUG_UART_CLOCK=24000000 --2.23.0.444.g18eeb5a265-goog
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
PATCH 44/126 spl: Convert CONFIG_SPL_LIMIT to hex
In reply to Simon GlassQuoted 7 lines · Simon Glass
This is currently a decimal value which is not as convenient or meaningful. Also U-Boot tends to use hex everywhere.
Convert this option to hex and add a comment for the
size_checkmacro.Signed-off-by Simon Glass <[email protected]>
Quoted 9 lines
---
Makefile | 10 +++++++--- arch/arm/mach-socfpga/Kconfig | 2 +- common/spl/Kconfig | 2 +- configs/evb-rk3288_defconfig | 2 +- configs/tinker-rk3288_defconfig | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-)
I can fix the commit summary issue (missing _SIZE, as pointed out by Simon Goldschmidt) when applying.
PATCH 44/126 spl: Convert CONFIG_SPL_LIMIT to hex
Quoted 19 lines · Bin Meng
Quoted 7 lines · Simon Glass
This is currently a decimal value which is not as convenient or meaningful. Also U-Boot tends to use hex everywhere.
Convert this option to hex and add a comment for the
size_checkmacro.Signed-off-by Simon Glass <[email protected]>Quoted 9 lines
---
Makefile | 10 +++++++--- arch/arm/mach-socfpga/Kconfig | 2 +- common/spl/Kconfig | 2 +- configs/evb-rk3288_defconfig | 2 +- configs/tinker-rk3288_defconfig | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-)
Quoted 4 lines
Acked-by Bin Meng <[email protected]>I can fix the commit summary issue (missing
_SIZE, as pointed out by Simon Goldschmidt) when applying.
Fixed the typo in the commit title, and
applied to u-boot-x86/next, thanks!
PATCH 45/126 spl: Add a size check for TPL
In reply to Simon GlassWe have the ability to enforce a maximum size for SPL but not yet for TPL. Add a new option for this.
Document the size check macro while we are here.
---
Makefile | 7 +++++++ common/spl/Kconfig | 8 ++++++++ 2 files changed, 15 insertions(+)
Makefile +7 -0
@@ -806,6 +806,12 @@ else SPL_SIZE_CHECK = endif +ifneq ($(CONFIG_TPL_SIZE_LIMIT),0) +TPL_SIZE_CHECK = @$(call size_check,$@,$(CONFIG_TPL_SIZE_LIMIT)) +else +TPL_SIZE_CHECK = +endif + # Statically apply RELA-style relocations (currently arm64 only) # This is useful for arm64 where static relocation needs to be performed on # the raw binary, but certain simulators only accept an ELF file (but don't
@@ -1786,6 +1792,7 @@ spl/boot.bin: spl/u-boot-spl tpl/u-boot-tpl.bin: tools prepare \ $(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_SPL_OF_PLATDATA),dts/dt.dtb) $(Q)$(MAKE) obj=tpl -f $(srctree)/scripts/Makefile.spl all + $(TPL_SIZE_CHECK) TAG_SUBDIRS := $(patsubst %,$(srctree)/%,$(u-boot-dirs) include)
common/spl/Kconfig +8 -0
@@ -1183,6 +1183,14 @@ config TPL if TPL +config TPL_SIZE_LIMIT + hex "Maximum size of TPL image" + depends on TPL + default 0 + help + Specifies the maximum length of the U-Boot TPL image. + If this value is zero, it is ignored. + config TPL_HANDOFF bool "Pass hand-off information from TPL to SPL and U-Boot proper" depends on HANDOFF && TPL_BLOBLIST
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 45/126 spl: Add a size check for TPL
Hi Simon,
Quoted 18 lines · Simon Glass
We have the ability to enforce a maximum size for SPL but not yet for TPL. Add a new option for this.
Document the size check macro while we are here.
Signed-off-by Simon Glass <[email protected]>---
Makefile | 7 +++++++ common/spl/Kconfig | 8 ++++++++ 2 files changed, 15 insertions(+)Makefile +0
-0
Makefile else · line 810
Quoted 5 lines
Makefile +2
-0@@ -806,6 +806,12 @@ else SPL_SIZE_CHECK = endif +ifneq ($(CONFIG_TPL_SIZE_LIMIT),0) +TPL_SIZE_CHECK = @$(call size_check,$@,$(CONFIG_TPL_SIZE_LIMIT))
Using a constant here is not what SPL does by now: some months ago, I implemented a more sophisticated size check for SPL that also integrates 'gd', stack and heap usage into the size check. Wouldn't that be required for TPL as well (at least on platforms where everything must fit into SRAM)?
Regards,
Simon
Quoted 37 lines
Makefile +5
-0+else +TPL_SIZE_CHECK = +endif + # Statically apply RELA-style relocations (currently arm64 only) # This is useful for arm64 where static relocation needs to be performed on # the raw binary, but certain simulators only accept an ELF file (but don't@@ -1786,6 +1792,7 @@ spl/boot.bin: spl/u-boot-spl tpl/u-boot-tpl.bin: tools prepare \ $(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_SPL_OF_PLATDATA),dts/dt.dtb) $(Q)$(MAKE) obj=tpl -f $(srctree)/scripts/Makefile.spl all + $(TPL_SIZE_CHECK) TAG_SUBDIRS := $(patsubst %,$(srctree)/%,$(u-boot-dirs) include)common/spl/Kconfig +8
-1@@ -1183,6 +1183,14 @@ config TPL if TPL +config TPL_SIZE_LIMIT + hex "Maximum size of TPL image" + depends on TPL + default 0 + help + Specifies the maximum length of the U-Boot TPL image. + If this value is zero, it is ignored. + config TPL_HANDOFF bool "Pass hand-off information from TPL to SPL and U-Boot proper" depends on HANDOFF && TPL_BLOBLIST --2.23.0.444.g18eeb5a265-goog
PATCH 45/126 spl: Add a size check for TPL
Hi Simon,
Quoted 25 lines · Simon Goldschmidt
Hi Simon,
Quoted 21 lines · Simon Glass
We have the ability to enforce a maximum size for SPL but not yet for TPL. Add a new option for this.
Document the size check macro while we are here.
Signed-off-by Simon Glass <[email protected]>---
Makefile | 7 +++++++ common/spl/Kconfig | 8 ++++++++ 2 files changed, 15 insertions(+)Makefile +0
-0@@ -806,6 +806,12 @@ else SPL_SIZE_CHECK = endif
Quoted 7 lines
Makefile else · line 810
Quoted 2 lines
Makefile +2
-0+ifneq ($(CONFIG_TPL_SIZE_LIMIT),0) +TPL_SIZE_CHECK = @$(call size_check,$@,$(CONFIG_TPL_SIZE_LIMIT))Using a constant here is not what SPL does by now: some months ago, I implemented a more sophisticated size check for SPL that also integrates 'gd', stack and heap usage into the size check. Wouldn't that be required for TPL as well (at least on platforms where everything must fit into SRAM)?
Yes I see, but in this case we just need the image to be below a certain size. The actual memory used is somewhere else.
Regards,
SImon
PATCH 46/126 spl: Allow distinguishing between two phases in U-Boot
In reply to Simon GlassU-Boot has two distinct phases: before and after relocation. These are commonly referred to as F (running from Flash) and R (Relocated and running from RAM). Some drivers want to do different things in these phases so update the SPL phase function to return a different value for each.
---
include/spl.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
include/spl.h +11 -5
@@ -50,9 +50,10 @@ static inline bool u_boot_first_phase(void) }enum u_boot_phase { -PHASE_TPL , -PHASE_SPL , -PHASE_U_BOOT , +PHASE_TPL ,/* Running in TPL */ +PHASE_SPL ,/* Running in SPL */ +PHASE_BOARD_F ,/* Running in U-Boot before relocation */ +PHASE_BOARD_R ,/* Running in U-Boot after relocation */ };/**
@@ -92,7 +93,7 @@ enum u_boot_phase {* * but with this you can use: * -* if (spl_phase() == PHASE_U_BOOT) { +* if (spl_phase() == PHASE_BOARD_F) { * ... * } *
@@ -105,7 +106,12 @@ static inline enum u_boot_phase spl_phase(void)#elif CONFIG_SPL_BUILD return PHASE_SPL ;#else -return PHASE_U_BOOT ; +DECLARE_GLOBAL_DATA_PTR ; + +if (!(gd->flags &GD_FLG_RELOC )) +return PHASE_BOARD_F ; +else +return PHASE_BOARD_R ;#endif }
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 46/126 spl: Allow distinguishing between two phases in U-Boot
Quoted 7 lines · Simon Glass
U-Boot has two distinct phases: before and after relocation. These are commonly referred to as F (running from Flash) and R (Relocated and running from RAM). Some drivers want to do different things in these phases so update the SPL phase function to return a different value for each.
Quoted 6 lines
Signed-off-by Simon Glass <[email protected]>---
include/spl.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
PATCH 46/126 spl: Allow distinguishing between two phases in U-Boot
Quoted 9 lines · Bin Meng
Quoted 7 lines · Simon Glass
U-Boot has two distinct phases: before and after relocation. These are commonly referred to as F (running from Flash) and R (Relocated and running from RAM). Some drivers want to do different things in these phases so update the SPL phase function to return a different value for each.
Quoted 8 lines
Quoted 6 lines
Signed-off-by Simon Glass <[email protected]>---
include/spl.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)Reviewed-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 47/126 spl: Allow SPL/TPL to use of-platdata without libfdt
In reply to Simon GlassAt present libfdt is included in SPL/TPL if SPL/TPL_OF_CONTROL is enabled. But if of-platdata is in use this is not required. Update the condition to avoid building this extra code. This ensures that if a libfdt function is used it will produce a link error rather than silently increasing the build size.
---
lib/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/Kconfig +2 -2
@@ -473,7 +473,7 @@ config OF_LIBFDT_OVERLAY config SPL_OF_LIBFDT bool "Enable the FDT library for SPL" - default y if SPL_OF_CONTROL + default y if SPL_OF_CONTROL && !SPL_OF_PLATDATA help This enables the FDT library (libfdt). It provides functions for accessing binary device tree images in memory, such as adding and
@@ -483,7 +483,7 @@ config SPL_OF_LIBFDT config TPL_OF_LIBFDT bool "Enable the FDT library for TPL" - default y if TPL_OF_CONTROL + default y if TPL_OF_CONTROL && !TPL_OF_PLATDATA help This enables the FDT library (libfdt). It provides functions for accessing binary device tree images in memory, such as adding and
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 47/126 spl: Allow SPL/TPL to use of-platdata without libfdt
Quoted 7 lines · Simon Glass
At present libfdt is included in SPL/TPL if SPL/TPL_OF_CONTROL is enabled. But if of-platdata is in use this is not required. Update the condition to avoid building this extra code. This ensures that if a libfdt function is used it will produce a link error rather than silently increasing the build size.
Quoted 6 lines
Signed-off-by Simon Glass <[email protected]>---
lib/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
PATCH 47/126 spl: Allow SPL/TPL to use of-platdata without libfdt
Quoted 9 lines · Bin Meng
Quoted 7 lines · Simon Glass
At present libfdt is included in SPL/TPL if SPL/TPL_OF_CONTROL is enabled. But if of-platdata is in use this is not required. Update the condition to avoid building this extra code. This ensures that if a libfdt function is used it will produce a link error rather than silently increasing the build size.
Quoted 8 lines
Quoted 6 lines
Signed-off-by Simon Glass <[email protected]>---
lib/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Reviewed-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 47/126 spl: Allow SPL/TPL to use of-platdata without libfdt
Quoted 14 lines · Bin Meng
Quoted 12 lines · Bin Meng
Quoted 10 lines · Simon Glass
At present libfdt is included in SPL/TPL if SPL/TPL_OF_CONTROL is enabled. But if of-platdata is in use this is not required. Update the condition to avoid building this extra code. This ensures that if a libfdt function is used it will produce a link error rather than silently increasing the build size.
Signed-off-by Simon Glass <[email protected]>---
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
lib/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Reviewed-by Bin Meng <[email protected]>applied to u-boot-x86/next, thanks!
This patch unfortunately breaks some ARM boards build, eg: chromebook_jerry
See
https://gitlab.denx.de/u-boot/custodians/u-boot-x86/-/jobs/17131
https://gitlab.denx.de/u-boot/custodians/u-boot-x86/-/jobs/17132
I will have to drop this patch from my queue.
Regards,
Bin
PATCH 47/126 spl: Allow SPL/TPL to use of-platdata without libfdt
Hi Bin,
Quoted 24 lines · Bin Meng
Quoted 14 lines · Bin Meng
Quoted 12 lines · Bin Meng
Quoted 10 lines · Simon Glass
At present libfdt is included in SPL/TPL if SPL/TPL_OF_CONTROL is enabled. But if of-platdata is in use this is not required. Update the condition to avoid building this extra code. This ensures that if a libfdt function is used it will produce a link error rather than silently increasing the build size.
Signed-off-by Simon Glass <[email protected]>---
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
lib/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Reviewed-by Bin Meng <[email protected]>applied to u-boot-x86/next, thanks!
Quoted 7 lines
This patch unfortunately breaks some ARM boards build, eg:
chromebook_jerrySee
https://gitlab.denx.de/u-boot/custodians/u-boot-x86/-/jobs/17131
https://gitlab.denx.de/u-boot/custodians/u-boot-x86/-/jobs/17132I will have to drop this patch from my queue.
I'll put this one in a separate series.
Regards,
SImon
PATCH 48/126 x86: Move acpi_s3.h to a common location
In reply to Simon GlassAt present this hedaer is only available on x86. To allow sandbox to use it for testing, move it to a common location.
---
arch/x86/cpu/baytrail/acpi.c | 2 +-
arch/x86/cpu/cpu.c | 2 +-
arch/x86/cpu/wakeup.S | 2 +-
arch/x86/lib/acpi_s3.c | 2 +-
arch/x86/lib/coreboot_table.c | 2 +-
arch/x86/lib/fsp/fsp_common.c | 2 +-
arch/x86/lib/fsp1/fsp_common.c | 2 +-
drivers/pci/pci_rom.c | 2 +-
drivers/sysreset/sysreset_x86.c | 2 +-
{arch/x86/include/asm => include}/acpi_s3.h | 0
10 files changed, 9 insertions(+), 9 deletions(-)
rename {arch/x86/include/asm => include}/acpi_s3.h (100%)arch/x86/cpu/baytrail/acpi.c +1 -1
@@ -4,10 +4,10 @@*/ #include <common.h> +#include <acpi_s3.h> #include <cpu.h> #include <dm.h> #include <dm/uclass-internal.h> -#include <asm/acpi_s3.h> #include <asm/acpi_table.h> #include <asm/io.h> #include <asm/tables.h>
arch/x86/cpu/cpu.c +1 -1
@@ -19,13 +19,13 @@*/ #include <common.h> +#include <acpi_s3.h> #include <command.h> #include <dm.h> #include <errno.h> #include <malloc.h> #include <syscon.h> #include <asm/acpi.h> -#include <asm/acpi_s3.h> #include <asm/acpi_table.h> #include <asm/control_regs.h> #include <asm/coreboot_tables.h>
arch/x86/cpu/wakeup.S +1 -1
@@ -5,7 +5,7 @@ * From coreboot src/arch/x86/wakeup.S */ -#include <asm/acpi_s3.h> +#include <acpi_s3.h> #include <asm/processor.h> #include <asm/processor-flags.h>
arch/x86/lib/acpi_s3.c +1 -1
@@ -4,8 +4,8 @@*/ #include <common.h> +#include <acpi_s3.h> #include <asm/acpi.h> -#include <asm/acpi_s3.h> #include <asm/acpi_table.h> #include <asm/post.h> #include <linux/linkage.h>
arch/x86/lib/coreboot_table.c +1 -1
@@ -4,8 +4,8 @@*/ #include <common.h> +#include <acpi_s3.h> #include <vbe.h> -#include <asm/acpi_s3.h> #include <asm/coreboot_tables.h> #include <asm/e820.h>
arch/x86/lib/fsp/fsp_common.c +1 -1
@@ -4,10 +4,10 @@*/ #include <common.h> +#include <acpi_s3.h> #include <dm.h> #include <errno.h> #include <rtc.h> -#include <asm/acpi_s3.h> #include <asm/cmos_layout.h> #include <asm/early_cmos.h> #include <asm/io.h>
arch/x86/lib/fsp1/fsp_common.c +1 -1
@@ -4,10 +4,10 @@*/ #include <common.h> +#include <acpi_s3.h> #include <dm.h> #include <errno.h> #include <rtc.h> -#include <asm/acpi_s3.h> #include <asm/cmos_layout.h> #include <asm/early_cmos.h> #include <asm/io.h>
drivers/pci/pci_rom.c +1 -1
@@ -35,7 +35,7 @@#include <linux/screen_info.h> #ifdef CONFIG_X86 -#include <asm/acpi_s3.h> +#include <acpi_s3.h> DECLARE_GLOBAL_DATA_PTR ;#endif
drivers/sysreset/sysreset_x86.c +1 -1
@@ -6,11 +6,11 @@*/ #include <common.h> +#include <acpi_s3.h> #include <dm.h> #include <efi_loader.h> #include <pch.h> #include <sysreset.h> -#include <asm/acpi_s3.h> #include <asm/io.h> #include <asm/processor.h>
include/acpi_s3.h renamed from arch/x86/include/asm/acpi_s3.h +0 -0
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 48/126 x86: Move acpi_s3.h to a common location
Quoted 7 lines · Simon Glass
At present this hedaer is only available on x86. To allow sandbox to use it for testing, move it to a common location.
Signed-off-by Simon Glass <[email protected]>---
Quoted 13 lines
arch/x86/cpu/baytrail/acpi.c | 2 +-
arch/x86/cpu/cpu.c | 2 +-
arch/x86/cpu/wakeup.S | 2 +-
arch/x86/lib/acpi_s3.c | 2 +-
arch/x86/lib/coreboot_table.c | 2 +-
arch/x86/lib/fsp/fsp_common.c | 2 +-
arch/x86/lib/fsp1/fsp_common.c | 2 +-
drivers/pci/pci_rom.c | 2 +-
drivers/sysreset/sysreset_x86.c | 2 +-
{arch/x86/include/asm => include}/acpi_s3.h | 0
10 files changed, 9 insertions(+), 9 deletions(-)
rename {arch/x86/include/asm => include}/acpi_s3.h (100%)PATCH 48/126 x86: Move acpi_s3.h to a common location
Quoted 23 lines · Bin Meng
Quoted 7 lines · Simon Glass
At present this hedaer is only available on x86. To allow sandbox to use it for testing, move it to a common location.
Signed-off-by Simon Glass <[email protected]>---
Quoted 13 lines
arch/x86/cpu/baytrail/acpi.c | 2 +- arch/x86/cpu/cpu.c | 2 +- arch/x86/cpu/wakeup.S | 2 +- arch/x86/lib/acpi_s3.c | 2 +- arch/x86/lib/coreboot_table.c | 2 +- arch/x86/lib/fsp/fsp_common.c | 2 +- arch/x86/lib/fsp1/fsp_common.c | 2 +- drivers/pci/pci_rom.c | 2 +- drivers/sysreset/sysreset_x86.c | 2 +- {arch/x86/include/asm => include}/acpi_s3.h | 0 10 files changed, 9 insertions(+), 9 deletions(-) rename {arch/x86/include/asm => include}/acpi_s3.h (100%)
Quoted 1 line
Reviewed-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 49/126 x86: pci: Drop the first parameter in pci_x86_r/w_config()
In reply to Simon GlassThis parameter is needed by the PCI driver-mode interface but is always NULL on x86. There are a number of calls to this function so it makes sense to minimise the parameters.
Adjust the x86 function to omit the first parameter, and introduce stub functions to handle the conversion.
---
arch/x86/cpu/broadwell/cpu.c | 7 ++----- arch/x86/cpu/intel_common/fast_spi.c | 3 +-- arch/x86/cpu/ivybridge/cpu.c | 3 +-- arch/x86/cpu/pci.c | 20 ++++++++------------ arch/x86/include/asm/pci.h | 15 ++++++--------- drivers/pci/pci_x86.c | 16 ++++++++++++++-- 6 files changed, 32 insertions(+), 32 deletions(-)
arch/x86/cpu/broadwell/cpu.c +2 -5
@@ -103,11 +103,8 @@ int print_cpuinfo(void)void board_debug_uart_init (void ) { -struct udevice *bus =NULL ; -/* com1 / com2 decode range */ -pci_x86_write_config (bus,PCH_DEV_LPC ,LPC_IO_DEC ,1 <<4 ,PCI_SIZE_16 ); +pci_x86_write_config (PCH_DEV_LPC ,LPC_IO_DEC ,1 <<4 ,PCI_SIZE_16 ); -pci_x86_write_config (bus,PCH_DEV_LPC ,LPC_EN ,COMA_LPC_EN , -PCI_SIZE_16 ); +pci_x86_write_config (PCH_DEV_LPC ,LPC_EN ,COMA_LPC_EN ,PCI_SIZE_16 ); }
arch/x86/cpu/intel_common/fast_spi.c +1 -2
@@ -36,8 +36,7 @@ int fast_spi_get_bios_mmap(ulong *map_basep, size_t *map_sizep, uint *offsetp)ulong bar, base, mmio_base;/* Special case to find mapping without probing the device */ -pci_x86_read_config (NULL ,PCH_DEV_SPI ,PCI_BASE_ADDRESS_0 , &bar, -PCI_SIZE_32 ); +pci_x86_read_config (PCH_DEV_SPI ,PCI_BASE_ADDRESS_0 , &bar,PCI_SIZE_32 ); mmio_base = bar &PCI_BASE_ADDRESS_MEM_MASK ; regs = (struct fast_spi_regs *)mmio_base; base =fast_spi_get_bios_region (regs, map_sizep);
arch/x86/cpu/ivybridge/cpu.c +1 -2
@@ -199,6 +199,5 @@ int print_cpuinfo(void)void board_debug_uart_init (void ) {/* This enables the debug UART */ -pci_x86_write_config (NULL ,PCH_LPC_DEV ,LPC_EN ,COMA_LPC_EN , -PCI_SIZE_16 ); +pci_x86_write_config (PCH_LPC_DEV ,LPC_EN ,COMA_LPC_EN ,PCI_SIZE_16 ); }
arch/x86/cpu/pci.c +8 -12
@@ -16,12 +16,8 @@#include <asm/io.h> #include <asm/pci.h> -/* -* TODO(sjg at chromium.org): Drop the first parameter from each of these -* functions since it is not used. -*/ -int pci_x86_read_config (struct udevice *bus,pci_dev_t bdf,uint offset, -ulong *valuep,enum pci_size_t size) +int pci_x86_read_config (pci_dev_t bdf,uint offset,ulong *valuep, +enum pci_size_t size) {outl (bdf | (offset &0xfc ) |PCI_CFG_EN ,PCI_REG_ADDR );switch (size) {
@@ -39,8 +35,8 @@ int pci_x86_read_config(struct udevice *bus, pci_dev_t bdf, uint offset,return 0 ; } -int pci_x86_write_config (struct udevice *bus,pci_dev_t bdf,uint offset, -ulong value,enum pci_size_t size) +int pci_x86_write_config (pci_dev_t bdf,uint offset,ulong value, +enum pci_size_t size) {outl (bdf | (offset &0xfc ) |PCI_CFG_EN ,PCI_REG_ADDR );switch (size) {
@@ -58,19 +54,19 @@ int pci_x86_write_config(struct udevice *bus, pci_dev_t bdf, uint offset,return 0 ; } -int pci_x86_clrset_config (struct udevice *bus,pci_dev_t bdf,uint offset, -ulong clr,ulong set,enum pci_size_t size) +int pci_x86_clrset_config (pci_dev_t bdf,uint offset,ulong clr,ulong set, +enum pci_size_t size) {ulong value;int ret; - ret =pci_x86_read_config (bus, bdf, offset, &value, size); + ret =pci_x86_read_config (bdf, offset, &value, size);if (ret)return ret; value &= ~clr; value |= set; -return pci_x86_write_config (bus, bdf, offset, value, size); +return pci_x86_write_config (bdf, offset, value, size); }void pci_assign_irqs (int bus,int device,u8 irq[4 ])
arch/x86/include/asm/pci.h +6 -9
@@ -22,30 +22,28 @@* * This function can be called before PCI is set up in driver model. * -* @bus: Bus to read from (ignored, can be NULL) * @bdf: PCI device address: bus, device and function -see PCI_BDF() * @offset: Register offset to read * @valuep: Place to put the returned value * @size: Access size * @return 0 if OK, -ve on error */ -int pci_x86_read_config (struct udevice *bus,pci_dev_t bdf,uint offset, -ulong *valuep,enum pci_size_t size); +int pci_x86_read_config (pci_dev_t bdf,uint offset,ulong *valuep, +enum pci_size_t size);/** * pci_bus_write_config() - Write a configuration value to a device * * This function can be called before PCI is set up in driver model. * -* @bus: Bus to read from (ignored, can be NULL) * @bdf: PCI device address: bus, device and function -see PCI_BDF() * @offset: Register offset to write * @value: Value to write * @size: Access size * @return 0 if OK, -ve on error */ -int pci_x86_write_config (struct udevice *bus,pci_dev_t bdf,uint offset, -ulong value,enum pci_size_t size); +int pci_x86_write_config (pci_dev_t bdf,uint offset,ulong value, +enum pci_size_t size);/** * pci_bus_clrset_config32() - Update a configuration value for a device
@@ -53,15 +51,14 @@ int pci_x86_write_config(struct udevice *bus, pci_dev_t bdf, uint offset,* The register at @offset is updated to (oldvalue & ~clr) | set. This function * can be called before PCI is set up in driver model. * -* @bus: Bus to read from (ignored, can be NULL) * @bdf: PCI device address: bus, device and function -see PCI_BDF() * @offset: Register offset to update * @clr: Bits to clear * @set: Bits to set * @return 0 if OK, -ve on error */ -int pci_x86_clrset_config (struct udevice *bus,pci_dev_t bdf,uint offset, -ulong clr,ulong set,enum pci_size_t size); +int pci_x86_clrset_config (pci_dev_t bdf,uint offset,ulong clr,ulong set, +enum pci_size_t size);/** * Assign IRQ number to a PCI device
drivers/pci/pci_x86.c +14 -2
@@ -8,9 +8,21 @@#include <pci.h> #include <asm/pci.h> +static int _pci_x86_read_config (struct udevice *bus,pci_dev_t bdf,uint offset, +ulong *valuep,enum pci_size_t size) +{ +return pci_x86_read_config (bdf, offset, valuep, size); +} + +static int _pci_x86_write_config (struct udevice *bus,pci_dev_t bdf, +uint offset,ulong value,enum pci_size_t size) +{ +return pci_x86_write_config (bdf, offset, value, size); +} +static const struct dm_pci_ops pci_x86_ops = { - .read_config = pci_x86_read_config, - .write_config = pci_x86_write_config, + .read_config = _pci_x86_read_config, + .write_config = _pci_x86_write_config, };static const struct udevice_id pci_x86_ids[] = {
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 49/126 x86: pci: Drop the first parameter in pci_x86_r/w_config()
Quoted 11 lines · Simon Glass
This parameter is needed by the PCI driver-mode interface but is always NULL on x86. There are a number of calls to this function so it makes sense to minimise the parameters.
Adjust the x86 function to omit the first parameter, and introduce stub functions to handle the conversion.
Signed-off-by Simon Glass <[email protected]>---
Quoted 8 lines
arch/x86/cpu/broadwell/cpu.c | 7 ++----- arch/x86/cpu/intel_common/fast_spi.c | 3 +-- arch/x86/cpu/ivybridge/cpu.c | 3 +-- arch/x86/cpu/pci.c | 20 ++++++++------------ arch/x86/include/asm/pci.h | 15 ++++++--------- drivers/pci/pci_x86.c | 16 ++++++++++++++-- 6 files changed, 32 insertions(+), 32 deletions(-)
PATCH 49/126 x86: pci: Drop the first parameter in pci_x86_r/w_config()
Quoted 22 lines · Bin Meng
Quoted 11 lines · Simon Glass
This parameter is needed by the PCI driver-mode interface but is always NULL on x86. There are a number of calls to this function so it makes sense to minimise the parameters.
Adjust the x86 function to omit the first parameter, and introduce stub functions to handle the conversion.
Signed-off-by Simon Glass <[email protected]>---
Quoted 8 lines
arch/x86/cpu/broadwell/cpu.c | 7 ++----- arch/x86/cpu/intel_common/fast_spi.c | 3 +-- arch/x86/cpu/ivybridge/cpu.c | 3 +-- arch/x86/cpu/pci.c | 20 ++++++++------------ arch/x86/include/asm/pci.h | 15 ++++++--------- drivers/pci/pci_x86.c | 16 ++++++++++++++-- 6 files changed, 32 insertions(+), 32 deletions(-)
Quoted 1 line
Reviewed-by Bin Meng <[email protected]>
Rebased the patch against u-boot-x86/next to get it applied cleanly, and
applied to u-boot-x86/next, thanks!
PATCH 50/126 x86: timer: Reduce timer code size in TPL on Intel CPUs
In reply to Simon GlassMost of the timer-calibration methods are not needed on recent Intel CPUs and just increase code size. Add an option to use the known-good way to get the clock frequency in TPL. Size reduction is about 700 bytes.
---
drivers/timer/Kconfig | 29 +++++++++++++++++++---------- drivers/timer/tsc_timer.c | 7 +++++-- 2 files changed, 24 insertions(+), 12 deletions(-)
drivers/timer/Kconfig +19 -10
@@ -117,16 +117,6 @@ config RENESAS_OSTM_TIMER Enables support for the Renesas OSTM Timer driver. This timer is present on Renesas RZ/A1 R7S72100 SoCs. -config X86_TSC_TIMER_EARLY_FREQ - int "x86 TSC timer frequency in MHz when used as the early timer" - depends on X86_TSC_TIMER - default 1000 - help - Sets the estimated CPU frequency in MHz when TSC is used as the - early timer and the frequency can neither be calibrated via some - hardware ways, nor got from device tree at the time when device - tree is not available yet. - config OMAP_TIMER bool "Omap timer support" depends on TIMER
@@ -174,6 +164,25 @@ config X86_TSC_TIMER help Select this to enable Time-Stamp Counter (TSC) timer for x86. +config X86_TSC_TIMER_EARLY_FREQ + int "x86 TSC timer frequency in MHz when used as the early timer" + depends on X86_TSC_TIMER + default 1000 + help + Sets the estimated CPU frequency in MHz when TSC is used as the + early timer and the frequency can neither be calibrated via some + hardware ways, nor got from device tree at the time when device + tree is not available yet. + +config TPL_X86_TSC_TIMER_NATIVE + bool "x86 TSC timer uses native calibration" + depends on TPL && X86_TSC_TIMER + help + Selects native timer calibration for TPL and don't include the other + methods in the code. This helps to reduce code size in TPL and works + on fairly modern Intel chips. Code-size reductions is about 700 + bytes. + config MTK_TIMER bool "MediaTek timer support" depends on TIMER
drivers/timer/tsc_timer.c +5 -2
@@ -49,8 +49,7 @@ static unsigned long native_calibrate_tsc(void)return 0 ; crystal_freq = tsc_info.ecx /1000 ; - -if (!crystal_freq) { +if (!CONFIG_IS_ENABLED (X86_TSC_TIMER_NATIVE ) && !crystal_freq) {switch (gd->arch.x86_model) {case INTEL_FAM6_SKYLAKE_MOBILE :case INTEL_FAM6_SKYLAKE_DESKTOP :
@@ -405,6 +404,10 @@ static void tsc_timer_ensure_setup(bool early)if (fast_calibrate) goto done; +/* Reduce code size by dropping other methods */ +if (CONFIG_IS_ENABLED (X86_TSC_TIMER_NATIVE )) +panic ("no timer" ); + fast_calibrate =cpu_mhz_from_cpuid ();if (fast_calibrate) goto done;
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 50/126 x86: timer: Reduce timer code size in TPL on Intel CPUs
Hi Simon,
Quoted 74 lines · Simon Glass
Most of the timer-calibration methods are not needed on recent Intel CPUs and just increase code size. Add an option to use the known-good way to get the clock frequency in TPL. Size reduction is about 700 bytes.
Signed-off-by Simon Glass <[email protected]>---
drivers/timer/Kconfig | 29 +++++++++++++++++++---------- drivers/timer/tsc_timer.c | 7 +++++-- 2 files changed, 24 insertions(+), 12 deletions(-)drivers/timer/Kconfig +19
-10@@ -117,16 +117,6 @@ config RENESAS_OSTM_TIMER Enables support for the Renesas OSTM Timer driver. This timer is present on Renesas RZ/A1 R7S72100 SoCs. -config X86_TSC_TIMER_EARLY_FREQ - int "x86 TSC timer frequency in MHz when used as the early timer" - depends on X86_TSC_TIMER - default 1000 - help - Sets the estimated CPU frequency in MHz when TSC is used as the - early timer and the frequency can neither be calibrated via some - hardware ways, nor got from device tree at the time when device - tree is not available yet. - config OMAP_TIMER bool "Omap timer support" depends on TIMER@@ -174,6 +164,25 @@ config X86_TSC_TIMER help Select this to enable Time-Stamp Counter (TSC) timer for x86. +config X86_TSC_TIMER_EARLY_FREQ + int "x86 TSC timer frequency in MHz when used as the early timer" + depends on X86_TSC_TIMER + default 1000 + help + Sets the estimated CPU frequency in MHz when TSC is used as the + early timer and the frequency can neither be calibrated via some + hardware ways, nor got from device tree at the time when device + tree is not available yet. + +config TPL_X86_TSC_TIMER_NATIVE + bool "x86 TSC timer uses native calibration" + depends on TPL && X86_TSC_TIMER + help + Selects native timer calibration for TPL and don't include the other + methods in the code. This helps to reduce code size in TPL and works + on fairly modern Intel chips. Code-size reductions is about 700 + bytes. + config MTK_TIMER bool "MediaTek timer support" depends on TIMERdrivers/timer/tsc_timer.c +1
-2@@ -49,8 +49,7 @@ static unsigned long native_calibrate_tsc(void)return 0 ; crystal_freq = tsc_info.ecx /1000 ; - -if (!crystal_freq) { +if (!CONFIG_IS_ENABLED (X86_TSC_TIMER_NATIVE ) && !crystal_freq) {switch (gd->arch.x86_model) {case INTEL_FAM6_SKYLAKE_MOBILE :case INTEL_FAM6_SKYLAKE_DESKTOP :
drivers/timer/tsc_timer.c static void tsc_timer_ensure_setup(bool early) · line 410
Quoted 7 lines
drivers/timer/tsc_timer.c +4
-0@@ -405,6 +404,10 @@ static void tsc_timer_ensure_setup(bool early)if (fast_calibrate) goto done; +/* Reduce code size by dropping other methods */ +if (CONFIG_IS_ENABLED (X86_TSC_TIMER_NATIVE )) +panic ("no timer" ); +
I don't get it. How could this reduce the code size? I don't see any #ifdefs around the other methods we want to drop?
drivers/timer/tsc_timer.c static void tsc_timer_ensure_setup(bool early)
Quoted 4 lines
drivers/timer/tsc_timer.c +0
-1fast_calibrate =cpu_mhz_from_cpuid ();if (fast_calibrate) goto done; --
Regards,
Bin
PATCH 50/126 x86: timer: Reduce timer code size in TPL on Intel CPUs
Hi Bin,
Quoted 81 lines · Bin Meng
Hi Simon,
Quoted 77 lines · Simon Glass
Most of the timer-calibration methods are not needed on recent Intel CPUs and just increase code size. Add an option to use the known-good way to get the clock frequency in TPL. Size reduction is about 700 bytes.
Signed-off-by Simon Glass <[email protected]>---
drivers/timer/Kconfig | 29 +++++++++++++++++++---------- drivers/timer/tsc_timer.c | 7 +++++-- 2 files changed, 24 insertions(+), 12 deletions(-)drivers/timer/Kconfig +19
-10@@ -117,16 +117,6 @@ config RENESAS_OSTM_TIMER Enables support for the Renesas OSTM Timer driver. This timer is present on Renesas RZ/A1 R7S72100 SoCs. -config X86_TSC_TIMER_EARLY_FREQ - int "x86 TSC timer frequency in MHz when used as the early timer" - depends on X86_TSC_TIMER - default 1000 - help - Sets the estimated CPU frequency in MHz when TSC is used as the - early timer and the frequency can neither be calibrated via some - hardware ways, nor got from device tree at the time when device - tree is not available yet. - config OMAP_TIMER bool "Omap timer support" depends on TIMER@@ -174,6 +164,25 @@ config X86_TSC_TIMER help Select this to enable Time-Stamp Counter (TSC) timer for x86. +config X86_TSC_TIMER_EARLY_FREQ + int "x86 TSC timer frequency in MHz when used as the early timer" + depends on X86_TSC_TIMER + default 1000 + help + Sets the estimated CPU frequency in MHz when TSC is used as the + early timer and the frequency can neither be calibrated via some + hardware ways, nor got from device tree at the time when device + tree is not available yet. + +config TPL_X86_TSC_TIMER_NATIVE + bool "x86 TSC timer uses native calibration" + depends on TPL && X86_TSC_TIMER + help + Selects native timer calibration for TPL and don't include the other + methods in the code. This helps to reduce code size in TPL and works + on fairly modern Intel chips. Code-size reductions is about 700 + bytes. + config MTK_TIMER bool "MediaTek timer support" depends on TIMERdrivers/timer/tsc_timer.c +1
-2@@ -49,8 +49,7 @@ static unsigned long native_calibrate_tsc(void)return 0 ; crystal_freq = tsc_info.ecx /1000 ; - -if (!crystal_freq) { +if (!CONFIG_IS_ENABLED (X86_TSC_TIMER_NATIVE ) && !crystal_freq) {switch (gd->arch.x86_model) {case INTEL_FAM6_SKYLAKE_MOBILE :case INTEL_FAM6_SKYLAKE_DESKTOP :@@ -405,6 +404,10 @@ static void tsc_timer_ensure_setup(bool early)if (fast_calibrate) goto done;
Quoted 7 lines
drivers/timer/tsc_timer.c static void tsc_timer_ensure_setup(bool early) · line 410
Quoted 4 lines
drivers/timer/tsc_timer.c +4
-0+/* Reduce code size by dropping other methods */ +if (CONFIG_IS_ENABLED (X86_TSC_TIMER_NATIVE )) +panic ("no timer" ); +I don't get it. How could this reduce the code size? I don't see any #ifdefs around the other methods we want to drop?
The compiler sees that CONFIG_IS_ENABLED(..) is 1, and leaves out the code that follows it.
Quoted 8 lines
drivers/timer/tsc_timer.c static void tsc_timer_ensure_setup(bool early)
Quoted 5 lines
drivers/timer/tsc_timer.c +0
-1fast_calibrate =cpu_mhz_from_cpuid ();if (fast_calibrate) goto done; --Regards,
Bin
Regards,
Simon
PATCH 50/126 x86: timer: Reduce timer code size in TPL on Intel CPUs
Hi Simon,
Quoted 93 lines · Simon Glass
Hi Bin,
Quoted 81 lines · Bin Meng
Hi Simon,
Quoted 77 lines · Simon Glass
Most of the timer-calibration methods are not needed on recent Intel CPUs and just increase code size. Add an option to use the known-good way to get the clock frequency in TPL. Size reduction is about 700 bytes.
Signed-off-by Simon Glass <[email protected]>---
drivers/timer/Kconfig | 29 +++++++++++++++++++---------- drivers/timer/tsc_timer.c | 7 +++++-- 2 files changed, 24 insertions(+), 12 deletions(-)drivers/timer/Kconfig +19
-10@@ -117,16 +117,6 @@ config RENESAS_OSTM_TIMER Enables support for the Renesas OSTM Timer driver. This timer is present on Renesas RZ/A1 R7S72100 SoCs. -config X86_TSC_TIMER_EARLY_FREQ - int "x86 TSC timer frequency in MHz when used as the early timer" - depends on X86_TSC_TIMER - default 1000 - help - Sets the estimated CPU frequency in MHz when TSC is used as the - early timer and the frequency can neither be calibrated via some - hardware ways, nor got from device tree at the time when device - tree is not available yet. - config OMAP_TIMER bool "Omap timer support" depends on TIMER@@ -174,6 +164,25 @@ config X86_TSC_TIMER help Select this to enable Time-Stamp Counter (TSC) timer for x86. +config X86_TSC_TIMER_EARLY_FREQ + int "x86 TSC timer frequency in MHz when used as the early timer" + depends on X86_TSC_TIMER + default 1000 + help + Sets the estimated CPU frequency in MHz when TSC is used as the + early timer and the frequency can neither be calibrated via some + hardware ways, nor got from device tree at the time when device + tree is not available yet. + +config TPL_X86_TSC_TIMER_NATIVE + bool "x86 TSC timer uses native calibration" + depends on TPL && X86_TSC_TIMER + help + Selects native timer calibration for TPL and don't include the other + methods in the code. This helps to reduce code size in TPL and works + on fairly modern Intel chips. Code-size reductions is about 700 + bytes. + config MTK_TIMER bool "MediaTek timer support" depends on TIMERdrivers/timer/tsc_timer.c +1
-2@@ -49,8 +49,7 @@ static unsigned long native_calibrate_tsc(void)return 0 ; crystal_freq = tsc_info.ecx /1000 ; - -if (!crystal_freq) { +if (!CONFIG_IS_ENABLED (X86_TSC_TIMER_NATIVE ) && !crystal_freq) {switch (gd->arch.x86_model) {case INTEL_FAM6_SKYLAKE_MOBILE :case INTEL_FAM6_SKYLAKE_DESKTOP :@@ -405,6 +404,10 @@ static void tsc_timer_ensure_setup(bool early)if (fast_calibrate) goto done;Quoted 7 lines
drivers/timer/tsc_timer.c static void tsc_timer_ensure_setup(bool early) · line 410
Quoted 4 lines
drivers/timer/tsc_timer.c +4
-0+/* Reduce code size by dropping other methods */ +if (CONFIG_IS_ENABLED (X86_TSC_TIMER_NATIVE )) +panic ("no timer" ); +I don't get it. How could this reduce the code size? I don't see any #ifdefs around the other methods we want to drop?
Quoted 2 lines
The compiler sees that
CONFIG_IS_ENABLED(..)is 1, and leaves out the code that follows it.
Why?
if (1)
panic("no timer");then compiler does not generate any codes of the following?
fast_calibrate = cpu_mhz_from_cpuid();
I don't understand.
Besides, I think adding some random Kconfig options to exclude some specific parts in one C file is a bad idea. It's unclear to me why we should exclude one part versus another part. I'm OK to exclude the whole C file for TPL/SPL though, but not part of it for size limitation purpose.
Quoted 7 lines
Quoted 7 lines
drivers/timer/tsc_timer.c static void tsc_timer_ensure_setup(bool early)
Quoted 6 lines
drivers/timer/tsc_timer.c +0
-1fast_calibrate =cpu_mhz_from_cpuid ();if (fast_calibrate) goto done; --
Regards,
Bin
PATCH 50/126 x86: timer: Reduce timer code size in TPL on Intel CPUs
Hi Bin,
Quoted 102 lines · Bin Meng
Hi Simon,
Quoted 93 lines · Simon Glass
Hi Bin,
Quoted 81 lines · Bin Meng
Hi Simon,
Quoted 77 lines · Simon Glass
Most of the timer-calibration methods are not needed on recent Intel CPUs and just increase code size. Add an option to use the known-good way to get the clock frequency in TPL. Size reduction is about 700 bytes.
Signed-off-by Simon Glass <[email protected]>---
drivers/timer/Kconfig | 29 +++++++++++++++++++---------- drivers/timer/tsc_timer.c | 7 +++++-- 2 files changed, 24 insertions(+), 12 deletions(-)drivers/timer/Kconfig +19
-10@@ -117,16 +117,6 @@ config RENESAS_OSTM_TIMER Enables support for the Renesas OSTM Timer driver. This timer is present on Renesas RZ/A1 R7S72100 SoCs. -config X86_TSC_TIMER_EARLY_FREQ - int "x86 TSC timer frequency in MHz when used as the early timer" - depends on X86_TSC_TIMER - default 1000 - help - Sets the estimated CPU frequency in MHz when TSC is used as the - early timer and the frequency can neither be calibrated via some - hardware ways, nor got from device tree at the time when device - tree is not available yet. - config OMAP_TIMER bool "Omap timer support" depends on TIMER@@ -174,6 +164,25 @@ config X86_TSC_TIMER help Select this to enable Time-Stamp Counter (TSC) timer for x86. +config X86_TSC_TIMER_EARLY_FREQ + int "x86 TSC timer frequency in MHz when used as the early timer" + depends on X86_TSC_TIMER + default 1000 + help + Sets the estimated CPU frequency in MHz when TSC is used as the + early timer and the frequency can neither be calibrated via some + hardware ways, nor got from device tree at the time when device + tree is not available yet. + +config TPL_X86_TSC_TIMER_NATIVE + bool "x86 TSC timer uses native calibration" + depends on TPL && X86_TSC_TIMER + help + Selects native timer calibration for TPL and don't include the other + methods in the code. This helps to reduce code size in TPL and works + on fairly modern Intel chips. Code-size reductions is about 700 + bytes. + config MTK_TIMER bool "MediaTek timer support" depends on TIMERdrivers/timer/tsc_timer.c +1
-2@@ -49,8 +49,7 @@ static unsigned long native_calibrate_tsc(void)return 0 ; crystal_freq = tsc_info.ecx /1000 ; - -if (!crystal_freq) { +if (!CONFIG_IS_ENABLED (X86_TSC_TIMER_NATIVE ) && !crystal_freq) {switch (gd->arch.x86_model) {case INTEL_FAM6_SKYLAKE_MOBILE :case INTEL_FAM6_SKYLAKE_DESKTOP :@@ -405,6 +404,10 @@ static void tsc_timer_ensure_setup(bool early)if (fast_calibrate) goto done;Quoted 7 lines
drivers/timer/tsc_timer.c static void tsc_timer_ensure_setup(bool early) · line 410
Quoted 4 lines
drivers/timer/tsc_timer.c +4
-0+/* Reduce code size by dropping other methods */ +if (CONFIG_IS_ENABLED (X86_TSC_TIMER_NATIVE )) +panic ("no timer" ); +I don't get it. How could this reduce the code size? I don't see any #ifdefs around the other methods we want to drop?
Quoted 2 lines
The compiler sees that
CONFIG_IS_ENABLED(..)is 1, and leaves out the code that follows it.Why?
Quoted 9 lines
if (1)
panic("no timer");then compiler does not generate any codes of the following?
fast_calibrate=cpu_mhz_from_cpuid();I don't understand.
The panic() function is marked as noreturn, so the compiler assume it doesn't return. You can try this if you like. It reduces the size by 700 bytes which on a 22KB image is a lot.
Quoted 5 lines
Besides, I think adding some random
Kconfigoptions to exclude some specific parts in one C file is a bad idea. It's unclear to me why we should exclude one part versus another part. I'm OK to exclude the whole C file for TPL/SPL though, but not part of it for size limitation purpose.
My understanding is the most of the code in this function is a fallback in case an earlier method doesn't work. But on modern CPUs the first method always works, so this is a waste of time?
Regards,
Simon
PATCH 50/126 x86: timer: Reduce timer code size in TPL on Intel CPUs
Hi Simon,
Quoted 111 lines · Simon Glass
Hi Bin,
Quoted 107 lines · Bin Meng
Hi Simon,
Quoted 93 lines · Simon Glass
Hi Bin,
Quoted 81 lines · Bin Meng
Hi Simon,
Quoted 77 lines · Simon Glass
Most of the timer-calibration methods are not needed on recent Intel CPUs and just increase code size. Add an option to use the known-good way to get the clock frequency in TPL. Size reduction is about 700 bytes.
Signed-off-by Simon Glass <[email protected]>---
drivers/timer/Kconfig | 29 +++++++++++++++++++---------- drivers/timer/tsc_timer.c | 7 +++++-- 2 files changed, 24 insertions(+), 12 deletions(-)drivers/timer/Kconfig +19
-10@@ -117,16 +117,6 @@ config RENESAS_OSTM_TIMER Enables support for the Renesas OSTM Timer driver. This timer is present on Renesas RZ/A1 R7S72100 SoCs. -config X86_TSC_TIMER_EARLY_FREQ - int "x86 TSC timer frequency in MHz when used as the early timer" - depends on X86_TSC_TIMER - default 1000 - help - Sets the estimated CPU frequency in MHz when TSC is used as the - early timer and the frequency can neither be calibrated via some - hardware ways, nor got from device tree at the time when device - tree is not available yet. - config OMAP_TIMER bool "Omap timer support" depends on TIMER@@ -174,6 +164,25 @@ config X86_TSC_TIMER help Select this to enable Time-Stamp Counter (TSC) timer for x86. +config X86_TSC_TIMER_EARLY_FREQ + int "x86 TSC timer frequency in MHz when used as the early timer" + depends on X86_TSC_TIMER + default 1000 + help + Sets the estimated CPU frequency in MHz when TSC is used as the + early timer and the frequency can neither be calibrated via some + hardware ways, nor got from device tree at the time when device + tree is not available yet. + +config TPL_X86_TSC_TIMER_NATIVE + bool "x86 TSC timer uses native calibration" + depends on TPL && X86_TSC_TIMER + help + Selects native timer calibration for TPL and don't include the other + methods in the code. This helps to reduce code size in TPL and works + on fairly modern Intel chips. Code-size reductions is about 700 + bytes. + config MTK_TIMER bool "MediaTek timer support" depends on TIMERdrivers/timer/tsc_timer.c +1
-2@@ -49,8 +49,7 @@ static unsigned long native_calibrate_tsc(void)return 0 ; crystal_freq = tsc_info.ecx /1000 ; - -if (!crystal_freq) { +if (!CONFIG_IS_ENABLED (X86_TSC_TIMER_NATIVE ) && !crystal_freq) {switch (gd->arch.x86_model) {case INTEL_FAM6_SKYLAKE_MOBILE :case INTEL_FAM6_SKYLAKE_DESKTOP :@@ -405,6 +404,10 @@ static void tsc_timer_ensure_setup(bool early)if (fast_calibrate) goto done;Quoted 7 lines
drivers/timer/tsc_timer.c static void tsc_timer_ensure_setup(bool early) · line 410
Quoted 4 lines
drivers/timer/tsc_timer.c +4
-0+/* Reduce code size by dropping other methods */ +if (CONFIG_IS_ENABLED (X86_TSC_TIMER_NATIVE )) +panic ("no timer" ); +I don't get it. How could this reduce the code size? I don't see any #ifdefs around the other methods we want to drop?
Quoted 2 lines
The compiler sees that
CONFIG_IS_ENABLED(..)is 1, and leaves out the code that follows it.Why?
if (1)
panic("no timer");then compiler does not generate any codes of the following?
Quoted 8 lines
Quoted 4 lines
fast_calibrate=cpu_mhz_from_cpuid();I don't understand.
The
panic()function is marked as noreturn, so the compiler assume it doesn't return. You can try this if you like. It reduces the size by 700 bytes which on a 22KB image is a lot.
OK, compiler is smart to generate less codes :)
But the way you added the CONFIG_IS_ENABLED(..) logic check here is obscure if one does not dig into that deep ..
Quoted 9 lines
Quoted 6 lines
Besides, I think adding some random
Kconfigoptions to exclude some specific parts in one C file is a bad idea. It's unclear to me why we should exclude one part versus another part. I'm OK to exclude the whole C file for TPL/SPL though, but not part of it for size limitation purpose.My understanding is the most of the code in this function is a fallback in case an earlier method doesn't work. But on modern CPUs
Yes, correct.
Quoted 2 lines
the first method always works, so this is a waste of time?
It's not a wast of time, but a bloat of the code size. As you said, these are fallbacks, and methods are prioritized based on the age of the processors, so that native method is tried first, followed by cpuid, MSR, and finally PIT.
You also mentioned that "on modern CPUs the first method always works", so today the first method is native_calibrate_tsc(), but say 3 years later, this might not be true, and chances are that we may add another method before native_calibrate_tsc() for whatever mechanism is used on the latest processors, and the insertion of the TPL Kconfig option (TPL_X86_TSC_TIMER_NATIVE) check today is not future proof.
Regards,
Bin
PATCH 50/126 x86: timer: Reduce timer code size in TPL on Intel CPUs
Hi Bin,
Quoted 149 lines · Bin Meng
Hi Simon,
Quoted 111 lines · Simon Glass
Hi Bin,
Quoted 107 lines · Bin Meng
Hi Simon,
Quoted 93 lines · Simon Glass
Hi Bin,
Quoted 81 lines · Bin Meng
Hi Simon,
Quoted 77 lines · Simon Glass
Most of the timer-calibration methods are not needed on recent Intel CPUs and just increase code size. Add an option to use the known-good way to get the clock frequency in TPL. Size reduction is about 700 bytes.
Signed-off-by Simon Glass <[email protected]>---
drivers/timer/Kconfig | 29 +++++++++++++++++++---------- drivers/timer/tsc_timer.c | 7 +++++-- 2 files changed, 24 insertions(+), 12 deletions(-)drivers/timer/Kconfig +19
-10@@ -117,16 +117,6 @@ config RENESAS_OSTM_TIMER Enables support for the Renesas OSTM Timer driver. This timer is present on Renesas RZ/A1 R7S72100 SoCs. -config X86_TSC_TIMER_EARLY_FREQ - int "x86 TSC timer frequency in MHz when used as the early timer" - depends on X86_TSC_TIMER - default 1000 - help - Sets the estimated CPU frequency in MHz when TSC is used as the - early timer and the frequency can neither be calibrated via some - hardware ways, nor got from device tree at the time when device - tree is not available yet. - config OMAP_TIMER bool "Omap timer support" depends on TIMER@@ -174,6 +164,25 @@ config X86_TSC_TIMER help Select this to enable Time-Stamp Counter (TSC) timer for x86. +config X86_TSC_TIMER_EARLY_FREQ + int "x86 TSC timer frequency in MHz when used as the early timer" + depends on X86_TSC_TIMER + default 1000 + help + Sets the estimated CPU frequency in MHz when TSC is used as the + early timer and the frequency can neither be calibrated via some + hardware ways, nor got from device tree at the time when device + tree is not available yet. + +config TPL_X86_TSC_TIMER_NATIVE + bool "x86 TSC timer uses native calibration" + depends on TPL && X86_TSC_TIMER + help + Selects native timer calibration for TPL and don't include the other + methods in the code. This helps to reduce code size in TPL and works + on fairly modern Intel chips. Code-size reductions is about 700 + bytes. + config MTK_TIMER bool "MediaTek timer support" depends on TIMERdrivers/timer/tsc_timer.c +1
-2@@ -49,8 +49,7 @@ static unsigned long native_calibrate_tsc(void)return 0 ; crystal_freq = tsc_info.ecx /1000 ; - -if (!crystal_freq) { +if (!CONFIG_IS_ENABLED (X86_TSC_TIMER_NATIVE ) && !crystal_freq) {switch (gd->arch.x86_model) {case INTEL_FAM6_SKYLAKE_MOBILE :case INTEL_FAM6_SKYLAKE_DESKTOP :@@ -405,6 +404,10 @@ static void tsc_timer_ensure_setup(bool early)if (fast_calibrate) goto done;Quoted 7 lines
drivers/timer/tsc_timer.c static void tsc_timer_ensure_setup(bool early) · line 410
Quoted 4 lines
drivers/timer/tsc_timer.c +4
-0+/* Reduce code size by dropping other methods */ +if (CONFIG_IS_ENABLED (X86_TSC_TIMER_NATIVE )) +panic ("no timer" ); +I don't get it. How could this reduce the code size? I don't see any #ifdefs around the other methods we want to drop?
Quoted 2 lines
The compiler sees that
CONFIG_IS_ENABLED(..)is 1, and leaves out the code that follows it.Why?
if (1)
panic("no timer");then compiler does not generate any codes of the following?
Quoted 8 lines
Quoted 4 lines
fast_calibrate=cpu_mhz_from_cpuid();I don't understand.
The
panic()function is marked as noreturn, so the compiler assume it doesn't return. You can try this if you like. It reduces the size by 700 bytes which on a 22KB image is a lot.OK, compiler is smart to generate less codes :)
But the way you added the
CONFIG_IS_ENABLED(..)logic check here is obscure if one does not dig into that deep ..Quoted 9 lines
Quoted 6 lines
Besides, I think adding some random
Kconfigoptions to exclude some specific parts in one C file is a bad idea. It's unclear to me why we should exclude one part versus another part. I'm OK to exclude the whole C file for TPL/SPL though, but not part of it for size limitation purpose.My understanding is the most of the code in this function is a fallback in case an earlier method doesn't work. But on modern CPUs
Yes, correct.
Quoted 2 lines
the first method always works, so this is a waste of time?
It's not a wast of time, but a bloat of the code size. As you said, these are fallbacks, and methods are prioritized based on the age of the processors, so that native method is tried first, followed by cpuid, MSR, and finally PIT.
Quoted 6 lines
You also mentioned that "on modern CPUs the first method always works", so today the first method is
native_calibrate_tsc(), but say 3 years later, this might not be true, and chances are that we may add another method beforenative_calibrate_tsc()for whatever mechanism is used on the latest processors, and the insertion of the TPLKconfigoption (TPL_X86_TSC_TIMER_NATIVE) check today is not future proof.
That's right, it is not. Perhaps we need to have separate timer drivers for different generations? But if not, I am loath to have 700 bytes of dead code in TPL, which I why I added the option.
If we later need to adjust it, we can do so, but this cuts off the worst of the bloat.
Regards,
Simon
PATCH 50/126 x86: timer: Reduce timer code size in TPL on Intel CPUs
Hi Simon,
Quoted 160 lines · Simon Glass
Hi Bin,
Quoted 149 lines · Bin Meng
Hi Simon,
Quoted 111 lines · Simon Glass
Hi Bin,
Quoted 107 lines · Bin Meng
Hi Simon,
Quoted 93 lines · Simon Glass
Hi Bin,
Quoted 81 lines · Bin Meng
Hi Simon,
Quoted 77 lines · Simon Glass
Most of the timer-calibration methods are not needed on recent Intel CPUs and just increase code size. Add an option to use the known-good way to get the clock frequency in TPL. Size reduction is about 700 bytes.
Signed-off-by Simon Glass <[email protected]>---
drivers/timer/Kconfig | 29 +++++++++++++++++++---------- drivers/timer/tsc_timer.c | 7 +++++-- 2 files changed, 24 insertions(+), 12 deletions(-)drivers/timer/Kconfig +19
-10@@ -117,16 +117,6 @@ config RENESAS_OSTM_TIMER Enables support for the Renesas OSTM Timer driver. This timer is present on Renesas RZ/A1 R7S72100 SoCs. -config X86_TSC_TIMER_EARLY_FREQ - int "x86 TSC timer frequency in MHz when used as the early timer" - depends on X86_TSC_TIMER - default 1000 - help - Sets the estimated CPU frequency in MHz when TSC is used as the - early timer and the frequency can neither be calibrated via some - hardware ways, nor got from device tree at the time when device - tree is not available yet. - config OMAP_TIMER bool "Omap timer support" depends on TIMER@@ -174,6 +164,25 @@ config X86_TSC_TIMER help Select this to enable Time-Stamp Counter (TSC) timer for x86. +config X86_TSC_TIMER_EARLY_FREQ + int "x86 TSC timer frequency in MHz when used as the early timer" + depends on X86_TSC_TIMER + default 1000 + help + Sets the estimated CPU frequency in MHz when TSC is used as the + early timer and the frequency can neither be calibrated via some + hardware ways, nor got from device tree at the time when device + tree is not available yet. + +config TPL_X86_TSC_TIMER_NATIVE + bool "x86 TSC timer uses native calibration" + depends on TPL && X86_TSC_TIMER + help + Selects native timer calibration for TPL and don't include the other + methods in the code. This helps to reduce code size in TPL and works + on fairly modern Intel chips. Code-size reductions is about 700 + bytes. + config MTK_TIMER bool "MediaTek timer support" depends on TIMERdrivers/timer/tsc_timer.c +1
-2@@ -49,8 +49,7 @@ static unsigned long native_calibrate_tsc(void)return 0 ; crystal_freq = tsc_info.ecx /1000 ; - -if (!crystal_freq) { +if (!CONFIG_IS_ENABLED (X86_TSC_TIMER_NATIVE ) && !crystal_freq) {switch (gd->arch.x86_model) {case INTEL_FAM6_SKYLAKE_MOBILE :case INTEL_FAM6_SKYLAKE_DESKTOP :@@ -405,6 +404,10 @@ static void tsc_timer_ensure_setup(bool early)if (fast_calibrate) goto done;Quoted 7 lines
drivers/timer/tsc_timer.c static void tsc_timer_ensure_setup(bool early) · line 410
Quoted 4 lines
drivers/timer/tsc_timer.c +4
-0+/* Reduce code size by dropping other methods */ +if (CONFIG_IS_ENABLED (X86_TSC_TIMER_NATIVE )) +panic ("no timer" ); +I don't get it. How could this reduce the code size? I don't see any #ifdefs around the other methods we want to drop?
Quoted 2 lines
The compiler sees that
CONFIG_IS_ENABLED(..)is 1, and leaves out the code that follows it.Why?
if (1)
panic("no timer");then compiler does not generate any codes of the following?
Quoted 8 lines
Quoted 4 lines
fast_calibrate=cpu_mhz_from_cpuid();I don't understand.
The
panic()function is marked as noreturn, so the compiler assume it doesn't return. You can try this if you like. It reduces the size by 700 bytes which on a 22KB image is a lot.OK, compiler is smart to generate less codes :)
But the way you added the
CONFIG_IS_ENABLED(..)logic check here is obscure if one does not dig into that deep ..Quoted 9 lines
Quoted 6 lines
Besides, I think adding some random
Kconfigoptions to exclude some specific parts in one C file is a bad idea. It's unclear to me why we should exclude one part versus another part. I'm OK to exclude the whole C file for TPL/SPL though, but not part of it for size limitation purpose.My understanding is the most of the code in this function is a fallback in case an earlier method doesn't work. But on modern CPUs
Yes, correct.
Quoted 2 lines
the first method always works, so this is a waste of time?
It's not a wast of time, but a bloat of the code size. As you said, these are fallbacks, and methods are prioritized based on the age of the processors, so that native method is tried first, followed by cpuid, MSR, and finally PIT.
Quoted 6 lines
You also mentioned that "on modern CPUs the first method always works", so today the first method is
native_calibrate_tsc(), but say 3 years later, this might not be true, and chances are that we may add another method beforenative_calibrate_tsc()for whatever mechanism is used on the latest processors, and the insertion of the TPLKconfigoption (TPL_X86_TSC_TIMER_NATIVE) check today is not future proof.
Quoted 4 lines
That's right, it is not. Perhaps we need to have separate timer drivers for different generations? But if not, I am loath to have 700 bytes of dead code in TPL, which I why I added the option.
I asked the TPL question in another thread. I think I will need understand why size is a problem for latest x86 processors to have just a single U-Boot booting from reset vector to the shell.
Quoted 2 lines
If we later need to adjust it, we can do so, but this cuts off the worst of the bloat.
Regards,
Bin
PATCH 50/126 x86: timer: Reduce timer code size in TPL on Intel CPUs
Hi Bin,
Quoted 164 lines · Bin Meng
Hi Simon,
Quoted 160 lines · Simon Glass
Hi Bin,
Quoted 155 lines · Bin Meng
Hi Simon,
Quoted 111 lines · Simon Glass
Hi Bin,
Quoted 107 lines · Bin Meng
Hi Simon,
Quoted 93 lines · Simon Glass
Hi Bin,
Quoted 81 lines · Bin Meng
Hi Simon,
Quoted 77 lines · Simon Glass
Most of the timer-calibration methods are not needed on recent Intel CPUs and just increase code size. Add an option to use the known-good way to get the clock frequency in TPL. Size reduction is about 700 bytes.
Signed-off-by Simon Glass <[email protected]>---
drivers/timer/Kconfig | 29 +++++++++++++++++++---------- drivers/timer/tsc_timer.c | 7 +++++-- 2 files changed, 24 insertions(+), 12 deletions(-)drivers/timer/Kconfig +19
-10@@ -117,16 +117,6 @@ config RENESAS_OSTM_TIMER Enables support for the Renesas OSTM Timer driver. This timer is present on Renesas RZ/A1 R7S72100 SoCs. -config X86_TSC_TIMER_EARLY_FREQ - int "x86 TSC timer frequency in MHz when used as the early timer" - depends on X86_TSC_TIMER - default 1000 - help - Sets the estimated CPU frequency in MHz when TSC is used as the - early timer and the frequency can neither be calibrated via some - hardware ways, nor got from device tree at the time when device - tree is not available yet. - config OMAP_TIMER bool "Omap timer support" depends on TIMER@@ -174,6 +164,25 @@ config X86_TSC_TIMER help Select this to enable Time-Stamp Counter (TSC) timer for x86. +config X86_TSC_TIMER_EARLY_FREQ + int "x86 TSC timer frequency in MHz when used as the early timer" + depends on X86_TSC_TIMER + default 1000 + help + Sets the estimated CPU frequency in MHz when TSC is used as the + early timer and the frequency can neither be calibrated via some + hardware ways, nor got from device tree at the time when device + tree is not available yet. + +config TPL_X86_TSC_TIMER_NATIVE + bool "x86 TSC timer uses native calibration" + depends on TPL && X86_TSC_TIMER + help + Selects native timer calibration for TPL and don't include the other + methods in the code. This helps to reduce code size in TPL and works + on fairly modern Intel chips. Code-size reductions is about 700 + bytes. + config MTK_TIMER bool "MediaTek timer support" depends on TIMERdrivers/timer/tsc_timer.c +1
-2@@ -49,8 +49,7 @@ static unsigned long native_calibrate_tsc(void)return 0 ; crystal_freq = tsc_info.ecx /1000 ; - -if (!crystal_freq) { +if (!CONFIG_IS_ENABLED (X86_TSC_TIMER_NATIVE ) && !crystal_freq) {switch (gd->arch.x86_model) {case INTEL_FAM6_SKYLAKE_MOBILE :case INTEL_FAM6_SKYLAKE_DESKTOP :@@ -405,6 +404,10 @@ static void tsc_timer_ensure_setup(bool early)if (fast_calibrate) goto done;Quoted 7 lines
drivers/timer/tsc_timer.c static void tsc_timer_ensure_setup(bool early) · line 410
Quoted 4 lines
drivers/timer/tsc_timer.c +4
-0+/* Reduce code size by dropping other methods */ +if (CONFIG_IS_ENABLED (X86_TSC_TIMER_NATIVE )) +panic ("no timer" ); +I don't get it. How could this reduce the code size? I don't see any #ifdefs around the other methods we want to drop?
Quoted 2 lines
The compiler sees that
CONFIG_IS_ENABLED(..)is 1, and leaves out the code that follows it.Why?
if (1)
panic("no timer");then compiler does not generate any codes of the following?
Quoted 8 lines
Quoted 4 lines
fast_calibrate=cpu_mhz_from_cpuid();I don't understand.
The
panic()function is marked as noreturn, so the compiler assume it doesn't return. You can try this if you like. It reduces the size by 700 bytes which on a 22KB image is a lot.OK, compiler is smart to generate less codes :)
But the way you added the
CONFIG_IS_ENABLED(..)logic check here is obscure if one does not dig into that deep ..Quoted 9 lines
Quoted 6 lines
Besides, I think adding some random
Kconfigoptions to exclude some specific parts in one C file is a bad idea. It's unclear to me why we should exclude one part versus another part. I'm OK to exclude the whole C file for TPL/SPL though, but not part of it for size limitation purpose.My understanding is the most of the code in this function is a fallback in case an earlier method doesn't work. But on modern CPUs
Yes, correct.
Quoted 2 lines
the first method always works, so this is a waste of time?
It's not a wast of time, but a bloat of the code size. As you said, these are fallbacks, and methods are prioritized based on the age of the processors, so that native method is tried first, followed by cpuid, MSR, and finally PIT.
You also mentioned that "on modern CPUs the first method always works", so today the first method is
native_calibrate_tsc(), but say 3 years later, this might not be true, and chances are that we may add another method beforenative_calibrate_tsc()for whatever mechanism is used on the latest processors, and the insertion of the TPLKconfigoption (TPL_X86_TSC_TIMER_NATIVE) check today is not future proof.
Quoted 9 lines
Quoted 4 lines
That's right, it is not. Perhaps we need to have separate timer drivers for different generations? But if not, I am loath to have 700 bytes of dead code in TPL, which I why I added the option.
I asked the TPL question in another thread. I think I will need understand why size is a problem for latest x86 processors to have just a single U-Boot booting from reset vector to the shell.
OK I replied on that thread.
I'm going to drop this patch for now as it is not necessary and breaks bootstage in TPL anyway.
Regards,
Simon
PATCH 51/126 x86: Use a common definition of MSR_IA32_PERF_CTL
In reply to Simon GlassRemove the duplicate definition as it is not needed.
---
arch/x86/cpu/broadwell/cpu.c | 2 +- arch/x86/cpu/broadwell/cpu_full.c | 2 +- arch/x86/cpu/intel_common/cpu.c | 2 +- arch/x86/include/asm/cpu_common.h | 2 -- 4 files changed, 3 insertions(+), 5 deletions(-)
arch/x86/cpu/broadwell/cpu.c +1 -1
@@ -57,7 +57,7 @@ void set_max_freq(void) } perf_ctl.hi =0 ; -msr_write (IA32_PERF_CTL , perf_ctl); +msr_write (MSR_IA32_PERF_CTL , perf_ctl);debug ("CPU: frequency set to %d MHz\n" , ((perf_ctl.lo >>8 ) &0xff ) *CPU_BCLK );
arch/x86/cpu/broadwell/cpu_full.c +1 -1
@@ -357,7 +357,7 @@ static void set_max_ratio(void) msr =msr_read (MSR_PLATFORM_INFO ); perf_ctl.lo = msr.lo &0xff00 ; } -msr_write (IA32_PERF_CTL , perf_ctl); +msr_write (MSR_IA32_PERF_CTL , perf_ctl);debug ("cpu: frequency set to %d\n" , ((perf_ctl.lo >>8 ) &0xff ) *CPU_BCLK );
arch/x86/cpu/intel_common/cpu.c +1 -1
@@ -116,7 +116,7 @@ int cpu_intel_get_info(struct cpu_info *info, int bclk) {msr_t msr; - msr =msr_read (IA32_PERF_CTL ); + msr =msr_read (MSR_IA32_PERF_CTL ); info->cpu_freq = ((msr.lo >>8 ) &0xff ) * bclk *1000000 ; info->features =1 <<CPU_FEAT_L1_CACHE |1 <<CPU_FEAT_MMU |1 <<CPU_FEAT_UCODE |1 <<CPU_FEAT_DEVICE_ID ;
arch/x86/include/asm/cpu_common.h +0 -2
@@ -6,8 +6,6 @@#ifndef __ASM_CPU_COMMON_H#define __ASM_CPU_COMMON_H -#define IA32_PERF_CTL 0x199 -struct cpu_info ;/**
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 51/126 x86: Use a common definition of MSR_IA32_PERF_CTL
Quoted 12 lines · Simon Glass
Remove the duplicate definition as it is not needed.
Signed-off-by Simon Glass <[email protected]>---
arch/x86/cpu/broadwell/cpu.c | 2 +- arch/x86/cpu/broadwell/cpu_full.c | 2 +- arch/x86/cpu/intel_common/cpu.c | 2 +- arch/x86/include/asm/cpu_common.h | 2 -- 4 files changed, 3 insertions(+), 5 deletions(-)
PATCH 51/126 x86: Use a common definition of MSR_IA32_PERF_CTL
Quoted 8 lines · Bin Meng
Quoted 6 lines · Simon Glass
Remove the duplicate definition as it is not needed.
Signed-off-by Simon Glass <[email protected]>---
Quoted 8 lines
Quoted 6 lines
arch/x86/cpu/broadwell/cpu.c | 2 +- arch/x86/cpu/broadwell/cpu_full.c | 2 +- arch/x86/cpu/intel_common/cpu.c | 2 +- arch/x86/include/asm/cpu_common.h | 2 -- 4 files changed, 3 insertions(+), 5 deletions(-)Reviewed-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 52/126 x86: Add a common function to set CPU thermal target
In reply to Simon GlassThis code appears in a few places, so move it to a common file.
---
arch/x86/cpu/broadwell/cpu_full.c | 20 +------------------- arch/x86/cpu/intel_common/cpu.c | 22 ++++++++++++++++++++++ arch/x86/cpu/ivybridge/model_206ax.c | 25 +++---------------------- arch/x86/include/asm/cpu_common.h | 11 +++++++++++ 4 files changed, 37 insertions(+), 41 deletions(-)
arch/x86/cpu/broadwell/cpu_full.c +1 -19
@@ -495,24 +495,6 @@ static void configure_misc(void)msr_write (MSR_IA32_PACKAGE_THERM_INTERRUPT , msr); } -static void configure_thermal_target (struct udevice *dev) -{ -int tcc_offset; -msr_t msr; - - tcc_offset =fdtdec_get_int (gd->fdt_blob,dev_of_offset (dev), -"intel,tcc-offset" ,0 ); - -/* Set TCC activaiton offset if supported */ - msr =msr_read (MSR_PLATFORM_INFO ); -if ((msr.lo & (1 <<30 )) && tcc_offset) { - msr =msr_read (MSR_TEMPERATURE_TARGET ); - msr.lo &= ~(0xf <<24 );/* Bits 27:24 */ - msr.lo |= (tcc_offset &0xf ) <<24 ; -msr_write (MSR_TEMPERATURE_TARGET , msr); - } -} -static void configure_dca_cap (void ) {struct cpuid_result cpuid_regs;
@@ -562,7 +544,7 @@ static void cpu_core_init(struct udevice *dev)configure_misc ();/* Thermal throttle activation offset */ -configure_thermal_target (dev); +cpu_configure_thermal_target (dev);/* Enable Direct Cache Access */ configure_dca_cap ();
arch/x86/cpu/intel_common/cpu.c +22 -0
@@ -123,3 +123,25 @@ int cpu_intel_get_info(struct cpu_info *info, int bclk)return 0 ; } + +int cpu_configure_thermal_target (struct udevice *dev) +{ +u32 tcc_offset; +msr_t msr; +int ret; + + ret =dev_read_u32 (dev,"tcc-offset" , &tcc_offset); +if (!ret) +return -ENOENT ; + +/* Set TCC activaiton offset if supported */ + msr =msr_read (MSR_PLATFORM_INFO ); +if (msr.lo & (1 <<30 )) { + msr =msr_read (MSR_TEMPERATURE_TARGET ); + msr.lo &= ~(0xf <<24 );/* Bits 27:24 */ + msr.lo |= (tcc_offset &0xf ) <<24 ; +msr_write (MSR_TEMPERATURE_TARGET , msr); + } + +return 0 ; +}
arch/x86/cpu/ivybridge/model_206ax.c +3 -22
@@ -283,26 +283,6 @@ static void configure_c_states(void)msr_write (MSR_PP1_CURRENT_CONFIG , msr); } -static int configure_thermal_target (struct udevice *dev) -{ -int tcc_offset; -msr_t msr; - - tcc_offset =fdtdec_get_int (gd->fdt_blob,dev_of_offset (dev), -"tcc-offset" ,0 ); - -/* Set TCC activaiton offset if supported */ - msr =msr_read (MSR_PLATFORM_INFO ); -if ((msr.lo & (1 <<30 )) && tcc_offset) { - msr =msr_read (MSR_TEMPERATURE_TARGET ); - msr.lo &= ~(0xf <<24 );/* Bits 27:24 */ - msr.lo |= (tcc_offset &0xf ) <<24 ; -msr_write (MSR_TEMPERATURE_TARGET , msr); - } - -return 0 ; -} -static void configure_misc (void ) {msr_t msr;
@@ -414,10 +394,11 @@ static int model_206ax_init(struct udevice *dev)configure_misc ();/* Thermal throttle activation offset */ - ret =configure_thermal_target (dev); + ret =cpu_configure_thermal_target (dev);if (ret) {debug ("Cannot set thermal target\n" ); -return ret; +if (ret != -ENOENT ) +return ret; }/* Enable Direct Cache Access */
arch/x86/include/asm/cpu_common.h +11 -0
@@ -40,4 +40,15 @@ int cpu_set_flex_ratio_to_tdp_nominal(void);*/ int cpu_intel_get_info (struct cpu_info *info,int bclk_mz); +/** +* cpu_configure_thermal_target() - Set the thermal target for a CPU +* +* This looks up the tcc-offset property and uses it to set the +* MSR_TEMPERATURE_TARGET value. +* +* @dev: CPU device +* @return 0 if OK, -ENOENT if no target is given in device tree +*/ +int cpu_configure_thermal_target (struct udevice *dev); +#endif
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 52/126 x86: Add a common function to set CPU thermal target
Quoted 17 lines · Simon Glass
This code appears in a few places, so move it to a common file.
Signed-off-by Simon Glass <[email protected]>---
arch/x86/cpu/broadwell/cpu_full.c | 20 +------------------- arch/x86/cpu/intel_common/cpu.c | 22 ++++++++++++++++++++++ arch/x86/cpu/ivybridge/model_206ax.c | 25 +++---------------------- arch/x86/include/asm/cpu_common.h | 11 +++++++++++ 4 files changed, 37 insertions(+), 41 deletions(-)arch/x86/cpu/broadwell/cpu_full.c +0
-0
arch/x86/cpu/broadwell/cpu_full.c static void configure_misc(void) · line 504
Quoted 10 lines
arch/x86/cpu/broadwell/cpu_full.c +0
-7@@ -495,24 +495,6 @@ static void configure_misc(void)msr_write (MSR_IA32_PACKAGE_THERM_INTERRUPT , msr); } -static void configure_thermal_target (struct udevice *dev) -{ -int tcc_offset; -msr_t msr; - - tcc_offset =fdtdec_get_int (gd->fdt_blob,dev_of_offset (dev), -"intel,tcc-offset" ,0 );
"intel,tcc-offset" removed
Quoted 29 lines
arch/x86/cpu/broadwell/cpu_full.c +1
-12- -/* Set TCC activaiton offset if supported */ - msr =msr_read (MSR_PLATFORM_INFO ); -if ((msr.lo & (1 <<30 )) && tcc_offset) { - msr =msr_read (MSR_TEMPERATURE_TARGET ); - msr.lo &= ~(0xf <<24 );/* Bits 27:24 */ - msr.lo |= (tcc_offset &0xf ) <<24 ; -msr_write (MSR_TEMPERATURE_TARGET , msr); - } -} -static void configure_dca_cap (void ) {struct cpuid_result cpuid_regs;@@ -562,7 +544,7 @@ static void cpu_core_init(struct udevice *dev)configure_misc ();/* Thermal throttle activation offset */ -configure_thermal_target (dev); +cpu_configure_thermal_target (dev);/* Enable Direct Cache Access */ configure_dca_cap ();arch/x86/cpu/intel_common/cpu.c +0
-0@@ -123,3 +123,25 @@ int cpu_intel_get_info(struct cpu_info *info, int bclk)
arch/x86/cpu/intel_common/cpu.c int cpu_intel_get_info(struct cpu_info *info, int bclk) · line 133
Quoted 10 lines
arch/x86/cpu/intel_common/cpu.c +8
-0return 0 ; } + +int cpu_configure_thermal_target (struct udevice *dev) +{ +u32 tcc_offset; +msr_t msr; +int ret; + + ret =dev_read_u32 (dev,"tcc-offset" , &tcc_offset);
"tcc-offset" added, so I wonder how this commit could avoid breaking broadwell? But I see no dts file provides "tcc-offset", or "intel,tcc-offset" neither. Probably not a problem.
Quoted 70 lines
arch/x86/cpu/intel_common/cpu.c +14
-0+if (!ret) +return -ENOENT ; + +/* Set TCC activaiton offset if supported */ + msr =msr_read (MSR_PLATFORM_INFO ); +if (msr.lo & (1 <<30 )) { + msr =msr_read (MSR_TEMPERATURE_TARGET ); + msr.lo &= ~(0xf <<24 );/* Bits 27:24 */ + msr.lo |= (tcc_offset &0xf ) <<24 ; +msr_write (MSR_TEMPERATURE_TARGET , msr); + } + +return 0 ; +}arch/x86/cpu/ivybridge/model_206ax.c +3
-22@@ -283,26 +283,6 @@ static void configure_c_states(void)msr_write (MSR_PP1_CURRENT_CONFIG , msr); } -static int configure_thermal_target (struct udevice *dev) -{ -int tcc_offset; -msr_t msr; - - tcc_offset =fdtdec_get_int (gd->fdt_blob,dev_of_offset (dev), -"tcc-offset" ,0 ); - -/* Set TCC activaiton offset if supported */ - msr =msr_read (MSR_PLATFORM_INFO ); -if ((msr.lo & (1 <<30 )) && tcc_offset) { - msr =msr_read (MSR_TEMPERATURE_TARGET ); - msr.lo &= ~(0xf <<24 );/* Bits 27:24 */ - msr.lo |= (tcc_offset &0xf ) <<24 ; -msr_write (MSR_TEMPERATURE_TARGET , msr); - } - -return 0 ; -} -static void configure_misc (void ) {msr_t msr;@@ -414,10 +394,11 @@ static int model_206ax_init(struct udevice *dev)configure_misc ();/* Thermal throttle activation offset */ - ret =configure_thermal_target (dev); + ret =cpu_configure_thermal_target (dev);if (ret) {debug ("Cannot set thermal target\n" ); -return ret; +if (ret != -ENOENT ) +return ret; }/* Enable Direct Cache Access */ arch/x86/include/asm/cpu_common.h +3
-0@@ -40,4 +40,15 @@ int cpu_set_flex_ratio_to_tdp_nominal(void);*/ int cpu_intel_get_info (struct cpu_info *info,int bclk_mz); +/** +* cpu_configure_thermal_target() - Set the thermal target for a CPU +*
arch/x86/include/asm/cpu_common.h int cpu_set_flex_ratio_to_tdp_nominal(void);
Quoted 10 lines
arch/x86/include/asm/cpu_common.h +8
-1+* This looks up the tcc-offset property and uses it to set the +* MSR_TEMPERATURE_TARGET value. +* +* @dev: CPU device +* @return 0 if OK, -ENOENT if no target is given in device tree +*/ +int cpu_configure_thermal_target (struct udevice *dev); +#endif --
PATCH 52/126 x86: Add a common function to set CPU thermal target
Quoted 143 lines · Bin Meng
Quoted 17 lines · Simon Glass
This code appears in a few places, so move it to a common file.
Signed-off-by Simon Glass <[email protected]>---
arch/x86/cpu/broadwell/cpu_full.c | 20 +------------------- arch/x86/cpu/intel_common/cpu.c | 22 ++++++++++++++++++++++ arch/x86/cpu/ivybridge/model_206ax.c | 25 +++---------------------- arch/x86/include/asm/cpu_common.h | 11 +++++++++++ 4 files changed, 37 insertions(+), 41 deletions(-)arch/x86/cpu/broadwell/cpu_full.c +0
-0arch/x86/cpu/broadwell/cpu_full.c static void configure_misc(void) · line 504
Quoted 10 lines
arch/x86/cpu/broadwell/cpu_full.c +0
-7@@ -495,24 +495,6 @@ static void configure_misc(void)msr_write (MSR_IA32_PACKAGE_THERM_INTERRUPT , msr); } -static void configure_thermal_target (struct udevice *dev) -{ -int tcc_offset; -msr_t msr; - - tcc_offset =fdtdec_get_int (gd->fdt_blob,dev_of_offset (dev), -"intel,tcc-offset" ,0 );"intel,tcc-offset" removed
Quoted 29 lines
arch/x86/cpu/broadwell/cpu_full.c +1
-12- -/* Set TCC activaiton offset if supported */ - msr =msr_read (MSR_PLATFORM_INFO ); -if ((msr.lo & (1 <<30 )) && tcc_offset) { - msr =msr_read (MSR_TEMPERATURE_TARGET ); - msr.lo &= ~(0xf <<24 );/* Bits 27:24 */ - msr.lo |= (tcc_offset &0xf ) <<24 ; -msr_write (MSR_TEMPERATURE_TARGET , msr); - } -} -static void configure_dca_cap (void ) {struct cpuid_result cpuid_regs;@@ -562,7 +544,7 @@ static void cpu_core_init(struct udevice *dev)configure_misc ();/* Thermal throttle activation offset */ -configure_thermal_target (dev); +cpu_configure_thermal_target (dev);/* Enable Direct Cache Access */ configure_dca_cap ();arch/x86/cpu/intel_common/cpu.c +0
-0@@ -123,3 +123,25 @@ int cpu_intel_get_info(struct cpu_info *info, int bclk)arch/x86/cpu/intel_common/cpu.c int cpu_intel_get_info(struct cpu_info *info, int bclk) · line 133
Quoted 10 lines
arch/x86/cpu/intel_common/cpu.c +8
-0return 0 ; } + +int cpu_configure_thermal_target (struct udevice *dev) +{ +u32 tcc_offset; +msr_t msr; +int ret; + + ret =dev_read_u32 (dev,"tcc-offset" , &tcc_offset);"tcc-offset" added, so I wonder how this commit could avoid breaking broadwell? But I see no dts file provides "tcc-offset", or "intel,tcc-offset" neither. Probably not a problem.
Quoted 67 lines
arch/x86/cpu/intel_common/cpu.c +14
-0+if (!ret) +return -ENOENT ; + +/* Set TCC activaiton offset if supported */ + msr =msr_read (MSR_PLATFORM_INFO ); +if (msr.lo & (1 <<30 )) { + msr =msr_read (MSR_TEMPERATURE_TARGET ); + msr.lo &= ~(0xf <<24 );/* Bits 27:24 */ + msr.lo |= (tcc_offset &0xf ) <<24 ; +msr_write (MSR_TEMPERATURE_TARGET , msr); + } + +return 0 ; +}arch/x86/cpu/ivybridge/model_206ax.c +3
-22@@ -283,26 +283,6 @@ static void configure_c_states(void)msr_write (MSR_PP1_CURRENT_CONFIG , msr); } -static int configure_thermal_target (struct udevice *dev) -{ -int tcc_offset; -msr_t msr; - - tcc_offset =fdtdec_get_int (gd->fdt_blob,dev_of_offset (dev), -"tcc-offset" ,0 ); - -/* Set TCC activaiton offset if supported */ - msr =msr_read (MSR_PLATFORM_INFO ); -if ((msr.lo & (1 <<30 )) && tcc_offset) { - msr =msr_read (MSR_TEMPERATURE_TARGET ); - msr.lo &= ~(0xf <<24 );/* Bits 27:24 */ - msr.lo |= (tcc_offset &0xf ) <<24 ; -msr_write (MSR_TEMPERATURE_TARGET , msr); - } - -return 0 ; -} -static void configure_misc (void ) {msr_t msr;@@ -414,10 +394,11 @@ static int model_206ax_init(struct udevice *dev)configure_misc ();/* Thermal throttle activation offset */ - ret =configure_thermal_target (dev); + ret =cpu_configure_thermal_target (dev);if (ret) {debug ("Cannot set thermal target\n" ); -return ret; +if (ret != -ENOENT ) +return ret; }/* Enable Direct Cache Access */ arch/x86/include/asm/cpu_common.h +0
-0@@ -40,4 +40,15 @@ int cpu_set_flex_ratio_to_tdp_nominal(void);*/ int cpu_intel_get_info (struct cpu_info *info,int bclk_mz);
Quoted 15 lines
arch/x86/include/asm/cpu_common.h int cpu_set_flex_ratio_to_tdp_nominal(void);
Quoted 13 lines
arch/x86/include/asm/cpu_common.h +11
-1+/** +* cpu_configure_thermal_target() - Set the thermal target for a CPU +* +* This looks up the tcc-offset property and uses it to set the +* MSR_TEMPERATURE_TARGET value. +* +* @dev: CPU device +* @return 0 if OK, -ENOENT if no target is given in device tree +*/ +int cpu_configure_thermal_target (struct udevice *dev); +#endif --Reviewed-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 53/126 x86: Use a common bus clock for Intel CPUs
In reply to Simon GlassModern Intel CPUs use a standard bus clock value of 100MHz, so put this in a common file and tidy up the copies.
---
arch/x86/cpu/broadwell/cpu.c | 2 +- arch/x86/cpu/broadwell/cpu_full.c | 4 ++-- arch/x86/cpu/ivybridge/model_206ax.c | 4 ++-- arch/x86/include/asm/arch-broadwell/cpu.h | 3 --- arch/x86/include/asm/arch-broadwell/pch.h | 3 --- arch/x86/include/asm/arch-ivybridge/model_206ax.h | 3 --- arch/x86/include/asm/cpu_common.h | 5 +++++ 7 files changed, 10 insertions(+), 14 deletions(-)
arch/x86/cpu/broadwell/cpu.c +1 -1
@@ -60,7 +60,7 @@ void set_max_freq(void)msr_write (MSR_IA32_PERF_CTL , perf_ctl);debug ("CPU: frequency set to %d MHz\n" , - ((perf_ctl.lo >>8 ) &0xff ) *CPU_BCLK ); + ((perf_ctl.lo >>8 ) &0xff ) *INTEL_BCLK_MHZ ); }int arch_cpu_init (void )
arch/x86/cpu/broadwell/cpu_full.c +2 -2
@@ -360,7 +360,7 @@ static void set_max_ratio(void)msr_write (MSR_IA32_PERF_CTL , perf_ctl);debug ("cpu: frequency set to %d\n" , - ((perf_ctl.lo >>8 ) &0xff ) *CPU_BCLK ); + ((perf_ctl.lo >>8 ) &0xff ) *INTEL_BCLK_MHZ ); }int broadwell_init (struct udevice *dev)
@@ -634,7 +634,7 @@ void cpu_set_power_limits(int power_limit_1_time)static int broadwell_get_info (struct udevice *dev,struct cpu_info *info) { -return cpu_intel_get_info (info,BROADWELL_BCLK ); +return cpu_intel_get_info (info,INTEL_BCLK_MHZ ); }static int broadwell_get_count (struct udevice *dev)
arch/x86/cpu/ivybridge/model_206ax.c +2 -2
@@ -346,7 +346,7 @@ static void set_max_ratio(void)msr_write (MSR_IA32_PERF_CTL , perf_ctl);debug ("model_x06ax: frequency set to %d\n" , - ((perf_ctl.lo >>8 ) &0xff ) *SANDYBRIDGE_BCLK ); + ((perf_ctl.lo >>8 ) &0xff ) *INTEL_BCLK_MHZ ); }static void set_energy_perf_bias (u8 policy)
@@ -418,7 +418,7 @@ static int model_206ax_init(struct udevice *dev)static int model_206ax_get_info (struct udevice *dev,struct cpu_info *info) { -return cpu_intel_get_info (info,SANDYBRIDGE_BCLK ); +return cpu_intel_get_info (info,INTEL_BCLK_MHZ );return 0 ; }
arch/x86/include/asm/arch-broadwell/cpu.h +0 -3
@@ -21,9 +21,6 @@#define CPUID_BROADWELL_D0 0x306d3#define CPUID_BROADWELL_E0 0x306d4 -/* Broadwell bus clock is fixed at 100MHz */ -#define BROADWELL_BCLK 100 -#define BROADWELL_FAMILY_ULT 0x306d0#define CORE_THREAD_COUNT_MSR 0x35
arch/x86/include/asm/arch-broadwell/pch.h +0 -3
@@ -6,9 +6,6 @@#ifndef __ASM_ARCH_PCH_H#define __ASM_ARCH_PCH_H -/* CPU bus clock is fixed at 100MHz */ -#define CPU_BCLK 100 -#define PMBASE 0x40#define ACPI_CNTL 0x44#define ACPI_EN (1 << 7)
arch/x86/include/asm/arch-ivybridge/model_206ax.h +0 -3
@@ -8,9 +8,6 @@#ifndef _ASM_ARCH_MODEL_206AX_H#define _ASM_ARCH_MODEL_206AX_H -/* SandyBridge/IvyBridge bus clock is fixed at 100MHz */ -#define SANDYBRIDGE_BCLK 100 -#define CPUID_VMX (1 << 5)#define CPUID_SMX (1 << 6)#define MSR_FEATURE_CONFIG 0x13c
arch/x86/include/asm/cpu_common.h +5 -0
@@ -6,6 +6,11 @@#ifndef __ASM_CPU_COMMON_H#define __ASM_CPU_COMMON_H +/* Standard Intel bus clock is fixed@100MHz */ +enum { +INTEL_BCLK_MHZ =100 +}; +struct cpu_info ;/**
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 53/126 x86: Use a common bus clock for Intel CPUs
Quoted 7 lines · Simon Glass
Modern Intel CPUs use a standard bus clock value of 100MHz, so put this in a common file and tidy up the copies.
Signed-off-by Simon Glass <[email protected]>---
Quoted 9 lines
arch/x86/cpu/broadwell/cpu.c | 2 +- arch/x86/cpu/broadwell/cpu_full.c | 4 ++-- arch/x86/cpu/ivybridge/model_206ax.c | 4 ++-- arch/x86/include/asm/arch-broadwell/cpu.h | 3 --- arch/x86/include/asm/arch-broadwell/pch.h | 3 --- arch/x86/include/asm/arch-ivybridge/model_206ax.h | 3 --- arch/x86/include/asm/cpu_common.h | 5 +++++ 7 files changed, 10 insertions(+), 14 deletions(-)
PATCH 53/126 x86: Use a common bus clock for Intel CPUs
Quoted 19 lines · Bin Meng
Quoted 7 lines · Simon Glass
Modern Intel CPUs use a standard bus clock value of 100MHz, so put this in a common file and tidy up the copies.
Signed-off-by Simon Glass <[email protected]>---
Quoted 9 lines
arch/x86/cpu/broadwell/cpu.c | 2 +- arch/x86/cpu/broadwell/cpu_full.c | 4 ++-- arch/x86/cpu/ivybridge/model_206ax.c | 4 ++-- arch/x86/include/asm/arch-broadwell/cpu.h | 3 --- arch/x86/include/asm/arch-broadwell/pch.h | 3 --- arch/x86/include/asm/arch-ivybridge/model_206ax.h | 3 --- arch/x86/include/asm/cpu_common.h | 5 +++++ 7 files changed, 10 insertions(+), 14 deletions(-)
Quoted 1 line
Reviewed-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH 54/126 x86: Add common functions for TDP and perf control
In reply to Simon GlassThese functions are the same on modern Intel CPUs, so use common code to set them.
---
arch/x86/cpu/broadwell/cpu.c | 7 ++---- arch/x86/cpu/broadwell/cpu_full.c | 9 ------- arch/x86/cpu/intel_common/cpu.c | 20 +++++++++++++++ arch/x86/cpu/ivybridge/model_206ax.c | 25 +++++++------------ arch/x86/cpu/ivybridge/northbridge.c | 2 +- .../include/asm/arch-ivybridge/model_206ax.h | 2 +- arch/x86/include/asm/cpu_common.h | 18 +++++++++++++ 7 files changed, 51 insertions(+), 32 deletions(-)
arch/x86/cpu/broadwell/cpu.c +2 -5
@@ -41,12 +41,9 @@ int arch_cpu_init_dm(void)void set_max_freq (void ) { -msr_t msr, perf_ctl, platform_info; +msr_t msr, perf_ctl; -/* Check for configurable TDP option */ - platform_info =msr_read (MSR_PLATFORM_INFO ); - -if ((platform_info.hi >>1 ) &3 ) { +if (cpu_config_tdp_levels ()) {/* Set to nominal TDP ratio */ msr =msr_read (MSR_CONFIG_TDP_NOMINAL ); perf_ctl.lo = (msr.lo &0xff ) <<8 ;
arch/x86/cpu/broadwell/cpu_full.c +0 -9
@@ -329,15 +329,6 @@ static int bsp_init_before_ap_bringup(struct udevice *dev)return 0 ; } -static int cpu_config_tdp_levels (void ) -{ -msr_t platform_info; - -/* Bits 34:33 indicate how many levels supported */ - platform_info =msr_read (MSR_PLATFORM_INFO ); -return (platform_info.hi >>1 ) &3 ; -} -static void set_max_ratio (void ) {msr_t msr, perf_ctl;
arch/x86/cpu/intel_common/cpu.c +20 -0
@@ -145,3 +145,23 @@ int cpu_configure_thermal_target(struct udevice *dev)return 0 ; } + +void cpu_set_perf_control (uint clk_ratio) +{ +msr_t perf_ctl; + + perf_ctl.lo = (clk_ratio &0xff ) <<8 ; + perf_ctl.hi =0 ; +msr_write (MSR_IA32_PERF_CTL , perf_ctl); +debug ("CPU: frequency set to %d MHz\n" , clk_ratio *INTEL_BCLK_MHZ ); +} + +bool cpu_config_tdp_levels (void ) +{ +msr_t platform_info; + +/* Bits 34:33 indicate how many levels supported */ + platform_info =msr_read (MSR_PLATFORM_INFO ); + +return ((platform_info.hi >>1 ) &3 ) !=0 ; +}
arch/x86/cpu/ivybridge/model_206ax.c +9 -16
@@ -140,19 +140,16 @@ static const u8 power_limit_time_msr_to_sec[] = { [0x11] = 128, }; -int cpu_config_tdp_levels (void ) +bool cpu_ivybridge_config_tdp_levels (void ) {struct cpuid_result result; -msr_t platform_info;/* Minimum CPU revision */ result =cpuid (1 );if (result.eax <IVB_CONFIG_TDP_MIN_CPUID )return 0 ; -/* Bits 34:33 indicate how many levels supported */ - platform_info =msr_read (MSR_PLATFORM_INFO ); -return (platform_info.hi >>1 ) &3 ; +return cpu_config_tdp_levels (); }/*
@@ -213,7 +210,7 @@ void set_power_limits(u8 power_limit_1_time)msr_write (MSR_PKG_POWER_LIMIT , limit);/* Use nominal TDP values for CPUs with configurable TDP */ -if (cpu_config_tdp_levels ()) { +if (cpu_ivybridge_config_tdp_levels ()) { msr =msr_read (MSR_CONFIG_TDP_NOMINAL ); limit.hi =0 ; limit.lo = msr.lo &0xff ;
@@ -329,24 +326,20 @@ static void configure_dca_cap(void)static void set_max_ratio (void ) { -msr_t msr, perf_ctl; - - perf_ctl.hi =0 ; +msr_t msr; +uint ratio;/* Check for configurable TDP option */ -if (cpu_config_tdp_levels ()) { +if (cpu_ivybridge_config_tdp_levels ()) {/* Set to nominal TDP ratio */ msr =msr_read (MSR_CONFIG_TDP_NOMINAL ); - perf_ctl.lo = (msr.lo &0xff ) <<8 ; + ratio = msr.lo &0xff ; }else {/* Platform Info bits 15:8 give max ratio */ msr =msr_read (MSR_PLATFORM_INFO ); - perf_ctl.lo = msr.lo &0xff00 ; + ratio = (msr.lo &0xff00 ) >>8 ; } -msr_write (MSR_IA32_PERF_CTL , perf_ctl); - -debug ("model_x06ax: frequency set to %d\n" , - ((perf_ctl.lo >>8 ) &0xff ) *INTEL_BCLK_MHZ ); +cpu_set_perf_control (ratio); }static void set_energy_perf_bias (u8 policy)
arch/x86/cpu/ivybridge/northbridge.c +1 -1
@@ -141,7 +141,7 @@ static void northbridge_init(struct udevice *dev, int rev)* CPUs with configurable TDP also need power limits set * in MCHBAR. Use same values from MSR_PKG_POWER_LIMIT. */ -if (cpu_config_tdp_levels ()) { +if (cpu_ivybridge_config_tdp_levels ()) {msr_t msr =msr_read (MSR_PKG_POWER_LIMIT );writel (msr.lo,MCHBAR_REG (0x59A0 ));
arch/x86/include/asm/arch-ivybridge/model_206ax.h +1 -1
@@ -58,6 +58,6 @@/* Configure power limits for turbo mode */ void set_power_limits (u8 power_limit_1_time); -int cpu_config_tdp_levels (void ); +bool cpu_ivybridge_config_tdp_levels (void );#endif
arch/x86/include/asm/cpu_common.h +18 -0
@@ -1,5 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 */ /* +* Common code for Intel CPUs +* * Copyright (c) 2016 Google, Inc */
@@ -56,4 +58,20 @@ int cpu_intel_get_info(struct cpu_info *info, int bclk_mz);*/ int cpu_configure_thermal_target (struct udevice *dev); +/** +* cpu_set_perf_control() - Set the nominal CPU clock speed +* +* This sets the clock speed as a muiltiplier of BCLK +* +* @clk_ratio: Ratio to use +*/ +void cpu_set_perf_control (uint clk_ratio); + +/** +* cpu_config_tdp_levels() - Check for configurable TDP option +* +* @return true if the CPU has configurable TDP (Thermal-desgn power) +*/ +bool cpu_config_tdp_levels (void ); +#endif
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 54/126 x86: Add common functions for TDP and perf control
Quoted 91 lines · Simon Glass
These functions are the same on modern Intel CPUs, so use common code to set them.
Signed-off-by Simon Glass <[email protected]>---
arch/x86/cpu/broadwell/cpu.c | 7 ++---- arch/x86/cpu/broadwell/cpu_full.c | 9 ------- arch/x86/cpu/intel_common/cpu.c | 20 +++++++++++++++ arch/x86/cpu/ivybridge/model_206ax.c | 25 +++++++------------ arch/x86/cpu/ivybridge/northbridge.c | 2 +- .../include/asm/arch-ivybridge/model_206ax.h | 2 +- arch/x86/include/asm/cpu_common.h | 18 +++++++++++++ 7 files changed, 51 insertions(+), 32 deletions(-)arch/x86/cpu/broadwell/cpu.c +2
-5@@ -41,12 +41,9 @@ int arch_cpu_init_dm(void)void set_max_freq (void ) { -msr_t msr, perf_ctl, platform_info; +msr_t msr, perf_ctl; -/* Check for configurable TDP option */ - platform_info =msr_read (MSR_PLATFORM_INFO ); - -if ((platform_info.hi >>1 ) &3 ) { +if (cpu_config_tdp_levels ()) {/* Set to nominal TDP ratio */ msr =msr_read (MSR_CONFIG_TDP_NOMINAL ); perf_ctl.lo = (msr.lo &0xff ) <<8 ;arch/x86/cpu/broadwell/cpu_full.c +0
-9@@ -329,15 +329,6 @@ static int bsp_init_before_ap_bringup(struct udevice *dev)return 0 ; } -static int cpu_config_tdp_levels (void ) -{ -msr_t platform_info; - -/* Bits 34:33 indicate how many levels supported */ - platform_info =msr_read (MSR_PLATFORM_INFO ); -return (platform_info.hi >>1 ) &3 ; -} -static void set_max_ratio (void ) {msr_t msr, perf_ctl;arch/x86/cpu/intel_common/cpu.c +20
-0@@ -145,3 +145,23 @@ int cpu_configure_thermal_target(struct udevice *dev)return 0 ; } + +void cpu_set_perf_control (uint clk_ratio) +{ +msr_t perf_ctl; + + perf_ctl.lo = (clk_ratio &0xff ) <<8 ; + perf_ctl.hi =0 ; +msr_write (MSR_IA32_PERF_CTL , perf_ctl); +debug ("CPU: frequency set to %d MHz\n" , clk_ratio *INTEL_BCLK_MHZ ); +} + +bool cpu_config_tdp_levels (void ) +{ +msr_t platform_info; + +/* Bits 34:33 indicate how many levels supported */ + platform_info =msr_read (MSR_PLATFORM_INFO ); + +return ((platform_info.hi >>1 ) &3 ) !=0 ; +}arch/x86/cpu/ivybridge/model_206ax.c +0
-0@@ -140,19 +140,16 @@ static const u8 power_limit_time_msr_to_sec[] = { [0x11] = 128, };
arch/x86/cpu/ivybridge/model_206ax.c static const u8 power_limit_time_msr_to_sec[] = { · line 150
Quoted 10 lines
arch/x86/cpu/ivybridge/model_206ax.c +1
-2-int cpu_config_tdp_levels (void ) +bool cpu_ivybridge_config_tdp_levels (void ) {struct cpuid_result result; -msr_t platform_info;/* Minimum CPU revision */ result =cpuid (1 );if (result.eax <IVB_CONFIG_TDP_MIN_CPUID )return 0 ;
We should return false here, since the return value type is now changed to bool.
Quoted 97 lines
arch/x86/cpu/ivybridge/model_206ax.c +8
-14-/* Bits 34:33 indicate how many levels supported */ - platform_info =msr_read (MSR_PLATFORM_INFO ); -return (platform_info.hi >>1 ) &3 ; +return cpu_config_tdp_levels (); }/* @@ -213,7 +210,7 @@ void set_power_limits(u8 power_limit_1_time)msr_write (MSR_PKG_POWER_LIMIT , limit);/* Use nominal TDP values for CPUs with configurable TDP */ -if (cpu_config_tdp_levels ()) { +if (cpu_ivybridge_config_tdp_levels ()) { msr =msr_read (MSR_CONFIG_TDP_NOMINAL ); limit.hi =0 ; limit.lo = msr.lo &0xff ;@@ -329,24 +326,20 @@ static void configure_dca_cap(void)static void set_max_ratio (void ) { -msr_t msr, perf_ctl; - - perf_ctl.hi =0 ; +msr_t msr; +uint ratio;/* Check for configurable TDP option */ -if (cpu_config_tdp_levels ()) { +if (cpu_ivybridge_config_tdp_levels ()) {/* Set to nominal TDP ratio */ msr =msr_read (MSR_CONFIG_TDP_NOMINAL ); - perf_ctl.lo = (msr.lo &0xff ) <<8 ; + ratio = msr.lo &0xff ; }else {/* Platform Info bits 15:8 give max ratio */ msr =msr_read (MSR_PLATFORM_INFO ); - perf_ctl.lo = msr.lo &0xff00 ; + ratio = (msr.lo &0xff00 ) >>8 ; } -msr_write (MSR_IA32_PERF_CTL , perf_ctl); - -debug ("model_x06ax: frequency set to %d\n" , - ((perf_ctl.lo >>8 ) &0xff ) *INTEL_BCLK_MHZ ); +cpu_set_perf_control (ratio); }static void set_energy_perf_bias (u8 policy)arch/x86/cpu/ivybridge/northbridge.c +1
-1@@ -141,7 +141,7 @@ static void northbridge_init(struct udevice *dev, int rev)* CPUs with configurable TDP also need power limits set * in MCHBAR. Use same values from MSR_PKG_POWER_LIMIT. */ -if (cpu_config_tdp_levels ()) { +if (cpu_ivybridge_config_tdp_levels ()) {msr_t msr =msr_read (MSR_PKG_POWER_LIMIT );writel (msr.lo,MCHBAR_REG (0x59A0 ));arch/x86/include/asm/arch-ivybridge/model_206ax.h +1
-1@@ -58,6 +58,6 @@/* Configure power limits for turbo mode */ void set_power_limits (u8 power_limit_1_time); -int cpu_config_tdp_levels (void ); +bool cpu_ivybridge_config_tdp_levels (void );#endif arch/x86/include/asm/cpu_common.h +10
-0@@ -1,5 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 */ /* +* Common code for Intel CPUs +* * Copyright (c) 2016 Google, Inc */ @@ -56,4 +58,20 @@ int cpu_intel_get_info(struct cpu_info *info, int bclk_mz);*/ int cpu_configure_thermal_target (struct udevice *dev); +/** +* cpu_set_perf_control() - Set the nominal CPU clock speed +* +* This sets the clock speed as a muiltiplier of BCLK +* +* @clk_ratio: Ratio to use +*/ +void cpu_set_perf_control (uint clk_ratio);
arch/x86/include/asm/cpu_common.h int cpu_intel_get_info(struct cpu_info *info, int bclk_mz);
Quoted 10 lines
arch/x86/include/asm/cpu_common.h +8
-1+ +/** +* cpu_config_tdp_levels() - Check for configurable TDP option +* +* @return true if the CPU has configurable TDP (Thermal-desgn power) +*/ +bool cpu_config_tdp_levels (void ); +#endif --
Other than above,
PATCH 54/126 x86: Add common functions for TDP and perf control
Quoted 18 lines · Bin Meng
Quoted 16 lines · Simon Glass
These functions are the same on modern Intel CPUs, so use common code to set them.
Signed-off-by Simon Glass <[email protected]>---
arch/x86/cpu/broadwell/cpu.c | 7 ++---- arch/x86/cpu/broadwell/cpu_full.c | 9 ------- arch/x86/cpu/intel_common/cpu.c | 20 +++++++++++++++ arch/x86/cpu/ivybridge/model_206ax.c | 25 +++++++------------ arch/x86/cpu/ivybridge/northbridge.c | 2 +- .../include/asm/arch-ivybridge/model_206ax.h | 2 +- arch/x86/include/asm/cpu_common.h | 18 +++++++++++++ 7 files changed, 51 insertions(+), 32 deletions(-)
[snip]
Quoted 12 lines
Quoted 12 lines
arch/x86/include/asm/cpu_common.h +2
-0@@ -1,5 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 */ /* +* Common code for Intel CPUs +* * Copyright (c) 2016 Google, Inc */
Quoted 8 lines
arch/x86/include/asm/cpu_common.h int cpu_intel_get_info(struct cpu_info *info, int bclk_mz); · line 64
Quoted 8 lines
arch/x86/include/asm/cpu_common.h +4
-0@@ -56,4 +58,20 @@ int cpu_intel_get_info(struct cpu_info *info, int bclk_mz);*/ int cpu_configure_thermal_target (struct udevice *dev); +/** +* cpu_set_perf_control() - Set the nominal CPU clock speed +* +* This sets the clock speed as a muiltiplier of BCLK
typo: multiplier
Quoted 9 lines
arch/x86/include/asm/cpu_common.h int cpu_intel_get_info(struct cpu_info *info, int bclk_mz); · line 73
Quoted 9 lines
arch/x86/include/asm/cpu_common.h +9
-0+* +* @clk_ratio: Ratio to use +*/ +void cpu_set_perf_control (uint clk_ratio); + +/** +* cpu_config_tdp_levels() - Check for configurable TDP option +* +* @return true if the CPU has configurable TDP (Thermal-desgn power)
typo: design
Quoted 5 lines
arch/x86/include/asm/cpu_common.h int cpu_intel_get_info(struct cpu_info *info, int bclk_mz);
Quoted 5 lines
arch/x86/include/asm/cpu_common.h +3
-1+*/ +bool cpu_config_tdp_levels (void ); +#endif --
Will fix these typos when applying.
PATCH 54/126 x86: Add common functions for TDP and perf control
Quoted 58 lines · Bin Meng
Quoted 18 lines · Bin Meng
Quoted 16 lines · Simon Glass
These functions are the same on modern Intel CPUs, so use common code to set them.
Signed-off-by Simon Glass <[email protected]>---
arch/x86/cpu/broadwell/cpu.c | 7 ++---- arch/x86/cpu/broadwell/cpu_full.c | 9 ------- arch/x86/cpu/intel_common/cpu.c | 20 +++++++++++++++ arch/x86/cpu/ivybridge/model_206ax.c | 25 +++++++------------ arch/x86/cpu/ivybridge/northbridge.c | 2 +- .../include/asm/arch-ivybridge/model_206ax.h | 2 +- arch/x86/include/asm/cpu_common.h | 18 +++++++++++++ 7 files changed, 51 insertions(+), 32 deletions(-)[snip]
Quoted 12 lines
Quoted 12 lines
arch/x86/include/asm/cpu_common.h +2
-0@@ -1,5 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 */ /* +* Common code for Intel CPUs +* * Copyright (c) 2016 Google, Inc */ Quoted 8 lines
arch/x86/include/asm/cpu_common.h int cpu_intel_get_info(struct cpu_info *info, int bclk_mz); · line 64
Quoted 8 lines
arch/x86/include/asm/cpu_common.h +4
-0@@ -56,4 +58,20 @@ int cpu_intel_get_info(struct cpu_info *info, int bclk_mz);*/ int cpu_configure_thermal_target (struct udevice *dev); +/** +* cpu_set_perf_control() - Set the nominal CPU clock speed +* +* This sets the clock speed as a muiltiplier of BCLK typo: multiplier
Quoted 9 lines
arch/x86/include/asm/cpu_common.h int cpu_intel_get_info(struct cpu_info *info, int bclk_mz); · line 73
Quoted 9 lines
arch/x86/include/asm/cpu_common.h +9
-0+* +* @clk_ratio: Ratio to use +*/ +void cpu_set_perf_control (uint clk_ratio); + +/** +* cpu_config_tdp_levels() - Check for configurable TDP option +* +* @return true if the CPU has configurable TDP (Thermal-desgn power) typo: design
Quoted 7 lines
Quoted 5 lines
arch/x86/include/asm/cpu_common.h int cpu_intel_get_info(struct cpu_info *info, int bclk_mz);
Quoted 5 lines
arch/x86/include/asm/cpu_common.h +3
-1+*/ +bool cpu_config_tdp_levels (void ); +#endif --Will fix these typos when applying.
Fixed return value as false, and these typos, and,
applied to u-boot-x86/next, thanks!
PATCH 55/126 x86: Tidy up some duplicate MSR defines
In reply to Simon GlassSome MSR registers are defined twice in different parts of the file. Move them together and remove the duplicates. Also drop some thermal defines which are not used.
---
arch/x86/cpu/baytrail/cpu.c | 6 +- arch/x86/cpu/broadwell/cpu_full.c | 6 +- arch/x86/cpu/turbo.c | 10 +-- arch/x86/include/asm/msr-index.h | 106 ++++++++++++------------------ 4 files changed, 54 insertions(+), 74 deletions(-)
arch/x86/cpu/baytrail/cpu.c +3 -3
@@ -68,9 +68,9 @@ static void set_max_freq(void)msr_t msr;/* Enable speed step */ - msr =msr_read (MSR_IA32_MISC_ENABLES ); - msr.lo |= (1 <<16 ); -msr_write (MSR_IA32_MISC_ENABLES , msr); + msr =msr_read (MSR_IA32_MISC_ENABLE ); + msr.lo |=MISC_ENABLE_ENHANCED_SPEEDSTEP ; +msr_write (MSR_IA32_MISC_ENABLE , msr);/* * Set guaranteed ratio [21:16] from IACORE_RATIOS to bits [15:8] of
arch/x86/cpu/broadwell/cpu_full.c +3 -3
@@ -470,9 +470,9 @@ static void configure_misc(void)msr_t msr; msr =msr_read (MSR_IA32_MISC_ENABLE ); - msr.lo |= (1 <<0 );/* Fast String enable */ - msr.lo |= (1 <<3 );/* TM1/TM2/EMTTM enable */ - msr.lo |= (1 <<16 );/* Enhanced SpeedStep Enable */ + msr.lo |=MISC_ENABLE_FAST_STRING ; + msr.lo |=MISC_ENABLE_TM1 ; + msr.lo |=MISC_ENABLE_ENHANCED_SPEEDSTEP ;msr_write (MSR_IA32_MISC_ENABLE , msr);/* Disable thermal interrupts */
arch/x86/cpu/turbo.c +5 -5
@@ -60,8 +60,8 @@ int turbo_get_state(void) cpuid_regs =cpuid (CPUID_LEAF_PM ); turbo_cap = !!(cpuid_regs.eax &PM_CAP_TURBO_MODE ); - msr =msr_read (MSR_IA32_MISC_ENABLES ); - turbo_en = !(msr.hi &H_MISC_DISABLE_TURBO ); + msr =msr_read (MSR_IA32_MISC_ENABLE ); + turbo_en = !(msr.hi &MISC_DISABLE_TURBO );if (!turbo_cap && turbo_en) {/* Unavailable */
@@ -86,9 +86,9 @@ void turbo_enable(void)/* Only possible if turbo is available but hidden */ if (turbo_get_state () ==TURBO_DISABLED ) {/* Clear Turbo Disable bit in Misc Enables */ - msr =msr_read (MSR_IA32_MISC_ENABLES ); - msr.hi &= ~H_MISC_DISABLE_TURBO ; -msr_write (MSR_IA32_MISC_ENABLES , msr); + msr =msr_read (MSR_IA32_MISC_ENABLE ); + msr.hi &= ~MISC_DISABLE_TURBO ; +msr_write (MSR_IA32_MISC_ENABLE , msr);/* Update cached turbo state */ set_global_turbo_state (TURBO_ENABLED );
arch/x86/include/asm/msr-index.h +43 -63
124 lines not on this page · raw message
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 55/126 x86: Tidy up some duplicate MSR defines
Quoted 5 lines · Simon Glass
Some MSR registers are defined twice in different parts of the file. Move them together and remove the duplicates. Also drop some thermal defines which are not used.
Quoted 9 lines
Signed-off-by Simon Glass <[email protected]>---
arch/x86/cpu/baytrail/cpu.c | 6 +- arch/x86/cpu/broadwell/cpu_full.c | 6 +- arch/x86/cpu/turbo.c | 10 +-- arch/x86/include/asm/msr-index.h | 106 ++++++++++++------------------ 4 files changed, 54 insertions(+), 74 deletions(-)
PATCH 55/126 x86: Tidy up some duplicate MSR defines
Quoted 10 lines · Bin Meng
Quoted 8 lines · Simon Glass
Some MSR registers are defined twice in different parts of the file. Move them together and remove the duplicates. Also drop some thermal defines which are not used.
Signed-off-by Simon Glass <[email protected]>---
Quoted 8 lines
Quoted 6 lines
arch/x86/cpu/baytrail/cpu.c | 6 +- arch/x86/cpu/broadwell/cpu_full.c | 6 +- arch/x86/cpu/turbo.c | 10 +-- arch/x86/include/asm/msr-index.h | 106 ++++++++++++------------------ 4 files changed, 54 insertions(+), 74 deletions(-)Reviewed-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!