From patchwork Wed Feb 2 01:08: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: 539301 Delivered-To: patch@linaro.org Received: by 2002:ac0:f7d2:0:0:0:0:0 with SMTP id i18csp1191115imr; Tue, 1 Feb 2022 17:10:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJzf/z+OWD4QetxVlhtcgQ3hJpbBTnBu4zAcfV19X2GIpmmd1AWZ1PTMromyHBvn2R/cYA3p X-Received: by 2002:a50:ab1a:: with SMTP id s26mr27460223edc.85.1643764203750; Tue, 01 Feb 2022 17:10:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643764203; cv=none; d=google.com; s=arc-20160816; b=Xtjr94ofa6DpgsxPGniM+YT3WfHu7m6Pos+vAfaWpIUKF5YxiErXD6DxUCX3F0jngj ks0B7bRVixtENaPcn+A0KspzOH1/ExiC1tgHiEC4ckaCTIEq536j3euWWukBg+VzAsxj iJEAJJZ2wJiJorKfUPOuJRkcDe63O1nS7ygqXlpWWzJiICpZaAcEOoQj4EY8va2fkWnj FZJGeIAt4o/sqtWIDIeuVh0gWwNw+8yyYo/JbWHAEDJPvV13Z34Cz0Ae7MPZ11LBDDyw aMxDYMlfOxrtOy4frhqGsf4FYSrmcmpS6uMF1mUkuIwT47x14YL4yycR5ItHgZEraLIH JPtw== 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=qmWo8ajh6FC3+J769E1n7+e/fv+fhY8AOmOHacKJHKs=; b=lf7eNzYkiz0wwH4VDlcVCqdYDDwvNa9hBjONGPAw4pZT/tYnQgpztA8ae1MJeORYv6 pPLt09VVsRlti20PftC8/nYJpNqbwOtMydEpDMYa/1k5ETVmHIeXhnAL49B92CFcTvGi ohVsol18lqUwY/Fci5pEl63A7ZNRwq0/vRWE2dwkH4l4CLHua131ua1S9uF8eYJAZw/r /jU2K+w39b+Rh0JvWPyo+g7+p7WAivD+DIlSdk2wKg/G5zqLnSNHmO8sCbSM7WWQIfSL /kJN4oJKBOPJlch9vFBWj43ZCrzRuXBl9dE1WVXeKRf3p1KMCU+IbCNo7fOGUGRZRGlp 00NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pIlkQN+8; 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 e10si10278599edj.463.2022.02.01.17.10.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:10:03 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pIlkQN+8; 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 E40C48389E; Wed, 2 Feb 2022 02:09:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="pIlkQN+8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D7D5882FA5; Wed, 2 Feb 2022 02:09:44 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-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 5B6F883384 for ; Wed, 2 Feb 2022 02:09:38 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pf1-x432.google.com with SMTP id a19so11449499pfx.4 for ; Tue, 01 Feb 2022 17:09:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qmWo8ajh6FC3+J769E1n7+e/fv+fhY8AOmOHacKJHKs=; b=pIlkQN+83wjPugEUiKQgdOZ1LXo6s1GhWm4aTbWyFMUBqwrhzvsrMKPjoy6YF2mnxi U4R49LjmjZrazppU2RMSk3v7BzvP5n4Aw6PDRWyJbvizoLPXToceebmeYMQYC42b+oNB YiMl0fhiAAAZwZOOQyFcV+CWWbC8u63xGbe+8gmMyPxSG8l5SSeMEIdk9VpjtuJrYJ8D r9yjHs2GDCNZk4eVXAgoAQnZg6a2kEpLr2r8342Up7FP23LCA+GwDRGeqoz/RP1jhuJ3 A8NZdqOkKqVx++7eZSXbepadLYTNg8+0+wJnrfS0RSlDaLvqZwn76B+lqA/Hwwf9oZNk PR2A== 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=qmWo8ajh6FC3+J769E1n7+e/fv+fhY8AOmOHacKJHKs=; b=JYdrnGr9HRklgcJ1yit4f9+fr4WXGFS2OcqN844XXBOuLDzZBzG/1Iui3rd3Joma6K 6OYZYlrdCI/yo9/HNFjtDWmHldKa/BuNz/RE4uCC98p1QM/iPJn1Qo+0ArjikZcbaA4d L1cMNvrmqGpi0krKWYmxkU+RV9xeuyvQ48b2b0ZhIZ+if+f3SbuGN/pCk+iuN7J7pagF t4NTY+2dAmasDJ7pqy7d2aZCJLGj1DwfrJsSusWyT8XwwxdcLtaR3n3BFpS27f3fqq+L aEm7izJAA7LDZMPsh1xmKSKtAmzED9P69ehb+XKawu4Mr/+koyr7BCn5fWUT3swNPcKV A0rw== X-Gm-Message-State: AOAM533ULqNG9nx1vTep7f/UJomhcUyjJI0IGO0Mi3gmBLnDCmO4SwoM WuNoQgfLz2U17MusLzLrK5Zacw== X-Received: by 2002:a05:6a00:2348:: with SMTP id j8mr25359139pfj.34.1643764171725; Tue, 01 Feb 2022 17:09:31 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:314e:b83b:fa90:7f2e]) by smtp.gmail.com with ESMTPSA id f5sm10761429pfc.0.2022.02.01.17.09.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:09:31 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH 01/19] scsi: call device_probe() after scanning Date: Wed, 2 Feb 2022 10:08:35 +0900 Message-Id: <20220202010853.40405-2-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220202010853.40405-1-takahiro.akashi@linaro.org> References: <20220202010853.40405-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 Every time a scsi bus/port is scanned and a new block device is detected, we want to call device_probe() as it will give us a chance to run additional post-processings for some purposes. In particular, support for creating partitions on a device will be added. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- drivers/scsi/scsi.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index d93d24192853..9a763ea78bbd 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -595,6 +595,11 @@ static int do_scsi_scan_one(struct udevice *dev, int id, int lun, bool verbose) ata_swap_buf_le16((u16 *)&bdesc->revision, sizeof(bd.revision) / 2); } + ret = blk_probe_or_unbind(bdev); + if (ret < 0) + /* TODO: undo create */ + return ret; + if (verbose) { printf(" Device %d: ", bdesc->devnum); dev_print(bdesc); From patchwork Wed Feb 2 01:08: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: 539300 Delivered-To: patch@linaro.org Received: by 2002:ac0:f7d2:0:0:0:0:0 with SMTP id i18csp1191060imr; Tue, 1 Feb 2022 17:09:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJwcoo2bO3m8GfOu8AlhbEOWb7KfVVzAAeEKcVLpRPOTf+XUNB6sPz8vDvrSnnNEdj3/ZM68 X-Received: by 2002:a17:907:1c8a:: with SMTP id nb10mr23173908ejc.273.1643764197666; Tue, 01 Feb 2022 17:09:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643764197; cv=none; d=google.com; s=arc-20160816; b=QyGq5O/5d6IeVZlHhotMs7Fck9o8qphGZcd3d9XuBHfRwYbbQMck8N4sR+4a6PYghv sFfQDMxaRCnyh99lmRLWUBLbaciYze4Cr3+0wnmQNvjch9GTWA7FzHf2AViwn3CIYu/b EJ7OShTnyGajuHozKK7y8fQK+z9hl4sjBRocz9eNifY4xVF6qa+G+8Rnjay6Zcjq1VuW XlM6MNce1dRlCFBjEnsGgvdCCdDijmWjWX8O2gqYpR1jCnyxyBaHSDfcxg5TEN+qQOQG ojGJbqNkxPHy5x7d4Xc1tbggpmQvw3eE1TpEQZ2VLQPIjuzs7rSeQj4n/R0pU01FB9C/ DElQ== 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=Y76P07ukuT1wREwWJsiB4J82LPFAi8f0WyRnmBNx5ts=; b=lMyxD489Rk0196UbzlAKDlXsELXR5eDJ+iyGEvjsJ4ufHnRZwsTp8Y3ZSccYkjb0/L FbabF1cC93z/BZAk10l20Aq1RkH9CrtE93TTL7FeAfw3F1yt8ffwYSckwTu9mCM8Lk8P LUEIkia02R38ifx331ffV9hmt7T8NnapT15w+OIN/gHzBKZ7ILGSoNnxasC4MQgsk2xt A6VVidhhK5JdGKa8YfApNTZU5jM20mQJmeUXP1WTLm6l030KDymJ/BMJR5wpVYVguDtB kp5zJPKJaxXbUPMR3qMLIfdhx21QBfl8bVV89dgPw1CIsvH1k9nUGPx7CeR3RFftTGkZ DrUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=x6JTsRpS; 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 13si9802092ejg.544.2022.02.01.17.09.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:09:57 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=x6JTsRpS; 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 869C08340A; Wed, 2 Feb 2022 02:09:45 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="x6JTsRpS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A1566830AB; Wed, 2 Feb 2022 02:09:43 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) (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 C350683845 for ; Wed, 2 Feb 2022 02:09:36 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pj1-x1032.google.com with SMTP id h20-20020a17090adb9400b001b518bf99ffso5212375pjv.1 for ; Tue, 01 Feb 2022 17:09:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Y76P07ukuT1wREwWJsiB4J82LPFAi8f0WyRnmBNx5ts=; b=x6JTsRpSTjCZaRSO3afW26E2YX/mv/hW7pEnVjzAknyl/5+yqdtjNP0UVzS0PM4LNg 9dKPkHLw+ofdFFyH4dqV1B33u11L13/7Mni64GA51uatGS0TjfG7t7W+7Qptkhndr/c1 q7YtdebnVGOfRGi3YsFN3PPbLcGClSUajAr2EWQ0YDx4RtK0roi0mRX2B1EGx8YNLqrx ktvOm6OlsNWmgjvPBlb0kU2BsYI7lYxSN2lajvIBEPhDTTGlIVwfAetfBWqtquxfDtfY a0QqtAT84aULApVAhqIiwTLzDztFCwLcLXNMKmBPNENONxWRCc46xkUjUVORpKBXGTjB DyTg== 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=Y76P07ukuT1wREwWJsiB4J82LPFAi8f0WyRnmBNx5ts=; b=0SERMVCw6CMjKSdjij02s89SKFdi/4OqZwwXzRVvLA1VUJUh58zLVDHRD72ybbafEy F7MwmZMuYxlA8xCIZ2GskrFAtG27sNIEQ4PMn/1CIZ65kxIPvFqfuM7Eb4o4wM36/rkU 74zSQdKE2XpXxobDHoP42O7xwL249CI4nLVN4/L33jvbls1x9UsUXAYRxY2bQlQhZedQ +iS8vYH8h+BBrxqGq9BGavkg9BawPL5BnpVo9LcZGb3VWp6zecle+3Qe4HWdfLvbLZPb 0btPh/0qGetNVjDYmmmJbchK1Qi1iIHNgsZrG6EPFHFA5YDd9Ha+GPawtzYAXZveum6t EAXg== X-Gm-Message-State: AOAM531YCSWEWaBOZmeazh5nPFNdje6AdRCtqMXMrlSUUb/lKdGo3sws IBytJWrQGO40eZC1P5uta8UyYg== X-Received: by 2002:a17:902:e852:: with SMTP id t18mr28386494plg.104.1643764175225; Tue, 01 Feb 2022 17:09:35 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:314e:b83b:fa90:7f2e]) by smtp.gmail.com with ESMTPSA id f5sm10761429pfc.0.2022.02.01.17.09.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:09:34 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH 02/19] usb: storage: call device_probe() after scanning Date: Wed, 2 Feb 2022 10:08:36 +0900 Message-Id: <20220202010853.40405-3-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220202010853.40405-1-takahiro.akashi@linaro.org> References: <20220202010853.40405-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 Every time a usb bus/port is scanned and a new device is detected, we want to call device_probe() as it will give us a chance to run additional post-processings for some purposes. In particular, support for creating partitions on a device will be added. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- common/usb_storage.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/usb_storage.c b/common/usb_storage.c index c9e2d7343ce2..291728f37e0a 100644 --- a/common/usb_storage.c +++ b/common/usb_storage.c @@ -239,6 +239,10 @@ static int usb_stor_probe_device(struct usb_device *udev) if (ret) return ret; } + + ret = blk_probe_or_unbind(dev); + if (ret) + return ret; } #else /* We don't have space to even probe if we hit the maximum */ From patchwork Wed Feb 2 01:08: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: 539304 Delivered-To: patch@linaro.org Received: by 2002:ac0:f7d2:0:0:0:0:0 with SMTP id i18csp1191366imr; Tue, 1 Feb 2022 17:10:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJzNehlyBteLRRuolt8V2ovf4iRlhdrVOaxWh3eFNK3THB+qLQWaW6Tp2S4pifvSxaibJ9YC X-Received: by 2002:a50:ab10:: with SMTP id s16mr27483216edc.382.1643764234522; Tue, 01 Feb 2022 17:10:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643764234; cv=none; d=google.com; s=arc-20160816; b=iIMgC6VhCRKZcwliRuU2pChcCqhaduTbmhL1GuLoy+t75yW+FtDrR0yMJeFvzqSMl/ Ekpb1YmekogXDayoo89jRxiyKpyfNM9HEJivKUmFqDa0Vf2i0jaieNULzYj1gdyGyw9l kFw7fQ509DuZn9GlXEvxXGoP3mmTOZoaVU0zZXlzcoAMQ02c0U/HcrmHKOkkWjj/lzro rYl56shjiZ3/IJkz1erm3Ub/Kew5QCpPPnN0CemqEjpADMNct9XeZjlTIuWvE+UlKmgG 7i5WmaO3JVq+kXZtvNjO18dQ8Di/34NJxcMRRag9hhxIzGmn197HeTHQlLL6I2/0Detb z09A== 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=y/HBlBYMaKXzB7YtVGHOXtoZiDFLDx7ETJhTTmoPvfs=; b=VfS8D5/8cJhiNMici8j1OBQwIemu5oDrj3zTShgykCKAn3wCLtg+QXMWHFaoHtSime brkWBetggXNxunTrwmQSBdgQUDZh/tdAO9fmTvMp0LGz6ZOWZEV/UpA9t35RaVfkHf/5 lnyKT1ML6XrxCyphcIzUwp5RO9E3oS7rHefB6Rb1WBSJqOI2aLqWFZqdxxXFdpIeAbBx PMkqx4usEMvzEAmp7cBPj2lBPYtm5QkWI81wPKy9joekqWZAquqD/yWgqi0PC0hnstyZ YTDmIqhuD8Bua6KeLEy6R4/ke834OIK+Lfo3oce6fq/+W58u+tYEjJGeNVYEFGxcIzNj zqyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EWZyjTIB; 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 g1si13680923ejt.939.2022.02.01.17.10.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:10:34 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EWZyjTIB; 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 BE0778388D; Wed, 2 Feb 2022 02:09:55 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="EWZyjTIB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E9BBC830AB; Wed, 2 Feb 2022 02:09:53 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) (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 8A8358341A for ; Wed, 2 Feb 2022 02:09:40 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pg1-x536.google.com with SMTP id g20so16918995pgn.10 for ; Tue, 01 Feb 2022 17:09:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=y/HBlBYMaKXzB7YtVGHOXtoZiDFLDx7ETJhTTmoPvfs=; b=EWZyjTIBZtQEvrwTM45lPPqGhOFaZxORuUk+Lp79eTsXRAx5IWpGSa7AX25MCAbtWa jGUAGncbDcquiJlLLe5WR7pnePKr6U5nYZMz/H9Aczo3J3Kjja3bQz8qT9H2arwC4T5Z 55H3c9JlLDR/YO1M1Y6ZEvjzrGnO1M7Lyzce/tq4UDzjk3xYa9ZYYNJ/k5HEl5E62vi7 QnwXlfcEwmgk1QrNTJ1v9gMGcyqOwAsupW5PX+9/qPzX3PGsoUwb7nuqGT0Ds7QQsYf3 K3gzlKkpZNLxiawWphHbCj5RV1nHQZaJCnS1iSB9PAlBYPH2FklzSEt3GPvsn9g2q9eT z/Ww== 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=y/HBlBYMaKXzB7YtVGHOXtoZiDFLDx7ETJhTTmoPvfs=; b=aH81iUz5kt7Kx3aiMeauEKzDZMyz/YIvOmVA7AsptADSQ2Nv9clTwoSyujZkhJV5GA RQoUovl7CNK7x3kNpctrTWwJ68bWF47tfNN/mHhXoc58XrlUMB35oSbdUz7BvE06PuyB zzaOZBPglOLbgPtvPETIl7z74jxEnKVVJIZo5E/04r40dBxhb3z7IDDymb98aTBGSgSU BSKRSlfKJiXCRzF6ixkPTshW1Vtwb5VFIpucKuT+RiE2I9S1cLPqYV9wUNq/ufskcRx5 YAlkKHApU7KniuAbPVZnnI/ClxligCB7vSuA7Rtp59m3zFsm11ED4r9YebxMWVlmhqSY KpLw== X-Gm-Message-State: AOAM533TT2WoQHhak5/EjKzLFbUq4A1fejQUtyiYefqOjgHFgtSa623Z e232xhAXY+JQMFG8lUneb+MCEA== X-Received: by 2002:a63:af08:: with SMTP id w8mr23234301pge.1.1643764178811; Tue, 01 Feb 2022 17:09:38 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:314e:b83b:fa90:7f2e]) by smtp.gmail.com with ESMTPSA id f5sm10761429pfc.0.2022.02.01.17.09.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:09:38 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH 03/19] mmc: call device_probe() after scanning Date: Wed, 2 Feb 2022 10:08:37 +0900 Message-Id: <20220202010853.40405-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220202010853.40405-1-takahiro.akashi@linaro.org> References: <20220202010853.40405-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 Every time a mmc bus/port is scanned and a new device is detected, we want to call device_probe() as it will give us a chance to run additional post-processings for some purposes. In particular, support for creating partitions on a device will be added. Signed-off-by: AKASHI Takahiro --- drivers/mmc/mmc-uclass.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c index b80e838066ca..e918f58a212e 100644 --- a/drivers/mmc/mmc-uclass.c +++ b/drivers/mmc/mmc-uclass.c @@ -467,6 +467,18 @@ static int mmc_blk_probe(struct udevice *dev) return ret; } + ret = device_probe(dev); + if (ret) { + debug("Can't probe\n"); + + if (IS_ENABLED(CONFIG_MMC_UHS_SUPPORT) || + IS_ENABLED(CONFIG_MMC_HS200_SUPPORT) || + IS_ENABLED(CONFIG_MMC_HS400_SUPPORT)) + mmc_deinit(mmc); + + return ret; + } + return 0; } From patchwork Wed Feb 2 01:08: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: 539303 Delivered-To: patch@linaro.org Received: by 2002:ac0:f7d2:0:0:0:0:0 with SMTP id i18csp1191242imr; Tue, 1 Feb 2022 17:10:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJzSZoVxXEk3qNvaMgrMqdYQKun30buCNvRpPwa0QFByzu35pSFcJp9/2UN3ngXog+jZCyWn X-Received: by 2002:a17:906:d54e:: with SMTP id cr14mr23768886ejc.692.1643764219292; Tue, 01 Feb 2022 17:10:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643764219; cv=none; d=google.com; s=arc-20160816; b=IXObOR7CsvjkXu+9z9JlDsFcPjhXd8QeYUy9tQeS1RRQtcpd+xcziOM4UnvhSsYFa1 LaFdOH5J6iX1mrDFuGOYxW0jMD3v7kJdNt82mwzc0DoyE2UGVr+xIqiD4v8eA2hTSXcR p3ZhVOwDUAS7bRga4VfQkulHcl1+UbsofC2J40QGaMeMYcN/zONOdovHspF0VUaMeZUs pTzFpAsEaBA+vpzOGywlOR7Gedc05Q3/z5G4XNql4+2VXnwY7nKBi5sndqY0zC4SNDa/ /vTe39LIudrsETA/C7rRPFAQFZJissY1lMgPUxVv/K+QpOgqaZnp+WJ+Wq4ebFdAuDzM AW2A== 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=bl8C1X+TOksXaJYBdDnrMAHxXq6nwVHHyloe9nAVxDA=; b=h8yvs0k8Cc4hAXpMrBkyfwdJHeEIjQ7vaTwNllgbNKHknoXxOAO15OKW0Q6adB6yTW +woq1sTui+znBhc/XMoYDq87DlkicRChpSOXFTOfrmaLO6rSrL6MMT8MS9Qa6noU7PLX VYrE+q/6+GVucel1aDgrISwQICNRUIEVVFEVcsLDafDnYkyb7HzKu101tOTx4doLyndV 8IGMby+kVTvR6TaCVuBpR7voGELJPn/jnKfha+Tmr7HKs6r6NaWelp6Ihz2qTe+dPcTC f04R+sYonEf/S3Z6tl8glyjSFx1eLM1A97RA8K8RpAlgE8XCKdfXf2So6zcBiScWOZT9 4NLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FiUSFygR; 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 g9si12393396edz.41.2022.02.01.17.10.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:10:19 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FiUSFygR; 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 70936838A5; Wed, 2 Feb 2022 02:09:51 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="FiUSFygR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 74354838A4; Wed, 2 Feb 2022 02:09:49 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE,T_SPF_TEMPERROR autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) (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 BDDF483845 for ; Wed, 2 Feb 2022 02:09:43 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pj1-x1034.google.com with SMTP id oa14-20020a17090b1bce00b001b61aed4a03so4402204pjb.5 for ; Tue, 01 Feb 2022 17:09:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bl8C1X+TOksXaJYBdDnrMAHxXq6nwVHHyloe9nAVxDA=; b=FiUSFygRUCxjD8WAA1ZRIzHbOmY9fAi3LI6gSRNp9RixbMhqrAh9EuaAIwV+9UjHQL DT01GK6oZ1CQcNTjv8ddRKvKjwr9CbQRjWi7pq/yg9Et0iOYopA8b5khWZ1fkvEx2jno gFxyY7oNdIUBJ16Uj7/l5WWuFvpT61it64QloIzlC7s2gKlyvSSRC3XlnJ3eZipxkKZB izNroNnl1YG2a31J7ulOg0iZqsSW6CoOX9Jl1eJJqq/lzDQqzbCuA1fKhoRQXQ5ZOmIq 3eYHCN0JZJvCE4Gkg2vRsiRL3cLG0Sf/OK6evHPto+W2tWK0fTdBPR3WJR/OxLs4vYr8 RYsw== 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=bl8C1X+TOksXaJYBdDnrMAHxXq6nwVHHyloe9nAVxDA=; b=edMvfAOjuk9JqbkpciJGYEc7qpg4PlpBv6z4bmJJVNAw9knWQsRPsqb6ew2S554Lkw 8gOV0oY9RC3qovZdHJ0/1wl6nvI7aA1ogs9n86ohMnh7uUmW1VHcWSICuKL+XKtKTo2w XHxMyPgWyy5LB6q1mUZsEq5bWrl/6JV6iN3TiBvdLhh2qxoCGbhGc7z4G1qQngQpA0xm 277DifuZcGY0O/N2v5bz/V+blStm7+wG2H5QRrPzTuI4Zta+7CKK02GZ9l4K9AJI9f6F QRGxZwc8mrEOxup48BxwZgsljmWUO/EJnDKJJEIWkDSWSi9k+l1Q9OKwP3SWfHKesVEL WCHw== X-Gm-Message-State: AOAM530HoHUEEmDsBnBiTaM0j+FANJ5c3XIlA4DJY9OS+wK42R2eZVw9 aWGskBJ0vrVjC+4rTwoC4l5mvw== X-Received: by 2002:a17:90b:23d4:: with SMTP id md20mr5366290pjb.199.1643764182200; Tue, 01 Feb 2022 17:09:42 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:314e:b83b:fa90:7f2e]) by smtp.gmail.com with ESMTPSA id f5sm10761429pfc.0.2022.02.01.17.09.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:09:41 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH 04/19] nvme: call device_probe() after scanning Date: Wed, 2 Feb 2022 10:08:38 +0900 Message-Id: <20220202010853.40405-5-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220202010853.40405-1-takahiro.akashi@linaro.org> References: <20220202010853.40405-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 Every time a nvme bus/port is scanned and a new device is detected, we want to call device_probe() as it will give us a chance to run additional post-processings for some purposes. In particular, support for creating partitions on a device will be added. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- drivers/nvme/nvme.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c index 3c529a2fce22..120a0f05a591 100644 --- a/drivers/nvme/nvme.c +++ b/drivers/nvme/nvme.c @@ -910,6 +910,10 @@ static int nvme_probe(struct udevice *udev) -1, 512, 0, &ns_udev); if (ret) goto free_id; + + ret = blk_probe_or_unbind(ns_udev); + if (ret) + goto free_id; } free(id); From patchwork Wed Feb 2 01:08: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: 539307 Delivered-To: patch@linaro.org Received: by 2002:ac0:f7d2:0:0:0:0:0 with SMTP id i18csp1191803imr; Tue, 1 Feb 2022 17:11:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJw3pba6oSE/94T9nLVKxWIJJPJrl4wk6sYXmSv/KpwCgsY/SGxxz52bemTY/oeGuZbRpbnk X-Received: by 2002:aa7:da44:: with SMTP id w4mr27737742eds.146.1643764283636; Tue, 01 Feb 2022 17:11:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643764283; cv=none; d=google.com; s=arc-20160816; b=M78TshKTsYrMTZCOpM0UoZcnznZ5xKPXXnPJ+iV8VuZadyoYD5JsQxdQSykqqhsUy4 ovwHuwO4EGv5HFEua4Z9VR6jhdMQfM8Y7w8Cz7du4w2fUOkGWaHHgv3b24ogzumgDDae nRjjDWDGSKe7pSBz5JKtqqXlv2ocHzvJcbW7cBHLA6ApdGERsGX5pNt3kvQyrwUW/zZe rTxPlzm92x0MflIKR6c/hHmENcoW4E/NEU1h6CDiolOaMck1kNHIKzLliOMsG+VBSvFd qzsrj6eMQ1NET7oUZPDPGgPCmXgTrbx+UVIbqMCiTq1hlerUpjbtxZ5beewqlU/Doov6 fiyQ== 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=tzYKj0DnTmjTUPdBVrRqbg9xnk+rMjSK/Bftseh2960=; b=sHfmnC72sImox68OUigJXJRmn7P2Tq46nU7I6hO30D1vqHeBOBjuaxIuF67PT4qX5u KZQ3upaoCUrfSfi20PoS+aN3efVrtBkDnZ4gy5bmfb7NjS5+Qpki2QOIGxTTRZcNma6f Zwll++BcoC8s633EPEnKiyK+MzJ+iDljAyQinuYHZmRA4TvfSmXvtpUZRm2YnGf3aFft RSCjuAW5mJM7P0etFslm2ZPcu7QMfLz+oXuT/evL3Wkz5ZlLwbtOjBpgueZ+MFZN6aP2 KKtNTcUVeTVW+7xgZE5L64Ed26FjHQDhdZnLTf84cLS5PGjp7zOc7jMcYFQwDCMhIayl ITgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XkwiShZN; 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 sa21si10815788ejc.979.2022.02.01.17.11.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:11:23 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XkwiShZN; 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 01FD0838D5; Wed, 2 Feb 2022 02:10:09 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="XkwiShZN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D4B4C838D5; Wed, 2 Feb 2022 02:10:06 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2240F838B6 for ; Wed, 2 Feb 2022 02:09:52 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pg1-x52a.google.com with SMTP id j10so16970575pgc.6 for ; Tue, 01 Feb 2022 17:09:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tzYKj0DnTmjTUPdBVrRqbg9xnk+rMjSK/Bftseh2960=; b=XkwiShZNxtUBVlzdt+mv5YYeMMlmMVdAl4eGGCrQ7hEB2lb2o/AQGH/AmjzQAcjN91 /nF+jT30jjEFeVR2O5FWPuF/wIkDvPF+T/Rn1gwTJA0BABPJM7iO6+PS8+bcPQ9SlAn2 NMfnD9n00Um4oBzB1lWwZbyopEZbCsPzag3nMX6mCH/IcWS7cIL1KeNW1Bza4qYbgVbA n/E6g5IPVqdyjZlxJO7no/9mdyKnYs/QTwW5dyyZKiBHrc0rH8edzyjQbo4fm+PtdQQS bGaxdYePnbNvsna4nrLxgvEd3FcPFNgwF1gX0kVHcOnzTaWD2oXDX05bPSp+hwBVuvPu 6KPw== 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=tzYKj0DnTmjTUPdBVrRqbg9xnk+rMjSK/Bftseh2960=; b=nZi1pBH8D7kHvvdaC4hD+BxlFADxLX+U9LS0ijXOx1O/NEGZu7IhUXQdx/98pob/H5 0qvVisLq64VvVcz80IPxpN6tpWedtYN9Fnvz/jyQ3s48qukEt2OQoo1oWn9l++Q5thH9 bS54d9sIGpdVtgMtSxG7R+0F2MMhfGgISpsGJ9cX/gigoGAO2olKOvhqzXQGNEYgvLuH tnLjPg2Ly+u/0iKYds4N4RjabjKk6voGamrfD7BY1T8GKTOs0G2fQWWjgXIysCBICeXK uv3u2phfgIRDxiLVALHR/CDDQ9fGwWsNXlJQx8PbXtWQkqVvdqeycltxROBOltVf4IjH we+A== X-Gm-Message-State: AOAM5323wjRqqZ339TufoL5MIUz+rikHVQD+iIhToLfcbhE9aBZgtqEq zCuHPlXQdGwhJkAlDLPi2kOu+A== X-Received: by 2002:a05:6a00:1256:: with SMTP id u22mr28165848pfi.82.1643764185524; Tue, 01 Feb 2022 17:09:45 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:314e:b83b:fa90:7f2e]) by smtp.gmail.com with ESMTPSA id f5sm10761429pfc.0.2022.02.01.17.09.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:09:45 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH 05/19] sata: call device_probe() after scanning Date: Wed, 2 Feb 2022 10:08:39 +0900 Message-Id: <20220202010853.40405-6-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220202010853.40405-1-takahiro.akashi@linaro.org> References: <20220202010853.40405-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 Every time a sata bus/port is scanned and a new device is detected, we want to call device_probe() as it will give us a chance to run additional post-processings for some purposes. In particular, support for creating partitions on a device will be added. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- drivers/ata/dwc_ahsata.c | 5 +++++ drivers/ata/fsl_sata.c | 11 +++++++++++ drivers/ata/sata_mv.c | 5 +++++ drivers/ata/sata_sil.c | 12 ++++++++++++ 4 files changed, 33 insertions(+) diff --git a/drivers/ata/dwc_ahsata.c b/drivers/ata/dwc_ahsata.c index 6d42548087b3..d9fd850c6fae 100644 --- a/drivers/ata/dwc_ahsata.c +++ b/drivers/ata/dwc_ahsata.c @@ -1026,6 +1026,11 @@ int dwc_ahsata_scan(struct udevice *dev) return ret; } + ret = blk_probe_or_unbind(dev); + if (ret < 0) + /* TODO: undo create */ + return ret; + return 0; } diff --git a/drivers/ata/fsl_sata.c b/drivers/ata/fsl_sata.c index e44db0a37458..346e9298b4c5 100644 --- a/drivers/ata/fsl_sata.c +++ b/drivers/ata/fsl_sata.c @@ -982,6 +982,17 @@ static int fsl_ata_probe(struct udevice *dev) failed_number++; continue; } + + ret = device_probe(bdev); + if (ret < 0) { + debug("Can't probe\n"); + ret = fsl_unbind_device(blk); + if (ret) + return ret; + + failed_number++; + continue; + } } if (failed_number == nr_ports) diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c index 003222d47be6..60666d551434 100644 --- a/drivers/ata/sata_mv.c +++ b/drivers/ata/sata_mv.c @@ -1099,6 +1099,11 @@ static int sata_mv_probe(struct udevice *dev) continue; } + ret = blk_probe_or_unbind(bdev); + if (ret < 0) + /* TODO: undo create */ + continue; + /* If we got here, the current SATA port was probed * successfully, so set the probe status to successful. */ diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c index dda712f42cb2..295f7ca72303 100644 --- a/drivers/ata/sata_sil.c +++ b/drivers/ata/sata_sil.c @@ -864,6 +864,18 @@ static int sil_pci_probe(struct udevice *dev) failed_number++; continue; } + + ret = device_probe(bdev); + if (ret < 0) { + debug("Can't probe\n"); + ret = sil_unbind_device(blk); + device_unbind(bdev); + if (ret) + return ret; + + failed_number++; + continue; + } } if (failed_number == sata_info.maxport) From patchwork Wed Feb 2 01:08: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: 539305 Delivered-To: patch@linaro.org Received: by 2002:ac0:f7d2:0:0:0:0:0 with SMTP id i18csp1191537imr; Tue, 1 Feb 2022 17:10:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJx4ZClzzJ7expcdwHuarfGfk/y52K3fzMGcLzrq7Az5aHa7zIhWSPwk3Sscb9XPRox/nqnX X-Received: by 2002:a17:906:489b:: with SMTP id v27mr16814549ejq.120.1643764254104; Tue, 01 Feb 2022 17:10:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643764254; cv=none; d=google.com; s=arc-20160816; b=SEEVrZyCzyo4IIV7hoktx8Bdi6B/1YVgl7yRpsWd9NxLr0qnJUDMcOjbsr/CkejVHm G6SAUFWEsyAFaCDgIC5C+yUcGUV/+oi8xZlJsnwKX+dfQ2XTKmSLSgxbAbvDUmYX69c8 mGCcl4nm043i0LfQcxSq/GXwRRSqqTqik4gZBCNVeDn8GHy66FNf2AjweGhCI2Bm0UYI tO/dfpQzVcV3ZfQp3uyh5Qdz5yq0e+Sjeu1KcObH1xkIg6c1RWkFPt1Q2dfgGxL45T5K Y0HNPg5mEO5EOYndmzgUuNBs+XzN31WQj/u2VbSCmOaZaU3+8ZcR08uIiY5UCfSVrCOk 4CWw== 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=XX0iEQ4dt4saQZhqaVxrcJum90hF8rJcNwW2ChZ7JxE=; b=MABPoj8ju7a/7zWSLSZHSsZgKCyk81+Zd4ByQU9vqo/Lsh2bgDTWQOQeig4E653m0w +tSHAU5NY1RWM0LN2496nlIEmQkq9xR3NwkKswO11JDUlC9AGnUpQPGoa1l+zijwYc0f +iVYW3fSBKnoWb1H8B3qTEOiud9PUUkNBRTs7S8fWvtOEykXJY978XUrMIqtG5IYdrad q3vsxWJeU1e6DijwRc3tDnBwRkhA6rt2Np4749h7FzfW55VCYSjVh0zTkrPnk5rTksTs 7UbugtNTHEe1BjdyFscnFlNnAKgDYWWIxV2DKiZEUjGAoouq9AtqjDE+28pHnqcONvby KS0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PKc9sYRG; 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 20si10124484ejj.384.2022.02.01.17.10.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:10:54 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PKc9sYRG; 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 7CDCC838A8; Wed, 2 Feb 2022 02:09:58 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="PKc9sYRG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3966883874; Wed, 2 Feb 2022 02:09:57 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9E955838A4 for ; Wed, 2 Feb 2022 02:09:50 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pj1-x1033.google.com with SMTP id s2-20020a17090ad48200b001b501977b23so5203436pju.2 for ; Tue, 01 Feb 2022 17:09:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XX0iEQ4dt4saQZhqaVxrcJum90hF8rJcNwW2ChZ7JxE=; b=PKc9sYRGhH32bgX9hZO4n4zBgKwmgRFY7UK5JVkYc6ynvc8CHeTj2XRKO4E1fGm2BP QeEYGQwCA6LxaCMbJdNIngkKU5R9CbATNLa3P/DaRfe4w7mt3Bpzl5Ik1mmfOh+A+Zwz sk7LqJR7wYJQ133qMUcyhU/Ukly0dN6ycgAz+q8nlWWhFh0cvhg1XkAxzHtSimJu7bKi 3EVOSC6lhfOD3GCakp0D+hMPjS6xRevLo4eDeWR/5Vnb+6/e0m9hKXzzIGaFgqtsvs+J mLUl4IB71802AGuI3/cboDfYIakYJmBGMF0XIVtXHOjaQdgle8dNoF35gw7TaKZgvHBf Oljw== 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=XX0iEQ4dt4saQZhqaVxrcJum90hF8rJcNwW2ChZ7JxE=; b=3XuCsrbEDQWv6vntbuF5Wy7gkpyuoxR1pFfhqYqwe/G/MLo8W8nXJiwc1pEALCK8vh HwWm5vu1mHnkq1twMKJ5ImaOGsmA2PnWcqSC3j/Z6ZjWZVpwvZi90OayzqcqffbIptRz kwLEGkFNjBI8xwq+/1dIbBhbeosucSepxrf9V8l+y0/jieH6st77n/2XZ/TB9P06Tebn 5dUYcl6wTPEeuArgdvW0YocWauiwLKs5GmOTUA2xZhyn+c9VyxdHbYp0EOGS2w4pbdi+ mmKV6uvZY4ppXplc43FHdX26jPN+0ucQIjAshYF8+Ah7QCfx5vaAZaWqFZwoCvEIg2gD tbag== X-Gm-Message-State: AOAM532DutxB1E/rjdq1ovBGFCjhJHyTfodfW+b533VsBfBLB0fUywHr Sq9qXeY5bwKNGWHp/l0QZ1qP0Q== X-Received: by 2002:a17:902:8344:: with SMTP id z4mr28860264pln.12.1643764189062; Tue, 01 Feb 2022 17:09:49 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:314e:b83b:fa90:7f2e]) by smtp.gmail.com with ESMTPSA id f5sm10761429pfc.0.2022.02.01.17.09.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:09:48 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH 06/19] block: ide: call device_probe() after scanning Date: Wed, 2 Feb 2022 10:08:40 +0900 Message-Id: <20220202010853.40405-7-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220202010853.40405-1-takahiro.akashi@linaro.org> References: <20220202010853.40405-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 Every time an ide bus/port is scanned and a new device is detected, we want to call device_probe() as it will give us a chance to run additional post-processings for some purposes. In particular, support for creating partitions on a device will be added. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- drivers/block/ide.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/block/ide.c b/drivers/block/ide.c index 085aa356feef..a96df4f0a3c7 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -1145,6 +1145,10 @@ static int ide_probe(struct udevice *udev) blksz, size, &blk_dev); if (ret) return ret; + + ret = blk_probe_or_unbind(blk_dev); + if (ret) + return ret; } } From patchwork Wed Feb 2 01:08: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: 539306 Delivered-To: patch@linaro.org Received: by 2002:ac0:f7d2:0:0:0:0:0 with SMTP id i18csp1191623imr; Tue, 1 Feb 2022 17:11:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJymvVDAdibBf08Yuuquy3VRQHO4M6/FKgij036Eg2oWhqpnS/vnFDO2eQNo944rxxkziwdy X-Received: by 2002:a05:6402:220c:: with SMTP id cq12mr27721284edb.138.1643764263968; Tue, 01 Feb 2022 17:11:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643764263; cv=none; d=google.com; s=arc-20160816; b=jDJgrmBQIk1q63NEhCpzaviDCrIap+Qh1/9T34WhYqhInf57k1pflfn4vTNINeXw13 qJh/X9f2b6oPvmmXltQjVnO8wqy9ijuRgLiWPh6htNkV9mxWr1fwuW6a4m00m8hlkl14 fDWUMoZ069WFMzmf408guPYnSdnxlF7kt/b1g7wo1LzlWUoE5XIQJPp1CHgLWkWYIDyr xwGe9hiq/ChaZ44Zu1aeiAZbVYXa7pvDoHaBbEusApM7NS4Gr/uhgci2sRkzRtO2Ji9y QPmHFDljU73dmwuAOStyr2MqpM9QfpJ8YvpmtiTr+KBKDeQBgGtBbu9Ff34md33GYaLe n16g== 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=UxiGG5EcxKzIREA6492c+Lci6IAn9Kg1DDcRwiFlG4U=; b=s+Ori/CyN4cGWTMI5I/KYTHPnuJ/cx2qC4b6PMQpj6lqZdFoZejcpxFnO9PkUaCkWk rjPY2i3WSsL5X3DYxAJxB8DqBSeOgwNuzfak0/9afoNaXTOz42nlQSrvg3//S2+T1ZG6 Wh/kax2BIl7k+xUJZMO+M1Cmp6GilUJo6apJgdRgaKNr2W6zUNrajh/KW7rDIKwVs4Qt ybPDx7WxkPqFfJXXdf427k4+NXi/nv55xAXJRZTJl1XBBx6aSh4edcMghyRLzUDURvRc 9nHIlSmkelraFYfALFqGju2gWR1mHz7NUmgNrbzrPnl0GCq8ZcVMHhjeBuW795drtR5C LfAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DCgklVRn; 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 t21si2411213edv.651.2022.02.01.17.11.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:11:03 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DCgklVRn; 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 275988387F; Wed, 2 Feb 2022 02:10:05 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="DCgklVRn"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1B08F838C3; Wed, 2 Feb 2022 02:10:03 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=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 06A84831B5 for ; Wed, 2 Feb 2022 02:09:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pj1-x102d.google.com with SMTP id h20-20020a17090adb9400b001b518bf99ffso5213074pjv.1 for ; Tue, 01 Feb 2022 17:09:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UxiGG5EcxKzIREA6492c+Lci6IAn9Kg1DDcRwiFlG4U=; b=DCgklVRnyoYkYZJ+nQRuSzpSopbNRQwuibW+kM8e9rciwJ/HYcoK5OMoTrqVuRLUAK QCMBrT368ylykedZuZ1ws5nKMG8YIPBc7Wzc2nb7kANTcZHYsm4udrwkvUO2Pys5qzR2 qrPSSsjOXKbabAauXYB/rVS849yZDwpFu2ENPNUXUhtpo8060iN59LJjpGk5VFR073SO NO/bAx0mGPreDngx0s7rGo47kXAd8sliyYSp7RHdIWrtw+JhcuGYUVkYpc/tpThgidxu xCqRD1Ib/6uHpW+JnF8dhNe32pI+d9paMQ7UX7LuI6AKUwqZ94UHMyM1wBYh2M25KlBL GfnA== 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=UxiGG5EcxKzIREA6492c+Lci6IAn9Kg1DDcRwiFlG4U=; b=BcTLRKP3gYqoTajj9lOcc+fPAp1cSjYsP0AtOJjj6hX6zcRtfpT3eFbs7I3Q89Bp1N 2Vr5UlBmFN5ZQnZKR/cqJkc64UyNZcMuMAapjmtp/7YQOCCp0PEpuTnbD68nGGo8s45F 3QB6llJTXA+fYWBZ9BGWulhDDaC6NAxinWdxgUYcJPOIDeULK6NJvZ0bjiSOSFniX/F4 VI5tPoqfbyYsykwdOq1kcYmLfOljirHusQVYo8XrD6jZT7S65VcKVahjYYJLTmm9ftYG uxAW9HdwTQkO8LROrwYTt7kiLnwSLh3uqX/FIHAOvMtpirCx4VBO8YvsDZ/XdErTsSK0 mNWg== X-Gm-Message-State: AOAM532MmFU+FP9oLGBvtusGt8iMm94Pm5eiNu7hy9aAnpR2dj+hGoNU 1dvsZ0zhM2wJ77oqJgi3RlytaA== X-Received: by 2002:a17:90a:e284:: with SMTP id d4mr5355453pjz.5.1643764192410; Tue, 01 Feb 2022 17:09:52 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:314e:b83b:fa90:7f2e]) by smtp.gmail.com with ESMTPSA id f5sm10761429pfc.0.2022.02.01.17.09.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:09:52 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH 07/19] virtio: call device_probe() in scanning Date: Wed, 2 Feb 2022 10:08:41 +0900 Message-Id: <20220202010853.40405-8-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220202010853.40405-1-takahiro.akashi@linaro.org> References: <20220202010853.40405-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 virtio_init() enumerates all the peripherals that are to be materialised with udevices(UCLASS_VIRIO) and creates particular device instances (UCLASS_BlK or whatever else) as children. On the other hand, device_probe() won't be invoked against those resultant udevices unlike other ordinary device drivers do in the driver model. This is particularly incovenient when we want to add "event notification" callback so that we will be able to automatically create all efi_disk objects in a later patch. With this patch applied, "virtio scan" will work in a similar way to "scsi rescan", "usb start" or others in term of 'probe' semantics. I didn't add this change to virtio_init() itself because this function may be called in board_init_r() (indrectly in board_late_init()) before UEFI subsustem is initialized. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- cmd/virtio.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/cmd/virtio.c b/cmd/virtio.c index 3dace5344f7e..ea3ed2e631e4 100644 --- a/cmd/virtio.c +++ b/cmd/virtio.c @@ -17,8 +17,25 @@ static int do_virtio(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { if (argc == 2 && !strcmp(argv[1], "scan")) { - /* make sure all virtio devices are enumerated */ - virtio_init(); + /* + * make sure all virtio devices are enumerated. + * Do the same as virtio_init(), but also call + * device_probe() for children (i.e. virtio devices) + */ + struct udevice *bus, *child; + int ret; + + ret = uclass_first_device(UCLASS_VIRTIO, &bus); + if (ret) + return CMD_RET_FAILURE; + + while (bus) { + device_foreach_child_probe(child, bus) + ; + ret = uclass_next_device(&bus); + if (ret) + break; + } return CMD_RET_SUCCESS; } From patchwork Wed Feb 2 01:08: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: 539309 Delivered-To: patch@linaro.org Received: by 2002:ac0:f7d2:0:0:0:0:0 with SMTP id i18csp1192031imr; Tue, 1 Feb 2022 17:11:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJzMUyomtoxmdxW0EJHsgYjYPTS5fR6RkiXBgE98KFl14B8Y8Z1ezboed7Yn1w4dkjmwELEQ X-Received: by 2002:a05:6402:f19:: with SMTP id i25mr27968736eda.91.1643764313601; Tue, 01 Feb 2022 17:11:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643764313; cv=none; d=google.com; s=arc-20160816; b=nAJty2/0MOUqE119flPx0U+pQOwDKV11wfyDv23wmhs8XPAXyG9i5cPuE1/yDbMTdd CcJ8b2OHLGT4Gy3frlyr4WOTk3RV+ZbdWYlCI4i8MVFj36GJwFX/iX1PSrVXg4+XUFLP wPxegCkIDUloTk6TSYjNerdMWfXo8Yfh2DPM3JaUIZTdQq+HkUx8fwIUyUyR/tba8opx 8I1f36bqSqaTi4M8/FwH26xhpcmgWahbLpTCqWPIF+CGHdDODKqYEXDK78QVgkz2OI9Y crXGIN4JDgWXHiScMlyeAz09yQ8kQb23UiXR85uDUZZ5g//9dTMfhc0l98SIqm7Pr1aR JBlA== 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=w7bTS5X0qC7tGEFe9I/AeP66sTQaBgLsEZfJnN0baQg=; b=bD/rHbyHgsaTqg6KGxUnWzcQKyAfAoOEswDIB50iQP02AdfG+faoMfpy4ywIvGQezU fhu45zvwOwR1J/88cMybKi0wBYhB8TS1hmQ1EHtltkmy+MY5zGKx+Z6wdeUnb5baaZtO JTEBuHhEIJWcrDglyJJxNPFmBgF4Cb8nhcIUIy6O0dSt9p56lOLqc7q3oIgI/CXtOxaR gPfN9LHvaQ2oClQov453SHDQC4R+TQ0LeEBRQSPZinMs0T7eN6NKbqgdbdfnqpcmnGby EuA9wPO9vs1XKyy/6u1OdDiRY4GiETM2eOkT/7TaquarzpYA6LWGIAXqOyQBHgMEJL1b XnPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UFOdUWUu; 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 2si9993287ejl.736.2022.02.01.17.11.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:11:53 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UFOdUWUu; 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 67103838E5; Wed, 2 Feb 2022 02:10:18 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=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="UFOdUWUu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BF075838D8; Wed, 2 Feb 2022 02:10:13 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) (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 E3190838D4 for ; Wed, 2 Feb 2022 02:09:57 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pj1-x1034.google.com with SMTP id b1-20020a17090a990100b001b14bd47532so4439202pjp.0 for ; Tue, 01 Feb 2022 17:09:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=w7bTS5X0qC7tGEFe9I/AeP66sTQaBgLsEZfJnN0baQg=; b=UFOdUWUujLmw/kOtCXvdHIlaYdkl5j0YZi3mu0SiCWCVmyS7SziV2clwTJTsLSIX+0 13Rz9X3C5p0siCnnLdFs2/0X87BXUjgBsDg1JUZroJMs4cCqPfOpwGcl3VzGKXfUsFZv lgMsU9Zta0s3gEaF/FevpGT7hdG+BaMKbuJMl80jbJsinwhW+iZbvY+K2rvJ+mNl8ccx kWsaGtGGXlhZVVTge4uIjqB1R+XFDAw5bMfQjJoZjm/WW6oqFTcIxXiYgeWTDCvsS+IG om4qNMFPgAOK9YqpGgO71fecs2Kn2lUoUxlAaBYwDQLtgVTrByM1b57+zP/k7p+0ROJl JxKw== 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=w7bTS5X0qC7tGEFe9I/AeP66sTQaBgLsEZfJnN0baQg=; b=qc2xSUJB3fw9H+AJvn0QlFtFdTzpTjmN+o08uXe+znS6LPfk/TTSYI0TYlkDtJQsQN ncPtFzJ1ni+RaeuVjIWvgCzanJ5D3xShXTsru/oHoMynyBZXxWSY7RLTXfyObQFeTlVh d9jurrFljre12XOHtGvmO3vZqLrAxBTz3H4DvCIRLWsdjSyZ6GIdHU09kMvMOeVWA+B6 GS9kHZOaf8xdxFB26Y/q/dneFJBWfOaT4uelKEbB82p6E7sXbrFV6haHDnrYW13WNlGK bsBRAw6nfjwkqcMQs87zveXAONvZjm3mnKp+NFzZaLED/mH6aOQXcee3eXiJGGPSoOw+ EyPQ== X-Gm-Message-State: AOAM5323J2utMzp4IpjDQN5Rf2L1W5huP2QYjGPYK0Ihh7PA8gmbB2zD GlDV5B2MAWD0vx2rV+tCCQXqIg== X-Received: by 2002:a17:902:d355:: with SMTP id l21mr26838189plk.128.1643764196143; Tue, 01 Feb 2022 17:09:56 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:314e:b83b:fa90:7f2e]) by smtp.gmail.com with ESMTPSA id f5sm10761429pfc.0.2022.02.01.17.09.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:09:55 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH 08/19] dm: add event notification Date: Wed, 2 Feb 2022 10:08:42 +0900 Message-Id: <20220202010853.40405-9-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220202010853.40405-1-takahiro.akashi@linaro.org> References: <20220202010853.40405-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 From: Simon Glass This is a draft implementation of event notification mechanism from Simon. Under this scheme, any U-Boot subsystem can register some kind of callback function to a particular event (more event types will be added later) and that function will be invoked once the event is fired. As a first user, UEFI subsystem makes use of PROBE and REMOVE events so that we will be able to automatically create/remove efi_disk objects relying on associated block devices (UCLASS_BLK). To run the test: ./u-boot -T -c "ut common test_event_probe" Signed-off-by: Simon Glass [add REMOVE event; fix checkpatch warnings] Signed-off-by: AKASHI Takahiro --- common/Kconfig | 11 ++++ common/Makefile | 2 + common/board_f.c | 2 + common/event.c | 103 +++++++++++++++++++++++++++++ common/log.c | 1 + drivers/core/device-remove.c | 9 +++ drivers/core/device.c | 9 +++ include/asm-generic/global_data.h | 3 + include/dm/device-internal.h | 10 +++ include/event.h | 105 ++++++++++++++++++++++++++++++ include/event_internal.h | 34 ++++++++++ include/log.h | 2 + test/common/Makefile | 1 + test/common/event.c | 87 +++++++++++++++++++++++++ test/test-main.c | 5 ++ 15 files changed, 384 insertions(+) create mode 100644 common/event.c create mode 100644 include/event.h create mode 100644 include/event_internal.h create mode 100644 test/common/event.c diff --git a/common/Kconfig b/common/Kconfig index 82cd864baf93..d411e5bf7a50 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -492,6 +492,17 @@ config DISPLAY_BOARDINFO_LATE menu "Start-up hooks" +config EVENT + bool "General-purpose event-handling mechanism" + default y if SANDBOX + help + This enables sending and processing of events, to allow interested + parties to be alerted when something happens. This is an attempt to + step the flow of weak functions, hooks, functions in board_f.c + and board_r.c and the Kconfig options below. + + See doc/develop/event.rst for more information. + config ARCH_EARLY_INIT_R bool "Call arch-specific init soon after relocation" help diff --git a/common/Makefile b/common/Makefile index 3eff71960160..4e9f59cc07ad 100644 --- a/common/Makefile +++ b/common/Makefile @@ -89,6 +89,8 @@ obj-y += malloc_simple.o endif endif +obj-$(CONFIG_EVENT) += event.o + obj-$(CONFIG_$(SPL_TPL_)HASH) += hash.o obj-$(CONFIG_IO_TRACE) += iotrace.o obj-y += memsize.o diff --git a/common/board_f.c b/common/board_f.c index a68760092ac1..e36bdbc988fa 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -828,6 +829,7 @@ static const init_fnc_t init_sequence_f[] = { initf_malloc, log_init, initf_bootstage, /* uses its own timer, so does not need DM */ + event_init, #ifdef CONFIG_BLOBLIST bloblist_init, #endif diff --git a/common/event.c b/common/event.c new file mode 100644 index 000000000000..428628da44d6 --- /dev/null +++ b/common/event.c @@ -0,0 +1,103 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Events provide a general-purpose way to react to / subscribe to changes + * within U-Boot + * + * Copyright 2021 Google LLC + * Written by Simon Glass + */ + +#define LOG_CATEGORY LOGC_EVENT + +#include +#include +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +static void spy_free(struct event_spy *spy) +{ + list_del(&spy->sibling_node); +} + +int event_register(const char *id, enum event_t type, event_handler_t func, void *ctx) +{ + struct event_state *state = gd->event_state; + struct event_spy *spy; + + spy = malloc(sizeof(*spy)); + if (!spy) + return log_msg_ret("alloc", -ENOMEM); + + spy->id = id; + spy->type = type; + spy->func = func; + spy->ctx = ctx; + list_add_tail(&spy->sibling_node, &state->spy_head); + + return 0; +} + +int event_notify(enum event_t type, void *data, int size) +{ + struct event_state *state = gd->event_state; + struct event_spy *spy, *next; + struct event event; + + event.type = type; + if (size > sizeof(event.data)) + return log_msg_ret("size", -E2BIG); + memcpy(&event.data, data, size); + list_for_each_entry_safe(spy, next, &state->spy_head, sibling_node) { + if (spy->type == type) { + int ret; + + log_debug("Sending event %x to spy '%s'\n", type, + spy->id); + ret = spy->func(spy->ctx, &event); + + /* + * TODO: Handle various return codes to + * + * - claim an event (no others will see it) + * - return an error from the event + */ + if (ret) + return log_msg_ret("spy", ret); + } + } + + return 0; +} + +int event_uninit(void) +{ + struct event_state *state = gd->event_state; + struct event_spy *spy, *next; + + if (!state) + return 0; + list_for_each_entry_safe(spy, next, &state->spy_head, sibling_node) + spy_free(spy); + + return 0; +} + +int event_init(void) +{ + struct event_state *state; + + state = malloc(sizeof(struct event_state)); + if (!state) + return log_msg_ret("alloc", -ENOMEM); + + INIT_LIST_HEAD(&state->spy_head); + + gd->event_state = state; + + return 0; +} diff --git a/common/log.c b/common/log.c index f7e0c0fbf556..7254aa70bfdf 100644 --- a/common/log.c +++ b/common/log.c @@ -28,6 +28,7 @@ static const char *const log_cat_name[] = { "devres", "acpi", "boot", + "event", }; _Static_assert(ARRAY_SIZE(log_cat_name) == LOGC_COUNT - LOGC_NONE, diff --git a/drivers/core/device-remove.c b/drivers/core/device-remove.c index e6ec6ff42121..c3f8ed3e5721 100644 --- a/drivers/core/device-remove.c +++ b/drivers/core/device-remove.c @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -207,6 +208,10 @@ int device_remove(struct udevice *dev, uint flags) if (!(dev_get_flags(dev) & DM_FLAG_ACTIVATED)) return 0; + ret = device_notify(dev, EVT_DM_PRE_REMOVE); + if (ret) + return ret; + /* * If the child returns EKEYREJECTED, continue. It just means that it * didn't match the flags. @@ -256,6 +261,10 @@ int device_remove(struct udevice *dev, uint flags) dev_bic_flags(dev, DM_FLAG_ACTIVATED); + ret = device_notify(dev, EVT_DM_POST_REMOVE); + if (ret) + goto err_remove; + return 0; err_remove: diff --git a/drivers/core/device.c b/drivers/core/device.c index 901c1e2f7db3..6f69b234a182 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -493,6 +494,10 @@ int device_probe(struct udevice *dev) if (dev_get_flags(dev) & DM_FLAG_ACTIVATED) return 0; + ret = device_notify(dev, EVT_DM_PRE_PROBE); + if (ret) + return ret; + drv = dev->driver; assert(drv); @@ -597,6 +602,10 @@ int device_probe(struct udevice *dev) dev->name, ret, errno_str(ret)); } + ret = device_notify(dev, EVT_DM_POST_PROBE); + if (ret) + goto fail; + return 0; fail_uclass: if (device_remove(dev, DM_REMOVE_NORMAL)) { diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index c2f8fad1cb92..9f4598f09ee5 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -467,6 +467,9 @@ struct global_data { */ char *smbios_version; #endif +#if CONFIG_IS_ENABLED(EVENT) + struct event_state *event_state; +#endif }; #ifndef DO_DEPS_ONLY static_assert(sizeof(struct global_data) == GD_SIZE); diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h index 02002acb787c..63074e1de509 100644 --- a/include/dm/device-internal.h +++ b/include/dm/device-internal.h @@ -10,6 +10,7 @@ #ifndef _DM_DEVICE_INTERNAL_H #define _DM_DEVICE_INTERNAL_H +#include #include #include @@ -426,4 +427,13 @@ static inline void devres_release_all(struct udevice *dev) } #endif /* ! CONFIG_DEVRES */ + +static inline int device_notify(const struct udevice *dev, enum event_t type) +{ +#ifdef CONFIG_EVENT + return event_notify(type, &dev, sizeof(dev)); +#else + return 0; +#endif +} #endif diff --git a/include/event.h b/include/event.h new file mode 100644 index 000000000000..e2b74e6e62f0 --- /dev/null +++ b/include/event.h @@ -0,0 +1,105 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Events provide a general-purpose way to react to / subscribe to changes + * within U-Boot + * + * Copyright 2021 Google LLC + * Written by Simon Glass + */ + +#ifndef __event_h +#define __event_h + +/** + * enum event_t - Types of events supported by U-Boot + * + * @EVT_DM_PRE_PROBE: Device is about to be probed + */ +enum event_t { + EVT_NONE, + EVT_TEST, + + /* Events related to driver model */ + EVT_DM_PRE_PROBE, + EVT_DM_POST_PROBE, + EVT_DM_PRE_REMOVE, + EVT_DM_POST_REMOVE, + + EVT_COUNT +}; + +union event_data { + /** + * struct event_data_test - test data + * + * @signal: A value to update the state with + */ + struct event_data_test { + int signal; + } test; + + /** + * struct event_dm - driver model event + * + * @dev: Device this event relates to + */ + struct event_dm { + struct udevice *dev; + } dm; +}; + +/** + * struct event - an event that can be sent and received + * + * @type: Event type + * @data: Data for this particular event + */ +struct event { + enum event_t type; + union event_data data; +}; + +/** Function type for event handlers */ +typedef int (*event_handler_t)(void *ctx, struct event *event); + +/** + * event_register - register a new spy + * + * @id: Spy ID + * @type: Event type to subscribe to + * @func: Function to call when the event is sent + * @ctx: Context to pass to the function + * @return 0 if OK, -ve on erropr + */ +int event_register(const char *id, enum event_t type, event_handler_t func, + void *ctx); + +/** + * event_notify() - notify spies about an event + * + * It is possible to pass in union event_data here but that may not be + * convenient if the data is elsewhere, or is one of the members of the union. + * So this uses a void * for @data, with a separate @size. + * + * @type: Event type + * @data: Event data to be sent (e.g. union_event_data) + * @size: Size of data in bytes + */ +int event_notify(enum event_t type, void *data, int size); + +#if CONFIG_IS_ENABLED(EVENT) +int event_uninit(void); +int event_init(void); +#else +static inline int event_uninit(void) +{ + return 0; +} + +static inline int event_init(void) +{ + return 0; +} +#endif + +#endif diff --git a/include/event_internal.h b/include/event_internal.h new file mode 100644 index 000000000000..19308453f7b2 --- /dev/null +++ b/include/event_internal.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Internal definitions for events + * + * Copyright 2021 Google LLC + * Written by Simon Glass + */ + +#ifndef __event_internal_h +#define __event_internal_h + +#include + +/** + * struct event_spy - a spy that watches for an event of a particular type + * + * @id: Spy ID + * @type: Event type to subscribe to + * @func: Function to call when the event is sent + * @ctx: Context to pass to the function + */ +struct event_spy { + struct list_head sibling_node; + const char *id; + enum event_t type; + event_handler_t func; + void *ctx; +}; + +struct event_state { + struct list_head spy_head; +}; + +#endif diff --git a/include/log.h b/include/log.h index ce48d51446f5..8f35c10abb5e 100644 --- a/include/log.h +++ b/include/log.h @@ -98,6 +98,8 @@ enum log_category_t { LOGC_ACPI, /** @LOGC_BOOT: Related to boot process / boot image processing */ LOGC_BOOT, + /** @LOGC_EVENT: Related to event and event handling */ + LOGC_EVENT, /** @LOGC_COUNT: Number of log categories */ LOGC_COUNT, /** @LOGC_END: Sentinel value for lists of log categories */ diff --git a/test/common/Makefile b/test/common/Makefile index 24c9145dccc8..9087788ba6a8 100644 --- a/test/common/Makefile +++ b/test/common/Makefile @@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0+ obj-y += cmd_ut_common.o obj-$(CONFIG_AUTOBOOT) += test_autoboot.o +obj-$(CONFIG_EVENT) += event.o diff --git a/test/common/event.c b/test/common/event.c new file mode 100644 index 000000000000..ddce7400f269 --- /dev/null +++ b/test/common/event.c @@ -0,0 +1,87 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Unit tests for event handling + * + * Copyright 2021 Google LLC + * Written by Simon Glass + */ + +#include +#include +#include +#include +#include +#include + +struct test_state { + struct udevice *dev; + int val; +}; + +static int h_adder(void *ctx, struct event *event) +{ + struct event_data_test *data = &event->data.test; + struct test_state *test_state = ctx; + + test_state->val += data->signal; + + return 0; +} + +static int test_event_base(struct unit_test_state *uts) +{ + struct test_state state; + int signal; + + state.val = 12; + ut_assertok(event_register("wibble", EVT_TEST, h_adder, &state)); + + signal = 17; + + /* Check that the handler is called */ + ut_assertok(event_notify(EVT_TEST, &signal, sizeof(signal))); + ut_asserteq(12 + 17, state.val); + + return 0; +} + +COMMON_TEST(test_event_base, 0); + +static int h_probe(void *ctx, struct event *event) +{ + struct test_state *test_state = ctx; + + test_state->dev = event->data.dm.dev; + switch (event->type) { + case EVT_DM_PRE_PROBE: + test_state->val |= 1; + break; + case EVT_DM_POST_PROBE: + test_state->val |= 2; + break; + default: + break; + } + + return 0; +} + +static int test_event_probe(struct unit_test_state *uts) +{ + struct test_state state; + struct udevice *dev; + + state.val = 0; + ut_assertok(event_register("pre", EVT_DM_PRE_PROBE, h_probe, &state)); + ut_assertok(event_register("post", EVT_DM_POST_PROBE, h_probe, &state)); + + /* Probe a device */ + ut_assertok(uclass_first_device_err(UCLASS_TEST_FDT, &dev)); + + /* Check that the handler is called */ + ut_asserteq(3, state.val); + + return 0; +} + +COMMON_TEST(test_event_probe, UT_TESTF_DM | UT_TESTF_SCAN_FDT); diff --git a/test/test-main.c b/test/test-main.c index 8fcb02ecea5c..fd89ff558a0e 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -218,6 +219,9 @@ static int dm_test_restore(struct device_node *of_root) */ static int test_pre_run(struct unit_test_state *uts, struct unit_test *test) { + gd->event_state = NULL; + ut_assertok(event_init()); + if (test->flags & UT_TESTF_DM) ut_assertok(dm_test_pre_run(uts)); @@ -260,6 +264,7 @@ static int test_post_run(struct unit_test_state *uts, struct unit_test *test) ut_unsilence_console(uts); if (test->flags & UT_TESTF_DM) ut_assertok(dm_test_post_run(uts)); + ut_assertok(event_uninit()); return 0; } From patchwork Wed Feb 2 01:08: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: 539308 Delivered-To: patch@linaro.org Received: by 2002:ac0:f7d2:0:0:0:0:0 with SMTP id i18csp1191874imr; Tue, 1 Feb 2022 17:11:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJxADpYAluLoRL4g4XrWb96mHcf6MNa8LDK7+Hci8YCu0lsBn9Q6se28H/pesAYwlrA/A8nl X-Received: by 2002:a17:907:6094:: with SMTP id ht20mr22094673ejc.609.1643764293267; Tue, 01 Feb 2022 17:11:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643764293; cv=none; d=google.com; s=arc-20160816; b=Xt5TTNOKgfoDY/6B3z6y04Ybt2ok1UdnU06FhNVBU2ssywuYlyTYlnvSn7qrbR3w8m SWEGWRxSEZ5yK0AMscZVpgNJjxgmxWbyC1nU6L3Eisp6U413r1mUioyqNKzv2ArJ0QQY r3E9mJ4W0GBHVxY3XeFdlWB043romKtL7G3wadWcg1RK4vUWROzhmRu2sAzRptRqMc9E BbeNyfUOvJAtS4+FTH7SX5R9r7OI3mitvT4GsriqOEYhPebN8+Z/Wjo1fR3Ama7jJFiC ijyKS3aNc0LYN6EVBNkMRaQHhqTzZX93EtDeC2Bj+V8dHdXEBOZMzymxaqd31Rc0rcjG zz0g== 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=6pj5V/kaNBbLXDIqzczrrUTGFMbBZ3ksgfvWf2PQANM=; b=WWNITM2dy4hJ/fzSxD8hRs6nFNDPr5OqZaU9D5Ucy+n83uuNDR5CuBKy+syAa6+2aU qglBmxeufH340lugqNyVZVLn8oVZBhOVRTJbyw3LOwDbqjkwyp9hL6oPuQbsRaE+Gu99 ChqHOw3JBObNvoGnThbqlg0SPvhbmVdyJjw2smhm42Q3n5K3XhLYaVaet03k70SDpQBv yv2zzZT4ENPOP3ydgmNVGanZdn9TImC7gbLc23wtMDDKUPt/OtkBQc8ykgCn6NETZNKH LbquWbRW9VPpC8YdzZwMrTNUk3qT2/UawFIBysXNmAdAAKBFMVpOK1gugsK018zsr/Xl Gn8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kUPQjJKM; 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 m17si11834614edd.153.2022.02.01.17.11.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:11:33 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kUPQjJKM; 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 40022838A4; Wed, 2 Feb 2022 02:10:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="kUPQjJKM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CA9FA838DE; Wed, 2 Feb 2022 02:10:10 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) (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 C28B4838D2 for ; Wed, 2 Feb 2022 02:10:01 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pj1-x102e.google.com with SMTP id oa14-20020a17090b1bce00b001b61aed4a03so4402829pjb.5 for ; Tue, 01 Feb 2022 17:10:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6pj5V/kaNBbLXDIqzczrrUTGFMbBZ3ksgfvWf2PQANM=; b=kUPQjJKMLeBkapWpoEngGZTn3BxaLRPXmmYRusZbuCL1LBWUxD3pf1WdhaY6bomSAT QqA10wFqP5Q8Gwhhj2nA8xjF5OLGexQp5rMx9YYn3tDrYCbnBEsGzGNM/Ip3pbuT9KI3 HRn9gLPUleirPYbpWcOy/Crei4cJZsemdkfG5jAwCTXwoZvqXUbjzfp40vgKiAI6f2BB lDfkKF4UqKiyuM6sMdpqh1Z6zz/DlPQ1eB+D/YUBAKdzAXWMhW8c+TzWlJK7/I9pYGB4 6qWboob8JEzrggz3obFtx1CJMvWnlwP5M3RRs12wDXIfbgNcHV5HHWzAyjOE3aoFipuS uvIQ== 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=6pj5V/kaNBbLXDIqzczrrUTGFMbBZ3ksgfvWf2PQANM=; b=FR0qqHzwCKcVXcSE4GOZYxHpJI7676sdjyLap1xKJ92BBI5pwPb7O6HdXOR+jqEkSy CMC88wQI/Z/Glgi1niD4NKjm5AXGPHkQ57SPEoiGOS5eufyG+2xheggaTCDTTT65cddQ i/HDHF3ME9z/khwwrkQ+3OJBsg0TVV326QHrelQ6vxtjlklVsCFIpwNlgZrBhNrNkOrm lQb7vUyg0jMQNeFK7ST3I9lBEFL2uDhBzWaDumdpWihyk1KHNslQ1CA8zU6Q3MNaPiy+ TaDV110tmknPe6uBWporq9yclfPtI0G/wiesYNS34M/E40Rxh5upIlxFDMLT5jkmRsQ7 PyiQ== X-Gm-Message-State: AOAM531wpqT0l7mItyxa0hxhrk5ssRQiwPppJU3nEJmndU5wqryJ38WL jM4Di1Vd3TBoKTldbhbFHOEHgyQQuC+sVg== X-Received: by 2002:a17:902:ab49:: with SMTP id ij9mr28824353plb.1.1643764200044; Tue, 01 Feb 2022 17:10:00 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:314e:b83b:fa90:7f2e]) by smtp.gmail.com with ESMTPSA id f5sm10761429pfc.0.2022.02.01.17.09.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:09:59 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH 09/19] dm: add tag support Date: Wed, 2 Feb 2022 10:08:43 +0900 Message-Id: <20220202010853.40405-10-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220202010853.40405-1-takahiro.akashi@linaro.org> References: <20220202010853.40405-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 With dm-tag feature, any U-Boot subsystem is allowed to associate arbitrary number of data with a particular udevice. This can been see as expanding "struct udevice" without modifying the definition. As a first user, UEFI subsystem makes use of tags to associate an efi_disk object with a block device. Signed-off-by: AKASHI Takahiro --- drivers/core/Makefile | 2 +- drivers/core/root.c | 2 + drivers/core/tag.c | 139 ++++++++++++++++++++++++++++++ include/asm-generic/global_data.h | 1 + include/dm/tag.h | 110 +++++++++++++++++++++++ 5 files changed, 253 insertions(+), 1 deletion(-) create mode 100644 drivers/core/tag.c create mode 100644 include/dm/tag.h diff --git a/drivers/core/Makefile b/drivers/core/Makefile index 5edd4e413576..3742e7574525 100644 --- a/drivers/core/Makefile +++ b/drivers/core/Makefile @@ -2,7 +2,7 @@ # # Copyright (c) 2013 Google, Inc -obj-y += device.o fdtaddr.o lists.o root.o uclass.o util.o +obj-y += device.o fdtaddr.o lists.o root.o uclass.o util.o tag.o obj-$(CONFIG_$(SPL_TPL_)ACPIGEN) += acpi.o obj-$(CONFIG_DEVRES) += devres.o obj-$(CONFIG_$(SPL_)DM_DEVICE_REMOVE) += device-remove.o diff --git a/drivers/core/root.c b/drivers/core/root.c index e3f87956d866..1aa4819ceb6c 100644 --- a/drivers/core/root.c +++ b/drivers/core/root.c @@ -199,6 +199,8 @@ int dm_init(bool of_live) return ret; } + INIT_LIST_HEAD((struct list_head *)&gd->dmtag_list); + return 0; } diff --git a/drivers/core/tag.c b/drivers/core/tag.c new file mode 100644 index 000000000000..6829bcd8806c --- /dev/null +++ b/drivers/core/tag.c @@ -0,0 +1,139 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2021 Linaro Limited + * Author: AKASHI Takahiro + */ + +#include +#include +#include +#include +#include +#include + +struct udevice; + +DECLARE_GLOBAL_DATA_PTR; + +int dev_tag_set_ptr(struct udevice *dev, enum dm_tag_t tag, void *ptr) +{ + struct dmtag_node *node; + + if (!dev || tag >= DM_TAG_COUNT) + return -EINVAL; + + list_for_each_entry(node, &gd->dmtag_list, sibling) { + if (node->dev == dev && node->tag == tag) + return -EEXIST; + } + + node = calloc(sizeof(*node), 1); + if (!node) + return -ENOSPC; + + node->dev = dev; + node->tag = tag; + node->ptr = ptr; + list_add_tail(&node->sibling, (struct list_head *)&gd->dmtag_list); + + return 0; +} + +int dev_tag_set_val(struct udevice *dev, enum dm_tag_t tag, ulong val) +{ + struct dmtag_node *node; + + if (!dev || tag >= DM_TAG_COUNT) + return -EINVAL; + + list_for_each_entry(node, &gd->dmtag_list, sibling) { + if (node->dev == dev && node->tag == tag) + return -EEXIST; + } + + node = calloc(sizeof(*node), 1); + if (!node) + return -ENOSPC; + + node->dev = dev; + node->tag = tag; + node->val = val; + list_add_tail(&node->sibling, (struct list_head *)&gd->dmtag_list); + + return 0; +} + +int dev_tag_get_ptr(struct udevice *dev, enum dm_tag_t tag, void **ptrp) +{ + struct dmtag_node *node; + + if (!dev || tag >= DM_TAG_COUNT) + return -EINVAL; + + list_for_each_entry(node, &gd->dmtag_list, sibling) { + if (node->dev == dev && node->tag == tag) { + *ptrp = node->ptr; + return 0; + } + } + + return -ENOENT; +} + +int dev_tag_get_val(struct udevice *dev, enum dm_tag_t tag, ulong *valp) +{ + struct dmtag_node *node; + + if (!dev || tag >= DM_TAG_COUNT) + return -EINVAL; + + list_for_each_entry(node, &gd->dmtag_list, sibling) { + if (node->dev == dev && node->tag == tag) { + *valp = node->val; + return 0; + } + } + + return -ENOENT; +} + +int dev_tag_del(struct udevice *dev, enum dm_tag_t tag) +{ + struct dmtag_node *node, *tmp; + + if (!dev || tag >= DM_TAG_COUNT) + return -EINVAL; + + list_for_each_entry_safe(node, tmp, &gd->dmtag_list, sibling) { + if (node->dev == dev && node->tag == tag) { + list_del(&node->sibling); + free(node); + + return 0; + } + } + + return -ENOENT; +} + +int dev_tag_del_all(struct udevice *dev) +{ + struct dmtag_node *node, *tmp; + bool found = false; + + if (!dev) + return -EINVAL; + + list_for_each_entry_safe(node, tmp, &gd->dmtag_list, sibling) { + if (node->dev == dev) { + list_del(&node->sibling); + free(node); + found = true; + } + } + + if (found) + return 0; + + return -ENOENT; +} diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index 9f4598f09ee5..b887bef6deef 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -470,6 +470,7 @@ struct global_data { #if CONFIG_IS_ENABLED(EVENT) struct event_state *event_state; #endif + struct list_head dmtag_list; }; #ifndef DO_DEPS_ONLY static_assert(sizeof(struct global_data) == GD_SIZE); diff --git a/include/dm/tag.h b/include/dm/tag.h new file mode 100644 index 000000000000..54fc31eb1539 --- /dev/null +++ b/include/dm/tag.h @@ -0,0 +1,110 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (c) 2021 Linaro Limited + * Author: AKASHI Takahiro + */ + +#ifndef _DM_TAG_H +#define _DM_TAG_H + +#include +#include + +struct udevice; + +enum dm_tag_t { + /* EFI_LOADER */ + DM_TAG_EFI = 0, + + DM_TAG_COUNT, +}; + +/** + * dmtag_node + * + * @sibling: List of dm-tag nodes + * @dev: Associated udevice + * @tag: Tag type + * @ptr: Pointer as a value + * @val: Value + */ +struct dmtag_node { + struct list_head sibling; + struct udevice *dev; + enum dm_tag_t tag; + union { + void *ptr; + ulong val; + }; +}; + +/** + * dev_tag_set_ptr() - set a tag's value as a pointer + * @dev: Device to operate + * @tag: Tag type + * @ptr: Pointer to set + * + * Set the value, @ptr, as of @tag associated with the device, @dev + * + * Return: 0 on success, -ve on error + */ +int dev_tag_set_ptr(struct udevice *dev, enum dm_tag_t tag, void *ptr); + +/** + * dev_tag_set_val() set a tag's value as an integer + * @dev: Device to operate + * @tag: Tag type + * @val: Value to set + * + * Set the value, @val, as of @tag associated with the device, @dev + * + * Return: on success, -ve on error + */ +int dev_tag_set_val(struct udevice *dev, enum dm_tag_t tag, ulong val); + +/** + * dev_tag_get_ptr() - get a tag's value as a pointer + * @dev: Device to operate + * @tag: Tag type + * @ptrp: Pointer to tag's value (pointer) + * + * Get a tag's value as a pointer + * + * Return: on success, -ve on error + */ +int dev_tag_get_ptr(struct udevice *dev, enum dm_tag_t tag, void **ptrp); + +/** + * dev_tag_get_val() - get a tag's value as an integer + * @dev: Device to operate + * @tag: Tag type + * @valp: Pointer to tag's value (ulong) + * + * Get a tag's value as an integer + * + * Return: 0 on success, -ve on error + */ +int dev_tag_get_val(struct udevice *dev, enum dm_tag_t tag, ulong *valp); + +/** + * dev_tag_del() - delete a tag + * @dev: Device to operate + * @tag: Tag type + * + * Delete a tag of @tag associated with the device, @dev + * + * Return: 0 on success, -ve on error + */ +int dev_tag_del(struct udevice *dev, enum dm_tag_t tag); + +/** + * dev_tag_del_all() - delete all tags + * @dev: Device to operate + * + * Delete all the tags associated with the device, @dev + * + * Return: 0 on success, -ve on error + */ +int dev_tag_del_all(struct udevice *dev); + +#endif /* _DM_TAG_H */ From patchwork Wed Feb 2 01:08: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: 539310 Delivered-To: patch@linaro.org Received: by 2002:ac0:f7d2:0:0:0:0:0 with SMTP id i18csp1192188imr; Tue, 1 Feb 2022 17:12:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJyGSE7L+mBE/iFME4qPgpdrZ3cXyFGW0PjygI8K7ROlLzbRX5WxL5heifUAt0KuXTJfcrCD X-Received: by 2002:a17:906:4dd7:: with SMTP id f23mr23259704ejw.385.1643764329988; Tue, 01 Feb 2022 17:12:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643764329; cv=none; d=google.com; s=arc-20160816; b=gmymLLQa+IGtNc1Epo2uetHOOmVHyVyh5hrcUixHOYnwMw1VXEpfqKttMO9wX5jfmU vt6+Y9QXtW8nTS5tXCFOPGpMsqleqksXw29KrXI1ArxBmv50L1J3Y3ZdamgEBvA8vDNL cnwxnoSwHUVEwju+uPsQvlxagz7QE08Y9fJPGNlfhP9kBEOzwh/5cD2N9TUuPzIyOOEy 6U3gZbrZ+vIKIfARhdmI46pOK7kNmXNpvWycLu5N9aZWf8yPBxSpGNMMzuN0M3O4zO2d UeQwDMBK/b8fnA56CpoBA+xDlvUGrutPDG1Mh9nsjj29A4BEbfgZmTQpeyVL1BHgSjJ1 kXdA== 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=ejw1is40U/7Wle0HW1PbG5bf3qWO0fEgyim5vk1bu2U=; b=Zt9iTMEtIltdI1THMdrPVnJA9li9LqUg6yfu5gf501scj9f4hckHaiJ48wkWueDDR/ OpR7fCutkONpibpHUo9Mpclf1M4I22bp/xuikHh4foucqTe1LGNFg80jl2vJGm5xfNOC 6YYVg6I09D1rywjrd9s7Wb9N9SMuZ+IL7hFeMpJlV5ueDyP4qR+TwtPn1GBffGeXeTIA amzhcKXooz1bNXjU/o22qk7iBQalOICFFwZJpagAj9zYM8F6bH0sJaM5iCli53R2eW/+ CjV7jUqdGyzT9LcRpqlsnJE2p851tADF8aRTj1hlC4ReRBl7RW3Qcgie+J/y6p/TUdpq OZ9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="X9cU8g/3"; 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 y19si10363857ejk.1004.2022.02.01.17.12.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:12:09 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="X9cU8g/3"; 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 9AFBC838DC; Wed, 2 Feb 2022 02:10:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="X9cU8g/3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E3117838C1; Wed, 2 Feb 2022 02:10:14 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) (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 1E7C0838B7 for ; Wed, 2 Feb 2022 02:10:05 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pf1-x429.google.com with SMTP id e28so17418028pfj.5 for ; Tue, 01 Feb 2022 17:10:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ejw1is40U/7Wle0HW1PbG5bf3qWO0fEgyim5vk1bu2U=; b=X9cU8g/3BVeHLrcCOPCr7pDOrOnFVj+ZA32m55rVgcnRuBevaNqUCrlF7JQCIYUoox cnKeF53/pMVSMgeztA0PPHwbJY1P5hnUU3iG4LD5tJotXXrC3PQKNsREhxJRa7Eu8Q3a D4Pmp8feY9X22vhNQO4h5q2pj7efBrS6eLFJbpwFE5ZN+dMGcjUTq9gkwTMSHtsRO4Jy TcOD1XdR63bkjh84FWjbXXvSZrAbYJjvTiVtW7Iu1QIywVwETLlE7YLuulE9S+54p2+W WtfIw677OG07pVPQSU9Znx+Oo8t4ZJzD0omt7dgPH3Q/aiwOFlHgYhjvZ8g40ciRADJE TTng== 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=ejw1is40U/7Wle0HW1PbG5bf3qWO0fEgyim5vk1bu2U=; b=WygMzvoQk+Bhd9TI1uVtsYoIqsQP5vbrBr2Fh31SsWBDW/FYGNi1EocNWmcSoX9GKw y+pM4sd25V33Z4jRZs3u0tH4OQEH4C1vAd2QGUsSWWaEJYWRyveDknpCcRDshE1sNBYR 51zT4QieVjsFxMqfcGX19MCUr8xSYxQnQ5sfqL+w8PzTcA3NYJQfGhVoDk9tE9Lk6sAG pj9uS+IZbl6XlLAK56NYBPYBZlg3NXaCRFFpzvwcY7LZWEQmQskzTOpKs594v/+vG05n W50H5ZriOnJrLr5No5Thz/JAf/UVg6YjThuTquvf14vrdt+yfaGO3txVkzMeweXGCAWy CrYg== X-Gm-Message-State: AOAM530D7zqJEHhZnXv3mbyyFqK0wKn6CCbzQe3Q6asE2HaZfL/CPo7s DtMAI6/AiifrjDMi2AuPLDmHrQ== X-Received: by 2002:a05:6a00:894:: with SMTP id q20mr10818595pfj.79.1643764203505; Tue, 01 Feb 2022 17:10:03 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:314e:b83b:fa90:7f2e]) by smtp.gmail.com with ESMTPSA id f5sm10761429pfc.0.2022.02.01.17.10.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:10:03 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH 10/19] dm: tag: add some document Date: Wed, 2 Feb 2022 10:08:44 +0900 Message-Id: <20220202010853.40405-11-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220202010853.40405-1-takahiro.akashi@linaro.org> References: <20220202010853.40405-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 --- 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 Wed Feb 2 01:08: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: 539311 Delivered-To: patch@linaro.org Received: by 2002:ac0:f7d2:0:0:0:0:0 with SMTP id i18csp1192237imr; Tue, 1 Feb 2022 17:12:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJw+3pr7sbusg2dZSWKw5zXdna8x7Ey7rnkyhRKgm1bbWHe+6gHl9Aue8U1bRYFQl8OOX6vP X-Received: by 2002:a17:906:9742:: with SMTP id o2mr14520991ejy.126.1643764338539; Tue, 01 Feb 2022 17:12:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643764338; cv=none; d=google.com; s=arc-20160816; b=ecHeE9ymXBDC8CrObWD2/pDWnRZF/0QETNCnbKVNqrjDI3Un8sxdjYm8t0RHy1RzGX yiGDqmS36lI/Z64MywPYckQDyG/LU+ywi69ijLIEvk18++60WciIPkd1arj7p19+QxiN XY3+oFgaUxzl3QcNU2agbdyMywv7DQWLwRwfSnBNSkfjYZX14J0wRNdXusSH2u+Xdnos JbrKcjYRCak8LrYy08m+1R+IBcitE0bkN09xlzgwVVny8HF4SZd2RxQKg1+iKuOWxuoN Hu33onBnwrC2l34C4b3Z8/mRpKLeD/gZssAWlgKnCz1gfjRqhLVNitzh8vyZEr2PkGYx hzxg== 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=j3rJkD9O8Gq+NKRNVXk0fZH0z+fLRoy2YIwtxpZ2jIo=; b=dXhYJBHt8ugCpLcsEW6IgGYNJ2Nt8AQoa3zLXsx2W+5kpxVaLA2Z1jcTWszWCGwRF2 CIuwPfNk631V6Gn+rQ9MC4yksHk34ZWf6tZmP0kU/yaa4YvAUYaDGnkyXekAOx7mdi11 9ZFBDQLdF8XUDHHBa2xsaib3wZVXDxDnjrGI1KJ86p/l2sDherGMx1kwSiFXhI/1Yxcm sJ+nLocrxR36JzQX8ZipUSwn+XtngK81w9Qj1F5XXvHU8Ou2UbI0vr9RytgzuMdU8sKf kSctjz6n4cVe8VAEnriT6+GGQs5piFU1VQhtEOHSCc/L4IXVue9BZdwGjOMUHUOA5Ely U/Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zI6CMT1w; 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 j5si9470502ejo.379.2022.02.01.17.12.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:12:18 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zI6CMT1w; 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 19F2F838F9; Wed, 2 Feb 2022 02:10:22 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="zI6CMT1w"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7634B838B6; Wed, 2 Feb 2022 02:10:16 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) (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 39CD1838D6 for ; Wed, 2 Feb 2022 02:10:09 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pj1-x1034.google.com with SMTP id v15-20020a17090a4ecf00b001b82db48754so206686pjl.2 for ; Tue, 01 Feb 2022 17:10:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=j3rJkD9O8Gq+NKRNVXk0fZH0z+fLRoy2YIwtxpZ2jIo=; b=zI6CMT1wkn8vFRWxTobgxcuKdLdbKPkcblYYzFVfqv2pDHEUDVqRsEDC17OcXCtb/V wgp1VNbTbia1FseDon92YOPz57FGnSxXD7E/20eE9q8AePS+gcV4CsG6tg9jV/x6zxdk wHvtYEGVwBkDA+zrFOiUI98WmyKMNMjwMdaRVKVliNQFzUrOfYNaCCvPjNV15usijNqu AQjr3kzidjren0C0seOMIetaqH80jVWca/qxF2FAe3eenaKO7BxCOw7bH3l6y3NcFUHS gX8OojEA+NhuIvmISFJe7trlwYADRzUqLOJHmBKXM4nWrCFpHk28ZnSIr71GRUi5nXwu jxJg== 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=j3rJkD9O8Gq+NKRNVXk0fZH0z+fLRoy2YIwtxpZ2jIo=; b=ih9yb5Qiqk6XqbUXHpspB2ON7sKBBmOGG6RXZgHRA8C6v9ji/sAx/cxuiQ2F3KWvS4 3f3WJhJ8fRWKOsotr+9Rbv91qS9yej04RkTfg+9YA6IMnsBhjRRPkT1L3rZAeYRazz3M 9urvX6SqRfmoG9scWJwSKXnXEflQTLmUEyIxY4IOvrUPBjCgAu4x5FVjRyo9h+JHYZFy nv97OPmTK1yopsRLI3gFVEIc8uSLcrVE9Y76UMhOe9dhz0lXBA71yxoBqlAkH6pWBVDZ EYsCdaCoWUhmlfI9WmcOgtnxIHkcqpKxGPUQHBumcHh2w0VRmfwiAw4W6ty73jMM4n/R JG3A== X-Gm-Message-State: AOAM530R74/YgHplhBAUpvrUM958d44xDNnkYEYV37S181u1EO7uXU1s dgS+aVo7nZYhnIw3TLj23G63yA== X-Received: by 2002:a17:903:32cb:: with SMTP id i11mr28441677plr.37.1643764207159; Tue, 01 Feb 2022 17:10:07 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:314e:b83b:fa90:7f2e]) by smtp.gmail.com with ESMTPSA id f5sm10761429pfc.0.2022.02.01.17.10.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:10:06 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH 11/19] test: dm: add tests for tag support Date: Wed, 2 Feb 2022 10:08:45 +0900 Message-Id: <20220202010853.40405-12-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220202010853.40405-1-takahiro.akashi@linaro.org> References: <20220202010853.40405-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 --- test/dm/Makefile | 1 + test/dm/tag.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 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..8599fdc242d8 --- /dev/null +++ b/test/dm/tag.c @@ -0,0 +1,80 @@ +// 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 Wed Feb 2 01:08: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: 539312 Delivered-To: patch@linaro.org Received: by 2002:ac0:f7d2:0:0:0:0:0 with SMTP id i18csp1192331imr; Tue, 1 Feb 2022 17:12:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJze8Z19LiojNtu+66W+HKXQly5unkY0zniJ2kMCvoSmpVz2WmqkukjGTgkWVUcMOXfN6xxF X-Received: by 2002:a17:907:7292:: with SMTP id dt18mr22488594ejc.305.1643764354595; Tue, 01 Feb 2022 17:12:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643764354; cv=none; d=google.com; s=arc-20160816; b=SM8pjZhaKCEkVhKjQYcM2pftRGFOVDa9omF7elNhCRG8vRkVy9xPyz0uWANaMC/4k+ PgLGcMifaXGeIRp4Wq4yBPo4VwCNGc7Hw/kwia4xE4BP86yosY9D3goPtyVrgc8YSrrM 8Sa3ntX7Dsl4f303QhqAyyHd99gdohZPtw3Duk8qIQ8oGqMFSBlN7V6mZAnN7KjXheLo Yg8ocDt6AR9SCVpIE+z53lwZNmI7fW0IFEXTKpaTP795sTaViR+7CHLhe0MGTfwWAONM l8S73j+J8CSCZ31GPeUUuUO4Scqr7pvwgmvBMZLKt/0EryiDpSO/HFlX4ld18BPBOzUz 0Jyw== 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=jOd231FtqlYhW0H9SCH9Peko72xgDMiZL/3jps6yxaU=; b=BjultSnlayUjje4loXZpAln9eSX7+qiTx6gNFtYOzZic8QuTDTw3FMTrVpdYIfo9vQ 8PkrPUTP64pmDhUThaNaH1ADXzIs7fN/L7G4etasnLzT+a18zMqjG7hcO7vt39GetGA0 oAXuJhSewcvsuKU1Gjn2nOF4XTXGl+OxlsCwaYaz8fSyAYZXQOF10xSQ3v7jY/i3vCI7 L3XGGC1pzLLDSot83zwrWaIwRvBO76uvyDpxFTI1Ws+OKxdNA3N9Y0b6wosbZcs1iI39 TBO4SqV5vEkN1TtI9pTDnf5UEzdHMra8F98cf7i4QqqMHbpAheSUgujPiNym12vqJq5o 5Y8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nPPFU2v9; 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 c90si6264412edf.355.2022.02.01.17.12.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:12:34 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nPPFU2v9; 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 C866D838E4; Wed, 2 Feb 2022 02:10:26 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="nPPFU2v9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 345B883542; Wed, 2 Feb 2022 02:10:25 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) (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 5389E838D2 for ; Wed, 2 Feb 2022 02:10:12 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pg1-x529.google.com with SMTP id p125so16966158pga.2 for ; Tue, 01 Feb 2022 17:10:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jOd231FtqlYhW0H9SCH9Peko72xgDMiZL/3jps6yxaU=; b=nPPFU2v9nlXe9wB97ikAOiaFZJKJCyNJLaWrzF/DPL/1uaRSKltPmCvnZV3tw/jZWz clkJ/4Ft47YXJQNwKopb/S1YhiD3EecB+AdtvJYrPlGgCXGCVKw9CDIDBrBUps7xnp+k uS1Qa8bHYZjTIsJfs4JCJONZYAMYHSfLhSvkYBUHHupSfcAh5GJnQXeDh/QT8CtSQqkh KUDLOWOTrGvw8oOcsE1qLDeXGDYjGFCGzEJgv3/HiLsN2b6hfhDBydj27yHrtCD79ch+ hjN5NBFCVY/M3caAKe/tgpGQ1czO9pQUb58qhYSSMDjcWP6fkorYBqhAmJC4pBxpShE0 5rCA== 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=jOd231FtqlYhW0H9SCH9Peko72xgDMiZL/3jps6yxaU=; b=H8SE02F81GzG7mnryMo0OkrgCehH4RClCX1t85fg+Nt4976VLJwOVwwCoOOZmaRw/5 VMkCpZzYM6Yio86ROkjgc6qVIGVzjf5EMMErEv+oPc0kxFo8KbXD7tL4M9kf/aAGNcB+ m95t68HltFByyFXaaFB+SXM89e80otvtIxAfeT1r46vkpwgpKI7Xc10l3kJ2SkFKfY7W ZEVeC5aO8o+GRzMQOeRaRV9O8U1YhqYBJ2hkjBS1kyf+931KqMc3zW+a0g7VFRXvFKcm I9rm2y6UnI2FwX1QyWHobPXgP8mEFaVw/X4hoep/XO1G54+C8IaappssvapJsJYHkc9U Mz3g== X-Gm-Message-State: AOAM530NbItUzLT2otwv5BSD8T+8nH5axf3BN5fj/1F5vD41quHaeVVr DqGeAyPlbhy8wBcLOaWTNwqNjw== X-Received: by 2002:aa7:9904:: with SMTP id z4mr27240176pff.68.1643764210738; Tue, 01 Feb 2022 17:10:10 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:314e:b83b:fa90:7f2e]) by smtp.gmail.com with ESMTPSA id f5sm10761429pfc.0.2022.02.01.17.10.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:10:10 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH 12/19] dm: disk: add UCLASS_PARTITION Date: Wed, 2 Feb 2022 10:08:46 +0900 Message-Id: <20220202010853.40405-13-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220202010853.40405-1-takahiro.akashi@linaro.org> References: <20220202010853.40405-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 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 | 11 +++ 4 files changed, 168 insertions(+) create mode 100644 disk/disk-uclass.c diff --git a/disk/Makefile b/disk/Makefile index 6ce5a687b36c..ec37b74f5f40 100644 --- a/disk/Makefile +++ b/disk/Makefile @@ -6,6 +6,9 @@ #ccflags-y += -DET_DEBUG -DDEBUG obj-$(CONFIG_PARTITIONS) += part.o +ifdef CONFIG_$(SPL_)BLK +obj-$(CONFIG_PARTITIONS) += disk-uclass.o +endif obj-$(CONFIG_$(SPL_)MAC_PARTITION) += part_mac.o obj-$(CONFIG_$(SPL_)DOS_PARTITION) += part_dos.o obj-$(CONFIG_$(SPL_)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..95e30e60af10 100644 --- a/include/part.h +++ b/include/part.h @@ -253,6 +253,17 @@ void part_set_generic_name(const struct blk_desc *dev_desc, int part_num, char *name); extern const struct block_drvr block_drvr[]; + +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); + #else static inline struct blk_desc *blk_get_dev(const char *ifname, int dev) { return NULL; } From patchwork Wed Feb 2 01:08:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 539313 Delivered-To: patch@linaro.org Received: by 2002:ac0:f7d2:0:0:0:0:0 with SMTP id i18csp1192579imr; Tue, 1 Feb 2022 17:12:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJzrR8zjINfBO8ZjTC9J4S+5L+a8l+QqrQ4Pdx0zKzIDPqMxApwdccoHFouM/EwrSwmpCMD6 X-Received: by 2002:a05:6402:2802:: with SMTP id h2mr28263755ede.255.1643764378722; Tue, 01 Feb 2022 17:12:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643764378; cv=none; d=google.com; s=arc-20160816; b=WHdWfzLDowds5jMlvweBomhxYZmAcnTmGllliJx+cH+r+14ueA/gGP68FmzLr8DN2r ANRV6kd+7X5zZntylf8Fwa1cpNIN1kZ8wFE5a1XUxBadLw324R7uyYBtMB34dqubhN/Q cK/ObONXRchL1PRDFR3gQxQzAc4XgWoRX/m/NnIDxvjfyGuB1S125cvrZuWzF3seW+di 2Oe6zhRLHwjc0DThaYcUi2tVNPNMQhkbXdsbkK5YjjC7P0hrttOZyG3qzSQ/fY2wunri s2vJW4eodhnL/YmcGSlSbPAx5U3jV4rwmtg/Tq4F3qDG/y0J0zJFO2c/1bKUrbm92hlu xnrw== 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=YHIS9w8yNUPCY2iopuxE0zXhJkMNeOp6UmbJxhRoxig=; b=JRUit2LrxTXPOfWO91vBPokwvYQT/35toC/qfkSXofuh6MWDHlNxSjAzP3nwWoCM54 W+2nYAQCQArZUAsAQk9BohnYPF9zt/1g6oN9tuwjr4el49hQKz2Eq3DOpkZ5YuSE//TY gv170pzeYPtDuYJa/Y1a4KcZJS95HmQ6lcx+YyivhXrFOfJfLwlugHEFVqUKwSn598Mt kNYGFCoJUFC9tHIDPZsuFTdHhbZvxQsGFK0UAkA1T/jiym62eyD225JMtqz+3p4dw8Rw JrxiMgjoXSKi86gCaPymSX4UfSnfN8lPRJxTgrhzc7VKCZQtKK6FbX2R3K8z3zLVYBxu DPhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d23j2sdx; 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 qw15si11777512ejc.315.2022.02.01.17.12.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:12:58 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d23j2sdx; 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 440DC83909; Wed, 2 Feb 2022 02:10:28 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="d23j2sdx"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6471A8341A; Wed, 2 Feb 2022 02:10:25 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE,T_SPF_TEMPERROR autolearn=unavailable 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 B43E383855 for ; Wed, 2 Feb 2022 02:10:15 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pj1-x102f.google.com with SMTP id s61-20020a17090a69c300b001b4d0427ea2so5189844pjj.4 for ; Tue, 01 Feb 2022 17:10:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YHIS9w8yNUPCY2iopuxE0zXhJkMNeOp6UmbJxhRoxig=; b=d23j2sdxV6yD7GtAw3LwlnvNAJQc47Mp4ZXmwz2M9ooIp+uZ1fQ7OozdDTR86t/kJz xJIRxv/0EkoVOZKjCHSEggubvjpC8+azGwfWou0RatYw7KcLm+HMJ7a+CdB6IwZyA/Tc jr/gJObXPl2i9xlPb8eGnu/wwBVNj1KvFVDyGbw2RrdUdC6JgP27Ftf/w6QbpSsuDcrF mRSN2ww37m52Hs+blRHGjFr/0JbUzDmKEMLP64wa/JNO54/2ItJXg8IUG1GJ4BMiqUcD s6GWoFcuAjMtxlll0yJDuD0oaYvzFpOh6xLEFIznnZnp5NrIX5te3ZHvBBxCLs9mfQGQ faTQ== 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=YHIS9w8yNUPCY2iopuxE0zXhJkMNeOp6UmbJxhRoxig=; b=m6eNbRBOKv3euQNn2nZJNKbPVO3CT9NQYS82pYhaN+urzTO4ssxCp96koxxS+vEIxX 7tfufy29sdfKjnjy8u4ixVxdx5zh9/U7mZQ7PSLWtdFYfG4rdPcWvnzYcDjbydJLFMaK Tjij3cJf4hXPSJFzq81FGcAwXg/SFlBdone5Dhd7ww9B1+sK3dtZHzoKsTMSySrt55XJ 7lfR79Su8/sKhCBCWp+zPI4lH96WGKaXgQOxKwQ0+Z5k+HQgFEqxLjMp5F00J1NFb4iB VmgnjORYaGM7Uc/vQTEIpoZ/piBpgmCfGMrOySENwIXAPU1SQjs3D2znO3oVBk9q/HeC DybA== X-Gm-Message-State: AOAM531JrVVDmKIUSN0wqM7FoJsLabSUrZ4Z+P1O9zX/L+JzXk+am11U 33lntY061VJwyB14u33iLQkxqQ== X-Received: by 2002:a17:903:2003:: with SMTP id s3mr28094881pla.97.1643764214167; Tue, 01 Feb 2022 17:10:14 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:314e:b83b:fa90:7f2e]) by smtp.gmail.com with ESMTPSA id f5sm10761429pfc.0.2022.02.01.17.10.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:10:13 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH 13/19] dm: blk: add a device-probe hook for scanning disk partitions Date: Wed, 2 Feb 2022 10:08:47 +0900 Message-Id: <20220202010853.40405-14-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220202010853.40405-1-takahiro.akashi@linaro.org> References: <20220202010853.40405-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 bee1cd6f0d80..58dc74e71f1e 100644 --- a/drivers/block/blk-uclass.c +++ b/drivers/block/blk-uclass.c @@ -717,6 +717,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 Wed Feb 2 01:08:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 539314 Delivered-To: patch@linaro.org Received: by 2002:ac0:f7d2:0:0:0:0:0 with SMTP id i18csp1192663imr; Tue, 1 Feb 2022 17:13:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJwdzcxxuJNosT0wyX4aaV7MDnp6wTXD6qlXuWEGOdDoIjTWcZd1w36jJ1+/PnlJdwkS5fKc X-Received: by 2002:a05:6402:7d0:: with SMTP id u16mr28102594edy.9.1643764389940; Tue, 01 Feb 2022 17:13:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643764389; cv=none; d=google.com; s=arc-20160816; b=Unfj68Qs/JBcMZliZlfycMyrWAWb0HpOlcSikA+dtSNMVlNcZEUN7p2jcrBxAl4U1I i8n28vOerMJILdo8cDdjxXhIgc6sIkgGTOBodcwdpgxTPeCaavsRma6dIMx9U2sORtpt m1UnxvdSwQ2+JY9O/76Gk8PWRUbbxkO/A+Nohf3O1LKTfvW/6YRNjbnfY3VPZrKFh3Zw /KvLOnv2Kcc5qia9qhcBh0VorsJcHkkmYmGz7jzaFGdrN6vAjWLiJcrlqYr9m8awTvao X8VjgzM5Cj2HR3x0kIoRFc1YIridudQVlEJyapdPyLEuYw9Vr+FNLkEDecvcGrqVFTGI 6O9A== 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=Eqn7bl+T5rW+KBOjrXa2T0UWdOSNA4tGBYnzalc2Dsk=; b=IzHZoiNgbJxfFWiI7jCMITSeweVPIPUISy1FJtxpbFVbK8avpJb2JRdNmTGFWcuASZ tnfwCAQBjf95Je34mIOxrAvs9bAPVTQPWdyyataLA8JYajXRC43VTdr/dCLxBOWVPd+5 DLrggsTUfnAb1RzVoX4DT6ZWr8QrZGbk+LiH1syZhKbIQ/yA/rLJdy/HsxBl8dfO+BI/ rZHI/ZDt5lPSUSEf6kmIM4FbxdxwftBMVZ4JjSDGS4FB1aSqp47O93O83uR8FHsJyaGe XBhqykKolCsL5QTgzkBM6hkevt/ekXY3nWdV/FXCkTTAgq87KcwlLe7h4NAYxGYl3e0o yNlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zxhSFuoP; 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 u2si8733277ejy.276.2022.02.01.17.13.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:13:09 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zxhSFuoP; 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 CD9C38390C; Wed, 2 Feb 2022 02:10:34 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="zxhSFuoP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 733E5838D6; Wed, 2 Feb 2022 02:10:28 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) (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 3C322838EB for ; Wed, 2 Feb 2022 02:10:19 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pg1-x533.google.com with SMTP id h23so16939766pgk.11 for ; Tue, 01 Feb 2022 17:10:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Eqn7bl+T5rW+KBOjrXa2T0UWdOSNA4tGBYnzalc2Dsk=; b=zxhSFuoPe9VPRCy9xQ7oT6rDbkOHg8ppg2W4OVf+3weZtNeYSWfEgpLGptfDEdwXQf FHclttE4EQdtS5CVcQrpJfXH9Ca+tMIbE2KayHsy3j/lNxNgCUlOL32q0vS+443AF2fn n5Gj1/nGUWHPaMTfeYXcHxrTrAFU2ZOz/qKabEdHlKBVXyycAGkmfPfFmk2f3D1eEP/M DY4laKlNR5oAPzIDPUObXsNZMQmYuI9F1oxQdAcKRorse92RmO/Zntrzz3wo20B4uF6b 00E7YvKJNdV+ywJ1k6tU0RSXOVMwVUyLrH6yayLTc/xbh08C/ku/m+ihJzDEmYatssLO F7pA== 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=Eqn7bl+T5rW+KBOjrXa2T0UWdOSNA4tGBYnzalc2Dsk=; b=qoJaDZHMvmXgOD/NL6eCBj9gI7FH7u4ydkiNZPiog/oxLPa3zsLgHUJZia7pqdJDLN wwt4xIRWV4YKzm9U7fIJUIGUyDxmaW9SJapXi3kRjEggZe0/evEZX3XrZ+gjvDkmZHJY PXfpAAgxSBEZzmpjCQIm+sszeVvVUoyfif2g2Joeo1zECWifamZcEjUek9Gnt6t0xxd4 t0FkaVYnBnIQ1QWsr+5h4A6zvuIb5MsffE2IgL3yuH1YdJx3e1RQEFC8sUbjZZmnweVw AQAQ2hpOpnlCtcpqnmGLJzdfGaD9pxEmz8YckNH5+RK3AIqrt+ZqhcGQThNFMYre2EAi UBcg== X-Gm-Message-State: AOAM533+VikJCJ8V2MSo2M3KLy45/YTadvzrRgeuDB5RL8ZGsiTXcltb 0nlO4Pgp7x5yarEtKDc+reEMvA== X-Received: by 2002:a05:6a00:228c:: with SMTP id f12mr27946194pfe.34.1643764217602; Tue, 01 Feb 2022 17:10:17 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:314e:b83b:fa90:7f2e]) by smtp.gmail.com with ESMTPSA id f5sm10761429pfc.0.2022.02.01.17.10.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:10:17 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH 14/19] efi_loader: disk: a helper function to create efi_disk objects from udevice Date: Wed, 2 Feb 2022 10:08:48 +0900 Message-Id: <20220202010853.40405-15-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220202010853.40405-1-takahiro.akashi@linaro.org> References: <20220202010853.40405-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_loader/Kconfig | 2 + lib/efi_loader/efi_disk.c | 206 ++++++++++++++++++++++++------------- lib/efi_loader/efi_setup.c | 11 +- 4 files changed, 142 insertions(+), 81 deletions(-) diff --git a/include/efi_loader.h b/include/efi_loader.h index 4e50f2d0c368..28b6454a111a 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -521,8 +521,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_loader/Kconfig b/lib/efi_loader/Kconfig index e5e35fe51f65..57a417a7eb23 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -14,6 +14,7 @@ config EFI_LOADER depends on DM_ETH || !NET depends on !EFI_APP default y if !ARM || SYS_CPU = armv7 || SYS_CPU = armv8 + select EVENT select LIB_UUID select PARTITION_UUIDS select HAVE_BLOCK_DEVICE @@ -41,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 45127d176869..2941b0c3db47 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,158 @@ error: return ret; } -/** - * efi_disk_create_partitions() - create handles and protocols for partitions +/* + * Create a handle for a whole raw disk * - * Create handles and protocols for the partitions of a block device. + * @dev uclass device (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 + * Create an efi_disk object which is associated with @dev. + * The type of @dev must be UCLASS_BLK. + * + * @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; + } + disk->dev = dev; + 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; + } + disk->dev = dev; + 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) { + if (id != UCLASS_PARTITION) + log_info("Not a block device: %s\n", dev->name); + 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 380adc15c886..86d1565a4e64 100644 --- a/lib/efi_loader/efi_setup.c +++ b/lib/efi_loader/efi_setup.c @@ -200,11 +200,12 @@ efi_status_t efi_init_obj_list(void) if (ret != EFI_SUCCESS) goto out; -#ifdef CONFIG_PARTITIONS - ret = efi_disk_register(); - if (ret != EFI_SUCCESS) - goto out; -#endif + if (IS_ENABLED(CONFIG_BLK)) { + ret = efi_disk_init(); + if (ret != EFI_SUCCESS) + goto out; + } + if (IS_ENABLED(CONFIG_EFI_RNG_PROTOCOL)) { ret = efi_rng_register(); if (ret != EFI_SUCCESS) From patchwork Wed Feb 2 01:08:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 539315 Delivered-To: patch@linaro.org Received: by 2002:ac0:f7d2:0:0:0:0:0 with SMTP id i18csp1192794imr; Tue, 1 Feb 2022 17:13:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJw41eAZVRRvLJddgqXTqFie44odXxTLEmiy6RLuk6Bu41+BqDK9meIcY3E9fu/vJ6xQImhQ X-Received: by 2002:a05:6402:26ce:: with SMTP id x14mr23667245edd.211.1643764408125; Tue, 01 Feb 2022 17:13:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643764408; cv=none; d=google.com; s=arc-20160816; b=lRaPMQ/0M2ouURGSgvvsi9vy/zUv5cgbNGij22ikOj21+OZpOsJlegthvWAitL5x4g gs9REUipbhiePM2j+DEqGBNmQpJPXvofX4FcZIqwFZnZDZSOliZRe10Cl1xxVaFfgPsO jtRR0UQqlacBR9clieCvfejOeTczTXGRzYU60mv3XIWCbYpxKpC2TxpZrsLXUkjRl0EW 3MOptXEgkyPb/w7EKSmvBYa4Gvgl3/EXtyP1phjCyQffMZmRwAgzj7Wj+E9jeb3Rezsf snZxLghQiH2VEN62goMX0sBwLr/KpA9LQiqa50oBPta8B08aV54EMiH1tsKfYYp/1JAI z9ug== 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=scQDk7CU4Htpi+80mL//SWDOEq0M+vsnaakCV4qH5zc=; b=N0RX7+NJYrb7qf+eIMUw0fnI6ol4ZN0W6Vn1MWY4BVL/QanM/0rbRWKGLoW5qwh93L cy/e1S6vz92MtvlLd62AsfrMu/xBHfxRV1QQkwBNEjVDIIiqUXtYHbu3fgCacyj8+VhW 1J4ae0n1Kmk7FDeTqpX3a6grEpeeImSGGuHPvRawiGRhuQoBRqzb9UgiB6RxJwCN51JN Xfwbazmmv0nbHfpHidXJMNyWf1jzkhfJDDoXARY206prNbxaiKf5LB3bkmjIZCrdEPHK +zoDb+5a+lD6D41KbWf15YHtmAYrACtFODuTxKef6pDyEimDrDl9b+fApkFrp2UrEpwl IbZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ux1Kvod2; 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 hq3si11511452ejc.417.2022.02.01.17.13.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:13:28 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ux1Kvod2; 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 11C9083910; Wed, 2 Feb 2022 02:10:36 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="ux1Kvod2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D9621838AD; Wed, 2 Feb 2022 02:10:32 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=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 781E2838FE for ; Wed, 2 Feb 2022 02:10:22 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pj1-x102d.google.com with SMTP id z10-20020a17090acb0a00b001b520826011so5187851pjt.5 for ; Tue, 01 Feb 2022 17:10:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=scQDk7CU4Htpi+80mL//SWDOEq0M+vsnaakCV4qH5zc=; b=ux1Kvod2N77ImLHStv5f8CSCDKY05nUpQFF9FAV2mYLnZiOA+PRFBo6r49OCQ+3jxj b4jL2PWhOn/Z+ezH3VcmM/ORdyezyV2iyVmquB5+XqgyZoaVsF9gKdrtJT4uRAoneEtF ZWkT9vVUwEdHDHRP5FeF0sZMI91wk7yJ2qxe5wFNj+P84mH79xGIKC9S+6gxDJKIW5G8 Bpzq5fxo69Q+fXgEmV2+Tvw86CTquglt9+J5nwH5aeRZltywGgVtmLWeeaWP4r1SLfZA 2dP5MzTpd83g33Kgbztsb0zss/4Ai/cavgYmHHIfMpEuzo4ykEv7c6uLNtV6FVLyeyZH YarQ== 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=scQDk7CU4Htpi+80mL//SWDOEq0M+vsnaakCV4qH5zc=; b=f1cLLTsfpKSkJ0TCwYiz+KBS2aX8cKpNPVmJ1F2s14d5vaSFPNE2k+AkZA6pZCLsfG vDL6tzMXqFm//LnxEibpfsb3aC1FFXRFe3+xgnTNi0HUmzRdpcmXwXQf1dK2lTPA+N7P s2rXp3vAo5uYeUZ/pMiTzs1OpsIE71Ud9xqf43vEp4DEAQwdZcxtPw57dEQbOuijSSeh UY7igfXE+dBE0lueLoUXaDvMTLd+3+drwsF6Sr+ny6YpwGIJEHhg9pgLYuzdj9Sw/8Zw A3wGugovAY7OPCYCwBZN7ttlAm/T1KHu+zsMseSiMvacZc7FmS2Q52lIH0X+h/J+sjja ygWw== X-Gm-Message-State: AOAM531odBaDG59ppReHCQFD/F9BvY8ViBesu1YRbntjWDQKXaC+KzEv 9wKw/xhMI4PPxPaRGyh95oXhrQ== X-Received: by 2002:a17:90a:34cc:: with SMTP id m12mr5509866pjf.24.1643764220875; Tue, 01 Feb 2022 17:10:20 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:314e:b83b:fa90:7f2e]) by smtp.gmail.com with ESMTPSA id f5sm10761429pfc.0.2022.02.01.17.10.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:10:20 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH 15/19] efi_loader: disk: a helper function to delete efi_disk objects Date: Wed, 2 Feb 2022 10:08:49 +0900 Message-Id: <20220202010853.40405-16-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220202010853.40405-1-takahiro.akashi@linaro.org> References: <20220202010853.40405-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 2941b0c3db47..8dc7534278da 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -632,6 +632,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; @@ -643,6 +724,13 @@ 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 Wed Feb 2 01:08:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 539316 Delivered-To: patch@linaro.org Received: by 2002:ac0:f7d2:0:0:0:0:0 with SMTP id i18csp1192819imr; Tue, 1 Feb 2022 17:13:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJz4GtpdAr14izG7MlcdCSoc3/7BOE/zF70u4PRldOcfhjMiz20pb0TBGSXZwvy993tzmd6e X-Received: by 2002:a17:907:1b16:: with SMTP id mp22mr23852112ejc.537.1643764411526; Tue, 01 Feb 2022 17:13:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643764411; cv=none; d=google.com; s=arc-20160816; b=rahUvbeadb5JtkV3WypFMaRao2d3eTcg2YBb01RGdgqANh8Y0EzLd+cr+UqM8USDgZ dwGgKAfR1YOpSbwqiolyOaZaxnSN955dLBsLhAWj28K4LvE7/4nRvAr24+4Me6bZOPVB OeTXkXj6o3/FNVGfBdLR5LBSBPhWGT+rQjX0TXcwB1VsYW5QDXCX6ksduBAInKF9Yrwe QQ172WdkY0v0NXZfNaezxMiuwGVHQ2qAkNgUbzzFRDxRI20zxfto8ewnbuH9rrxEYjvm /aYEY3zY2NPTaKABqLUlfXulI8RyMz37rif+qNyBdjghdfYF6Zo7xx70twsm+tqT02Mm i73g== 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=OsQfVSYdhgShxJakhkjh4CKoWsiUp44hecLFF1owVw0=; b=qXlZ0KA8pwR3M8F40KCZMVBt6DC0n9yWRhLkeVNcfCDqRKuFI5Pmb3QpdFsOrg3dBk DD/B84sRLp+t8WJw7rkP6BFlJb8R1GcInwx4HeoRj8YWWmdZeO7cdsAsBNgbT69Zc7CW SXB+LYqfY86WYHzFGdlZwTnXiS4KXGRbHp+v5ReNIIyb+2yzJTCXhCMeZgjx3UnlgWZK P03MZTFIhLZFhgzEuXJBGw7WcTWLJ7klqYVqB70I07OMksJ6g2/+C+18JsYGUROvTrQW eQl81OwbOvw/abk3vIYeFuwCj95GKLShHECE2VtkEHiI0DSZMUoA+nX6tgRv3S5juXgC +//g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hhtsp59u; 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 h20si12559276ede.184.2022.02.01.17.13.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:13:31 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hhtsp59u; 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 3C56883917; Wed, 2 Feb 2022 02:10:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="hhtsp59u"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4D36783003; Wed, 2 Feb 2022 02:10:33 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) (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 14A4F8341A for ; Wed, 2 Feb 2022 02:10:26 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pl1-x62f.google.com with SMTP id b15so16882115plg.3 for ; Tue, 01 Feb 2022 17:10:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OsQfVSYdhgShxJakhkjh4CKoWsiUp44hecLFF1owVw0=; b=hhtsp59uGy19ITQ7WGmgRm/3NSvN86L1gQqr1oZysNVeaawt114zlbk2/oGbP7gwNq pbakc8KGypq9Uij2SMbRvTh0rOJvA0CxgekoTzFhVThXAVUT1PC+oNmtE1dUNbmpignG NzoZzf9Kwurcdw2gPBY08YnSy6x3Cu7YkeRiRLPU2ZQClI+r0iwb5igrkIfV+uG/rTRu n8yQtj7vqwgbogX6EmHdwi429Q7vW+qdF+LS5mRHDGyae+fSh8xrmNCw93rMsY3lvQzK UlkmqCd/12Lh581qgr9h/oDc6qRETvcNNolx8qnKyOVqZXYzv2AAqg3iqsODja0RgBtl eTFQ== 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=OsQfVSYdhgShxJakhkjh4CKoWsiUp44hecLFF1owVw0=; b=h3WGlkeVOI604cxWGUxcYVcHo+7JrNt4/J6hv6j99GRKeL01ACIhOHBeI44P94VQaF HVlCJuLesu5lzAdzks9z9E4Cvd+DNv/qGD/ErUKZM/QtpaO5TvgdkrJJaXc2OxtVXzoq usxI37AptFGiAb/ceN/Sf+1u3fgthrVpBqSb/2LlOhy9IdohM93ui0MAomerfNcadRV1 EZn+uFkFjWYhpfEy2kBJFd51EX5rRFTH0qiK8ec8UOp5Ve9op/Jc8CmVEDhafqqqeW7Y RhISquOma/6v02/k4MwXj39BEkw/txq650tFPNcSUGpIkW1OwOzEtBqlL82PZRZ67c0H Rt3w== X-Gm-Message-State: AOAM533MgH4q80ywXGSp3ak/LhPtsYNJxZOH4qYgNvGcsc9ApqfujlAP 4cSmP77HRenuG2NxNmVXvGtdVg== X-Received: by 2002:a17:90b:2281:: with SMTP id kx1mr5418988pjb.37.1643764224453; Tue, 01 Feb 2022 17:10:24 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:314e:b83b:fa90:7f2e]) by smtp.gmail.com with ESMTPSA id f5sm10761429pfc.0.2022.02.01.17.10.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:10:24 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH 16/19] dm: disk: add read/write interfaces with udevice Date: Wed, 2 Feb 2022 10:08:50 +0900 Message-Id: <20220202010853.40405-17-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220202010853.40405-1-takahiro.akashi@linaro.org> References: <20220202010853.40405-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 95e30e60af10..d4e5cd921db1 100644 --- a/include/part.h +++ b/include/part.h @@ -264,6 +264,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); + #else static inline struct blk_desc *blk_get_dev(const char *ifname, int dev) { return NULL; } From patchwork Wed Feb 2 01:08:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 539317 Delivered-To: patch@linaro.org Received: by 2002:ac0:f7d2:0:0:0:0:0 with SMTP id i18csp1192958imr; Tue, 1 Feb 2022 17:13:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJwgScronSIYplGynCjiX2UAxnKd735e5Uz2eYIFXn+ngExAD4SOaaNYENLz6FTBF2MjyKd/ X-Received: by 2002:a17:907:1622:: with SMTP id hb34mr23443754ejc.280.1643764425939; Tue, 01 Feb 2022 17:13:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643764425; cv=none; d=google.com; s=arc-20160816; b=bQSTJmnQEu7yl2ydzz1JFKlD5CyYuVI+c3pErTAIuE2YFBJeblpt7sG1Hbl69wRG4T O/0vJMQg9WtNz/2cCjmokvJQF8K+dw6nSDzqlqiXwsKZCTdmr+uHNg9M6dKZxcqrhJGy 0bI8t8O2YmvN1wBaeyy7yqUp3wAOe7+mRemyN1cLpeMjvBOvvZ32kFnUdMIdFAzUNscb jJIbX384HSj7eve6dXWpeAxiXj7BogPTrLvbZYctTz4dE3l0TZKJPAcVeWb93FiydJ7u b73qmvPFPOVAX3lfkAHAMV978GjogYy3PinwS1AX0XAeEf0KscT/8i5dQJalQAt9/7Fn 2i1Q== 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=3FYoYlTI2sh6c0aqIN0PncgivPez6oVYEDUBCXbdrT8=; b=EjLbzZKOCRRbzUEbkjOINHZ3Ad65s6QMR5dNTAjTDOMZWYGZS4IoDS1GZOG2cVH8fi 759RIYeOBJ3cHJ9g+sw27YcvRRvWZ+In+NAzG3y46frVcIARtFoQ6N5VbkdG70qk7bwp druDsW8nxtWJIJhkIIP+hF4cik0rLz0CCUGL7WD2JRQsCLrXgKpanZX+AbayxlJaIpfc KzfAtQfdtylKFddvuNH2GfRCmw5Yw4MG3SQ2gXsrKX8wXi6KYKA71TZwQTMhUdGo95Mr srimN7HlhmgmLanlJwDEcQ94JjMjgooxM4aLigNTKi0sIKFQniXbOBGhFoevCCwua0wz iXCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=J8UuVWqN; 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 cs16si5026638ejc.455.2022.02.01.17.13.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:13:45 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=J8UuVWqN; 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 16A29838CC; Wed, 2 Feb 2022 02:10:45 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="J8UuVWqN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DF6E4839EF; Wed, 2 Feb 2022 02:10:42 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-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 8345B838EE for ; Wed, 2 Feb 2022 02:10:29 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pj1-x1035.google.com with SMTP id g15-20020a17090a67cf00b001b7d5b6bedaso4413150pjm.4 for ; Tue, 01 Feb 2022 17:10:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3FYoYlTI2sh6c0aqIN0PncgivPez6oVYEDUBCXbdrT8=; b=J8UuVWqN66LqCuWrbC5zCY52DvVabo95tYrfUSsRNKBQscNA7LUmLPphvzvJUi3eBd dPY9KmejQgpR2w9w/oCArhyxMo7YkWnHO3LWa0rcdOp7IlZSk23lunj3/fYB5pDz/5Yv hbtCw/zVhMcgFlhE7eJzDaDXDhBKWgOC1+qYtYKaztjUBbWMjcyf2gAkWdX1346+uEi9 LbopxetFHnTMVQkLYDyL8bG4rPatKX8zbfiHtfkzPKmQ5c7T5jERCPtpM7GCEpGYpPVB TM0XXQzoXVdVCwPsa8V11U7zgEnCr9GDi4ZKXxBUH+Jgu0CThYmlq1NFuf7uJWvGVXB3 lOhQ== 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=3FYoYlTI2sh6c0aqIN0PncgivPez6oVYEDUBCXbdrT8=; b=EdZGB0faZJTSRCtD/AN+XyOUvjKf89/z4OAhwSTAMsyY0iMcFGtuJSracpTjo9aT+e dZlzBzPxzBQWFTwAIrHMDrGAXtRYDt8o7Dm6Bu3UAmQ9LBXEDpgP/k97IyCaJRA9xM4a w/Rs5tyFW8rpnkFDznrxjqsqDq3C31C/hJn8vNBL6L16xvgU9LqDJ8HcyzKBLa6JXxEb /3xZEz32xsZ2dkUH+rLXIe4v0nHnWBDlnRtKpZhJ8yXY4vpZxNtFLrLbkOjx4jEfCy49 ESP3Qcm/fdrUinvSFCYtVHd323URGv6C1ZoeBiEIlfnbHhK/01C/F9L6uM9AM6Lce9qd +E1g== X-Gm-Message-State: AOAM531DGSpQzo7NjRU5ic2F1NLqBi1QgE9ZhFgxWAyZAynrCZcC87JS 4cpEQyXQ0Bg88+d1ORv2o/uPOQ== X-Received: by 2002:a17:902:ce8a:: with SMTP id f10mr174747plg.35.1643764227923; Tue, 01 Feb 2022 17:10:27 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:314e:b83b:fa90:7f2e]) by smtp.gmail.com with ESMTPSA id f5sm10761429pfc.0.2022.02.01.17.10.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:10:27 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH 17/19] efi_loader: disk: use udevice instead of blk_desc Date: Wed, 2 Feb 2022 10:08:51 +0900 Message-Id: <20220202010853.40405-18-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220202010853.40405-1-takahiro.akashi@linaro.org> References: <20220202010853.40405-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 manupulated 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 | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index 8dc7534278da..8e33af76711f 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -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; @@ -745,20 +742,22 @@ bool efi_disk_is_system_part(efi_handle_t handle) { struct efi_handler *handler; struct efi_disk_obj *diskobj; - struct disk_partition info; + struct udevice *dev; + struct disk_part *part; efi_status_t ret; - int r; /* check if this is a block device */ ret = efi_search_protocol(handle, &efi_block_io_guid, &handler); if (ret != EFI_SUCCESS) return false; + /* find a partition udevice */ diskobj = container_of(handle, struct efi_disk_obj, header); - - r = part_get_info(diskobj->desc, diskobj->part, &info); - if (r) + dev = diskobj->dev; + if (!dev || dev->driver->id != UCLASS_PARTITION) return false; - return !!(info.bootable & PART_EFI_SYSTEM_PARTITION); + part = dev_get_uclass_plat(dev); + + return !!(part->gpt_part_info.bootable & PART_EFI_SYSTEM_PARTITION); } From patchwork Wed Feb 2 01:08:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 539318 Delivered-To: patch@linaro.org Received: by 2002:ac0:f7d2:0:0:0:0:0 with SMTP id i18csp1193086imr; Tue, 1 Feb 2022 17:14:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJyNQLtT4ooj4suf6yJvYMZkVrRawe0LmYc5UhhXR/w3Ek7t6Vu+P8WnD4xYvcQhJEVPDrUe X-Received: by 2002:a17:907:d8d:: with SMTP id go13mr22502920ejc.440.1643764440244; Tue, 01 Feb 2022 17:14:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643764440; cv=none; d=google.com; s=arc-20160816; b=QX1IoXxbIRhXm3R5GSw2aI127w9CTIoLfsjjyrPIfsf7TZeX1M8M7EW+3cOLAHUzvz xlYtTgKexRtcYPXQqQG3ya23jyJWfdDWgatCpQtnvYRhh4Yelyj4+dvW+lL97eXJRNtV 7TWwEzGPmX6xxrWqbH6TCp9VOjv0MzVHFCbnT2ZKCAORqJzVG32mU4+oSWTOaMfWYlyA zuzBLl03aYDU1etvmmPZzlcoIw4ZhCO9wYU59lTiLmAwLiVaavVg4R98VwsXSJmrNVou gIz7kUVtV50zHCaeXLttmBmiQVhVUrpzmUGJypXY+SyMU/TQpYUoK9y+V8s6nN8kIgpU uj5g== 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=ha2wSAj7i1Ko6BdG1tS4mSnA4lyWSDCDvN964INYsL8=; b=RxOmdztaqMmgIbTUhRnKHdBriCjhqDrSCJ2/pkxWvw8U8CZ4uw1vYI7EVRP4e5V8n1 vPMzGEo0LmdL8kz+j5aypYl/1V+iq2234fmnNK9A68+JvIOO+X9p6Emg86oSguZwHYqP 5wQ80VZzrDR+dSlNJ5FlT613JzjYNzhSXqxszr1tbXlB+kmGPn+qmXhMtT1oVBMMNBHe ckObEk3HfGOsQvTD3XdqgxaXypLg+e5mos53UH24Qt87DcRrbrCWLHyeFYzqR5a98tpV O8QwKeqGRdB6Jcar8V6cRgXFQ0xa0A4ZVRbRxYAZSWcmb+ZcxVyApbZ06sBGj5KZTNjg a5gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jHQ+v1WI; 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 a26si10143815edx.29.2022.02.01.17.13.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:14:00 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jHQ+v1WI; 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 72ECD839F1; Wed, 2 Feb 2022 02:10:46 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="jHQ+v1WI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0E4B5838B6; Wed, 2 Feb 2022 02:10:43 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE,T_SPF_TEMPERROR autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) (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 2F0AD838D6 for ; Wed, 2 Feb 2022 02:10:33 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pl1-x635.google.com with SMTP id l13so8192640plg.9 for ; Tue, 01 Feb 2022 17:10:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ha2wSAj7i1Ko6BdG1tS4mSnA4lyWSDCDvN964INYsL8=; b=jHQ+v1WI1/89zxIRewshaG1qvbh3wWLEfs28LpYSuUY8XmDZMvWQm2Gz9HfLeMu4i4 LqSZ++sFon2E8GtrHU692sZBw8ucv9HZ+9ZIKA+qFWIxR+yF1/Jkd23+3NwVvgErnEY5 rwwbhxsJe5XcCEHI9KFcGO9aZivCz5gzehta3hSw/mGoc8L6gyDZHh/cZ1EoyBP3giFh nx6Uous30vuZuFcp9LYujrGi43mbfCaQ4XKhVoizppAJxgUqczeIMpQGDiKMxL8DMdla HT69c21M6jZjG7WVBA35Zc320dIXe72ECcwBtVvJhE0MEy1Z6tfQw19AOrLjAWeLVxVb SWNA== 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=ha2wSAj7i1Ko6BdG1tS4mSnA4lyWSDCDvN964INYsL8=; b=c6LFnzNKids1h0Cn+VJJjPmoWkmcPfj4NVTTIz5R/mRnkmF7orOz9/dqYen9qcu0Ai xUXCHxBP/er9Br0b8H4ET7ELpiI+iWvo44MtnmE+jXyl14yt3MqwiULHBgQMykn9yJG0 CxmrcKWenDiwqaRcVjhqqEAHs4PBTirg9dRNZm55Tw0sMjOgIag2qKziwIzb23LIqNFp nX2ehKdjT2ernYSOZqcfI9Gisu3bTk4eyeCuL0icx97RXznr3v+/+TfmMEAMSILlCPfI PVXsfn26v0OhZk9MFiTltzCkJ9S1UBDdtoos8nguqEaQtEbZjPIDFOY7LCRSDNIiEX6F Z4SA== X-Gm-Message-State: AOAM530DS0Bfqs6R1lmD9SKEn2ncjlqfbKnxn/VwFrz02I6Zy3+qpRJr MgWUC+UzF9mreK4p5/L7TBJGbg== X-Received: by 2002:a17:90b:17c4:: with SMTP id me4mr5479856pjb.198.1643764231612; Tue, 01 Feb 2022 17:10:31 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:314e:b83b:fa90:7f2e]) by smtp.gmail.com with ESMTPSA id f5sm10761429pfc.0.2022.02.01.17.10.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:10:31 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH 18/19] efi_loader: disk: not create BLK device for BLK(IF_TYPE_EFI_LOADER) devices Date: Wed, 2 Feb 2022 10:08:52 +0900 Message-Id: <20220202010853.40405-19-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220202010853.40405-1-takahiro.akashi@linaro.org> References: <20220202010853.40405-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 | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index 8e33af76711f..0ee892c95bf0 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -603,6 +603,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; @@ -616,9 +617,16 @@ static int efi_disk_probe(void *ctx, struct event *event) 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); @@ -642,13 +650,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 Wed Feb 2 01:08:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 539319 Delivered-To: patch@linaro.org Received: by 2002:ac0:f7d2:0:0:0:0:0 with SMTP id i18csp1193176imr; Tue, 1 Feb 2022 17:14:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJx+qlVaiKLJ132y0czeVv1Yd47GOVRrhZgKYreFWKdtfBpedef1qQRV56A7vgi8KtTVeOS5 X-Received: by 2002:a17:907:6283:: with SMTP id nd3mr23096695ejc.2.1643764454821; Tue, 01 Feb 2022 17:14:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643764454; cv=none; d=google.com; s=arc-20160816; b=vPMDGWkMiYfgKGzpxo9eXXEwkeq93e8QoyoLYXw9rjvau6CXJn3T+tfC0LPhWPNFg7 ggBboUI9vW8uby1LB2EnzbbX3+McTIWgiYFcky/SLHP9TEjodmaGXUR8TO4cE6iSROVQ lAv3Olg5Bp7likoDpHUOp6cj1sYs39kbOUjw+fBZzn35ypo4Ym1Vm1AWppYOQ43sMWCS Ag72SDWBxTNULLVZrr7J09fMQoN3MFdOHYWLTlD46LPp1rLL9AIilJs9GO7AL5YXFdsf bkCDNdxTElHKXxuUn1RqZMbSQLhfSbdBUBZKP+yo5igNun7fsl+imssRtFPBsIITk9YQ Bdmg== 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=eYHYzsO6Ya0KXfUNViqMWI46hl0I0il0h5rYfPH5f+o=; b=nSVakcOOVxcYvYRWhJQeASw1EkYEJNRyGPdnfnm5GvfrimcY1FD1OLmsrbmQ/6lFoD FCIh3MVa+ZZZmq1VZAGs4o6Vx9Whxgc6cHhkDT3A33b5JAYGGuisDhEnLqWKKYSs0BUt HnUPKXQktX5QZrrvuf+r/kfo9o/SJxgnnSUBP3MQgLLWjwSqcr+aCBCKmJ9dLmw6FEPV eIxcJen613NoTIXN0oLh478A2jCFARoEQjxERseO8bKPDfLzq2G0QnV66C2r6WRvMeNG 3cmIqoumVVJp0My3S+olvnJAy3p936la3R3dhEq20xl/CzXIqvVsO5+Ibf9aeOqcUDWF 1vaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MZtQjPgT; 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 h7si8337350ede.573.2022.02.01.17.14.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:14:14 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MZtQjPgT; 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 C1657838D4; Wed, 2 Feb 2022 02:10:53 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="MZtQjPgT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 08E0782FA5; Wed, 2 Feb 2022 02:10:53 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE,T_SPF_TEMPERROR autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) (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 49DB983900 for ; Wed, 2 Feb 2022 02:10:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pl1-x62d.google.com with SMTP id l13so8192740plg.9 for ; Tue, 01 Feb 2022 17:10:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eYHYzsO6Ya0KXfUNViqMWI46hl0I0il0h5rYfPH5f+o=; b=MZtQjPgTd3L0g3WEFZxOtJZWDeOuIAOmI598v64TGrOxyUouMkDAFTns6t98kW+ejn lmBnV4Wo4H5di3idx42ce3JhnVLcJgrYMHDiRtMtq3sX5uIWpybsP9XLMsFx545cS8zI SBMJm+3RVWfZeRqB/5Jz5LhJ6Oq/1sW+hPFTA1hlTV5sCiuKUgn/iH3H1uUf/u3gBqnc pag2KHO8ecIbix4lJHscNzhqBYPIB5xHDM/RrTvZ5R5G8GJpFP/9/k3+dxA1xRlLQ7YX 4lphMIMqeEPIRl2eY+3v5P57bmqKmBbAryLBMQJF9CHmUQitvUchYSsyipsGsBuLcF8A wwhA== 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=eYHYzsO6Ya0KXfUNViqMWI46hl0I0il0h5rYfPH5f+o=; b=5gsRBzvS7vizOC/qRGsDZaZwFTURa7G8yKV+RJBISdhqVfFWrkhM02BUGy3vMzY/A7 60cTPwLGulyz9a+v+NDJEPX/zVa3FYgv3it3zx4DueAY4yWFWBRLTxRI+WzXbkaGvBgn XU1X7CqZOzDEC0cmhz4YRKZaHcDV2eRFOza6Loqzz+qm1sYTXNU5OGQOzDbF/bCG1DEX 5uR5YUHOPNvpJx1Xj5ZzpNshCsN4uzFwnY0HQMltNzNSu0bgdzdgRUpID+GBtvyeu1/A H5+jczRGDL2Rcwqe38SkqJGW5BV8UjlVgk5xtEUv195LGXJiFuXi4gf62lQhndeqDjuf juSw== X-Gm-Message-State: AOAM530PW4HTlp2FDcNfdaRMKPDyvMTMML/yC3ZNS/hnaA7nUKt+JYxd q2qD41Bs171/DUwMgyVwN6imTw== X-Received: by 2002:a17:90b:1d06:: with SMTP id on6mr5508846pjb.6.1643764235099; Tue, 01 Feb 2022 17:10:35 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:314e:b83b:fa90:7f2e]) by smtp.gmail.com with ESMTPSA id f5sm10761429pfc.0.2022.02.01.17.10.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:10:34 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH 19/19] efi_driver: align with efi_disk-dm integration Date: Wed, 2 Feb 2022 10:08:53 +0900 Message-Id: <20220202010853.40405-20-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220202010853.40405-1-takahiro.akashi@linaro.org> References: <20220202010853.40405-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 With DM-efi_disk integration, we don't need to explicitly call efi_disk_create_partitions(). The only thing to do is to associate an efi_disk object to the corresponding udevice as we skip most of processing in efi_disk_probe() by the previous commit ("efi_loader: disk: not create BLK device for BLK(IF_TYPE_EFI) devices"). Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- lib/efi_driver/efi_block_device.c | 34 +++++++++---------------------- 1 file changed, 10 insertions(+), 24 deletions(-) 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; }