From patchwork Thu Feb 10 08:11:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 541395 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp2038506imo; Thu, 10 Feb 2022 00:12:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJwwTtJAyaOa+bG76FTSHQRyuF8fiRn5furranVr0KTwYVJwJi6cghsJSgP86a/iJuTcT7Z1 X-Received: by 2002:a05:6402:5cf:: with SMTP id n15mr6962330edx.245.1644480748609; Thu, 10 Feb 2022 00:12:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644480748; cv=none; d=google.com; s=arc-20160816; b=awUih+GxKH8sA5CaY82MRb09yN76w6wWeZvD4X26ZQ0MG+cZNXzy1rCR/fiSARAJ1t 9DhGMYSMahreFZXvk/5pPYBOqI2Cg/xqJdZf86lMYGFBh8fWaog4XKq7d0a6CCVhC/Ru aTi0ayF4F3xyjRkk+IW4vp02FksqbNTuQhvNdjqjvXZTHT6smT6Op6p91jIpfa9J+myZ y1n0Nw7Y48jyHZRDSNOEEjGAM+vUWgXLB9CjjORFgNLktXlCbWUrZnUcbQpMv27JpU+M pHO4nS65NjmD/9Eaa+Z2JsVA36Ou9h7iXRuRRKrO1qakIHVqVedBoS+1eC8ftupA/wom SzSw== 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=wWZWsl/17bJqb6Hld4dDf7eMnBfRLZNj37qeoAXo4JDf7ckzYc0BPgK2ubMU+pZu5r XlqSeCc3meQ1TciWsBdeRqjcbgSEneo5ljLsvRs7bEfHbfSgioD00f4NPkC5kcBrRxG3 nbDRWp6FGQlCrY4Sf536L1qxpEKzmmogLuxecA2avet8k6SZOhDsEyVwsovxhdqLCfQn 3BNXXzpRCVGYDbjJhEvJ45w399QU1DpMvWST1Gm3PnbMQRthKxOwGnFKWx/rbuq12U6f /D9g6KH4JoCBpgZrULcnpDexKPTfm4TIQQcaTDqWnQDLEfYvIzPWHlZOl+I0GrrrgAY7 GwPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d1Ve+Nsq; 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 ds9si13639761ejc.775.2022.02.10.00.12.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:12:28 -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=d1Ve+Nsq; 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 F336B82014; Thu, 10 Feb 2022 09:12: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=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="d1Ve+Nsq"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 153D18142D; Thu, 10 Feb 2022 09:12:22 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) (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 1A59F8142D for ; Thu, 10 Feb 2022 09:12:17 +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-x42a.google.com with SMTP id u16so3212211pfg.3 for ; Thu, 10 Feb 2022 00:12:17 -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=d1Ve+NsqDaTmI978GbxCVhm3rqMsicBN7/MV5eMEup3ykMeQfUBHxgsC9XuvDRpXy8 xIxcY2b1pOqn9kFWhGTpci1t1x/oabURht7znjjRY5P6MhgbhIuI7TkGyB87jpIdn8ET 0yYFegi6h+ASJO/+1L3t+seGMMEr8GITfWGeTRc+r7+JaIMaeJ1/uGsLlnB0GWtKU679 t+on5LY1A+feFIUa0s567le8jW+WmbxGdWsdy8pSHFFNRTHe5Jq3g48YJwHWExxmK7XV GSJ5L3br8zjKESSL70t+mht55A2LdefMw6oD8DTJOFYQyAVvG4kvsYeOoIIM3lmvt3xl ofLw== 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=xxD5Q192vpYc/ahyF0/RjqAvuh4RMm8QBayPYfLuqjLrk08bnRRjTjUYgud7jcfbA+ wBoo6ILUbcP7uudjNk5/YmlVXGg0Hiex81xy8JQYDDbfL3YPbAWD+RH4iprXU5+RpBjg iZWAidAK2Z6z2bEVbmmCq0z0CeeTGwkdcWjJqpYbqU3xpGEFuZ4sCZye+u94ekkVlpor PVZ1iVokFpZSpVKBoB9od4HQ+hE6ftKu4GOuGnAgF1lT1eDkP0Q23FHlvIN6k+Zq0phe r8J8Nty0cbwCqvMlS1PFZZn+eYaxvDlJ5PBMkPNKXQPhgNoJMw7FRmdGYSgmvkYHOzxH Y8ag== X-Gm-Message-State: AOAM531fRWeWwbVmvoUUOMV3Iwg+rDgmb0PUTtVrBRATUvhGXyhONG9V i78a59hst1PJ3cZJtC9It4LEdA== X-Received: by 2002:a62:2581:: with SMTP id l123mr6319629pfl.71.1644480734936; Thu, 10 Feb 2022 00:12:14 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:412e:384:fab9:f24]) by smtp.gmail.com with ESMTPSA id lk8sm1529208pjb.40.2022.02.10.00.12.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:12:14 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v2 01/20] scsi: call device_probe() after scanning Date: Thu, 10 Feb 2022 17:11:05 +0900 Message-Id: <20220210081124.86612-2-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220210081124.86612-1-takahiro.akashi@linaro.org> References: <20220210081124.86612-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Every time a scsi bus/port is scanned and a new block device is detected, we want to call device_probe() as it will give us a chance to run additional post-processings for some purposes. In particular, support for creating partitions on a device will be added. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- drivers/scsi/scsi.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index d93d24192853..9a763ea78bbd 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -595,6 +595,11 @@ static int do_scsi_scan_one(struct udevice *dev, int id, int lun, bool verbose) ata_swap_buf_le16((u16 *)&bdesc->revision, sizeof(bd.revision) / 2); } + ret = blk_probe_or_unbind(bdev); + if (ret < 0) + /* TODO: undo create */ + return ret; + if (verbose) { printf(" Device %d: ", bdesc->devnum); dev_print(bdesc); From patchwork Thu Feb 10 08:11:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 541396 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp2038578imo; Thu, 10 Feb 2022 00:12:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJxmLg9iRfo7uKFvi1/zW4Lsp37b797I9+7CZeeQPGx1g5OTyifbPHMsA5eqKb1ffug5ArXY X-Received: by 2002:a05:6402:38e:: with SMTP id o14mr7067031edv.414.1644480758452; Thu, 10 Feb 2022 00:12:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644480758; cv=none; d=google.com; s=arc-20160816; b=J7kxei7oirUACW65WHg18G4rQYNGt4e9tVlr22J3M6xFBufm+wZ6tIy0D/4uYobbgu wRGRSxtNca2uSTtD+4Bhkyc6LhMa6G9q11NdEBwaAqpF0sjvXcSVYw39Q7pc0FABv9nk YKuBEmZeuRy8PEHwQRxPPSRhz9p8lZptupPY//v2a7BjG4nCB/IlrKJ8b45XkuDZqr5n I3QMB3UinJbhv9hWDRvGL0L8K5RY9H1tB8Mij/7sfjo2LG4Om5gjK3/eM6312vxjuRRJ EuJpUEhvxhn83wAiJH8VTVL6BpyLrMXaZXHdo3n4nEM4i/BKnfmX+wlyl+D4xnAjK9x1 3kVA== 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=TKCjqkcReOTIdWupV0g/IOts48k1maVRDSlcVfP/OiSzQ0kRbyt9t9wyyu8EP/X5C+ j9kEJ0csQXWr3pE9cjHY2txDHfNLpnzLadqDxBJXVgIuwYnOMKJtqEJRyHjSYWZIft5F a0lS0l4+R1b9hZuDwvxgzfFwvB7tfc8VeZffrbKCgyCDmnhwko+x87z5Tt4wVkfZkXJe eg1qj1b/YqAnQ6AKv20+yfEZY4Ponf8lwUbQLwmZ+Gb6SokrFukTTLoCtLozfDMOVSSi LhCx6fFViCJjreJu8/sd10+bEhefCWPZwwEH60FV5QzVsY4qtmjAYlTZH9oSZtHexr/6 wJfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qwRiOqmK; 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 g7si4862027edb.109.2022.02.10.00.12.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:12:38 -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=qwRiOqmK; 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 AA68882F65; Thu, 10 Feb 2022 09:12: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="qwRiOqmK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2AA0381A03; Thu, 10 Feb 2022 09:12:26 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) (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 7F49481F4D for ; Thu, 10 Feb 2022 09:12: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=takahiro.akashi@linaro.org Received: by mail-pf1-x433.google.com with SMTP id i21so7409239pfd.13 for ; Thu, 10 Feb 2022 00:12:20 -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=qwRiOqmKBAq5k3ch1hGBNcYSw/t53a5FfmjO2Rl2N6ZQAllb6/RuQHxbNJAUEmsiPI v0IZH9Jh4FJlYjaAdfM4quP8xTR4Y3VUnjftuzpr5tWXkrTGUJudZkyR0a1FlGjvYXvU MVcSE7VSF+V/BwtwTk3aQcHu0dwXxMT3uuXr+8sdQsfLLYR5AbRQxMZzFZjQA3ZJoowt 2ejAMjImp3rE7Hy7xi3IFi1PJ7rF/zkoZf/yejVEEQqMNRenVwY4oarj1jTwIbJUo+Is TRxQbQBYdTfSYZkKwQ2uiWPi4mivxENz7vPBzzE6ETGoLIGEsS1IQsSnYlRAbrgN2yDC 23uA== 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=EX78BIxot1rLwHuhvwOshax8E+mAFqpjGj8yZzMENM45q2msYsv1NdcxEnqotCHUF0 mPT1WQaQkcq1JySnry5cVFtnk4bbwrJRj0DtaW12putQIqsfwdwxWZ6n3xThX/0Olt0F 1SPEa6M86aE4YccdTSHHb9N+nEPw7n8bh+yJNKAwLeiHBatd1ks26otiKGe/tMEhy7b9 nVrtfHbgoVka9oY13myC2CXexDhmF99vS8n0i/Ym9/Vkl6PtB1ZKKbAIITS3QuxzUY4X V5YuUZEr/NoG0CD9d8tsSnNUJSU+v84RiO2+WThiQsrQ9RbHZwMTnxhHzxyEy8zdmMYt s28w== X-Gm-Message-State: AOAM532eH3qu9gIduGZDwFBdfXMuzk7dYfwwONRajRlt7ozj/JRWOFV3 9YU32z6qZQQVhq2/O4PJrqpeww== X-Received: by 2002:a63:864a:: with SMTP id x71mr1197426pgd.380.1644480738760; Thu, 10 Feb 2022 00:12:18 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:412e:384:fab9:f24]) by smtp.gmail.com with ESMTPSA id lk8sm1529208pjb.40.2022.02.10.00.12.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:12:18 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v2 02/20] usb: storage: call device_probe() after scanning Date: Thu, 10 Feb 2022 17:11:06 +0900 Message-Id: <20220210081124.86612-3-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220210081124.86612-1-takahiro.akashi@linaro.org> References: <20220210081124.86612-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Every time a usb bus/port is scanned and a new device is detected, we want to call device_probe() as it will give us a chance to run additional post-processings for some purposes. In particular, support for creating partitions on a device will be added. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- common/usb_storage.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/usb_storage.c b/common/usb_storage.c index c9e2d7343ce2..291728f37e0a 100644 --- a/common/usb_storage.c +++ b/common/usb_storage.c @@ -239,6 +239,10 @@ static int usb_stor_probe_device(struct usb_device *udev) if (ret) return ret; } + + ret = blk_probe_or_unbind(dev); + if (ret) + return ret; } #else /* We don't have space to even probe if we hit the maximum */ From patchwork Thu Feb 10 08:11:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 541397 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp2038644imo; Thu, 10 Feb 2022 00:12:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJxaApOZTF7vV9AwRbiRNyiA+tPLVMe6gEXmj2FfBjKYoIwAC7ABImlUrgjxZ49NkTDiEot3 X-Received: by 2002:a17:906:6a20:: with SMTP id qw32mr5370268ejc.40.1644480768084; Thu, 10 Feb 2022 00:12:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644480768; cv=none; d=google.com; s=arc-20160816; b=ZaRxABh6I7+BjNfBEcWByM1kewl3q5AN12rOTdjk3pKfzs97wsrHASrmZ/06PzJGYN FV8MZdvxsQdMik6wpek15Vm3z0Ac7H4vJ0sfmO0ffWnjnFAlzsUNOB1dzS3SeGYsuNE8 DUKMVUGGgRzo1bdcA24CSCbTbnrzCKn0ZS3GI9MEo7DGM4ZJVy2FEmSGjASjV6gnHEFn oRxJqB+w08SZOXR/qguGqQhCdg0K6Ggbma2Xr9Twjc44p/4p81Pol+dtJ9MbMvkCC0gk VnXgj2c649Ctg2vgJkkVRI9kGliE0HvIkFtkuaKBMFLfkIzDbRejrC0R/O3wJxHGODGv 5rSg== 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=8MQeMEgxA8Fzplo3qyKWRVNh/30V422w+bdA2E6g2KY=; b=hMQYHjjre3zrCge6tn7Rv+EVZzvFow8e5tV3Xm/XDaA2zilw5OIhSC/daaxJz/KXo5 RQN44XfEx/9Ld5NDjTqRSSgcvAHRe5X0y3veo2SKb1R09ZHbjNN0CqLYVDKf3X6k2uGV +k8HgKzXOMS+umXLlKWCTJSYzVxZCBvTuzmYKLOFmK+QjoGLDhwHy3D47cr+STyGSIdS g/Z6KOZPh3AYbkCuTSqYBD2ESJbOBMX8iAN4CjfbmF0obgYJs9A3KJ8dm7mKOVUr34h1 re+S4F7ocFbMlcAQ3bi5/yzyFg3eVXUVFFQjsiZebUM+uU23zZ5o2W5IGqBFBpjbn1iF tPzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TKh6V3RT; 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 m4si10953630ejn.639.2022.02.10.00.12.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:12: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=TKh6V3RT; 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 9D2FB8307A; Thu, 10 Feb 2022 09:12:36 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="TKh6V3RT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 397468141A; Thu, 10 Feb 2022 09:12:33 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0F71083055 for ; Thu, 10 Feb 2022 09:12: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-pj1-x102e.google.com with SMTP id t14-20020a17090a3e4e00b001b8f6032d96so4825798pjm.2 for ; Thu, 10 Feb 2022 00:12:25 -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=8MQeMEgxA8Fzplo3qyKWRVNh/30V422w+bdA2E6g2KY=; b=TKh6V3RTJIb4+rIW+tUJ+Ry1zFd5GO8fcJfo/qPgIMTMJmx94cNV2hAV4mnlgNoJIv QBYwpao+3PYDRiaDFTnOOyfw0HR0iHj4VR2+dEb8QSSOlGTw602p+YryOnEQ9bgr6m0m Tn8p+9QouLY7RI6OnHQobwAoderW0pXTL1sAX0FGLG9pleX2ZiNdQEpCFnYezsH6fMgH zf4VsRKb/r6Bve+NMypqkf2UiBfo7fBjLuhVC7ZPC8jl7TBIvjc+gLyhSCvdg39uJki8 0XPZwhOS0CvvnbSoxl3nyyObXzGej8VXkgkrR9ntYMv2pVYYqGok17hdIll1JnE1O782 d2ag== 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=8MQeMEgxA8Fzplo3qyKWRVNh/30V422w+bdA2E6g2KY=; b=T33q6YQmqrh+5abFmjucZyNHVWQtr9oDCCEcCpKie5MJZ5fG835DZqMlQqMuSmSTN0 X+BwnKgNkrNzve+TvSn5NErOAmMiLJ3hAK186gb1tw14aCd0BPJd9yLyX16GBsGMJmSA NCIGxYAWewrC30moBXE5QKPAcppt/pdMElH+jxWKzY718S47zoeFbSH2MynrZkPI7z9u BqG6XiSWDElh/RKWpDeBsKdF4FHvTWEMftRBVykR9YQuabZES9LQfGf+3EkXydn8us/Z wz0NB1prOuWKt8AVf6NW35KM6aWsO3j/F1Hcf2h1D1EW4VnvEg9eZdTZ4xqKF2q7hd2l NZwg== X-Gm-Message-State: AOAM532glsQRE5SxcwBmMoAqZdz+dmIeuhAy6Zilh+tsuITbPJRILi0+ le8dHKYg2f3+VtWOOK+PHSbMBw== X-Received: by 2002:a17:90b:4a8d:: with SMTP id lp13mr1542516pjb.206.1644480742567; Thu, 10 Feb 2022 00:12:22 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:412e:384:fab9:f24]) by smtp.gmail.com with ESMTPSA id lk8sm1529208pjb.40.2022.02.10.00.12.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:12:22 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v2 03/20] mmc: call device_probe() after scanning Date: Thu, 10 Feb 2022 17:11:07 +0900 Message-Id: <20220210081124.86612-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220210081124.86612-1-takahiro.akashi@linaro.org> References: <20220210081124.86612-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Every time a mmc bus/port is scanned and a new device is detected, we want to call device_probe() as it will give us a chance to run additional post-processings for some purposes. In particular, support for creating partitions on a device will be added. Signed-off-by: AKASHI Takahiro Reviewed-by: Jaehoon Chung --- drivers/mmc/mmc-uclass.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c index b80e838066ca..aa2ab5d8c753 100644 --- a/drivers/mmc/mmc-uclass.c +++ b/drivers/mmc/mmc-uclass.c @@ -467,6 +467,18 @@ static int mmc_blk_probe(struct udevice *dev) return ret; } + ret = device_probe(dev); + if (ret) { + debug("Probing %s failed (err=%d)\n", dev->name, ret); + + 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 Thu Feb 10 08:11:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 541398 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp2038760imo; Thu, 10 Feb 2022 00:13:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJx7ElY7nLCSsM/NOn+nBAmykiK5AHA0zNZOGT/DmtbqvfrIbLWcm/OwxTQC57iK0ewCb8ZJ X-Received: by 2002:a17:907:9619:: with SMTP id gb25mr5461784ejc.422.1644480786844; Thu, 10 Feb 2022 00:13:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644480786; cv=none; d=google.com; s=arc-20160816; b=leDAo9ycydanNe8PcXLd87Tk7krzB5/GPK5kYHYnIQf89OUat/L8ugSUCc7s+CXuLI oeWUl57dD2mOfJmnEzUUD9gQaRNWO2HersjrqyDMR4rh1SbjfkLzNSiMrSeUSvypvuuV GN7wIy6O1yKVJcyb/PXEWkCbqkuQ/SBnZdzbI3C7JGrJ0AzQ6kKcAUGRQ9ey2UFG1wah 8xhEiSQfzwKhEgEh89hw3fyniOcGCpHg39FzWPJcpCWwEda9LyAVcANJi7ZMjDKqASK1 0h+Bt7kXDQNbit+Y8JHGb7E+baytlLOfMzzdzjHAbhLUpMiPKchw8lKa6PPWJasVIUSc QZug== 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=ozhwnzXcx5Y/5Dy3PbH5KJLj073b/371l8ZVkGGglexXZnkSMoe3Mu271eywVWuD6R tkPx4QbWlrYUXOy99BpGl8rCpvFEG4ZHXg+nt3zyr2lZxf+pEAzNMzZ3gUChH6H7MDHX jBOHeQB+aljhrrTlnSVvjPTm202d7V4KmtwwwXThQG6DHA+/Ub0GTKDJ+IfU5vTICrYj 0+pX+6KZPw0NtPi3Vc1cXSx9/8AM3ehKDCFNP8kGSfvTXuRoVoDMrvkfx6do6ALAcd4l hiEZaoSoeBVVkcSn7jGhwzxNnhmduMz2CQ/sStJ55bC+LOLzHekvDB1qSGdSIZQaE7Dg Vwjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rxVUk5GE; 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 qf19si4228826ejc.902.2022.02.10.00.13.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:13: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=rxVUk5GE; 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 7F0B4836BF; Thu, 10 Feb 2022 09:12:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="rxVUk5GE"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5CDE982F5E; Thu, 10 Feb 2022 09:12:36 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D213D815D1 for ; Thu, 10 Feb 2022 09:12: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=takahiro.akashi@linaro.org Received: by mail-pj1-x102f.google.com with SMTP id h14-20020a17090a130e00b001b88991a305so7734603pja.3 for ; Thu, 10 Feb 2022 00:12:27 -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=rxVUk5GEVPwvYSdxTIJnzXCnJUXY0A2e0zaB7EvVRsgx+G5s7ly1rhPYe8wnpx0MRZ CUicXadKQuDuWIhMs/ChF5PQ7DPI30MgSC0YIEpVrvT4W3G68o7KE5tIB7mtqjSk73jF dK15KR22ecp4Yaxu0fBbwwlOnX+6o0IQQIsOJF0YQk0SAxhyU04sqBMzMrcvBj8uTEC8 lJB+fMcHJJEw/lPIGbEnnAS32XjpWTd1UPmc3sGmo+074jlmFBGDFwr5WpN/gi/0oTnY DWv4AqkX2Dx/MEUvN9Z8Gnb+EuacF9V77BThZraonJnJtm45m77xa7aeiiIVAmihdoN4 pIFw== 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=bslBpsv0M1D5guSCwaiIvdfitlU6ovboJhWqDPI2reFRDL9Y1rqMFX7yzAgY3gtAL1 cOxHxRqW8/J2j9b2ZcZ7B2aHpe3v0Qrm8Xt+uMCh0rfykXJ5us16I8f5cpUrKGYRJdyp DPOHAOFAxZfT83xyBpZYUjE1PeNvIyDvqVEkN+5QhLwMHSU8tHd8J/QI2N41H0GLzohf Ru4ID2BRQiMdMzkFXqsw1nkX+D5UIMyvoe3KAmnMVUqnRh5PKy2hVQQMsvI1Q3ruBhgc yjQcsVN93eFRNTqNxiJxwNSURINNZR207pOD3UxIvijjCywy5HTrtXNYLsdpbEdLvcs5 GEBQ== X-Gm-Message-State: AOAM5337TH6+NOpyfzovAeio0vLpg5Gyad1TaEzlDETJKTmtNL6/U9Ek 3sDEmAr7Hng6PnWjm6JTwLq2Sg== X-Received: by 2002:a17:90a:ae03:: with SMTP id t3mr1534912pjq.55.1644480746255; Thu, 10 Feb 2022 00:12:26 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:412e:384:fab9:f24]) by smtp.gmail.com with ESMTPSA id lk8sm1529208pjb.40.2022.02.10.00.12.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:12:25 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v2 04/20] nvme: call device_probe() after scanning Date: Thu, 10 Feb 2022 17:11:08 +0900 Message-Id: <20220210081124.86612-5-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220210081124.86612-1-takahiro.akashi@linaro.org> References: <20220210081124.86612-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Every time a nvme bus/port is scanned and a new device is detected, we want to call device_probe() as it will give us a chance to run additional post-processings for some purposes. In particular, support for creating partitions on a device will be added. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- drivers/nvme/nvme.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c index 3c529a2fce22..120a0f05a591 100644 --- a/drivers/nvme/nvme.c +++ b/drivers/nvme/nvme.c @@ -910,6 +910,10 @@ static int nvme_probe(struct udevice *udev) -1, 512, 0, &ns_udev); if (ret) goto free_id; + + ret = blk_probe_or_unbind(ns_udev); + if (ret) + goto free_id; } free(id); From patchwork Thu Feb 10 08:11:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 541399 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp2038845imo; Thu, 10 Feb 2022 00:13:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJwEwd3AWTWkKqg+47tsgZ0KXmEK4IYw6tQfHcHHSyFvxZCQLT82wtXtJ6z2wvHg6aFMremp X-Received: by 2002:a05:6402:1a52:: with SMTP id bf18mr7109973edb.428.1644480798813; Thu, 10 Feb 2022 00:13:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644480798; cv=none; d=google.com; s=arc-20160816; b=04BhSJAvZz6npmJZOY7944toc2ItEmApgYfTw3FWpQLIcpT+0ndBudpzmbuMR4CgeN UC8sN+mcIr1NJwDnqqXU2LBM6TEoe6xF49E5M00+VZVns5Eo9+ioImjpnbSGQ0Hq/8EN TaD4gu0XMs4ur9cO5DosVBdfEU3mt4Y3dv0tfwK2jWIzuiAagbzh1C3Vdx/tu1KMpeNA jJrRx+k1MW+fUaseGpqVptp3WDgXt7fE8Br7aYzPC6+mG6ejFwil2FHXQG1YWuw1IPRi 9pnLOUzSR53T4vvGd8ohazsdtCLoaUkigKOhlwQS2ay9PecTf87Dqx0nJIT2sus4aDpq Rgwg== 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=pcaNr8OceKx1o+wZH+Av/BHFeWyqQYvQxkcV8HghPX8=; b=V8bF9Kg54G6dmrFpdDFpa4fi2Ok9rqtEn696J8UkqJd5VeU7OPox5RP/n9yekLBq4h uMQGT0YKLGPhUgX+eGmlp1gyWUhWZo6GaWDj+KkU+d6qq78COl94qVDCfyei1JqbvVIz PTwx728d283NQvytEd9/ibxM7HvH/xa2CmW4Urn3cdXFv/etfL1DN7i4S+iMU37LoCOB CU4jBwFna8L0bt4tuD7gkXClTaa3je0+ArcUxZXdvVJ5o7p4qFFha75imAMte8qllsW/ DJ6iczS7oHT4FR/hmvGfEEt/cUYNPSgHx4SAbqXnGwQUZ6HhfsqbJn3oCXMwbUOuIGJ/ caKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lI2KPruU; 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 nc1si7860905ejc.151.2022.02.10.00.13.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:13:18 -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=lI2KPruU; 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 0390D83764; Thu, 10 Feb 2022 09:12: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="lI2KPruU"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8BC6982F5E; Thu, 10 Feb 2022 09:12:42 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E63B08319C for ; Thu, 10 Feb 2022 09:12:31 +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-x1030.google.com with SMTP id y9so4497579pjf.1 for ; Thu, 10 Feb 2022 00:12:31 -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=pcaNr8OceKx1o+wZH+Av/BHFeWyqQYvQxkcV8HghPX8=; b=lI2KPruU3R9S+udrnRUQEIN+NHnEezfryrD34Cz4KiUXMHr5HmfNWujrdJIaTovw09 HXyY/jAcODIrEfbJLU2voyA09IhD5aQPRNGoyZyTzUyGN4vL0ShkMWz0s2jm0JFEXhNf BSXA/LMxYxaKgz5coED+GDzsHyQA1SyJowuvRj/+obbA9ihrQ0vyKsJWAAn9dSfeQsQw Y9adv6m//cLdmRzGyKZ2Q+tplStoB2t1mmdtyTjdXsWAzuyQKPKnDObX3IxXKjsWkgff p2iyal5MlaLT+v65pRUKoZagG9xcvV6E+Hlax4ZK0eawsmO/TyKJYyye1elforZp5RHE uLHQ== 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=pcaNr8OceKx1o+wZH+Av/BHFeWyqQYvQxkcV8HghPX8=; b=r1TRAjKhU0UOepK6ekHM0vIkAJSW6YLcFuicdHaAcQLt+xvlv3fIRxNpWUAuOylREW XcckmUYIWFjyJjd3gP0wKvFyBhJSWBuwLb1SoLajqZ3+rUCaOpG79gzndue2+HBZU/eT nOcc2U8YELnLJwNNt8hNbU+mfx57pcdtYc700YEB/T7Sb/u45VT9HipKAl88YNJci9wT 8A7SLUCbEBuz7tUEmdxHFrVIkfKju8l6nJ7/SKBQp9aDXxwrw9SkwxEJ7Oz71pBNo7uM nl77+OTPe1mbxGkwDyufguheeaph2FiBz8frvLihFXCCfrNXWTjLwZYv5VGyneIVDgi9 iLEQ== X-Gm-Message-State: AOAM530IgN71Q4VYEFXSXEQeaIiBc8xuKfHQIHibhQoDyUJFJKSsaAFL HJeDavEMkc2BFidUUV8F2rSwaLyB3myrZA== X-Received: by 2002:a17:90b:3852:: with SMTP id nl18mr1567832pjb.228.1644480750256; Thu, 10 Feb 2022 00:12:30 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:412e:384:fab9:f24]) by smtp.gmail.com with ESMTPSA id lk8sm1529208pjb.40.2022.02.10.00.12.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:12:29 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v2 05/20] sata: call device_probe() after scanning Date: Thu, 10 Feb 2022 17:11:09 +0900 Message-Id: <20220210081124.86612-6-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220210081124.86612-1-takahiro.akashi@linaro.org> References: <20220210081124.86612-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Every time a sata bus/port is scanned and a new device is detected, we want to call device_probe() as it will give us a chance to run additional post-processings for some purposes. In particular, support for creating partitions on a device will be added. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- drivers/ata/dwc_ahsata.c | 5 +++++ drivers/ata/fsl_sata.c | 11 +++++++++++ drivers/ata/sata_mv.c | 5 +++++ drivers/ata/sata_sil.c | 12 ++++++++++++ 4 files changed, 33 insertions(+) diff --git a/drivers/ata/dwc_ahsata.c b/drivers/ata/dwc_ahsata.c index 6d42548087b3..d9fd850c6fae 100644 --- a/drivers/ata/dwc_ahsata.c +++ b/drivers/ata/dwc_ahsata.c @@ -1026,6 +1026,11 @@ int dwc_ahsata_scan(struct udevice *dev) return ret; } + ret = blk_probe_or_unbind(dev); + if (ret < 0) + /* TODO: undo create */ + return ret; + return 0; } diff --git a/drivers/ata/fsl_sata.c b/drivers/ata/fsl_sata.c index e44db0a37458..7b2d62d7581b 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(dev); + if (ret < 0) { + debug("Probing $s failed (%d)\n", dev->name, ret); + 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..a187796dfcdf 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(dev); + 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..cffeb01561b1 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(dev); + if (ret < 0) { + debug("Probing %s failed (%d)\n", dev, ret); + ret = sil_unbind_device(blk); + device_unbind(dev); + if (ret) + return ret; + + failed_number++; + continue; + } } if (failed_number == sata_info.maxport) From patchwork Thu Feb 10 08:11:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 541400 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp2038935imo; Thu, 10 Feb 2022 00:13:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJxfpuH7/1jxUSsQNc2b4tfcP8iE8T7OSwRzUz4vqS4B0pCiJ5XUuUkph2F9j/1g6kNVa7fa X-Received: by 2002:a17:906:9742:: with SMTP id o2mr5336985ejy.254.1644480809878; Thu, 10 Feb 2022 00:13:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644480809; cv=none; d=google.com; s=arc-20160816; b=wOd4mqxCeKYgDPl4jS3ndakZUJFiMlPjZSPGxCB6mc7TaRZNHNWrOWQ/ADJ80JnguR PjwBQefRP/Gz1OhCQUUY+W9WwEVhXhCMS3Q99umPrLj+TodZ9rFFse8k39QCj/+L1w2N ngmDtHe+nB42rMS/wVpr+WYdzU8hQP3t4qwR+Wlq7ViCi2Phb/zMHP8uLxWHxuXXOcWG 8jFyLsx8+2wsCTr//RpaQq48s5bQCBkembmgu4iQ5Hzbj3PWgJ2l+x5D0ZsEzoXARFsY KUw0UQvQX+MPfUmPSSfIYBJsB9H4gK83FZfW+pCQ5S/jy6Jh0QkmFoB7+8yrn5Apq4ga dJfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XX0iEQ4dt4saQZhqaVxrcJum90hF8rJcNwW2ChZ7JxE=; b=bzubaPQEoRSPByuHObgMgvRMLdy1kFXmbQ1/87hu3ZrQ8+Nm/oqfRhFKjbwonRnVai 0ty0hHjhXAOhc4Tzna0vURxTGb2vPUFWo87/zGV3hxjH9IqTej5mIjSKOedvxIpaybYb murDV3gA1b6Ln7HZ7PtWMcx4EQhpWrcH88eHF1xjD6RHe2u9ggZMzyT0ugNBsw6w8Lcd rbS7W3atGcA95LVUyYMIhHpFNhhvSau9Rq+eT8uEV5ljJCM2jPbj4KoyZB4XiCaol4z4 npUpGaivwPyG4OLskSNyRrXm7Xxos85EFq8H+qEtQG0AcbkxNJ8fio5i3IRWVYDhONF/ UXuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lKUct46u; 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 el12si12235698edb.382.2022.02.10.00.13.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:13:29 -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=lKUct46u; 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 68A8183542; Thu, 10 Feb 2022 09:12: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="lKUct46u"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 645DE81112; Thu, 10 Feb 2022 09:12:50 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 816408141A for ; Thu, 10 Feb 2022 09:12: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 m7so4525997pjk.0 for ; Thu, 10 Feb 2022 00:12: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=XX0iEQ4dt4saQZhqaVxrcJum90hF8rJcNwW2ChZ7JxE=; b=lKUct46u6/J9urrIdR8WJ4GiiBLe55D1F7vLVPexltFJ2F9q8Ewz+Qp+1doE9J0s4W 0g/m9ogtj2W/oxOxi0nl2WmbMkfcZS5g1bXX35AKv0RRG8l3SNvcUA8OVKEpk1jeUh9X SkgofiB7S6UdWGweAJTaz6aSzp4mkfScxSaa4YPypJ2zFrPBg3WS6kM0svmJhFmTSrsF wy1ZhhJEzgAEqCVfYjGDlM468qkMu4w7Gs3/+fjiPRQOsZR7j0MnC9AzxDS80p0v9Aqf Z6a7OPf2gztEmF2FsDfXKG4uBjcr7IED4RBCxBRMU0nzeEnWIdSbk0p4IHnSDKQjK5w4 P47A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XX0iEQ4dt4saQZhqaVxrcJum90hF8rJcNwW2ChZ7JxE=; b=ESVEeaHyFVGQMXBRr71dhWw4idFmlseBsEInaeLFr3cT9Jwy61ukJsr09Exj8tJ2ql D4L9yySYfl+nljOvSitwsUCK32SeZua/AkPBRUzh+TyQnsDw1L1BuHq5eCpFbH2MkuiV jX4nYLc8DjwMjumxXa2CmCVvkOyMQao/DYXpgwccv26SQBKiLb/8OCflc3HCrsf2UVNQ WpM/aIT4Qhf94apAADVCNyExQab4FqM0AEYZELQmJkibMwb1hqzqVvJA4uMAEwTwufuB clteH1Vthc6KhZyic3arXTQ1EIKfmAcLuTFg8LAkYptbCMcC7i3JzOiEY7z9Hi1MTtd2 0Z5A== X-Gm-Message-State: AOAM533ES5esNma6B1zxxhKvfCVYlgCrr44VM3yB/JDT6cCmACZDkLWS hUpxdi0LVc61c7jIIvxQjDIZxw== X-Received: by 2002:a17:902:e5c1:: with SMTP id u1mr6323683plf.52.1644480753857; Thu, 10 Feb 2022 00:12:33 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:412e:384:fab9:f24]) by smtp.gmail.com with ESMTPSA id lk8sm1529208pjb.40.2022.02.10.00.12.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:12:33 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v2 06/20] block: ide: call device_probe() after scanning Date: Thu, 10 Feb 2022 17:11:10 +0900 Message-Id: <20220210081124.86612-7-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220210081124.86612-1-takahiro.akashi@linaro.org> References: <20220210081124.86612-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Every time an ide bus/port is scanned and a new device is detected, we want to call device_probe() as it will give us a chance to run additional post-processings for some purposes. In particular, support for creating partitions on a device will be added. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- drivers/block/ide.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/block/ide.c b/drivers/block/ide.c index 085aa356feef..a96df4f0a3c7 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -1145,6 +1145,10 @@ static int ide_probe(struct udevice *udev) blksz, size, &blk_dev); if (ret) return ret; + + ret = blk_probe_or_unbind(blk_dev); + if (ret) + return ret; } } From patchwork Thu Feb 10 08:11:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 541401 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp2039016imo; Thu, 10 Feb 2022 00:13:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJzds9HGrjMSeAvnhocEaJ6FZefg3MUHr3Cvgd93GQUUx3E9UH34tm/lF5n9shFbY6aFUa7q X-Received: by 2002:a17:907:3d01:: with SMTP id gm1mr5401047ejc.22.1644480820336; Thu, 10 Feb 2022 00:13:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644480820; cv=none; d=google.com; s=arc-20160816; b=N8qNLpUqyug26wiyq6hXdFsGaD79XHr+JkfoWXEAnbGoB3X+5ZGGG0bhWmlBsS0P2b IswW70xiRmHFQ4A4SuPgnRG5O14Dk+54gQcgUgnaHPUaK0ttsNt1Wh45N3XBsk6x2jY5 2soDMM0PL101Rm339pg0BomO7ilfLYIsxvOp3VpHjbIEBHR2yqJ+mdt+pBUyGULr84GP oUA/8uzUPf107uDNAnfEKKIx0bgYIgIkw0tU9L3KGucDmF0tP7HVaQo/4ZqevyvyBRub 1LsG1j5rUKoajgsTr1OYFLYauxfxcEF/GMex+IHvqtOSKoq57jKFO6tAhV0+PYWCm6n7 2n1A== 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=rPa/7DDkj4iBuuTqq6EESbf96QBNWiHX8VcQZUMtLjo=; b=yIEuw8VjVGQvofCc/OWrAWt2nr5YdVhtbfatwEwQSd3bZNbC/CKx9STahF2EWGdlcc Q14ioRtBsq8hfTr3zkgL6e6jhy5NIKpb5ra/wjraoTVH3izNzD00yVgAPntGIZuV4z6o jrntUNeawf/B0QPAbZEP6TeCvBWfB6+vfeGlCRNH5Inv/hF6b+kBE54PGN0CUxn+VHz7 XqLtWmrLV1oIETQ8CCOukolHDo3u5AInt+jZiYZHzymmtHMkktZ0Q73QeIJqFKZF9LF8 Qy75jCkY2bp0TNKhQ7/z3VPmX1Ac5ikWgOcmojNvbuMYTSo44rIesItd02Lpff9xhIKV RNKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aDLUm+3+; 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 hd20si6718523ejc.944.2022.02.10.00.13.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:13:40 -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=aDLUm+3+; 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 757B081A03; Thu, 10 Feb 2022 09:12:59 +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="aDLUm+3+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F41088309D; Thu, 10 Feb 2022 09:12: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, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) (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 D89968321B for ; Thu, 10 Feb 2022 09:12: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=takahiro.akashi@linaro.org Received: by mail-pf1-x42d.google.com with SMTP id d187so8875657pfa.10 for ; Thu, 10 Feb 2022 00:12:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rPa/7DDkj4iBuuTqq6EESbf96QBNWiHX8VcQZUMtLjo=; b=aDLUm+3+Yz7cW+SNMPY52K2jnSS23UDTtYa+OPiM8m6EceAkiCb6nWevD4fhYnVJlX 9uZEe7zNisvBtIB/P/GUVIGLSiB4FJpvMUoUtf3zZGOKXsBdOwHnZR7Lashsm+B0qpm4 krV3GStIc8iGuCTborWjCPgKQupvJdHMIW47NkGho0igELcyyHCsmBANEsqNQxjtzXbg pouIRHYfLlCy3d+/nWWHtq8UOA+mRH3iFMN64Fw9LLH6ymdpXghqxg/8syTpt5vs+0Cw UiajjUSPNkt6Vzxo1LD3zA+AULHNCz4IPyWcHSiHWQSJhSgTzA8+skFyLPnE+x6xNr13 yFbQ== 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=rPa/7DDkj4iBuuTqq6EESbf96QBNWiHX8VcQZUMtLjo=; b=gFMlVA2ehWfJ4kXCR/I3TXElcP0gBoQn2OQeWyk9rGnIeZ2QHYfnp/3upteYi0OHrt nQJoZ85q6O8iPDAu1BeKxFKzsM3obGov2AkMPqCWg5ajf07X+3fjk1+vDmO/6xiwLU3j g+AR8NpiHtZwPvpeh/GXKtn55biMipMXqMpFbEH8Pt22POVuyVGl+PxWlN19MWaNycRX QvTniL7gvYMW4AaA/UUy9Q4IKTEH6YKeVYl+jV8hNebnHUbzjQ74WJZ/609diYygGKmY r+7eVkuPMMNcLl1SHtwZuolZ5XZJ4vEUpYGcJBEwe0iRGFNrd7Z0wX1uxrI78Ox8odek sm8Q== X-Gm-Message-State: AOAM532ZAQqdniHDVcor83qYkrJnrH+duIQMwM82B1OFL2/LXCdBgURm vuw+1xV7WUG05PSvTtm0+5Psow== X-Received: by 2002:a05:6a00:2305:: with SMTP id h5mr6460979pfh.13.1644480757246; Thu, 10 Feb 2022 00:12:37 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:412e:384:fab9:f24]) by smtp.gmail.com with ESMTPSA id lk8sm1529208pjb.40.2022.02.10.00.12.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:12:36 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v2 07/20] virtio: call device_probe() in scanning Date: Thu, 10 Feb 2022 17:11:11 +0900 Message-Id: <20220210081124.86612-8-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220210081124.86612-1-takahiro.akashi@linaro.org> References: <20220210081124.86612-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean virtio_init() enumerates all the peripherals that are to be materialised with udevices(UCLASS_VIRIO) and creates particular device instances (UCLASS_BlK or whatever else) as children. On the other hand, device_probe() won't be invoked against those resultant udevices unlike other ordinary device drivers do in the driver model. This is particularly inconvenient 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() (indirectly 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 Thu Feb 10 08:11:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 541402 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp2039090imo; Thu, 10 Feb 2022 00:13:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJy03FPtEZv5eIoifve9d4pouxYKn/nEx/5iQcrtVa/6PVv0TTl8eeLB0dlgZ6D+etjeElN7 X-Received: by 2002:a05:6402:358e:: with SMTP id y14mr7197233edc.136.1644480831456; Thu, 10 Feb 2022 00:13:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644480831; cv=none; d=google.com; s=arc-20160816; b=lvQqShcJXFz3qFvmLtHS8rDRZnNGo7sX1sevEUH0WxElsAQ91wjmQqm6zDvt5HD0rI J6icqvUp8a493BOWvJXvtEsiXTsMCizOk9HowAafI7sJvi8ukcsfInP/+V2o7DaDD6ai ENqixC46TPQHM7GwwaVLh/Zl1+3YG2Y4btkaC4PD90VAqDK3e5jUxn8jEKug1+O3cYC4 7dhsUAhHUvvj45zmpwIw9+PbHEQk+DWIDJnSanVBh+3cmtLuN9ANe6eiqkqOtPBFRZJX /14tH4Bvzb9LlznF76fIulLTO/X3rK1Sg2guSIlEyNOaDU3fi+NYZAo787XBcjruy2Pw MGmQ== 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=QPt7dWgGxUj0M27z8VSX2nRtzLgnc+QhOj9CDSRh/7g=; b=aPcz8aF660UuhwszMtLi/TCBvkjT0HKjIDpoMsD/M2OL3ZpEe2g3Zda4NJDI7twlir Ad4H0NAQ8Q7OYigCsCqK5zm/0hue/KLqFkBd20k/KLckjySGQYZsQieW3zvk8q296Olr Qg3QCUeId4fMLuuC6GxmOGjf03fhLfDjpipgQ7+oh3GKDtcyxr12pXpGLNl2ewFlzlRi 3IqE6XnbR+qaNLUXZOYdyrvKHcYlGU9kvQ2SpgZhXU9IR5sPsJMkrrNwbIDjClFJHTBe YNnCG5vSSF7c5eRAVJKXNPMA6nmqGcP5UfEKmGybxbLhoz1h0Ham+m3fWGSFfwtKVIh/ qWDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bKUkWvIA; 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 he15si6549858ejc.161.2022.02.10.00.13.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:13:51 -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=bKUkWvIA; 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 946998368F; Thu, 10 Feb 2022 09:13: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=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="bKUkWvIA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A65EF837E7; Thu, 10 Feb 2022 09:13:03 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) (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 BCD9D82F5A for ; Thu, 10 Feb 2022 09:12:42 +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-x629.google.com with SMTP id y17so1184982plg.7 for ; Thu, 10 Feb 2022 00:12:42 -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=QPt7dWgGxUj0M27z8VSX2nRtzLgnc+QhOj9CDSRh/7g=; b=bKUkWvIAN1yLo8k5xq+WmcfQi74INkn2c3OS+DZX1FzNKbpslanBePMR97/9zzmop8 QDc+7Ifky10BOeyWVD86Q8d+5Ek3ezCmGcocdef5ZaLMBEzNNx9FTe9D5GQp2SiwxYAS QTyathnxTlQ1zHJY0HStrAzHL5Ek6jpUbAqBTLb4+b4ag73CJkLubRjrwxs3zlug+ucH 8zf8HzJTRyf4WfZ6tOt1YPsUECvJcUPALbCjlXTv0lO+6pwfiLT4/0ObZIE0ePdMiQCr Zuk2sPlSWiWwym40WcI9NWMPIK5XVht2n076HyktC5ZPosDVfyfJWGQXxSnXN5XT/G6e ZYlQ== 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=QPt7dWgGxUj0M27z8VSX2nRtzLgnc+QhOj9CDSRh/7g=; b=ixpG+L+iDLS7xI0Wu24SwCIp7W8jZYqA/rzMmSfOp4Z3zuHKzWJeW9iFjsFi0mG+sy JT4cdXPF6kkSQj7Kc4dsf6uhS6HNrftgiUjQtE8Fmt8gORK36Wfs+yLhyxA8om1TgU8B nAaWJiX11GGGaxRbW2PZZbumv1P+NVm1dal0AhZ7qF/Q9DyMN+VgwGywYThygd1Vx0eP j6PX0/7XN5EJ5sp7BgvBqxtY1FP7duzz6CoDa19bFaiwHYBrwPuie3W++kKXQ21ZUowU 4KsLSsPNPFZNBDIKpCJImLWyCFna6bffmEzC72UQPLAVEHCxGybUYvc+Bvklm8NxrUmL pruw== X-Gm-Message-State: AOAM533SuTh69++dgHkjOXFAM+5XrvhnuUutLqsriuzEE9Ldb3NxwXfq MVqtu0k9nxLfuTPJQRHnZayHUw== X-Received: by 2002:a17:90b:1d8c:: with SMTP id pf12mr576674pjb.229.1644480761022; Thu, 10 Feb 2022 00:12:41 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:412e:384:fab9:f24]) by smtp.gmail.com with ESMTPSA id lk8sm1529208pjb.40.2022.02.10.00.12.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:12:40 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v2 08/20] dm: add event notification Date: Thu, 10 Feb 2022 17:11:12 +0900 Message-Id: <20220210081124.86612-9-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220210081124.86612-1-takahiro.akashi@linaro.org> References: <20220210081124.86612-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean From: Simon Glass This is a draft implementation of event notification mechanism from Simon. Under this scheme, any U-Boot subsystem can register some kind of callback function to a particular event (more event types will be added later) and that function will be invoked once the event is fired. As a first user, UEFI subsystem makes use of PROBE and REMOVE events so that we will be able to automatically create/remove efi_disk objects relying on associated block devices (UCLASS_BLK). To run the test: ./u-boot -T -c "ut common test_event_probe" Signed-off-by: Simon Glass [add REMOVE event; fix checkpatch warnings] Signed-off-by: AKASHI Takahiro --- common/Kconfig | 11 ++++ common/Makefile | 2 + common/board_f.c | 2 + common/event.c | 103 +++++++++++++++++++++++++++++ common/log.c | 1 + drivers/core/device-remove.c | 9 +++ drivers/core/device.c | 9 +++ include/asm-generic/global_data.h | 6 ++ 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 | 7 ++ 15 files changed, 389 insertions(+) create mode 100644 common/event.c create mode 100644 include/event.h create mode 100644 include/event_internal.h create mode 100644 test/common/event.c diff --git a/common/Kconfig b/common/Kconfig index 82cd864baf93..d411e5bf7a50 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -492,6 +492,17 @@ config DISPLAY_BOARDINFO_LATE menu "Start-up hooks" +config EVENT + bool "General-purpose event-handling mechanism" + default y if SANDBOX + help + This enables sending and processing of events, to allow interested + parties to be alerted when something happens. This is an attempt to + step the flow of weak functions, hooks, functions in board_f.c + and board_r.c and the Kconfig options below. + + See doc/develop/event.rst for more information. + config ARCH_EARLY_INIT_R bool "Call arch-specific init soon after relocation" help diff --git a/common/Makefile b/common/Makefile index 3eff71960160..cc2ba30c631f 100644 --- a/common/Makefile +++ b/common/Makefile @@ -89,6 +89,8 @@ obj-y += malloc_simple.o endif endif +obj-$(CONFIG_$(SPL_TPL_)EVENT) += event.o + obj-$(CONFIG_$(SPL_TPL_)HASH) += hash.o obj-$(CONFIG_IO_TRACE) += iotrace.o obj-y += memsize.o diff --git a/common/board_f.c b/common/board_f.c index a68760092ac1..e36bdbc988fa 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -828,6 +829,7 @@ static const init_fnc_t init_sequence_f[] = { initf_malloc, log_init, initf_bootstage, /* uses its own timer, so does not need DM */ + event_init, #ifdef CONFIG_BLOBLIST bloblist_init, #endif diff --git a/common/event.c b/common/event.c new file mode 100644 index 000000000000..428628da44d6 --- /dev/null +++ b/common/event.c @@ -0,0 +1,103 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Events provide a general-purpose way to react to / subscribe to changes + * within U-Boot + * + * Copyright 2021 Google LLC + * Written by Simon Glass + */ + +#define LOG_CATEGORY LOGC_EVENT + +#include +#include +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +static void spy_free(struct event_spy *spy) +{ + list_del(&spy->sibling_node); +} + +int event_register(const char *id, enum event_t type, event_handler_t func, void *ctx) +{ + struct event_state *state = gd->event_state; + struct event_spy *spy; + + spy = malloc(sizeof(*spy)); + if (!spy) + return log_msg_ret("alloc", -ENOMEM); + + spy->id = id; + spy->type = type; + spy->func = func; + spy->ctx = ctx; + list_add_tail(&spy->sibling_node, &state->spy_head); + + return 0; +} + +int event_notify(enum event_t type, void *data, int size) +{ + struct event_state *state = gd->event_state; + struct event_spy *spy, *next; + struct event event; + + event.type = type; + if (size > sizeof(event.data)) + return log_msg_ret("size", -E2BIG); + memcpy(&event.data, data, size); + list_for_each_entry_safe(spy, next, &state->spy_head, sibling_node) { + if (spy->type == type) { + int ret; + + log_debug("Sending event %x to spy '%s'\n", type, + spy->id); + ret = spy->func(spy->ctx, &event); + + /* + * TODO: Handle various return codes to + * + * - claim an event (no others will see it) + * - return an error from the event + */ + if (ret) + return log_msg_ret("spy", ret); + } + } + + return 0; +} + +int event_uninit(void) +{ + struct event_state *state = gd->event_state; + struct event_spy *spy, *next; + + if (!state) + return 0; + list_for_each_entry_safe(spy, next, &state->spy_head, sibling_node) + spy_free(spy); + + return 0; +} + +int event_init(void) +{ + struct event_state *state; + + state = malloc(sizeof(struct event_state)); + if (!state) + return log_msg_ret("alloc", -ENOMEM); + + INIT_LIST_HEAD(&state->spy_head); + + gd->event_state = state; + + return 0; +} diff --git a/common/log.c b/common/log.c index f7e0c0fbf556..7254aa70bfdf 100644 --- a/common/log.c +++ b/common/log.c @@ -28,6 +28,7 @@ static const char *const log_cat_name[] = { "devres", "acpi", "boot", + "event", }; _Static_assert(ARRAY_SIZE(log_cat_name) == LOGC_COUNT - LOGC_NONE, diff --git a/drivers/core/device-remove.c b/drivers/core/device-remove.c index e6ec6ff42121..c3f8ed3e5721 100644 --- a/drivers/core/device-remove.c +++ b/drivers/core/device-remove.c @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -207,6 +208,10 @@ int device_remove(struct udevice *dev, uint flags) if (!(dev_get_flags(dev) & DM_FLAG_ACTIVATED)) return 0; + ret = device_notify(dev, EVT_DM_PRE_REMOVE); + if (ret) + return ret; + /* * If the child returns EKEYREJECTED, continue. It just means that it * didn't match the flags. @@ -256,6 +261,10 @@ int device_remove(struct udevice *dev, uint flags) dev_bic_flags(dev, DM_FLAG_ACTIVATED); + ret = device_notify(dev, EVT_DM_POST_REMOVE); + if (ret) + goto err_remove; + return 0; err_remove: diff --git a/drivers/core/device.c b/drivers/core/device.c index 901c1e2f7db3..6f69b234a182 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -493,6 +494,10 @@ int device_probe(struct udevice *dev) if (dev_get_flags(dev) & DM_FLAG_ACTIVATED) return 0; + ret = device_notify(dev, EVT_DM_PRE_PROBE); + if (ret) + return ret; + drv = dev->driver; assert(drv); @@ -597,6 +602,10 @@ int device_probe(struct udevice *dev) dev->name, ret, errno_str(ret)); } + ret = device_notify(dev, EVT_DM_POST_PROBE); + if (ret) + goto fail; + return 0; fail_uclass: if (device_remove(dev, DM_REMOVE_NORMAL)) { diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index c2f8fad1cb92..a65a85de3ea5 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -467,6 +467,12 @@ struct global_data { */ char *smbios_version; #endif +#if CONFIG_IS_ENABLED(EVENT) + /** + * @event_state: List of event notifications + */ + struct event_state *event_state; +#endif }; #ifndef DO_DEPS_ONLY static_assert(sizeof(struct global_data) == GD_SIZE); diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h index 02002acb787c..c33bbf3b29b9 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) +{ +#if CONFIG_IS_ENABLED(EVENT) + return event_notify(type, &dev, sizeof(dev)); +#else + return 0; +#endif +} #endif diff --git a/include/event.h b/include/event.h new file mode 100644 index 000000000000..e2b74e6e62f0 --- /dev/null +++ b/include/event.h @@ -0,0 +1,105 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Events provide a general-purpose way to react to / subscribe to changes + * within U-Boot + * + * Copyright 2021 Google LLC + * Written by Simon Glass + */ + +#ifndef __event_h +#define __event_h + +/** + * enum event_t - Types of events supported by U-Boot + * + * @EVT_DM_PRE_PROBE: Device is about to be probed + */ +enum event_t { + EVT_NONE, + EVT_TEST, + + /* Events related to driver model */ + EVT_DM_PRE_PROBE, + EVT_DM_POST_PROBE, + EVT_DM_PRE_REMOVE, + EVT_DM_POST_REMOVE, + + EVT_COUNT +}; + +union event_data { + /** + * struct event_data_test - test data + * + * @signal: A value to update the state with + */ + struct event_data_test { + int signal; + } test; + + /** + * struct event_dm - driver model event + * + * @dev: Device this event relates to + */ + struct event_dm { + struct udevice *dev; + } dm; +}; + +/** + * struct event - an event that can be sent and received + * + * @type: Event type + * @data: Data for this particular event + */ +struct event { + enum event_t type; + union event_data data; +}; + +/** Function type for event handlers */ +typedef int (*event_handler_t)(void *ctx, struct event *event); + +/** + * event_register - register a new spy + * + * @id: Spy ID + * @type: Event type to subscribe to + * @func: Function to call when the event is sent + * @ctx: Context to pass to the function + * @return 0 if OK, -ve on erropr + */ +int event_register(const char *id, enum event_t type, event_handler_t func, + void *ctx); + +/** + * event_notify() - notify spies about an event + * + * It is possible to pass in union event_data here but that may not be + * convenient if the data is elsewhere, or is one of the members of the union. + * So this uses a void * for @data, with a separate @size. + * + * @type: Event type + * @data: Event data to be sent (e.g. union_event_data) + * @size: Size of data in bytes + */ +int event_notify(enum event_t type, void *data, int size); + +#if CONFIG_IS_ENABLED(EVENT) +int event_uninit(void); +int event_init(void); +#else +static inline int event_uninit(void) +{ + return 0; +} + +static inline int event_init(void) +{ + return 0; +} +#endif + +#endif diff --git a/include/event_internal.h b/include/event_internal.h new file mode 100644 index 000000000000..19308453f7b2 --- /dev/null +++ b/include/event_internal.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Internal definitions for events + * + * Copyright 2021 Google LLC + * Written by Simon Glass + */ + +#ifndef __event_internal_h +#define __event_internal_h + +#include + +/** + * struct event_spy - a spy that watches for an event of a particular type + * + * @id: Spy ID + * @type: Event type to subscribe to + * @func: Function to call when the event is sent + * @ctx: Context to pass to the function + */ +struct event_spy { + struct list_head sibling_node; + const char *id; + enum event_t type; + event_handler_t func; + void *ctx; +}; + +struct event_state { + struct list_head spy_head; +}; + +#endif diff --git a/include/log.h b/include/log.h index ce48d51446f5..8f35c10abb5e 100644 --- a/include/log.h +++ b/include/log.h @@ -98,6 +98,8 @@ enum log_category_t { LOGC_ACPI, /** @LOGC_BOOT: Related to boot process / boot image processing */ LOGC_BOOT, + /** @LOGC_EVENT: Related to event and event handling */ + LOGC_EVENT, /** @LOGC_COUNT: Number of log categories */ LOGC_COUNT, /** @LOGC_END: Sentinel value for lists of log categories */ diff --git a/test/common/Makefile b/test/common/Makefile index 24c9145dccc8..9087788ba6a8 100644 --- a/test/common/Makefile +++ b/test/common/Makefile @@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0+ obj-y += cmd_ut_common.o obj-$(CONFIG_AUTOBOOT) += test_autoboot.o +obj-$(CONFIG_EVENT) += event.o diff --git a/test/common/event.c b/test/common/event.c new file mode 100644 index 000000000000..ddce7400f269 --- /dev/null +++ b/test/common/event.c @@ -0,0 +1,87 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Unit tests for event handling + * + * Copyright 2021 Google LLC + * Written by Simon Glass + */ + +#include +#include +#include +#include +#include +#include + +struct test_state { + struct udevice *dev; + int val; +}; + +static int h_adder(void *ctx, struct event *event) +{ + struct event_data_test *data = &event->data.test; + struct test_state *test_state = ctx; + + test_state->val += data->signal; + + return 0; +} + +static int test_event_base(struct unit_test_state *uts) +{ + struct test_state state; + int signal; + + state.val = 12; + ut_assertok(event_register("wibble", EVT_TEST, h_adder, &state)); + + signal = 17; + + /* Check that the handler is called */ + ut_assertok(event_notify(EVT_TEST, &signal, sizeof(signal))); + ut_asserteq(12 + 17, state.val); + + return 0; +} + +COMMON_TEST(test_event_base, 0); + +static int h_probe(void *ctx, struct event *event) +{ + struct test_state *test_state = ctx; + + test_state->dev = event->data.dm.dev; + switch (event->type) { + case EVT_DM_PRE_PROBE: + test_state->val |= 1; + break; + case EVT_DM_POST_PROBE: + test_state->val |= 2; + break; + default: + break; + } + + return 0; +} + +static int test_event_probe(struct unit_test_state *uts) +{ + struct test_state state; + struct udevice *dev; + + state.val = 0; + ut_assertok(event_register("pre", EVT_DM_PRE_PROBE, h_probe, &state)); + ut_assertok(event_register("post", EVT_DM_POST_PROBE, h_probe, &state)); + + /* Probe a device */ + ut_assertok(uclass_first_device_err(UCLASS_TEST_FDT, &dev)); + + /* Check that the handler is called */ + ut_asserteq(3, state.val); + + return 0; +} + +COMMON_TEST(test_event_probe, UT_TESTF_DM | UT_TESTF_SCAN_FDT); diff --git a/test/test-main.c b/test/test-main.c index 8fcb02ecea5c..dedfd0f81dae 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,11 @@ static int dm_test_restore(struct device_node *of_root) */ static int test_pre_run(struct unit_test_state *uts, struct unit_test *test) { +#if CONFIG_IS_ENABLED(EVENT) + gd->event_state = NULL; +#endif + ut_assertok(event_init()); + if (test->flags & UT_TESTF_DM) ut_assertok(dm_test_pre_run(uts)); @@ -260,6 +266,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 Thu Feb 10 08:11:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 541403 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp2039181imo; Thu, 10 Feb 2022 00:14:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJx1ADBny9+EAhpqdtAXKplKul+Y/YnDYG9KD31BCQUbGzzQI+bL0cKnKcRUldfprDloeIgE X-Received: by 2002:a17:907:7893:: with SMTP id ku19mr5443760ejc.123.1644480843457; Thu, 10 Feb 2022 00:14:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644480843; cv=none; d=google.com; s=arc-20160816; b=QRHCeXlT4kn4aDGD777Q2BKvJV/DidnXVuwkTnRKavMAXXD7Ut0XMk14lzkd0JHRzH h7yFubot6ynUEqvKLqYlPR33qHSo4ciMFoRbLC/FZzraJ5vqxtvwLHDIF5VcrJDd2zFP inOGHjGFjSgoo1RZnHbIXWl5tHm+euqINuquzLv1f6GKKJQ3FE6oqTp9KJzuTvNWS9ka EbLjLzptcn4w7ypZMl9olRxcTF1ykcAo41RnyTY+QT/b8XCEv7RQg8Hq76jMUZ4QTYBF Wzc/yk3rENo0VZJGE8ObkSOSdUDgICTwleGJSnqhxN8K3mR6B+2qhonPpHXz0qQb0WPW LIIg== 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=Ed324GI0Fxh0APyF3wumOLriKtxc5X39bdt6OXRYu1s=; b=QXVWVaYCAGp+6BWCqXpyF4OOT4el2oJ7rYeLoYR8igy2wh3AWqLLgLvO4MZHFXO5WJ H9Zlb2OAzA1WLX3VzYjOtmMribjsEQxq+SnXrMLDAHuyMcULcQbm73WYidKdczJgp9NG RySElRPIxYSywDqEpeud+JZeJih920W6mPgo0/KwMEn50EtrT9+ik4wQ0c0RHREyGTaz rEnofNXlbDhlxbGodfwfHD7ikKNL4PeBBgbk+EZUBmC94Zlr4CgGUMF3/ixNKq/hRKIK IOUjbqjwz4H/8vFP8u4zIax1xQnazmFTctUDduRLc8KiW7O60LJVS4B5dZ6H7KN7nL+Y 8FMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Vptp4V+T; 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 ej17si3988098edb.172.2022.02.10.00.14.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:14:03 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Vptp4V+T; 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 88B7C8366B; Thu, 10 Feb 2022 09:13: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=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="Vptp4V+T"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8FCCD82F65; Thu, 10 Feb 2022 09:13:09 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) (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 426A5836A3 for ; Thu, 10 Feb 2022 09:12: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-x1031.google.com with SMTP id qe15so4477678pjb.3 for ; Thu, 10 Feb 2022 00:12: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=Ed324GI0Fxh0APyF3wumOLriKtxc5X39bdt6OXRYu1s=; b=Vptp4V+T1qZbVTgNEy8LbW1AIyaPfaMHQG5RzAF/BoWnuTlyvcXo22GolnLo9ocV6N 6S94QdZd8WuDrqnkUPCz8tuAVA2wwwSAOtNqjX+IPzE4OuSXLg6a1Q6qKaa1toabuXXm tCnqjSPzOBXeYpV0sewHW36Le0+kIvZKNw57KWf1oFe8oRCi+ghpl5FjlzutLTsuw/92 2nK2/u4JY+E6ZCPzq/XFtwfpHS/TW0TPnXoLAHfQ2I4dbjlwkAV8GQWtMWksRfOYR8FT xpgj4GLsUAZb+ccsXZsZ6ZvgZ25RMR94qxy4fiDBOSoS315DGf3qTB3iFzrgRzdnKVPX XjxA== 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=Ed324GI0Fxh0APyF3wumOLriKtxc5X39bdt6OXRYu1s=; b=Kdp0zhBJ/frlDp8OaiZu4esLxDrvxgvZfcZb5ODT2ajECs4oQFoBNNIjf2J9FGIBRC IvVg+zbXwg+6BK/HJK1sabN+qtgmkW+gpPFquRh9Y9VxcIAjn58ty+genMuUNdL055zi yim2a47o6XeL5vfV/QQKZusIH1/p1ROgfDkLReaInfxg4XEe+F4XpLkKMGu7CLQg8t1O 6+sRL2TPfHEvYhfhZ7l1AvfzFxRYZY2DRUgrB/iMRKsk0NEM0bbfn8AFwtQYpsBdApJv RIPR5NeBDZrA7Kw/oRUdEwjaDvtDGq0bPZ9y/pQk6QTzvcl79pirEJ9fulIwGZivZV/U Uzbw== X-Gm-Message-State: AOAM530a5ilF4hY+pjq8QR9QbDIYaC7TMkvggGV4Iq18XCET7v7y/0ng C4jTJR9VuAqnjfMpMNnVZGEyf9etF91kEg== X-Received: by 2002:a17:902:e5c2:: with SMTP id u2mr6648436plf.144.1644480764585; Thu, 10 Feb 2022 00:12:44 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:412e:384:fab9:f24]) by smtp.gmail.com with ESMTPSA id lk8sm1529208pjb.40.2022.02.10.00.12.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:12:44 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v2 09/20] dm: add tag support Date: Thu, 10 Feb 2022 17:11:13 +0900 Message-Id: <20220210081124.86612-10-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220210081124.86612-1-takahiro.akashi@linaro.org> References: <20220210081124.86612-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean With dm-tag feature, any U-Boot subsystem is allowed to associate arbitrary number of data with a particular udevice. This can been see as expanding "struct udevice" without modifying the definition. As a first user, UEFI subsystem makes use of tags to associate an efi_disk object with a block device. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- drivers/core/Makefile | 2 +- drivers/core/root.c | 2 + drivers/core/tag.c | 139 ++++++++++++++++++++++++++++++ include/asm-generic/global_data.h | 4 + include/dm/tag.h | 110 +++++++++++++++++++++++ 5 files changed, 256 insertions(+), 1 deletion(-) create mode 100644 drivers/core/tag.c create mode 100644 include/dm/tag.h diff --git a/drivers/core/Makefile b/drivers/core/Makefile index 5edd4e413576..3742e7574525 100644 --- a/drivers/core/Makefile +++ b/drivers/core/Makefile @@ -2,7 +2,7 @@ # # Copyright (c) 2013 Google, Inc -obj-y += device.o fdtaddr.o lists.o root.o uclass.o util.o +obj-y += device.o fdtaddr.o lists.o root.o uclass.o util.o tag.o obj-$(CONFIG_$(SPL_TPL_)ACPIGEN) += acpi.o obj-$(CONFIG_DEVRES) += devres.o obj-$(CONFIG_$(SPL_)DM_DEVICE_REMOVE) += device-remove.o diff --git a/drivers/core/root.c b/drivers/core/root.c index e3f87956d866..1aa4819ceb6c 100644 --- a/drivers/core/root.c +++ b/drivers/core/root.c @@ -199,6 +199,8 @@ int dm_init(bool of_live) return ret; } + INIT_LIST_HEAD((struct list_head *)&gd->dmtag_list); + return 0; } diff --git a/drivers/core/tag.c b/drivers/core/tag.c new file mode 100644 index 000000000000..6829bcd8806c --- /dev/null +++ b/drivers/core/tag.c @@ -0,0 +1,139 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2021 Linaro Limited + * Author: AKASHI Takahiro + */ + +#include +#include +#include +#include +#include +#include + +struct udevice; + +DECLARE_GLOBAL_DATA_PTR; + +int dev_tag_set_ptr(struct udevice *dev, enum dm_tag_t tag, void *ptr) +{ + struct dmtag_node *node; + + if (!dev || tag >= DM_TAG_COUNT) + return -EINVAL; + + list_for_each_entry(node, &gd->dmtag_list, sibling) { + if (node->dev == dev && node->tag == tag) + return -EEXIST; + } + + node = calloc(sizeof(*node), 1); + if (!node) + return -ENOSPC; + + node->dev = dev; + node->tag = tag; + node->ptr = ptr; + list_add_tail(&node->sibling, (struct list_head *)&gd->dmtag_list); + + return 0; +} + +int dev_tag_set_val(struct udevice *dev, enum dm_tag_t tag, ulong val) +{ + struct dmtag_node *node; + + if (!dev || tag >= DM_TAG_COUNT) + return -EINVAL; + + list_for_each_entry(node, &gd->dmtag_list, sibling) { + if (node->dev == dev && node->tag == tag) + return -EEXIST; + } + + node = calloc(sizeof(*node), 1); + if (!node) + return -ENOSPC; + + node->dev = dev; + node->tag = tag; + node->val = val; + list_add_tail(&node->sibling, (struct list_head *)&gd->dmtag_list); + + return 0; +} + +int dev_tag_get_ptr(struct udevice *dev, enum dm_tag_t tag, void **ptrp) +{ + struct dmtag_node *node; + + if (!dev || tag >= DM_TAG_COUNT) + return -EINVAL; + + list_for_each_entry(node, &gd->dmtag_list, sibling) { + if (node->dev == dev && node->tag == tag) { + *ptrp = node->ptr; + return 0; + } + } + + return -ENOENT; +} + +int dev_tag_get_val(struct udevice *dev, enum dm_tag_t tag, ulong *valp) +{ + struct dmtag_node *node; + + if (!dev || tag >= DM_TAG_COUNT) + return -EINVAL; + + list_for_each_entry(node, &gd->dmtag_list, sibling) { + if (node->dev == dev && node->tag == tag) { + *valp = node->val; + return 0; + } + } + + return -ENOENT; +} + +int dev_tag_del(struct udevice *dev, enum dm_tag_t tag) +{ + struct dmtag_node *node, *tmp; + + if (!dev || tag >= DM_TAG_COUNT) + return -EINVAL; + + list_for_each_entry_safe(node, tmp, &gd->dmtag_list, sibling) { + if (node->dev == dev && node->tag == tag) { + list_del(&node->sibling); + free(node); + + return 0; + } + } + + return -ENOENT; +} + +int dev_tag_del_all(struct udevice *dev) +{ + struct dmtag_node *node, *tmp; + bool found = false; + + if (!dev) + return -EINVAL; + + list_for_each_entry_safe(node, tmp, &gd->dmtag_list, sibling) { + if (node->dev == dev) { + list_del(&node->sibling); + free(node); + found = true; + } + } + + if (found) + return 0; + + return -ENOENT; +} diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index a65a85de3ea5..5b599a274847 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -473,6 +473,10 @@ struct global_data { */ struct event_state *event_state; #endif + /** + * @dmtag_list: List of DM tags + */ + struct list_head dmtag_list; }; #ifndef DO_DEPS_ONLY static_assert(sizeof(struct global_data) == GD_SIZE); diff --git a/include/dm/tag.h b/include/dm/tag.h new file mode 100644 index 000000000000..54fc31eb1539 --- /dev/null +++ b/include/dm/tag.h @@ -0,0 +1,110 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (c) 2021 Linaro Limited + * Author: AKASHI Takahiro + */ + +#ifndef _DM_TAG_H +#define _DM_TAG_H + +#include +#include + +struct udevice; + +enum dm_tag_t { + /* EFI_LOADER */ + DM_TAG_EFI = 0, + + DM_TAG_COUNT, +}; + +/** + * dmtag_node + * + * @sibling: List of dm-tag nodes + * @dev: Associated udevice + * @tag: Tag type + * @ptr: Pointer as a value + * @val: Value + */ +struct dmtag_node { + struct list_head sibling; + struct udevice *dev; + enum dm_tag_t tag; + union { + void *ptr; + ulong val; + }; +}; + +/** + * dev_tag_set_ptr() - set a tag's value as a pointer + * @dev: Device to operate + * @tag: Tag type + * @ptr: Pointer to set + * + * Set the value, @ptr, as of @tag associated with the device, @dev + * + * Return: 0 on success, -ve on error + */ +int dev_tag_set_ptr(struct udevice *dev, enum dm_tag_t tag, void *ptr); + +/** + * dev_tag_set_val() set a tag's value as an integer + * @dev: Device to operate + * @tag: Tag type + * @val: Value to set + * + * Set the value, @val, as of @tag associated with the device, @dev + * + * Return: on success, -ve on error + */ +int dev_tag_set_val(struct udevice *dev, enum dm_tag_t tag, ulong val); + +/** + * dev_tag_get_ptr() - get a tag's value as a pointer + * @dev: Device to operate + * @tag: Tag type + * @ptrp: Pointer to tag's value (pointer) + * + * Get a tag's value as a pointer + * + * Return: on success, -ve on error + */ +int dev_tag_get_ptr(struct udevice *dev, enum dm_tag_t tag, void **ptrp); + +/** + * dev_tag_get_val() - get a tag's value as an integer + * @dev: Device to operate + * @tag: Tag type + * @valp: Pointer to tag's value (ulong) + * + * Get a tag's value as an integer + * + * Return: 0 on success, -ve on error + */ +int dev_tag_get_val(struct udevice *dev, enum dm_tag_t tag, ulong *valp); + +/** + * dev_tag_del() - delete a tag + * @dev: Device to operate + * @tag: Tag type + * + * Delete a tag of @tag associated with the device, @dev + * + * Return: 0 on success, -ve on error + */ +int dev_tag_del(struct udevice *dev, enum dm_tag_t tag); + +/** + * dev_tag_del_all() - delete all tags + * @dev: Device to operate + * + * Delete all the tags associated with the device, @dev + * + * Return: 0 on success, -ve on error + */ +int dev_tag_del_all(struct udevice *dev); + +#endif /* _DM_TAG_H */ From patchwork Thu Feb 10 08:11:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 541404 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp2039291imo; Thu, 10 Feb 2022 00:14:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJwyRzhjyvQK6Rc8wYHWaKnEtn198hOmrWFd3tsHpdzUexY+96/Tz6iKusaiylM+Hm34vAXk X-Received: by 2002:a17:907:3d94:: with SMTP id he20mr5471769ejc.637.1644480855278; Thu, 10 Feb 2022 00:14:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644480855; cv=none; d=google.com; s=arc-20160816; b=KSbezZ2On0VpFGF6qeo9xPUtjL/3zO6RRBU8xFWfncNL67rU3weHgdRsUsUiRDTkRo z/5WlgAlI2MYMpPiqqJbAt7sv5OWGWBvmfkXnNhAVh25OQa5sIb4N3ehOSxcNmdNrF5P EQRAOu32F8i8zrOlyI1MBacSmGCY5Fad99q0S3KvVkWzbMqhmeNNZ4mIHGbeg1qg8IF4 h/hnr2xUP+TqBCkjWuc3xLbWaqYlxB47RDejiEDl7T7420ZpKgjIBgtkbCVerpjv0xit aCU+NJzGmaL0jK1EKcb/iSqQF2D/wSBdOJ3H54xR6clUUAEOcQDJbgBbgUh6eVuPRoMz fZWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ejw1is40U/7Wle0HW1PbG5bf3qWO0fEgyim5vk1bu2U=; b=0xafe07lfKi9rmxlSQMLSc4aRG2dfFjcUSAkQS8fTY4K69iP9CXcqVfiVTI5Ght0cy MsAN8cvKQZzv4WQHMV9UhxRSMnz95ZgnUT/Tsoa96Zrbpzgz701/URcXQDH42glc4DcP dw46BzKXwvTorkdod0yqWvo0yY4lz25NUb+JiFJmHSAfe9jG8Z91RYd2wcTH7ngFpGU3 m3yp+C4+J3EXtiMl6QJyZj9Yxa3Az/tLogjxemChe0TWUIUIDcB+/KRzBSlUvc8sl6qB EPZz9k+s5Jw3Xrisq8Mym+imhQmIjqqydb2Gx1I/nWBz5mVlUpOKqpS7XLIit3YeGN0x iyVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZCbku4qh; 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 b9si3854386ede.136.2022.02.10.00.14.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:14:15 -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=ZCbku4qh; 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 A42768321B; Thu, 10 Feb 2022 09:13: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="ZCbku4qh"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B96F883836; Thu, 10 Feb 2022 09:13:16 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0A35C8366F for ; Thu, 10 Feb 2022 09:12: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=takahiro.akashi@linaro.org Received: by mail-pl1-x635.google.com with SMTP id 10so1200862plj.1 for ; Thu, 10 Feb 2022 00:12:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ejw1is40U/7Wle0HW1PbG5bf3qWO0fEgyim5vk1bu2U=; b=ZCbku4qhtNLte97dUEeWbjzyKHU/41WuwdkkqqgULiUJIHH71Jz8n0VasNpQLzICJ4 cfOMSm9EEQHNHZ+6/KpTEqvlja69UEIhgJYBup0Rc0Q9BbD8pl2CqU2NCaq5k24svAT9 ajJSGypOvAEmhsGPaa1EEouXFiGzaMlg/tMUI5dpov3Q4aiU+bB+TlalMnlWx+vkW7pj 76kPDHscZC6hcxS9SLZPgMnHIPlNxzW8IOUKpxsNgDYDz11lIvaGhZHz2fa4HSfQnSpY cWA0ZTbR1uwyMYsO1t1ldjD8UAjRoty8QInVNJANxZjIwbx/6equJpezaCeG+i1a2bdu sAcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ejw1is40U/7Wle0HW1PbG5bf3qWO0fEgyim5vk1bu2U=; b=2h0cVXn7Le+QtTVec5OO7MlQ+wIZQo9WwDa/F3kAcbIy3cWWpB004w9vrXn6IWBKRW mFZc8JSlGhSPO+Gf6YNXsD0agTQ08ihkEcDWiwhYv1pRGsM4LFNZlRgFdJow5U541Rdu y7kiam99L+LEMeKlkeVsJ7fLbKxiE64vHIrsxR+4a6oBayxuKrQt1LvjJTboD8riBIKC 7MbvM5sZGUKeWGhaxosnp9pUSuaNlVyCk2gQ2SPHa8l7f2jZQ+sWM8ykOvcjC/30NjXi aDSN5sqjr22b68rN3uV6Ij7dhlMywAGpcUC5lf658TO59fpnmsZUggK1mLEwMHROc2CK KBoA== X-Gm-Message-State: AOAM5315ZzacR6Q53Ghk1poGVxD2UBg/LBttafRqJVcrdkza7DUMGzoj k2J4XKY2Rhaw2j35gC/ZDRDlHutGpfZzMw== X-Received: by 2002:a17:90b:1e0e:: with SMTP id pg14mr1598553pjb.4.1644480768212; Thu, 10 Feb 2022 00:12:48 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:412e:384:fab9:f24]) by smtp.gmail.com with ESMTPSA id lk8sm1529208pjb.40.2022.02.10.00.12.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:12:47 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v2 10/20] dm: tag: add some document Date: Thu, 10 Feb 2022 17:11:14 +0900 Message-Id: <20220210081124.86612-11-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220210081124.86612-1-takahiro.akashi@linaro.org> References: <20220210081124.86612-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Some basic stuff about tag support is explained under doc/devlop/driver-model. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- doc/develop/driver-model/design.rst | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/doc/develop/driver-model/design.rst b/doc/develop/driver-model/design.rst index b0e6337030a1..3e88dc40e6fd 100644 --- a/doc/develop/driver-model/design.rst +++ b/doc/develop/driver-model/design.rst @@ -1042,6 +1042,26 @@ data structure might be worthwhile in some rare cases, once we understand what the bottlenecks are. +Tag Support +----------- + +It is sometimes useful for a subsystem to associate its own private +data (or object) to a DM device, i.e. struct udevice, to support +additional features. + +Tag support in driver model will give us the ability to do so dynamically +instead of modifying "udevice" data structure. In the initial release, we +will support two type of attributes: +- a pointer with dm_tag_set_ptr(), and +- an unsigned long with dm_tag_set_val() + +For example, UEFI subsystem utilizes the feature to maintain efi_disk +objects depending on linked udevice's lifecycle. + +While the current implementation is quite simple, it will get evolved +as the feature is more extensively used in U-Boot subsystems. + + Changes since v1 ---------------- From patchwork Thu Feb 10 08:11:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 541405 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp2039378imo; Thu, 10 Feb 2022 00:14:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJyY/bxIusPSAJMt/zS4I0z2E6OHf7ZAWF68eAubemyVqCheufgRv7OVe4F5Xn5L6XuES/cr X-Received: by 2002:aa7:dc44:: with SMTP id g4mr7066121edu.438.1644480865259; Thu, 10 Feb 2022 00:14:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644480865; cv=none; d=google.com; s=arc-20160816; b=J8gPYcvsrYMRYgQB3Mv2uQLJ+exyEnGkNxMdCxknBLLNmLkCiJXTKSTCL70dPtn69W oqxTY76yP0LIAktd9aYdGxn9PfJWfjK8V6dwm3oiir9CTbFIRkEOOPeNNI2Xl5i0grhn 16eNd29zUaaggooTWiPWzcPW9PH2rerrEzfqwJQ7fgAs/e2k4o1Pau+6qWo80L+pAI98 3CGsU6A0u/wS/+6nnYb4hY39yqjGBLs7H3tVh/VsapTAef2w2oV7FltIkvIFDy/jLuSP atLPWDfUbOhMjJO7aIaQG4UIXWENV16mXNKqh985KY20g3qqNdGGErJUc4t3ayF1pEy6 Zsgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=j3rJkD9O8Gq+NKRNVXk0fZH0z+fLRoy2YIwtxpZ2jIo=; b=iPMVRNQ88+ONhXeffeB6SRldipfGH568d5vMJa2zIa2Wc58hFI2qJ4z8hcHBeAKU0M 4MjFP2sXlIczBqKx9UWpGRyAbdYt0UoPF+uAdmOf87Kvef8k5aMtQdq1QG/a5RdxiM7j uLiBbhg1+T+/O0WikN04FJu8M6m+FVziGnAc8M/CkkBe7XtJHC25LXXWHnCsOVvlSvwJ PkQVvCKZw+sNWLAsVSbHczzxQLol+C5Mq5omTvfANn7BDpUtBjMdNzTY6R1yEFOrXbHV wlukeVA5ICk4lAGPZBtP4Z6rw71pWUL4Jnj0+iWxEaw+fMxkp9HtXjuaa8iimW8LPscI QLhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uDaOsu7q; 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 sb42si5556384ejc.748.2022.02.10.00.14.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:14:25 -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=uDaOsu7q; 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 A4ACD8390C; Thu, 10 Feb 2022 09:13:26 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="uDaOsu7q"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B4C19838C3; Thu, 10 Feb 2022 09:13: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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) (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 85BBF837B6 for ; Thu, 10 Feb 2022 09:12: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=takahiro.akashi@linaro.org Received: by mail-pl1-x629.google.com with SMTP id j4so1184435plj.8 for ; Thu, 10 Feb 2022 00:12:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=j3rJkD9O8Gq+NKRNVXk0fZH0z+fLRoy2YIwtxpZ2jIo=; b=uDaOsu7qdgH5+OrUlJgrYxRKG3D4MLcXmUOmxLQQDSCdjXjBH8Jk9lXzuC3BSTPwv2 RIWB08a5EW5EMXhk2IfwoXYvCVTIxUZGIeL9P2Fas+j0ttDfNP/t0mi8Bm3TZeCgEYb5 QFcgMiTxXeNbbz47GQ6IIXlvsifNrOc9VWvYILCwb9QLEvZsz9PNEnuWI6TnxWXDol3n tleqOjZ+yeXjPC8vjoHBwp116b+//CjHHe8L//hg0QLum+aBoT611u4OmH28f0UUWeXr HKXKnwsmlLrYopCKsoqGAaxHBCQUuUDz2uOORAkAUUZhBGW0KTJGssknLRr+23WOmphq 9VkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=j3rJkD9O8Gq+NKRNVXk0fZH0z+fLRoy2YIwtxpZ2jIo=; b=ks+/+0Y6etJhb3BtmhgkaiUFhpI2Da4f+7af0Llt7OsFbupUM9K28FdfTkXw+nk82G qmBq7MrNFhT6ANzQv6+JxOAcIwCPQHberTK2eVX3fHMSNbnVY+219DiWJZFdKracD4j0 EgmqQDNIc0ucfS5C3eG+IvE4inOeeGdNYd289gtjMus86OiV99yTeXJlsgPHszToYxIW YK0C0LDCQQyUVBAuxjUDKWQuaJwUovMCj+ND2JkW/UlK5im+e3WouD1ZwuX7rykkK1Iu nJvEfU7ngMFtcUnmtfiuBo06colaZrfENh8Ys8Or/7PKHNMOhfTzzvKKsT8v/+Dw5UIv 0jGw== X-Gm-Message-State: AOAM5306gA1LT+TzvPfaGafqyn/wtOE2eivRByhm0eprjvd/LZo6GZeD powKyB1uDYQ5wG6qJaaH2BOIpQ== X-Received: by 2002:a17:902:b941:: with SMTP id h1mr6516525pls.73.1644480771907; Thu, 10 Feb 2022 00:12:51 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:412e:384:fab9:f24]) by smtp.gmail.com with ESMTPSA id lk8sm1529208pjb.40.2022.02.10.00.12.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:12:51 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v2 11/20] test: dm: add tests for tag support Date: Thu, 10 Feb 2022 17:11:15 +0900 Message-Id: <20220210081124.86612-12-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220210081124.86612-1-takahiro.akashi@linaro.org> References: <20220210081124.86612-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean The new test covers all tag-related interfaces. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- test/dm/Makefile | 1 + test/dm/tag.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 test/dm/tag.c diff --git a/test/dm/Makefile b/test/dm/Makefile index d46552fbf320..dc3177dbb7f4 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -102,6 +102,7 @@ obj-y += syscon.o obj-$(CONFIG_RESET_SYSCON) += syscon-reset.o obj-$(CONFIG_SYSINFO) += sysinfo.o obj-$(CONFIG_SYSINFO_GPIO) += sysinfo-gpio.o +obj-$(CONFIG_UT_DM) += tag.o obj-$(CONFIG_TEE) += tee.o obj-$(CONFIG_TIMER) += timer.o obj-$(CONFIG_DM_USB) += usb.o diff --git a/test/dm/tag.c b/test/dm/tag.c new file mode 100644 index 000000000000..8599fdc242d8 --- /dev/null +++ b/test/dm/tag.c @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * DM tag test + * + * Copyright (c) 2021 Linaro Limited + * Author: AKASHI Takahiro + */ + +#include +#include +#include /* DM_TEST() */ +#include /* struct unit_test_state */ +#include /* assertions */ + +/* + * Test dm_tag_ptr() API + */ +static int dm_test_tag_ptr(struct unit_test_state *uts) +{ + ulong val; + void *ptr = NULL; + + ut_assertok(dev_tag_set_ptr(uts->root, DM_TAG_EFI, &val)); + + ut_assertok(dev_tag_get_ptr(uts->root, DM_TAG_EFI, &ptr)); + + ut_asserteq_ptr(&val, ptr); + + ut_assertok(dev_tag_del(uts->root, DM_TAG_EFI)); + + return 0; +} +DM_TEST(dm_test_tag_ptr, 0); + +/* + * Test dm_tag_val() API + */ +static int dm_test_tag_val(struct unit_test_state *uts) +{ + ulong val1 = 0x12345678, val2 = 0; + + ut_assertok(dev_tag_set_val(uts->root, DM_TAG_EFI, val1)); + + ut_assertok(dev_tag_get_val(uts->root, DM_TAG_EFI, &val2)); + + ut_asserteq_64(val1, val2); + + ut_assertok(dev_tag_del(uts->root, DM_TAG_EFI)); + + return 0; +} +DM_TEST(dm_test_tag_val, 0); + +/* + * Test against an invalid tag + */ +static int dm_test_tag_inval(struct unit_test_state *uts) +{ + ulong val; + + ut_asserteq(-EINVAL, dev_tag_set_ptr(uts->root, DM_TAG_COUNT, &val)); + + return 0; +} +DM_TEST(dm_test_tag_inval, 0); + +/* + * Test dm_tag_del_all() AP: + */ +static int dm_test_tag_del_all(struct unit_test_state *uts) +{ + ulong val; + + ut_assertok(dev_tag_set_ptr(uts->root, DM_TAG_EFI, &val)); + + ut_assertok(dev_tag_del_all(uts->root)); + + return 0; +} +DM_TEST(dm_test_tag_del_all, 0); From patchwork Thu Feb 10 08:11:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 541406 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp2039502imo; Thu, 10 Feb 2022 00:14:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJxav9GcdHs2HIK1K+gNfdS/c4N3fN1cUoFoEyc8sVCSNojcLepElrUtVb0SO6TfxqKk/puj X-Received: by 2002:a17:906:dc91:: with SMTP id cs17mr5361942ejc.678.1644480875907; Thu, 10 Feb 2022 00:14:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644480875; cv=none; d=google.com; s=arc-20160816; b=tVNI19jhu4w8hwKN27c04NltSyf+s7Sk3IOI1GVxWoR9pQaV2tfT06Nh960LMh59WU bG0dLQqxhrrRJxUAuqpGCKbUBso0y+3j+Coyjl12uEuPgrbT6e4RzlZFwnFXfEBePdHz gdmTsTUZXioFCacMUEaY6Rx4qfC7Dpkb8EbSCEV85ZEtSc1IF28fdIO7xz6bTfjTLSX+ t+DOWaypmm1Kjbeft1wb4hwmeICOthUVYgQHybNkAzMMcIdzILc8wRnKB4UV8wedIKI8 PDmn+G23oqgUa04HgfAMeIf8xYk1rGN5Qw4UDpA1O3erJsclm2blGPylsOm4IU9T/vyo UTBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jOd231FtqlYhW0H9SCH9Peko72xgDMiZL/3jps6yxaU=; b=XCQlFt//VGjfOU9ohXTjJ4oxOOUAwy4XLXs9BglJYZH+FCV853PPV36MOWtpkLrxe6 Y0mfVciLFJqUGRfaOnqvGRPIcYiHaH7uNPfwsNTVroiBZJNBbbEAq2AY9RX31QcMMBE3 5BVNXvRz0Y+xWrMnFLjcWdy5z6/29EpPWTWMC8nmI3Y9RDVJPZzRAcd82Nz35xAO/hVW QP//4ZVO7vcxSvuIC4lJMWyMR2C1yVN66Fu3xZ1yBJhT/5AJQ7Kj5F/2o1qybdH1I5MF 1DcxAuniEQ0PWxFfjLzB5Ae8H1QjG6kk+viU7ccWOt0VCYvBcPEnp4my9dklrRnpCaim Y2RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JLvrL5BA; 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 f3si12457000ejj.22.2022.02.10.00.14.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:14:35 -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=JLvrL5BA; 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 9AC3483916; Thu, 10 Feb 2022 09:13:31 +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="JLvrL5BA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B9C0D83916; Thu, 10 Feb 2022 09:13:29 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 497E4835EA for ; Thu, 10 Feb 2022 09:12:57 +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 i186so9008066pfe.0 for ; Thu, 10 Feb 2022 00:12:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jOd231FtqlYhW0H9SCH9Peko72xgDMiZL/3jps6yxaU=; b=JLvrL5BAlkNvo71qdmTh80NmNsTG2OXqX4VHWEfVL5P8t9RqbB5EXPa20vtaLUChVA yaQy5hQH5Ki5zJjDl3y8YcKD00PBK85cQBPOQC/15Q6dqQlmrUqdNjLdWHRhbd0sueSD TSnIBdqFAHKR35S8uHz3/VkPotT1MJHqH0/uzh5XKP53hfSC4baKM0OoEhhEcBJgrqM4 AnN18hId3GMcKxcf3MOCeEujhm6QX8eh8jABvLNvYYE18HwqpC8oBhnQMzyP9IfuK63d i47w8ZKjRvRUc/6aMaPyV/SYWt9XdBIHY5Ut5DLnMNMYJTDzb6rJ0B+e28mfNnbhmhBS J4Eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jOd231FtqlYhW0H9SCH9Peko72xgDMiZL/3jps6yxaU=; b=A7HaqnOYe/dbEILkJZaKZ16hPkEQYXFtnrQpjHSLPb2FYh/HVx9hpIvPwKQwaaqVsf 0Sk2N/etMa77eKY/Vpyjn4no9n7KBD8cXN0RQ3iJFJTA+xAcrPkZTTIrN7Et47XyNcuJ mqGNwmCRQGPLZHz4ASbjaGJ6nejUuHMV1NvgIoOvBlft9gi0GogN5wQlhmZ3AZlXD1S+ gakOWVq87gFPLjeA7b/N1I4Ujxho3AmXH9QqG9RDS40o031s3GZiLbnWP+rmyfM2LuWA szpsI2t+XgztXkA3MyihiMFwbxyLzxYsBNhEYqbJLtxK5AtjIEYYUCu9hTinaXhDjcMv IKwA== X-Gm-Message-State: AOAM530ocYwwlmF0oHN2UN+FL8xZQgZF4E8Qb1PWJ3hNhTT9QvY8pz9n dNPDa897rgajwcROyFrIlbuOPg== X-Received: by 2002:a63:130f:: with SMTP id i15mr3330312pgl.562.1644480775567; Thu, 10 Feb 2022 00:12:55 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:412e:384:fab9:f24]) by smtp.gmail.com with ESMTPSA id lk8sm1529208pjb.40.2022.02.10.00.12.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:12:55 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v2 12/20] dm: disk: add UCLASS_PARTITION Date: Thu, 10 Feb 2022 17:11:16 +0900 Message-Id: <20220210081124.86612-13-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220210081124.86612-1-takahiro.akashi@linaro.org> References: <20220210081124.86612-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean With this new function, UCLASS_PARTITION devices will be created as child nodes of UCLASS_BLK device. Signed-off-by: AKASHI Takahiro --- disk/Makefile | 3 + disk/disk-uclass.c | 153 +++++++++++++++++++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + include/part.h | 11 +++ 4 files changed, 168 insertions(+) create mode 100644 disk/disk-uclass.c diff --git a/disk/Makefile b/disk/Makefile index 6ce5a687b36c..ec37b74f5f40 100644 --- a/disk/Makefile +++ b/disk/Makefile @@ -6,6 +6,9 @@ #ccflags-y += -DET_DEBUG -DDEBUG obj-$(CONFIG_PARTITIONS) += part.o +ifdef CONFIG_$(SPL_)BLK +obj-$(CONFIG_PARTITIONS) += disk-uclass.o +endif obj-$(CONFIG_$(SPL_)MAC_PARTITION) += part_mac.o obj-$(CONFIG_$(SPL_)DOS_PARTITION) += part_dos.o obj-$(CONFIG_$(SPL_)ISO_PARTITION) += part_iso.o diff --git a/disk/disk-uclass.c b/disk/disk-uclass.c new file mode 100644 index 000000000000..4918a2f72d1e --- /dev/null +++ b/disk/disk-uclass.c @@ -0,0 +1,153 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Software partition device (UCLASS_PARTITION) + * + * Copyright (c) 2021 Linaro Limited + * Author: AKASHI Takahiro + */ + +#define LOG_CATEGORY UCLASS_PARTITION + +#include +#include +#include +#include +#include +#include +#include + +int part_create_block_devices(struct udevice *blk_dev) +{ + int part, count; + struct blk_desc *desc = dev_get_uclass_plat(blk_dev); + struct disk_partition info; + struct disk_part *part_data; + char devname[32]; + struct udevice *dev; + int ret; + + if (!CONFIG_IS_ENABLED(PARTITIONS) || + !CONFIG_IS_ENABLED(HAVE_BLOCK_DEVICE)) + return 0; + + if (device_get_uclass_id(blk_dev) != UCLASS_BLK) + return 0; + + /* Add devices for each partition */ + for (count = 0, part = 1; part <= MAX_SEARCH_PARTITIONS; part++) { + if (part_get_info(desc, part, &info)) + continue; + snprintf(devname, sizeof(devname), "%s:%d", blk_dev->name, + part); + + ret = device_bind_driver(blk_dev, "blk_partition", + strdup(devname), &dev); + if (ret) + return ret; + + part_data = dev_get_uclass_plat(dev); + part_data->partnum = part; + part_data->gpt_part_info = info; + count++; + + ret = device_probe(dev); + if (ret) { + debug("Can't probe\n"); + count--; + device_unbind(dev); + + continue; + } + } + debug("%s: %d partitions found in %s\n", __func__, count, + blk_dev->name); + + return 0; +} + +static ulong blk_part_read(struct udevice *dev, lbaint_t start, + lbaint_t blkcnt, void *buffer) +{ + struct udevice *parent; + struct disk_part *part; + const struct blk_ops *ops; + + parent = dev_get_parent(dev); + ops = blk_get_ops(parent); + if (!ops->read) + return -ENOSYS; + + part = dev_get_uclass_plat(dev); + if (start >= part->gpt_part_info.size) + return 0; + + if ((start + blkcnt) > part->gpt_part_info.size) + blkcnt = part->gpt_part_info.size - start; + start += part->gpt_part_info.start; + + return ops->read(parent, start, blkcnt, buffer); +} + +static ulong blk_part_write(struct udevice *dev, lbaint_t start, + lbaint_t blkcnt, const void *buffer) +{ + struct udevice *parent; + struct disk_part *part; + const struct blk_ops *ops; + + parent = dev_get_parent(dev); + ops = blk_get_ops(parent); + if (!ops->write) + return -ENOSYS; + + part = dev_get_uclass_plat(dev); + if (start >= part->gpt_part_info.size) + return 0; + + if ((start + blkcnt) > part->gpt_part_info.size) + blkcnt = part->gpt_part_info.size - start; + start += part->gpt_part_info.start; + + return ops->write(parent, start, blkcnt, buffer); +} + +static ulong blk_part_erase(struct udevice *dev, lbaint_t start, + lbaint_t blkcnt) +{ + struct udevice *parent; + struct disk_part *part; + const struct blk_ops *ops; + + parent = dev_get_parent(dev); + ops = blk_get_ops(parent); + if (!ops->erase) + return -ENOSYS; + + part = dev_get_uclass_plat(dev); + if (start >= part->gpt_part_info.size) + return 0; + + if ((start + blkcnt) > part->gpt_part_info.size) + blkcnt = part->gpt_part_info.size - start; + start += part->gpt_part_info.start; + + return ops->erase(parent, start, blkcnt); +} + +static const struct blk_ops blk_part_ops = { + .read = blk_part_read, + .write = blk_part_write, + .erase = blk_part_erase, +}; + +U_BOOT_DRIVER(blk_partition) = { + .name = "blk_partition", + .id = UCLASS_PARTITION, + .ops = &blk_part_ops, +}; + +UCLASS_DRIVER(partition) = { + .id = UCLASS_PARTITION, + .per_device_plat_auto = sizeof(struct disk_part), + .name = "partition", +}; diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h index 0e26e1d13824..230b1ea528cf 100644 --- a/include/dm/uclass-id.h +++ b/include/dm/uclass-id.h @@ -83,6 +83,7 @@ enum uclass_id { UCLASS_P2SB, /* (x86) Primary-to-Sideband Bus */ UCLASS_PANEL, /* Display panel, such as an LCD */ UCLASS_PANEL_BACKLIGHT, /* Backlight controller for panel */ + UCLASS_PARTITION, /* Logical disk partition device */ UCLASS_PCH, /* x86 platform controller hub */ UCLASS_PCI, /* PCI bus */ UCLASS_PCI_EP, /* PCI endpoint device */ diff --git a/include/part.h b/include/part.h index 53cfbdd87671..95e30e60af10 100644 --- a/include/part.h +++ b/include/part.h @@ -253,6 +253,17 @@ void part_set_generic_name(const struct blk_desc *dev_desc, int part_num, char *name); extern const struct block_drvr block_drvr[]; + +struct udevice; +/** + * part_create_block_devices - Create block devices for disk partitions + * + * Create UCLASS_PARTITION udevices for each of disk partitions in @parent + * + * @blk_dev: Whole disk device + */ +int part_create_block_devices(struct udevice *blk_dev); + #else static inline struct blk_desc *blk_get_dev(const char *ifname, int dev) { return NULL; } From patchwork Thu Feb 10 08:11:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 541407 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp2039639imo; Thu, 10 Feb 2022 00:14:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJzu/ynatl+J96feRHRbn7PfppG9Vw7dFGmTgsdGr+Ln0dPlUFZcuYeE4G7WkyRgfBMuR3GW X-Received: by 2002:a50:8e4b:: with SMTP id 11mr7084312edx.445.1644480887323; Thu, 10 Feb 2022 00:14:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644480887; cv=none; d=google.com; s=arc-20160816; b=o+r7YtJxFyKqyTV9UcwIUshTXO/QtfDdB9uOijxaawYJTNznEI01xh7pkuGp1QJoaZ UFaBVqIGJdLS3bJLwxtvYbx0JNcOClNPyWjqEshp0JdjadrVmRHbbo8OZLn0spjSEgHv syQ5CDqg8yY05ob8DXuf62tuiXug4Gqs08u4Tfc1NinRvIufA8w49d+qgBNvs7/EMLko fdZ24hzZWR8F2cj/N8jcTX/FIaT4jB2hVoRK/PAVSfZWY7FL14KXHYMGRH0j23WI3O4E 0LsIDznKSxmv2ZeRArhCVQosomAiTaOJb2hdSRgIw3N2b4h6dZwJJ4HLIbKQ8tZ+KlRl xpcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YHIS9w8yNUPCY2iopuxE0zXhJkMNeOp6UmbJxhRoxig=; b=csBSo+fkTwY8J3c8oJROK+c3dkRdBUbttO0RqUgLBh+OYGlaZIvtvUoBnX4VRdmvEF U6dgxTWFfNr5l29hTNqmZjMfj5fo01m3+KWxPfDAQA+pX5y/2NLQiadxKSuIdES4kPmZ UOhGUlroETfOEemL7GIvd54CMqwLYv0Gvbu6FTa1zQa4xCVmcvaFxJo1A4Kq/BFW8sRP F67AdWfq7MHzva2ubeQRAW5REjElj/MwKexuFGgXowQc7mkbS+BZalaLpA2bDFTB942h 51viRgcLhT2wbdGBWcrsfR58sUBbLEGIElSnkmul4XTqkg/iOxoid0AhhjURBeWMFBjF r79g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aXOtStNh; 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 a16si11214059edx.337.2022.02.10.00.14.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:14:47 -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=aXOtStNh; 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 9E6CF837B5; Thu, 10 Feb 2022 09:13: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="aXOtStNh"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 72D4082014; Thu, 10 Feb 2022 09:13:34 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2CE148018F for ; Thu, 10 Feb 2022 09:13: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-x1035.google.com with SMTP id h7-20020a17090a648700b001b927560c2bso3633338pjj.1 for ; Thu, 10 Feb 2022 00:13: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=YHIS9w8yNUPCY2iopuxE0zXhJkMNeOp6UmbJxhRoxig=; b=aXOtStNhqFumjIo08CQykvMzZDiVX7BrAM0i5FwRjDLExNqtYbA25GVkHzhl0+zaet z+nX9vvJky3aU1H5RMdx2gVo7/iz31+MfiyKf+KiM/rCdKq/eNFwXzp4Mah45ZDFsMAD AYeLGaHFWq0LeAWqnP0F3q6kg9+g6tDBuJr/S6lpvmDbGLH8/PCNLhHkdGnqdsxJqaYz ZKO9HbBvs9dvpmBKKl/DqkWzYoOJb+s5LkE06XHpFBaL35R1W30e/s6m4Jt9Wf8zvhvV g4s/cTNr/MezWPSALWY1sq+8fYQDRrVQ1W52UErh5ftzyoO2B3d/sI5DjCAt7+8q+cVB WQSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YHIS9w8yNUPCY2iopuxE0zXhJkMNeOp6UmbJxhRoxig=; b=TvFIS8rvMBkGMDofbVnrDSbPiOxRKdgWDHMdPDnQ2BR79rbYs4KqTrigHnZTujFcDB sBr9oFchOtk3hnARQAtWzIT6CKbLQvPFpQ91wJl1IW1N7yGApkhFaohrbM/NnvKbgoBI tA+s2tyclZZFVT+W0tX1LB9+LG+mh4A1srfGTpNf5mQnq+3WyP3WxA05XjoWalHeNlOP MP+h0qKKIXPs1I7MNKPHK4CJbaN1WaupWZcpJz0DhZ5k+hR9M1FKetQaXZZGTfveGrCE wxfcSlrxaiOwVNviIsfuQ0EerkqN+mvwQJsRS/wRPDvtWMd0AsGvYjEzp8e1nwbFIQvH 7H1w== X-Gm-Message-State: AOAM532SOUYr73UR3vdhWNHnToUP5Rny/nkBWW+xJariJz2H9YTUBFpk MrlEfiag/pmsmVh5SBEJuaxpAw== X-Received: by 2002:a17:902:694c:: with SMTP id k12mr6456670plt.98.1644480779076; Thu, 10 Feb 2022 00:12:59 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:412e:384:fab9:f24]) by smtp.gmail.com with ESMTPSA id lk8sm1529208pjb.40.2022.02.10.00.12.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:12:58 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v2 13/20] dm: blk: add a device-probe hook for scanning disk partitions Date: Thu, 10 Feb 2022 17:11:17 +0900 Message-Id: <20220210081124.86612-14-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220210081124.86612-1-takahiro.akashi@linaro.org> References: <20220210081124.86612-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Now that all the block device drivers have enable a probe hook, we will call part_create_block_devices() to enumerate all the partitions and create associated udevices when a block device is detected. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- drivers/block/blk-uclass.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c index bee1cd6f0d80..58dc74e71f1e 100644 --- a/drivers/block/blk-uclass.c +++ b/drivers/block/blk-uclass.c @@ -717,6 +717,10 @@ static int blk_post_probe(struct udevice *dev) struct blk_desc *desc = dev_get_uclass_plat(dev); part_init(desc); + + if (desc->part_type != PART_TYPE_UNKNOWN && + part_create_block_devices(dev)) + debug("*** creating partitions failed\n"); } return 0; From patchwork Thu Feb 10 08:11:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 541408 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp2039751imo; Thu, 10 Feb 2022 00:14:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJz0EQVfAoKjSrNd0pwna3yWrqyB/VzZJMFgNO4eqwd/YMionVxvKiTLRtyFc6NDrruH3v54 X-Received: by 2002:a17:906:c14d:: with SMTP id dp13mr5623705ejc.188.1644480896978; Thu, 10 Feb 2022 00:14:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644480896; cv=none; d=google.com; s=arc-20160816; b=S74s4fF5O/3eadhaIwlYTSfAUyqVe6N/AqiZtdGFnEtwMRtYPjtmvBZ1H6af9fScT8 NNmMJBaC5bLXFpFN4Ra7RGV1VzPbvD9gWVY4XERptZYyJl59bl40b/6q7q10PbqHi2SH zaYEXlqRtFXB4MnMLItP0L9/pNdS9MXFOyyb4OckPpEoQI12jqLV+lJ98PVNqWZUqGZ5 eD3rLbfwvZ/yNzafueMdn0fRWI4+y1MV9w+Eg/1fBqq3R/rxKGHLSvPeq45mi3R44kZ3 0oQOZDRHCD5CwoKhr3iFg58U8tKVHNSUEkdqFXttuhzDH53xNNeA++NeymViAFabwOfR 1uUw== 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=PU1xvhXim6h4QTgvNe88h+8+FqTOVNivCMssvdV35uU=; b=1DPFhcN7tsNPi5fxNi8gHo65Ttk2NP8JxGA8sxFWd45IndF2IwbDFZk93w9sMXhrlI fox40k8SE6NA62XqXqlOIP6krM7WL+IyPJT3P8TnThXyk+ULsrPclThmDEGycfM1BaK1 ifxsXye3hebcNdv7G//ri3iGmEUCGGcH7RSt2PtILQq/6/wsIp/ws0IhnzWkYifwmQzg 0GHgDSXs9OJi/QDiUz8FUw/Aqw3cUuwp38Alr+GGQCrkz1uJ5PZu8640zbzGggqJ6Sqa 6fYuDxTevekEQCg7oLbrd6Wd0F7cW8rG9NXNBiCTOk7CDBrTbTAyhL01GTU7d9qJHKZk urXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="rya4iB/C"; 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 qw2si2772331ejc.267.2022.02.10.00.14.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:14:56 -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="rya4iB/C"; 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 E5E9783A08; Thu, 10 Feb 2022 09:13: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="rya4iB/C"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C510283041; Thu, 10 Feb 2022 09:13:43 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) (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 9CB378319C for ; Thu, 10 Feb 2022 09:13: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-pl1-x629.google.com with SMTP id y17so1185656plg.7 for ; Thu, 10 Feb 2022 00:13: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=PU1xvhXim6h4QTgvNe88h+8+FqTOVNivCMssvdV35uU=; b=rya4iB/C6es2VMaIez0DzKvsC5zo2rWM034U98GUp7EojmgQiOqNXOijddAeXU4eHv U95GkASZDLo+R11a6zP4b3vL8HYHGmht3sY+OOgG2k6y+eeZ8H3OR7rK6/OUqhpJSdu2 6YAtvh/xxQOFlx82h07l1trXmMnsuK5NNUUlOdj5YY7VEhNO74WBIli3vjpsHDDybJkR eFSsCxQwV86xGQm6LJpZjQ4pwlz5BhKHj42uU//M5eYHa5M0TtMm8aLC6AJgS3uuoUp/ hofq54aWTWwzGNPakkKy/ie9IwO7+RcT5dgxUm1H5ef5emRU65YKRzRM9L54PoYh7kiB 0RFA== 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=PU1xvhXim6h4QTgvNe88h+8+FqTOVNivCMssvdV35uU=; b=S7L9LWdOa5uoklunAr1Y1WsVKhF18YccvdCrxnH9loM2VFesuQbtTae4NHxWWM6ala dRGnb7HWsmv17ZO0DRgpbOCOq7U3lQ27OHZzYweOqcLVI35xzIAxn7vGsGveO/68ln5l 6RbZBppomYqucAobfG4DYO5hXlfsvdN/mFmilEHKWaWXPZMpl5xp4x7LhZ+aubaN1KGV qMkMznCvpsUfx3C+6Pem8Kv/5EPN00pbPK0Q52FrW1Mf6PnGewyKo6NwjUpr/kgtcuF8 2dNFnbA0IuInlj/+QmaAcQBxy7nxPnBkzPcJI2Ocvz18EGbqGDRZQAUT4nSxKT6PUBdy c/1w== X-Gm-Message-State: AOAM5326qP0nqbJ1+L5zpgMPHi/UN87MSpIqU3HQaGOXYoGg+Aj+jnQl 5WIiNSSKS70ULlTqTtrL8dZyPQ== X-Received: by 2002:a17:90a:601:: with SMTP id j1mr1594148pjj.192.1644480782618; Thu, 10 Feb 2022 00:13:02 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:412e:384:fab9:f24]) by smtp.gmail.com with ESMTPSA id lk8sm1529208pjb.40.2022.02.10.00.12.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:13:02 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v2 14/20] efi_loader: split efi_init_obj_list() into two stages Date: Thu, 10 Feb 2022 17:11:18 +0900 Message-Id: <20220210081124.86612-15-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220210081124.86612-1-takahiro.akashi@linaro.org> References: <20220210081124.86612-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean In the next commit, CONFIG_EFI_SETUP_EARLY will become mandated in order to support dynamic enumeration of efi_disk objects. This can, however, be problematic particularly in case of file-based variable storage (efi_variable.c, default). Non-volatile variables are to be restored from EFI system partition by efi_init_variables() in efi_init_obj_list(). When efi_init_obj_list() is called in board_init_r(), we don't know yet what disk devices we have since none of device probing commands (say, scsi rescan) has not been executed at that stage. So in this commit, a preparatory change is made; efi_init_obj_list() is broken into the two functions; * efi_init_early(), and * new efi_init_obj_list() Only efi_init_early() will be called in board_init_r(), which allows us to execute any of device probing commands, either though "preboot" variable or normal command line, before calling efi_init_obj_list() which is to be invoked at the first execution of an efi-related command (or at efi_launch_capsules()) as used to be. Signed-off-by: AKASHI Takahiro --- common/board_r.c | 2 +- common/main.c | 7 +++-- include/efi_loader.h | 2 ++ lib/efi_loader/efi_setup.c | 58 ++++++++++++++++++++++++++++++++------ 4 files changed, 57 insertions(+), 12 deletions(-) diff --git a/common/board_r.c b/common/board_r.c index c24d9b4e220b..7b004b8ae9af 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -789,7 +789,7 @@ static init_fnc_t init_sequence_r[] = { initr_mem, #endif #ifdef CONFIG_EFI_SETUP_EARLY - (init_fnc_t)efi_init_obj_list, + efi_init_early, #endif run_main_loop, }; diff --git a/common/main.c b/common/main.c index 3f5214fd44b8..682f3359ea38 100644 --- a/common/main.c +++ b/common/main.c @@ -54,8 +54,11 @@ void main_loop(void) if (IS_ENABLED(CONFIG_UPDATE_TFTP)) update_tftp(0UL, NULL, NULL); - if (IS_ENABLED(CONFIG_EFI_CAPSULE_ON_DISK_EARLY)) - efi_launch_capsules(); + if (IS_ENABLED(CONFIG_EFI_CAPSULE_ON_DISK_EARLY)) { + /* efi_init_early() already called */ + if (efi_init_obj_list() == EFI_SUCCESS) + efi_launch_capsules(); + } s = bootdelay_process(); if (cli_process_fdt(&s)) diff --git a/include/efi_loader.h b/include/efi_loader.h index 4e50f2d0c368..58b661d5c4c6 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -491,6 +491,8 @@ struct efi_register_notify_event { /* List of all events registered by RegisterProtocolNotify() */ extern struct list_head efi_register_notify_events; +/* called at pre-initialization */ +int efi_init_early(void); /* Initialize efi execution environment */ efi_status_t efi_init_obj_list(void); /* Install device tree */ diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c index 380adc15c886..74b4d2623f88 100644 --- a/lib/efi_loader/efi_setup.c +++ b/lib/efi_loader/efi_setup.c @@ -174,20 +174,18 @@ static efi_status_t efi_init_os_indications(void) &os_indications_supported, false); } - /** - * efi_init_obj_list() - Initialize and populate EFI object list + * __efi_init_early() - handle initialization at early stage + * + * This function is called in efi_init_obj_list() only if + * !CONFIG_EFI_SETUP_EARLY. * * Return: status code */ -efi_status_t efi_init_obj_list(void) +static efi_status_t __efi_init_early(void) { efi_status_t ret = EFI_SUCCESS; - /* Initialize once only */ - if (efi_obj_list_initialized != OBJ_LIST_NOT_INITIALIZED) - return efi_obj_list_initialized; - /* Allow unaligned memory access */ allow_unaligned(); @@ -202,9 +200,51 @@ efi_status_t efi_init_obj_list(void) #ifdef CONFIG_PARTITIONS ret = efi_disk_register(); - if (ret != EFI_SUCCESS) - goto out; #endif +out: + return ret; +} + +/** + * efi_init_early() - handle initialization at early stage + * + * external version of __efi_init_early(); expected to be called in + * board_init_r(). + * + * Return: status code + */ +int efi_init_early(void) +{ + efi_status_t ret; + + ret = __efi_init_early(); + if (ret != EFI_SUCCESS) { + /* never re-init UEFI subsystem */ + efi_obj_list_initialized = ret; + return -1; + } + return 0; +} + +/** + * efi_init_obj_list() - Initialize and populate EFI object list + * + * Return: status code + */ +efi_status_t efi_init_obj_list(void) +{ + efi_status_t ret = EFI_SUCCESS; + + /* Initialize once only */ + if (efi_obj_list_initialized != OBJ_LIST_NOT_INITIALIZED) + return efi_obj_list_initialized; + + if (!IS_ENABLED(CONFIG_EFI_SETUP_EARLY)) { + ret = __efi_init_early(); + if (ret != EFI_SUCCESS) + goto out; + } + if (IS_ENABLED(CONFIG_EFI_RNG_PROTOCOL)) { ret = efi_rng_register(); if (ret != EFI_SUCCESS) From patchwork Thu Feb 10 08:11:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 541409 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp2039848imo; Thu, 10 Feb 2022 00:15:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJw4KVoiMcozJD/tp8BFWyRdV5s59P4487FX6y9R1N6vNU8hfjQFjczVfJRvhVnEJCLAq/5v X-Received: by 2002:a17:907:3e8a:: with SMTP id hs10mr5422586ejc.767.1644480908603; Thu, 10 Feb 2022 00:15:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644480908; cv=none; d=google.com; s=arc-20160816; b=vO31e2/6e7AUxdqJ7UfoXMUtQDT/tKCb4NqYoNGe554EJFR3I3MNr1wKWGzZCh4iUR GGRIoMC2/lxsFtAKY796ioOnhMYB3eFSj+OzHtx4Kkk5lWHXpyOdh4m/XmKfehu3Cbk5 7i34+tcszxT8VwiZYP6o2oWx1p4saxe9i6DikWSGUxDBEuVqQi0S5LPfVIT2Hv+DMnR5 wkltyISaWcCaBkA76qYJhUZjT76yZvci2SGI4Y2wQmlwrcZWbZNsqB9MUSvezTOoDvHp vJJRCoHsGHw9zPq6RQHcK3CfLZBTVIQ5Zh9m5LLLoKsJpz4a13hMx5QrdEqghYy8b9m5 pgqw== 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=LsqMGhH62uwJ9mqq3Gjb4OyNuz9Qqxtm98rhjS6pKXo=; b=plTn9b2NZLEzvuEeWzYqktYWSWX/JwzupbmRutzeM2Qq5uc5wMOkyOrh6+ANyZX+kL XkA+oR2WYTZlX9EFA8Ul85XZoV7jPYw+c9xw7AFeYhnv/RUjtyCkatPhK1Avx4nCbsMD r1MZzRqN2/M7dMIDQvS+IPAZW3/UHMkG6HQhMnSIGpWfXjVznV7tQ6/P7xUdTmbdp2Kz XEcFdpxJeO3oGTeOgBo48I6ULTu27B4DaN4da34wvKQK2KmXpvr9ON6rb9qBvlq5x0O9 sofWC13ki0Pe54B0eRk5D3B4QaFW5LzxPDMK3/aEuaN231qHg+evAgBJsPJLJ9fNbebu aVRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Dgc6CTwg; 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 kx3si13721018ejc.130.2022.02.10.00.15.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:15:08 -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=Dgc6CTwg; 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 7D48C83A0E; Thu, 10 Feb 2022 09:13: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="Dgc6CTwg"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DD0A383041; Thu, 10 Feb 2022 09:13:46 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0533B83804 for ; Thu, 10 Feb 2022 09:13:08 +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-x1034.google.com with SMTP id t4-20020a17090a510400b001b8c4a6cd5dso4803401pjh.5 for ; Thu, 10 Feb 2022 00:13: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=LsqMGhH62uwJ9mqq3Gjb4OyNuz9Qqxtm98rhjS6pKXo=; b=Dgc6CTwgklRQReOSW/3c2ZsbtmXFrkiG/tO0jSiwt08WyI063SVbNCHCHHoLgpcsLm PE6aKPkGIPG3QAen9i4Q06+CwlOpJQHG5z01YI0bgyatB+/LPVxY8h1TYevHCVlqmIbz J4ev/GH2R4ql4pPjMo7f5ihyyrWEINuGbvh1wVv9UpFT5h8w4z8y3WKXJRvNZkiaBQH2 sX4wXVu6GhLRFYLQxGHpDxGM4syvOAIZCjuw38X0D4jYX1/M72fcQABx04MOtInc5UPW Y9emGG9jjTu1oOsNZse1+w0cszP9BtckSTMHM6rlsUYc3GB2sDAN4nN2MwExCESFA5Wc sKoQ== 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=LsqMGhH62uwJ9mqq3Gjb4OyNuz9Qqxtm98rhjS6pKXo=; b=inIbD2GRh7Mh/CB6jr1+nai+YVY0u9HbYWpIIgsXxfbQn5wVYx7Vk2xBCIdWqTETpJ U3Jo3rkxGi6hRidhOAv84WuZlIhyAEx78aZ5+UZfvR7xRoF0yKm/GCNU31AmnvSl5uki uZxg8a1PBJkATtw/D8+nSmUBzXOfmsQAWReBv+8cFMf6tr83laaTX730iiqsrBxPPd6+ g2NVjc8+bSbdND0Juu8kcNvI56/h3EmKfH6i4eRYEqxNqo8Oj8LK9pgfz/OqaxDKCYez Eik1sZ6CYZkV4BU4XS9sKAmQjqT1WkSpb0LgzU0lE4wEhTBR7tJgFU6Z3zSosR47uXMI Ed0g== X-Gm-Message-State: AOAM531Q/COou4GA3KbjvBeYSNvlfWTFVsWqXpk8+mEop7GeLYaH86PA FJBoMezosCAZPRY/mfnnEBHvQg== X-Received: by 2002:a17:903:2083:: with SMTP id d3mr6271707plc.174.1644480786324; Thu, 10 Feb 2022 00:13:06 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:412e:384:fab9:f24]) by smtp.gmail.com with ESMTPSA id lk8sm1529208pjb.40.2022.02.10.00.13.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:13:06 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v2 15/20] efi_loader: disk: a helper function to create efi_disk objects from udevice Date: Thu, 10 Feb 2022 17:11:19 +0900 Message-Id: <20220210081124.86612-16-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220210081124.86612-1-takahiro.akashi@linaro.org> References: <20220210081124.86612-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Add efi_disk_probe() function. This function creates an efi_disk object for a raw disk device (UCLASS_BLK) and additional objects for related partitions (UCLASS_PARTITION). So this function is expected to be called through driver model's "probe" interface every time one raw disk device is detected and activated. We assume that partition devices (UCLASS_PARTITION) have been created when this function is invoked. Signed-off-by: AKASHI Takahiro --- include/efi_loader.h | 4 +- lib/efi_loader/Kconfig | 2 + lib/efi_loader/efi_disk.c | 204 +++++++++++++++++++++++-------------- lib/efi_loader/efi_setup.c | 4 +- 4 files changed, 135 insertions(+), 79 deletions(-) diff --git a/include/efi_loader.h b/include/efi_loader.h index 58b661d5c4c6..ed9d4f4ffa96 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -523,8 +523,8 @@ void efi_carve_out_dt_rsv(void *fdt); void efi_try_purge_kaslr_seed(void *fdt); /* Called by bootefi to make console interface available */ efi_status_t efi_console_register(void); -/* Called by bootefi to make all disk storage accessible as EFI objects */ -efi_status_t efi_disk_register(void); +/* Called by efi_init_obj_list() to initialize efi_disks */ +efi_status_t efi_disk_init(void); /* Called by efi_init_obj_list() to install EFI_RNG_PROTOCOL */ efi_status_t efi_rng_register(void); /* Called by efi_init_obj_list() to install EFI_TCG2_PROTOCOL */ diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index e5e35fe51f65..57a417a7eb23 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -14,6 +14,7 @@ config EFI_LOADER depends on DM_ETH || !NET depends on !EFI_APP default y if !ARM || SYS_CPU = armv7 || SYS_CPU = armv8 + select EVENT select LIB_UUID select PARTITION_UUIDS select HAVE_BLOCK_DEVICE @@ -41,6 +42,7 @@ config CMD_BOOTEFI_BOOTMGR config EFI_SETUP_EARLY bool + default y choice prompt "Store for non-volatile UEFI variables" diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index 45127d176869..243cd0e215d4 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,156 @@ 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; + } + if (dev_tag_set_ptr(dev, DM_TAG_EFI, &disk->header)) { + efi_free_pool(disk->dp); + efi_delete_handle(&disk->header); + + return -1; } - return disks; + return 0; } -/** - * efi_disk_register() - register block devices - * - * U-Boot doesn't have a list of all online disk devices. So when running our - * EFI payload, we scan through all of the potentially available ones and - * store them in our object pool. +/* + * Create a handle for a disk partition * - * This function is called in efi_init_obj_list(). + * @dev uclass device (UCLASS_PARTITION) * - * TODO(sjg@chromium.org): Actually with CONFIG_BLK, U-Boot does have this. - * Consider converting the code to look up devices as needed. The EFI device - * could be a child of the UCLASS_BLK block device, perhaps. + * Create an efi_disk object which is associated with @dev. + * The type of @dev must be UCLASS_PARTITION. * - * Return: status code + * @return 0 on success, -1 otherwise */ -efi_status_t efi_disk_register(void) +static int efi_disk_create_part(struct udevice *dev) { + efi_handle_t parent; + struct blk_desc *desc; + const char *if_typename; + struct disk_part *part_data; + struct disk_partition *info; + unsigned int part; + int diskid; + struct efi_handler *handler; + struct efi_device_path *dp_parent; struct efi_disk_obj *disk; - int disks = 0; efi_status_t ret; + + if (dev_tag_get_ptr(dev_get_parent(dev), DM_TAG_EFI, (void **)&parent)) + return -1; + + desc = dev_get_uclass_plat(dev_get_parent(dev)); + if_typename = blk_get_if_type_name(desc->if_type); + diskid = desc->devnum; + + part_data = dev_get_uclass_plat(dev); + part = part_data->partnum; + info = &part_data->gpt_part_info; + + ret = efi_search_protocol(parent, &efi_guid_device_path, &handler); + if (ret != EFI_SUCCESS) + return -1; + dp_parent = (struct efi_device_path *)handler->protocol_interface; + + ret = efi_disk_add_dev(parent, dp_parent, if_typename, desc, diskid, + info, part, &disk); + if (ret != EFI_SUCCESS) { + log_err("Adding partition for %s failed\n", dev->name); + return -1; + } + if (dev_tag_set_ptr(dev, DM_TAG_EFI, &disk->header)) { + efi_free_pool(disk->dp); + efi_delete_handle(&disk->header); + + return -1; + } + + return 0; +} + +/* + * Create efi_disk objects for a block device + * + * @dev uclass device (UCLASS_BLK) + * + * Create efi_disk objects for partitions as well as a raw disk + * which is associated with @dev. + * The type of @dev must be UCLASS_BLK. + * This function is expected to be called at EV_PM_POST_PROBE. + * + * @return 0 on success, -1 otherwise + */ +static int efi_disk_probe(void *ctx, struct event *event) +{ struct udevice *dev; + enum uclass_id id; + struct udevice *child; + int ret; - for (uclass_first_device_check(UCLASS_BLK, &dev); dev; - uclass_next_device_check(&dev)) { - struct blk_desc *desc = dev_get_uclass_plat(dev); - const char *if_typename = blk_get_if_type_name(desc->if_type); + dev = event->data.dm.dev; + id = device_get_uclass_id(dev); - /* Add block device for the full device */ - log_info("Scanning disk %s...\n", dev->name); - ret = efi_disk_add_dev(NULL, NULL, if_typename, - desc, desc->devnum, NULL, 0, &disk); - if (ret == EFI_NOT_READY) { - log_notice("Disk %s not ready\n", dev->name); - continue; - } - if (ret) { - log_err("ERROR: failure to add disk device %s, r = %lu\n", - dev->name, ret & ~EFI_ERROR_MASK); - continue; - } - disks++; + /* TODO: We won't support partitions in a partition */ + if (id != UCLASS_BLK) { + 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 74b4d2623f88..b9b36a5f6707 100644 --- a/lib/efi_loader/efi_setup.c +++ b/lib/efi_loader/efi_setup.c @@ -198,9 +198,7 @@ static efi_status_t __efi_init_early(void) if (ret != EFI_SUCCESS) goto out; -#ifdef CONFIG_PARTITIONS - ret = efi_disk_register(); -#endif + ret = efi_disk_init(); out: return ret; } From patchwork Thu Feb 10 08:11:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 541410 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp2039978imo; Thu, 10 Feb 2022 00:15:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJyF+1B1Mg3FF2xaSoLoyqp8nRWCeZ8LwRVA2bXx10ViBbeViVuFcUFBasSK1l93ixCJpJsf X-Received: by 2002:a05:6402:42cd:: with SMTP id i13mr7110029edc.121.1644480920147; Thu, 10 Feb 2022 00:15:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644480920; cv=none; d=google.com; s=arc-20160816; b=hVy4uNcXfoAO4IS2cL9RdOZRPU2GD4OdcDWQLdcCzEOPJ5HGBQek3Unpe00doA5B40 rKouMzzf+1tiZwmIoEku+yhkG9oUAlhYPV5PRlamrbeqWmV5zyh3UcS17U8X93zFGtxo VBUEUakK8do3xTGt8Qe8H0MbNKg2YCjUQERtNodw257eGBI2rSDxwtpMEl2bhYiQT8BP aDs9SisjiMYB43at2hlFyU6liH+1+WyOm70lKYsrTgjMiHf2d0zjDNWx376wV25WnJwx opoGE92RYY4svPOsRLZ+6R02LcgD/WUbubw3L+RB7NHYhni63Rkhl8/kmMYkSlKtWDUt cuWA== 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=KDkB6jeJfQUa2ED0ziGxkJDYCnCmWevQG5aoPTJeaVE=; b=MrcfqwtSxbIbF2qHcjm1Gf7YZOQxFKdDSBzf0c1KIISrqfgeUXQffqWNYFIzG+QuZx uSYjB2RibX1+UENPcuuqb4VbQFu0E+7e8UHp5jl4+15FZBlzfZFRptZQdOeDnYoT9OEs Bs8ynvR6LM/RRlJEvC3MyMMPrIw/VKESVcLHUrhGIFLJD19VQD9tnbicbNB1fjkfRzap dQ9NNSQnvB3khZLHEiyk3v61eMr3HCjkCh2dDhLLucYPIo96rLMhllU58g43KJI/dRJf BpDa2d5GnE6FP77o3pNTZC5jSOXn91pdG4P3NJd0yOEIjkjUTTonig6QX31Sc2BTT29z u17w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Fv1ydTg5; 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 gt37si3085188ejc.97.2022.02.10.00.15.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:15:20 -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=Fv1ydTg5; 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 08F7F83A27; Thu, 10 Feb 2022 09:13:56 +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="Fv1ydTg5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 80ABA83A2B; Thu, 10 Feb 2022 09:13:52 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) (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 A3418836A3 for ; Thu, 10 Feb 2022 09:13: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=takahiro.akashi@linaro.org Received: by mail-pl1-x630.google.com with SMTP id x3so1197851pll.3 for ; Thu, 10 Feb 2022 00:13:11 -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=KDkB6jeJfQUa2ED0ziGxkJDYCnCmWevQG5aoPTJeaVE=; b=Fv1ydTg5c8t9NK1daN3EQzAkkfiFmNgcDdeJABlF1e9+nk9DBrmv1ht40qPWL+kc7M do7x1IE36UxhLdfBsVuRt/vA/mUK3WiCsrp3ebpyIMxHoxeTW2414sVsRWTbNy47pr3a sTb9XkHkrVpIzsAe6YVshtvo2s0FB3yQWWc+/JnrNN+hSlOrGg6YHfnHn1qMgdp3ZHZO vGStsl/1Da5pX22B7kosrceN7tIq+i59hvVraBXxOzZx34Q3+R7BjPN5757GcJGaiDOx vrO+moAx3r5Mt7hdT3ewaj80t3NmZYW1/HvJxgZaRHKlYZuWPZJ8phYGyFC8ayFkrFqj 9UYA== 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=KDkB6jeJfQUa2ED0ziGxkJDYCnCmWevQG5aoPTJeaVE=; b=Omemxjg23w/ZA+GYkL14KZ4y2FvxqMsYyMsCN/EkG3NdccYUlPp6QuIawPVZkntpal RduWDGELQyAgLnkSWxI75ACACTdW3IZxfPIcmKS1Pjgh8CONb2cpegNxxPJrL86eZcpN xsHLOinHPO5Hsyj0CLB/kbMgcfW5oj5O52l2sNXQp3E3NGYIv3NBRl0QtGvPAQI0iUbo 8FExKnNafWUgimJ+X2R2xIA1aGoxBO25nQrvBpw/wW8Y+XVXdoGHw2FZA0PENlVVc1Uz Vr3C+g5aGPBLVrE1eLg4frJI+Qb0C+uxu18AtnQHfwlWkfliup8OciMce4xO2+kwZ9XP Bbgw== X-Gm-Message-State: AOAM532+ewHFq5qQA18cSR763GeiE5gXeKJxLg7FSN7CLNplo+N3X/WK eGdqtRl7fGuQ6IY/nI7rWWDmtQ== X-Received: by 2002:a17:902:ecc3:: with SMTP id a3mr4236493plh.84.1644480789881; Thu, 10 Feb 2022 00:13:09 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:412e:384:fab9:f24]) by smtp.gmail.com with ESMTPSA id lk8sm1529208pjb.40.2022.02.10.00.13.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:13:09 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v2 16/20] efi_loader: disk: a helper function to delete efi_disk objects Date: Thu, 10 Feb 2022 17:11:20 +0900 Message-Id: <20220210081124.86612-17-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220210081124.86612-1-takahiro.akashi@linaro.org> References: <20220210081124.86612-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean This function is expected to be called, in particular from dm's pre_remove hook, when associated block devices no longer exist. Add efi_disk_remove() function. This function removes an efi_disk object for a raw disk device (UCLASS_BLK) and related objects for its partitions (UCLASS_PARTITION). So this function is expected to be called through driver model's "remove" interface every time a raw disk device is to be disconnected. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- lib/efi_loader/efi_disk.c | 88 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index 243cd0e215d4..7abe5d3a6bd2 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -630,6 +630,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; @@ -641,6 +722,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 Thu Feb 10 08:11:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 541412 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp2040192imo; Thu, 10 Feb 2022 00:15:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJyEvoA3tIcrENJZMfvNk1bPZqCOrCZdufcaafzXMSYwpAu4KLnbT0LjELECz1zyRsT3h5sY X-Received: by 2002:a17:907:9720:: with SMTP id jg32mr2210344ejc.175.1644480941736; Thu, 10 Feb 2022 00:15:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644480941; cv=none; d=google.com; s=arc-20160816; b=cgwaHRdsHNELUC4Ok/9Wu8N2f8SmGwIjz4Gt/4TyB1U17ufWSpk5JKfq7+UVO77Q+H zQy/z+JgVvMziD+YsAtWCfae6o94nng7OdhcxXEuSe01+Va2ECgKHjSSXsm6juiKOCq8 COsjI/ZVHbimD8bkGGGcclNaSvVuAJLZEU5/+BCr8cAmD6TcXerNp96JEwSTxThgDJSN vQqTcliFFQBHZBcDsLpN0EPNsROAbbYRBkqzh/BTqAZyodPswM+ZTI4u0q+ipNUT/yCX h6/ZrwgJhILbkopWdPZ6voxKNFn/gzvBG5ib+4lC5oU7XdwnYR7DBvtEH4FaYdQXbp2+ kSiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=OsQfVSYdhgShxJakhkjh4CKoWsiUp44hecLFF1owVw0=; b=sDTuKkqok2ZBSJbtkeB6uEUmmpp1Aa/YXf6vlpHa5QKOSDUJA1H+8n6svzv39N0Jcx T7e6Pl/5Uj9/G25QaL6AI0gQqQm15qoxU83ySD3aCit5gyTLRcCIBPlLWLM71wuzFJ9G pHd/kla71t5nyHDNbWPg+W71oYw1Jty6M8abBKpZ690obds6vWKAvjeDiLLJFK6fsX6p Y8BPFvDyon4rXpfQFdXZ8xi6q+1VyKnrncecu86eX1JqoIEB+uh93x6LYN6ZADXVqDQS /5QeeeVfGRVRipT0mS/hphLDCqCVjlVVZR07aXy3Q4YSau+yt1tA+YgNzSK8vzgaJ6nN 3hFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G+0Uwvbj; 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 dt7si14896305ejc.559.2022.02.10.00.15.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:15:41 -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=G+0Uwvbj; 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 86D4C83A46; Thu, 10 Feb 2022 09:14:09 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="G+0Uwvbj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CCE2881F4D; Thu, 10 Feb 2022 09:14: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, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 47A8983885 for ; Thu, 10 Feb 2022 09:13: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=takahiro.akashi@linaro.org Received: by mail-pj1-x102d.google.com with SMTP id h7-20020a17090a648700b001b927560c2bso3633808pjj.1 for ; Thu, 10 Feb 2022 00:13: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=OsQfVSYdhgShxJakhkjh4CKoWsiUp44hecLFF1owVw0=; b=G+0UwvbjLNpdHevXagLUgtgKN5V0uyrhWIxVBSpgA6fFgTcpNjyLinAqrQxGuFgQPT Lk8iO0NkfkFgEV46FySB0ZgyFvXz78kIflOfwVdERiUR26bK6ybohv09GJ3wYLhMsM5j v3pHGZnZRblLkU9aebzzpbeVj15OHlMEw6hFgAmtc1wmJvb4MnfeYdpEyMsDXF53OOjc G0lcZmk9euj7vUfDsaZd+zoCKU8fh5YLUMqHC6OSyaRBoHGJNedNoF67GxDda2or9h8G Ye41iJBzaIg71ZEGoMUT7NxlK37DKRaI6n6yqdhD5Y8XaCBCPkwHW6gtVQM8MqVBMZ83 zrDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OsQfVSYdhgShxJakhkjh4CKoWsiUp44hecLFF1owVw0=; b=jXS7NwMvyYCB1+5/XxYscRFR83M3Ey+E7aoIz1AwAl/sDxvU8rGQzDv/0O/v9jRtWw LMZomj+gpt6w9pe8VTUsJmDlqZiDwU28zoZK7eK0eGtlJfi9ViWHh5jMGUr4kad+4erH cSE+nKqHL6jQkX73gD5KNzpE1w2NbjswIEG44L7xDJpuzWTSeypOT48ZEUTHkATeiSui cYFByx661mmoMTk3H8KB1GSEVSCGmPBDR9hTyEX3Q9XHJVPrOy7n1QqP4gi2N6yiFNP0 EqtpRL1/Vw6p1J7A0wNJERHtjxg9Z5edOz4t+71QVXtT4SpaSkXCZ5Ngqe7lfSATqZGR vi4Q== X-Gm-Message-State: AOAM533o1Z2u0im+pZrosw7dGLGmGh42UuZxJ0PePG2yFjibXw6cJKq8 DcGNuaM58jx33slSbGrE4pwirA== X-Received: by 2002:a17:902:e74c:: with SMTP id p12mr6702441plf.115.1644480793610; Thu, 10 Feb 2022 00:13:13 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:412e:384:fab9:f24]) by smtp.gmail.com with ESMTPSA id lk8sm1529208pjb.40.2022.02.10.00.13.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:13:13 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v2 17/20] dm: disk: add read/write interfaces with udevice Date: Thu, 10 Feb 2022 17:11:21 +0900 Message-Id: <20220210081124.86612-18-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220210081124.86612-1-takahiro.akashi@linaro.org> References: <20220210081124.86612-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean In include/blk.h, Simon suggested: ===> /* * These functions should take struct udevice instead of struct blk_desc, * but this is convenient for migration to driver model. Add a 'd' prefix * to the function operations, so that blk_read(), etc. can be reserved for * functions with the correct arguments. */ unsigned long blk_dread(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt, void *buffer); unsigned long blk_dwrite(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt, const void *buffer); unsigned long blk_derase(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt); <=== So new interfaces are provided with this patch. They are expected to be used everywhere in U-Boot at the end. The exceptions are block device drivers, partition drivers and efi_disk which should know details of blk_desc structure. Signed-off-by: AKASHI Takahiro --- disk/disk-uclass.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++ include/part.h | 7 ++++ 2 files changed, 101 insertions(+) diff --git a/disk/disk-uclass.c b/disk/disk-uclass.c index 4918a2f72d1e..72ff62ebf581 100644 --- a/disk/disk-uclass.c +++ b/disk/disk-uclass.c @@ -146,6 +146,100 @@ U_BOOT_DRIVER(blk_partition) = { .ops = &blk_part_ops, }; +/* + * BLOCK IO APIs + */ +static struct blk_desc *dev_get_blk(struct udevice *dev) +{ + struct blk_desc *block_dev; + + switch (device_get_uclass_id(dev)) { + /* + * We won't support UCLASS_BLK with dev_* interfaces. + */ + case UCLASS_PARTITION: + block_dev = dev_get_uclass_plat(dev_get_parent(dev)); + break; + default: + block_dev = NULL; + break; + } + + return block_dev; +} + +unsigned long dev_read(struct udevice *dev, lbaint_t start, + lbaint_t blkcnt, void *buffer) +{ + struct blk_desc *block_dev; + const struct blk_ops *ops; + struct disk_part *part; + lbaint_t start_in_disk; + ulong blks_read; + + block_dev = dev_get_blk(dev); + if (!block_dev) + return -ENOSYS; + + ops = blk_get_ops(dev); + if (!ops->read) + return -ENOSYS; + + start_in_disk = start; + if (device_get_uclass_id(dev) == UCLASS_PARTITION) { + part = dev_get_uclass_plat(dev); + start_in_disk += part->gpt_part_info.start; + } + + if (blkcache_read(block_dev->if_type, block_dev->devnum, + start_in_disk, blkcnt, block_dev->blksz, buffer)) + return blkcnt; + blks_read = ops->read(dev, start, blkcnt, buffer); + if (blks_read == blkcnt) + blkcache_fill(block_dev->if_type, block_dev->devnum, + start_in_disk, blkcnt, block_dev->blksz, buffer); + + return blks_read; +} + +unsigned long dev_write(struct udevice *dev, lbaint_t start, + lbaint_t blkcnt, const void *buffer) +{ + struct blk_desc *block_dev; + const struct blk_ops *ops; + + block_dev = dev_get_blk(dev); + if (!block_dev) + return -ENOSYS; + + ops = blk_get_ops(dev); + if (!ops->write) + return -ENOSYS; + + blkcache_invalidate(block_dev->if_type, block_dev->devnum); + + return ops->write(dev, start, blkcnt, buffer); +} + +unsigned long dev_erase(struct udevice *dev, lbaint_t start, + lbaint_t blkcnt) +{ + struct blk_desc *block_dev; + const struct blk_ops *ops; + + block_dev = dev_get_blk(dev); + if (!block_dev) + return -ENOSYS; + + ops = blk_get_ops(dev); + if (!ops->erase) + return -ENOSYS; + + blkcache_invalidate(block_dev->if_type, block_dev->devnum); + + return ops->erase(dev, start, blkcnt); +} + UCLASS_DRIVER(partition) = { .id = UCLASS_PARTITION, .per_device_plat_auto = sizeof(struct disk_part), diff --git a/include/part.h b/include/part.h index 95e30e60af10..d4e5cd921db1 100644 --- a/include/part.h +++ b/include/part.h @@ -264,6 +264,13 @@ struct udevice; */ int part_create_block_devices(struct udevice *blk_dev); +unsigned long dev_read(struct udevice *dev, lbaint_t start, + lbaint_t blkcnt, void *buffer); +unsigned long dev_write(struct udevice *dev, lbaint_t start, + lbaint_t blkcnt, const void *buffer); +unsigned long dev_erase(struct udevice *dev, lbaint_t start, + lbaint_t blkcnt); + #else static inline struct blk_desc *blk_get_dev(const char *ifname, int dev) { return NULL; } From patchwork Thu Feb 10 08:11:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 541411 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp2040080imo; Thu, 10 Feb 2022 00:15:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJxrL73JzpjpkPYseSxCTLNpDZetkiHNCW6GQsYqHM2ZIEs5NMfdWY7hNtAXtEQ81sTIk0y3 X-Received: by 2002:a05:6402:2549:: with SMTP id l9mr7100811edb.129.1644480930750; Thu, 10 Feb 2022 00:15:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644480930; cv=none; d=google.com; s=arc-20160816; b=DOlEHRfeqXh9jC+WCCZXutVOryCN/FBGiXttgcL9aiQaaVtJrKrCnX7H4Gapgggz3J TXZ5Z+OINCBlSwCx4aSOre/tcRt4YZ4+4AaMLABqmgGGvFsAp0RrrLCYz8RKrblDpOnA i65TkiiMjfyVb17Lqkr8DEyGuXy2e0RKtMPMOpLF48Dka+ATpKOH4YI6Ob7Z63rXlp55 1B3z0sPznN3NCXaUq41jiBcxqeVBFgfc0oU/jeRzOunLkaqy4u+hdu/ov/tHNKxBi+/3 b5uDNu2A5hE8WH8nhmpdaNfaqEDytVUX9s5CNiLfjLI/rA/Ozd0egpxhklggX07KSxjk 87iw== 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=nGtFj32QYfOOcSHbM1uUU+QpwypLb1V3dy+QFTQBg50=; b=0/7N5SDl3LcrK2iqRQqTY2zf0/qDLu9qsocHwbCdjQjZRWSJO7hBixOZ4OY0DoeycP BNNEGbMfsTrwbvWz/9tuVDUzyftE+/dYnvinMeuwlkTsibh0rS5FxGQu6Vu/e394bQmH 88jaPkHX58iIOWwC21/oqU3hhHTBMPj8wQj5Uwe/I3zfNEplY5fewzSBB69rSUDEBQPW J0afwyH3nkF0ZizlY7jXVuG+srIcBH/Edl1uWGe4PvGXFKqng7orz2z1jKnKhEks5vdU 6l2Ky7omvsRiiBOJQ+VZ28K9KZKPgpQBYXi3PuhB2UnMyKS4b78/ZXfU+U4wWmlB9EuD cj8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ol3mta0a; 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 do9si12436324ejc.968.2022.02.10.00.15.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:15:30 -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=Ol3mta0a; 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 84F038386D; Thu, 10 Feb 2022 09:14: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=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="Ol3mta0a"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F1BE281FDE; Thu, 10 Feb 2022 09:13:59 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) (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 D4C788386D for ; Thu, 10 Feb 2022 09:13:18 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pj1-x102c.google.com with SMTP id c5-20020a17090a1d0500b001b904a7046dso6211133pjd.1 for ; Thu, 10 Feb 2022 00:13:18 -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=nGtFj32QYfOOcSHbM1uUU+QpwypLb1V3dy+QFTQBg50=; b=Ol3mta0a44odfmyvs5C9cZ6gf1HWS04FoK45qb7oz6IUjVEDU3/4fCVr47rUwHsi6n xMxenC/e5+cJmxHTbAG2oIKFSTICxZeV13eUnkm9ibImCUIK71Mwe63n9AVcms4Q0KPG G3dUsKITAcgFMQV73O6NZCDzI3G8hJKBGORd1KhSbdDjYWkfqCxMaBypoBpjeQuox1DW JhmgkocmSj0FO+ntAtkWgjLjuh5ybBhwCEx3+jn+JIbNvjnLfofyY4AMDlVeQBRXbXrK JhdX4YwmUzEafZm33cinuCrap1N7vHSNQqH7JVUz5uEUp7/FYJ3vxyVyxI+jxuzsqbCT hYMA== 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=nGtFj32QYfOOcSHbM1uUU+QpwypLb1V3dy+QFTQBg50=; b=GSOCMzchSqWyMmJeXvGthM4B5zXxrJHsxkeI7V8g+3hU8Y7WEaCFBwQ2s+R1NGBVJQ lgPDBTdLFv8WCtkFZyQUKv4KmcduFXMliiG7NKNiVMsM7NseV8vlHk90MnA3nXQLZUiK Z9aGpGmuNl7yarD4LCdXtwhAABuIvGQmy0itWP+08f7XSYeaJykAyE20pjTRZRcnMb3v BXgmP7WpJKkui4vlLIK5CFb6byc+pnJhSxr2muNC80nBYdg1i/A//XXcJE8IPSYT4xzI t2eERFEHdgxUPBnjllIUW0zn55m9UX40KNPFebHmcGxEB2sj2kSNK2MwJeoLqdBpGp8w WGYQ== X-Gm-Message-State: AOAM530CnoWsmebyWnxBlTRDgxi6mNg4zSaLRjhWVviCXofdn81lRXK3 IR/fbp691lQx7Z/OwA6Am6MbXA== X-Received: by 2002:a17:902:ce02:: with SMTP id k2mr2904727plg.93.1644480797266; Thu, 10 Feb 2022 00:13:17 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:412e:384:fab9:f24]) by smtp.gmail.com with ESMTPSA id lk8sm1529208pjb.40.2022.02.10.00.13.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:13:16 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v2 18/20] efi_loader: disk: use udevice instead of blk_desc Date: Thu, 10 Feb 2022 17:11:22 +0900 Message-Id: <20220210081124.86612-19-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220210081124.86612-1-takahiro.akashi@linaro.org> References: <20220210081124.86612-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean In most of all cases, we can avoid using blk_desc which is expected to be private to udevice(UCLASS_BLK), that is, the data should not be manipulated outside the device driver unless really needed. Now efi_disk's internally use dev_read/write() interfaces. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- lib/efi_loader/efi_disk.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index 7abe5d3a6bd2..a8cac0a002c9 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -36,7 +36,7 @@ const efi_guid_t efi_system_partition_guid = PARTITION_SYSTEM_GUID; * @part: partition * @volume: simple file system protocol of the partition * @offset: offset into disk for simple partition - * @desc: internal block device descriptor + * @dev: associated DM device */ struct efi_disk_obj { struct efi_object header; @@ -48,7 +48,7 @@ struct efi_disk_obj { unsigned int part; struct efi_simple_file_system_protocol *volume; lbaint_t offset; - struct blk_desc *desc; + struct udevice *dev; /* TODO: move it to efi_object */ }; /** @@ -83,14 +83,12 @@ static efi_status_t efi_disk_rw_blocks(struct efi_block_io *this, void *buffer, enum efi_disk_direction direction) { struct efi_disk_obj *diskobj; - struct blk_desc *desc; int blksz; int blocks; unsigned long n; diskobj = container_of(this, struct efi_disk_obj, ops); - desc = (struct blk_desc *) diskobj->desc; - blksz = desc->blksz; + blksz = diskobj->media.block_size; blocks = buffer_size / blksz; lba += diskobj->offset; @@ -102,9 +100,9 @@ static efi_status_t efi_disk_rw_blocks(struct efi_block_io *this, return EFI_BAD_BUFFER_SIZE; if (direction == EFI_DISK_READ) - n = blk_dread(desc, lba, blocks, buffer); + n = dev_read(diskobj->dev, lba, blocks, buffer); else - n = blk_dwrite(desc, lba, blocks, buffer); + n = dev_write(diskobj->dev, lba, blocks, buffer); /* We don't do interrupts, so check for timers cooperatively */ efi_timer_check(); @@ -446,7 +444,6 @@ static efi_status_t efi_disk_add_dev( diskobj->ops = block_io_disk_template; diskobj->ifname = if_typename; diskobj->dev_index = dev_index; - diskobj->desc = desc; /* Fill in EFI IO Media info (for read/write callbacks) */ diskobj->media.removable_media = desc->removable; @@ -522,6 +519,7 @@ static int efi_disk_create_raw(struct udevice *dev) return -1; } + disk->dev = dev; if (dev_tag_set_ptr(dev, DM_TAG_EFI, &disk->header)) { efi_free_pool(disk->dp); efi_delete_handle(&disk->header); @@ -578,6 +576,7 @@ static int efi_disk_create_part(struct udevice *dev) log_err("Adding partition for %s failed\n", dev->name); return -1; } + disk->dev = dev; if (dev_tag_set_ptr(dev, DM_TAG_EFI, &disk->header)) { efi_free_pool(disk->dp); efi_delete_handle(&disk->header); @@ -743,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 Thu Feb 10 08:11:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 541413 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp2043934imo; Thu, 10 Feb 2022 00:23:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJx81YTnxyUJgH9lpZ09amofLS8Ot+TflMvRBqwpD5FYMEjO3ikFRNV92R6sydj1mRu8+UAh X-Received: by 2002:a17:907:948c:: with SMTP id dm12mr5749822ejc.770.1644481395170; Thu, 10 Feb 2022 00:23:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644481395; cv=none; d=google.com; s=arc-20160816; b=WM1iRHPvTI2V+FZHS0XrEiZAhzh7AhYwYuAHBB/DnbH8DY8IS9JDVtGcyG8Yy+gv/C eY3PI5wgOiTxVkH5uKTtSUzI8TZS/qlhKg+teD0DbRZeezlmw46PLK2mND06PePb5Mxr qEG9NIR5WnbGaColyGOVt/quphH4teLHOG3fs2XLB0s1BVzxU3EnriRzxBUGIhDuXYOm oaJDfcMI9VbdfAYvB0W7m/xSWGGVRPnCLWSnzFRIRPLbmiVBdAdavycmdeGw9AfQzYN3 gDvgW7MLWXOetbSl4UZfUxcrQkC0KjxRmp2RpHqV/sS2BY6jgWbAqbD7HRFkWWVZrhqZ czTw== 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=eUnD9r6UABYEGlnmE8mvDYkuB51/oGLpUMozPsW3RbM=; b=K8gkpPOP7Hr6wUAGtZ7wOky4ScgrGPaDSlN7kzr5hvsFN4+eZ67iTTZrxZ1XmWKuLn Q2JxNEHCOydpuyR4FcUF/E2bOHDXC75oSTKjoOGt2XGB7MCMq3Apk3xIPU0uYMiUUXWQ ggkcY3Ivy0/OB6ZQa+GOApDvuUDEkgdMj75wCWUOVQogyml4Ug7WX1BXB0B/0XRQBWZb c8OaV0fAsmOF8LMS4zXXkxZgGBY4+abFlnW6m+LtIGZcDpQpVumr3CXdY3vRChENtVot 51ZOmgYUhhdIWhES/aZbHA/KN2U3yLLgO6x0JupE6EbiXg8Kdd/JmuVM+wjDzdxTcCUg GDHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Vwol8j44; 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 v4si7722588edc.51.2022.02.10.00.23.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:23:15 -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=Vwol8j44; 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 1FD8982F65; Thu, 10 Feb 2022 09:23:14 +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="Vwol8j44"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 84EB18141A; Thu, 10 Feb 2022 09:23: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, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) (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 8D3B3838EC for ; Thu, 10 Feb 2022 09:13: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-pf1-x430.google.com with SMTP id i6so7000559pfc.9 for ; Thu, 10 Feb 2022 00:13: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=eUnD9r6UABYEGlnmE8mvDYkuB51/oGLpUMozPsW3RbM=; b=Vwol8j44MOj47tPxARoknWFQ5VNca1UHF/Lge+QrLFnRjU6sEYHH9asc+1dYZMbx7N 6slSJIeyPEQPj5uHiVADFr8qNuOS/EdrfLXTdAWXeWtOnk/Qb7aAQG5KE2XxBHLVtRBc fQVW7PXIBkNGzhHrAo920bUgIAN7hTmFX7TzGjl/gTyu8s925t4H2bovM2GXgTAU2GY6 yiOdw8RwyinDNnnpMOGGC4L+uhkpMF+TJAlJBMLhgoGf9lbWpQxD5fSxLdsbojFJ8XGO GD7tNlYi1aNR2d/5m+NQs9VLJ2+ZgT+QL8ePSrMnEm2ef7EHOYh7++0U846O06Eki6nA +UyA== 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=eUnD9r6UABYEGlnmE8mvDYkuB51/oGLpUMozPsW3RbM=; b=6NpASlaU2MROe9zyPQsp2Llh0PkrxS69qShFtG77JjsqPR+ZzvoPtMbTv0x0O0S76y WyQFypH5ZCWMTUOFZq9UwhKgjytVsqDEhl0soT90cY1t0O4RAeXDzWKsN7BG60EnYUHr LAuGWuHZ94hJkwDfnNSiSNGp6f/K3OPyLarx+Qd/KUbu/dwoeA2D/oDgAjpmfljy2tmw S/JiMyeE3ijZsyDfkPznKsEG3yApHgPjfa7rHCht24JRpIBPwgdALB2o4m4X9oFFgrJL l+lfGIzZNWCWQBdoK4HikqMy/sw6X+i29J7uLPMoUN6k8SWsMCsBQyiSvP0Jp30Eqnhm rifg== X-Gm-Message-State: AOAM533kVXPdS158aVahLkrLjHNzrpJagTfVicFtyFW5tnyiAWvq8k0O 17NKrBGvt8gk3/HRi8YksvVBow== X-Received: by 2002:a63:1f19:: with SMTP id f25mr5054119pgf.324.1644480800932; Thu, 10 Feb 2022 00:13:20 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:412e:384:fab9:f24]) by smtp.gmail.com with ESMTPSA id lk8sm1529208pjb.40.2022.02.10.00.13.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:13:20 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v2 19/20] efi_loader: disk: not create BLK device for BLK(IF_TYPE_EFI_LOADER) devices Date: Thu, 10 Feb 2022 17:11:23 +0900 Message-Id: <20220210081124.86612-20-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220210081124.86612-1-takahiro.akashi@linaro.org> References: <20220210081124.86612-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean When we create an efi_disk device with an UEFI application using driver binding protocol, the 'efi_driver' framework tries to create a corresponding block device(UCLASS_BLK/IF_TYPE_EFI). This will lead to calling a PROBE callback, efi_disk_probe(). In this case, however, we don't need to create another "efi_disk" device as we already have this device instance. So we should avoid recursively invoke further processing in the callback function. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- lib/efi_loader/efi_disk.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index a8cac0a002c9..5474e867533b 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -603,6 +603,7 @@ static int efi_disk_probe(void *ctx, struct event *event) { struct udevice *dev; enum uclass_id id; + struct blk_desc *desc; struct udevice *child; int ret; @@ -616,9 +617,16 @@ static int efi_disk_probe(void *ctx, struct event *event) return 0; } - ret = efi_disk_create_raw(dev); - if (ret) - return -1; + /* + * avoid creating duplicated objects now that efi_driver + * has already created an efi_disk at this moment. + */ + desc = dev_get_uclass_plat(dev); + if (desc->if_type != IF_TYPE_EFI_LOADER) { + ret = efi_disk_create_raw(dev); + if (ret) + return -1; + } device_foreach_child(child, dev) { ret = efi_disk_create_part(child); @@ -642,13 +650,17 @@ static int efi_disk_probe(void *ctx, struct event *event) static int efi_disk_delete_raw(struct udevice *dev) { efi_handle_t handle; + struct blk_desc *desc; struct efi_disk_obj *diskobj; if (dev_tag_get_ptr(dev, DM_TAG_EFI, (void **)&handle)) return -1; - diskobj = container_of(handle, struct efi_disk_obj, header); - efi_free_pool(diskobj->dp); + desc = dev_get_uclass_plat(dev); + if (desc->if_type != IF_TYPE_EFI_LOADER) { + diskobj = container_of(handle, struct efi_disk_obj, header); + efi_free_pool(diskobj->dp); + } efi_delete_handle(handle); dev_tag_del(dev, DM_TAG_EFI); From patchwork Thu Feb 10 08:11:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 541414 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp2044112imo; Thu, 10 Feb 2022 00:23:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJzh8ChvqC7wymCh6N04n1qahpvKHC2Y4Rm2JNs4ngY5Hz6K8ZZLY4EWm7aQ5EnD/VprNyMp X-Received: by 2002:a05:6402:28a4:: with SMTP id eg36mr7187180edb.288.1644481413941; Thu, 10 Feb 2022 00:23:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644481413; cv=none; d=google.com; s=arc-20160816; b=uIsNIRAfDNK1sshyNlFzzsqkA276zSdYb8iKFHbeJ4BMNQxOBH6Z1JkZKhK4z0H6cp 0bWpKzBlo8Czk+ZTJ7awZf0mLpPlkvMlUmgJMjAmeiMYXhsquWIIFNQ0umwE+KVR1rz2 W7q+fM2qhaoSyEzQ/OpoK+7LC6jIy+8+Ajka+p+k/XSFNo+hLWehvdpQHgS+dXoGeJLs r4vr2lxdqcaaxl1bqO5RNj3TrTamw1i7XIELmpWrxKfNgGzlyyGpFHEoAQHocDZyxmOc sBOav52845lap90agJ9glqT7V2HrH+sX6PgxgGUJeavDu4EegLdlCxTPHwTQO0Vfu6gx Ifvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=eYHYzsO6Ya0KXfUNViqMWI46hl0I0il0h5rYfPH5f+o=; b=IklbeXDPfaPGcXZGSDgkJdE+Ty2i+lN5BUNTZKF20dPbVhyZBAdcTSaQDlAegZWIvk xitsM6gUJwK8EtTHKRry2rreizrGtyqydyPPgrm9T2y04y6a/u5ndUCVke+Zi/ppGdjY pxEE7KS4aS0UGh1Ux5ZJ5MNDrqdB2+bgzbt3pC5MhhIxyl1wbvD1DmOhSMAUKVsOsIlO ndpAda4mvjTpOdIlCGCr1zv80eyqapqp3Y0ouMtcfZNRihQE66AynZPOfIU0SU9upk/b kBb0z7Oci+/uvuJsEqiugBz/6Ls3g3LYg0WsTrLDd6uhEZceq+t5lLoWXYecV/ESEwAp cAQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Uv/Zos9P"; 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 t21si12415672edv.651.2022.02.10.00.23.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:23:33 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Uv/Zos9P"; 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 A1C16810F3; Thu, 10 Feb 2022 09:23: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=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="Uv/Zos9P"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 27DD680F90; Thu, 10 Feb 2022 09:23: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, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) (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 3B91F83559 for ; Thu, 10 Feb 2022 09:13: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-pf1-x42e.google.com with SMTP id a39so8063296pfx.7 for ; Thu, 10 Feb 2022 00:13: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=eYHYzsO6Ya0KXfUNViqMWI46hl0I0il0h5rYfPH5f+o=; b=Uv/Zos9P9i8b9M55KQLDtbU8g8WJxsad4ivyH+2R8Kiep0wRXim1l1nBVNV2WquRfg 5Im9sRU4UJKXDaNwzl/VBWSBII1ymEH3HLKlba20ry4y5tioa8drAisLETup704JWKmT kRPjdo9mThM1fcrhOd50vZ/avOtUYzl2/fGy0Bdw55Pdzagk+yzauDyR6BAfaNG2qZdB oBKCFXGWZfTvC4HLUhRBqMp7nvBof1wcj8Jia678PX2HUa8gnDDEwg4bN4B/bsw5poi+ +Ct3d5JW8rx34yXHVsu2lTkCGfpTkBu/bDKPM/OpG/YGg+GagDIlR5NotOfSjwK2Hd7U v4HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eYHYzsO6Ya0KXfUNViqMWI46hl0I0il0h5rYfPH5f+o=; b=1XulT1zxP7NnbJ3iUl/HaOzcv0lMKEj6H8+0BVR0s43IQVH/OPpjqG3zwLl3CicN/X jEL1T3UzVi1QrxszxVc/J0s4idX5MO2j32MHAX48IB3m13b18vWClE5NbPChDFaes+Bo 8HipRyvNnNyPURcQLzoK/cyTr7PSKAzpKhyRdKeyJhG3EPD9jz+g15RKYF9gyNXkxefV LgxFQd3VsYAdDn50gklDQks4E/LTQki9f8CbN55PG6yCxpVWHHLv7h1vzUI3MGEX+1yQ ePRLhXavCNSXWnrPWYF+IZgmLZJVgSKGE3s4+vyVZecTb5oF4MIGUdEHlcKDTdyzKnC7 zhlg== X-Gm-Message-State: AOAM531hLOf4VkTDP5/y9BMLQNcwWaywBnpsHULig60L9gN6P59PpdJz Evf5QbykJNIREmU+/tZ6P5F1LQ== X-Received: by 2002:a63:d145:: with SMTP id c5mr5244868pgj.217.1644480804483; Thu, 10 Feb 2022 00:13:24 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:412e:384:fab9:f24]) by smtp.gmail.com with ESMTPSA id lk8sm1529208pjb.40.2022.02.10.00.13.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:13:24 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v2 20/20] efi_driver: align with efi_disk-dm integration Date: Thu, 10 Feb 2022 17:11:24 +0900 Message-Id: <20220210081124.86612-21-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220210081124.86612-1-takahiro.akashi@linaro.org> References: <20220210081124.86612-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean With DM-efi_disk integration, we don't need to explicitly call efi_disk_create_partitions(). The only thing to do is to associate an efi_disk object to the corresponding udevice as we skip most of processing in efi_disk_probe() by the previous commit ("efi_loader: disk: not create BLK device for BLK(IF_TYPE_EFI) devices"). Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- lib/efi_driver/efi_block_device.c | 34 +++++++++---------------------- 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/lib/efi_driver/efi_block_device.c b/lib/efi_driver/efi_block_device.c index 04cb3ef0d4e5..5baa6f87a375 100644 --- a/lib/efi_driver/efi_block_device.c +++ b/lib/efi_driver/efi_block_device.c @@ -35,6 +35,7 @@ #include #include #include +#include /* * EFI attributes of the udevice handled by this driver. @@ -106,25 +107,6 @@ static ulong efi_bl_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, return blkcnt; } -/** - * Create partions for the block device. - * - * @handle: EFI handle of the block device - * @dev: udevice of the block device - * Return: number of partitions created - */ -static int efi_bl_bind_partitions(efi_handle_t handle, struct udevice *dev) -{ - struct blk_desc *desc; - const char *if_typename; - - desc = dev_get_uclass_plat(dev); - if_typename = blk_get_if_type_name(desc->if_type); - - return efi_disk_create_partitions(handle, desc, if_typename, - desc->devnum, dev->name); -} - /** * Create a block device for a handle * @@ -139,7 +121,6 @@ static int efi_bl_bind(efi_handle_t handle, void *interface) char *name; struct efi_object *obj = efi_search_obj(handle); struct efi_block_io *io = interface; - int disks; struct efi_blk_plat *plat; EFI_PRINT("%s: handle %p, interface %p\n", __func__, handle, io); @@ -173,15 +154,20 @@ static int efi_bl_bind(efi_handle_t handle, void *interface) plat->handle = handle; plat->io = interface; + /* + * FIXME: necessary because we won't do almost nothing in + * efi_disk_create() when called from device_probe(). + */ + ret = dev_tag_set_ptr(bdev, DM_TAG_EFI, handle); + if (ret) + /* FIXME: cleanup for bdev */ + return ret; + ret = device_probe(bdev); if (ret) return ret; EFI_PRINT("%s: block device '%s' created\n", __func__, bdev->name); - /* Create handles for the partions of the block device */ - disks = efi_bl_bind_partitions(handle, bdev); - EFI_PRINT("Found %d partitions\n", disks); - return 0; }