From patchwork Tue Mar 8 11:36:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 549283 Delivered-To: patch@linaro.org Received: by 2002:adf:80eb:0:0:0:0:0 with SMTP id 98csp1663206wrl; Tue, 8 Mar 2022 03:42:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJwpw1cnE+8knuyHdQ1HViE9j3l1RuKpZYCsLbicE3RSOlBf07FGz591SmJV6MlZZoXyQN0G X-Received: by 2002:a17:907:9712:b0:6b7:98d6:6139 with SMTP id jg18-20020a170907971200b006b798d66139mr13049161ejc.498.1646739754822; Tue, 08 Mar 2022 03:42:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646739754; cv=none; d=google.com; s=arc-20160816; b=uk5P7JdcUx6UJIiCOhLg3aiBpbJEWhfqGEWwMTkiq10CHnF/Y5Qu2LbG1U0qABdv08 3m0f8v5IEpkuPypcF0k75Z4NloJlucKfok3PYzgEo4iT2CtEL/sme5uejvbjFAmX1N1n jFLs/MDNSjGb/ZiBvTPNjFDWV63ltLSb97IS/yGl+NeqfQfXcNS9SwsVDm1A9sR51tZs ySPBOlVEPTcq7nLjrzad/KYRWZNTQL9n9S9eXUwCLLpIptoHO10wrqAD7/Bq3HAkXOsv xYDqZKSvVOm7MFAKL0GfhZSIeIvj0CbEbwgXxh/KHD75UEVcIbAZ57iO2AdLePA+yzr1 YO7A== 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=jBruEweBMiUF+MJbXlyuTRzN/cbcqgOmBUefUaeiB0g=; b=KyEw52n/3KQAlbj+f7hKVdXP5q+0KJxt95VXJ8AWQ0wytM+hMa+YywuFDOow1GQ6mp lJhKeFtZXEayplXY68YFttByow2cank0IQI0uCiCS2nvJkCcv3RD8HlFNeZGg/F9FMq+ lGL/119CAVfQGkRhEohDU8566LD6usRiQQTffndmDzFhXO5EhjHKT8SHvw0id9u2R81e 2gkH2GybU1J5/DHLtC6a/uJlL7tzxSK2NR+kmWKlCVtsURl4QirOWTwmn61M3j+UCtoh 8lzUuEF8EQxwETI6Tw3mggJEM97k/99jkQzoVCcAgLTuJ9ylm6m02opah9LJk/dzdCq1 atzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eTXmjMsl; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id i21-20020a05640242d500b0041674ea5496si1021094edc.464.2022.03.08.03.42.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 03:42:34 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eTXmjMsl; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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 1AEF5839CF; Tue, 8 Mar 2022 12:41:57 +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="eTXmjMsl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 142CE839A0; Tue, 8 Mar 2022 12:41:23 +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-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) (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 137F5839A7 for ; Tue, 8 Mar 2022 12:38:44 +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-pl1-x62c.google.com with SMTP id p17so16810266plo.9 for ; Tue, 08 Mar 2022 03:38:44 -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=jBruEweBMiUF+MJbXlyuTRzN/cbcqgOmBUefUaeiB0g=; b=eTXmjMslET9Ex0q6AAWfSsPubzM01DHTOPRSYPseQo7Lhz0gZQZAdiLMgDcXKlwCzv 7ODw2TboLFecJunp4tqw47C3Z1blLJsN+v3/Q2L1yHISvDQHGQ0DQJMkujt0c3Uu0fop qKCN6EU/XCvgaG+99WctcEl5zQPLNdHJv0f1JCL9Qsl/fho8hIQrR2uJp8LS3Y6o5ivz 1UqcIcEfCSrilBI5HQpRvgGUjBMeFcse9LcQLQeJwiPRqFzQ/Qb/4EhZGhp6VMb2u3wR zaq3wA0QPw4ifBI0aU5Tsb8BqihtD/q+hYPOXEk00y8qkDdPLvsoqW3FR98K4crHsOXK FzXg== 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=jBruEweBMiUF+MJbXlyuTRzN/cbcqgOmBUefUaeiB0g=; b=4lOiah7jV5gkiR3A6jSbuLWWojAoaTSG3jxsUpuqE2Nu3uzb9mDjWX8wrBYFQWao7I Xb2k9e04Q2HAVTeDNS/S1eyG2Ui2qm8qeL0mo3luwpqe9ZYnQKROitLrIooq/gMybgUE BMmJNXSG02/XW/e8V93riOeriQUz/M0ZDj+vaqJX+5vOBkX2c6n5mk3/oTo9BIqwtfEj XqzTVpdJ4J/A366SePhxoVBT+k8Upcf2Y6FtPmoxfl+7pxtKp6EMu/yyFDfooH20uEFM q9d6hf0mQyHseAVQg7VmSlaltlwtXtqJ2pBm6fgvca7vV3QDBrw4Bu+NRe1DwOWD3E+S DrbA== X-Gm-Message-State: AOAM5339LyGMaE6kgmQXHWOcTV9CYxBYrKx1cMkk8pxBTbZSJe66xZ+O Zf7HDokYyzc7OZQiGjr1ivC4tg== X-Received: by 2002:a17:902:f68f:b0:151:fbf5:db45 with SMTP id l15-20020a170902f68f00b00151fbf5db45mr4151132plg.60.1646739522440; Tue, 08 Mar 2022 03:38:42 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:b94a:f47a:3d51:185c]) by smtp.gmail.com with ESMTPSA id z2-20020a17090a170200b001bf2d530d64sm3434677pjd.2.2022.03.08.03.38.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 03:38:42 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.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 v3 17/19] efi_loader: disk: use udevice instead of blk_desc Date: Tue, 8 Mar 2022 20:36:55 +0900 Message-Id: <20220308113657.221101-18-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220308113657.221101-1-takahiro.akashi@linaro.org> References: <20220308113657.221101-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 53bee6654421..0b4f7a9ca317 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); @@ -740,20 +739,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); }