From patchwork Fri Dec 10 06:49:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1566194 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=hYcIJ4zm; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J9M3v6Kc4z9sR4 for ; Fri, 10 Dec 2021 17:50:35 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9438B82F03; Fri, 10 Dec 2021 07:50:30 +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="hYcIJ4zm"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4D17D82F96; Fri, 10 Dec 2021 07:50: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 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 6C44C82982 for ; Fri, 10 Dec 2021 07:50:23 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pf1-x429.google.com with SMTP id x5so7720282pfr.0 for ; Thu, 09 Dec 2021 22:50:23 -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=CE9Ru0+BtM/aB7yGhZ7xbEBAasBATDEKK3UGeDqn+m0=; b=hYcIJ4zmeCNYWZAz9zTH0Dz4S4lcYZGsgIfBf2DUjtF3Jp4F7EbksnGipk8fKNhk6r dPt4+OHQIajINW4cM3azGcJ7uKYnaI2AiLNGP8FtyTuGvKqiptIJbhN1kdB4tb8wSHWv sdfX5JkWuP1NOgAKkmV7a9pwDvms0JoVPiZDfQeVe37e09XLJpP1oLjDDEmvpejn/zc9 PSNtb4tqQqzhBr8HSv+M+x+A7j4S4rFDa2Wq9kThInpwOMmWwlQFJgpHZaH0F8hJT8Q7 y3vLpKBhqPGxb/ORXxPcmsNnaZKz3x5CPN5PiPPIhius19qtptvflxfqVpbV82uk7fV4 1cfg== 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=CE9Ru0+BtM/aB7yGhZ7xbEBAasBATDEKK3UGeDqn+m0=; b=z1TAxQkHoh+Xlf1p2liqIugklCEYXWXfU/U1KJ474TVGYLj13cAAYW+2DP0GsPn/Eb CRXbui/sxQi9l15KijYgTAiAtjPDZ2R81OExIIHlcNk6wr9JgI5V7eNgWMamScpK2Wvh j3hZPGVUXkiIeOmchA9UGSXT9emYmTILSmGp2mHRlJimn2FrFzXacAAyaTWXPERmuDdy HSQqHNMKX7diHre0+qnP64YqWg+Grru5dNucSJw5KmII3lQN/W1cVEYrHCdumbpf0pfB lc2ifuszHUviImVW9K7WKM/U/uKc7+SZ+YgLYK53ds8EWeD2rjhd8DpOxK91XeDtnvoy 2sEA== X-Gm-Message-State: AOAM533nVULbZfkymxUS1kPiqhpjW8rTYC6hozjmpS+svZ0hQBfxCnCM UBP0hTNv+MuAMMqYQBt/gc0jDA== X-Google-Smtp-Source: ABdhPJyeEeyZIsZ4WhkFRgw0emqFkV7ttZSVMNG9dk9Ep+V85jB+O7jLU8pqmode3U9tVzJ9KWDLnw== X-Received: by 2002:a05:6a00:b49:b0:49f:c8e0:51ff with SMTP id p9-20020a056a000b4900b0049fc8e051ffmr15936789pfo.36.1639119021703; Thu, 09 Dec 2021 22:50:21 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:75dd:4e0e:4542:936e]) by smtp.gmail.com with ESMTPSA id nn4sm1639035pjb.38.2021.12.09.22.50.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:50:21 -0800 (PST) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC v2 01/20] part: call part_init() in blk_get_device_by_str() only for MMC Date: Fri, 10 Dec 2021 15:49:28 +0900 Message-Id: <20211210064947.73361-2-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211210064947.73361-1-takahiro.akashi@linaro.org> References: <20211210064947.73361-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 at phobos.denx.de X-Virus-Status: Clean In blk_get_device_by_str(), the comment says: "Updates the partition table for the specified hw partition." Since hw partition is supported only on MMC, it makes no sense to do so for other devices. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- disk/part.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/disk/part.c b/disk/part.c index fe1ebd4adf7e..c0556a41e57f 100644 --- a/disk/part.c +++ b/disk/part.c @@ -427,7 +427,8 @@ int blk_get_device_by_str(const char *ifname, const char *dev_hwpart_str, * Always should be done, otherwise hw partition 0 will return stale * data after displaying a non-zero hw partition. */ - part_init(*dev_desc); + if ((*dev_desc)->if_type == IF_TYPE_MMC) + part_init(*dev_desc); #endif cleanup: From patchwork Fri Dec 10 06:49:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1566195 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=uaT2V/ov; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J9M453z2kz9sR4 for ; Fri, 10 Dec 2021 17:50:45 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 66BE383112; Fri, 10 Dec 2021 07:50:39 +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="uaT2V/ov"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4300882F96; Fri, 10 Dec 2021 07:50:30 +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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 20F0E82D5B for ; Fri, 10 Dec 2021 07:50: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=takahiro.akashi@linaro.org Received: by mail-pg1-x534.google.com with SMTP id g16so7283641pgi.1 for ; Thu, 09 Dec 2021 22:50: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=aDXZpBFciB1TCl85HxxTr1gYe7xaD2d3VLbPxF/8dMY=; b=uaT2V/ove3v2aRGjLxU4GC3LvcSwcdo5uksCyf/a7Yz7FZKz+Sh0xluXPYT59b8nY1 rP4ntEUcB5hRHSCOUCWAMquTikaUEnZ332wB2q9EY15dIih8YxPdFh9/DmX6Y329NTEp VusaIQykmxe+m/nVHODsI/K3UnWOFvHkQZMDwmEy3ZPzFULtaaJlOEPJthU4M/gk0Lpd DZVcVsUynbnXzikH6QNEvwqOSkxOKS+L+mALw3wmMII72MOAWy0jsYcGqPT/LB8ZFLiz LnzbP6R1fWr436f1SDdSPQGo48IjRba09yxPj8Ii9sbpEQ1jblf7OqkbSeXmJ4r/Xw0p ezwg== 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=aDXZpBFciB1TCl85HxxTr1gYe7xaD2d3VLbPxF/8dMY=; b=LTWZynDwFZESURa8vnD9AdpeGN5q2AzACkGUhv6sA/G/mJIAFP5U1NklF9smpbF6Eh vbVAKP5xyKCm2e4W3QriaeUgwd8FHBiN9hyvJ7/WKINMu1Vn+Ei2ikkmGv3dPrED4a4D NDi8iU4Y/9607g1nwEsaC5pUjECBjGXdntjXfSCW2BdPviAYIt4e5+AEutwEl77fHZdL +O1FH9ciTFlxYh9sSCZRjQ7hlzq/gzySm9c14bNPT0rcrQDAUVHoiYNqEZW5tQZ6Cs4B d9UmnFc92juC7iazHSTaJxZeX7GzKDHHe+NRDZMlzP7E87dlX2L5/uFDdQ3Q7GEU3Jsp TEBw== X-Gm-Message-State: AOAM5302tC2YpEIMDhMG2qW1+MT/TjsIwjdchPINMzin8kUzNt/zlvE7 ydB1KiHumx+0itXb1NA2SLdxXw== X-Google-Smtp-Source: ABdhPJzhPVHZ6Dz/Mq3z8wX6mxORO750p8DeX/vVVWp0g3e0fWbsdOckI9qRrR2NMgX2o966uc/wuA== X-Received: by 2002:a05:6a00:2af:b0:49f:c4b0:879b with SMTP id q15-20020a056a0002af00b0049fc4b0879bmr16252481pfs.55.1639119024547; Thu, 09 Dec 2021 22:50:24 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:75dd:4e0e:4542:936e]) by smtp.gmail.com with ESMTPSA id nn4sm1639035pjb.38.2021.12.09.22.50.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:50:24 -0800 (PST) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC v2 02/20] blk: add a helper function, blk_probe_or_unbind() Date: Fri, 10 Dec 2021 15:49:29 +0900 Message-Id: <20211210064947.73361-3-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211210064947.73361-1-takahiro.akashi@linaro.org> References: <20211210064947.73361-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 at phobos.denx.de X-Virus-Status: Clean This function will be commonly used in block device drivers in the succeeding patches. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- drivers/block/blk-uclass.c | 13 +++++++++++++ include/blk.h | 12 ++++++++++++ 2 files changed, 25 insertions(+) diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c index 83682dcc181a..f7ad90e8890f 100644 --- a/drivers/block/blk-uclass.c +++ b/drivers/block/blk-uclass.c @@ -670,6 +670,19 @@ int blk_create_devicef(struct udevice *parent, const char *drv_name, return 0; } +int blk_probe_or_unbind(struct udevice *dev) +{ + int ret; + + ret = device_probe(dev); + if (ret) { + debug("probing %s failed\n", dev->name); + device_unbind(dev); + } + + return ret; +} + int blk_unbind_all(int if_type) { struct uclass *uc; diff --git a/include/blk.h b/include/blk.h index f0cc7ca1a28c..ef79e7b27b0a 100644 --- a/include/blk.h +++ b/include/blk.h @@ -369,6 +369,18 @@ int blk_create_devicef(struct udevice *parent, const char *drv_name, const char *name, int if_type, int devnum, int blksz, lbaint_t lba, struct udevice **devp); +/** + * blk_probe_or_unbind() - Try to probe + * + * Try to probe the device, primarily for enumelating partitions. + * If it fails, the device itself is unbound since it means that it won't + * work any more. + * + * @dev: The device to probe + * @return 0 if OK, -ve on error + */ +int blk_probe_or_unbind(struct udevice *dev); + /** * blk_unbind_all() - Unbind all device of the given interface type * From patchwork Fri Dec 10 06:49:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1566196 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=RGKGRB/9; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J9M4J2sKzz9sR4 for ; Fri, 10 Dec 2021 17:50:56 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 16E7282982; Fri, 10 Dec 2021 07:50: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="RGKGRB/9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3780582DA1; Fri, 10 Dec 2021 07:50:35 +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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id F271F82FAB for ; Fri, 10 Dec 2021 07:50: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=takahiro.akashi@linaro.org Received: by mail-pg1-x52a.google.com with SMTP id g16so7283727pgi.1 for ; Thu, 09 Dec 2021 22:50:28 -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=RGKGRB/9J7UVNjx24s10qv1aiNocGebL8N+xIjDVf+2DfT8VT5/2EqsWMiJP7PbEsM AcWxAxbPB9EPUPRhhVwLQGfIovy29e/l7KabtxQgB2q4z7utqhcsJRFQRgLSkdqu1E8t vSC8T0LFxnPwwe4ViX9+TLcIC1N4oK7NPgkaKCaAPNgO5Qq5hpjAmZ1n1mGjqdRCh6tL QP3Wm9rkrcTvEvHvPewPllJ99dRV+yHY4Wx40bDh+GDu74qBEvRWrjaYZo1eD6o5DG7i 50fgzPAJCzGGRkLrAW+dzomHROa+orzIMUhJyJY4BOtyEGoAuXm0CCe84H6obV1hoqwo O1sA== 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=rf419/PUu3oqASpHpxzL8hbIOifopw+5NGUkHDXmIstG4FeU0wLsqiRqOOONabepSc Oag3VrT0qKc6iw5GAmBl14NlRJ+8XjtMpdTF9zx2X9QsHSFb464JJyD/41g5ZybVgTT3 Vvi0Vhy5Lpcx5a6dpGq1P1GsIkIQ7PN+oQD9vJNdaZhDVZMMacu4/N+jtchL08GdetPX vCb0A9wTe3EYCFP8xzteyRiiN1x5caEgpYqZnbvmjAN9P9w0l7d3YELE4eQJjKxZPugY FjaCpk5dE3ztoe29v3ckjwN6MEbE1keAjbjUEavoIQTdB5gsJUZg0A8yWu3OVPIOeQh7 pxYg== X-Gm-Message-State: AOAM531+rcUpgA9dmBxkdqtNIl608mAHJPm5YJOfIK4AjUZ9hAQtZ6BS 5vsOuu3/MJtGQVbhEOq80LgX7OC7e0wGdHlL X-Google-Smtp-Source: ABdhPJxHO4+MYV4/14vvFL+fwdJEE0nfmzTf0jI9I4tMQO2BBOxSWVbym8L8CXopgWYzMp+hjZNHpQ== X-Received: by 2002:a05:6a00:21c3:b0:4a7:ffeb:ec1f with SMTP id t3-20020a056a0021c300b004a7ffebec1fmr16481857pfj.60.1639119027404; Thu, 09 Dec 2021 22:50:27 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:75dd:4e0e:4542:936e]) by smtp.gmail.com with ESMTPSA id nn4sm1639035pjb.38.2021.12.09.22.50.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:50:26 -0800 (PST) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC v2 03/20] scsi: call device_probe() after scanning Date: Fri, 10 Dec 2021 15:49:30 +0900 Message-Id: <20211210064947.73361-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211210064947.73361-1-takahiro.akashi@linaro.org> References: <20211210064947.73361-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 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 Fri Dec 10 06:49:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1566197 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=NfuoF0EQ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J9M4X2LWBz9sR4 for ; Fri, 10 Dec 2021 17:51:08 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0DDF9830BE; Fri, 10 Dec 2021 07:50:48 +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="NfuoF0EQ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C2F2682982; Fri, 10 Dec 2021 07:50:37 +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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2C09F830BE for ; Fri, 10 Dec 2021 07:50:32 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pl1-x62c.google.com with SMTP id y7so5695839plp.0 for ; Thu, 09 Dec 2021 22:50:32 -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=NfuoF0EQ7Ai/dXAsW7E/8hjK5RsbSVbvgSebH45jVxwdzatbld5faguwiZizTlq5bC F2Fj72W7KSUbAUFu4qPELA876fUAPass+gaj7UCdrkXvJvPlp06JCien6MpiAI+VRDqs UFEht08eboeHu1I/fY1fIZY7OlJsColclvxHzlG1uKnez2DPsHUqMdB7v3dvJ+qENLh4 qUxi7V9mkeiYW8NdEDb+8kbJJzRHmHzunHIdwVsfR/GO7Tl1JdD4WytDAYwoprLU/IeN hmbepSvkVIEIaYOMFFq6Ilg68b7mBRHqaYJ2tZ+6AYz+GJjjBopZswhM4Mp33LWz+rgE bQIA== 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=cQBYSWF3OiJ+e9aigGlXfQr1mAJxjvnvZ1pG9tmYcAJJfjVztKao3B88JKvqT4fx6t 7DaF0nHOTor3B+ko+TyqtgbJfI4f8gXIzRMAd68SMoDqB9b+AW/bFoYkeft5exN0ZkMH kGrI+pxNBONNB4cK3UDPr3/h/GdHhm2F4Cz2hBunI82J9ahOMGOEMD/TB4j8CGV1nWKD o5VPb7f0gQ5Ny3fJJF4OnyhjLYYIGmaU4Qy3yOuxCKzfIMVz1tkMUD5pTOlOAhCU6vrs NuUKAJaz5tYTS1FcGOsyL/mvia7c27Oa4RH/miXjMHMQuT0zAlbsJsMqXwMgKKEHJPgO gWKQ== X-Gm-Message-State: AOAM531whgnZNmf9v8yxQOkLCPP0gwzTh8PQGQUrzWrnH+mJxgZtk9L2 LQr5d2EOVsQhcSZ720qXfZHbnQ== X-Google-Smtp-Source: ABdhPJxLn+HyV2Y7REGitrDCFDvpjKdn1JaBufqEiZym4oQjWe/UVaqMLfdidCEOGlN/AsMFwNb+AA== X-Received: by 2002:a17:902:da8d:b0:142:4fa:9147 with SMTP id j13-20020a170902da8d00b0014204fa9147mr72309385plx.72.1639119030572; Thu, 09 Dec 2021 22:50:30 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:75dd:4e0e:4542:936e]) by smtp.gmail.com with ESMTPSA id nn4sm1639035pjb.38.2021.12.09.22.50.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:50:29 -0800 (PST) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC v2 04/20] usb: storage: call device_probe() after scanning Date: Fri, 10 Dec 2021 15:49:31 +0900 Message-Id: <20211210064947.73361-5-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211210064947.73361-1-takahiro.akashi@linaro.org> References: <20211210064947.73361-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 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 Fri Dec 10 06:49:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1566198 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=ljb8vjE1; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J9M4l4cVXz9sR4 for ; Fri, 10 Dec 2021 17:51:19 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5F6648340A; Fri, 10 Dec 2021 07:50:52 +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="ljb8vjE1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F2BC2830C5; Fri, 10 Dec 2021 07:50:39 +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 autolearn=ham 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 163AF830A7 for ; Fri, 10 Dec 2021 07:50:35 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pj1-x102e.google.com with SMTP id np3so6145566pjb.4 for ; Thu, 09 Dec 2021 22:50:35 -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=74wqDPeORcXuh+mDzjDs/7A1t3UgXTLsYe1yBw20K2M=; b=ljb8vjE15rll8UHRtfaL183gpwlbEgRcM4gmMwYtxd9gOrCnTeZaaCbvNOU5aMGumI 2smOu6VLyv6DKpNFoXwPtWK2spVkmE8O5vtImWyIg+dmRU3lQz0AOuQCAAoC7lSlfYji Oj3Ht9+wzR0pMBkFqyBTTYy16UCE8yXU0zWNjkxSck+3jckLO7k7G3lzt6b9QT2DWrsa TLW24EsfKPbQlABdrynibbjgfoLkprfLXWpc17k2t9w3PMtAOpNtVgrLlywnyd39Q75a WMZvWp0PmGjE+N+rakeulzd2n7C859y56/Nt8csxIs0ZMusx3D6vnxfJLiWBsawGH+3a YW5g== 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=74wqDPeORcXuh+mDzjDs/7A1t3UgXTLsYe1yBw20K2M=; b=eTY5fSYmnRoaW0OtQZNk+cZizbCKhQB+Wniu3ISpbPqQnWvf+sx8UGOWHI8TOI833O TblMf3c//I1bBDH0P+pQMGDmJZF+FO67NCIxR0Bec100DKqfPzV57e5Q1vBKf3XQFMOi P11vUsqeYj4bGCwUTC1DB97h1fHe9/swSptvDRhph9UqXsGroO2YPpE4ZW+/gSEkzfK3 5QR67qnXyDYcuRz87JI7WQKQVF+aNZyFv3ctdY7bm5WxGeHhs/sWmxvLDuXzRyQt6JmP jzdzSUhxRQGXNA/POMPcA1ri8/I/ROfqAlDgtsAZRzggIh49D+5RvltdSdjKaHMG/EYe +5zA== X-Gm-Message-State: AOAM532s/P7xpUD1ftJ2uDyeY+crbM6LYH37LlPzYjuhH66E9Jmgz29s hBu9fGhO2sT4Tm07DUPRPHuF6w== X-Google-Smtp-Source: ABdhPJxxW5BvdwyaIjh3AyBkgV41+PZamvNuC+oe3Ztdx4euXUtc6pS15bzftx8qjEIUGsQPlo1Fiw== X-Received: by 2002:a17:903:1210:b0:143:a088:7932 with SMTP id l16-20020a170903121000b00143a0887932mr74539452plh.11.1639119033469; Thu, 09 Dec 2021 22:50:33 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:75dd:4e0e:4542:936e]) by smtp.gmail.com with ESMTPSA id nn4sm1639035pjb.38.2021.12.09.22.50.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:50:32 -0800 (PST) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC v2 05/20] mmc: call device_probe() after scanning Date: Fri, 10 Dec 2021 15:49:32 +0900 Message-Id: <20211210064947.73361-6-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211210064947.73361-1-takahiro.akashi@linaro.org> References: <20211210064947.73361-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 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 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c index 3ee92d03ca23..6c907b65fde7 100644 --- a/drivers/mmc/mmc-uclass.c +++ b/drivers/mmc/mmc-uclass.c @@ -418,6 +418,7 @@ int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config *cfg) bdesc->part_type = cfg->part_type; mmc->dev = dev; mmc->user_speed_mode = MMC_MODES_END; + return 0; } @@ -467,6 +468,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 Fri Dec 10 06:49:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1566199 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=vequKxCF; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J9M4x42Njz9sR4 for ; Fri, 10 Dec 2021 17:51:29 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E574C830C5; Fri, 10 Dec 2021 07:50: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="vequKxCF"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8EF4582054; Fri, 10 Dec 2021 07:50: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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) (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 D5BA783012 for ; Fri, 10 Dec 2021 07:50: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=takahiro.akashi@linaro.org Received: by mail-pj1-x1029.google.com with SMTP id j6-20020a17090a588600b001a78a5ce46aso8788306pji.0 for ; Thu, 09 Dec 2021 22:50: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=bl8C1X+TOksXaJYBdDnrMAHxXq6nwVHHyloe9nAVxDA=; b=vequKxCFnJz1tBKdMetgjIdDsMGhAvpr4/DOW2ut2uJA3EL/7ttNEwoYpSYj8/85TA ohJRj9kGZqNgmd/b7LUHJOnCrK6E8nEfwx09hzIfO2SnJiyx7ZQ5sVAr4u6kNqfLz5Eb +ntQpPeRis2X3FENpmAHM/fhyTOB9k/ij0z3pc68MsUgzwcmkBra9pmbg0DRDQUXHFkL HM2Kr8ffdM59h0+fqk7nX4jd/GhgIBR/vpn5Qp5IZ/8w9oJtX+sEjyuZ1tbzz5LHlOXI F4Ck4GXDWM5hh7kkDO7X6WMCe8h3X+3lxemvlv3xa+IsvsIxOadT0g9t1hcBzEVegSoJ IW4Q== 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=CJiyA7R1E3KKd19cfciN6/D7bv+yuKpvUSwwHjv7cpuj9Kkg6jF9hJSL6helMfzmMq C6xdS8ozVCO1+wE5C055XLAqwpcAvZXysWo7XfBe/s2B8ltYlCaavcVGpFKCYWRVsjfA MsKzu7vFvGbkUf7Z/Dp8QBAD6PfxIdkYXmC5UzSjgcmDQxlAg1Fumu+9oruQJltEvD/r 1TbsMcZ546XEqqRuHIMrSYzSpuJJbBvM71am87nRXF+C9k39vvY1SeEa4bZVNFI1wwiY 5W+anjdU+d1oBIstH5URPDhccmpwhWWEfPu3m3SHwETaAx1Ulb7D8cXJEq03yxllMACQ QOsQ== X-Gm-Message-State: AOAM530Z3TqYzrX5ZueuCj0yVp2WguucpemqELxzgN1/bWx3xQJQU5np Gk4u3tl0qKyMtQKjc1dd16FzcQ== X-Google-Smtp-Source: ABdhPJyefToOi7oFpN98Zv/oNPkQy5DwKKsPoDMWvd6FXDAzEzj1WXmAOFz7G1ZpA05C0vi5FBf9oQ== X-Received: by 2002:a17:90b:124d:: with SMTP id gx13mr21765472pjb.106.1639119036307; Thu, 09 Dec 2021 22:50:36 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:75dd:4e0e:4542:936e]) by smtp.gmail.com with ESMTPSA id nn4sm1639035pjb.38.2021.12.09.22.50.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:50:35 -0800 (PST) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC v2 06/20] nvme: call device_probe() after scanning Date: Fri, 10 Dec 2021 15:49:33 +0900 Message-Id: <20211210064947.73361-7-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211210064947.73361-1-takahiro.akashi@linaro.org> References: <20211210064947.73361-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 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 Fri Dec 10 06:49:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1566200 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=KXwXq55v; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J9M582Gnhz9sR4 for ; Fri, 10 Dec 2021 17:51:40 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BD1268345C; Fri, 10 Dec 2021 07:50: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="KXwXq55v"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CD58E830A2; Fri, 10 Dec 2021 07:50:47 +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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) (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 BD8CE830A7 for ; Fri, 10 Dec 2021 07:50:40 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pj1-x102b.google.com with SMTP id iq11so6158967pjb.3 for ; Thu, 09 Dec 2021 22:50: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=c86AUGw9p8OP3Ujy+6u4RxbpzSXHf7b/TNv4ldBBLdk=; b=KXwXq55vCbwtFkH/Goe3p9qcL7+YfeE56rlqEgaCmNL/VtPwEidWCzdO03a+XbaD4k GxdvnumgHF2U6Zrie3DSpuWVOE57ZdFh1tRKB9NIBmQHeG6Ql81y/WcYLpMTq26N9kQd SQjrZ/hjJPWvuDnDY05Of3X4Kvg5eR9C8ML5aF/u/bviY32/qJ2czat4OTJEK9ekpQI6 jZXJoPEyyP0l6Hu9v6gENj3Fo3O4Ee9fcU036HH5yJLA6jB3HJ8cx8kL6eWxxMH84nxF bU5hkvC70wHYWq51qqMdALxjrhHDtYbm5HxBZWhP025SdHizlKzS91wUib4F4OULhbua r5/A== 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=c86AUGw9p8OP3Ujy+6u4RxbpzSXHf7b/TNv4ldBBLdk=; b=fDSXqjHW2gSXGzCBAokSbmEsXg0hmMC2hhaDdiBUCL7svHoA9l7h/mPhQo41hhYB52 i7jS0+ejr5f8WXi+T+ywCibFr50nFVNBVRJWlQAd1FwBjfuQKKrsS63JU2r1lgG/Vr4v ziusEBHI+RjPuHKuzO40SDSfkyjbbBrmFG5THNHNDnpy2hmDNPNx0vESFdLD9x3h669E d/FhIPBLT9bz/nKlLF+LgrBLblvXZDjIPPPv/r49G29n7g+korqX9+NMt83ug59dflAa ZBp/Ael5HNMieZmyhgAnbyagq+Ain/SEsZMXZUWkm3dPXAAiyHiquEk5cqcq3xrVNizp ZbSA== X-Gm-Message-State: AOAM532BesHvEhVwwQ1v1nA6BRamxNWja1TYVWkVwTGj2Kt0HOAYQPvO tpQzMx7XnXxDFok4qF3OZ75urA== X-Google-Smtp-Source: ABdhPJzkbbcTM3jVQr4ytCotiBjruxRQ1o9ZL92jN37Xybf307B/mKay2iB6hG4Y/wqG/WdmSgw1Og== X-Received: by 2002:a17:902:d88b:b0:142:8acf:615b with SMTP id b11-20020a170902d88b00b001428acf615bmr73878041plz.62.1639119039200; Thu, 09 Dec 2021 22:50:39 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:75dd:4e0e:4542:936e]) by smtp.gmail.com with ESMTPSA id nn4sm1639035pjb.38.2021.12.09.22.50.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:50:38 -0800 (PST) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC v2 07/20] sata: call device_probe() after scanning Date: Fri, 10 Dec 2021 15:49:34 +0900 Message-Id: <20211210064947.73361-8-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211210064947.73361-1-takahiro.akashi@linaro.org> References: <20211210064947.73361-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 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 Fri Dec 10 06:49:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1566201 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=o/IaTh6V; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J9M5L229kz9sR4 for ; Fri, 10 Dec 2021 17:51:50 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 66EAA83267; Fri, 10 Dec 2021 07:51: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="o/IaTh6V"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7124083230; Fri, 10 Dec 2021 07:50: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,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7F38F82FAB for ; Fri, 10 Dec 2021 07:50:43 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pl1-x632.google.com with SMTP id k4so5645282plx.8 for ; Thu, 09 Dec 2021 22:50: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=F9NEStEGogNVLvNc4mBNKs8gXvObGAndUA6jBNqxsDs=; b=o/IaTh6V0lDY6oTTK8/tg+chTksrYXdGkOpTr5UOl8l8zAsc5uoz8SMhX5kfR30vsV 4YzcWpJcY/JyigrrIR6VP/0vNun/A+ARrzbcSSe/sWLLqfGtW1Un/ZJg5PCmrBfaDosK 5lLeu2qr57wK8y4ToOmwjFwNP7Rwkds70vzPuBblgMRXk4oVkz//7RLbwpgxxkKlVHDm QtyBbe1I17/n0hhmpIiMQLSD8e4oKds6wVDhL37FY+N+aYiTpWeTM1RdZSNCwY5a2/IH C8aS3vD2Rnck/3DxBC45gaTfNOxKH+av5fIdvMVL55CJoNnYy+eiWCqjzhicvsr8st/V h2mQ== 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=F9NEStEGogNVLvNc4mBNKs8gXvObGAndUA6jBNqxsDs=; b=0ySM8+xiNPvl0KTQxKWkctIY8VGC6gPEtpuLIv9Dwpr3ScfCEN/1LzG3PsLV4cK6CM ziD3JzuQMT3Xo816SXh0CsGKfQAFaQbTBMf+SvtZFXPRd866TtE0espf5FDdHQnMKLFs Pd/4SiBEcMPucPy8NZ6WbwYikiCy42CZy7jREt9Yj0fNTL1vTacFV4E+g3/bkT/suzCH STshltrpdm3txbkIK7kJPKmzx9Fhe1AZLgf6GX+F54889vT+MfrY44tQIyAEJNrmKMUE OwxcZuC7zpatFVnv+TKR3z83hkqySRfdAjbY1tWJsFl0vFjpce2h0G3szlU+3WXx0Spu aGOQ== X-Gm-Message-State: AOAM533es5s0QVpakD51NIHofa82BP/GoDlNUJ0vzfS6auh83gv6Esuq ddlQtyvgrkcYnbdkgu/ybz2prw8XHjez2bbl X-Google-Smtp-Source: ABdhPJyPUxZ6efpfiSavVhzjsVPqccXsoN5+mS0BYEkTAt5h6v84OwJUaEHyPhbfAICM90zDF8mMhg== X-Received: by 2002:a17:90b:2389:: with SMTP id mr9mr21996921pjb.152.1639119041961; Thu, 09 Dec 2021 22:50:41 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:75dd:4e0e:4542:936e]) by smtp.gmail.com with ESMTPSA id nn4sm1639035pjb.38.2021.12.09.22.50.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:50:41 -0800 (PST) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC v2 08/20] block: ide: call device_probe() after scanning Date: Fri, 10 Dec 2021 15:49:35 +0900 Message-Id: <20211210064947.73361-9-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211210064947.73361-1-takahiro.akashi@linaro.org> References: <20211210064947.73361-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 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 c99076c6f45d..8071b5870931 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -1151,6 +1151,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 Fri Dec 10 06:49:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1566202 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=oPKZddO9; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J9M5X2Qt7z9sR4 for ; Fri, 10 Dec 2021 17:52:00 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9479E8316B; Fri, 10 Dec 2021 07:51:11 +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="oPKZddO9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3AFA083012; Fri, 10 Dec 2021 07:50:51 +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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) (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 305B8830BA for ; Fri, 10 Dec 2021 07:50: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=takahiro.akashi@linaro.org Received: by mail-pj1-x1029.google.com with SMTP id j6-20020a17090a588600b001a78a5ce46aso8788509pji.0 for ; Thu, 09 Dec 2021 22:50:46 -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=Dn4vUcXR703H4rWltIKdHVHwUawMm6yEwEClHG4bWi8=; b=oPKZddO9mPnvvbyBoSPr0N//kO6PG7WayeR+2N5oeljToNwhWCQCx1DED+m1cCOmmh i23/R8KEpwoXAdqs3ubz9nRwcyidyXIaUKmFyzf7b/FPAdShGiK/kNBSWJ9aJYrg3Gg2 zbXUwbVhevd/a4x3jxlNEEdiBwyt+9b+ch9VD5o+IzOor1Fpzo03mqNZhyV/9EmUHAJ5 uDjxaYwZdXCdfb62xtgtj3lHoAyQxTDRfH2QR2goV+Hc/FidoBhjRPZSeRr6TlYkU8Yv GKnSNOQFv7qHuDoA24wY2SAfcgzBcJQ71cKv7zaUbXnL8R6s3vxT22laVgDzGH79ToEK DHRA== 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=Dn4vUcXR703H4rWltIKdHVHwUawMm6yEwEClHG4bWi8=; b=GcJz3wl8WleaXcFqjxuSMhq3Scimb2zhmMqj8ZmaNUSV80ilu9lOyh2pSobkDEB0w3 cU9g7/G/+98Ru0kxgfanUEijJr17kQGkFrAQfdwQeV0D9enponGPDKuHc6dg8N/obXcB qMo6LUPFjo6qDRgrJwmY53gtKi8A9coVa16XkkTB4Eed3/hufZ4l4WPHdQDNYFJtblGY Q14RobXLMrzFgx1jadcDNBkits1x4wehcNuhBj9FXpL8UE/FGE/lX/SrZFqxXzKSmZn7 2Y5XCBhEQcaQcno19czZYc7KYJxhbbjc5LzWOEIvbE8lQOpldv5Zm1sVIP9zZZStiOeE DXwQ== X-Gm-Message-State: AOAM530noWcwAk98hoYYjXfNZ0ObyNK1zEeShXCV+PQy0KN0l+Awx5YC aBnNtHRLHHBxLoeQttWwsBnfqQ== X-Google-Smtp-Source: ABdhPJzO/KA8RTH/wOqsemS42MNfBn3hTvMlF8oylri/WMIt0HpFxaka5Iu1Oq7sWv38yQSKgdsMqg== X-Received: by 2002:a17:90a:be0c:: with SMTP id a12mr22060375pjs.204.1639119044715; Thu, 09 Dec 2021 22:50:44 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:75dd:4e0e:4542:936e]) by smtp.gmail.com with ESMTPSA id nn4sm1639035pjb.38.2021.12.09.22.50.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:50:44 -0800 (PST) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC v2 09/20] dm: fix an 'undefined' error in some macros Date: Fri, 10 Dec 2021 15:49:36 +0900 Message-Id: <20211210064947.73361-10-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211210064947.73361-1-takahiro.akashi@linaro.org> References: <20211210064947.73361-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 at phobos.denx.de X-Virus-Status: Clean Due to a non-existing parameter name in macro's, use of those macro's will cause a compiler error of "undefined reference". Unfortunately, dm test doesn't fail because a wrong name ("&dev", hence it is accidentally a valid name in the context of a caller site) is passed on. Signed-off-by: AKASHI Takahiro Fixes: f262d4ca4b2b ("dm: core: Add a way to read platdata for all child devices") Fixes: 903e83ee8464 ("dm: core: Add a way to iterate through children, probing each") Reviewed-by: Simon Glass Reviewed-by: Ilias Apalodimas --- include/dm/device.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/dm/device.h b/include/dm/device.h index 3028d002ab0d..f7900417066d 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -959,8 +959,8 @@ static inline bool device_is_on_pci_bus(const struct udevice *dev) * @parent: parent device to scan */ #define device_foreach_child_of_to_plat(pos, parent) \ - for (int _ret = device_first_child_ofdata_err(parent, &dev); !_ret; \ - _ret = device_next_child_ofdata_err(&dev)) + for (int _ret = device_first_child_ofdata_err(parent, &pos); !_ret; \ + _ret = device_next_child_ofdata_err(&pos)) /** * device_foreach_child_probe() - iterate through children, probing them @@ -976,8 +976,8 @@ static inline bool device_is_on_pci_bus(const struct udevice *dev) * @parent: parent device to scan */ #define device_foreach_child_probe(pos, parent) \ - for (int _ret = device_first_child_err(parent, &dev); !_ret; \ - _ret = device_next_child_err(&dev)) + for (int _ret = device_first_child_err(parent, &pos); !_ret; \ + _ret = device_next_child_err(&pos)) /** * dm_scan_fdt_dev() - Bind child device in the device tree From patchwork Fri Dec 10 06:49:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1566203 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=bvHfLATo; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J9M5l13KLz9sR4 for ; Fri, 10 Dec 2021 17:52:11 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F3A4883515; Fri, 10 Dec 2021 07:51:15 +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="bvHfLATo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 054CB8203C; Fri, 10 Dec 2021 07:50:55 +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 autolearn=ham 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 EA6828331E for ; Fri, 10 Dec 2021 07:50:48 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pj1-x102e.google.com with SMTP id n15-20020a17090a160f00b001a75089daa3so8756186pja.1 for ; Thu, 09 Dec 2021 22:50:48 -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=5ofz6CLdNamhisd2BzpPocTNzh4e+6k+0LG9jrDMQZs=; b=bvHfLAToCiBm/vOySAtqCKrSUwKlPJDQblx7nTj5fwe9MBCKRHON2SXKaD7NQHLnDa BZwXF16TKDXR0NJWCYfvXlGpyY4nqC+dRqhypaJ89idTF+bBohUwB2drJYFCxymrEoUc gYBggSClwUcTgd99bqaN68skgiM+y6E1/useE/4B00KmKoheoZW3EqI5+uTkSp+QdCOM ViK0nCHkprLCfelbVYaJCWOlNr08HyJlVU2nZRtoyMGkCEX4qSaafU/nVGX0R5rw2NVR gh2gtIervPtvtBPIE64hWeSFRTHrWjmhqjkclhDrt66JB1TXqClhe47+BMXlsB3HhN9p n3bw== 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=5ofz6CLdNamhisd2BzpPocTNzh4e+6k+0LG9jrDMQZs=; b=hlX58wDb+U4xwDw5jqHrbjN3/riKm6e2eCTvp/Jdvf++Fz51tPjdnmM1C2yrBPDBK+ UAAb3jb5wtbvV9jvK7SDlHQplJVV4Lf1s+xnVBd9Mjvr9eI5iosfEe3Uot6iCBxEpfRX sGvNYgEwNzT/gatLI7VqhoOLykB5E6MhYchbPv4/N1rIh8X/q2swJwFZPt4vDhWhfxD7 g9N3YLZQWdWDBUX/kCO2MH39htMxEzEkEc+xOH3uMbckBkSZsWV4sxhGqFfD1XkODbf7 K+/Wx9MUeSmTTH+AaWfNGxyjoWUif/y36ErkSDTnRlG0vjedZuaJNihfxCBvJJNxxDcg f6SA== X-Gm-Message-State: AOAM531C53tajHgSlCTRsk0L4eBKx+IFNJu3/R2eYsJHepJ0ENreVCBb d/beWeD6wrqgwAeWLAE/fHFZtA== X-Google-Smtp-Source: ABdhPJwTs79JC2OoTuTsZZiPmh1mLvlVQjoE1w4FysZ2PI8AyWIJ9n9n+MybpxNC9SaimdZ51u8JFA== X-Received: by 2002:a17:90b:3849:: with SMTP id nl9mr21990192pjb.145.1639119047348; Thu, 09 Dec 2021 22:50:47 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:75dd:4e0e:4542:936e]) by smtp.gmail.com with ESMTPSA id nn4sm1639035pjb.38.2021.12.09.22.50.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:50:46 -0800 (PST) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC v2 10/20] virtio: call device_probe() in scanning Date: Fri, 10 Dec 2021 15:49:37 +0900 Message-Id: <20211210064947.73361-11-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211210064947.73361-1-takahiro.akashi@linaro.org> References: <20211210064947.73361-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 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 Fri Dec 10 06:49:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1566204 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=Ide03Cwo; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J9M5x1hBsz9sR4 for ; Fri, 10 Dec 2021 17:52:21 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DBCA8834A7; Fri, 10 Dec 2021 07:51: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="Ide03Cwo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C11648345E; Fri, 10 Dec 2021 07:51:00 +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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) (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 103DE830BA for ; Fri, 10 Dec 2021 07:50:52 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pj1-x102a.google.com with SMTP id h24so6175837pjq.2 for ; Thu, 09 Dec 2021 22:50:51 -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=bb0Hptkch8fV2ufC8L+MC8yxzYTdSIsniK0gym31g0M=; b=Ide03Cwofwee/QlARL4h/lsTUKlCBcNgBWCkKa8PpSSzdJgwouLHNWN12ncHSTmSXy X6Cyt3G/MC8Q3zdnsRDyEuJoBNZ7VK1sqFXqpXj6yzJJdIfN5Z2tQsasWKDbc+2orH3i sJsSwsv49r4wCP/5anLeF2uv+n/yvwQDenUSxLl0bNBQxAXOYSD5FfMtK+xq3vOhAJWI aABBb5FWd5EYEiwAkqU5yYDWBt2XUyi0nWlbf7h8Noemf9AZK2uc4HDuDTb0gvQ9w79s LxFY52qQVUGHS2K/RS/kxscSPTer/6SokTqlWXQ3DTeDnv0co53votCNK5PocQIl5Hh2 30bA== 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=bb0Hptkch8fV2ufC8L+MC8yxzYTdSIsniK0gym31g0M=; b=CozdcvQF3tRp+LfLyrXlPPqOt1+nzDlN9sbQDku7S1hLSha3nKUzA8cRHT6/8KNT95 UWrtqZ3y8hlvMwdfHPaBtX4RfvH3mPH69/hEFqsnIDrPs64+Oy4i0V6bjRRquRoG4QNC wyNXqHjf/571C0w873IZYsDaonFJK+MMVPfzP6dGpqihGxOA8zohP95bMGvFc9zaMhb5 X85iSwGSmY1a43Lq1B071N23tsDfPL5jo99qKmFn+rqPVbL4brsK6K2KZUfkLe/QJ1Eh o12pnl8Xpwe7s0E3oYDr5xlBzbKkG/iJTjcf6I99KwE+tSliVeoeRdR/P55QPX1ZJuhA RtfA== X-Gm-Message-State: AOAM5302c11cDVZMXpELH6kqiNCKGqs95o58juLUKW+Jn5WwQ4qxprau n1Fi8RqDJwNA1vv0UFrWe7GN2w== X-Google-Smtp-Source: ABdhPJwZfdOB259dWZBdLBznQHNBmN7rHoFZBfXNjMWzhQBKpmuAjKdQuvmeTVuKyXlRTFsQ2TO61Q== X-Received: by 2002:a17:90b:230c:: with SMTP id mt12mr21546916pjb.63.1639119050353; Thu, 09 Dec 2021 22:50:50 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:75dd:4e0e:4542:936e]) by smtp.gmail.com with ESMTPSA id nn4sm1639035pjb.38.2021.12.09.22.50.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:50:49 -0800 (PST) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC v2 11/20] dm: add event notification Date: Fri, 10 Dec 2021 15:49:38 +0900 Message-Id: <20211210064947.73361-12-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211210064947.73361-1-takahiro.akashi@linaro.org> References: <20211210064947.73361-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 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 fdcf4536d0f0..37b9276deeb2 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -482,6 +482,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 c500bcd7d8a0..bac7677e2f9e 100644 --- a/common/Makefile +++ b/common/Makefile @@ -90,6 +90,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 f7ea7c7a1e45..ca345f265004 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -822,6 +823,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 1aaa6c1527b9..aa2e780d2d7a 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 11d3959d20f4..a63454f1b1d9 100644 --- a/drivers/core/device-remove.c +++ b/drivers/core/device-remove.c @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -206,6 +207,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. @@ -255,6 +260,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 efd07176e374..a5ba8a111b4c 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); @@ -589,6 +594,10 @@ int device_probe(struct udevice *dev) if (dev->parent && device_get_uclass_id(dev) == UCLASS_PINCTRL) pinctrl_select_state(dev, "default"); + 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 16fd305a65c1..771cda57a584 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -459,6 +459,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 e6b71cbfd2b6..1d0fd0b33c66 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 e0e12ce1944e..7169fff7aa53 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 3cdf6849c57f..c3ccdf3fed83 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 Fri Dec 10 06:49:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1566205 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=lsBZunZL; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J9M674DZzz9sR4 for ; Fri, 10 Dec 2021 17:52:31 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 20BE78350D; Fri, 10 Dec 2021 07:51:24 +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="lsBZunZL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C536A82F03; Fri, 10 Dec 2021 07:51:11 +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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A186183459 for ; Fri, 10 Dec 2021 07:50: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=takahiro.akashi@linaro.org Received: by mail-pl1-x632.google.com with SMTP id b11so5632763pld.12 for ; Thu, 09 Dec 2021 22:50:58 -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=5ycV4eCQgzM+92pnWZI0t3c18bzKrR4QXUixcJeoN6s=; b=lsBZunZLWwPiOmDE8n+WQfYOyQAy5xqRDZASdmCoUEv5ZziWNCRICOJOxF2/JA6G4F Xu7oiNQOV4ArdkDTJQMuyJdhJoV4+YxLiP652PK/nV85Am+8bqwbWlSmELYXMnLXa7qk uOY4BdA7duF5ro9z6QTXFBCJba+ET9Vk+bBbrBRhnhpcsR+q59ibTgF7182hGi/cblpo HjWtXk77IeyTzNn3y8F9qEKg2L8fW+PvAhIzqJwPRdciRrxuGvrE6z/e4GZKgfrqtgOw Tf6nBwX+X3cPGzkiQo7Xqpo9hMbdu7++MGtguCPRwk5EeHi/ot8VzL9b5MT+l2eyPCNN H3GA== 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=5ycV4eCQgzM+92pnWZI0t3c18bzKrR4QXUixcJeoN6s=; b=ymnrx0doBPN+aHkKNk/R333ilW8TtGGPyCLZ3kId//nLf5tmQ67mRmfBsmUsrrvY/v wBMh1N8pY8eDn5YWBm9Dq+0nIYvEX8+CzJ41bpiIqnY1ceVy/cpb9/AxS9KW8PfrP95L EqXlvsPjMDP5GHxD1HGDV1K6AAAI79KH/65VohnLPLuP7kj5awU0TSgnlbSac0fNXM/X VRfZ5kf1+Vd4zyAl3b8WXpV8sbZi6FCngeMH7jg2tklsS2Y9ZhMxGNZJ18TCHxNMY8WU WJcHkOa0d79h78UAP1WzafLmXkSvemOi0WmQV0w5iXkAhihaPsRnlsuGRC4VOqPt1rCw +Lzg== X-Gm-Message-State: AOAM530fP61f8vY1QHURky0jXt0QXO/tFsZHWOJpv9/OzEwfGcSmQHYx rDZgaqed2g5nY1V4BGfGt1EbrA== X-Google-Smtp-Source: ABdhPJxHX8AI7/k62Jwq5WZ/vH78i33gGfbPot8P7va6b5mhaqeHADP2yW0MPrHzVro3uj6JTEQP4A== X-Received: by 2002:a17:902:c404:b0:142:4c7e:ab8b with SMTP id k4-20020a170902c40400b001424c7eab8bmr73829040plk.10.1639119057035; Thu, 09 Dec 2021 22:50:57 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:75dd:4e0e:4542:936e]) by smtp.gmail.com with ESMTPSA id nn4sm1639035pjb.38.2021.12.09.22.50.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:50:56 -0800 (PST) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC v2 12/20] dm: add tag support Date: Fri, 10 Dec 2021 15:49:39 +0900 Message-Id: <20211210064947.73361-13-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211210064947.73361-1-takahiro.akashi@linaro.org> References: <20211210064947.73361-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 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/tag.c | 162 ++++++++++++++++++++++++++++++++++++++++++ include/dm/tag.h | 76 ++++++++++++++++++++ 3 files changed, 239 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/tag.c b/drivers/core/tag.c new file mode 100644 index 000000000000..562df3590c44 --- /dev/null +++ b/drivers/core/tag.c @@ -0,0 +1,162 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2021 Linaro Limited + * Author: AKASHI Takahiro + */ + +#include +#include +#include +#include +#include + +struct udevice; + +static LIST_HEAD(dmtag_list); + +/** + * dev_tag_set_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, &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, &dmtag_list); + + return 0; +} + +/** + * dev_tag_set_val() + * + */ +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, &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, &dmtag_list); + + return 0; +} + +/** + * dev_tag_get_ptr() + * + */ +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, &dmtag_list, sibling) { + if (node->dev == dev && node->tag == tag) { + *ptrp = node->ptr; + return 0; + } + } + + return -ENOENT; +} + +/** + * dev_tag_get_val() + * + */ +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, &dmtag_list, sibling) { + if (node->dev == dev && node->tag == tag) { + *valp = node->val; + return 0; + } + } + + return -ENOENT; +} + +/** + * dev_tag_del() + * + */ +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, &dmtag_list, sibling) { + if (node->dev == dev && node->tag == tag) { + list_del(&node->sibling); + free(node); + + return 0; + } + } + + return -ENOENT; +} + +/** + * dev_tag_del_all() + * + */ +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, &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/dm/tag.h b/include/dm/tag.h new file mode 100644 index 000000000000..8f81b4f7ffaa --- /dev/null +++ b/include/dm/tag.h @@ -0,0 +1,76 @@ +/* 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 { + 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() + * + */ +int dev_tag_set_ptr(struct udevice *dev, enum dm_tag_t tag, void *ptr); + +/** + * dev_tag_set_val() + * + */ +int dev_tag_set_val(struct udevice *dev, enum dm_tag_t tag, ulong val); + +/** + * dev_tag_get_ptr() + * + */ +int dev_tag_get_ptr(struct udevice *dev, enum dm_tag_t tag, void **ptrp); + +/** + * dev_tag_get_val() + * + */ +int dev_tag_get_val(struct udevice *dev, enum dm_tag_t tag, ulong *valp); + +/** + * dev_tag_del() + * + */ +int dev_tag_del(struct udevice *dev, enum dm_tag_t tag); + +/** + * dev_tag_del_all() + * + */ +int dev_tag_del_all(struct udevice *dev); + +#endif /* _DM_TAG_H */ From patchwork Fri Dec 10 06:49:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1566208 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=LrlmCVYP; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J9M6l3xGZz9sR4 for ; Fri, 10 Dec 2021 17:53:03 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5E84D83112; Fri, 10 Dec 2021 07:51:38 +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="LrlmCVYP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 184E983112; Fri, 10 Dec 2021 07:51: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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) (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 722B7830BA for ; Fri, 10 Dec 2021 07:51:01 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pj1-x1036.google.com with SMTP id gt5so6179848pjb.1 for ; Thu, 09 Dec 2021 22:51: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=g5jbnk1IB+GiTYr6NhVHDYbCdhrqe/DkUf2QCnibqFw=; b=LrlmCVYPWlYeZGRlXqqnCVoowJt6aoDXnWLkJSwHXfp5xgL6tZn9exqin0WcAWn9WF 79by5XPW57YNp+JMlI7sDqq6C5qldBYwzGBLzZDtQGlyN2jq5PPPgHyO4ZBPjOsvh+Sy +23cg+PJMqZvG4kZGXxoQoVH9Oa0SV28r2Fu08a6MVmnUbFUFmtXmxfKHvY5o3LZ2nm3 dK5WfezDk2wrz4tsy908gwDhUrZnGbiWcfyXpTamGfwln2mZ7RQn7MdaP5gbm/F+6NpW 9Qqtv4mSrpZPzXBOlmA1JHuHXv8fYfcn7sL5F0AzFro3++0U1ZCAkDFBGRSya0+V8/m3 4qVw== 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=g5jbnk1IB+GiTYr6NhVHDYbCdhrqe/DkUf2QCnibqFw=; b=484Rm/bHDt2ztBz9BdEMEhpx0W1zga/Mt4c80iOkWAUdY1x43dYmwHkbg7bxKBp6k8 Hjp/l2Kwci4KVNrYnb7pgU7IKqyefS/8MdGgY2VIeQuJsBLovQ9Kxbzb8T09NtnAwwh8 WWIz6JCJYGT4fAow8HDm2kne5S3/5D4RCcncGck57Y7GOkhNXOIdw2Md9VW9Buh5NjsP ZhnCCcfD1Ye0Dyena3KbmHXgq7o6bv0sMiTHwZPYdMN+wD99f0hnhCfclVzFfjexI0UF /lyZI8xvyPTFma622kqh/5XQ1fyU2BqITCPExBNTrNeo3RJ77LEjAcSRj2WwUrJWJ8qS gwKA== X-Gm-Message-State: AOAM532I3hwKa2EtOlDbV8kYAnIjSDRznF89UzHtITG4lkg2qPQ5LH1E 4QxTkXreYRvuXbRpv5WXpwxqXw== X-Google-Smtp-Source: ABdhPJxR58zgzkAKbeKuPc0I6lLFqj/5oOMddUCKDjdf6WTMjVVBugh+yx4SBQFnHaYCo9FCvZ3TyA== X-Received: by 2002:a17:902:d28a:b0:142:61ce:ae4c with SMTP id t10-20020a170902d28a00b0014261ceae4cmr73173661plc.35.1639119059854; Thu, 09 Dec 2021 22:50:59 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:75dd:4e0e:4542:936e]) by smtp.gmail.com with ESMTPSA id nn4sm1639035pjb.38.2021.12.09.22.50.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:50:59 -0800 (PST) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC v2 13/20] dm: disk: add UCLASS_PARTITION Date: Fri, 10 Dec 2021 15:49:40 +0900 Message-Id: <20211210064947.73361-14-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211210064947.73361-1-takahiro.akashi@linaro.org> References: <20211210064947.73361-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 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 fd139b9b2a08..e69de8568b9e 100644 --- a/include/dm/uclass-id.h +++ b/include/dm/uclass-id.h @@ -82,6 +82,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 b66b07a1f04b..e492c2249019 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 Fri Dec 10 06:49:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1566206 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=V8Kcx3Cc; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J9M6L48HMz9sR4 for ; Fri, 10 Dec 2021 17:52:42 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CF6D38348F; Fri, 10 Dec 2021 07:51:27 +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="V8Kcx3Cc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3167B83468; Fri, 10 Dec 2021 07:51:12 +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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 53E738203C for ; Fri, 10 Dec 2021 07:51:04 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pf1-x432.google.com with SMTP id i12so7639868pfd.6 for ; Thu, 09 Dec 2021 22:51:04 -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=u4TnVOX5Qtgz+lAK7BS7cMpdxPf+iFXz/Br2DGxN0qg=; b=V8Kcx3CcrT27PY9ZF+cu6F08eV2dETufti6GhFqitUEnW3mqN1S62ksfCfwLFewcW3 DvZQO+cMDdOLTHn9gbUTIRY3XztVh1Uj2IgTQ1auVeu4aKbRDkAL1XCMHq9lCm9eHSn+ NWoqEcxtdoTVF6mNfx0Rifw5lj6lxseDjH8ubApijS7EWmfKbuuyHNoeGMx4UiXo+SBE SuiGtM1lA+YaxXrJtvv9L5QNcZwOgbuP2SciaUpyMYz77wEja0MSh2hLv38SHR7RQu0T YzxgkH2DYGRdIgP0y1gZsIxMbQUFkw23V+4QjImuy/3ujgIAiCRQL84b/iDuOMQ2KUHi GVVA== 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=u4TnVOX5Qtgz+lAK7BS7cMpdxPf+iFXz/Br2DGxN0qg=; b=NdXPhwvqSLmGwwnpLbD/hcYhJaUz92tQds+VzAJHtY+RmO42HdAgZsHUIPdrEHnpe/ VO6J1zN7/L1+hrSl7kyNSc+k/oAIMKDDDI13gh5F0H/DJkVQ/nTEGAIfP7eyUCvAAPNi NSqq8d4abErRA+82Ta/VqCT9ZMWZMCCeCX/E3G2E9c34PcfeoSn2foJLbUl/b7hShkvz +SROOem+j5umSUCQAtOsqFqLSbMh7qz4rIcstHjVWSQKuCJvDDSNzDTp9kzgFXgIgqlP nVg770pUw52Knr40k7JttzT6LjPTPnUeJVjD7+ozIiapUkAeNbW/GfMoMgOk9lNTI7Fq 7LPg== X-Gm-Message-State: AOAM530yCECKX8IsuK29L+NK1RJJjSK0ukqACs9g7pExyYkJd9fjrSHJ 9NZ2WmkKg0HmRONUiBKJBis9Nw== X-Google-Smtp-Source: ABdhPJypzuwkoT9L2AlLumdgsO2bO2eJ0uOWu81sPPg9KcfIVcGBrO9l2SbkfI4jHVDfgF6G6dq7yQ== X-Received: by 2002:a63:e515:: with SMTP id r21mr18374706pgh.337.1639119062775; Thu, 09 Dec 2021 22:51:02 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:75dd:4e0e:4542:936e]) by smtp.gmail.com with ESMTPSA id nn4sm1639035pjb.38.2021.12.09.22.51.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:51:02 -0800 (PST) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC v2 14/20] dm: blk: add a device-probe hook for scanning disk partitions Date: Fri, 10 Dec 2021 15:49:41 +0900 Message-Id: <20211210064947.73361-15-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211210064947.73361-1-takahiro.akashi@linaro.org> References: <20211210064947.73361-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 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 f7ad90e8890f..90687189e6d3 100644 --- a/drivers/block/blk-uclass.c +++ b/drivers/block/blk-uclass.c @@ -715,6 +715,10 @@ static int blk_post_probe(struct udevice *dev) struct blk_desc *desc = dev_get_uclass_plat(dev); part_init(desc); + + if (desc->part_type != PART_TYPE_UNKNOWN && + part_create_block_devices(dev)) + debug("*** creating partitions failed\n"); } return 0; From patchwork Fri Dec 10 06:49:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1566207 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=YgarU/gz; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J9M6X4WFJz9sR4 for ; Fri, 10 Dec 2021 17:52:52 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 685AD8352D; Fri, 10 Dec 2021 07:51:33 +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="YgarU/gz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E948382F03; Fri, 10 Dec 2021 07:51: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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) (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 7A19C8348F for ; Fri, 10 Dec 2021 07:51:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pl1-x636.google.com with SMTP id b11so5632987pld.12 for ; Thu, 09 Dec 2021 22:51:07 -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=TFTi4eZR8V4BD5x+AszorX/mKD69sIAYkkbi0D9OyB8=; b=YgarU/gzSzglG+BrWqM/KinVw6Uh1DNuLyULoIyNpa5XYzNtDqXDLiiUp0pNrAh1bB 9Dh4Tb4eEZQ20G6pY81CtHOZz2LU8yY2DtO0g5qRnUZHn2cuQ8Ix57MLfD7/k9Dp5IET dNUaV2EgHliqCL9/Fb221psADUmoWZuhCnBMxpPFJfN0RbDB8bxohc0Myt8n4em14ivz Ik9bCFZ+i+fDMqI2F6RySdyv75medpZGN//jxV+M2U7omYQVIQnhzE+6DfSkEytMhtb7 9p7h2KFdAxzzlVv3PDG95IxEldv3pvn8Pj/kATAS/mlKYwkLgiS+uylYldd6w8Phq7bM aGew== 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=TFTi4eZR8V4BD5x+AszorX/mKD69sIAYkkbi0D9OyB8=; b=my0P4qEsR9UJ7jRElgJ9zpLOUn5pk0UkDeoyjHr0Ey+JvunLNYN156de3GHIL0kd4h LWVN3jeeGh3DnjOZvNYT0I9GVRi7AO2/jm7Hem0ojjkO7u4HstVLFlJDVGPIyhikhGdU JEE/KP6zoAx2kAffXDo8iV0UYTxEKPFufHR5GMZ8XJChN0BJ/ZBH5SBQGXrFCh+Vanr1 9Q5e2e/AouuDzXqFUvs0oYe4Ch7JKOPyjoxkcR7JiUboCLXJ0HZiVzlKJbwYEuxbrgo2 YIY0fnZOAaHPfGqFE6TsmsFxM8voCjWf22FTrwRWrxLemK3yzyWkfQvX0XiH3+leK3CI 5L8g== X-Gm-Message-State: AOAM532XXElXzhCIqp4BUdmEngvl6DMbS7JHrbhZv+wUhxcpA4mnNFRW nmIE/1jetd+kYnIdx4LOvTPiHg== X-Google-Smtp-Source: ABdhPJxZcvu5rGUzjoM+1sXASWfCkJLAZ/YIIDi8Lbx+BmfZiDrMNWybMtCibqyJ7sGMxLkt8s4wIg== X-Received: by 2002:a17:903:2445:b0:142:2471:644e with SMTP id l5-20020a170903244500b001422471644emr73262946pls.48.1639119065800; Thu, 09 Dec 2021 22:51:05 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:75dd:4e0e:4542:936e]) by smtp.gmail.com with ESMTPSA id nn4sm1639035pjb.38.2021.12.09.22.51.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:51:05 -0800 (PST) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC v2 15/20] efi_loader: disk: a helper function to create efi_disk objects from udevice Date: Fri, 10 Dec 2021 15:49:42 +0900 Message-Id: <20211210064947.73361-16-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211210064947.73361-1-takahiro.akashi@linaro.org> References: <20211210064947.73361-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 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 d52e399841ba..a51095930efa 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -519,8 +519,8 @@ efi_status_t EFIAPI efi_convert_pointer(efi_uintn_t debug_disposition, void efi_carve_out_dt_rsv(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 700dc838ddb9..108c00343fce 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -11,6 +11,7 @@ config EFI_LOADER # We need EFI_STUB_32BIT to be set on x86_32 with EFI_STUB depends on !EFI_STUB || !X86 || X86_64 || EFI_STUB_32BIT depends on BLK + depends on EVENT depends on DM_ETH || !NET depends on !EFI_APP default y if !ARM || SYS_CPU = armv7 || SYS_CPU = armv8 @@ -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 1aba71cd9624..1c912b0157aa 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 Fri Dec 10 06:49:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1566209 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=xhDn9K/Z; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J9M6z1j5qz9sR4 for ; Fri, 10 Dec 2021 17:53:15 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 78A29835FC; Fri, 10 Dec 2021 07:51:40 +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="xhDn9K/Z"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0B395830BA; Fri, 10 Dec 2021 07:51:19 +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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) (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 7A773834B5 for ; Fri, 10 Dec 2021 07:51:10 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pj1-x1036.google.com with SMTP id j6-20020a17090a588600b001a78a5ce46aso8789139pji.0 for ; Thu, 09 Dec 2021 22:51:10 -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=xhDn9K/Zd16oYKiAkSgDVvZ8DHVc3ZHYhINhbNqDyxfC2dORoZrphOnuIN4uVquW5U C9MBQmgIZ/fm3ACGTaHjh9o2hGh2LajRsOFBGQL3zWicHCEXjrqtnis9FOzOgq4fjY18 5zqvOqOzFXHuHOzTIUTkZdnhg0dcpx4I0/cdNmIxCwGMKuELPZEHo42O7TDKl+9RKCE0 oXGaPiHW98OXusRdl8QyvsLcdalDdGbLnlIXoZNGIY63sQk9hJ/l0jdeHLi/ebmyjh0k mLob/4V7KBpsqoCemPyZ0KkWk2cyQNK0fCffZkFvZgbux2Tu2A/65yQMKPcp9EfoUlOJ BKJg== 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=lAhSyIZxcCEm8VpmG0BZgwU00HMmhFjYXpuYVoVtFNfcBEHwk0HeZVhwau1ULYE71Y IcC4nUtYjdEBfc7hi9qVkwTTmHY/oeRKs2bZum0zIPcqPFg+a4o2GS64OCgbZfJ1NBQ0 IgOYm5R/90Hj41OE4H0hNWx6rqJqc7kyG+wdWSFYmBzAqet79kHK6uFKfNG3qzWufHt1 UbfY/Xs9Hxio9HlzX8TdVsRV8hMb7nr2qfeu6oVOLVyMjJlHC00gvfZFbCBwbLwKy3j0 qoR2TIL4Y7jT3Y+bVeEWKkvQVVaQu2VIhB43+vNoso+cWG/VW9g1ATwUCuqCLV6PWpTc o63A== X-Gm-Message-State: AOAM532z2gLtIaDdej/ckqEz0yMHkYS1OZhCzlnPYSPKHUyJps6ui1CR CwCtzHzM7g94fkdDPOJjzA/hFQ== X-Google-Smtp-Source: ABdhPJzIEzvK/wYI4tygArrwgvQB2H4pxVUl//sdDA7zMOuRsl/7N+3gbHlTpTXz4jfHj5F0bJfAtw== X-Received: by 2002:a17:902:e302:b0:141:ba08:2e44 with SMTP id q2-20020a170902e30200b00141ba082e44mr73023927plc.81.1639119068855; Thu, 09 Dec 2021 22:51:08 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:75dd:4e0e:4542:936e]) by smtp.gmail.com with ESMTPSA id nn4sm1639035pjb.38.2021.12.09.22.51.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:51:08 -0800 (PST) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC v2 16/20] efi_loader: disk: a helper function to delete efi_disk objects Date: Fri, 10 Dec 2021 15:49:43 +0900 Message-Id: <20211210064947.73361-17-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211210064947.73361-1-takahiro.akashi@linaro.org> References: <20211210064947.73361-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 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 Fri Dec 10 06:49:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1566211 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=KCtnqvsu; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J9M7M1cQcz9sR4 for ; Fri, 10 Dec 2021 17:53:35 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 916918361E; Fri, 10 Dec 2021 07:51: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="KCtnqvsu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D6F2F834DE; Fri, 10 Dec 2021 07:51:23 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4789C834E8 for ; Fri, 10 Dec 2021 07:51:13 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pf1-x42f.google.com with SMTP id u80so7627806pfc.9 for ; Thu, 09 Dec 2021 22:51:13 -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=sYUc3BMcyz8ePK8CD3CP67NTGto6abBt+cXyNi4SEbI=; b=KCtnqvsu2urr+zJJstWb5oanj2Xhi5zKAkEoSUo2zAoJD/2uNYv6z4OhomP0M9mp9V uzrCOCkyWgAMVoln1VfQ3/lxLNHqL8ojK7iBLa2/c1HrY2/qeQRSlhV2gSQfGWeKIO4V xKJTkiP2o9fKpzhWJL6rlnJkvKWGarWV8qQZB9D9xmgDbjzllaR2TogtV6ZiVZOjGCEW WZmGCU7+LRFsZBAxXRd/Jjq6KKOo/xOb2DWEdATN2Qygov5TCDLVUw7xo+oIbN4iaKdq tJJlyLBjgRTv0+f1UCrypVPVf9XhNFp0ZFJa6AW/vOzNAts/NBlE+n2t5KiZ9fOV1N6w zNpg== 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=sYUc3BMcyz8ePK8CD3CP67NTGto6abBt+cXyNi4SEbI=; b=uXTfRZEQQ40vKudM+MnNaYr6bEnr3q7pmb6eH3r2XbsVWeNQjxBszMUxTnWw22gLyk 23pKXFD8o9nSMgpur69yWHvg5GwnJyWwiEteqeLtAfLI8YI9rvfzPrKP2t2HQF9m/nhb C6BaCeyiJMx7GvVzy+xgSiEki6bHxWDbZiWl8baELxq485gGm3iOwkJK+hXvX33bWJXv 1FBbF4kZNmZ9aqm1pCHaXBQF08/ldcYBa/SRswnncfOe7hyKLA9+tmGnF3cnAS+diJHU CwDoire9RhTsVe5Zful+fLvR7fqWIbQ0zENs2O541uUTE5m3aTVaB68pUo/KHqwezgGK eT+g== X-Gm-Message-State: AOAM5325pUQ5r5zv0G17YhNmpMqXMY1tYoNXulaCf/kwrkfxgazxSMZX fFfWL2eaFbjWHnQ0vzR3zz0hiQ== X-Google-Smtp-Source: ABdhPJzON2aIanUQs2p8Rar3HTvXtQt18F6x7AoMT582U79naOCDPdI7KDb4waHrh+S+jO1UKg8Crg== X-Received: by 2002:a63:b5e:: with SMTP id a30mr18811270pgl.432.1639119071627; Thu, 09 Dec 2021 22:51:11 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:75dd:4e0e:4542:936e]) by smtp.gmail.com with ESMTPSA id nn4sm1639035pjb.38.2021.12.09.22.51.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:51:11 -0800 (PST) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC v2 17/20] dm: disk: add read/write interfaces with udevice Date: Fri, 10 Dec 2021 15:49:44 +0900 Message-Id: <20211210064947.73361-18-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211210064947.73361-1-takahiro.akashi@linaro.org> References: <20211210064947.73361-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 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 | 96 ++++++++++++++++++++++++++++++++++++++++++++++ include/part.h | 7 ++++ 2 files changed, 103 insertions(+) diff --git a/disk/disk-uclass.c b/disk/disk-uclass.c index 4918a2f72d1e..9cadba37ab2d 100644 --- a/disk/disk-uclass.c +++ b/disk/disk-uclass.c @@ -146,6 +146,102 @@ 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)) { +#if 0 /* FIXME */ + case UCLASS_BLK: + block_dev = dev_get_uclass_plat(dev); + break; +#endif + 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 e492c2249019..1c564c6d6a3e 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 Fri Dec 10 06:49:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1566210 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=w6C5Hu8i; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J9M793Vdnz9sR4 for ; Fri, 10 Dec 2021 17:53:25 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7E82283693; Fri, 10 Dec 2021 07:51:43 +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="w6C5Hu8i"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C0C11834DE; Fri, 10 Dec 2021 07:51:21 +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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 08B5F83518 for ; Fri, 10 Dec 2021 07:51: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=takahiro.akashi@linaro.org Received: by mail-pl1-x631.google.com with SMTP id u11so5655051plf.3 for ; Thu, 09 Dec 2021 22:51: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=2RJeyfCToQYeF9AW4ATinruQnvSK9EpBCOGEFn+5BEY=; b=w6C5Hu8i74VOcL9/vVh7UnIYyEdQCa+qID+f3Q6hilWw+Ijey7IB1z5I9getbclNCf n9SQBr6ystzExWfIapHkHBOrNPQJCUvhX1U4/eEJ7IMtwZ0cGLc16N/YIQZXAC3raC7M ysxUf9ByFn3fnaZK7Rw6LodJ8pmjXXMb9Yp8nJRup44tY0Kj+83HobDO5pdsOrPWC1D5 3Au2GIVDvLMnR3DdHZI0MvkNVzIMzi1mn9CKQJDr/PHTjBiMxXZO1LdonluEBcSoLH3y Qo7JJpLc4XasPfaUuZI0TC6Puca7su+iHDcwz6RLnDBBO5oVVGgiXBlGXQ0tiC17W4li rYfg== 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=2RJeyfCToQYeF9AW4ATinruQnvSK9EpBCOGEFn+5BEY=; b=JFR4fQbJf5LWxH661ahCXXCC92P7CG8XVQ/y+D8jQTU6c7ffsGEnshSUyyrPM2yeq0 wZplF78xvppWdipY+7bLIVh/DR8l0jrVHUzCErAJr2eXDln9J27c5qtz3GrEKSAael+b I2mBtds2Q68ZCx908EQqOFdWpDjWqRDFRzsO6UTQPfhc9pv1MSfE8KnNiYTe+PPE18/C NK1JiOOMBxZi7F3PyDm8awCXl4AygE/X3pVaAf1b/bsK2cS1eVYZA14aw0KMcp68LRSS yPa4oFGCPyFmoMa3HcTnQ79c6qSAfiNxvRdvYayCt2aXpW+gtjE02c6OtKCQ/p72Il77 ttkg== X-Gm-Message-State: AOAM533uUH9e68CKjp00rMlQxlUCJ2IqbAI6SXifvwGrtTlXZyIuRoT4 2pBA9dzpNVnXUQTUFsCMfl9EKg== X-Google-Smtp-Source: ABdhPJyLKTL4Tf7/F4j/Uh+F5QeOf1DBywdw6XcAchlYIL1TRZ2VJG4o0EHMOcETMceyJ7BBHWMo+Q== X-Received: by 2002:a17:90b:124d:: with SMTP id gx13mr21768502pjb.106.1639119074339; Thu, 09 Dec 2021 22:51:14 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:75dd:4e0e:4542:936e]) by smtp.gmail.com with ESMTPSA id nn4sm1639035pjb.38.2021.12.09.22.51.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:51:13 -0800 (PST) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC v2 18/20] efi_loader: disk: use udevice instead of blk_desc Date: Fri, 10 Dec 2021 15:49:45 +0900 Message-Id: <20211210064947.73361-19-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211210064947.73361-1-takahiro.akashi@linaro.org> References: <20211210064947.73361-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 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 Fri Dec 10 06:49:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1566212 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=kkaf1V+d; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J9M7Y5MRlz9sR4 for ; Fri, 10 Dec 2021 17:53:45 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 230938366F; Fri, 10 Dec 2021 07:51:50 +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="kkaf1V+d"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 35A47834EE; Fri, 10 Dec 2021 07:51:24 +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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) (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 2C4CE82F03 for ; Fri, 10 Dec 2021 07:51:19 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pj1-x1029.google.com with SMTP id w33-20020a17090a6ba400b001a722a06212so7599962pjj.0 for ; Thu, 09 Dec 2021 22:51: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=7kmYl4c08xqigOLNyOCeB6rtRrnbW/qILnthkGKOw7I=; b=kkaf1V+dlj4r7KG3yAdxh2Al58l3NXzvnSU2KtMtFm3TqUEPytcL5pwX+A2C/OyV06 2ZVP4ax2eFX7Da71i2jDb0OMlOa2Vos72C+n8z6USmblojFzLA+UGbXcyl6LuH9MNxq7 E2CL2FBlVVNTS13kgbcwG9CChRL3B1OXkmFaEGdw0wt03ge3ahfK5D+YgfIU/AmmkrO+ Wh/28R7SqI1mwis1Af1JIibeJhin/kwnMD9s/tJ354ta8iZe7n1QHWT6jjGec0pHiv7g 7zykcHINjxdjd1v2alQF7qK64u/5ZNijbWqh4qEL4/o/ag4kyFJGSgSx3avcjYA+mZaz VNAw== 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=7kmYl4c08xqigOLNyOCeB6rtRrnbW/qILnthkGKOw7I=; b=f+1OL1vdIh+Z+Ju0VJsuFHsZjPpuca+s5lhGIKtQKjw0ds4209LxkQs8WbrcLdjKgd ECNWgdjLCoqStNQpnbOZAc/9u77z7T3NbVn65PzcF2g76r9VtEVLT1fmFyqTTRnxcbQZ 47T9fJ/KgFYZWSjdannd8SMwNGQoLgf0WbPlx9j5Ed8rMGrXCGHYu1pe4/iNmrRCxQ6F ROTSGHfTU1H05XhhxusP5tLa6ARfxL2U6w7maE6NqUBeE6Nhz9Yz/ksb4r4T/BIXpyY3 f1QsKG3eOYFDSEE86f3IUVt7iDVxr9ygNTVm+Uwe6HPOVc4IatGUL3wFaB67KxSlJhqo bbYQ== X-Gm-Message-State: AOAM5331DsuB1q0QMJMtbdS8wTln8FXVgdn1xK89xLyhAPlAN/26DDIt R+m5R0cLxG+65UwFOYNhXXdSOw== X-Google-Smtp-Source: ABdhPJynhFxbEV1SrpZSwCpka9pgIbv3xEXm1zW2fodZiEvqjDY1Hb1YxykZrrLZJmlEYZS+1/4pZg== X-Received: by 2002:a17:90b:17c4:: with SMTP id me4mr21563587pjb.15.1639119077552; Thu, 09 Dec 2021 22:51:17 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:75dd:4e0e:4542:936e]) by smtp.gmail.com with ESMTPSA id nn4sm1639035pjb.38.2021.12.09.22.51.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:51:16 -0800 (PST) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC v2 19/20] efi_loader: disk: not create BLK device for BLK(IF_TYPE_EFI) devices Date: Fri, 10 Dec 2021 15:49:46 +0900 Message-Id: <20211210064947.73361-20-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211210064947.73361-1-takahiro.akashi@linaro.org> References: <20211210064947.73361-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 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..f37f8c1ab0f1 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) { + 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) { + diskobj = container_of(handle, struct efi_disk_obj, header); + efi_free_pool(diskobj->dp); + } efi_delete_handle(handle); dev_tag_del(dev, DM_TAG_EFI); From patchwork Fri Dec 10 06:49:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1566213 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=vxyRkd5G; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J9M7m1DPLz9sR4 for ; Fri, 10 Dec 2021 17:53:56 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E896183736; Fri, 10 Dec 2021 07:51: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="vxyRkd5G"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0256F83112; Fri, 10 Dec 2021 07:51: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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) (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 303DC83518 for ; Fri, 10 Dec 2021 07:51: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=takahiro.akashi@linaro.org Received: by mail-pl1-x62a.google.com with SMTP id o14so5647847plg.5 for ; Thu, 09 Dec 2021 22:51: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=2E8j064XPFTH1anOXyWK37XKESJbFHCLe03Ly8Wy8ZU=; b=vxyRkd5GtUuxzactpNXz2exfk9HgdBcwywuF0reKnM6j2Ah7lRA7IB92ThG7hRbgnV k3piwZ3zY78V55G9PC7Lzq33bDdA46+VXHSdIeEQCS9DoTPvPRnzcT9F9NBjLFXzTjQa H5SeU3cIzz8BXUJ71qVZa6uWU0K3dzMbQ7uhlgmiV2x2K/ufi+vQs6jlkbGpAFxyq8Bk I5HZ6gp2iX+/y2USmr18AFC5Vw1jlYKknVO3JXzPC+sK+y7a3vKQPr0F7evooSptARyn l9T5IcguxkcDFHkfdzpt+aZ5Pgw2qsiDUGvQBhMujl5y/uQSQ3kl9yN2tE2z/KDjPFBu ry/A== 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=2E8j064XPFTH1anOXyWK37XKESJbFHCLe03Ly8Wy8ZU=; b=eeyFdoalHDrXAWcfza+rFOx7KPpl4Jx6DywZu0+1Ts4CKvwd5bsvWgAVCe4s4skMws kCFP6YCFwkJH0LxZCAun6alO0pCYeqh9D0pvjfkgrKIYMwCu2Zelv86hNbLy7alWFGnF DZTSx8Cc7tQP1B4nIXZoz3XyOp4j0mahrQ2izG/6MVMK6WhYeRNqdEqmXTE+qwOJIJDN MDoPBJlRiCARJ6jfVhQBCBYapAhEZ27gWD/TsMKDlAIPm5gUC/yejmtXJ1WHirzGdb7P 5nAx3C14erWRKb8U/qgv7SNSeP9eiZ9f/EYbtECUQ4nDRD/OkjjQRTfKtffH5zX+Hz2i qxjw== X-Gm-Message-State: AOAM530QIdxMBUS/usZusMusjwzjzKXaBOOqEt32EjCj12jZz4Xvb+YS 2bK53bHrzKSK41aJ4vsvXDWmUH9FRgtLbHzL X-Google-Smtp-Source: ABdhPJxnlVbInm9LDXa+V7JmHHhLtPRTlJN4bqRwnyY1hBzkjuyC0dQ7u/P0xwN9cYuU8kg5VY4s/Q== X-Received: by 2002:a17:902:d395:b0:141:a913:1920 with SMTP id e21-20020a170902d39500b00141a9131920mr73683711pld.81.1639119080583; Thu, 09 Dec 2021 22:51:20 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:75dd:4e0e:4542:936e]) by smtp.gmail.com with ESMTPSA id nn4sm1639035pjb.38.2021.12.09.22.51.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:51:19 -0800 (PST) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC v2 20/20] efi_driver: align with efi_disk-dm integration Date: Fri, 10 Dec 2021 15:49:47 +0900 Message-Id: <20211210064947.73361-21-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211210064947.73361-1-takahiro.akashi@linaro.org> References: <20211210064947.73361-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 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 0937e3595a43..28f672324991 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; }