From f26ce03b444ac97448eca0cc58071f5fa8ffc3bd Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Mon, 15 Oct 2018 02:21:06 -0700 Subject: efi_driver: blk: Switch to use platdata_auto_alloc_size for the driver data Currently the efi block driver uses priv_auto_alloc_size for the driver data, however that's only available after the device probe phase. In order to make it accessible in an earlier phase, switch to use platdata_auto_alloc_size instead. This patch is the prerequisite for the follow up patch of DM BLK driver changes to work with EFI loader. Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- lib/efi_driver/efi_block_device.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'lib') diff --git a/lib/efi_driver/efi_block_device.c b/lib/efi_driver/efi_block_device.c index 5b9c139f38..7b71b4dd2e 100644 --- a/lib/efi_driver/efi_block_device.c +++ b/lib/efi_driver/efi_block_device.c @@ -38,7 +38,7 @@ * handle handle of the controller on which this driver is installed * io block io protocol proxied by this driver */ -struct efi_blk_priv { +struct efi_blk_platdata { efi_handle_t handle; struct efi_block_io *io; }; @@ -55,8 +55,8 @@ struct efi_blk_priv { static ulong efi_bl_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, void *buffer) { - struct efi_blk_priv *priv = dev->priv; - struct efi_block_io *io = priv->io; + struct efi_blk_platdata *platdata = dev_get_platdata(dev); + struct efi_block_io *io = platdata->io; efi_status_t ret; EFI_PRINT("%s: read '%s', from block " LBAFU ", " LBAFU " blocks\n", @@ -84,8 +84,8 @@ static ulong efi_bl_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, static ulong efi_bl_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, const void *buffer) { - struct efi_blk_priv *priv = dev->priv; - struct efi_block_io *io = priv->io; + struct efi_blk_platdata *platdata = dev_get_platdata(dev); + struct efi_block_io *io = platdata->io; efi_status_t ret; EFI_PRINT("%s: write '%s', from block " LBAFU ", " LBAFU " blocks\n", @@ -135,7 +135,7 @@ static int efi_bl_bind(efi_handle_t handle, void *interface) struct efi_object *obj = efi_search_obj(handle); struct efi_block_io *io = interface; int disks; - struct efi_blk_priv *priv; + struct efi_blk_platdata *platdata; EFI_PRINT("%s: handle %p, interface %p\n", __func__, handle, io); @@ -163,16 +163,16 @@ static int efi_bl_bind(efi_handle_t handle, void *interface) return -ENOENT; /* Set the DM_FLAG_NAME_ALLOCED flag to avoid a memory leak */ device_set_name_alloced(bdev); - /* Allocate priv */ + + platdata = dev_get_platdata(bdev); + platdata->handle = handle; + platdata->io = interface; + ret = device_probe(bdev); if (ret) return ret; EFI_PRINT("%s: block device '%s' created\n", __func__, bdev->name); - priv = bdev->priv; - priv->handle = handle; - priv->io = interface; - ret = blk_prepare_device(bdev); /* Create handles for the partions of the block device */ @@ -193,7 +193,7 @@ U_BOOT_DRIVER(efi_blk) = { .name = "efi_blk", .id = UCLASS_BLK, .ops = &efi_blk_ops, - .priv_auto_alloc_size = sizeof(struct efi_blk_priv), + .platdata_auto_alloc_size = sizeof(struct efi_blk_platdata), }; /* EFI driver operators */ -- cgit From d0851c8937067ad396f2bdafc46d0326bf3317db Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Mon, 15 Oct 2018 02:21:07 -0700 Subject: blk: Call part_init() in the post_probe() method part_init() is currently called in every DM BLK driver, either in its bind() or probe() method. However we can use the BLK uclass driver's post_probe() method to do it automatically. Update all DM BLK drivers to adopt this change. Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- lib/efi_driver/efi_block_device.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'lib') diff --git a/lib/efi_driver/efi_block_device.c b/lib/efi_driver/efi_block_device.c index 7b71b4dd2e..3f147cf608 100644 --- a/lib/efi_driver/efi_block_device.c +++ b/lib/efi_driver/efi_block_device.c @@ -173,8 +173,6 @@ static int efi_bl_bind(efi_handle_t handle, void *interface) return ret; EFI_PRINT("%s: block device '%s' created\n", __func__, bdev->name); - ret = blk_prepare_device(bdev); - /* Create handles for the partions of the block device */ disks = efi_bl_bind_partitions(handle, bdev); EFI_PRINT("Found %d partitions\n", disks); -- cgit From 2895c4b7d65e1a65f7d8804126f91ee91e8e2481 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Mon, 15 Oct 2018 02:21:15 -0700 Subject: kconfig: Introduce HAVE_ARCH_IOMAP Introduce a new Kconfig option for architecture codes to control whether it provides io{read,write}{8,16,32} I/O accessor functions. Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- lib/Kconfig | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib') diff --git a/lib/Kconfig b/lib/Kconfig index ccab426e12..847e797a3a 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -21,6 +21,12 @@ config DYNAMIC_CRC_TABLE Enable this option to calculate entries for CRC tables at runtime. This can be helpful when reducing the size of the build image +config HAVE_ARCH_IOMAP + bool + help + Enable this option if architecture provides io{read,write}{8,16,32} + I/O accessor functions. + config HAVE_PRIVATE_LIBGCC bool -- cgit From ef329a6a736ba1bbfb940edc34ceaa14d3f45b53 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Wed, 24 Oct 2018 06:36:37 -0700 Subject: sysreset: Remove DM_FLAG_PRE_RELOC flag in various drivers When a driver declares DM_FLAG_PRE_RELOC flag, it wishes to be bound before relocation. However due to a bug in the DM core, the flag only takes effect when devices are statically declared via U_BOOT_DEVICE(). This bug has been fixed recently by commit "dm: core: Respect drivers with the DM_FLAG_PRE_RELOC flag in lists_bind_fdt()", but with the fix, it has a side effect that all existing drivers that declared DM_FLAG_PRE_RELOC flag will be bound before relocation now. This may expose potential boot failure on some boards due to insufficient memory during the pre-relocation stage. To mitigate this potential impact, the following changes are implemented: - Remove DM_FLAG_PRE_RELOC flag in the driver, if the driver only supports configuration from device tree (OF_CONTROL) - Keep DM_FLAG_PRE_RELOC flag in the driver only if the device is statically declared via U_BOOT_DEVICE() - Surround DM_FLAG_PRE_RELOC flag with OF_CONTROL check, for drivers that support both statically declared devices and configuration from device tree Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- lib/efi/efi_app.c | 1 - 1 file changed, 1 deletion(-) (limited to 'lib') diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c index 5879d40386..0047998ee0 100644 --- a/lib/efi/efi_app.c +++ b/lib/efi/efi_app.c @@ -161,5 +161,4 @@ U_BOOT_DRIVER(efi_sysreset) = { .id = UCLASS_SYSRESET, .of_match = efi_sysreset_ids, .ops = &efi_sysreset_ops, - .flags = DM_FLAG_PRE_RELOC, }; -- cgit