From patchwork Tue Apr 19 01:05:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 563294 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp2860113map; Mon, 18 Apr 2022 18:05:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxoGPKBjRb4FzdxeImFt/ONzyyGEnfqW6gnknpw7gdWdNly1pehjG5Dp17LFhfeNwemZui6 X-Received: by 2002:a05:6402:42d4:b0:412:c26b:789 with SMTP id i20-20020a05640242d400b00412c26b0789mr14985659edc.232.1650330352206; Mon, 18 Apr 2022 18:05:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650330352; cv=none; d=google.com; s=arc-20160816; b=IA5tf96Iiassvms5YcvjRWmtSlB/F+bSQE6g8lelIUDcp338HRUyQiD0vxr5N+ASPD kGi4WeAgJKWoPl27+h8Fhpuo/8ENFgy/pbitH8/c+7y6lu3nx8zbMQ6XZqLuJ3MoKioc RbQaXSguB5bsjgowEkkQcoQffIFO/m1uPx1FtT71RN0L5izQ5+aC/ELGmq9/ASf/NVvI 7swW9NvvMWhdwZjlHR5S8cyuT3d47BjGtCz7mT1pWGvcH6w44+lKYevI5+0ihZcFEDJU MYZqUAuODCgJTOJzuqlEG4zUd9i0Z9IKTx6eJPiMEvSOlIIUPTuDbEePgsegvp89JqzD 2zRw== 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=yPlc4gJGW0AhXRY0zwO1CjBS+z1fQTk36P+/M080M4Q=; b=AGnBbgI+kH3GoVVDMAiuMjRPsB9RyRrd8snWG8g1dzBGEStaeVg7xzo1Y7SW1ON1EU raDnRHQJ0AAwBG97p/nTJLe51vK6MJGpC5x8t3zyQoBbCMmFrFzEUqUtBv3jqUQ2gtOk 0NhnDCAX+M9sM7vwdxok99+PjwoCVIlDzwjkplJLbeYyaMG/tPCFs7b5dN3JwHjk2gZ5 OnOw4VzpOmmckxgnGTe71pPzF/aQFQHkPwgrDXEHwP2fY2LcHXOazBTHV+hWSRA1CHhN FAKor5Qy8uJ548J+2oB33BWpCSAcDbyBfyz7p7Penjb3nne8HIMPQcOZdOud9nm9msjH nZ+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fUMHTN6h; 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 o16-20020a1709064f9000b006efd8a8ce10si685334eju.639.2022.04.18.18.05.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 18:05:52 -0700 (PDT) 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=fUMHTN6h; 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 07D3D83B29; Tue, 19 Apr 2022 03:05:51 +0200 (CEST) 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="fUMHTN6h"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B9EFC83C13; Tue, 19 Apr 2022 03:05:47 +0200 (CEST) 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=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) (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 8022983B25 for ; Tue, 19 Apr 2022 03:05:42 +0200 (CEST) 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-pg1-x52b.google.com with SMTP id 203so2952326pgb.3 for ; Mon, 18 Apr 2022 18:05:42 -0700 (PDT) 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=yPlc4gJGW0AhXRY0zwO1CjBS+z1fQTk36P+/M080M4Q=; b=fUMHTN6hhSih6vtRKX2jDaA6+NCH6OVh1vHCGCmf7/Ddr2AN7aAdBNIbGW27/LKkZE fM/AlxDFXTHcHrzg9e8CBeAgjPIUZcn4GDGVt0KJev/mBqopPHegBwtny6CQTTDyMxBN NZHpaDEYMvTiFEGXo8zJ9J8lSa4thoD+M96iie8rJsE0fF5mTy2GW++Su9ZyBmRKKwwC 3WjElQOV1y+dHExkytxSoeP7g20XkezpwzEzh8qAozB5Q9RyUL5B3TVLUflNNAlp3mdW iwM5yvsxJktRK4NwK6C1AOkhj/QyjuFyyt6Db6oysT9rgM9gxYj9MAl3Xe+4A4DbsvIW neKA== 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=yPlc4gJGW0AhXRY0zwO1CjBS+z1fQTk36P+/M080M4Q=; b=M/3MaE1Piv5Xccf4MlWtNrI5xnODpD6EoZS/7QH6ErlM4BryyxB7bpQKc0x/Cni5Wc MCHXc0fksWF4txWBBqmiqjd7VA7BgiD2bKa6AnqNF2baPC2w1YY/MYC33OVGjoLNNjjE b6ocI8Y49HZa/wKaOyrg8EmW8lBPUtoH+0G4efBI1kNMViq+qlfJJQpmmPdYYrg+HeUo HYH+vQSSePYid78D3k3RwdW7QmYRkOVl6ZICq9GZFqsvx2Acof9KRVasESsGFJ4CZizN doclbt9Zoe4EhZn0Pt3EhQOIS9KqO9+R4vzCgaFWBES0Cp5k/4BrI+XicCF5j8uFRdAw /z8A== X-Gm-Message-State: AOAM532Gp52AnReizDr1ncFQ/5CZqtt4mwL1FcORUJZx9t2Sw2meX4uZ 52K3pEQwD6UPfm477pL91KNEumE2J3vhkw== X-Received: by 2002:a63:368a:0:b0:398:2829:2698 with SMTP id d132-20020a63368a000000b0039828292698mr12513288pga.172.1650330340927; Mon, 18 Apr 2022 18:05:40 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c3e1:100:5858:d3a6:5cad:ceeb]) by smtp.gmail.com with ESMTPSA id k137-20020a633d8f000000b0039800918b00sm14043756pga.77.2022.04.18.18.05.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 18:05:40 -0700 (PDT) From: AKASHI Takahiro To: 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 v5 01/12] dm: tag: change ENOSPC to ENOMEM Date: Tue, 19 Apr 2022 10:05:06 +0900 Message-Id: <20220419010517.47175-2-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220419010517.47175-1-takahiro.akashi@linaro.org> References: <20220419010517.47175-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 ENOMEM is a more common error code for memory starvation. Signed-off-by: AKASHI Takahiro --- drivers/core/tag.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/core/tag.c b/drivers/core/tag.c index 6829bcd8806c..22999193a5a3 100644 --- a/drivers/core/tag.c +++ b/drivers/core/tag.c @@ -29,7 +29,7 @@ int dev_tag_set_ptr(struct udevice *dev, enum dm_tag_t tag, void *ptr) node = calloc(sizeof(*node), 1); if (!node) - return -ENOSPC; + return -ENOMEM; node->dev = dev; node->tag = tag; @@ -53,7 +53,7 @@ int dev_tag_set_val(struct udevice *dev, enum dm_tag_t tag, ulong val) node = calloc(sizeof(*node), 1); if (!node) - return -ENOSPC; + return -ENOMEM; node->dev = dev; node->tag = tag; From patchwork Tue Apr 19 01:05:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 563295 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp2860207map; Mon, 18 Apr 2022 18:06:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZi+Trpty4IvKAF8RzL74ZSu+elL/MRrdD0o7ucyYqJS+oIY/eyFJQIyrvx7U2661xuv1k X-Received: by 2002:a17:907:2d93:b0:6e8:9838:339c with SMTP id gt19-20020a1709072d9300b006e89838339cmr11831807ejc.655.1650330364682; Mon, 18 Apr 2022 18:06:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650330364; cv=none; d=google.com; s=arc-20160816; b=Jmcv/GA/8YMtiWWGEbsbB/dvjMZJZhbOfNlclqkthE/O9jWKQABixpeuURKrJvxqWc TtQlgjDihtIkAo8pBo1XhdB63WVOSVEynxtAGkc1VMvWTeSUD0b+J/QJRJdw6Fv2o/O3 BjE9zCMJGOhsFoeXu63xIWVlSW0R/UTX6x+lY6E/DmOo2qqCTpsYBbUPpdRyG4kstgbP cSQBVA+Awp7WMXBobgFtk9Gu7jshPCeifLIlqVft3lEvUr+UDEEkx1XfsWQ1PKkxLMlO uZRrFk8LCk7/+Pv8FhwRUOcojY1uWUPVsBvHqapbxKxy1a0v9SbfyAGChPExN4yyriWY 5vQA== 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=cX/nLKjs6xoyV+5h4EfvdKOKYkfovrTdR9z7OgzIyt0=; b=DwtV8cy4wkCNbC0x4YI/dAIxMnWDCbjZS/MEy9lxLVSKd/G9TxGV6qW6pd2vGBTCpn YB7/V9Jg9TLrW6GPyv6EJ1NjyLGBtoH/GRmcJi1S25qukOhCXYIVPS1M5ruysMSRVhAP bP+RUQMGmnbMfmMOhu8sP9t9Mj+nNWTe+CkwcAfAR7WSedPBv63ZJNUHGj90X9LzelPS wnhN7wwrpYSd7EiRFK8HFSEgWy0u8ug57ixcNKsj0TasK+5HZQ9kvZQPG7+37zwjbJZW kWAmEXBTEBOvhjJ1iZb//YsNgM43fZEnspIxlrq/VXJ20zxnq8gwi7n18Rg/1qek5Chd tjLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=U0ZJLz8Y; 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 z17-20020a1709060f1100b006df9ffbf08dsi6309853eji.365.2022.04.18.18.06.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 18:06:04 -0700 (PDT) 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=U0ZJLz8Y; 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 3D14383B3D; Tue, 19 Apr 2022 03:05:56 +0200 (CEST) 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="U0ZJLz8Y"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DEF5C83C5A; Tue, 19 Apr 2022 03:05:48 +0200 (CEST) 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=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) (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 E5D9283B38 for ; Tue, 19 Apr 2022 03:05:44 +0200 (CEST) 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-pg1-x535.google.com with SMTP id k29so21958831pgm.12 for ; Mon, 18 Apr 2022 18:05:44 -0700 (PDT) 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=cX/nLKjs6xoyV+5h4EfvdKOKYkfovrTdR9z7OgzIyt0=; b=U0ZJLz8YRru/MC16ZoU8meNq+tzIjbfs5WiJgIYeeiK9I3p4LP11s7rD64suRGKj2O oons0+bkKDzkYNbJ6hAp2F20IzT4sXfcPnkgusKZESS5sbnheYah0LSkBrZZ+pfdkZKa u0+lr7ZYV2bMkWdOION2YznekrLv5sgcPdmVWVSY/0s4OBgEuaVqEUxcCTZuCzS16EwE HR015POXudRRbiQvOaUAWcOjrY7GwSrsRVp/7JdDGV3j5BE/mRFShp3sU1r3HY9hwvRw C//fjc9z4bvxFGkIC6wc01PUhaBHP6YnFQMde/otUEiucYptt/RxJTFtlboWS51dPi4l 7b8A== 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=cX/nLKjs6xoyV+5h4EfvdKOKYkfovrTdR9z7OgzIyt0=; b=zXRpWERO60dLYaa/XRMn3llBlPIWjH5tl1v7sYbpggEJa0RBkHuc5ziwjFZJ0wBtIx VuSXbq31CydyrQUIzAaDoQeGBZ3Fa8BBNft3sqg7PsKc3lMqhftgRWxuwoGxeMrkp8iB 4XZJVB06Leu7p9UwOO1Plax1k5Ab1cPx5Sz0T3JkWWiP+PBcjzkp7ykuBpouzb3sXKTE oc83LGdChAhzvr3pCqKvvgNsogyS+TIhUcNZF1XpcX51uEYRZ8Y/Z6WmBN2to2zJA3S+ ADAlMtUo1sF8nXn3lAe+ELoaseSRirPa9WhXhGhmOzIDW7obsVJmXu5TmAGQBm+8zuj9 eKDA== X-Gm-Message-State: AOAM5319FhwvtmqjvxrBRQSU6gV8Aw9s5VokiJK+tPyn3ydxD4jUlKNC y/HegQ4bx0KGGf1xXscX88SiUg== X-Received: by 2002:a65:5b0b:0:b0:3a8:2190:9a07 with SMTP id y11-20020a655b0b000000b003a821909a07mr10001664pgq.462.1650330343302; Mon, 18 Apr 2022 18:05:43 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c3e1:100:5858:d3a6:5cad:ceeb]) by smtp.gmail.com with ESMTPSA id k137-20020a633d8f000000b0039800918b00sm14043756pga.77.2022.04.18.18.05.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 18:05:42 -0700 (PDT) From: AKASHI Takahiro To: 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 v5 02/12] dm: tag: add some document Date: Tue, 19 Apr 2022 10:05:07 +0900 Message-Id: <20220419010517.47175-3-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220419010517.47175-1-takahiro.akashi@linaro.org> References: <20220419010517.47175-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 Some basic stuff about tag support is explained under doc/devlop/driver-model. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- doc/develop/driver-model/design.rst | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/doc/develop/driver-model/design.rst b/doc/develop/driver-model/design.rst index b0e6337030a1..3e88dc40e6fd 100644 --- a/doc/develop/driver-model/design.rst +++ b/doc/develop/driver-model/design.rst @@ -1042,6 +1042,26 @@ data structure might be worthwhile in some rare cases, once we understand what the bottlenecks are. +Tag Support +----------- + +It is sometimes useful for a subsystem to associate its own private +data (or object) to a DM device, i.e. struct udevice, to support +additional features. + +Tag support in driver model will give us the ability to do so dynamically +instead of modifying "udevice" data structure. In the initial release, we +will support two type of attributes: +- a pointer with dm_tag_set_ptr(), and +- an unsigned long with dm_tag_set_val() + +For example, UEFI subsystem utilizes the feature to maintain efi_disk +objects depending on linked udevice's lifecycle. + +While the current implementation is quite simple, it will get evolved +as the feature is more extensively used in U-Boot subsystems. + + Changes since v1 ---------------- From patchwork Tue Apr 19 01:05:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 563296 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp2860308map; Mon, 18 Apr 2022 18:06:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYhVTFDSSjP3hjsgwXmIt9A0uiTevkirD/VWLqDnpE2Ag5egy64RMJMrjhi4f9PvzCDjdw X-Received: by 2002:a17:907:7f8c:b0:6ef:e43e:f08f with SMTP id qk12-20020a1709077f8c00b006efe43ef08fmr3043ejc.733.1650330374823; Mon, 18 Apr 2022 18:06:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650330374; cv=none; d=google.com; s=arc-20160816; b=ggQho/U9Qri73on4Q6aufC8qf/Rs/lXzGog0uZaFWZG/mF/NuA4TEunPeZNMgNnScr n2RyTPntA9Ih1ATXVyN1g8HfNa8vzKsqGDNS134fKDRNANKzOIrxyLDti38JGxML3gzK oXfOWDw7jyWEPZdFFpSI5pcEmUxx8wf3VBFbX9P50Ckogn4AOjqO4xR7T/vy+AW1zEFk okD2+9QttBxHhKRvrSlyLAgSh0r6iZCEJBQlQVJpYSH4LZiEhyOXPYCNG+S824D9Rhgw g7mq57TGolCtLCYqIqg9H8qPrLrF7Mf4TNMZIKe5ScbRU6TTJcnPqbTxhpTKhtCQOpRa ct6g== 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=3zhbFhwoFiwMQkaYNb5BSiBvrj1lKF9eqN1bn4CV1xU=; b=X4ldgdiIZtVImr4HX58TCjQnaBqBK5CDq+KOM7Bc6H6bJaAIBrvrb4KrFCZKp20N+1 EL2ouGTAwza1T0Y9IhiVaWOqtg6pdDWCRTGWsOsWgDiBNaraWPzWcOudSZC7psO8jwxe SXXoOiQJs8I9ZI3lPuApTeQFe1UTHDQDkZLdnKlEHO46O4YfyzdlMJBOWPnqI9OofMHQ i2X7nZ4KAXZQQOxE2ipBZo4DXcwYUgAuNSM5kDYig1AY1OwCTBcEPfMKiwnHFx3gCbC+ w42Gl5fhfg0ntCZKrN4ZqVUBAPUSbDTrNZ2d4AseigEEEB0bSDfQM7wdaRCg3EoDjhNP UKtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=W6N7oHwR; 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 b8-20020a170906038800b006e8cb4353f2si7224821eja.302.2022.04.18.18.06.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 18:06:14 -0700 (PDT) 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=W6N7oHwR; 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 4123583D8E; Tue, 19 Apr 2022 03:06:07 +0200 (CEST) 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="W6N7oHwR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A86D383C11; Tue, 19 Apr 2022 03:05:54 +0200 (CEST) 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=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) (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 5330A83C06 for ; Tue, 19 Apr 2022 03:05:47 +0200 (CEST) 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-x102d.google.com with SMTP id mm4-20020a17090b358400b001cb93d8b137so818743pjb.2 for ; Mon, 18 Apr 2022 18:05:47 -0700 (PDT) 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=3zhbFhwoFiwMQkaYNb5BSiBvrj1lKF9eqN1bn4CV1xU=; b=W6N7oHwRJxB/mvAwHQY663/VXmgTCjTngepzDgiS+mYU4HjY2kGUvQCxmpHHqtgfO3 rNv0PsFVZluCzWiKM3El8iR7xZSSXtOSvTwPbpUgAho6w0zuwuwkF302tBDaASNR4XKe UhAx4NbGi4VLGdf/AEHcYsD97lEpvgaM511uzIixEwv/uayfhTY2BM5IdbH8Ann3YeTm B/fs/lH6AyteHO4Y/UmFe0YpBeWe4Ui/5kBxx1GF9siqaHDcyDqs8BFnJqQBWwwL5eNy iM9WRtV9bNqohnUJLKaSwu6RBxh/9XGSrtG3SucsipHzoOCtkMdcP9JlF8g9o2n87HBo DGoQ== 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=3zhbFhwoFiwMQkaYNb5BSiBvrj1lKF9eqN1bn4CV1xU=; b=gC/UiFnTlIZTQ4bMEe4RYw0ZL+O5XBshBEanq8/PyprW0wM5IV8AmErhz32OsBiYbj AEjLWdL2mKr2fmLhOJECNIguvWwCl5PXUtNhPH+DgrTZqV/fZzOnD5KbL5qLlE1iCcMy rz85IjzptYXI6qYB5XiW73ql62JUWDubTZoNHyn8OOo4PYGQZFvlW4QDNEmhgqQRPIno avgkE2B+kQyh7Z2NW80LpDYhVjA+hRzed1I41TDLN3J2wB02qDNJJuFaWf/yJHjt/xMl StPKWHEh2JFRCAzUQTN0Etft8UdHkUuXUxUI4fcTSbkG5DktXBgl2DDsFPagz8RMA0L+ RYsw== X-Gm-Message-State: AOAM533mc6zLsShJwY9CwoJsvtMcuNuimTfye6ZmerAdoMSGEM5OaKFf VPHUBaYRdBVOhO0M+kdR4MfFIA== X-Received: by 2002:a17:90a:b014:b0:1cb:ba36:8fe1 with SMTP id x20-20020a17090ab01400b001cbba368fe1mr21476839pjq.67.1650330345699; Mon, 18 Apr 2022 18:05:45 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c3e1:100:5858:d3a6:5cad:ceeb]) by smtp.gmail.com with ESMTPSA id k137-20020a633d8f000000b0039800918b00sm14043756pga.77.2022.04.18.18.05.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 18:05:45 -0700 (PDT) From: AKASHI Takahiro To: 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 v5 03/12] test: dm: add tests for tag support Date: Tue, 19 Apr 2022 10:05:08 +0900 Message-Id: <20220419010517.47175-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220419010517.47175-1-takahiro.akashi@linaro.org> References: <20220419010517.47175-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 The new test covers all tag-related interfaces. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- test/dm/Makefile | 1 + test/dm/tag.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 test/dm/tag.c diff --git a/test/dm/Makefile b/test/dm/Makefile index d46552fbf320..dc3177dbb7f4 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -102,6 +102,7 @@ obj-y += syscon.o obj-$(CONFIG_RESET_SYSCON) += syscon-reset.o obj-$(CONFIG_SYSINFO) += sysinfo.o obj-$(CONFIG_SYSINFO_GPIO) += sysinfo-gpio.o +obj-$(CONFIG_UT_DM) += tag.o obj-$(CONFIG_TEE) += tee.o obj-$(CONFIG_TIMER) += timer.o obj-$(CONFIG_DM_USB) += usb.o diff --git a/test/dm/tag.c b/test/dm/tag.c new file mode 100644 index 000000000000..8289954e7c26 --- /dev/null +++ b/test/dm/tag.c @@ -0,0 +1,84 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * DM tag test + * + * Copyright (c) 2021 Linaro Limited + * Author: AKASHI Takahiro + */ + +#include +#include +#include /* DM_TEST() */ +#include /* struct unit_test_state */ +#include /* assertions */ + +/* + * Test dm_tag_ptr() API + */ +static int dm_test_tag_ptr(struct unit_test_state *uts) +{ + ulong val; + void *ptr = NULL; + + ut_assertok(dev_tag_set_ptr(uts->root, DM_TAG_EFI, &val)); + + ut_assertok(dev_tag_get_ptr(uts->root, DM_TAG_EFI, &ptr)); + + ut_asserteq_ptr(&val, ptr); + + ut_assertok(dev_tag_del(uts->root, DM_TAG_EFI)); + + return 0; +} + +DM_TEST(dm_test_tag_ptr, 0); + +/* + * Test dm_tag_val() API + */ +static int dm_test_tag_val(struct unit_test_state *uts) +{ + ulong val1 = 0x12345678, val2 = 0; + + ut_assertok(dev_tag_set_val(uts->root, DM_TAG_EFI, val1)); + + ut_assertok(dev_tag_get_val(uts->root, DM_TAG_EFI, &val2)); + + ut_asserteq_64(val1, val2); + + ut_assertok(dev_tag_del(uts->root, DM_TAG_EFI)); + + return 0; +} + +DM_TEST(dm_test_tag_val, 0); + +/* + * Test against an invalid tag + */ +static int dm_test_tag_inval(struct unit_test_state *uts) +{ + ulong val; + + ut_asserteq(-EINVAL, dev_tag_set_ptr(uts->root, DM_TAG_COUNT, &val)); + + return 0; +} + +DM_TEST(dm_test_tag_inval, 0); + +/* + * Test dm_tag_del_all() AP: + */ +static int dm_test_tag_del_all(struct unit_test_state *uts) +{ + ulong val; + + ut_assertok(dev_tag_set_ptr(uts->root, DM_TAG_EFI, &val)); + + ut_assertok(dev_tag_del_all(uts->root)); + + return 0; +} + +DM_TEST(dm_test_tag_del_all, 0); From patchwork Tue Apr 19 01:05:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 563297 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp2860405map; Mon, 18 Apr 2022 18:06:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/x2Fo8UFVUPY43XC/yYpOuUnHW9FNjS6cbFFLPF1bVegumKZxmDV6MOqVCn7VTxN7ce0u X-Received: by 2002:a17:907:9602:b0:6df:e82c:f84 with SMTP id gb2-20020a170907960200b006dfe82c0f84mr11246230ejc.590.1650330385609; Mon, 18 Apr 2022 18:06:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650330385; cv=none; d=google.com; s=arc-20160816; b=Ys+3d70Y1bJf44rcZRxB00fmyOcIE2cfo/JQqljP3EMp+PKfuv/VgZ0v4WUPlSUu8Y lLnpDFQAfeQco8uaVLwYUmmb+2wdrsQEzF6vz6xNFLSjMWVzT6JkIqG4ApoJYsWym+nG 50DT3mPCZVgqGIXthpwBlDeAifDMIMiMgK2ePwCIyLkmb9EAvWlCmZWh5yMTz2iQfsS/ x49Y0/G58UrtHQvBUK+M5aUTC7dQ1IfHUyO0MkDaq1ZbL7GcFTUP/fBaz8qFK/qkGfrf kkrBfPO4CUApNB90NYHjVOie3UqS8KSWTzim1IWgsij7QIhdhekqV9H0zld6o9t8zZPJ ubRA== 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=ih7uQuXQd9OKOnMZdhgbhBngmt18xa7GFh0dW3fVUn0=; b=FkoDC+vQA2Z9OW/owoWrOemg7PHYpynVzLoBrjHBQICkbCvD8sc6ctKsDsZK7pEjuB z2y9Cm9YnEKQ8RCP6rVRg+6zOSE49GHM8XjOeMC+WJ3/ILvpDdH7MDsJBt4cair8rk0j bAbOP1FL33gbDD74Ozb1SbU9BSPHIAgIlxO3bIPZknLgwwXF+s51uaNnGZsmgxxaqrpp XU2sDUbt8S7nxSerMo5kickG6dEJJZFTaYp3ADxa+mge68TG/Etsp3bDeiw316jllmo2 cE2Vv13PfxH0M8eT5mw56xGPmlxXppSFK2F8JALVLHyTaQ3FEulGOD8GdRiqmTDIQPYX Z9+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UiMZZ3Ly; 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 z23-20020a170906435700b006e898982060si7546200ejm.476.2022.04.18.18.06.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 18:06:25 -0700 (PDT) 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=UiMZZ3Ly; 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 A05BC83C06; Tue, 19 Apr 2022 03:06:10 +0200 (CEST) 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="UiMZZ3Ly"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D97AF83C1E; Tue, 19 Apr 2022 03:05:55 +0200 (CEST) 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=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) (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 BCEEC83B38 for ; Tue, 19 Apr 2022 03:05:49 +0200 (CEST) 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-x1033.google.com with SMTP id j8-20020a17090a060800b001cd4fb60dccso840803pjj.2 for ; Mon, 18 Apr 2022 18:05:49 -0700 (PDT) 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=ih7uQuXQd9OKOnMZdhgbhBngmt18xa7GFh0dW3fVUn0=; b=UiMZZ3LyF4Okrv+aMwNMntrzkt9F+bHFQQQnw1cGktiJ5ois3cG09iCpGtGUcjz/21 okI8P0b/1fSVcvNNhI5lYQ0L/c60t+fnGExghZo0U1yNkUX/d2EjBBruG89FiE00fehh OpRCi9SlQZJZQx5Dvm1Y06Ngj4BED7Uq0OVnEbjBqjwPiZPTYFSRjCLxggskNr73JnDD 955YDmbkapSj/xOOlOsAn1hpqJbs6cvmvjJpQxtWiWRQI3G+eGOzhxZtvGaK4zqFyMfN WA6TqOJIrCmE6wsq1a2lBm5Dx2OB5ohH7yGB6sLSAN4aKdjEf8ZBGWK+U9yx6s523H5o ZHZA== 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=ih7uQuXQd9OKOnMZdhgbhBngmt18xa7GFh0dW3fVUn0=; b=q+YpjDviazKWrXVMmxjS7n8zxtOaO1p/H7lGYvh7p0gevqpS2tqDeoP6Qrj8egIBj5 aJHP566Hb/R7JsNRUImsxWCwkXEWssA2ZHoz14MyqeyLJ4PZSmI7lVraqD0qgaWci2vW TNnGa3Kg26zOu0FNArDebqMMI5aX/WCCha7ypDtLK3PKRkUVbSjPLCLcYYoDJyPXLxGh MMFTIYjyT/Ra+zGSfMt3xmEFV2U7BFumw55C5w8d5tR+DStfR0dh513OMqKmr3X0DylE Um1nyrdiPWx5Kv7Q6n0GnYqZjBiGNbUbCA9klahhDGGG3VFKhxNVt5EmvG4HGQD5B47T hGmA== X-Gm-Message-State: AOAM531fxkizFMpaNbfXvAW6THOCp+DUr4dRqiG2XVcazK3DNsL6YF1K EXF3iavrJ6lewzBmHG4ycoD50WhIHzKGLw== X-Received: by 2002:a17:90a:d082:b0:1ca:be58:c692 with SMTP id k2-20020a17090ad08200b001cabe58c692mr21129582pju.238.1650330348076; Mon, 18 Apr 2022 18:05:48 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c3e1:100:5858:d3a6:5cad:ceeb]) by smtp.gmail.com with ESMTPSA id k137-20020a633d8f000000b0039800918b00sm14043756pga.77.2022.04.18.18.05.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 18:05:47 -0700 (PDT) From: AKASHI Takahiro To: 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 v5 04/12] dm: disk: add UCLASS_PARTITION Date: Tue, 19 Apr 2022 10:05:09 +0900 Message-Id: <20220419010517.47175-5-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220419010517.47175-1-takahiro.akashi@linaro.org> References: <20220419010517.47175-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 NOTE: probably we have to update config dependencies, in particular, SPL/TPL_PRINTF? With this new function, UCLASS_PARTITION devices will be created as child nodes of UCLASS_BLK device. Signed-off-by: AKASHI Takahiro --- disk/Makefile | 3 + disk/disk-uclass.c | 153 +++++++++++++++++++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + include/part.h | 10 +++ 4 files changed, 167 insertions(+) create mode 100644 disk/disk-uclass.c diff --git a/disk/Makefile b/disk/Makefile index 5ca10c55762b..ec148832b330 100644 --- a/disk/Makefile +++ b/disk/Makefile @@ -6,6 +6,9 @@ #ccflags-y += -DET_DEBUG -DDEBUG obj-$(CONFIG_$(SPL_TPL_)PARTITIONS) += part.o +ifdef CONFIG_$(SPL_TPL_)BLK +obj-$(CONFIG_$(SPL_TPL_)PARTITIONS) += disk-uclass.o +endif obj-$(CONFIG_$(SPL_TPL_)MAC_PARTITION) += part_mac.o obj-$(CONFIG_$(SPL_TPL_)DOS_PARTITION) += part_dos.o obj-$(CONFIG_$(SPL_TPL_)ISO_PARTITION) += part_iso.o diff --git a/disk/disk-uclass.c b/disk/disk-uclass.c new file mode 100644 index 000000000000..4918a2f72d1e --- /dev/null +++ b/disk/disk-uclass.c @@ -0,0 +1,153 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Software partition device (UCLASS_PARTITION) + * + * Copyright (c) 2021 Linaro Limited + * Author: AKASHI Takahiro + */ + +#define LOG_CATEGORY UCLASS_PARTITION + +#include +#include +#include +#include +#include +#include +#include + +int part_create_block_devices(struct udevice *blk_dev) +{ + int part, count; + struct blk_desc *desc = dev_get_uclass_plat(blk_dev); + struct disk_partition info; + struct disk_part *part_data; + char devname[32]; + struct udevice *dev; + int ret; + + if (!CONFIG_IS_ENABLED(PARTITIONS) || + !CONFIG_IS_ENABLED(HAVE_BLOCK_DEVICE)) + return 0; + + if (device_get_uclass_id(blk_dev) != UCLASS_BLK) + return 0; + + /* Add devices for each partition */ + for (count = 0, part = 1; part <= MAX_SEARCH_PARTITIONS; part++) { + if (part_get_info(desc, part, &info)) + continue; + snprintf(devname, sizeof(devname), "%s:%d", blk_dev->name, + part); + + ret = device_bind_driver(blk_dev, "blk_partition", + strdup(devname), &dev); + if (ret) + return ret; + + part_data = dev_get_uclass_plat(dev); + part_data->partnum = part; + part_data->gpt_part_info = info; + count++; + + ret = device_probe(dev); + if (ret) { + debug("Can't probe\n"); + count--; + device_unbind(dev); + + continue; + } + } + debug("%s: %d partitions found in %s\n", __func__, count, + blk_dev->name); + + return 0; +} + +static ulong blk_part_read(struct udevice *dev, lbaint_t start, + lbaint_t blkcnt, void *buffer) +{ + struct udevice *parent; + struct disk_part *part; + const struct blk_ops *ops; + + parent = dev_get_parent(dev); + ops = blk_get_ops(parent); + if (!ops->read) + return -ENOSYS; + + part = dev_get_uclass_plat(dev); + if (start >= part->gpt_part_info.size) + return 0; + + if ((start + blkcnt) > part->gpt_part_info.size) + blkcnt = part->gpt_part_info.size - start; + start += part->gpt_part_info.start; + + return ops->read(parent, start, blkcnt, buffer); +} + +static ulong blk_part_write(struct udevice *dev, lbaint_t start, + lbaint_t blkcnt, const void *buffer) +{ + struct udevice *parent; + struct disk_part *part; + const struct blk_ops *ops; + + parent = dev_get_parent(dev); + ops = blk_get_ops(parent); + if (!ops->write) + return -ENOSYS; + + part = dev_get_uclass_plat(dev); + if (start >= part->gpt_part_info.size) + return 0; + + if ((start + blkcnt) > part->gpt_part_info.size) + blkcnt = part->gpt_part_info.size - start; + start += part->gpt_part_info.start; + + return ops->write(parent, start, blkcnt, buffer); +} + +static ulong blk_part_erase(struct udevice *dev, lbaint_t start, + lbaint_t blkcnt) +{ + struct udevice *parent; + struct disk_part *part; + const struct blk_ops *ops; + + parent = dev_get_parent(dev); + ops = blk_get_ops(parent); + if (!ops->erase) + return -ENOSYS; + + part = dev_get_uclass_plat(dev); + if (start >= part->gpt_part_info.size) + return 0; + + if ((start + blkcnt) > part->gpt_part_info.size) + blkcnt = part->gpt_part_info.size - start; + start += part->gpt_part_info.start; + + return ops->erase(parent, start, blkcnt); +} + +static const struct blk_ops blk_part_ops = { + .read = blk_part_read, + .write = blk_part_write, + .erase = blk_part_erase, +}; + +U_BOOT_DRIVER(blk_partition) = { + .name = "blk_partition", + .id = UCLASS_PARTITION, + .ops = &blk_part_ops, +}; + +UCLASS_DRIVER(partition) = { + .id = UCLASS_PARTITION, + .per_device_plat_auto = sizeof(struct disk_part), + .name = "partition", +}; diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h index 0e26e1d13824..230b1ea528cf 100644 --- a/include/dm/uclass-id.h +++ b/include/dm/uclass-id.h @@ -83,6 +83,7 @@ enum uclass_id { UCLASS_P2SB, /* (x86) Primary-to-Sideband Bus */ UCLASS_PANEL, /* Display panel, such as an LCD */ UCLASS_PANEL_BACKLIGHT, /* Backlight controller for panel */ + UCLASS_PARTITION, /* Logical disk partition device */ UCLASS_PCH, /* x86 platform controller hub */ UCLASS_PCI, /* PCI bus */ UCLASS_PCI_EP, /* PCI endpoint device */ diff --git a/include/part.h b/include/part.h index e5806edb3452..c4e0bef7749d 100644 --- a/include/part.h +++ b/include/part.h @@ -296,6 +296,16 @@ part_get_info_by_dev_and_name_or_num(const char *dev_iface, } #endif +struct udevice; +/** + * part_create_block_devices - Create block devices for disk partitions + * + * Create UCLASS_PARTITION udevices for each of disk partitions in @parent + * + * @blk_dev: Whole disk device + */ +int part_create_block_devices(struct udevice *blk_dev); + /* * We don't support printing partition information in SPL and only support * getting partition information in a few cases. From patchwork Tue Apr 19 01:05:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 563298 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp2860505map; Mon, 18 Apr 2022 18:06:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgNu4TWF1yaY2wJcw/QKExI9+XIjBkc9MDc7FL4FczT7d+ro3pJWjbcqyRL/kZ4TjNt+KG X-Received: by 2002:a17:907:6d83:b0:6ef:db74:8b9b with SMTP id sb3-20020a1709076d8300b006efdb748b9bmr891593ejc.561.1650330396191; Mon, 18 Apr 2022 18:06:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650330396; cv=none; d=google.com; s=arc-20160816; b=M7ERvDlae4c/mFoy5kmWTNhrpINIqTYbjiL+OetZm83S4WUV2o6725BR1wFj5HeZjL XHr3t1688fUgGLv0jBK73eI4DST3aupwf+ToayrrMvNOjndDKYhC38CCwuVDNV0a6bLf fgreSvIPAK5qVS9bFkUFELrfkrFtEMnroiaD+GG0Qyjf4OURvhtly7/ZevTsmg0N5Az9 jmsEYyfuZJ1mti6zzZ60lfPf3rz2elovmRcqLzWOCBEx3V7SdWzW8E3kDryx/94ZIC3Y X2KDHaRMRJ0aWMVqDlIhk0As+g+J76fmx4WxSnQdMb/PWLVQHiYoPxDQJKbjAPCI6lJ+ g8aA== 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=2+O99jPAsVE8MNTnpcalytHrEjhAeCo2wBfrWozxCMc=; b=0TjnB38RnTjoshv5NY+7NXAlUP621CDG3R6WfQJNibTRkM17dHmeFEL+KgYiSR4coC Gw8DTaeyffo3F0SOXZi8Eq5bBhGkie4TKizaN3LT+XmtyRs2s1x6GOAP5T3gbxcYTWia O0cyfY8O9jKSffOPsQ5bWQ+2tCRuxt5DFM+1zNEK54sj18dRD8lbL6JlBSJ8IU4UD1jG +gnqeOLANd/O8JTKFiAq4pOK0UxiYNLPcCXMsFvh+4RvmDFMCCOafbDtX6aGPFtyJ2Kb teb9StyDWJiOP2icCeGCd5ZK38LfmmLuuBIOJq1ZBkJV2jeP2EQmUR5M9fcuA8ox9UGF /Ppg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ih8bbXir; 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 a22-20020aa7cf16000000b0041d6b8a6d9bsi6919040edy.559.2022.04.18.18.06.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 18:06:36 -0700 (PDT) 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=ih8bbXir; 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 779B983D07; Tue, 19 Apr 2022 03:06:13 +0200 (CEST) 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="ih8bbXir"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BF7AF83BE5; Tue, 19 Apr 2022 03:05:56 +0200 (CEST) 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=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) (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 1C69083BE5 for ; Tue, 19 Apr 2022 03:05:52 +0200 (CEST) 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-pg1-x534.google.com with SMTP id k14so22013164pga.0 for ; Mon, 18 Apr 2022 18:05:52 -0700 (PDT) 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=2+O99jPAsVE8MNTnpcalytHrEjhAeCo2wBfrWozxCMc=; b=ih8bbXirohMeDXqqn12ALzJiJEg9K/juWb5ZeExm7XuwxkDxC5lJyl5A0YLsJLmhyA SwNyU6asfndJLih+oIy10XQljczwIx8sHoOxJvlguFlnX9+lkxBiCfTlEQxM1qKPjd02 1xfkeFjz7KCMqe3kkb8XAObay1l2wubogwBXMsTwPQ73lsB44OTaTxj/QTNQKg/OV4Rn nTBo3WPhkN5WmVGKGYdkN54Ld+lxXc4y6eXrhm2NlFSTQWOej5ZYk/FlLhe9Pvf+43Rm 9oS+/M6M1yPdbtL3iUO0jdpm4Go9q4rgyvNbh5xkoFx61k75jbmpKVz1ukxsKBF5vwqO bzmA== 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=2+O99jPAsVE8MNTnpcalytHrEjhAeCo2wBfrWozxCMc=; b=HUrrWu7Iphi/K/VmBEhEfWITqAAOIbE71mVo1edmCgQAkDuOr+l/NfOxelCVdDwFk1 L2nDozIjFFHKdioYIp48fhzXaJBD/svMz1MXexBtInTSfWtvScNXPYmPA1YN4S+vO8Y4 W94ask2P9r7sAZ5Q9OMYGwO5ZtdFctwrHCJEpBt4VEB5YHHqy50bkAayW+f7sCOshfLG gw1LReSt5xM0Tk0D+8+vvWPykMrz0vjTmpxQ9ZtJLmmXCCEdX4iKvdNXgZaxWOdmtCbL xBRr0GyNgV81LscfH64XLuuecPPU4y87VYMTWq/RKdh+snUVXlgLG/thH/GV/VrIyHpQ M7TQ== X-Gm-Message-State: AOAM533btNPOVDUBr8nsqzONWRCSVRApZ3MBNPgbJgPKEVUL/R4ei/Ww rudP0hFboqmy/aD1KLnl47UyJIJgBJy7fw== X-Received: by 2002:a63:5007:0:b0:3aa:1670:e327 with SMTP id e7-20020a635007000000b003aa1670e327mr3947331pgb.124.1650330350537; Mon, 18 Apr 2022 18:05:50 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c3e1:100:5858:d3a6:5cad:ceeb]) by smtp.gmail.com with ESMTPSA id k137-20020a633d8f000000b0039800918b00sm14043756pga.77.2022.04.18.18.05.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 18:05:50 -0700 (PDT) From: AKASHI Takahiro To: 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 v5 05/12] dm: blk: add a device-probe hook for scanning disk partitions Date: Tue, 19 Apr 2022 10:05:10 +0900 Message-Id: <20220419010517.47175-6-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220419010517.47175-1-takahiro.akashi@linaro.org> References: <20220419010517.47175-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 Now that all the block device drivers have enable a probe hook, we will call part_create_block_devices() to enumerate all the partitions and create associated udevices when a block device is detected. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- drivers/block/blk-uclass.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c index f1e4a8564679..791e26c06ebe 100644 --- a/drivers/block/blk-uclass.c +++ b/drivers/block/blk-uclass.c @@ -741,6 +741,10 @@ static int blk_post_probe(struct udevice *dev) struct blk_desc *desc = dev_get_uclass_plat(dev); part_init(desc); + + if (desc->part_type != PART_TYPE_UNKNOWN && + part_create_block_devices(dev)) + debug("*** creating partitions failed\n"); } return 0; From patchwork Tue Apr 19 01:05:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 563299 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp2860600map; Mon, 18 Apr 2022 18:06:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8TRXLVw/TR+iSPchwyPdSa9UAgLu6WPnc5Rbk/l/dwpD2P3OtcATb04SasnvsCt7mD/b4 X-Received: by 2002:a05:6402:1d4b:b0:416:13bf:4fc5 with SMTP id dz11-20020a0564021d4b00b0041613bf4fc5mr10752434edb.115.1650330407472; Mon, 18 Apr 2022 18:06:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650330407; cv=none; d=google.com; s=arc-20160816; b=wWhPogLLZejchsNiwGBSQNDkKPDjNegpjG8hQJBJYZlLofnRXiTONCWtJyNRdbkvWy TIJ2ILQKKsTSFZTbw/xXbJcRwocO4xhKfMhYByNCi3cri7GcFjCU6XycguaciFATauQ+ CNIKsP4XsuFvEyvJls+oWqhMxO51LVwkXsjEAnMnqBtUKMZmUOkr0Nikrkoxt27GeuS4 pbPCBp/vm1K3vOETaZZ2fIvA8Fz+FbT6vAOqKN7+HL9+R3Xh//JLkyvAFdQVOyFaT8Md GsD8kzPN43Ggc+noqYUcLmOjNZcxgk9UAoL80W6PqCSVRLPUfgwzwIa1PqCR+0bbi6s8 CwVw== 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=UQgQUXH6/e3P5T+GBMNREsegS1VF3JwCWSwgCegxL1I=; b=VNxGcwtjTnCrgTXqsf6Wv46qbZnYp0PsVmwmTKIqV1suQkBSwy6eT6O8wO+CuqoTSE j984yRB+HDIB9VLqAP6qQsrwKp/shbj9YdGsTjz4XNXgQgLCw4R2kvtDJJKXJKsiM9K2 WFGi6LlmWqAILA40mhIUpGF5pl4IGKEXBRjcBN4pn0aYRTpgbt9He+76F7ITAr8bOLsJ wDibecVDOG6t4VeFnRvt1ZXAyHQy9RJNihe25RJlz3Now32dLsoU1wEwxVdnlW7QqMqp 3nYGRiAaprXNocOXf4LgsM7Ywwv/mYlNHsWnIqu+tYiYUNvudkBabkQAuNuJ/Ef0476Y B6sA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ovv5H9BB; 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 ci17-20020a170906c35100b006e7f31adf04si7229309ejb.442.2022.04.18.18.06.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 18:06:47 -0700 (PDT) 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=Ovv5H9BB; 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 D9DDC83D92; Tue, 19 Apr 2022 03:06:16 +0200 (CEST) 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="Ovv5H9BB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D103583D07; Tue, 19 Apr 2022 03:05:58 +0200 (CEST) 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=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) (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 610D783B4E for ; Tue, 19 Apr 2022 03:05:54 +0200 (CEST) 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-pg1-x530.google.com with SMTP id q12so21956433pgj.13 for ; Mon, 18 Apr 2022 18:05:54 -0700 (PDT) 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=UQgQUXH6/e3P5T+GBMNREsegS1VF3JwCWSwgCegxL1I=; b=Ovv5H9BBmdwMPMMt5Gqn6iyTqp/2LIA3TBeivaPVUWGSbmC5Q5JjuFy1T/bL3lbo8d 79rVXp0puO4gzmEUTRWmK7ZSekvuCyNP7rDO/y1wRX3hu0JuDaz3YQnjt1nRGPtr20DN bZsvWaDmtJ4nHKQBKIJ7b40dcUpqKCcH7gmuThcNeZdbwb6Ichg0eN0W1mc78qNHDsI2 qhYjS05cJHERXxICBZmYqsfKU41diDlPE2kxemkhGN3e192olr6sCXP2oycqkVKgjDeZ HdxZEd5CPkzIM0Yu1vSOhqU6cURd3DzJfddFszZ5MgTmR0V0Wr+p6JdkvvBn2BLYg9bI NwSQ== 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=UQgQUXH6/e3P5T+GBMNREsegS1VF3JwCWSwgCegxL1I=; b=1h0YdEasGPjuHcezmkiUjR1VGxs6NpTNXVp/S+kxDGIemSxoavbkObY8VL09nB5Edy rgVUbTslS3STm0vHfLfvbvQVMg4It5XXK3V0g/W/BoyrTi8UMLfr85DWWDt8jIA7fR4D GEhOqyDkutwHADh//4Wp9vcvYVZTGGR1Udd2/dKTgCUFWn05VW9NqLPIXmeSeM2Bbv77 T5noiBut0WpQN58LpGgYT2L1HTFr26pfyY/rIwXM5HVgSoL7RGqi48STHiqcYup7k5p5 DURopktagn48cL1cH+ytThIe07VNnKVRgew6NZtTMstQ3UXRQuc4iQfwsC0zooqWeVWA VfEg== X-Gm-Message-State: AOAM532G4aWAamanKh3nzsWAGB7lF8Ghu6Ui+yqbSMu6OY3S8AJMaQqc vjy7NZOzFozx707pWfLSZi1odQ== X-Received: by 2002:a63:4862:0:b0:385:fb1d:fc54 with SMTP id x34-20020a634862000000b00385fb1dfc54mr12467966pgk.57.1650330352795; Mon, 18 Apr 2022 18:05:52 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c3e1:100:5858:d3a6:5cad:ceeb]) by smtp.gmail.com with ESMTPSA id k137-20020a633d8f000000b0039800918b00sm14043756pga.77.2022.04.18.18.05.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 18:05:52 -0700 (PDT) From: AKASHI Takahiro To: 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 v5 06/12] efi_loader: split efi_init_obj_list() into two stages Date: Tue, 19 Apr 2022 10:05:11 +0900 Message-Id: <20220419010517.47175-7-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220419010517.47175-1-takahiro.akashi@linaro.org> References: <20220419010517.47175-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 the next commit, CONFIG_EFI_SETUP_EARLY will become mandated in order to support dynamic enumeration of efi_disk objects. This can, however, be problematic particularly in case of file-based variable storage (efi_variable.c, default). Non-volatile variables are to be restored from EFI system partition by efi_init_variables() in efi_init_obj_list(). When efi_init_obj_list() is called in board_init_r(), we don't know yet what disk devices we have since none of device probing commands (say, scsi rescan) has not been executed at that stage. So in this commit, a preparatory change is made; efi_init_obj_list() is broken into the two functions; * efi_init_early(), and * new efi_init_obj_list() Only efi_init_early() will be called in board_init_r(), which allows us to execute any of device probing commands, either though "preboot" variable or normal command line, before calling efi_init_obj_list() which is to be invoked at the first execution of an efi-related command (or at efi_launch_capsules()) as used to be. Signed-off-by: AKASHI Takahiro --- common/board_r.c | 2 +- common/main.c | 7 +++-- include/efi_loader.h | 2 ++ lib/efi_loader/efi_setup.c | 58 ++++++++++++++++++++++++++++++++------ 4 files changed, 57 insertions(+), 12 deletions(-) diff --git a/common/board_r.c b/common/board_r.c index 8dc87ed2be4c..7d0281f5447e 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -795,7 +795,7 @@ static init_fnc_t init_sequence_r[] = { initr_mem, #endif #ifdef CONFIG_EFI_SETUP_EARLY - (init_fnc_t)efi_init_obj_list, + efi_init_early, #endif run_main_loop, }; diff --git a/common/main.c b/common/main.c index 3f5214fd44b8..682f3359ea38 100644 --- a/common/main.c +++ b/common/main.c @@ -54,8 +54,11 @@ void main_loop(void) if (IS_ENABLED(CONFIG_UPDATE_TFTP)) update_tftp(0UL, NULL, NULL); - if (IS_ENABLED(CONFIG_EFI_CAPSULE_ON_DISK_EARLY)) - efi_launch_capsules(); + if (IS_ENABLED(CONFIG_EFI_CAPSULE_ON_DISK_EARLY)) { + /* efi_init_early() already called */ + if (efi_init_obj_list() == EFI_SUCCESS) + efi_launch_capsules(); + } s = bootdelay_process(); if (cli_process_fdt(&s)) diff --git a/include/efi_loader.h b/include/efi_loader.h index c52ea59ec7ae..5bb8fb2acd04 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -493,6 +493,8 @@ struct efi_register_notify_event { /* List of all events registered by RegisterProtocolNotify() */ extern struct list_head efi_register_notify_events; +/* called at pre-initialization */ +int efi_init_early(void); /* Initialize efi execution environment */ efi_status_t efi_init_obj_list(void); /* Install device tree */ diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c index eee54e48784f..de2f34bab537 100644 --- a/lib/efi_loader/efi_setup.c +++ b/lib/efi_loader/efi_setup.c @@ -174,20 +174,18 @@ static efi_status_t efi_init_os_indications(void) &os_indications_supported, false); } - /** - * efi_init_obj_list() - Initialize and populate EFI object list + * __efi_init_early() - handle initialization at early stage + * + * This function is called in efi_init_obj_list() only if + * !CONFIG_EFI_SETUP_EARLY. * * Return: status code */ -efi_status_t efi_init_obj_list(void) +static efi_status_t __efi_init_early(void) { efi_status_t ret = EFI_SUCCESS; - /* Initialize once only */ - if (efi_obj_list_initialized != OBJ_LIST_NOT_INITIALIZED) - return efi_obj_list_initialized; - /* Allow unaligned memory access */ allow_unaligned(); @@ -202,9 +200,51 @@ efi_status_t efi_init_obj_list(void) #ifdef CONFIG_PARTITIONS ret = efi_disk_register(); - if (ret != EFI_SUCCESS) - goto out; #endif +out: + return ret; +} + +/** + * efi_init_early() - handle initialization at early stage + * + * external version of __efi_init_early(); expected to be called in + * board_init_r(). + * + * Return: status code + */ +int efi_init_early(void) +{ + efi_status_t ret; + + ret = __efi_init_early(); + if (ret != EFI_SUCCESS) { + /* never re-init UEFI subsystem */ + efi_obj_list_initialized = ret; + return -1; + } + return 0; +} + +/** + * efi_init_obj_list() - Initialize and populate EFI object list + * + * Return: status code + */ +efi_status_t efi_init_obj_list(void) +{ + efi_status_t ret = EFI_SUCCESS; + + /* Initialize once only */ + if (efi_obj_list_initialized != OBJ_LIST_NOT_INITIALIZED) + return efi_obj_list_initialized; + + if (!IS_ENABLED(CONFIG_EFI_SETUP_EARLY)) { + ret = __efi_init_early(); + if (ret != EFI_SUCCESS) + goto out; + } + if (IS_ENABLED(CONFIG_EFI_RNG_PROTOCOL)) { ret = efi_rng_register(); if (ret != EFI_SUCCESS) From patchwork Tue Apr 19 01:05:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 563302 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp2860913map; Mon, 18 Apr 2022 18:07:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyedC3oX4NItfHGzmN4nTxaz69oqP8efbBQLyO1wYX35Hwz1B7Z9SwNaLJUhMBHHIyZB/W3 X-Received: by 2002:a50:ee89:0:b0:41d:70eb:eb36 with SMTP id f9-20020a50ee89000000b0041d70ebeb36mr9045469edr.24.1650330441592; Mon, 18 Apr 2022 18:07:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650330441; cv=none; d=google.com; s=arc-20160816; b=x6zeUTCZ/qr5Hn9VCjhBImcbIm+tBLzUTaPkzuzzAUF5es35bF+jqW+o1gW0yMt38B EHW95x9qKlddMlIojhHV/3qcRbzU5UfQCLVj/tfauq1lwpX387wdiV+V0S/Lj6SdCr1M 6CxpZQWrAQyuVWTJStwHwmmStWK8j7d3irPheXoCMI6c1sRs8PStLj9H16lkydlKilVK HzsrcVN5d/q0E5p+RoLG5K0hYZ6e2cqqVNfe46TkWEMWgK16utDwdDkSreB+DAqWLLK1 FYvVQv2QPqLmXfvcC6G5c1drjIVMIF5vLu8utVZ6jTHF5yqqoLIPqC9Vslq1cp505eHR ULDw== 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=2efJQefKSbtDOhaTgGEEp5k6x3B/OY/cH9I91c8yY/8=; b=lq5lVH4EvWK1PORuaLe2LAnwy+NHgfnsGrHwFVgbygKZrfNnRqw+enonvUDTTAuDqi SHObEFNJKCKHulr99lCVCBYZx16LMAz+iJXUYCcWigBDGiiy4Np4OOwhCzhvVK3UDGC4 OwjrKDGtCM9tpFU2/NMCG8ZlhRml7zGYxDDPv+kTcYU0c9LiwiOElvanLlCGLEpw12dR S35JyopokYesZvSmGIWXiVp8wRZmWTu/0xahBsQNj+qL2wHXwYvhP1NoHa262GWWXylG tXyLPkkdMAyLGmW5UF7F9F3U+cNjMOPZfODQ+JBU/x7nQBZpEs4c83dVAqeJg2J7/8+I 7cJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oZj6W2os; 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 x28-20020a50f19c000000b00418c2b5bdc7si7698353edl.169.2022.04.18.18.07.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 18:07:21 -0700 (PDT) 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=oZj6W2os; 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 3ACDF83DC8; Tue, 19 Apr 2022 03:06:52 +0200 (CEST) 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="oZj6W2os"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 674D683D07; Tue, 19 Apr 2022 03:06:07 +0200 (CEST) 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=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) (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 AF75283CF7 for ; Tue, 19 Apr 2022 03:05:56 +0200 (CEST) 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-x1035.google.com with SMTP id mm4-20020a17090b358400b001cb93d8b137so819014pjb.2 for ; Mon, 18 Apr 2022 18:05:56 -0700 (PDT) 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=2efJQefKSbtDOhaTgGEEp5k6x3B/OY/cH9I91c8yY/8=; b=oZj6W2osd0j21PEBLKR9wh4MWt2aKPqT+J2rrr1ZYbXSJNL5DhoBD6FQ9EkXw7fEnP GG/C9fsnV1imexM00zWRUaZ1l2y/eAHYo27TtoNQOQeuF3p+EwEGhKA1Ti/Omtks4+uM mWl1pc/RLRnwedGvy28fJctgqVfCrIXwL05Gf6LQuSNa5Q+bWXhiT5QNNuRG1Lc6AfGM LY7d352aPbyz73MrytxZtwt0891nzhQe+c1tfBdld4tOmiCc9+wGNk892GQB1M8xI0Q1 ax+ItOkM4+V26ixs358xSj1TrByW1EjrZj5vVq1pfbS9AQi4Qhc46a/PdFvnEyX5eSC0 vFeA== 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=2efJQefKSbtDOhaTgGEEp5k6x3B/OY/cH9I91c8yY/8=; b=iWQ2OjLO6trsGj81uV3JPvIkIa2sPh13t6gjJpV+wVvshZxlC8VMJ2+IYJBridNUq3 WtbLZK0L5iUYHIm4a/OD7874kzs32vivfQiehlidDGcUxypW1OtMHiie6sldFD4KrKYA TV+veQvzikXnItnuRzHBmBnVxD+0TDbVPly+b/wewzzSoOfpnAPM4bXPvTuDZSwQMgLp cAGdjGXjiSrWyfC5hCgU/YpR9ER+7eE6kyVw1A9NAeuUQAIsBhAu+KvTwTiFiM9Ih6dJ vawLUUI0q0LpAaCobHC6xa/ITUkiGel4HdFf5yly4Lm+DHEyH919IEXHM5jqY9Sm6oGv uYpw== X-Gm-Message-State: AOAM531ktewbv14fxtpJcqxHB/Foo1Bh29t2EzCEVBYhgLUy7Uhfyw88 CAzZ6AOCdodV/5XH7LjGzNT2gg== X-Received: by 2002:a17:902:d4cb:b0:15a:872:a71 with SMTP id o11-20020a170902d4cb00b0015a08720a71mr2042599plg.151.1650330355022; Mon, 18 Apr 2022 18:05:55 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c3e1:100:5858:d3a6:5cad:ceeb]) by smtp.gmail.com with ESMTPSA id k137-20020a633d8f000000b0039800918b00sm14043756pga.77.2022.04.18.18.05.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 18:05:54 -0700 (PDT) From: AKASHI Takahiro To: 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 v5 07/12] efi_loader: disk: a helper function to create efi_disk objects from udevice Date: Tue, 19 Apr 2022 10:05:12 +0900 Message-Id: <20220419010517.47175-8-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220419010517.47175-1-takahiro.akashi@linaro.org> References: <20220419010517.47175-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 Add efi_disk_probe() function. This function creates an efi_disk object for a raw disk device (UCLASS_BLK) and additional objects for related partitions (UCLASS_PARTITION). So this function is expected to be called through driver model's "probe" interface every time one raw disk device is detected and activated. We assume that partition devices (UCLASS_PARTITION) have been created when this function is invoked. Signed-off-by: AKASHI Takahiro --- include/efi_loader.h | 4 +- lib/efi_driver/efi_block_device.c | 34 ++--- lib/efi_loader/Kconfig | 3 + lib/efi_loader/efi_disk.c | 201 +++++++++++++++++++----------- lib/efi_loader/efi_setup.c | 4 +- 5 files changed, 143 insertions(+), 103 deletions(-) diff --git a/include/efi_loader.h b/include/efi_loader.h index 5bb8fb2acd04..ba79a9afb404 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -525,8 +525,8 @@ void efi_carve_out_dt_rsv(void *fdt); void efi_try_purge_kaslr_seed(void *fdt); /* Called by bootefi to make console interface available */ efi_status_t efi_console_register(void); -/* Called by bootefi to make all disk storage accessible as EFI objects */ -efi_status_t efi_disk_register(void); +/* Called by efi_init_obj_list() to initialize efi_disks */ +efi_status_t efi_disk_init(void); /* Called by efi_init_obj_list() to install EFI_RNG_PROTOCOL */ efi_status_t efi_rng_register(void); /* Called by efi_init_obj_list() to install EFI_TCG2_PROTOCOL */ diff --git a/lib/efi_driver/efi_block_device.c b/lib/efi_driver/efi_block_device.c index 04cb3ef0d4e5..5baa6f87a375 100644 --- a/lib/efi_driver/efi_block_device.c +++ b/lib/efi_driver/efi_block_device.c @@ -35,6 +35,7 @@ #include #include #include +#include /* * EFI attributes of the udevice handled by this driver. @@ -106,25 +107,6 @@ static ulong efi_bl_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, return blkcnt; } -/** - * Create partions for the block device. - * - * @handle: EFI handle of the block device - * @dev: udevice of the block device - * Return: number of partitions created - */ -static int efi_bl_bind_partitions(efi_handle_t handle, struct udevice *dev) -{ - struct blk_desc *desc; - const char *if_typename; - - desc = dev_get_uclass_plat(dev); - if_typename = blk_get_if_type_name(desc->if_type); - - return efi_disk_create_partitions(handle, desc, if_typename, - desc->devnum, dev->name); -} - /** * Create a block device for a handle * @@ -139,7 +121,6 @@ static int efi_bl_bind(efi_handle_t handle, void *interface) char *name; struct efi_object *obj = efi_search_obj(handle); struct efi_block_io *io = interface; - int disks; struct efi_blk_plat *plat; EFI_PRINT("%s: handle %p, interface %p\n", __func__, handle, io); @@ -173,15 +154,20 @@ static int efi_bl_bind(efi_handle_t handle, void *interface) plat->handle = handle; plat->io = interface; + /* + * FIXME: necessary because we won't do almost nothing in + * efi_disk_create() when called from device_probe(). + */ + ret = dev_tag_set_ptr(bdev, DM_TAG_EFI, handle); + if (ret) + /* FIXME: cleanup for bdev */ + return ret; + ret = device_probe(bdev); if (ret) return ret; EFI_PRINT("%s: block device '%s' created\n", __func__, bdev->name); - /* Create handles for the partions of the block device */ - disks = efi_bl_bind_partitions(handle, bdev); - EFI_PRINT("Found %d partitions\n", disks); - return 0; } diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index bc518d7a413b..6b245f50a726 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -14,6 +14,8 @@ config EFI_LOADER depends on DM_ETH || !NET depends on !EFI_APP default y if !ARM || SYS_CPU = armv7 || SYS_CPU = armv8 + select DM_EVENT + select EVENT_DYNAMIC select LIB_UUID imply PARTITION_UUIDS select HAVE_BLOCK_DEVICE @@ -40,6 +42,7 @@ config CMD_BOOTEFI_BOOTMGR config EFI_SETUP_EARLY bool + default y choice prompt "Store for non-volatile UEFI variables" diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index c905c12abc2f..d4a0edb458b8 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -10,6 +10,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -487,103 +490,153 @@ error: return ret; } -/** - * efi_disk_create_partitions() - create handles and protocols for partitions +/* + * Create a handle for a whole raw disk + * + * @dev uclass device (UCLASS_BLK) * - * Create handles and protocols for the partitions of a block device. + * Create an efi_disk object which is associated with @dev. + * The type of @dev must be UCLASS_BLK. * - * @parent: handle of the parent disk - * @desc: block device - * @if_typename: interface type - * @diskid: device number - * @pdevname: device name - * Return: number of partitions created + * @return 0 on success, -1 otherwise */ -int efi_disk_create_partitions(efi_handle_t parent, struct blk_desc *desc, - const char *if_typename, int diskid, - const char *pdevname) +static int efi_disk_create_raw(struct udevice *dev) { - int disks = 0; - char devname[32] = { 0 }; /* dp->str is u16[32] long */ - int part; - struct efi_device_path *dp = NULL; + struct efi_disk_obj *disk; + struct blk_desc *desc; + const char *if_typename; + int diskid; efi_status_t ret; - struct efi_handler *handler; - /* Get the device path of the parent */ - ret = efi_search_protocol(parent, &efi_guid_device_path, &handler); - if (ret == EFI_SUCCESS) - dp = handler->protocol_interface; - - /* Add devices for each partition */ - for (part = 1; part <= MAX_SEARCH_PARTITIONS; part++) { - struct disk_partition info; - - if (part_get_info(desc, part, &info)) - continue; - snprintf(devname, sizeof(devname), "%s:%x", pdevname, - part); - ret = efi_disk_add_dev(parent, dp, if_typename, desc, diskid, - &info, part, NULL); - if (ret != EFI_SUCCESS) { - log_err("Adding partition %s failed\n", pdevname); - continue; - } - disks++; + desc = dev_get_uclass_plat(dev); + if_typename = blk_get_if_type_name(desc->if_type); + diskid = desc->devnum; + + ret = efi_disk_add_dev(NULL, NULL, if_typename, desc, + diskid, NULL, 0, &disk); + if (ret != EFI_SUCCESS) { + if (ret == EFI_NOT_READY) + log_notice("Disk %s not ready\n", dev->name); + else + log_err("Adding disk for %s failed\n", dev->name); + + return -1; + } + if (dev_tag_set_ptr(dev, DM_TAG_EFI, &disk->header)) { + efi_free_pool(disk->dp); + efi_delete_handle(&disk->header); + + return -1; } - return disks; + return 0; } -/** - * efi_disk_register() - register block devices - * - * U-Boot doesn't have a list of all online disk devices. So when running our - * EFI payload, we scan through all of the potentially available ones and - * store them in our object pool. +/* + * Create a handle for a disk partition * - * This function is called in efi_init_obj_list(). + * @dev uclass device (UCLASS_PARTITION) * - * TODO(sjg@chromium.org): Actually with CONFIG_BLK, U-Boot does have this. - * Consider converting the code to look up devices as needed. The EFI device - * could be a child of the UCLASS_BLK block device, perhaps. + * Create an efi_disk object which is associated with @dev. + * The type of @dev must be UCLASS_PARTITION. * - * Return: status code + * @return 0 on success, -1 otherwise */ -efi_status_t efi_disk_register(void) +static int efi_disk_create_part(struct udevice *dev) { + efi_handle_t parent; + struct blk_desc *desc; + const char *if_typename; + struct disk_part *part_data; + struct disk_partition *info; + unsigned int part; + int diskid; + struct efi_handler *handler; + struct efi_device_path *dp_parent; struct efi_disk_obj *disk; - int disks = 0; efi_status_t ret; + + if (dev_tag_get_ptr(dev_get_parent(dev), DM_TAG_EFI, (void **)&parent)) + return -1; + + desc = dev_get_uclass_plat(dev_get_parent(dev)); + if_typename = blk_get_if_type_name(desc->if_type); + diskid = desc->devnum; + + part_data = dev_get_uclass_plat(dev); + part = part_data->partnum; + info = &part_data->gpt_part_info; + + ret = efi_search_protocol(parent, &efi_guid_device_path, &handler); + if (ret != EFI_SUCCESS) + return -1; + dp_parent = (struct efi_device_path *)handler->protocol_interface; + + ret = efi_disk_add_dev(parent, dp_parent, if_typename, desc, diskid, + info, part, &disk); + if (ret != EFI_SUCCESS) { + log_err("Adding partition for %s failed\n", dev->name); + return -1; + } + if (dev_tag_set_ptr(dev, DM_TAG_EFI, &disk->header)) { + efi_free_pool(disk->dp); + efi_delete_handle(&disk->header); + + return -1; + } + + return 0; +} + +/* + * Create efi_disk objects for a block device + * + * @dev uclass device (UCLASS_BLK) + * + * Create efi_disk objects for partitions as well as a raw disk + * which is associated with @dev. + * The type of @dev must be UCLASS_BLK. + * This function is expected to be called at EV_PM_POST_PROBE. + * + * @return 0 on success, -1 otherwise + */ +static int efi_disk_probe(void *ctx, struct event *event) +{ struct udevice *dev; + enum uclass_id id; + struct udevice *child; + int ret; - for (uclass_first_device_check(UCLASS_BLK, &dev); dev; - uclass_next_device_check(&dev)) { - struct blk_desc *desc = dev_get_uclass_plat(dev); - const char *if_typename = blk_get_if_type_name(desc->if_type); + dev = event->data.dm.dev; + id = device_get_uclass_id(dev); - /* Add block device for the full device */ - log_info("Scanning disk %s...\n", dev->name); - ret = efi_disk_add_dev(NULL, NULL, if_typename, - desc, desc->devnum, NULL, 0, &disk); - if (ret == EFI_NOT_READY) { - log_notice("Disk %s not ready\n", dev->name); - continue; - } - if (ret) { - log_err("ERROR: failure to add disk device %s, r = %lu\n", - dev->name, ret & ~EFI_ERROR_MASK); - continue; - } - disks++; + /* TODO: We won't support partitions in a partition */ + if (id != UCLASS_BLK) + return 0; + + ret = efi_disk_create_raw(dev); + if (ret) + return -1; - /* Partitions show up as block devices in EFI */ - disks += efi_disk_create_partitions( - &disk->header, desc, if_typename, - desc->devnum, dev->name); + device_foreach_child(child, dev) { + ret = efi_disk_create_part(child); + if (ret) + return -1; } - log_info("Found %d disks\n", disks); + return 0; +} + +efi_status_t efi_disk_init(void) +{ + int ret; + + ret = event_register("efi_disk add", EVT_DM_POST_PROBE, + efi_disk_probe, NULL); + if (ret) { + log_err("Event registration for efi_disk add failed\n"); + return EFI_OUT_OF_RESOURCES; + } return EFI_SUCCESS; } diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c index de2f34bab537..250eeb2fcd6b 100644 --- a/lib/efi_loader/efi_setup.c +++ b/lib/efi_loader/efi_setup.c @@ -198,9 +198,7 @@ static efi_status_t __efi_init_early(void) if (ret != EFI_SUCCESS) goto out; -#ifdef CONFIG_PARTITIONS - ret = efi_disk_register(); -#endif + ret = efi_disk_init(); out: return ret; } From patchwork Tue Apr 19 01:05:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 563300 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp2860713map; Mon, 18 Apr 2022 18:06:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwUeV2D7XwNZLnFM1qXuDYTZC4fByg31pzZgP7auKDCdW7JmUBXGvJjIC9I9JbTWaKhOEAa X-Received: by 2002:a17:907:a0c8:b0:6e8:b135:c864 with SMTP id hw8-20020a170907a0c800b006e8b135c864mr11181649ejc.233.1650330418286; Mon, 18 Apr 2022 18:06:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650330418; cv=none; d=google.com; s=arc-20160816; b=u9WTe2nrXGPHpL9RK54D8YcMEyxwqizDlTQYpD/YyrF63VOIP20b2kf3ol1yEJrecz AojZ/vFEB1Vu/2JGek0bApPezB7aAM9Ftp8auzMoyZdPebkOUKGPdfWf/aBqZbt+dQWO JXyz2xVWO/Z3N6x/jcP8fEaeBw88tylfhE6QacFPrtrlCkzwLDgp/ywrHes/jJfuNuYU m6P0gz+QTm0wh/dlv1WnWbDlWEnOn0T4SBlPW5StFod0opzS7UMN1fcsCEvS1AsNAsYn q1jAQKRrdDLAeAWh9qrD/S1QIpupJgNj9zH41rMxmdTppvq7xPdU6QWLNT54kKBdyVZl zJ6w== 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=j/16UycWtqTLoNpUdQHYPcu4PfFK9e8OHWjqkEtJQ2g=; b=Nt/Gx/asliM1fmAmHe7XOSmmirkMPeFtf3dIXg04b5BLGmZ+9G4TdFmJOCPzCAm1xT hxNWQPjq1cCtSE1pPUeavhIjTU8+BSXC1/zZj4V2jW4W/dNjcb2kFjaiIJ/kXHO68tjx cG08XlqDttmGK90ZaNMFWdBKcCQPxvP9+U4cMkUUNAN7XivrFV3g80/HLr3uqtqRt7Vz 4WYvRhaXJhoqyvzSL+Q5dRAvf4RtP9wyrdOLGthAyulvOENaQxVCSLg84jbZWYMIcVZD vJ8gmZdkKdNPEaBUaCwVW9r5N/xo+8uEwAzdG9bPClDm7IEPBvuhswJkCU41ScbCHg4R etLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=znSPGsk3; 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 bl2-20020a170906c24200b006e86bbe41a9si7359080ejb.112.2022.04.18.18.06.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 18:06:58 -0700 (PDT) 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=znSPGsk3; 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 67EDB83B3D; Tue, 19 Apr 2022 03:06:40 +0200 (CEST) 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="znSPGsk3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 11A5183C7B; Tue, 19 Apr 2022 03:06:10 +0200 (CEST) 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=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) (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 EF3DA83B4E for ; Tue, 19 Apr 2022 03:05:58 +0200 (CEST) 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-x62e.google.com with SMTP id v12so13738143plv.4 for ; Mon, 18 Apr 2022 18:05:58 -0700 (PDT) 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=j/16UycWtqTLoNpUdQHYPcu4PfFK9e8OHWjqkEtJQ2g=; b=znSPGsk3hLRPEkvKTl9juCveLElJTDYj1gimMfREzD7fIsJJiGXJHvy6/jA2GcXQrR qW/JUCe3jEG+D7nLwOV8qXeKsaWqAaBbL1UO2nAFI1Q3KIKwy7WMb4vKpa6s0BGuoeko 8Wau1Q0buFFfuslZD/vPQDaO3c4mYvzI5RO9MWYa3omeQ6i+NCaeJNnTwWHhZikSUA3r QMQxKxiv8PBB9mCHDs3bwW/snOJT1AiPA3C4c3ynZFQP/mnuItJvPyvJw/OhABmkDrke mCjjIySkPgGYtfzHZipVyzC79P9+Zq4R9SaEb+5w9h8jlLNz4zwZe0E4FHNu+Ev9PGuz ZvMA== 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=j/16UycWtqTLoNpUdQHYPcu4PfFK9e8OHWjqkEtJQ2g=; b=Y3FR3bmILkh05PX5KklK3FcEauchIJFrbjENG9P68/PuW4k+jZMjyTNAmpsNVHXIRy nCuhtyXCmPjGmlG7ssH+mJc41MmjYF2iwPG9871LpCdbCnJI56wvYBiGPOFEXS5iVY8s N3n9epxYrGO0MOdYs7uuykssMk5R9yBnGvFTAQtRjbXZ8+RRybT8loi/5dgw54HrACKK yPMSy/dP3lzWBTNdGZhpvUd6bApH7K05is8iaJorSoJAfoW3Hlzo4XbS7Lmek6Nous1y jeleHj0pjQgkuq0X7zkBD+BquoSd48Camjuarcp6cxGSVE/v6vpSBQBIZtWolRHOGzAi QZ+Q== X-Gm-Message-State: AOAM533TJkl+HDq+AahT9D1sV19PMF5vCx5i6wiphNeEj+7V4p7TJNsu t6puArMldg9wgGeVttn1oUWw+VukqYAVQA== X-Received: by 2002:a17:902:e8c6:b0:158:f809:311f with SMTP id v6-20020a170902e8c600b00158f809311fmr8934625plg.4.1650330357340; Mon, 18 Apr 2022 18:05:57 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c3e1:100:5858:d3a6:5cad:ceeb]) by smtp.gmail.com with ESMTPSA id k137-20020a633d8f000000b0039800918b00sm14043756pga.77.2022.04.18.18.05.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 18:05:57 -0700 (PDT) From: AKASHI Takahiro To: 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 v5 08/12] efi_loader: disk: not create BLK device for BLK(IF_TYPE_EFI_LOADER) devices Date: Tue, 19 Apr 2022 10:05:13 +0900 Message-Id: <20220419010517.47175-9-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220419010517.47175-1-takahiro.akashi@linaro.org> References: <20220419010517.47175-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 When we create an efi_disk device with an UEFI application using driver binding protocol, the 'efi_driver' framework tries to create a corresponding block device(UCLASS_BLK/IF_TYPE_EFI). This will lead to calling a PROBE callback, efi_disk_probe(). In this case, however, we don't need to create another "efi_disk" device as we already have this device instance. So we should avoid recursively invoke further processing in the callback function. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- lib/efi_loader/efi_disk.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index d4a0edb458b8..037f8594a727 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -604,6 +604,7 @@ static int efi_disk_probe(void *ctx, struct event *event) { struct udevice *dev; enum uclass_id id; + struct blk_desc *desc; struct udevice *child; int ret; @@ -614,9 +615,16 @@ static int efi_disk_probe(void *ctx, struct event *event) if (id != UCLASS_BLK) return 0; - ret = efi_disk_create_raw(dev); - if (ret) - return -1; + /* + * avoid creating duplicated objects now that efi_driver + * has already created an efi_disk at this moment. + */ + desc = dev_get_uclass_plat(dev); + if (desc->if_type != IF_TYPE_EFI_LOADER) { + ret = efi_disk_create_raw(dev); + if (ret) + return -1; + } device_foreach_child(child, dev) { ret = efi_disk_create_part(child); From patchwork Tue Apr 19 01:05:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 563301 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp2860785map; Mon, 18 Apr 2022 18:07:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHq4sp0MvXNk0lCrzAAey+ciCPOa5SfZa414tlV4HWwRBOYw/9CoMO0HI4NYx2Gk44geqK X-Received: by 2002:a17:906:3ec6:b0:6e8:8534:6765 with SMTP id d6-20020a1709063ec600b006e885346765mr11226476ejj.110.1650330429398; Mon, 18 Apr 2022 18:07:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650330429; cv=none; d=google.com; s=arc-20160816; b=V85rbcztFlcouWoOM/4lIEffHcUlPc/VUxKC3omYxXilYOvnNReE7jIxGx4Ug6ztA9 wexircXxnfkSLG9GVYTX1fiKbpnA3eoyjxfvkf3fhUNTkl/MPFWaszyvahCL+oUCQ2cY ODBlSjkGG8Zsa1WDzx9PfIhBr0uRvllhGRhOVM0Hy9mtwYIgclqVctXKvg06aDcemyB5 3iQhqFkvXFikj3tgXxTXX00LiYjLTB84sUacp4ZElV8/Oy1NpNJ2LoueasJ+OXO37JNg 8gTJ5nMapwYDN1lZ8jPtD6KGdCMcsVvKZdyvOhXiH4SPvlGOFPmLOpzZZFEy3HfqJ9og Bc7A== 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=us55YGuTJDqDpqGBbF/SZgDLRcXZhwzXbRwbiam3AVQ=; b=R4/d+lKC2g30MsZHNXqvyLSXFngH6asqdeHzZF0J6H3L9ew9d35B5QedmS1cEENKju 5Ox4CbVBo/STHjzPCmPKe3SQSJeHc286ClRf3kRpB5g9yag1H3V4Q66CxzGrqmYNMuPX myEsuAV2+lICkEyq6a9wo+wr4SFE1WoQDXQ+eO1dUGkilogTFCnPBnPD4GnV6rbIJ8ht nMQgWohQZuRe/mLDrXfxXNiHB8h+gHrKt011MrsDTyI4YvIvhOfQ+gU0hnuY3xPoAYii sKlOOsO+kV3/uyrjGi7Kk123u4e0PYTfrFMM/mIa71XMpxFqk9rWoGvWO0Qp+va0Yvwb 1PXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fZtG1bbE; 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 d3-20020a170906c20300b006e88cd8b684si8044489ejz.727.2022.04.18.18.07.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 18:07:09 -0700 (PDT) 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=fZtG1bbE; 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 9E7B683B11; Tue, 19 Apr 2022 03:06:44 +0200 (CEST) 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="fZtG1bbE"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4CAD783D07; Tue, 19 Apr 2022 03:06:11 +0200 (CEST) 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=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) (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 5A46C83D61 for ; Tue, 19 Apr 2022 03:06:01 +0200 (CEST) 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-pg1-x52d.google.com with SMTP id q12so21956849pgj.13 for ; Mon, 18 Apr 2022 18:06:01 -0700 (PDT) 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=us55YGuTJDqDpqGBbF/SZgDLRcXZhwzXbRwbiam3AVQ=; b=fZtG1bbESJmXp63uxh/ba0/tGfW6IxEeZKtR3krYgGFOMfnUPQv+nCiVqgw4KaftW9 wFi4Ex21O81nboMlH3/18qbxVzVKC5tKNghmywQLIFaZUu9R07Qy30tlr5IiLov0H20k isu7DfQzhYa/s5bts7teg6ny6FXA/bPRrEfJSsY6x5k6teIXRMesYITVqeD6+uPbxcKs NPGuMM6EcPrFy7HH64UZp5mFdS+TqCtg3x9s42eyhMmPdUB9jBn0uzU5fjQOV0cDoJC6 buy6wL6DrESzUHu1Yf9LwH8MBEc900TFs7IfANyjZA+FUjOoaPSuRsIu1ptg7ZtBRPGV kimg== 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=us55YGuTJDqDpqGBbF/SZgDLRcXZhwzXbRwbiam3AVQ=; b=MQ/O9wcUCpeSCaAocSpaS6WFcxtMu5NUGsyIXc0BXvUvMw+acToS9hyxhTij0Ozvm6 4Pnd4kJV9unCUn9dykJPK9Ug58iU0PDn77VUNfGgLMspAGYI755JlTZH/XQySqnF2NRs PBH1ZnsGxiXA/L2OR82wGSDumqxi6lnJOapeGRL+0urTOVWI7satGpUfM1GFVuFkYsEP GOiLnT37vAbufPGg6N0ax5ar72GUGydEMEqEXBMW28RUbKO6Ig6tANJuhj3pKNvIY3YA J259GthJKS6wfe7NjgWSg/cU509nlKWvp0FoHvIU7GFpjWMGADnHceK87ZwN1BhzyFxI c78Q== X-Gm-Message-State: AOAM531HfcURW/fdrZFVRvcidoyAdvyh4o77XV2gKxKBcY+4MR3pk5Uq +E13pKQqpltiMdwdLBe/Gr4Ayg== X-Received: by 2002:a65:4503:0:b0:382:aad5:ad7d with SMTP id n3-20020a654503000000b00382aad5ad7dmr12438436pgq.488.1650330359686; Mon, 18 Apr 2022 18:05:59 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c3e1:100:5858:d3a6:5cad:ceeb]) by smtp.gmail.com with ESMTPSA id k137-20020a633d8f000000b0039800918b00sm14043756pga.77.2022.04.18.18.05.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 18:05:59 -0700 (PDT) From: AKASHI Takahiro To: 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 v5 09/12] efi_loader: disk: a helper function to delete efi_disk objects Date: Tue, 19 Apr 2022 10:05:14 +0900 Message-Id: <20220419010517.47175-10-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220419010517.47175-1-takahiro.akashi@linaro.org> References: <20220419010517.47175-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 This function is expected to be called, in particular from dm's pre_remove hook, when associated block devices no longer exist. Add efi_disk_remove() function. This function removes an efi_disk object for a raw disk device (UCLASS_BLK) and related objects for its partitions (UCLASS_PARTITION). So this function is expected to be called through driver model's "remove" interface every time a raw disk device is to be disconnected. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- lib/efi_loader/efi_disk.c | 88 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index 037f8594a727..940390ac8bcc 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -635,6 +635,87 @@ static int efi_disk_probe(void *ctx, struct event *event) return 0; } +/* + * Delete an efi_disk object for a whole raw disk + * + * @dev uclass device (UCLASS_BLK) + * + * Delete an efi_disk object which is associated with @dev. + * The type of @dev must be UCLASS_BLK. + * + * @return 0 on success, -1 otherwise + */ +static int efi_disk_delete_raw(struct udevice *dev) +{ + efi_handle_t handle; + struct efi_disk_obj *diskobj; + + if (dev_tag_get_ptr(dev, DM_TAG_EFI, (void **)&handle)) + return -1; + + diskobj = container_of(handle, struct efi_disk_obj, header); + efi_free_pool(diskobj->dp); + + efi_delete_handle(handle); + dev_tag_del(dev, DM_TAG_EFI); + + return 0; +} + +/* + * Delete an efi_disk object for a disk partition + * + * @dev uclass device (UCLASS_PARTITION) + * + * Delete an efi_disk object which is associated with @dev. + * The type of @dev must be UCLASS_PARTITION. + * + * @return 0 on success, -1 otherwise + */ +static int efi_disk_delete_part(struct udevice *dev) +{ + efi_handle_t handle; + struct efi_disk_obj *diskobj; + + if (dev_tag_get_ptr(dev, DM_TAG_EFI, (void **)&handle)) + return -1; + + diskobj = container_of(handle, struct efi_disk_obj, header); + + efi_free_pool(diskobj->dp); + efi_delete_handle(handle); + dev_tag_del(dev, DM_TAG_EFI); + + return 0; +} + +/* + * Delete an efi_disk object for a block device + * + * @dev uclass device (UCLASS_BLK or UCLASS_PARTITION) + * + * Delete an efi_disk object which is associated with @dev. + * The type of @dev must be either UCLASS_BLK or UCLASS_PARTITION. + * This function is expected to be called at EV_PM_PRE_REMOVE. + * + * @return 0 on success, -1 otherwise + */ +static int efi_disk_remove(void *ctx, struct event *event) +{ + enum uclass_id id; + struct udevice *dev; + + dev = event->data.dm.dev; + id = device_get_uclass_id(dev); + + if (id == UCLASS_BLK) + return efi_disk_delete_raw(dev); + else if (id == UCLASS_PARTITION) + return efi_disk_delete_part(dev); + else + return 0; +} + efi_status_t efi_disk_init(void) { int ret; @@ -646,5 +727,12 @@ efi_status_t efi_disk_init(void) return EFI_OUT_OF_RESOURCES; } + ret = event_register("efi_disk del", EVT_DM_PRE_REMOVE, + efi_disk_remove, NULL); + if (ret) { + log_err("Event registration for efi_disk del failed\n"); + return EFI_OUT_OF_RESOURCES; + } + return EFI_SUCCESS; } From patchwork Tue Apr 19 01:05:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 563303 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp2861002map; Mon, 18 Apr 2022 18:07:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMYGZqs25WkDJff6qOh/fWVaUet7D7PLR0pyQNxBZWGb4i8nNJWOxvTDGIK03u0YzHnJxo X-Received: by 2002:a17:907:7242:b0:6da:b561:d523 with SMTP id ds2-20020a170907724200b006dab561d523mr11116420ejc.118.1650330453439; Mon, 18 Apr 2022 18:07:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650330453; cv=none; d=google.com; s=arc-20160816; b=zbY2HMEkG2BXrrETP3FvsSe7p9STpCGJQFYzceDWJTo/2NgyDETJvwi5HsoxFtAqmQ rIzxIPH8DLdl+wTroUvOSLxgYaZWbwzNfwkN2e5Guo7LEelmokq9zQtRDqnVVPvU933E 0eS+3xPzsik1zBjNrS7ltFvXZRFTmj3pb8zf6UL167Gstsc8WnLX+42LaC1jaWmG7YiE WQM+mtMxz3iMkJOJdNYtGE2kMYUJQf1xNVy5Y/hS0OOUqZidijyC1rlip11EO0lT4uBT /nvRbw8IiTf8I+jE6Njia7AUY+iI9Gf9vR9asA//9ZpagK5dRWPbdOJxVtCqDaN3u/hl 4D0w== 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=iM8IiiuHSbTPbKVfkhnxnKS9CR4E6GlTaqdcIdJsPes=; b=fRNhWNm/9b1qw29ANl4hkjQbFM592pA4dT4Sg13m38vtpMwG9bG5o8u3+T0Oh+Rp1A 3Vd29kVH848F15Yn1UpfhBxLO8qUyk7KIcQtZeOD9qLIqlmKZkXGHfqwRhRKwhBSUent l8ImFCjwwZpVmOhstkQ2Jeyi/CjU++MEVBFXelnfjeuhf6DPowIL9I82ct6r3tAEa/yr yDzwvt/tN3yxEcxCx7Hh7vy19L8qC8kfgySmvw39UrPW4UfJ8CZ79L/bjve9LTa2n4k0 BglBGK711lfjmw9piFq1ChZLezKZZDZ19zwxkeb1MEDWdXZBCRbN2/HM/lEkBSRTTbEI zcMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="lj1/6pyR"; 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 w15-20020a05640234cf00b00423fb5cb330si920096edc.187.2022.04.18.18.07.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 18:07:33 -0700 (PDT) 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="lj1/6pyR"; 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 7FB4083DB6; Tue, 19 Apr 2022 03:06:56 +0200 (CEST) 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="lj1/6pyR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CA68983D62; Tue, 19 Apr 2022 03:06:11 +0200 (CEST) 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=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) (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 E0A7983C8C for ; Tue, 19 Apr 2022 03:06:03 +0200 (CEST) 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-x1030.google.com with SMTP id o5so14448998pjr.0 for ; Mon, 18 Apr 2022 18:06:03 -0700 (PDT) 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=iM8IiiuHSbTPbKVfkhnxnKS9CR4E6GlTaqdcIdJsPes=; b=lj1/6pyRPvdn6kD0zhnxanqG/DhGgBmGTEeZPT6WHc4tHobe8FeroR3cJuOGHRzGsx IdmhgYfUKm10RsRonuKuBN/0tWAWIp91WYieo6OwEl/+DqBaJKwfrxGT6lOq26CAeIiT lTFqnAzwd4i37rG0akFHln2wPJzx8tDKMT+4DWg3lpmIPIR/A/fiCd/LLJTwEONOy83N 02r96uTWMKbMPsT9SFv5cltaw/gMRj9j6+FyIWfIBQd2LtEpm9JSpkrznbiOV+T9l0iK xWRcgBpRPhDqDEILGIx+4yG/jnNvOxbqLCRamGPtm/pEtuPzoY8mW4HiTVHlES8vaDRs /pTg== 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=iM8IiiuHSbTPbKVfkhnxnKS9CR4E6GlTaqdcIdJsPes=; b=5N5JAdKwjXYSCeOq/GManUEOYEV7+Ey/+57IWsiHnI/4JtANl7Qou6vs9Q3jrQ6LAj U7sSOiLY6jk6hmhSK14JdaZOsxBK4/KvkxezYLZ6umrjcg2VTbpTdbaPFgCTDLN2Ed+z 1T4dGnbRgpo7PnTnLi/VicY56wiD0hQdFJmliwZ4hozlTb4yDcj8eFtYbwL+8F82Gq5P nbHQjv4znpd+LXQyKi8PvE7czpJTNqcsblXpZXFJ4F0ZEOwxDIxeds7PmlI7GlH4Sgce 6zh11Zl6Wra8ysep0ccxcuBhAYgdQyusGzxU2TKMo5x5cCdl/NgWXYps8gggMoo+zsg2 I8YQ== X-Gm-Message-State: AOAM5325tKERvJWY03wxSQKPCnsuEa81FJAfcojQztvdM0WhwadiflAO 7X+/C64eHAVXNah8KtGn1mNKDA== X-Received: by 2002:a17:902:7296:b0:151:62b1:e2b0 with SMTP id d22-20020a170902729600b0015162b1e2b0mr12915881pll.165.1650330361904; Mon, 18 Apr 2022 18:06:01 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c3e1:100:5858:d3a6:5cad:ceeb]) by smtp.gmail.com with ESMTPSA id k137-20020a633d8f000000b0039800918b00sm14043756pga.77.2022.04.18.18.05.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 18:06:01 -0700 (PDT) From: AKASHI Takahiro To: 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 v5 10/12] efi_loader: disk: not delete BLK device for BLK(IF_TYPE_EFI_LOADER) devices Date: Tue, 19 Apr 2022 10:05:15 +0900 Message-Id: <20220419010517.47175-11-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220419010517.47175-1-takahiro.akashi@linaro.org> References: <20220419010517.47175-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 When we create an efi_disk device with an UEFI application using driver binding protocol, the 'efi_driver' framework tries to create a corresponding block device(UCLASS_BLK/IF_TYPE_EFI). This will lead to calling a PROBE callback, efi_disk_probe(). In this case, however, we don't need to create another "efi_disk" device as we already have this device instance. So we should avoid recursively invoke further processing in the callback function. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- lib/efi_loader/efi_disk.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index 940390ac8bcc..34bb662e9cc0 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -648,13 +648,17 @@ static int efi_disk_probe(void *ctx, struct event *event) static int efi_disk_delete_raw(struct udevice *dev) { efi_handle_t handle; + struct blk_desc *desc; struct efi_disk_obj *diskobj; if (dev_tag_get_ptr(dev, DM_TAG_EFI, (void **)&handle)) return -1; - diskobj = container_of(handle, struct efi_disk_obj, header); - efi_free_pool(diskobj->dp); + desc = dev_get_uclass_plat(dev); + if (desc->if_type != IF_TYPE_EFI_LOADER) { + diskobj = container_of(handle, struct efi_disk_obj, header); + efi_free_pool(diskobj->dp); + } efi_delete_handle(handle); dev_tag_del(dev, DM_TAG_EFI); From patchwork Tue Apr 19 01:05:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 563304 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp2861124map; Mon, 18 Apr 2022 18:07:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqX8bGpXFabsSh/gQHDwlJC6rIenXNGFznXvPo6P2q20qBHS0IYbmlQYouxvSJVCljmMXE X-Received: by 2002:a17:906:c10b:b0:6e8:b306:f9d2 with SMTP id do11-20020a170906c10b00b006e8b306f9d2mr11111717ejc.498.1650330469684; Mon, 18 Apr 2022 18:07:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650330469; cv=none; d=google.com; s=arc-20160816; b=hqbGJ2flOLMuAFiw3KK5NN3tfKQmHjRbmzO5CKYAe5IKZlud5e5m0khwiQhUDFanWR 9UoFQNBxZrBk+9MnHu3emfFe3+lD62qTPJDpyDoP1td2+Y2OKCTk5v5eI7CU2xGAIzfm KR8HsIJB6IdsO9bHWCRIUsHC4xShhlzxN/ByFlPC5BOZohFtMHmtSzC05ViApw3UysMd GAxxKUYIBaa8iwuM6uwaAlKzVscS64BgiT1FzXaxgCUE7r0SMRdGSQtSRqKXzi65eoCn KrzGR/k/BFoSIkMxmnFa4mwh+LTxoxI11PCDgRSs5OqfpfGZlGV+KipvQIkHawnXI580 RvQw== 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=4wYb7tEoKo57lYnVDu9KLBr+sDHPj+ghJWaUwTkHj10=; b=b5zneY1dZkFEBDhX+KL4iPUGHZdgtA7oVc7kla04K6XAH/0v3UJY7WymjPfJB/6K5W n/T+7++BIqsdx6bnDzKEavgJCeIpqCNA19jj9jU0Sr6F1Mxhu+L0EFowOwX+mfpAdFs4 Y6R67h37t+/ubqqcDiK1e86YknJFwwnM0MguyFtNVPahpiyoi/mHx8Wmp9zuw4nShAsC Fjcrn6nGD5D9BtnwXDF47LiuiamnKpiL6xcDCJiHzTF3KEoc0tv9sDfUhczhtidaA//Q BEwAW6QaOgxyFZyDaHU4GJGbfipMrwivBwV8ZIFy8zOmBDD4l1/WAv7bl7w6rbP3u6Kp f+Ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Mmjy1TL3; 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 a8-20020aa7d748000000b0041f9bcdc712si7547314eds.472.2022.04.18.18.07.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 18:07:49 -0700 (PDT) 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=Mmjy1TL3; 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 F17EB83DEB; Tue, 19 Apr 2022 03:07:17 +0200 (CEST) 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="Mmjy1TL3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B201883D7A; Tue, 19 Apr 2022 03:06:12 +0200 (CEST) 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=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) (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 866E583D87 for ; Tue, 19 Apr 2022 03:06:06 +0200 (CEST) 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-pg1-x52a.google.com with SMTP id bg9so21961151pgb.9 for ; Mon, 18 Apr 2022 18:06:06 -0700 (PDT) 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=4wYb7tEoKo57lYnVDu9KLBr+sDHPj+ghJWaUwTkHj10=; b=Mmjy1TL3yqLVYyTSpA/jRmyqDUYuVOphz8XFYb8kEzbrciR8APwr/femo6Vc8RS2UO ElfDdq4Pae4X73eMQwsiwF0Xrl0e1/a9mY3WDw85qEXjnCXQg6gqyKho5fkKx6S/9Iz1 0Cl06QD4jHyA7eETVaBJBugutP3SWy6VB3eYb/ZKJdH7ZmF/gblQDcVN6CAenQCStB/B KtC/+AAD91WyhLWOgjoqA+wLjF598XbaBrb88sutR9ubpXRtpN6boiO3tLrhFv2Utol8 s8ni4+PReS/WFyyaAbu2FRA/Lx5HvhudZQCiUUcEjqr8xVo0JRHiwcl6v1Hp6IHnmUmg Uaiw== 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=4wYb7tEoKo57lYnVDu9KLBr+sDHPj+ghJWaUwTkHj10=; b=P7jGrmIWqhQ473IJK85y980P5d2Ad5HtOcOc4hyNVibfL28rDjVJstxlm22l1lWP0/ B/+vT4p9X4VCaRFo5DV0R/ggfzTG2e6Ya/n7rOR+sRSeIsO7wa2gtYZ7Cjo7up42HSvc syKem0azUu4W303PntqNn600BqXlxFY/6/vQSUOxn9Vkh7/HQ3aGQ6DWpl6E76X0nhEF 5Y1Q5INkyGYbXel1D1E3fDFYJJTnFnN/xOxr/Fg3wFPzzD7UK6lBSDDYlQ3ixXkUHrcf sO2Ah4e9Kt8eY7U5/Z9oSzZDLNK4Qaf0Y0NHpsRs2ygk9dEg8195r279ZjPH4SsXUQDw 2aSA== X-Gm-Message-State: AOAM532T/u2eQVUIn6X9QdaSz/1hxi+LzviHLy1+u8gcfuK1FR1u3kIW BnJbl9WT6oOVJvS76fsPTfXNVA== X-Received: by 2002:a65:4381:0:b0:3a2:ca0a:7ed8 with SMTP id m1-20020a654381000000b003a2ca0a7ed8mr12188238pgp.15.1650330364361; Mon, 18 Apr 2022 18:06:04 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c3e1:100:5858:d3a6:5cad:ceeb]) by smtp.gmail.com with ESMTPSA id k137-20020a633d8f000000b0039800918b00sm14043756pga.77.2022.04.18.18.06.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 18:06:04 -0700 (PDT) From: AKASHI Takahiro To: 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 v5 11/12] dm: disk: add read/write interfaces with udevice Date: Tue, 19 Apr 2022 10:05:16 +0900 Message-Id: <20220419010517.47175-12-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220419010517.47175-1-takahiro.akashi@linaro.org> References: <20220419010517.47175-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 include/blk.h, Simon suggested: ===> /* * These functions should take struct udevice instead of struct blk_desc, * but this is convenient for migration to driver model. Add a 'd' prefix * to the function operations, so that blk_read(), etc. can be reserved for * functions with the correct arguments. */ unsigned long blk_dread(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt, void *buffer); unsigned long blk_dwrite(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt, const void *buffer); unsigned long blk_derase(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt); <=== So new interfaces are provided with this patch. They are expected to be used everywhere in U-Boot at the end. The exceptions are block device drivers, partition drivers and efi_disk which should know details of blk_desc structure. Signed-off-by: AKASHI Takahiro --- disk/disk-uclass.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++ include/part.h | 7 ++++ 2 files changed, 101 insertions(+) diff --git a/disk/disk-uclass.c b/disk/disk-uclass.c index 4918a2f72d1e..72ff62ebf581 100644 --- a/disk/disk-uclass.c +++ b/disk/disk-uclass.c @@ -146,6 +146,100 @@ U_BOOT_DRIVER(blk_partition) = { .ops = &blk_part_ops, }; +/* + * BLOCK IO APIs + */ +static struct blk_desc *dev_get_blk(struct udevice *dev) +{ + struct blk_desc *block_dev; + + switch (device_get_uclass_id(dev)) { + /* + * We won't support UCLASS_BLK with dev_* interfaces. + */ + case UCLASS_PARTITION: + block_dev = dev_get_uclass_plat(dev_get_parent(dev)); + break; + default: + block_dev = NULL; + break; + } + + return block_dev; +} + +unsigned long dev_read(struct udevice *dev, lbaint_t start, + lbaint_t blkcnt, void *buffer) +{ + struct blk_desc *block_dev; + const struct blk_ops *ops; + struct disk_part *part; + lbaint_t start_in_disk; + ulong blks_read; + + block_dev = dev_get_blk(dev); + if (!block_dev) + return -ENOSYS; + + ops = blk_get_ops(dev); + if (!ops->read) + return -ENOSYS; + + start_in_disk = start; + if (device_get_uclass_id(dev) == UCLASS_PARTITION) { + part = dev_get_uclass_plat(dev); + start_in_disk += part->gpt_part_info.start; + } + + if (blkcache_read(block_dev->if_type, block_dev->devnum, + start_in_disk, blkcnt, block_dev->blksz, buffer)) + return blkcnt; + blks_read = ops->read(dev, start, blkcnt, buffer); + if (blks_read == blkcnt) + blkcache_fill(block_dev->if_type, block_dev->devnum, + start_in_disk, blkcnt, block_dev->blksz, buffer); + + return blks_read; +} + +unsigned long dev_write(struct udevice *dev, lbaint_t start, + lbaint_t blkcnt, const void *buffer) +{ + struct blk_desc *block_dev; + const struct blk_ops *ops; + + block_dev = dev_get_blk(dev); + if (!block_dev) + return -ENOSYS; + + ops = blk_get_ops(dev); + if (!ops->write) + return -ENOSYS; + + blkcache_invalidate(block_dev->if_type, block_dev->devnum); + + return ops->write(dev, start, blkcnt, buffer); +} + +unsigned long dev_erase(struct udevice *dev, lbaint_t start, + lbaint_t blkcnt) +{ + struct blk_desc *block_dev; + const struct blk_ops *ops; + + block_dev = dev_get_blk(dev); + if (!block_dev) + return -ENOSYS; + + ops = blk_get_ops(dev); + if (!ops->erase) + return -ENOSYS; + + blkcache_invalidate(block_dev->if_type, block_dev->devnum); + + return ops->erase(dev, start, blkcnt); +} + UCLASS_DRIVER(partition) = { .id = UCLASS_PARTITION, .per_device_plat_auto = sizeof(struct disk_part), diff --git a/include/part.h b/include/part.h index c4e0bef7749d..4956cec314ed 100644 --- a/include/part.h +++ b/include/part.h @@ -306,6 +306,13 @@ struct udevice; */ int part_create_block_devices(struct udevice *blk_dev); +unsigned long dev_read(struct udevice *dev, lbaint_t start, + lbaint_t blkcnt, void *buffer); +unsigned long dev_write(struct udevice *dev, lbaint_t start, + lbaint_t blkcnt, const void *buffer); +unsigned long dev_erase(struct udevice *dev, lbaint_t start, + lbaint_t blkcnt); + /* * We don't support printing partition information in SPL and only support * getting partition information in a few cases. From patchwork Tue Apr 19 01:05:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 563305 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp2861204map; Mon, 18 Apr 2022 18:08:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCLRLdy3Q98rKaAwawwaLHJXLFgxReM923McbYrKsC1wlZtgqxEesJ4qkF4l7SA5IROeSd X-Received: by 2002:a17:906:c113:b0:6d7:7b53:9cb with SMTP id do19-20020a170906c11300b006d77b5309cbmr11771235ejc.197.1650330481185; Mon, 18 Apr 2022 18:08:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650330481; cv=none; d=google.com; s=arc-20160816; b=yzILKTqP+S+kJmINzRZ4vMiZJVoGQSVsOo/aZlNPrsufvCv/CLROXHD53SLi3Ywvql GzoBXq2KEUW0VvTMfGJWOrhyK9E/18ofdozmFC/eLL2/wlmWM5/CcxDBGiKBGYwwJiUI Cd3six+yKgm8jAd3545V5xu+A5TT/chPY4M9wXcw67RMJh6/wT4TPCfqBKLtrkTQ6FqX dAyZFylWkFhWMgWOrv2GlhvFajbWNU+urGkAmqKKe8++7uTmNrD6aPvuR8fs3pyeVIVP SrSvjhiSNWxnzHLgIBMhoqd4vPEBumqW6S/UFFpTv92JDgwFtzmUeuq6RwWrSMJnnKcS bKSw== 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=ttzRaXmF+uRsWc3HJfIzPa3gWWQ85JO83DmWjnDfnrM=; b=RFoZNub3CdKCOe4p/ZgPV/HD1nivNbWi/h2msVRpq+fZbrvC7795riKFiPqEAM4qL1 e4hM9o5qrnaXcblxGQNfCKAKgTbCVmW3kmwqem8srSKDaA86OXE66XrEKDvJkGT4WbSR +PPFNzEazdrYz1jUCwwJffKj0YqYkShxUklGTy/TafP9mBmXW/J6rM0Buw3Zn8FVblds KiSHF/opK60Jzmx0AHPHe4Tkqh4ZOeoMAN+cdbwD8nT0cOtLCzteh3VQCYoESrOxWgP3 3Bec3uPJGG+yuJOgn0xH5OioHeiEdU89eYrL36+JHw+mk5zpRFp5Dg48SRKgCR6VabrA a6jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xGyUKgFF; 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 v10-20020a056402348a00b0041d79cd16d5si8044073edc.304.2022.04.18.18.08.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 18:08:01 -0700 (PDT) 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=xGyUKgFF; 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 7DDFC83DF3; Tue, 19 Apr 2022 03:07:26 +0200 (CEST) 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="xGyUKgFF"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6A94783DA7; Tue, 19 Apr 2022 03:06:18 +0200 (CEST) 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=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) (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 7953E83DA3 for ; Tue, 19 Apr 2022 03:06:08 +0200 (CEST) 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-pg1-x52d.google.com with SMTP id t13so21988326pgn.8 for ; Mon, 18 Apr 2022 18:06:08 -0700 (PDT) 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=ttzRaXmF+uRsWc3HJfIzPa3gWWQ85JO83DmWjnDfnrM=; b=xGyUKgFFKY2ooMkM38FcPTuaCvEV0i0k/Pqdfp/D/vKc3t9k1VY7JBt0uBSftBMo8n 6/oKmH51TZHyLLBCZWA/+lOMRhn99bo0K+fnED2btORTLxCM4Dcvf/aYtrWp8BcjHJXW DObENk71g/soBA3sLQOP+HowtJZziM+YYu17S3a8mMnlX/ZVHe/zpcG9o0cNVMcCUMem cK5SU8+6lgQJd/6AMYRLVTqKwZ63fGZGFA1r+7wK+OiJGL5H2p/YQIUKS/lcjlKs0mfy MdSNyJ9wGQQOQnxKIpfyBJMji2hLCie/LHS6lYcUpzdYNeUenh5M8rRivr74e5mkFvdK w/yg== 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=ttzRaXmF+uRsWc3HJfIzPa3gWWQ85JO83DmWjnDfnrM=; b=A6HsppUoBt7UvhIBzVfUdOseEfco7wH9Axkd3TfKOcXIwSfs9Rp79U5Y9gZVgW5pzO r1AOZKqcjXdJns47gRkWLsBTRUwwkfEIf9wUHtyJM9BYx4VdymWNPPHkFf1jaGHtLwbH F4+tHGNmaZADwLOen9VzAzutYDjgTaEJWnpNdCJ25ALZRQZQ4BKHnv0HFHtd3liiAIUg QFGHZqZIJ5q6kl9hN9cK5vab+s+MDNe2C35MhDq9gOUbgnAIVBMO5VGgwljhPcOY/gid 7VgV9PQr5mAymnHToCyzVDch33p1dU5lO/uasAzlvvoJ3G1HWDuShMB4bvuAy2BybeDk unVA== X-Gm-Message-State: AOAM532iE0gGrQXzy3QOW4xX0TB6mAT5rVT9G3fBR3YlR4/7Lu3jY6YP 3QhbvaWOlp7E5XbDmqK5VpDDOw== X-Received: by 2002:a63:af06:0:b0:378:3582:a49f with SMTP id w6-20020a63af06000000b003783582a49fmr12324720pge.125.1650330366826; Mon, 18 Apr 2022 18:06:06 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c3e1:100:5858:d3a6:5cad:ceeb]) by smtp.gmail.com with ESMTPSA id k137-20020a633d8f000000b0039800918b00sm14043756pga.77.2022.04.18.18.06.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 18:06:06 -0700 (PDT) From: AKASHI Takahiro To: 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 v5 12/12] efi_loader: disk: use udevice instead of blk_desc Date: Tue, 19 Apr 2022 10:05:17 +0900 Message-Id: <20220419010517.47175-13-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220419010517.47175-1-takahiro.akashi@linaro.org> References: <20220419010517.47175-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 if CONFIG_PARTITIONS is enabled. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- lib/efi_loader/efi_disk.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index 34bb662e9cc0..8fb5b2363c45 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; @@ -101,10 +99,21 @@ static efi_status_t efi_disk_rw_blocks(struct efi_block_io *this, if (buffer_size & (blksz - 1)) return EFI_BAD_BUFFER_SIZE; +#if CONFIG_IS_ENABLED(PARTITIONS) + if (direction == EFI_DISK_READ) + n = dev_read(diskobj->dev, lba, blocks, buffer); + else + n = dev_write(diskobj->dev, lba, blocks, buffer); +#else + /* dev is always a block device (UCLASS_BLK) */ + struct blk_desc *desc; + + desc = dev_get_uclass_plat(diskobj->dev); if (direction == EFI_DISK_READ) n = blk_dread(desc, lba, blocks, buffer); else n = blk_dwrite(desc, lba, blocks, buffer); +#endif /* We don't do interrupts, so check for timers cooperatively */ efi_timer_check(); @@ -446,7 +455,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 +530,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 +587,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);