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: 522724 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp2168479imb; Thu, 9 Dec 2021 22:50:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJxyrvC+vS2IYjC5eaTzp4P4jlbAtbuRl92jDryzWYluv/kaoY5HXtVhlfgglSkJ6xvduzyz X-Received: by 2002:a17:906:fca3:: with SMTP id qw3mr21953184ejb.285.1639119033491; Thu, 09 Dec 2021 22:50:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639119033; cv=none; d=google.com; s=arc-20160816; b=iE2rjMrS5GqfmTuG3b9vjVVBpHFiqC8Fhwsy10iowmANq9fBkHYKsvteQvY04jXd9N mwMj25e8DC/tT4wCOfqzgT0nOTZNRKzkkPAToi0LnzQXc5lCYyYCkrampTNHUkQIdyUW NafgV7WgcvhVnCYmPKAGpcnuIwokGNfnz2AREWpCniLc7jFfVz9KgbB3fcx40fLtwl6I C054deujMSRHWCO37ZWepzaRfRkokgTrdcKaVvQ51fmEf9JYjgvsKHvz1/U5lPGnPt8x +CoQk0ED7M+ZUGbI5kEPyU3gcPNmj9ZLNrmBuXuUYn+c+UUI+I3fzvopXvGWk8rIt7wk WFIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=CE9Ru0+BtM/aB7yGhZ7xbEBAasBATDEKK3UGeDqn+m0=; b=UhHxUT2hlLvQWTplDoWCbRrjnP20UDTHNJUG/JJakfC+8AGC39OoXuBIuoFCdjZtoh Fh5J1dpB1IOaZQ2qP62HBEPCt6+0Eod32pgiDGOXTV4+CCWgyqMJQdGGYMh9cC51UkMG jb+ofGcJ6vrfqTRrDtT/WuDvS3fMkU5Fdh53e5UiO5ka7bpMyBUGfFQDOgbWz0dJfGNZ W+aKpBhT1jRN3nc1oCCuKv9tBwUPUqxlmuWMpeSsINbnHH/4E3mAgiZTrM/R9jUQQu1C odB/SQuvAwu4vkqzg7n6awZMD8TXvqcIO7nfVvDg3IetpbUqTpcfj8lq+tAv07JX/J8A e8jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hYcIJ4zm; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id s5si4298893ejn.407.2021.12.09.22.50.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:50:33 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hYcIJ4zm; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 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-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: 522725 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp2168580imb; Thu, 9 Dec 2021 22:50:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJxeNn4Lqek+ZGk2bNwl0p0b0nVha8++p+WjTrUkaf4W7Dv/r2kFCNTMa48mMO28i8WuDf/k X-Received: by 2002:a17:907:72c7:: with SMTP id du7mr22146130ejc.424.1639119043148; Thu, 09 Dec 2021 22:50:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639119043; cv=none; d=google.com; s=arc-20160816; b=wL4Qo5f3Y45KdUndNDo1R4G1YgGswhtDjenjP6rLofGGYFEJVL9GMPTfc2N2oa7FSL B4GHcEG1g2zDXLM7hAYr/NA6ydopwZEnAWdJD6zzc81fb4OfL1JhS8AdpUVxFCtJD4qQ P2aOQRgv4J9zSuhYAhCUjUZ69z9GFXQ9MwOcGyWwjaqrgWUPbZabs3xN4XBAEtZgrBTv 0KKRTm0VBE+00EzDv2sKT+YYF0gfGwZBXAT13OT/2rJqhxmZNJ8hjejZFsP5pHv9PV6H k2TEFZ+DKKDiuEK+k9Zu8lqJwCxI5b4PySAm4KbTlIH4bIfShiUvOHHcHlqfnnzxpSuG NFeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aDXZpBFciB1TCl85HxxTr1gYe7xaD2d3VLbPxF/8dMY=; b=bvBhCkkQNOsY5vNPHUbV4TyZkOJGxf9o809n2YtBwVI5p4DZPGCHGSX2V8cwak0RJL TwsNgXpDqwfvOI23GlFF6gFVub1uMSuSBHksIlOc5E6DjGAy7yIwPl2nUtb7EqjcC4YG TdkMOQDqPnSFPeSFZkxn/Qcl5vmoAts8HBEWKgL0athy7R3reHGB+VJ4cgNwNReOYNts XFvgUuWHi/7G7WF1ZsDm/+8xUbjPOKALqKnfgbJ8ZHlO8rN7c2/02Z28jqpWI/KmcQSu c6q1n5o8c9fSKYmCwCy8cVw6aYPEVltEFQte5cdCHZ2NB4VvnAcks+STD3KfDyklWFZc g+0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="uaT2V/ov"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id q20si2941421edi.135.2021.12.09.22.50.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:50:43 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="uaT2V/ov"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 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-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: 522726 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp2168714imb; Thu, 9 Dec 2021 22:50:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJyI0cHmtKlps4nebR41LHw1qv+DUgeWJLyP63IEcHw+rl7b3W3/Yjm1fIOebpURUnX+EWCW X-Received: by 2002:a17:907:3da6:: with SMTP id he38mr21006180ejc.151.1639119054036; Thu, 09 Dec 2021 22:50:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639119054; cv=none; d=google.com; s=arc-20160816; b=t9ulIeh0XET38pIp8BpfKOXJCVoTYQjW1Iv1S2oWSZgUCuQ3PiO3d/RJ5jCh8QrpAi B+hS+07859wx7DmiUScc+lKeOnbkkR9bCkmP1V8N7oD3zPV06lCY0YvfBYnbtg9OOjHV 7wxS7CsFz1GuC8DgEs24SHBJfLpTFapYLTgGBBh3zxhZSepJiVioyc6Raa/TMGtg8RpL soZz7DKlTRcdRkBKfh4jUoxyESBlLHkrpSHVLorQdk+LvD55w+WNqHe2EFYIY/fM0m48 zcAJNhu+Je+Jy00kZr6o5X8i4/04URjpRVMkDeKmou12apNHEmyNefHE6kTrPbGp9BFu kh0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qmWo8ajh6FC3+J769E1n7+e/fv+fhY8AOmOHacKJHKs=; b=J7pDx225F3SKQGt8kxaJPws0WSwQLP/aX+rxQBiNkJz23lolPGwW7eBptUXrNjTh67 OYXS0HUGJIH3v7SCo93ZmdcO62YsU2UXtTc4Bj/ahpWqZQSI+qgOOgNK2P+fm0nGE2AY S7n4WuQequdL0vJ/D6JWHEkSG5JxMOoVcnrBEWJKFnEu4uHDFcjz3w8/xmDg+fpa5VB9 /yxkLz9R/tykASsZP/0w7tnQjs7a5H7iQUDkYRJUq6QwmE6pS2a0o7/OuH1vO+kGHP6B ucRnuREJFhWFPAyHY5e31S3qIiNKezAdqJB2ZmaMQTyC6UFL1l8qCjCoufXO1w42q/9e tqow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="RGKGRB/9"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id z1si4402734edc.600.2021.12.09.22.50.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:50:54 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="RGKGRB/9"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 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-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: 522727 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp2168873imb; Thu, 9 Dec 2021 22:51:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJwIUWnKz/Y0ZqKGmSXQPrHQar0uyXvpTlMC8KXAvfsrA5AJbDXEzrzBviqnbQKq34/yJMoE X-Received: by 2002:a05:6402:51c7:: with SMTP id r7mr36658550edd.359.1639119066308; Thu, 09 Dec 2021 22:51:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639119066; cv=none; d=google.com; s=arc-20160816; b=y8ZbHWWUPCium8kH0Anv/ND82YCpXPr/0E00F9PFOcQDkrOnR+fRuyUTlZ2NKnqtpv JLbT4xRGSDzFEx8zkAn/9zPjpMNsDZtyq68RKSyvlWGrqmz+zVM6ZuxnmFUL0S0Wqdhk ibF2f/vTncnYBU53thMV1hloPSWg5JdncyWA4nCRJPARehNdbWz+/vH9Y05YNU4fwJ1Y KQc4Cy7YiLN6guPcO1pV9QYaNtfa7Y/kO/QVqogwxkPzm/PFHh/IB4+9K8EaBhHdd9Tu y2KhZsvjEOpYtn3T38k66Y/CmOwGajxmeFX0mSzkJQ06a7YIaCoRqXd7p+ySlb+NRgPw E5zQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Y76P07ukuT1wREwWJsiB4J82LPFAi8f0WyRnmBNx5ts=; b=QR0/s4oavs79g14OdFxaBAx+7uP3tkRIIT0mRui1ahbT25RPXJvZ1zmhXo6H8b1Stu UuWVWDLIkJwQ4UkQ2GOXxXAq6hQCHih+3tU/5QCxvU0R7Xy71zE84YQXnS+8O3M2y6ZC EgTE3+PLRBxM/nOfC1K0lvqW3XjNZEJ9vxlJzgiXENcEvBvLZNs9/8pRWZtAJTk17ogy HwBe8SAp74FJ3GihJM2HqX98p9zgeVbFyzwSRNw3hZzMNPptNoidE4mZChdx2PlmDNEA baNbvUQymqzNNsikH28+QvOoAkK0aY8x0b09uqq1cyvX0fewj2gspSzg6zV7gUaFl85l 5GGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NfuoF0EQ; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id p2si3227417edq.79.2021.12.09.22.51.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:51:06 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NfuoF0EQ; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 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-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: 522728 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp2169006imb; Thu, 9 Dec 2021 22:51:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJz9WByZEgBZvA5Xa2w41aFPSUIPWjO+uJXkxQqMqfjZ4Gg+2QRcoGwTXg2H00ezD/+CxOad X-Received: by 2002:a17:907:3d88:: with SMTP id he8mr21803122ejc.565.1639119077035; Thu, 09 Dec 2021 22:51:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639119077; cv=none; d=google.com; s=arc-20160816; b=A+Zg7zRUQ/eRAYB2sVyUpe3N6vaJK/70k/0bf2mgzB5gni4BvtM2TOxi5Xa0MJgHsF wFdSE29FazUgr0avbD0KzwylGiB2TuRP0qzDjMGT1/GYK3eGIOY01sG3M/lidVMHgsNN YDHi2og/vsqF3l7vfOxNO36RfXkgiP5bJESy3XaUEunBdGEZleKOTU+2YSt1VFgGBJjK EO3jlI+ScIOT+AJf/BCZFF4yyW8ya9T2cwjmJ+AghUwiXwBaS4OJBBr4h0yh5D29POjH pykhEoo7/ahX/chMjriBkbk3OtFy4CmZqnYOF1GuVOlRiwQckW9cD8iZFPaQEavSU1cL Ximw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=74wqDPeORcXuh+mDzjDs/7A1t3UgXTLsYe1yBw20K2M=; b=SKtK4LsdcRoc0ZsuYGzAb76YKGGCPvUaTI35+LbeRBv5ijR2a1H0HIQFlf+LO5kq4B 01GG0+m0JUkdSE7mMP2dmZKd+HOV+6wkWTa8/Fuxj+nUUrNU47pJUL6LDBJzFL25ZQwU 3pX5dK8OlnHO9EM7ypslQFMCkmx7oVmW5+vqDXEmT2OFR34PPEMZv7E2g6/H0n0BjeuO iFd3XkUqQkVw7XuxHfrsv5H9U0PxX3IxU2m+61RkvZqwwCG6CPkd7zK8L30bH3vK2Azs MGKngedXIlbY3+TZUFd8A+iyK3IboxRNywawzBFulTifJgk3Hb5C4rd1K/HvtxJUnz2T TkKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ljb8vjE1; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id dn19si4590063ejc.462.2021.12.09.22.51.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:51:17 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ljb8vjE1; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 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-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: 522729 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp2169123imb; Thu, 9 Dec 2021 22:51:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJzzIJSJ9RdktBaewxBHdHUcWik+qm37ol11RsmvvgvdmCUmoC50zrffibTDl6OQ2Qm+GPWX X-Received: by 2002:a50:eb85:: with SMTP id y5mr36766805edr.173.1639119087661; Thu, 09 Dec 2021 22:51:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639119087; cv=none; d=google.com; s=arc-20160816; b=MVfTHWry3nLWZV30cXDpMEGQVzzuGEbRJqf+VMa7Mk0DUcvQXUDBHYZLZgJE8kwfI8 QHUcEGuBqAz5qf0airi1YSNbkBfT7g8m7AGb66dYYae0NbZwd8rAbo/oQvO87LVqLK8w wC20mWWMyI/Ft0oSwcR92mwHdlQrntlqnbQy5nnu381qNYjUYVO19ZuKdkYFUM5S6AlF SgyjlXkprTaR4KuSFUv3XwnysZCP0LCHyf57s+XUBRuIZJIqsBhhp4moYM3gx+2rZCAf 82aEw50ZTX9g+qpxUASiusCqbIWrRDPBXhOKJfRqhFL5S+KwazrLkBytvyYGpH+KCKVs pFyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bl8C1X+TOksXaJYBdDnrMAHxXq6nwVHHyloe9nAVxDA=; b=j5yf53+1FFCpAIiG/psoTFPMm1/NMCGMD8Rtm/d8/xN7A8ECRaW/UaGepwsAH67wT+ lZky/tcPCR3Uv+0uYX5QCgR5YGrJdYBDXoOxoMLKaqKIDo3H4OXeBkyIdhzUbQBb/Mlx QjrMxx9wc6XMzYcCwDWW2s8i/Fo8CpvUm6NXtci8ewEVpDg4OyeO7ynC5m+ztJNgGl6N 3TJo5z2/AEv4lWBDm28ZNkjQDlLLZarEJpR5ByEuZGCQaGHZdodExgLFGwzQCWBN4rma zQp8497Mtypafl1d2iEuZEDCPH2R/pgieFF2nQRmJh5iuKKeBeQX1As+UYkBjGNKU7jw xsRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vequKxCF; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id hr39si4631532ejc.598.2021.12.09.22.51.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:51:27 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vequKxCF; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 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-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: 522730 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp2169255imb; Thu, 9 Dec 2021 22:51:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJz2k3XYWQLIzdXoYCAS3k9aYn8RmWRiK7KQnnHhi1S1BxWSzTcA9J9uG0i6aaSSsU8XWkNL X-Received: by 2002:a17:906:3c46:: with SMTP id i6mr21043068ejg.371.1639119097493; Thu, 09 Dec 2021 22:51:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639119097; cv=none; d=google.com; s=arc-20160816; b=hLstRWwkPG3tIrOEPl24HihhDfpQjPDeVIVwI6mnHu6sBrnp+j3D9N/gHTyFAtmkyh 6t8OVBIUfODxOI/iam66Ow4bKh0WjYeGdGsyCPt4NR0KLKgsak43Qj1PmU3Zk/Frupod R+GhWWrgggtj5qaLugxMcnftXdq2CZ4/qvwRxeBj0I/r8N5gPCfdoBUyRkTGnmDphXrs axm0P5RxbtNghdCXSxpai00AxWyNzACmMU9P61TCZQcocRzMewyRcImT3PBWH3I1shSk bnzk8HzeVCokJnV798nGxIEuTWB6EJCn83bFeAskYFm6JM1qUYikVME2rrZChpS1y/LM FOfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=c86AUGw9p8OP3Ujy+6u4RxbpzSXHf7b/TNv4ldBBLdk=; b=QBLBDgjRe/kZFQW3ZNl5lxlrCEAK6gB3ebChD6E+IceiD/j+Ma81UxJnWBWDHyWg7b BpSwOxcFk7bSZnkQwYWBoAOXIq6vPYglYThzCS1ZpX6tqh7bU+RRQLFrG+kMhX1KHd4k IzL9unrbwIeAgOBs6nbPbCvYEUlDBGqEwyUkEIN3+9VwghYaOAiQ5MXb9xamWX/Irt5r quDCJGp67erOR+NIN7Jsh0FDJTna2/6VifBrDwAIzbvrXnh/EJL3rcr2fR5m5LQ78FKH a33UfTIwNXJjs9lAHMLjqKHm5OVJkZszld0s9zyT6u/OJ89yixLDquZz226HCO0vp0Tx +k6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KXwXq55v; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id dz11si4356573edb.569.2021.12.09.22.51.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:51:37 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KXwXq55v; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 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-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: 522731 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp2169419imb; Thu, 9 Dec 2021 22:51:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJztTXJWXjS7jPkwG0NJAj/f46Qd6zqcBPX1i6N3ZKzMp7m+qhCkmslsEr2/XxgsBYs7Zm/M X-Received: by 2002:a17:907:9495:: with SMTP id dm21mr21160605ejc.478.1639119108091; Thu, 09 Dec 2021 22:51:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639119108; cv=none; d=google.com; s=arc-20160816; b=R1DxbHAKOy04giGM0lPaCOOkYa8JI+sCiJZU/TB3gnHOdphaJhZqKCqQJs2Z5ojFA7 ZQXse1OgQWIbzNvVS+Ohz8LlEpOJiVEU8dH/xsAqo86IqGkWEUp0HuHUwjX/6vPLYcEF LpvnI/Db5eqScZlMycd23jU+OaLU1Eu17P+1GwRZTGpceJQdHfIYQ9jQng2QqVuuh7+e PgE7mcoRtyYcccQsvqtifPYrbeJMLJn28Lid8KlR9gepyX8LJzGOu4iBA/cIvfcp0H0F tXlPrGkt4pza6Y4SVjEpruN5lrGxhgpayk2x95CwHZl0SIDlqrF4RQ62cc2C7iNd5ZIf VRLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=F9NEStEGogNVLvNc4mBNKs8gXvObGAndUA6jBNqxsDs=; b=D+OAuebzHRofUhvCM4pUAwzM1HDiMV/GAAsASjaJCje9+vuE2aff40mGUMcqqMu/c/ JAH+Oc4U76St/+7rGIhMqK9n7c15va8P7IXzEuZ9JQ++Zjm4vXb+8+0nLRnotdRGt1e/ SEdCUUsvWNRCmI2Kz5kTFUgfr1NDlL4fLkLh047WbR7vz6ZjQmDhD7//LU5IB+vFLe1q a+T+YA/c5EmOmnd8wRUou3dlCi0euijCHggaR4EjNBGNOpP+02hfDFX7pRV6nlsRmNIE 9kY1NMmdubCDUyGoMUQAzzKstCk4JOMOiUMMyYGP1BtRu8basPS/3D3wQZCloi4cjCtk 3duQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="o/IaTh6V"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id d8si3245637edv.124.2021.12.09.22.51.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:51:48 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="o/IaTh6V"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 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-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: 522732 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp2169591imb; Thu, 9 Dec 2021 22:51:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJw5tXxh3ZtVNFzGtqv8krh820CsrTHMa9wYGPefS/kx0zcEGtAkm885dlHLF+3Vx2bwIkj4 X-Received: by 2002:a05:6402:3590:: with SMTP id y16mr34934405edc.343.1639119117622; Thu, 09 Dec 2021 22:51:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639119117; cv=none; d=google.com; s=arc-20160816; b=izy9TGJ13aTYmPUzhhbT/4b44kqqJXwcHwb2Fc9a8jSdC5O58uDfO2YCTuoDSAa7SR c74NMMzdlqQ/uexspI+LyZvY/1h80dUu3Rhou/a4O0dxFarXq0AtdgREXOxdNqfZjQ2T DQAvclbgnOFJ6LZ+JRaUgIqKjVHQ8Z9dR5alqsU+mQOWdEBegvXzrQRsdp8gvbYEO+B6 9L7LbRRLyBoXwgD1QA0KGUsa0QrXk+2zTcbHu2VgfFEDbWe28AZfC8HJkdVxMNXizIGW S3R9PTcNwk+blgFOnUk5jkqiV7sTbDEimnP9xNtcX98bO49pD1z61L4X+mXSe2YAgog2 Jn5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Dn4vUcXR703H4rWltIKdHVHwUawMm6yEwEClHG4bWi8=; b=F1YylNNEfQKvrm0R7wvIoPrxOIKH1rCWFydIKy7ahZa1NkMZ0a7Fht2ok8EpwX1YCq fy+i2LIWGrD/D+gtNzD1a/8VQ5qLb19av1M0KtsPxYeVHUMCdQOiTaBJt0gxzqK/j92n ehLmD34gHR+ORcj3Wg/VtInXuR36rCt9PTTAkInSumXDtAE/bUp+NMaBIQIRT+SS7NmP 3wuJOfb7nR1MfHPJpc1ONILRiUy82HxlB2esuhah6wmBnC3/dxcUZBN2CW7ABTnjWAHY K2MpII3VRgS/y5DIUICG1jgqTDkLAB0f9jNdp2AptM0HuJrtIvgQQJNNJS0IFD1O+Ldg 000Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oPKZddO9; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id bi1si3379897edb.285.2021.12.09.22.51.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:51:57 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oPKZddO9; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 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-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: 522733 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp2169767imb; Thu, 9 Dec 2021 22:52:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJwyrPXkxA/o3StUMYNIpEfOJhjXm5pWR+GzNcU9ZEVyY8wQtomQDcz22sAkvbZnKejkfV7B X-Received: by 2002:a05:6402:350a:: with SMTP id b10mr35486664edd.184.1639119128820; Thu, 09 Dec 2021 22:52:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639119128; cv=none; d=google.com; s=arc-20160816; b=V9ItkDaZxY66mw/xPrMXz9nsi0W9A2hGikWVFniCo8+yQ3DutdSYUqr2Bo47bJ8nBt +tKf60d/16jVU7Of6Pg2lJUK8tvgMJJsgOEKiqP5Ke3hnR2qq9lRkZCRzetVtSV23o6E KkIwKKKSlaefCQltP+B9l5A9gcTvmSpFV56i7hAkYPYVLJ7dxsnYQvQpXukepDzFMpUt YeRfEcO2zdSeaml0OjlDhQjCKc/A8czRJ5MK+9w3DBsWOmMaYbvGdrKYHNBD4su6uXaX klhRPrjPOnFI9UD0Vx4E4/SzeTHS+soOUY5thuhmI3249HXBHORS2NFQyjR75lnXpKwZ DClw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5ofz6CLdNamhisd2BzpPocTNzh4e+6k+0LG9jrDMQZs=; b=BV07XT4UYDOgnyWg9f4oSnQ7VE09NPr2AE7cxU9lOZ5nGSVz1IRfpCZoqOYPujzOrZ cYnMgwWmA50sZuiytrHqO6DonGdwD8SRyt+PcfrhZi1xEsu9/a9STdXwR+qfCAXtq8TC yCt7abIhYbhAX/lx/H0EwW9hUlmfFNvSPTXESxdLeRjbTrN4/4Pyx7xmjYNsJGv07ZMG UNq7nivK34EmeM2g0pUCmA3gjodyLe+MfjiIGSUt6a2pgwuUqVKArcv5fX5kt+tiQbiU dV8lUMDFYD6z3VXtCAARQ24s20RVC/ijJ1o5yyfvfVYFH0BfjwRa1lWsUbjny4/vc8Fr JvGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bvHfLATo; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id s20si3023370ejb.327.2021.12.09.22.52.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:52:08 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bvHfLATo; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 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-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: 522734 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp2169946imb; Thu, 9 Dec 2021 22:52:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJyEVJXghla3l33ntGtFkwE3NTFcRQjHT+rWj29wgMQSEeBpxXcKa9VSfnFQmnBci7705Wqu X-Received: by 2002:a17:906:d54c:: with SMTP id cr12mr21158238ejc.56.1639119139018; Thu, 09 Dec 2021 22:52:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639119139; cv=none; d=google.com; s=arc-20160816; b=eIq6EuFpDpV/XBsopvdZXDbg1MHVfAjr7zX7eqzQAaoJ7L0K124qIF07k/H+8lOgFT uDX+GbnmQRpEcjyGi5cFE9Of4EDy/ESKRy/t7PGSEX14iTTpgnDw6JPMiVqphmGSKvr4 X+nZy2nw9VG1h6QkMk3CEYWvu9zFi82CchSf7u/XTJ6RwkL9RvaDbdZWnYMkRG5xsCfP k9evzYLFYmWLgRS7i4huxwibUsZ07u+JSWF5TsvJtgdyiiESlKCTnU3bImuebTquP6Lj Zx2Xg0RvBkUt+Bd4s+HYoZ0O9sfid3UNklRKZnAvIEoVoJNXQOjlvvsOzizwzvq8frp6 ig7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bb0Hptkch8fV2ufC8L+MC8yxzYTdSIsniK0gym31g0M=; b=lycQgiJY+kmHrQcTgdNKy9KbGyyp3xcmx99IK/qn+HE1v3hwiA4RtkEC2OIHEsXLGE RnxOfHEB1mRE4wtB/XklK5N+muvVfIxeoGg7r4uF/ubAJSYLV851ii9liTSpqcLsFhuZ yQaQS76LNXxhJlRrrMyq44psnfAE+4fBRLw7/v+GFsxHraXf5p4lST3VbHto3CWoe8Kd gXQpuBKyqwVkMtRQ4/bqhYzHRSnvZ1KyhHCFrPDuDgYp/M9k+U4ILnx05rlTcdsxCDCD 25nP0V4A08nNxzGmPuIkE6aQx0dsONetc7biZOgimsSqxUS+pLqIhKuufgoBXhv1xzgw nsWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ide03Cwo; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id b9si4021008ede.11.2021.12.09.22.52.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:52:19 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ide03Cwo; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 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-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: 522735 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp2170086imb; Thu, 9 Dec 2021 22:52:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJxvykooGWG1iTfCsBSzkkeQS/wKEZmbe2KmzJQRPZ1Is6YVCAQMlKk5rpvCtIcXa+GSJ4yk X-Received: by 2002:a17:907:c03:: with SMTP id ga3mr20489081ejc.180.1639119149448; Thu, 09 Dec 2021 22:52:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639119149; cv=none; d=google.com; s=arc-20160816; b=rPc0hsNJ6U0kdhXyOcdQZJzxtxGroKPKMktX6yH0FojcL1eIBfoZ7mKNXPCc5nGxds b4Q9yeDq9/NuTMMUXofWSCIVX9XRQxbAz7a2hSU5lZYzwAqHrYfNysrQr4Dkfkcd4R2i guI6T53vYEUHC9zVBFDWUcwtXCz1JUI6br/CPYr2rUJKW3DGEylqJgeUXl1iMgIqhcYB EuuxcNTxBqwoSev6csehoxsUXgbIeIwHC8PWimm3iMEp27jKxwwTzPiZNtgbrXK7oV1R 75Gj7kb+0Ipt/JwauK5m22lMVUz53k6dF/St+Y926Pzzccw0HLTViS+wi8F3HiJ5/fqK U3+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5ycV4eCQgzM+92pnWZI0t3c18bzKrR4QXUixcJeoN6s=; b=iDTTmE9zwCK/3YCA1Vl8u/kHRKwxMJa16StoFnOwoIjdb/nmVeGDSFG9A7umghIncr EHNsUzqOyrkhBwHW56UFwrZtY6hmUCEnsBUH1aX/L40zG9QIgIvLipZEB+hVSVcA+j7Q OLcF/Bd8+77MKa6TyMkBKaIXpwL2PVWqmCWs/2dgwdb4jn5IlyheiuhAsvNvHBLb0W05 Gp+MhQjoQNdGuW41RkaYTxt2q2zletKICFOXXrr48R+LLHjh86Pe8cwsRQlb+uCv6ouO jgR+1sKdjpp9JQwKZba0owRUQjP19yOy7/OWNaua5K7cz/QVUCiOM92ao9fcRTeRK/+d VXWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lsBZunZL; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id y8si2525351ejw.78.2021.12.09.22.52.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:52:29 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lsBZunZL; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 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-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: 522738 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp2170509imb; Thu, 9 Dec 2021 22:53:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJxz1A1nYC2vVghV5TO9pXZJdN5e48i3xsmZRkYdVhDsw8P62etObP/oJaWer9xdJPlvXvw3 X-Received: by 2002:a17:907:7664:: with SMTP id kk4mr21338115ejc.319.1639119181031; Thu, 09 Dec 2021 22:53:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639119181; cv=none; d=google.com; s=arc-20160816; b=mhOx/ukhv/5yiL5xu2aSmSRZjfPxZRBCEtzjVNZXbJxY4ruBZFj4hwna7VemuE38rX mqsU1yKDWG3vQ0trk6699nErBmdrAY7PgOQ4h9h8IyR3XyTGdgtaSFFA1bhJNZ0s+Bxi wZJiNORwPvqzMvoR6afA5V8ohYFPiJgc4TafOOtSemyjxt729xazJGdfpne2AbWOVN/V bUA5p4HMsNEJANbU9kZ/ITuxgE3CV1ZD6XJcs1npCqw/xU4s5lInSoeF9RGZsdnDGETl gsPqQo30bwHAwhWizA2ucVmbWclVCTVVnewk88u4Sc+5SPoYrOPfmLmRhtfXvPn9PpYJ 4WuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=g5jbnk1IB+GiTYr6NhVHDYbCdhrqe/DkUf2QCnibqFw=; b=Wtx6OxQuzQgp5iqUEJCRyggf75+Eg5tx7j7NKT1DFjTXmR2tp5BCGD367Ye0M722Ji RTRQzGmdCxrgNtOVBtQsoi/h9eyJvVEn0UozU3ThTEIWVuHT0zFeWuf9l2nELgtW34qu OLMhqWeZq5D/ope5BmF6VJC9gIOSoWvfLKtr+2DJfScyc5wjUoi4eno3tKW2oQZl283y x5IEkNosc0zy4/MZT+c2kGmh1cKf7TnWnlvAVck/hlZ6zhiWcJ8TMei5HXmApEw8SiVo o7X6sJs4WvxtJ941vj8eGnQDapujt+juh0BZMPKLpat/N6Od4tgfkLX2C1J5QOhhWN7K H34w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LrlmCVYP; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id z11si4069712edb.194.2021.12.09.22.53.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:53:01 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LrlmCVYP; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 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-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: 522736 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp2170241imb; Thu, 9 Dec 2021 22:52:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJxnEuJ6yc5HNESZlHyuczEj2PV6M9yCmhwvFe6MXdYfttcVacw1roD9yNUWWUJO5BboALls X-Received: by 2002:a05:6402:42d4:: with SMTP id i20mr36528100edc.281.1639119160212; Thu, 09 Dec 2021 22:52:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639119160; cv=none; d=google.com; s=arc-20160816; b=b2kFhZpL1KbLaE6qPvobeoBNw+Gb6W/eqrTyHLd9VqoJIQfbZJ3NMOi4mjgM8NOvCG 8qaGEbgOQA2+JIy5bMeKUapNAX63lSo4oaakJbq0rwMsQEKtq6UgGn9z2GSvc/mN4D6F Uy4dt77NFKftGoG3Y8m2SAefdvC8UrtGyk2a+EezXVQCVdNejNmsNa/0ZbdWi1olazaz Na2WPgeM8Y0X74lqw6r0YpRemrukwNaoY7BlMpXTDNRgYcLMHrxflaPVrfYBBBTuJ7FD GNBhmsRn0Yo5crzy7rrhOo77elxtkkoMcsqqYWSUVFS6jki+EWf6Fog916ZaKxPztsXc 5Nkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=u4TnVOX5Qtgz+lAK7BS7cMpdxPf+iFXz/Br2DGxN0qg=; b=PE0Vp5ylznm5NxzoIQsvjRf0xgpOKTp4rVCFI14VEmuI8lVSxS2byoIR0eGz6bkmSK tzde6rlRMT1hQvSq79R+FHaVEPuDjjZK7UX/I3l1t9PdahntOO5q7O7n7euUKRXJ3t4/ E2JCx/0btKrvTlAoJcf6iFO/E6P2I0MRnAaMMp/oBNdf/DoHNXgAJc+dL2CEIxgnaclO VHqyejV8kvvtgrYwrM/KTzUhQXW9codLdyRKvgYyVad4Bu/EOjehj9r4rYvQEzQKANUB iOjP9o/Nh6Sm9fOhlsygjPoWS3urSbjGKExdFTwC7TA0Ewpees7hqlZWvwmuS9YinPS0 W3rA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=V8Kcx3Cc; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id c14si3243305edn.629.2021.12.09.22.52.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:52:40 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=V8Kcx3Cc; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 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-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: 522737 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp2170375imb; Thu, 9 Dec 2021 22:52:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJyrZAraDOqJsdIv2VTMWxQ4AsOC9GL1xAzMTH+FzZm3Acf7PmcdHmwvSr/zRYKCLKUDAkdy X-Received: by 2002:a17:906:5951:: with SMTP id g17mr22205897ejr.315.1639119170408; Thu, 09 Dec 2021 22:52:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639119170; cv=none; d=google.com; s=arc-20160816; b=cswinz4FSQ+6o9SZx6fqDyxEM/bARMq8W4z+KRX0ZJt17XG9qCsrPep4w4QoXOY/7n 7KKIK3YzrHFWolThvqy5esb5/AKkR01/iDtwgzjqIJtswc9A3cjjgH8iuM89i7Wmqgs9 /kH2oASRYKVYDnrSb6wEYWGQZexrnBWbPox1bVE5rkGD/DknnPQVHKx8296KHQSaC4dJ L12BPnQjzXXlJboB0wII/X5fUK0mKZ50sfV85+wetM7VNToYafGw/KF8PcVVfmofqgJ4 rZUj90iPz1ggPaSLQqZ08e9rLzIx+y+SuEac4SOy/F7+OY1XX2313nflYBFoeU+pBbrd Zx7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=TFTi4eZR8V4BD5x+AszorX/mKD69sIAYkkbi0D9OyB8=; b=0hjOyeyBkwkOTbF50g3Cj4wI1iorI8m+SLAE57D7553TuMr0FJ+mv7w3hMmqvArurm SPekqFzBEt9hZAlLVA+oS80MsROjYEBrbxIOwx9//88EWxpzVL382ftqOGWD0H/+a6zI O8+QWCCS9hPRFC+3xr5lMaOe2SXwE7LKTuHgknn0vXQLzAk8n2i/txLwl9BJdeRryLm9 sXseAfLDE1qdPeLBYa2GwbVw6GdE6V8x8niWEMcRolpRiMcQ8T4ABhGvOwQjLMXrXiiG MTSSPc+BvrLQe7iKQE8/Zpa4MNoXMnzKj5LIvx9WuKXZJU7QLhrS2IC8xROQBbLLVX8N 0raQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="YgarU/gz"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id hs39si5163176ejc.70.2021.12.09.22.52.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:52:50 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="YgarU/gz"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 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-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: 522739 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp2170681imb; Thu, 9 Dec 2021 22:53:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJwrzS0LIZLDZrzLEBgHnZDsmyc1tUgrike5ZYPjRVQl9Myee/Mwbpoe+GwvUbHHV2PFfIIQ X-Received: by 2002:aa7:d8da:: with SMTP id k26mr36243229eds.406.1639119192865; Thu, 09 Dec 2021 22:53:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639119192; cv=none; d=google.com; s=arc-20160816; b=kmohlfqDzmcYJd6/IfDKDJ56+SFEBngCGYvVQBp1ZRZix4TF1j64ZFuOqEdojZiDHT ruo93c17SMSskM9Tj2OfAw8HolgF3ARm55oRZRjAYXswP47oktocysguFKV4Y+TjImeI 2mCdhhGy3JNu8+DwnQ3RFG1c5DOCo+ANRqSz+habwtEqP4xZudj5+W01B/HnQa8UPiC+ l0J0cpaasYP3vL+FsHe1tbguhN4Tn4ZaHALfP+10hx6GT3ts8jS0JU9+aOLn0TJ6o85B w49NY8l94gvdAH869sNIfca2y8YORrF4hH4tj9cHU82dzZZ9qCyl3tnHPrx+cwdBkNhE xjMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=scQDk7CU4Htpi+80mL//SWDOEq0M+vsnaakCV4qH5zc=; b=LfzrvlE3CoM2ItEwxiKKRieK7zh6ChhYbS0KY4+JpOnkXQkMn3dVZrEgRf8doR5gc3 x9kwGfqT72VNAPWvRrSsglvD8DZiqKmNWl7kuI8L8iMv9dC1d6psOpC1p+VnE7MLCES4 lgBvTuMg7Tku1kJy9FR+IWw9kaUHzb3Araa0E2Txcwu5XSOmh2U4t7Hxx41w31y9thiP ZExVhREdua7Jfr6bH7hx1m0/WGGQb/PeE0H7MBnQMhxxUxjJueKWN4Z0TaL97M0lnsfg lAi7+vV7Dy/T8p0QbqxyUUK01cam7XsBUBDfiHymEg7H1YPpb6sdKkhovuQ5Blnqb6Hp Xgiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="xhDn9K/Z"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id w18si3365067edq.29.2021.12.09.22.53.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:53:12 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="xhDn9K/Z"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 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-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: 522741 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp2170944imb; Thu, 9 Dec 2021 22:53:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJyvnIgjvaVnYBfieDTWSZYhn4k8VzTUuJPEjfAGTWl/lMnxjr0G18Qwx2sv9yWAT4d8szD+ X-Received: by 2002:a50:ee19:: with SMTP id g25mr37105210eds.162.1639119212913; Thu, 09 Dec 2021 22:53:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639119212; cv=none; d=google.com; s=arc-20160816; b=KLlhFHY+OQDxUpPr5WMPxLCRFl7s6NpmX6nnzv5KyOubXWfZ77xEzouC1avmzG9Ul8 L+c64abknCZSaRuR8hFbM8eMFuAF7XulxbuXmDA4wSti9KiDVCChKC6tcGuMuOOyToir T5fMnavHPUVoG8VdrTEvheeKbr15PUj8tbA8a7Rkzuxu75S9VGUEuJeuE5l27/iIyOOm 3Eds7IxdV4gz7P7PgW/30EIE1cbwsqKjBieozkdFnpuf011iWYe1f7NpM36vG0jS7Pmh mW/MUVQiiBiF7bwJys688b8zZwyXG2M9vUu+Zlc217/bLLyTUUcU+HckTUvQ9eQP1SF8 UeFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=sYUc3BMcyz8ePK8CD3CP67NTGto6abBt+cXyNi4SEbI=; b=DEeCkqAEQzPm3dPmIoUUMJJ7+7eJSXBc1Aw+VnFuZsEBPmg1FkNX6T+hw0KM8Tbhta eJrIqLwbXbsa7OE0OluztxwLKNuUmiHUOsBKz/++6XC2weZUAxRuJK2EMBloYw2ep4Or KBO095e1BOlMsg4JYtJW3xomnqqGp6HqN462gS0WjvLjh6kY7ppTSYizYQw4sCVw0RTU 0K1GjmlKu43AXsH80SinOslI4mrX5EDikW30pXp59vwE5BB/5BacacNk1ySbiX+MEXrY je7ZYQuwEtGSBht2aZvQaojW1yHMd7gWN6nJctT33oZ4075gZmUrQlhnT2Flxe4R4yXU lVdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KCtnqvsu; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id du13si4776922ejc.417.2021.12.09.22.53.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:53:32 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KCtnqvsu; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 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-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: 522740 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp2170828imb; Thu, 9 Dec 2021 22:53:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJztGJqKEdc7E2ki5adr9PD2sG+qTqfzF+hV0XfBG9rn+VQRZLBLAoafjVxdbP8sgUhJBoCa X-Received: by 2002:a17:906:7304:: with SMTP id di4mr21323643ejc.327.1639119203224; Thu, 09 Dec 2021 22:53:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639119203; cv=none; d=google.com; s=arc-20160816; b=IIWEOQDNZM45rhxhMGV6iLqqa4pajAEj+Gx5pjMIYKgYyDbkebwfZdaD2X+xVXWiCA bYzrNl/NN2L3CcwIqYcd8IdjiYh4zlVqVIwwHJIgGZd1Bj31ZNhBs9d2Y8JXTzyTEYSH m8VofrClxTi156VfOESIQafcn0T4CglL/euVmi1OqvzGzrgJq/2WyVQmr0zPJ9qTr/8F RwLSLUD4NhyQqLrOlPhePKmPm/kz0xXCNEAXXcvIUaaQTAgGiTVI5JUi24RsUZjiBdgM dE8U2zD+rUwMlLyRD4zEE9l3s7JjEuDzHngalSPhr7CKtH9IN5hdAgN06zWWzu0gZaY8 SlUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2RJeyfCToQYeF9AW4ATinruQnvSK9EpBCOGEFn+5BEY=; b=kQEDBJx37VNjfjdpxFBt8WUzG4hTUxeOE+ZgkeR+OiL2Vg85wVmkShI8GYHoJ/FrJl 0MsL0H2h/D3oyekx2jJvYSEp4vCNUI9/8NF4xl6oQzq9SnU/v37yaRk5H6zuRlcUH/CV qbk0DovY/ggy1qZLWV8UqePHzJ92PYBUgMf74sVvlTGFTxOu9fudslxyGZ8WBt4cmbQY +DaKEPiWack87mTt1ujhqaAquex2OO8cyrOTIq6uN37DmEsD9pbxvi4AwsYmgZVB3ios ++AkYmhWgidWrTXAldRfKwGqC6WAzuyQmAXO8XhaDqCaztbuN/pQ0r1zPa6gBlNBpJr/ jSsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=w6C5Hu8i; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id c11si3678995edw.416.2021.12.09.22.53.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:53:23 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=w6C5Hu8i; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 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-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: 522742 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp2171057imb; Thu, 9 Dec 2021 22:53:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJzPzOaQtvpZ4MEiRxFp0QEJ++VYF7Jgg7VQNpadBn6sDDmwm8OkmnJYsBRccdPbUlJUg3GR X-Received: by 2002:a17:906:9b8e:: with SMTP id dd14mr21601871ejc.337.1639119223558; Thu, 09 Dec 2021 22:53:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639119223; cv=none; d=google.com; s=arc-20160816; b=SKtadqhV7CQDXIHsrhfsSAaFj1F4htkaUAT8zZPRnrFkFMVOxAAt07tEQxg3/O2zN8 Z9zve2oJgw2QIQ2siP1z8LwD2y1VG9H1BHFHLHyHlVa1WMb+7puPTmTCgW6pQVbFPsHG YeLf4zeKjVBfZTI6qs9O8gn3HuDkOeHXzUmPoe4ECwYIsopIVNnR06Wb5jvQ843bpFZ6 WH4EZbxHJOik4U1IGcg5W5Qw4yNPJDUI6OfYn0EA29SbvHmgaq8MD5+4CTDEiD4WSbAV /tOWZkgH37hfkyyHB3fa3madVQqxvhDMwTSPTXiAQ9WvP7VeNnDpNgtj52bn75ztRVT4 Ddzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7kmYl4c08xqigOLNyOCeB6rtRrnbW/qILnthkGKOw7I=; b=dkNj+xaNOHETym4dPqEdcGsDYBU8WNRTwHI4/3WB4rDuGGukYoLirzdATVJzghqgyJ JZZ1dRXGt9QRqPLq7FeJG2usCXiYwsILxNtoPjP/2MT5MzLTNqb+QWmDhVbcY/ObVC6W GhvL4f8hjoA3h8/rf0C4JIyo4+Pels/tzNn8WMn87odiJRGixpWtvedCsJzeGtLTZEVK TvJ4ySEYjIJbN//hNcCEt70eS3YAWXz4Z6lI4EhugKd1jmeDq2zpd2mrzIZa5QqcUnRh h5AR2e0rhDG8/vooxLsVeqhrnw5XSPBC305Ya2ONgCy0WWEJBbOdhCmt/qq6ouaIfHTX eAQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kkaf1V+d; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id qw11si4534118ejc.59.2021.12.09.22.53.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:53:43 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kkaf1V+d; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 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-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: 522743 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp2171183imb; Thu, 9 Dec 2021 22:53:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJy67cDFum41mauIeeK7mX8PPucJPO4ncyywXu6Ga50MYQBDHs/pCByCAwaiS1dwrqvkMm5b X-Received: by 2002:a50:d88b:: with SMTP id p11mr34990974edj.287.1639119233824; Thu, 09 Dec 2021 22:53:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639119233; cv=none; d=google.com; s=arc-20160816; b=D8DPd8E6WzOGB/pDbY+/bIWr3PZYoyqc+akZCHeVCPnVXIU1HL4EJOCWwDaCNtkXZh l95DWuVpAM85rraUhKKq+L7WcRswTpnGZNkJavZQFpgdCU/EMbL6TOsxnumJKo249aJd R2YXxJvT5sVdmflnpUHR4K17ZAL8ckWZsG2NXYhw7rFIacp17Q7RVpBl2bsxjrDdJ2ug Xeb4xc4ljrRx732uIhV5UWZ1i0QsLzsv16X0HdPSYHBJKNbXl3gpZkKSjjvua3XQiUr9 39ei7OafWIWypV9dwdHKB/r3d3jgn8m0pTGLZ+I49klQt/9CR7eRrsbSxqnGiLWpjrw6 HW6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2E8j064XPFTH1anOXyWK37XKESJbFHCLe03Ly8Wy8ZU=; b=uqfTRUgRNzVYMDyvsFcKY4cfD3joAkzEk8j97GpUPu+y9fiOivlD0wq1Cd9hjH0f61 CECdc6h0H1KiP9cxP8zdfXGAqIZxXXGZ8BgrM6L6E+lUkkXV2MOvA0P/hnjoa9rRaDUE 6jBesnHlpOuPIOlX0++EbkvfQYw0mixI/KFrXTfwD7SUq6xYkBFRiOvfWBgTOSQ3Tlm7 22eso+7j9Ka9o5yOoymw6DqmzJ5n6bMC8rl/x4C91zujazuoZ926h6bp4LtfBsFwJ15x BifTh3UdU93WYtXvnnTj64lID45vUc9UHqkqBp1YuZXrb/LHLjYvR9zAkuxgOdHyvHkU WpsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vxyRkd5G; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id z2si3692102ejm.647.2021.12.09.22.53.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:53:53 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vxyRkd5G; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 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-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; }