From patchwork Fri Apr 15 07:15:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 561937 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp114992map; Fri, 15 Apr 2022 00:16:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9eOGDfDiMZvqKJI8ko5Y6tKjhdBNG1oZH/22SMeQV3umachaw6I2ImaTKPBOD2w3ASC0A X-Received: by 2002:a17:906:58d3:b0:6da:bdb2:2727 with SMTP id e19-20020a17090658d300b006dabdb22727mr5166025ejs.549.1650006986729; Fri, 15 Apr 2022 00:16:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650006986; cv=none; d=google.com; s=arc-20160816; b=U/EL9AFAivmkXw+kWQ8VUZfEZ9781/2XK1BzdeYT84szsEM2vv/zw5uqLHyOjhoho3 pmni2Lu0kctp4mKnV4L/6cGKN2Afj+ytjzV/7an2yXaSTRl6xY9avN77ilLpAtRddDin KZuIEWCGeuaTNXRCaITHp0Sb/jyPpyBfCC01O50L9arblOBV5+rfLzvFU7A6QlQlc24U F7oHCZUkw/FNae96d8W5xpGEJwhh+G27dzvb7jUuilcvnTRyAp0VdfEcw6oj/Lq/dlL5 Brogz4PXCUbwTizaj3jnFuE8e301WW7wJm4TuzSwkDIhSM2yeSqMstGBgRoliIUYesW4 ErHw== 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=ZKNauYgHFCk4hOUrxya9O+8I+VDTJrOJ8GaRnW+SYsAT6b4ZQe2q6xAKWCqYA/KKkZ /u62YbAodU/jrZHHQDc66+10I0Z0OKGP27cp+60DfyUjOQzDGwtW6gSjFjL8QTRoFvDv vPPE7SbHrpm0H+blravPeVH2MKzioIBMp3X5oTdbnR8+rZE68Y/h2s+jz7cXnIEb3U1N 1moAJHiU9S32WpwF4NTT45sb5cd33Q8HM6feRtnhdIVFlAdQZiuT+OMqnoZ1vdLsSf0o 50XRJ/RhUNAp8PsrRaoziGFKpFlJ+YXDZ4cxGLPqZc9NuQheMtn1VGIZrynlZc3mmYwJ hHow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZP1op1+v; 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 f12-20020a170906824c00b006e834cdabedsi533315ejx.291.2022.04.15.00.16.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 00:16:26 -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=ZP1op1+v; 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 2DC21839C3; Fri, 15 Apr 2022 09:16:22 +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="ZP1op1+v"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0204E839B9; Fri, 15 Apr 2022 09:16:21 +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-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) (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 44E5983941 for ; Fri, 15 Apr 2022 09:16:18 +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-pf1-x42f.google.com with SMTP id l127so4983683pfl.6 for ; Fri, 15 Apr 2022 00:16:18 -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=ZP1op1+vfbGDSw08dFaTHoVLmL3TiiHbYXwnK+fYlQnqOo906m48rIA/knUUEVroEj 0VszAKtLd1nw7RMFtm/D7phE8Ld208YWUhPV29tJ/yGiejkKg9EOdWsGag4Z5thM7MW7 bqJs3u+Ajtjr8NbALbzq+cSNrsU+NlxBn9Uu8vcgnef0AEWKNAbP61u+17kKoDqKlwKV iBxbPQyunCaIahuuepCa4p5M2HQM6fLNMDVef+5xFx8FOUDqOq1ZDIKq6ExTLowNxTze Bnu18ONFQiryMNwWR+krVPIqij3gjcbzFRQEmGTyYCIyWxjMolRtYOgfqyTXMCV++VYt Q46Q== 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=CDq07QhUa05Vn5XFVMVXJPFv/imNLTFa2A0BH2dlBPdtIUOT3hJHyMMvWbVe3Nap8J 4aIjpwii7uwUiCYJvvNUzNLt+cELf+VyQsrPevsJX2D/Nt0kyplhH5AtxBppz/jJ1AyH lXcQt5QUjXaiG2HctcsjldHfuSULEuPLbpWkyFWCeFn9Vsogck4TITJ5LQB9TW6N0+cH Xv3M2cVTg+zDK6J/yDiu9gMiOLAu8P+TOMVK82ohsPAFkFVuCP406aDCPJn8n9Qcknyz sU5SxJHutl/svXOBJO1PgpFlRJqEaNcWrSsXJxlwsKiPZ17IWhtVBvjxQKLxWyODzBkZ SSAQ== X-Gm-Message-State: AOAM530czLmrTIe1KcpiepnlmYZMjuKF/lJw3HP17giL0NYruUegP9Nq MeTZVb5bwJzsNqZfH36nu4BN9g== X-Received: by 2002:a05:6a00:140c:b0:4e1:530c:edc0 with SMTP id l12-20020a056a00140c00b004e1530cedc0mr18543378pfu.18.1650006976687; Fri, 15 Apr 2022 00:16:16 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c3e1:100:18f3:1e4:6c4:6ea3]) by smtp.gmail.com with ESMTPSA id p1-20020a17090a0e4100b001ce188720e5sm3566921pja.53.2022.04.15.00.16.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 00:16:16 -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 v4 01/12] dm: tag: change ENOSPC to ENOMEM Date: Fri, 15 Apr 2022 16:15:35 +0900 Message-Id: <20220415071546.122475-2-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220415071546.122475-1-takahiro.akashi@linaro.org> References: <20220415071546.122475-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 Reviewed-by: Heinrich Schuchardt Reviewed-by: Ilias Apalodimas --- 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 Fri Apr 15 07:15:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 561938 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp115063map; Fri, 15 Apr 2022 00:16:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhMFhJ+yxhXmU+QrHO0DzcRQMt+LxfKT0lxsXSdwXbY3TGrKcXwGwJIU8stysITzMxhV2K X-Received: by 2002:a17:906:38d9:b0:6e8:3f85:4da3 with SMTP id r25-20020a17090638d900b006e83f854da3mr5459352ejd.196.1650006995791; Fri, 15 Apr 2022 00:16:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650006995; cv=none; d=google.com; s=arc-20160816; b=NxF6JxWtYH/1qgzeoWSKNlLLXcgY4ofi4b0BwlYhu02mEtu/HWc8S/xdiphrOtmwTG +B9iVaPqhsBZLDMrHz+zz7GlUefgoKZFmdI/eqkiS0rn5ELPyHIKTMJtqk30IXifIkNI TXYnjHdUU4LFepx6QaBcF81kJrmBjhTyA8XX72Ni7A88pxkNaBcd2Z6pLsWYE7RBc3HX hRHVi3Ra69DU+ajiXvKHvR4zwU8Czg9n3dt4YWIiB8fVrGuwdWYe8B9znR7L7ji9UwYR ErS1EgleZQCEAmqakJ8Qy8q44UD/j8RwHYmlTeyAHgqJkXhxDDcP6p9p4WXueVGSc6UI D1IA== 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=KBo6iH8HdFc2WC31d5ktVOd0WcWnRyPWwuX5IyoE3pbou877R6j3mJxwJfOVjA1rpZ t+zipXsbNKFdHlj07e03ewH60wWyFoneHViTyXAOHiycx16U89e1qSjg01visAsmuvzs 3a7cF3OgK6jMJDMlWH2y3NS9Tx6HQ5QWPKf30sn4vtbKyJJ4zcdXOhJKReX3PIWSTb9m AD3woToL54MO176OvebDkRLvZMhMPRrwyiw2qy3whH7YoW+m+aTyuhiCXo7301iT+qM/ aVUJ3HDpFWjzc7+89WPh6ubIb6O/1VyG2qOOCbOKpM8M9sclFisz8k1mgvqmienCjimL iTtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nWf4GjsP; 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 g2-20020a056402180200b0041d799aa068si584067edy.147.2022.04.15.00.16.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 00:16:35 -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=nWf4GjsP; 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 A9EAC83959; Fri, 15 Apr 2022 09:16: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="nWf4GjsP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E334983965; Fri, 15 Apr 2022 09:16:23 +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-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) (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 81C6D8399E for ; Fri, 15 Apr 2022 09:16:20 +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-pf1-x42c.google.com with SMTP id p8so6696719pfh.8 for ; Fri, 15 Apr 2022 00:16:20 -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=nWf4GjsPpno/qcxMfPRVEqN9KRBjfKrybP5zZt3OHyYCzDSQ4GcfBNHf2H7yOXtHDl f9CbSwbdR1Y1IDcwDBi7MEagVRzeZsXoLzHNDEr//t2hy2XBp9KZ2oz07YZdy2JfTZUH 621hcP6SDWqrrU9jwTXcm/mkPyRqLHkCVYzAEpxxb3kE6vSxgZSSIMVYtBWpGR6I00Mb yJmtVHbgkj73F1FuIBChQTi4I0E8zQnS2h43MFUlvtdOfEiOLwYKIdm3P//D06R5QV/8 dTIihwcggqO7RTrMo3S+OY3xj8B49kiUqFu/zy2p3rUtrce4+hv6NjcOGBNHeBK/zrb+ lZ+g== 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=HX8SeIYAFh1WJ/OyUOdvUvJ+EH4U3yf5GDsf03Sdgw9uU4fJVWstslPY7Q+zw8xQp0 S68jtsN+lYEVjCDDX7HhSNUVtKbRi9EposFq5h3V8sIZYPNFfOul8AMPI3fQ4p02fAVM Y54apvJtAga898hTq7+YAdQG0BvEyYFa9GD6qWQ2o0CO8P6S6ms+DyDax8sqYcgDAGhF IEVbB/J1Por6LZgQOxMRitAFuY4eTFZSaAbUlAHztbolKz/ozXtzoXRp8gOv/B7GXJDG 5UW+FrkOYkf9bIKNQDaOtqBIyL1Xz1eQ9EZKSrVNLVOCM/UkKIPnQov2vS57e20q97HM qIVQ== X-Gm-Message-State: AOAM531CJjmDq+s6DkIjONSoByBQdCTgdyDP5zelLoNv5F3Xe+iUzx6A /bIueAYM/gwA8PqhD+DFOFrlug== X-Received: by 2002:a05:6a00:1a06:b0:4fc:d6c5:f3d7 with SMTP id g6-20020a056a001a0600b004fcd6c5f3d7mr7522163pfv.53.1650006978971; Fri, 15 Apr 2022 00:16:18 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c3e1:100:18f3:1e4:6c4:6ea3]) by smtp.gmail.com with ESMTPSA id p1-20020a17090a0e4100b001ce188720e5sm3566921pja.53.2022.04.15.00.16.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 00:16:18 -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 v4 02/12] dm: tag: add some document Date: Fri, 15 Apr 2022 16:15:36 +0900 Message-Id: <20220415071546.122475-3-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220415071546.122475-1-takahiro.akashi@linaro.org> References: <20220415071546.122475-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 Fri Apr 15 07:15:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 561939 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp115144map; Fri, 15 Apr 2022 00:16:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZS1qS9VIoHku8qkre2YB1cufOP2HBf3rE/9Cgq/mPpU8vAMn/vPgICAsDZyRmXNcGGwWw X-Received: by 2002:a17:907:7242:b0:6da:b561:d523 with SMTP id ds2-20020a170907724200b006dab561d523mr5214748ejc.118.1650007006436; Fri, 15 Apr 2022 00:16:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650007006; cv=none; d=google.com; s=arc-20160816; b=XrdGHdzqKJLcsvJfiJQF/F8V1KKho9njlxEKz4pq0FUDU9shq4QHQCCGOEJF/5/X4x 9u8vbPVpeS/FIH1czUW52EfqqkihcBJ4inoiK4Pu79JIyZJVR8crtK8RP8p/XnFAgbl6 ciPthwKnwkhua180gI0u/mxKFWEeNAUyv1gMmV3gbFgX74owI0Mee9vUbp52AYIQcePM 3Asz+6yMjaOfMl+Ip2qfOzMw3yHjuYJocr0AY6Vf2CQMgTEK4qAIFkqs9+HzqNusoTVb UFXNiimSUNzCHMF041TV4aFCC8HkZqI18uwg0LkGFKzRCuW6k4xpbfIRbiDaE0wa6lmW zKNQ== 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=Eacsu420BmAUaZohJQkVTvQ2VcDs8tSzthJkjHbBuEFs/fxTEenL9LH0cIjvieK7UH d7v0s4naSW0xx+2OEGY10mKUUh3MZ/lamsm54MueXtf1VuEtHiS/Mm6Cm5kivWxzODhc rR2HNBvLsEOzNsCDSm6I7T5AlItEH41elpkX76EH3JJGrq123QU88+5modbQ4reoxJxP eP9Cycm8mZ/W5gzLgW9tBaKHs47YW33cd3oBAJC4kb+vcWBbMTCmJ4KIh4hwh0BzJb2/ c4BRy8lNUXz48xxEsJO7InVxnS4VUSQBnLAZEafSUM0tABzdxC5Q9s/7Wh+logrMeRJV bDPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Z2/SxQR9"; 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 vp6-20020a17090712c600b006e1442ff695si480235ejb.590.2022.04.15.00.16.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 00:16:46 -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="Z2/SxQR9"; 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 DFD3F83B3A; Fri, 15 Apr 2022 09:16:30 +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="Z2/SxQR9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 30AB8839BD; Fri, 15 Apr 2022 09:16:28 +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 E2FE883AD0 for ; Fri, 15 Apr 2022 09:16:22 +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 h15-20020a17090a054f00b001cb7cd2b11dso7722486pjf.5 for ; Fri, 15 Apr 2022 00:16:22 -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=Z2/SxQR9PRGujfeRsiUagBS5AxO+LS+bYJxIMoliBO6D7Ah6UV+0TiC8zLpp9RhLnC 40WVb4s3ehoXftPcUi5wFytiUxDc6Fmmr3VNWkdJ3zJuxdbsi+CAhP3OKLL3u6FqcgD6 LlTl/2vhs1o99jhiKj8NKdf9Qn4YWhZRKVsUMfUwo62S/d6puVJ6fiKSat1kNlnNRQDn tC5/Jz7N+G/mScI9cXT1c5zEGRGTpQ5MrNR4WJxp+/ekfbJRGPEECRxC8nb3gZD21Qxi 6tAgxjphSjjmfgvcl/M22I97jy21CDz7dCfiWgRuxV1UDSQm8tVBw9MqXlapmorAUKgI FHAQ== 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=nG5cvKDMbjcyM/OETfU/yho4wETh9MxMu+Apcs8CJdlEFBJVQV/WSsV93YwKRs9xTU HcAP4RyRF25/ruPIhZqu++Tz8jLWS55mB93PeAkVPS2YatCx7U+lgb/baWt1dQ4/9fSE b29q/n2lq0tSPdI1fD3E8ieyA92SLu2al1CHwyRj0Uez+NHBOQA6A6x7+hLpoR4XyybH HmOpXZXY++suIw2vME5eBlzfiMmSnKVJ9Gnfz+R5Egis96mrjPDDEdiemH6kYuTEhLA6 r7bz40jayfSl8z7rwUxjZZoNoiyhSF+LRDpp2rTdsiRkOL0PDCSgCZhgbkYqxB7fygGC xsoQ== X-Gm-Message-State: AOAM532HgxgqT1gD6/D3bKARV+KMlfUgrlMh3PTVyxZfDcUM0qKejGMd fWM+jBYJc5ij2Szo8qBAvmd/0w9zeXoa7A== X-Received: by 2002:a17:90b:4b89:b0:1c7:d452:4bc1 with SMTP id lr9-20020a17090b4b8900b001c7d4524bc1mr2759435pjb.134.1650006981373; Fri, 15 Apr 2022 00:16:21 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c3e1:100:18f3:1e4:6c4:6ea3]) by smtp.gmail.com with ESMTPSA id p1-20020a17090a0e4100b001ce188720e5sm3566921pja.53.2022.04.15.00.16.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 00:16:21 -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 v4 03/12] test: dm: add tests for tag support Date: Fri, 15 Apr 2022 16:15:37 +0900 Message-Id: <20220415071546.122475-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220415071546.122475-1-takahiro.akashi@linaro.org> References: <20220415071546.122475-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 Fri Apr 15 07:15:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 561940 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp115249map; Fri, 15 Apr 2022 00:16:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEkrBODEh1sn1l/6xve7ZzZhWh4Wf/nAqtAOSquK9+T3gfbhVynVPAtr0TFioCa/TjPR4T X-Received: by 2002:a05:6402:134e:b0:41d:774f:4c40 with SMTP id y14-20020a056402134e00b0041d774f4c40mr7000531edw.202.1650007019570; Fri, 15 Apr 2022 00:16:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650007019; cv=none; d=google.com; s=arc-20160816; b=g8jH29A0aGvv0gkeF/trAMJdp/riGeQ6J5bFjFqoG6g/D2qsnl1WSo+LADUvQG+lxs qX3s5ZxQsUCT9IN7oCJQ86HGbeTEd0EfvOdKc+cXnv6ikTLBfKXP80QXQ1UGHLadjgRE MjY3jRe1kkUcBjmbjpS1qU0yvBLDJaUKyIoWjYKTg1TqW5D93jeTQgI1gOa2a595GafP +yVzhrAgu0YZJBi/hY76LZJIzE6mnQUQ4XQKFLOAKEA6e/Y3t4b0jHQlyJjl1ctdCJh4 gmlMDSQR1A2Nu/GoFUb7mM9Z4Iwy2LnInUdjvgTtgGJNT9iolx/l53rgNluL1SykAVWC rd6g== 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=Ao/Y3BMYKq5BtgP/1yBdnx1BqNPG07Ibdvm5nE+ob5w=; b=wQeUkoWLjOLA5/pXWIWAdfva+tP5FCHczbobjtTlTOfQc5yKw83jNXw50DseVVumF7 24Lv4aNMarf7caOgynRHmgnMeh/fmcZKNLkmt6kxr44m7ks2va8AdEbz6DbohoZsmeJP vUxQJZH0bx5wO/aPoWFO1ML9LIG4HGZCnOk8+FN4rAW6kTUtmTVrzoH4GpxrFtcSN/ED c1df2YDa/zqi58ifYN0C0qT1Yqw20R4ThN1BQxkApHzyhOMSGEgHUQG1uCd34J8zTXYk 3kdzz3ZFTBYF4I457jnEtmAAYbNYjXK+02IQ6slbS59GIPfVz2w7iSQ0xWejNsPD6pWF NRxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ffskeXGt; 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 k16-20020a17090632d000b006df76385e97si519819ejk.823.2022.04.15.00.16.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 00:16:59 -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=ffskeXGt; 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 9299A83A95; Fri, 15 Apr 2022 09:16:33 +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="ffskeXGt"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BCCBD83AD0; Fri, 15 Apr 2022 09:16:28 +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-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) (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 6E16B831CA for ; Fri, 15 Apr 2022 09:16:25 +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-x631.google.com with SMTP id n8so6548492plh.1 for ; Fri, 15 Apr 2022 00:16:25 -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=Ao/Y3BMYKq5BtgP/1yBdnx1BqNPG07Ibdvm5nE+ob5w=; b=ffskeXGt3CF1MrDt89Fj6HfkQ0eTkTwHr/SnayEA9W+c+xSH4FN73krH2X3qc1id5S ysUW12lvvRecUwRG3YSxS4apJOAhKNITkvjRv6TTPUOerWn0vJy7kaXGC2iQmpP7W7LP KLX9Ox3ijfUKMhLjXHy7m8q+npAYgo3scn/H3k+FS8C7zznWe5azE3cxzVx5tOXZ3yhY 1twJwUJiE55/rAaGg7AisySaQ4x+QMu4ffKMaz9VZ76CLi6fxm/Ow0j0x+BG3MUlV8lI OJTkF4rrPpviN9dKaFNyHEhnktzGcg9LOdC5sQLbYbxPTbN0mB75LCDTifRdfV5VIguF sKhA== 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=Ao/Y3BMYKq5BtgP/1yBdnx1BqNPG07Ibdvm5nE+ob5w=; b=pcd8v7lgDD5B5YksIt4DjWv+JoYZv2Lqch8ippiarbtGwZXDULGZ64G36Gt+trulLz 7/sZxyPccvrg2F3XEeanonOVuqq5cxG1o8srs5gOGFHMxLD0oOkUt78sLP49BekeRGo0 snoLEQ/BPVU3klgDFjQaRWa2nllCMmNt6Dq8tl5IjAAG2UfT4d+2CtImAI095DjrTwWj T2LuPIIAZJ7bPz83Q90lwwbFopGvgTHPhR7wSg3esUBolnALeuEpbWt8FVSbM4mQCnUn 3bEC+txDT8wNtvt1RfS3yrGLTcIhvkKoA+EwHutR3vzGs/v556R+L80aKRgbcSwy/i6w wbuQ== X-Gm-Message-State: AOAM532U6EJAxGrGGKqemNYIXFMHlZEJPUxiFPpGrbjM5EYKcfgywGHS SZcM/3TKyh0wAEBlAQrJYn53rg== X-Received: by 2002:a17:90b:38d2:b0:1c6:fa94:96bb with SMTP id nn18-20020a17090b38d200b001c6fa9496bbmr2736863pjb.206.1650006983776; Fri, 15 Apr 2022 00:16:23 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c3e1:100:18f3:1e4:6c4:6ea3]) by smtp.gmail.com with ESMTPSA id p1-20020a17090a0e4100b001ce188720e5sm3566921pja.53.2022.04.15.00.16.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 00:16:23 -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 v4 04/12] dm: disk: add UCLASS_PARTITION Date: Fri, 15 Apr 2022 16:15:38 +0900 Message-Id: <20220415071546.122475-5-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220415071546.122475-1-takahiro.akashi@linaro.org> References: <20220415071546.122475-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 53cfbdd87671..907c227aa20d 100644 --- a/include/part.h +++ b/include/part.h @@ -287,6 +287,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 Fri Apr 15 07:15:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 561941 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp115350map; Fri, 15 Apr 2022 00:17:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhK6qsTG3ICpKd9760sBAdiWnjdkZCW6OWYro4tu7W84mzJok3aqYPHNl9hDndL5UXgtYa X-Received: by 2002:a17:906:f85:b0:6d6:e97b:d276 with SMTP id q5-20020a1709060f8500b006d6e97bd276mr5157563ejj.431.1650007029840; Fri, 15 Apr 2022 00:17:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650007029; cv=none; d=google.com; s=arc-20160816; b=nZBzCDroC330ZyS0X1gwJB6EF/wmC+3Q29MbyNxPJoQ4x/O9LFh7Di+4jVrvjmbSPZ jJKEFyeU66dkFkrO3aZmh2v+lqZH6li+NKu4nkQvjgF+mXDBKiNTSw15VpoPYUOB75I/ Btc7eTRfobtF264PQzVinY8NQ1NVyvOBk6P3EIiT+7CMXNF48V8sdXDKwIKRcgh7Gvhw vDH7hCt+n0IlA9sVEWoZpiWAZ11FkhEZRAt33u8VAI9o77Xa8Lq5QPcpqNKEbMqitMag xgk9p0EuEBNWY61o9kNJHiJbZSnUvCPeBWjk2i0zNXxwIeiLNtrD5HfkGcQPBpfttHsk Hp3g== 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=S0em1TOpCoAJakdRKKFEDXoGK1Fmysrx+T8HujuYynsmDs4iFRYLwEZEYLRcce7w2n zaxc7fODFLcUdqrDaSY7J7Cqq2CA8LawWraiwM6TSEg7CiKROKeTNnWKiDew3hKH2knC bzFRSxhluNU1hYIPbHDIlUW/Z7D5msT/9ZH+cer0We7j7Qad5SFUnNk2OBi1WCXba7dL 25FVGAyEZQJ2z7UEZvnIztzGjauGBU52e4WQYSTKyY/rXxxr6xdZZ5Q4oKD150za2nT3 T0PmNbf1Ix3xVp6bH9H/OdqXar6MleaK5cncS5zRWGspRTLVKKMlTq8kesze0FAIZzSL O07A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="KBQwGW/i"; 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 l24-20020a056402345800b00418c2b5beacsi542823edc.398.2022.04.15.00.17.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 00:17:09 -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="KBQwGW/i"; 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 846AD83C0E; Fri, 15 Apr 2022 09:16:37 +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="KBQwGW/i"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 77AE883B4E; Fri, 15 Apr 2022 09:16:31 +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-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) (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 B861D839AA for ; Fri, 15 Apr 2022 09:16:27 +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-x52e.google.com with SMTP id r66so6718379pgr.3 for ; Fri, 15 Apr 2022 00:16:27 -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=KBQwGW/imgorQtpEKwZmI75e9i420R4ckTTB+J87HqccrObAtBlH97uOra4jokKcyh SQFJi6lDMhb2YuMPabOe6pVaesTfilVB6T/BLYVpo3kQMUfX+vaKCuOVCnhWwgX6okFj ZbI/F2ccScUUreymMkV4xkOGKLC+7GXtRcA5s0asz5fBQ97roAevlRIdFnEEMODctvpB 5Pz9jV/f+r9EIUz3asl032GCOjl8bRMxGW9TK7N+ZEHgVKF1OO9WfFSBQu+zctjo0yf1 tQ2ctfSFF2EFZXJFFAud12TfFYvGG4NfIjM4sYwUZ8hpkC6Lp9MEQYnV3heeKWx7rhwz N4QA== 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=w8bP36PG1pw+qY4rXZDY7kguPkCKePugG2P8IZRpcPN2T7ZUidtp75X1PeXEhNqBq5 ZUUJYUXGJoXKDxv0EcQhvN8geqrIYHE8wD/h0jIAvoZYD0PP7A0Zk3cU2iRLKkBj1ZMA tHFjR9VRUgi8RhadkNY/4az8UKCq04OIrg6YUtBlBlY9IclvSXkTOBiHR3BVnjiGLECu pec5v40N+ip9EPvJvC/9lHIuPHrjcjIGt9rV/HZdfG93A2GfC9N0lnLzOjvyzxcxcgol w8l85QUpTyuHkba3PMyS9BGGXD92DQw0nolv1mOanBdN9Kp8NWgydSG60wyaDp/CJCmz 6hUg== X-Gm-Message-State: AOAM530LpmhEVnnuli3k7nuSi9ljHX4/QmNIb03BPGSw/3gKbBDzVN0l pN1r9+6HWs1LXUR5N5FqlCNN2w== X-Received: by 2002:a63:2b0b:0:b0:39d:890a:ab68 with SMTP id r11-20020a632b0b000000b0039d890aab68mr5294638pgr.247.1650006986173; Fri, 15 Apr 2022 00:16:26 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c3e1:100:18f3:1e4:6c4:6ea3]) by smtp.gmail.com with ESMTPSA id p1-20020a17090a0e4100b001ce188720e5sm3566921pja.53.2022.04.15.00.16.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 00:16:25 -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 v4 05/12] dm: blk: add a device-probe hook for scanning disk partitions Date: Fri, 15 Apr 2022 16:15:39 +0900 Message-Id: <20220415071546.122475-6-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220415071546.122475-1-takahiro.akashi@linaro.org> References: <20220415071546.122475-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 Fri Apr 15 07:15:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 561942 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp115443map; Fri, 15 Apr 2022 00:17:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6i1tacjrkxlpj4FRx0NAoIH9QE2Vg+ULJ0jDT3WzCUwRQJb5PLGn1nA552OmaT0JdIDjx X-Received: by 2002:a17:907:3da5:b0:6e8:c2c8:1f18 with SMTP id he37-20020a1709073da500b006e8c2c81f18mr5240080ejc.728.1650007040233; Fri, 15 Apr 2022 00:17:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650007040; cv=none; d=google.com; s=arc-20160816; b=H6iaxYwuSzDVlNtQNbzqXl0G/aH6mTLpE9m/iKNzT3B2dlf7ic0jvuslqALDlURLgc i5IQoVcbk73AEspc82EAdpKk4CcJ9Chzt8ngQbBG9TbZ+GI93Iyh+bjc5b1lLFVMvB+U JmJ0BqoUY0CfaHhupKaP5QgTiPU8vaUe2Lp4212ecq6u40k7OFKmeRSIiD+F8k1/B8J4 VzWkm6RTmpzTOi1dmquSy/84YjNfgstBbwkbhHOUzP/Y7E3NfNjKq+MXb7GSHZuHlfHx x3butMeta4JnRgp1YR6ykY/w5CL8ZaD1MatVQZtB+vSGfIkwt4DGER5FJk1htpWSA5Sb bEaw== 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=cbFzoCA87IcKmFGTSIc0nYbRxTMR3twfvdohAUjaIdA=; b=K/uIW2eDYDCF2O6uzdT1K9BUdZQP3qErGdxo3iybBtQ9v5+JPyeoE0ABT8H6Gwcsap lQzSkladhM983Mz3oXvuDWYeQnD48aZURNdJt6OEJJc4qVPxt15n1grX+AjEk3aQMgFG QnFodEDvb2t5PLH4EenX9hZJ2vSYeXpombxj3/3SDKxKX+VvONr3C9GPL4FLlt/EhDOe B1Rx0ncdekgpGnVjPuBxSp2Wjy8m6+kTGSrnFf/AG70o1i+MZW642Pa8pOl4ry9ZOii5 SIa+6TitRCIiBSmxR2WbEt7v1VvLrF9M4qg9Sdm0Y4gk4s489/BDV+AKroE67Fagu4Zm Yu4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=er+IAaZv; 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 m15-20020a170906258f00b006e748e41ceasi552694ejb.308.2022.04.15.00.17.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 00:17:20 -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=er+IAaZv; 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 B143783D8B; Fri, 15 Apr 2022 09:16:39 +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="er+IAaZv"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C748C83B4E; Fri, 15 Apr 2022 09:16:34 +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 2A49183AE6 for ; Fri, 15 Apr 2022 09:16:30 +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 t13so6706848pgn.8 for ; Fri, 15 Apr 2022 00:16:30 -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=cbFzoCA87IcKmFGTSIc0nYbRxTMR3twfvdohAUjaIdA=; b=er+IAaZvwoQeo6gpUCOkHz0zKeWo6f6bbDdNhZ68Ky/Kl0j8/9Ng1QaEu9yFDEOyPl NAet538R3p+XH8OD/rhnpCSHmccRmxE1S2gJP61TqqIMaF3urD3sAytViGXqTEWTBCgX JnwTn8jueCOMjqsKia8q/LbK+zd7ZP/rd49ZWmYf9efrxPGgVGyBqSA/Lfowcuhzc4oY GMod6LY2/mOWOf+Qwur3rIrQg0J18XGq6eCcUqMexJRkOF+nKbujhYC0c0HtjMhk/uSX F442OgNvSgilsPTK0R524vO8y+Z5U/vjQZZzsFHWJgHXcy2VYFak563xQQ7pxkruwpux EhAQ== 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=cbFzoCA87IcKmFGTSIc0nYbRxTMR3twfvdohAUjaIdA=; b=N/EItUeT08TvEMVu7wc3b757oshZiw02epoGIpkZdmkkPiHWqTflJP70f21Fu6PyPC NB9leIMX6iK0OWuTmOsVyT2YNA1+nHujK749+thgWInlYjiXVpREwhqw3V5kBJm7ba5S YMl//XCtAnkSYmmipUQJmWCqY0Fve/XVX5WdbZhIVgDea/hLq9ub36aDOY0dW4HwV6gX uiwEBvR+q/OxHCiIUW9sr3hlN7R1rguoJk+E6imJO0/FdV9KwqLaEywpRkmT7Wt9d9tc qri2a0kd31BLiZVBdTOusUU5Wb6Ea8XeUiP2eUS+C6k4GgI8y7hazYNWwuVziSsKec2S mJhw== X-Gm-Message-State: AOAM533QqrYgWpajAFcRwNvTm0zMafaTecvLrMInEFBHDkm6u6abfDvy K84N7LsR96mJBW54pbkrJQohhw== X-Received: by 2002:a63:d149:0:b0:384:b288:8704 with SMTP id c9-20020a63d149000000b00384b2888704mr5280034pgj.112.1650006988529; Fri, 15 Apr 2022 00:16:28 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c3e1:100:18f3:1e4:6c4:6ea3]) by smtp.gmail.com with ESMTPSA id p1-20020a17090a0e4100b001ce188720e5sm3566921pja.53.2022.04.15.00.16.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 00:16:28 -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 v4 06/12] efi_loader: split efi_init_obj_list() into two stages Date: Fri, 15 Apr 2022 16:15:40 +0900 Message-Id: <20220415071546.122475-7-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220415071546.122475-1-takahiro.akashi@linaro.org> References: <20220415071546.122475-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 af36639ec6a7..3dedb2c5299d 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 Fri Apr 15 07:15:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 561944 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp115690map; Fri, 15 Apr 2022 00:17:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvqw4iE8z9AgChKeZRR6jIsyP84UyxZ2GVOqqd1psMJFA+J5EOLGaaVpAq4lHMDi7CNELk X-Received: by 2002:a05:6402:1906:b0:41f:a57c:f1f with SMTP id e6-20020a056402190600b0041fa57c0f1fmr6882967edz.241.1650007069759; Fri, 15 Apr 2022 00:17:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650007069; cv=none; d=google.com; s=arc-20160816; b=wlSN/8SQVDEmonD/DXx1NFEvAX8MnnzlOK1XiABfKNMylNDmcyZ0WbZbAXQ2e4AYMI ZrWejNfgmQHracXywwqgDR0HoIeRmj+2fzohFh+3MLoktMJHZg6oZ6J5/LAn43Z2UE3F wlgwYLH4s3PeGoZFhLn5ZJLa1VdWTVKuiQriiAlfR480rtlPlyvFALsNkYsZUKOlBCqu tbIUcn5ITSTYydxITFA2VVTfKmk0wRT4zkdI29hNXFlap0AzZISO+OJGamkP587LkPcK Lzwx/KD5IEB7xMxAY2vwuunEB7rX+l8siNfthpgZ2VryQnxqhVaycH1hE4s39F09JzSO 10Ow== 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=QuRt41T/VcRq1FJA9bUnMic95kfhfuw9t7CGGEk+XYs=; b=xiKbkPJ5VRriv/Bmmp4OqaI63J0vJTlSulEqn++gsHyGX9COCMyv+BJe9KfA+1BjAS MbX7ZinLGoUrJY2/Q0ojkyU7CcwPy4a9Hrp5J0ips5Jl97SHiPT7KUgrREd88XG6BUya dlMGRZXudlYX+VrOy6eomFrfuSqogRC6vUpfCHHOLQOwsddBvAFGhl27jseb4ceDDUOe 3u3v+1XkTL74v8hDB53+q3B/cONDi8qgHYWM7OH3ipleN538dDzBgszRrvi5CVBXKVi0 Ra0b77SB8Z9If9IjFG3CMB5e2+Lr5XOaGBUbdnu6D9CjXOHhP/hx//GNvsEnQv3M3Zkl GMrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dibbX19S; 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 h11-20020a170906854b00b006e89d3a635esi480441ejy.104.2022.04.15.00.17.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 00:17: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=dibbX19S; 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 E880283DBD; Fri, 15 Apr 2022 09:16: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=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="dibbX19S"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6B92D83B4E; Fri, 15 Apr 2022 09:16:38 +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-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) (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 9B68183952 for ; Fri, 15 Apr 2022 09:16:32 +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-x102f.google.com with SMTP id z6-20020a17090a398600b001cb9fca3210so7754342pjb.1 for ; Fri, 15 Apr 2022 00:16:32 -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=QuRt41T/VcRq1FJA9bUnMic95kfhfuw9t7CGGEk+XYs=; b=dibbX19SSYFfGQnbL+EvpqQrD1ZADfcFi4bir/uSsorLJ7ctJqBDneLdQYTGstk091 3TiswAoSVuxllfRCnUXjEJbIGTDUJxbimXkV49QQvTdMj7RU3H8R6l2xdCHIAW1zcTn3 NRJt26FhR/Ckzmcom2Nw2/Yvg7XvAn6BbiPbMq1cojwtl9Y50UmIseKRpvMsEIWTwMsx GkE+NPYs5IYE4uuSF8LUxRH9i2Wq/pLGIM39uIAZ+fVacpB+158vbttNb75cJN3SP3RD QvLm/RdoSN6VfoRtFrpR0rbFcX5tLh+RAKvcRP0O0p0kGB/14lOn77T9N+8qRcyCq5lB 5zgA== 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=QuRt41T/VcRq1FJA9bUnMic95kfhfuw9t7CGGEk+XYs=; b=6NH/FyQEfFUg+UU74krmWR2qGorNSrct8YebKnQ///N/EWpB07U6ZFjOsTPLgruMYz QOwk1IToq9CJaQ26G7FE2jog1eWY901hSHXU1EAGhdBYzMtaLwmpEITmxXtT2+INu568 +SAUHUoqhDR1DOpPXAXdcAqW3bxb0b3NaJDJZT4bV0HUm56rqzN4tGcsOIH2hxL1jRcK xnWbq6bjgApTae2Mu7ehxLf6e2H6I1OFo7rCdjz+3F/76Wvl5Y3yHGbOHlPH6j6yThe5 Td6OF740lKzDlTuf4F+GqS+nVoYAY5xQnBvFAGW7sW9go+SL8t5fphmReISg9CGzDp2L KV/A== X-Gm-Message-State: AOAM532vjPc45/iNlzXUFXfd0Y8E0oBs6O5Qwq+dVd8ceu7MWriPcDsT 7QKPDQ9lv/d7UdnK6f3LdSfahw== X-Received: by 2002:a17:90b:3c47:b0:1cb:8121:dcc8 with SMTP id pm7-20020a17090b3c4700b001cb8121dcc8mr2747205pjb.35.1650006990979; Fri, 15 Apr 2022 00:16:30 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c3e1:100:18f3:1e4:6c4:6ea3]) by smtp.gmail.com with ESMTPSA id p1-20020a17090a0e4100b001ce188720e5sm3566921pja.53.2022.04.15.00.16.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 00:16:30 -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 v4 07/12] efi_loader: disk: a helper function to create efi_disk objects from udevice Date: Fri, 15 Apr 2022 16:15:41 +0900 Message-Id: <20220415071546.122475-8-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220415071546.122475-1-takahiro.akashi@linaro.org> References: <20220415071546.122475-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 3dedb2c5299d..f946e74c93cf 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 559b95a599b9..7dc24fbf0aa9 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 select 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 Fri Apr 15 07:15:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 561943 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp115605map; Fri, 15 Apr 2022 00:17:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLBWfF0iUK1ZXUwTz1k5HfqB/sGgWavgxAcXqvpJv2xhVpWtknzp/hcB9d/wuV2lqh9cd+ X-Received: by 2002:a17:907:629c:b0:6e1:6ad:5dd8 with SMTP id nd28-20020a170907629c00b006e106ad5dd8mr5145248ejc.641.1650007057847; Fri, 15 Apr 2022 00:17:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650007057; cv=none; d=google.com; s=arc-20160816; b=SP/BZti0QlcXOL3RzwuFoOMtKq6hCvluHPve+xVokOG/r/f6tWqS2AqegTcfzm8jXV 7SJEBy05QQmX+hRimmNGaimZAxaJKqPwD26vqMakn56b2qB3PeSBH1W/G4lWvjECZNq6 1KVxM0NiT2s7D9SnSdQhzqxyw54Wo2zU3J1LBHyIf7yYzz4v551URzxNVSfFSDgFwTL0 K/gR5BfhJhrTutmcS7S96ZRG0e6TRITdi2YOgcNrTlOGVL7BclegKVyN3d2mhejPKef7 v9gM/obc96/N7wWzPV78C3po2L3q8H31mtdTAQnU7wzuyNgQ+3T/bNfsfyIXGk5z/h7w EegQ== 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=Nqrh3pb8GrmO3uAVPEpLwnoaWXpEHHRTj9wWjfx6KKxk7SSjXwz7Y5vplK+6XlkrZf +8kKFLO/XkfRmeFvrozwd8rFPiUzljv0fdeY8GXE/uhHiq/hKANrFZeP9faAdBJDvvLX u4S+UDS0zpwraiWfkGbrrCOxsWe7pTgzjdMwjEoZb2QeXjQb7/IXVO19FwXfj/A1k/dM vT3VEVfIAIm27d8TuhQJIOuwMBX+jJnM6tSKnUtP6cJIPqVg8FU0ysZvgL40ArpvfwOl Xh6pRsi+sP9xmlHWOoJPfQmf0LvcreeyMZ1z4wBOSAg8SVcI8JveVQAOywYVmvpFjcAk JdrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cz2WMQ7G; 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 q20-20020a170906145400b006e86c3056c2si517082ejc.33.2022.04.15.00.17.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 00:17:37 -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=cz2WMQ7G; 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 2EA3C83DE7; Fri, 15 Apr 2022 09:16:45 +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="cz2WMQ7G"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E19EC83C8C; Fri, 15 Apr 2022 09:16:37 +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 149C683B29 for ; Fri, 15 Apr 2022 09:16:35 +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 k29so6692262pgm.12 for ; Fri, 15 Apr 2022 00:16:35 -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=cz2WMQ7GwBuvrOq7EWEJNEsMUs12fP0szm+/83UvfKLMC4AhpvFvA1PgYyDXhPKJ2I z39hwuRWCjqzFTQo+Bt2/2exEZWUT6DSVo2yda03ttJY0Bs/VqraJtL3wMj9/tqkhlAt 4VJ9JoLqg7Y6rfflWgfjMnAhUHG33UuK60QhYt9hs3KfwaZgVBsERS00JDsB9Zpi8Luh XYXIRdO82b42QiAXMMSC6BtXE2XTwyaB3r+qpl5fTqbZ6rwnKsFWMJLYDOpSG3Od4xKm 5/ibXkOsmK6ZPU7LAzkoFsln8kApgQuuH9uML7+T1r8X3csOCcyRA2XeR0inci7xQT7l tWvw== 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=76gDcXHQD+cQeJWd2Fyn/zNtiKsYaOnaD8B1UTZBq2ZGRMHXvYKmVUcRKP0WLIJVjM feObA4iQp0OJXkm7QcAjyNmy56lpVOIlUGo4kebAwAamE0EuZtjxB2+/0NiLMvDMFQh4 wgse99yY77I7L6xfR433P0hVBBDp7OBL0BHPf4fp/JVPSWS+NuTjAL6lbwsx1ahBbdKv zszNUC9x7lvYqSOROeX6XFTZjsZgjR/J7WHFtl8gLMXo3UXWCBnh+klMf4D+PUkDI11R 3lpwhNFgBd5ISqhuUjRMftZsRmPLtye0G3HREgZ+4dj4jvYbdnJOP/SDT2sZ/+4fJAlf D3mg== X-Gm-Message-State: AOAM532sd2175j7I+Z/Wbz0BljZ248e54mgBa46zMkDOlLPDvnNs32he 2z1dXUxZhxncNprI0YClukVzKQ== X-Received: by 2002:a05:6a00:24cf:b0:508:3278:8c21 with SMTP id d15-20020a056a0024cf00b0050832788c21mr5752180pfv.57.1650006993520; Fri, 15 Apr 2022 00:16:33 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c3e1:100:18f3:1e4:6c4:6ea3]) by smtp.gmail.com with ESMTPSA id p1-20020a17090a0e4100b001ce188720e5sm3566921pja.53.2022.04.15.00.16.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 00:16:33 -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 v4 08/12] efi_loader: disk: not create BLK device for BLK(IF_TYPE_EFI_LOADER) devices Date: Fri, 15 Apr 2022 16:15:42 +0900 Message-Id: <20220415071546.122475-9-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220415071546.122475-1-takahiro.akashi@linaro.org> References: <20220415071546.122475-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 Fri Apr 15 07:15:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 561945 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp115749map; Fri, 15 Apr 2022 00:18:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxy4BreEX06gbIF2CAPU0UP+wm+2TxYcbyNCAVXt826+QAunWGH5wr2V89O+HiJTYzNVhtS X-Received: by 2002:a17:906:d54b:b0:6df:7cff:42b7 with SMTP id cr11-20020a170906d54b00b006df7cff42b7mr5234662ejc.731.1650007080064; Fri, 15 Apr 2022 00:18:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650007080; cv=none; d=google.com; s=arc-20160816; b=bP3SDvyZvFg88qxnWqiIKOpsLkBqZLN0n6UsJn3h6N6WicpuNPUPxh6tI9eUhpm27w JItG9nmcapYPdPiglFwDG+TR9gavc948EIyTqvW2RG5X412kX+7RCvlkycITd+2MLuco Bsc3I7GkJzbMt+mbBzgH8jCSBftveFLqy6U9xybLYKD9kiQ/QfN5iG8CUmg2w9RL769K VW+WpQ8ra1g0uba/Ex+84s74e+3JOD7xiVWFxHrPdUkLMudlLnPRGQJ0g4HHpJ9pUcGY l0cSBXVopxSfB9tZplz5dwHbiNPiDUm/Z7pDNarMHcj0oh7V4ihUHX/qV4JqjSJcGTu7 PqDg== 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=GWoDVIZTmstMsJR3XFg3+gBYfV4C6KqB4qpMrC4s8Lwvy755VWQGC+jdvA4JV8OXIA HN3KGgWFeK+KqeoFncnzu1p9R1keLLLlv40iFVurcEteKfHfWch0k7jqDHoXp0jiu7CR N+2SIV8UlOT52lsGWVkDMg55tt5YP4gIFe9E6GnW4ehXmd7KuwFxf6rWGaikiRLOVLEF MB+1mJnsc+u0MHsjWicVBQE+U9euU0p6ej3QOr7BQpBBQTP7EjJz+Dj4bqZdxYkC8ysE /g05bP/CnKSZ+3/HPp3XFaQ8vI8mK8UBPOmu/E17O8OmYhd9jV0GadJSz4fo4EWtJtwG gngA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jR5pSG9s; 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 oz16-20020a170906cd1000b006e8c12d426csi478079ejb.1002.2022.04.15.00.17.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 00:18:00 -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=jR5pSG9s; 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 8F60B83DEF; Fri, 15 Apr 2022 09:16:50 +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="jR5pSG9s"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5A83583D9B; Fri, 15 Apr 2022 09:16:40 +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 80D9683BF6 for ; Fri, 15 Apr 2022 09:16:37 +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 bx5so7024647pjb.3 for ; Fri, 15 Apr 2022 00:16:37 -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=jR5pSG9sV1qT0Wyxp1a9gwgl0i5jymBAhI9DJAhrAHDyzvxidauJw1ugQxWI56cg6k U1nRyQuoKzcb8LApVD5xtHI6RMq5A5g9Omz/ktwblKLH9FXBfFOdbExxhSYonLu4NkfS igY9JGHpq+bo/dGegf+KuncBqRF0xA51OmJXg3zFYlAOdEisgwpFNTOyNucmOq1//PBY d3xXVcaJoj2trLoGqw5aVMyaeFGe9Pd1KAssseWiKwppetMW2HV2WFRm4Y1I+O4JJVoL NxJOgSEDnjexZKxvFsmdQRf1CeXN0hJ7/Y5Ny6mVMxV7Ux5KeE2KgJLDegK8h10WWR1b bGYQ== 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=7kSgp9IYX7DdsG3fiirJjlWPtkjJHJK8uwfEXeD5c+NpJTUJloP+5hNtxnGy6tOMA1 BO1D7seZJwENwO5EBhFBNjbiiOTwu44EBHUlYIr5oT0DP8D06+YBZ8Uv0E+YhdB0hHPO o9IHs71F3G0RnWsiipzR3yI5IbTFc8UJ0o/tTpl7e8Mu1pljXW5y5ROWtGETAT85qbeC pnWJJ7X5epywqspJ9EWY/XeGinTfQGxLZKOz80JQAs37OqNfoZHm0z8vB36/yil7MpIq /S/0EdpMeFhI8d7wCZBV2wT0WIy2cEbqYsOTrGvMz1ADU2yYOr/AgJrf38+pW5FjHBWk ogLg== X-Gm-Message-State: AOAM5314k5nNCezoMCDko1+koVOGSWxUIabgYDr8t1zqgopMYCz+YkoM FDhczAIvs3RNbAQXzrKPcQ0uTg== X-Received: by 2002:a17:902:f612:b0:14c:e978:f99e with SMTP id n18-20020a170902f61200b0014ce978f99emr51196232plg.23.1650006995898; Fri, 15 Apr 2022 00:16:35 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c3e1:100:18f3:1e4:6c4:6ea3]) by smtp.gmail.com with ESMTPSA id p1-20020a17090a0e4100b001ce188720e5sm3566921pja.53.2022.04.15.00.16.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 00:16:35 -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 v4 09/12] efi_loader: disk: a helper function to delete efi_disk objects Date: Fri, 15 Apr 2022 16:15:43 +0900 Message-Id: <20220415071546.122475-10-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220415071546.122475-1-takahiro.akashi@linaro.org> References: <20220415071546.122475-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 Fri Apr 15 07:15:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 561946 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp115829map; Fri, 15 Apr 2022 00:18:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwN+N62xgdiTBd4S5suf+csuysdQixPB+OHsCCh+fGqTQ3ySvol2JrMcmnV88K3c31KO/YC X-Received: by 2002:a17:907:6287:b0:6e1:6ac:c769 with SMTP id nd7-20020a170907628700b006e106acc769mr5310407ejc.388.1650007090506; Fri, 15 Apr 2022 00:18:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650007090; cv=none; d=google.com; s=arc-20160816; b=fQu97eZt2ohchw/fp78Ic2teqFOpqBG97CBoe6/bzyn5oRFGKAgUWvYGl/075gIUsQ UdpBzbxTVDC8EiNDbE2JghYWJbqLqrU9NpqE3G/fW60Xo3VeLpdzU5uOu5zx7yuh2Oli Qtb1wDQmcfPKv/np+YYGJpOJMJnOWvYQn67Ixhthrtd+fumxazvQm41DbCgCdJTM84yL kXT9KuJHFtxZSQ73RAJDcZHX/KkhJtoK5M3ZqXVgRyeoU3DLcMsLbvEz+rZkncat6cj+ +uAygF0yGy22Zr8taeDflbQCYW/odBweAy80PxUZ2+jUdifTlcEsTgLsffmpY6JiYJuF wblg== 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=Y8YmNVkjNu8Cx5kXjY7TqgcEUFRl0MxoAHahqoo7O8/bwjE2nTJ5ehHBHpQW+D7vv0 9breA2jwLn9uYCeRt3YhZgp+IXhrDHG++7gUsrcWBqfZkqPfOZtMt+PawZUwElPFCSO3 r+/czBzK0/cK+Yxb835CVcPnkVlb2046uhkuDoikgJ/3g6oNYJ9V7Au9I6CPTEMNUhVw NaVsXhanubOAJEBdu8ncN42yThgZc+DtKD56UHe/2Yq/hpx4j9ARrHw1NIvLt5ArV7Bi dpNmn+xGIUugEvZPUS262mxqw0z9/5sg+rWrmAaBnS7GZ6to0wzUfXMI9QHr6QNyubAU P2iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xv3CpU8y; 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 n25-20020a05640206d900b00418e57d9986si593018edy.42.2022.04.15.00.18.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 00:18:10 -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=xv3CpU8y; 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 D908883E30; Fri, 15 Apr 2022 09:16: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="xv3CpU8y"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id ED15183D9B; Fri, 15 Apr 2022 09:16:42 +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-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) (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 B7A4283D8C for ; Fri, 15 Apr 2022 09:16:39 +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-pf1-x432.google.com with SMTP id s8so6693653pfk.12 for ; Fri, 15 Apr 2022 00:16:39 -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=xv3CpU8yn7+VwzBJt6JbZYXL5TwhUS473PIoTbgKaMAqUopKOVe/yb8frZ+iPxmHCn CwfM6YeV8QHEGNFnp9LpyNQrxCnuFiNGquHqq952vbTWkjm5xr/k9ICdJQAHp9hFQBVF nfMlqw9KuBo3nTwbk8ZKKSSnIFbbvoR8E777pxIxrxI51HaPvdXqmJJW247dahTZ/Qzt WEnFXeEyq2t8u3gQOZ66zLVgBJffY6w9RQKVz48eakAGwdex2Ilr5k5e9vzocnlS950q qVJv1Kru9k8FV+XA4ZiJ76KfUtjvHSf79NsKb9glwwDi+h3SM/JeWdhZElajeZG+b6el mWZw== 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=NToTUtbmUg7CGt2yTqfA6IIXxvFU6jN6y6q4XWBuWevz4Qc6oN1ElwfZulDXVsEFWP PaZIrcuSYIjzepfHpjSl63taIjqHGPmQAHdLwnIMDhqkRKYwEBKgQM1KVwcMFVacqzWZ 9Hl5GnbJeNB96B48nwtSuEOEU3p2ZGbZgVg6+HHC7j+qp+s72AXP8LxinJl+W2/ZR3QT LVHwi7znnJcADajYycctxinfElnrYVfABp9DI0cAj3cvbdg7Ep+nkpybmAJP4uaedvb2 4OhFEHeV1gwoIF14ZjsHsTDV20c9JOZRKjLBnWaPsV+bUyq6Vy6zc3ukaNm6mHALpCI+ uThw== X-Gm-Message-State: AOAM533LuFH8sG3qkoIp4PQwdnupOBkxWBfkfgnMbj5S5q6cdGn8NVy4 d4kF/RBaAbHJxlr/hdDtJ9Ctpg== X-Received: by 2002:a65:6951:0:b0:381:f10:ccaa with SMTP id w17-20020a656951000000b003810f10ccaamr5252905pgq.587.1650006998182; Fri, 15 Apr 2022 00:16:38 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c3e1:100:18f3:1e4:6c4:6ea3]) by smtp.gmail.com with ESMTPSA id p1-20020a17090a0e4100b001ce188720e5sm3566921pja.53.2022.04.15.00.16.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 00:16:37 -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 v4 10/12] efi_loader: disk: not delete BLK device for BLK(IF_TYPE_EFI_LOADER) devices Date: Fri, 15 Apr 2022 16:15:44 +0900 Message-Id: <20220415071546.122475-11-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220415071546.122475-1-takahiro.akashi@linaro.org> References: <20220415071546.122475-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 Fri Apr 15 07:15:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 561947 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp115920map; Fri, 15 Apr 2022 00:18:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy55pIUU4JsYcocDAW5k/vCv7aU6YJw/iRsBftROolwKxU/z7w5b6Ra+8FvVUFhLV1shgVE X-Received: by 2002:a17:906:4408:b0:6da:bec1:2808 with SMTP id x8-20020a170906440800b006dabec12808mr5153569ejo.543.1650007101651; Fri, 15 Apr 2022 00:18:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650007101; cv=none; d=google.com; s=arc-20160816; b=ex+Af64mjvud7d/jYs40R05QuADAIEkaZ6WCDdi347HKP2X2bH66kkTfr8rxI7EW+Z KiUgslKzsxOgQ9VEPCJ4JeImVmhwIKiPduFkgRyKlTtCVe/OnsLzcQ+h+zdvYSDQ2a+f /At8x/qDvVM8M9wWMZOc4u6yP8ccM98bzan1WfWKYmqLT+GH+9/+mePaelS5EJ4yyxVJ VAXYH02BPZHZbx3gb8sV0e+ELolTyv/lk6dsh5C4dLHR+8n4Mua5D/xmwcH2y0sBGyq7 NtgGJLVRCegP1jaPaE/IOZvQqJGq3bmugwaLRjT/33QwsNTXJs1T4HcRmnYzzdMIqwrr 6Wsg== 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=061GZJVSIIurGZJRV3GvyZc3JG4zYyc5UBd90jHpFIw=; b=nQVC/N8FRNC4NLVr02h/pjBTquPVGpMOtPgthrJfmBnAxMeFJoXpBbcWsx17PWgdwF t1v8Fvyga73RX5YnEVwM8qa31MjCRkwwDOTuwnNDGdiff/WIUryzrDdqpJ8SaTDErirj EPPpDG3Y3JcwkHokt9nLbBOGgjp8YNFIJ6oWUzzZJwNvVVcld7JGaGZXe9odtA1gEnWo PupdYXT63kUrPxipWmNwOzw+e7/czFac5uTWKfjvw9XQA4qrbqfmJuHJwCkqPIHXBN6d yVqv4YqCVwiGM5+LhogOzSV2GQoheV4W4och+Y40fqHdkDFp/5MjX2fI5Z24zZ0bTFIs zKjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j6i4TrmD; 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 j7-20020a05640211c700b0041d71714dc1si723005edw.420.2022.04.15.00.18.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 00:18: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=j6i4TrmD; 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 DEBBF83E0E; Fri, 15 Apr 2022 09:16: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=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="j6i4TrmD"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 509A1831CA; Fri, 15 Apr 2022 09:16:45 +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 16C72831CA for ; Fri, 15 Apr 2022 09:16: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-pj1-x1030.google.com with SMTP id md20-20020a17090b23d400b001cb70ef790dso11184853pjb.5 for ; Fri, 15 Apr 2022 00:16: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=061GZJVSIIurGZJRV3GvyZc3JG4zYyc5UBd90jHpFIw=; b=j6i4TrmDuygszmFgQDm5V9b236DKql/Gn3mgufqFndhGfh6TO5vIis5citEyLeCFDw 7HY4ju9JWRZm40wUjiDEJDT+XP6M5QhmkXrD+ynZlZZsyz4cqkQ0kRjAgZhMdlv5/WF4 BniEQnGvllq7zElFS6uASemzyp88uf0GQktubPoQob6YLNXkwIvUY75vvKlBqZZsJcYK O8pC+wwvLyAwIHphchc5DAVqVKxtA5xo+sPpKGegBsM4/ZetCE4sNFhBylPPgvd5I4Va wLIHxE3edA7ixA228iMCWSNzizWNhe563BHLH8yJiJXJUlrAumVJxPO3OsM1RMrK96jO RxuQ== 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=061GZJVSIIurGZJRV3GvyZc3JG4zYyc5UBd90jHpFIw=; b=wIAQxRzxuZXOYhMfqfxqDoQu7FZEL5T9O2m+VZooPZ+EVQ2dUU84ZVa1AqssUU8hrK ZOYKwiJs+cxSQu5ujZrRKAvvzItQvmNdxPRxSU4majEnr5alIumtiUfy/WoO+ZmOO6EE 3y51BMKiOZcPfLcF3iCNsC/btpMr0Loh3TkbqOAOWHcJEN85OlBHMNdZc1KIql6Iml9F TImKXu9tbeMqywFyx5MHukCUCluvRFuGfELlfcN33CH/jJWHeIr5A0gYCLFTmkoFOBd3 FjXPHHGB/yP2/JlnvuD16XFbbGYtI3EnkvKwxMMXQGY9s6XzQYXaoy1FxKqmjqzmfm4e klBQ== X-Gm-Message-State: AOAM531ZG+G7u+VodHFwkc+GEkrwzQ2cM0UGffKC8WkMp4KmtbOxh/+G liNSBuvdelZpyXY/SGOP0ZmWgA== X-Received: by 2002:a17:90a:4897:b0:1c7:5fce:cbcd with SMTP id b23-20020a17090a489700b001c75fcecbcdmr2699532pjh.45.1650007000523; Fri, 15 Apr 2022 00:16:40 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c3e1:100:18f3:1e4:6c4:6ea3]) by smtp.gmail.com with ESMTPSA id p1-20020a17090a0e4100b001ce188720e5sm3566921pja.53.2022.04.15.00.16.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 00:16: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 v4 11/12] dm: disk: add read/write interfaces with udevice Date: Fri, 15 Apr 2022 16:15:45 +0900 Message-Id: <20220415071546.122475-12-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220415071546.122475-1-takahiro.akashi@linaro.org> References: <20220415071546.122475-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 907c227aa20d..36b76f00563f 100644 --- a/include/part.h +++ b/include/part.h @@ -297,6 +297,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 Fri Apr 15 07:15:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 561948 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp116030map; Fri, 15 Apr 2022 00:18:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJy6IovcZWf+zp7HjBFUSsKeKykEt5l7pZjlVeUkcGW9oT4OrHOaB5PDkdF6dS0NUmniyT X-Received: by 2002:a17:906:5d14:b0:6e8:90d6:efe4 with SMTP id g20-20020a1709065d1400b006e890d6efe4mr5318419ejt.559.1650007113902; Fri, 15 Apr 2022 00:18:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650007113; cv=none; d=google.com; s=arc-20160816; b=gL8nXM1gqIBGBv4lAoAyo4ffdoPCEBOc2i/qmtBkb82/EEtp3aM7kFMyBD1QbZXGjA Eue+ky4+W+3TwsoGRfxj4MXuixZEydb5xK2MiItq6z1BBL8wG1glA+qZmIjmJaiDVTWi Jw47UZ/MQPiqqawscJCgIVmcvh6oiBKEW3iO8CTtV0x/1DzKzGCn/SuTXBOvPkXZEgCo Estk+FrVzfMHviXwmQspq/aZX7rLox0LeT6682j7AuvFv74UOlNCe3SNZsrUoJSz3R/n HTzSPsAdVloFJ6eEDgCq26rHMsP1Tzk67r59sBLfdN0fS7NlkwU0ms15+7AqWLFuWZzL 8DQw== 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=rNLLIfTuq1qKd/v07Kv5kb2TuLlTdjrx7M41nrSL5rY=; b=vinvqlyBLqK9IwvdCUA4pxG+8iRUPlsVHf9JqTgc7Xe++fapC0PiMiv3mpy3fZlGLg CXwQ0thlbzGbOVqxa3e1+/mLcEXOKBd1jJpoc6MQyZNJF3yiCKaToQawFIrLZ1QkrNAo qoRkMO2fMtLU+6bTF7qvIyYOSf953zQN7YLECkYnLcq4xTlIoRquesXB9HOMX5lDbA8P btuo//EMjGvmVZFjwa+dcsWV19xui7Yamc4bo3hNHx/5COF7sSwm7iehLyqsG9fYlseU wGggfYcwUkywDw66y5eOu0G8xF8NEH2RcQppTJ9G/xiTNwI5r2vCqr/vs2fjLyA+nsK+ 7KRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pyKGirvJ; 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 ec50-20020a0564020d7200b004190310aa85si545223edb.131.2022.04.15.00.18.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 00:18:33 -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=pyKGirvJ; 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 C657D83E3A; Fri, 15 Apr 2022 09:16:57 +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="pyKGirvJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BFDF783D44; Fri, 15 Apr 2022 09:16: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-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) (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 6722A83DBD for ; Fri, 15 Apr 2022 09:16: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-pl1-x632.google.com with SMTP id n8so6548939plh.1 for ; Fri, 15 Apr 2022 00:16: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=rNLLIfTuq1qKd/v07Kv5kb2TuLlTdjrx7M41nrSL5rY=; b=pyKGirvJwSBWxVNeko4RtaZqZIFjjyzKRGkKOOYt+gJTNRjPdPRadmeK17frUEfRA6 Te9Ffn+rLSJP7yRyiP3G5EE89u1IlcTmYP4SwEW1mvo5Ki/qGSE5skXrn+TFaldLCs1o dt+sNQlnhKdsoGq4SpwEzZ+bcWlZzA0s9bWAhjJhU/SbtmzZtkxoccKUWkZBDIm095Tc 71KhS54iQKFfNTFaqUPOvMXQo9CrGt6VfyQ3OimLImMXv2x7jPFlMYDM5vZ5TOVCxrJ2 JzWlxOJlUVIX6ZVh1oCsxwsTrszHcmwQ7XKIZGid+rn9JD/lVPYV/sa1nA2snirNBffw 4xbQ== 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=rNLLIfTuq1qKd/v07Kv5kb2TuLlTdjrx7M41nrSL5rY=; b=7OejnmZ4C52HyM6iLJwcRVXi1CU9HPWdq9VYMpzXURhK8YKQ1wHcK/fPUOyShXkswG ncons7r/InLOwuwnH1ecCNdiPBMKYF8wtVAoc15r8LwOXWhk5tLOWj3/KQf01VgO319/ EpE6qhTo3HPsXMcQ0/2J/ZGGR1pm76PEUdh3E8oTglnIm4wSP50zI3xfbhOdb0zKfwC6 juKCpOm2S1g2xeJNZKsoWrf52PnYRA9Ef9Ahtz/qPl1ZYZHUkdFmIqUJbp+h3iMdQsrR HForC+yDWySwZu5GuG5CK4rpSm3a+3akFX6WWPbThMo/OMK06jjw+5WsDpgnR1Q+53NW ERfw== X-Gm-Message-State: AOAM5338PaJ7RGQu4+FR4GVysfDr1Qddgul/ga+dJ0UhCa1HggrzrYHz 5GOl2x9jg0xfM7sgfD/Q0MabxncncU2LGg== X-Received: by 2002:a17:90b:4b0e:b0:1c6:f499:1cc9 with SMTP id lx14-20020a17090b4b0e00b001c6f4991cc9mr2737068pjb.133.1650007002863; Fri, 15 Apr 2022 00:16:42 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c3e1:100:18f3:1e4:6c4:6ea3]) by smtp.gmail.com with ESMTPSA id p1-20020a17090a0e4100b001ce188720e5sm3566921pja.53.2022.04.15.00.16.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 00:16: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 v4 12/12] efi_loader: disk: use udevice instead of blk_desc Date: Fri, 15 Apr 2022 16:15:46 +0900 Message-Id: <20220415071546.122475-13-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220415071546.122475-1-takahiro.akashi@linaro.org> References: <20220415071546.122475-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean In most of all cases, we can avoid using blk_desc which is expected to be private to udevice(UCLASS_BLK), that is, the data should not be manipulated outside the device driver unless really needed. Now efi_disk's internally use dev_read/write() interfaces. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- lib/efi_loader/efi_disk.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index 34bb662e9cc0..8ef493cc972e 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -36,7 +36,7 @@ const efi_guid_t efi_system_partition_guid = PARTITION_SYSTEM_GUID; * @part: partition * @volume: simple file system protocol of the partition * @offset: offset into disk for simple partition - * @desc: internal block device descriptor + * @dev: associated DM device */ struct efi_disk_obj { struct efi_object header; @@ -48,7 +48,7 @@ struct efi_disk_obj { unsigned int part; struct efi_simple_file_system_protocol *volume; lbaint_t offset; - struct blk_desc *desc; + struct udevice *dev; /* TODO: move it to efi_object */ }; /** @@ -83,14 +83,12 @@ static efi_status_t efi_disk_rw_blocks(struct efi_block_io *this, void *buffer, enum efi_disk_direction direction) { struct efi_disk_obj *diskobj; - struct blk_desc *desc; int blksz; int blocks; unsigned long n; diskobj = container_of(this, struct efi_disk_obj, ops); - desc = (struct blk_desc *) diskobj->desc; - blksz = desc->blksz; + blksz = diskobj->media.block_size; blocks = buffer_size / blksz; lba += diskobj->offset; @@ -102,9 +100,9 @@ static efi_status_t efi_disk_rw_blocks(struct efi_block_io *this, return EFI_BAD_BUFFER_SIZE; if (direction == EFI_DISK_READ) - n = blk_dread(desc, lba, blocks, buffer); + n = dev_read(diskobj->dev, lba, blocks, buffer); else - n = blk_dwrite(desc, lba, blocks, buffer); + n = dev_write(diskobj->dev, lba, blocks, buffer); /* We don't do interrupts, so check for timers cooperatively */ efi_timer_check(); @@ -446,7 +444,6 @@ static efi_status_t efi_disk_add_dev( diskobj->ops = block_io_disk_template; diskobj->ifname = if_typename; diskobj->dev_index = dev_index; - diskobj->desc = desc; /* Fill in EFI IO Media info (for read/write callbacks) */ diskobj->media.removable_media = desc->removable; @@ -522,6 +519,7 @@ static int efi_disk_create_raw(struct udevice *dev) return -1; } + disk->dev = dev; if (dev_tag_set_ptr(dev, DM_TAG_EFI, &disk->header)) { efi_free_pool(disk->dp); efi_delete_handle(&disk->header); @@ -578,6 +576,7 @@ static int efi_disk_create_part(struct udevice *dev) log_err("Adding partition for %s failed\n", dev->name); return -1; } + disk->dev = dev; if (dev_tag_set_ptr(dev, DM_TAG_EFI, &disk->header)) { efi_free_pool(disk->dp); efi_delete_handle(&disk->header);