From patchwork Thu Feb 10 08:11:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 541411 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp2040080imo; Thu, 10 Feb 2022 00:15:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJxrL73JzpjpkPYseSxCTLNpDZetkiHNCW6GQsYqHM2ZIEs5NMfdWY7hNtAXtEQ81sTIk0y3 X-Received: by 2002:a05:6402:2549:: with SMTP id l9mr7100811edb.129.1644480930750; Thu, 10 Feb 2022 00:15:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644480930; cv=none; d=google.com; s=arc-20160816; b=DOlEHRfeqXh9jC+WCCZXutVOryCN/FBGiXttgcL9aiQaaVtJrKrCnX7H4Gapgggz3J TXZ5Z+OINCBlSwCx4aSOre/tcRt4YZ4+4AaMLABqmgGGvFsAp0RrrLCYz8RKrblDpOnA i65TkiiMjfyVb17Lqkr8DEyGuXy2e0RKtMPMOpLF48Dka+ATpKOH4YI6Ob7Z63rXlp55 1B3z0sPznN3NCXaUq41jiBcxqeVBFgfc0oU/jeRzOunLkaqy4u+hdu/ov/tHNKxBi+/3 b5uDNu2A5hE8WH8nhmpdaNfaqEDytVUX9s5CNiLfjLI/rA/Ozd0egpxhklggX07KSxjk 87iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nGtFj32QYfOOcSHbM1uUU+QpwypLb1V3dy+QFTQBg50=; b=0/7N5SDl3LcrK2iqRQqTY2zf0/qDLu9qsocHwbCdjQjZRWSJO7hBixOZ4OY0DoeycP BNNEGbMfsTrwbvWz/9tuVDUzyftE+/dYnvinMeuwlkTsibh0rS5FxGQu6Vu/e394bQmH 88jaPkHX58iIOWwC21/oqU3hhHTBMPj8wQj5Uwe/I3zfNEplY5fewzSBB69rSUDEBQPW J0afwyH3nkF0ZizlY7jXVuG+srIcBH/Edl1uWGe4PvGXFKqng7orz2z1jKnKhEks5vdU 6l2Ky7omvsRiiBOJQ+VZ28K9KZKPgpQBYXi3PuhB2UnMyKS4b78/ZXfU+U4wWmlB9EuD cj8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ol3mta0a; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id do9si12436324ejc.968.2022.02.10.00.15.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:15:30 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ol3mta0a; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 84F038386D; Thu, 10 Feb 2022 09:14:04 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Ol3mta0a"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F1BE281FDE; Thu, 10 Feb 2022 09:13:59 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D4C788386D for ; Thu, 10 Feb 2022 09:13:18 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pj1-x102c.google.com with SMTP id c5-20020a17090a1d0500b001b904a7046dso6211133pjd.1 for ; Thu, 10 Feb 2022 00:13:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nGtFj32QYfOOcSHbM1uUU+QpwypLb1V3dy+QFTQBg50=; b=Ol3mta0a44odfmyvs5C9cZ6gf1HWS04FoK45qb7oz6IUjVEDU3/4fCVr47rUwHsi6n xMxenC/e5+cJmxHTbAG2oIKFSTICxZeV13eUnkm9ibImCUIK71Mwe63n9AVcms4Q0KPG G3dUsKITAcgFMQV73O6NZCDzI3G8hJKBGORd1KhSbdDjYWkfqCxMaBypoBpjeQuox1DW JhmgkocmSj0FO+ntAtkWgjLjuh5ybBhwCEx3+jn+JIbNvjnLfofyY4AMDlVeQBRXbXrK JhdX4YwmUzEafZm33cinuCrap1N7vHSNQqH7JVUz5uEUp7/FYJ3vxyVyxI+jxuzsqbCT hYMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nGtFj32QYfOOcSHbM1uUU+QpwypLb1V3dy+QFTQBg50=; b=GSOCMzchSqWyMmJeXvGthM4B5zXxrJHsxkeI7V8g+3hU8Y7WEaCFBwQ2s+R1NGBVJQ lgPDBTdLFv8WCtkFZyQUKv4KmcduFXMliiG7NKNiVMsM7NseV8vlHk90MnA3nXQLZUiK Z9aGpGmuNl7yarD4LCdXtwhAABuIvGQmy0itWP+08f7XSYeaJykAyE20pjTRZRcnMb3v BXgmP7WpJKkui4vlLIK5CFb6byc+pnJhSxr2muNC80nBYdg1i/A//XXcJE8IPSYT4xzI t2eERFEHdgxUPBnjllIUW0zn55m9UX40KNPFebHmcGxEB2sj2kSNK2MwJeoLqdBpGp8w WGYQ== X-Gm-Message-State: AOAM530CnoWsmebyWnxBlTRDgxi6mNg4zSaLRjhWVviCXofdn81lRXK3 IR/fbp691lQx7Z/OwA6Am6MbXA== X-Received: by 2002:a17:902:ce02:: with SMTP id k2mr2904727plg.93.1644480797266; Thu, 10 Feb 2022 00:13:17 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:412e:384:fab9:f24]) by smtp.gmail.com with ESMTPSA id lk8sm1529208pjb.40.2022.02.10.00.13.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:13:16 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v2 18/20] efi_loader: disk: use udevice instead of blk_desc Date: Thu, 10 Feb 2022 17:11:22 +0900 Message-Id: <20220210081124.86612-19-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220210081124.86612-1-takahiro.akashi@linaro.org> References: <20220210081124.86612-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean In most of all cases, we can avoid using blk_desc which is expected to be private to udevice(UCLASS_BLK), that is, the data should not be manipulated outside the device driver unless really needed. Now efi_disk's internally use dev_read/write() interfaces. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- lib/efi_loader/efi_disk.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index 7abe5d3a6bd2..a8cac0a002c9 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -36,7 +36,7 @@ const efi_guid_t efi_system_partition_guid = PARTITION_SYSTEM_GUID; * @part: partition * @volume: simple file system protocol of the partition * @offset: offset into disk for simple partition - * @desc: internal block device descriptor + * @dev: associated DM device */ struct efi_disk_obj { struct efi_object header; @@ -48,7 +48,7 @@ struct efi_disk_obj { unsigned int part; struct efi_simple_file_system_protocol *volume; lbaint_t offset; - struct blk_desc *desc; + struct udevice *dev; /* TODO: move it to efi_object */ }; /** @@ -83,14 +83,12 @@ static efi_status_t efi_disk_rw_blocks(struct efi_block_io *this, void *buffer, enum efi_disk_direction direction) { struct efi_disk_obj *diskobj; - struct blk_desc *desc; int blksz; int blocks; unsigned long n; diskobj = container_of(this, struct efi_disk_obj, ops); - desc = (struct blk_desc *) diskobj->desc; - blksz = desc->blksz; + blksz = diskobj->media.block_size; blocks = buffer_size / blksz; lba += diskobj->offset; @@ -102,9 +100,9 @@ static efi_status_t efi_disk_rw_blocks(struct efi_block_io *this, return EFI_BAD_BUFFER_SIZE; if (direction == EFI_DISK_READ) - n = blk_dread(desc, lba, blocks, buffer); + n = dev_read(diskobj->dev, lba, blocks, buffer); else - n = blk_dwrite(desc, lba, blocks, buffer); + n = dev_write(diskobj->dev, lba, blocks, buffer); /* We don't do interrupts, so check for timers cooperatively */ efi_timer_check(); @@ -446,7 +444,6 @@ static efi_status_t efi_disk_add_dev( diskobj->ops = block_io_disk_template; diskobj->ifname = if_typename; diskobj->dev_index = dev_index; - diskobj->desc = desc; /* Fill in EFI IO Media info (for read/write callbacks) */ diskobj->media.removable_media = desc->removable; @@ -522,6 +519,7 @@ static int efi_disk_create_raw(struct udevice *dev) return -1; } + disk->dev = dev; if (dev_tag_set_ptr(dev, DM_TAG_EFI, &disk->header)) { efi_free_pool(disk->dp); efi_delete_handle(&disk->header); @@ -578,6 +576,7 @@ static int efi_disk_create_part(struct udevice *dev) log_err("Adding partition for %s failed\n", dev->name); return -1; } + disk->dev = dev; if (dev_tag_set_ptr(dev, DM_TAG_EFI, &disk->header)) { efi_free_pool(disk->dp); efi_delete_handle(&disk->header); @@ -743,20 +742,22 @@ bool efi_disk_is_system_part(efi_handle_t handle) { struct efi_handler *handler; struct efi_disk_obj *diskobj; - struct disk_partition info; + struct udevice *dev; + struct disk_part *part; efi_status_t ret; - int r; /* check if this is a block device */ ret = efi_search_protocol(handle, &efi_block_io_guid, &handler); if (ret != EFI_SUCCESS) return false; + /* find a partition udevice */ diskobj = container_of(handle, struct efi_disk_obj, header); - - r = part_get_info(diskobj->desc, diskobj->part, &info); - if (r) + dev = diskobj->dev; + if (!dev || dev->driver->id != UCLASS_PARTITION) return false; - return !!(info.bootable & PART_EFI_SYSTEM_PARTITION); + part = dev_get_uclass_plat(dev); + + return !!(part->gpt_part_info.bootable & PART_EFI_SYSTEM_PARTITION); }