From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0E1ACC07E9D for ; Tue, 27 Sep 2022 01:51:31 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 73D1C84E24; Tue, 27 Sep 2022 03:51:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="YbetUQ/m"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7251984E32; Tue, 27 Sep 2022 03:51:27 +0200 (CEST) Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4E03C84E1E for ; Tue, 27 Sep 2022 03:51:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pf1-x42c.google.com with SMTP id d10so7278981pfh.6 for ; Mon, 26 Sep 2022 18:51:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date; bh=V4m0zmL11lZm8ZdnSodieYzsu9l8xqJqTtNP/GwGdvk=; b=YbetUQ/mI+RHrywV1X8IIZLP6PszlHvi3GMpv0Vz9BTtD63zqcaUpJ67QE43kiz1JH /LnESbBM6RkyQAtkZ1AsRRhCxf3nbhy+izr/sZFQ5xRfIOEUyGcs811LCeGMZD9yNV9v fdwDTwhapaOFMb5WN5zZXvTLB9A/IIMRbs8Dli3JBAqKbRwznGVZk6rqbTb9bZ9IShbX gMjESgMlbZhjIYXS/BckU/2/d99F3hBwSoMzN0lIzdEcLVcVv8SS/1yhmKdBerKUjETc Q6J0oOCfZpjW3xByj0I2lev5bOEB8aOH32Z6rOdnD2Qe9orocmFlNyB8T+vT726Npk8g YpUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date; bh=V4m0zmL11lZm8ZdnSodieYzsu9l8xqJqTtNP/GwGdvk=; b=acADlUqt8qSGL1APpz0XtsQwWDnZLN9DssiXNxtiSqHmZ+yVSyrMps0hL6ucPTGUx+ eHpRKWULhlKKoYXWZNkKPfTUqNKTkbGF8J4eZ1tCZlPTHKacRFVoQwgN/2abmkJ9QFaB NElgmd5/uEiwk0a+b42sKga6kOrYYrLSqa5ElwCFR+q0RjMlz3Ymve1JdZsgg4Sogani mj59QFCJZjKZhH5fD1Gw9U1idEISX04Ie7teq9Gd7QlS355my1q3GO4zmBBoYIuviIKy EL0C8AU3rAtyqqiy5dozIaPfX33Gjt7T+kpBhV0/abKK8UONOxVVlZSZ9awy4sDm1NcJ mqrA== X-Gm-Message-State: ACrzQf3EydP9IlCkHt1z6MpnG89/jueoHuyYa7FRRXNLcTmRQay7OF4E t2ZWODRMU36G16O1XNK6/UJ3Yw== X-Google-Smtp-Source: AMsMyM5wppBiLEqBUPgwiv0RLmP5cIrGkkXynf2BED89hTpiIjWO+E9YOU9tCMoPK46hgAIIM9QkOA== X-Received: by 2002:a63:1b4d:0:b0:439:db24:a3a6 with SMTP id b13-20020a631b4d000000b00439db24a3a6mr22709167pgm.539.1664243482373; Mon, 26 Sep 2022 18:51:22 -0700 (PDT) Received: from laputa ([2400:4050:c3e1:100:835a:afba:269b:b6fb]) by smtp.gmail.com with ESMTPSA id d12-20020a17090a564c00b001efa9e83927sm7103543pji.51.2022.09.26.18.51.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 18:51:21 -0700 (PDT) Date: Tue, 27 Sep 2022 10:51:17 +0900 From: AKASHI Takahiro To: Heinrich Schuchardt Cc: Simon Glass , Ilias Apalodimas , Masahisa Kojima , u-boot@lists.denx.de Subject: Re: [PATCH 0/2] efi_loader: provide media ID Message-ID: <20220927015117.GA34139@laputa> Mail-Followup-To: AKASHI Takahiro , Heinrich Schuchardt , Simon Glass , Ilias Apalodimas , Masahisa Kojima , u-boot@lists.denx.de References: <20220915200242.18358-1-heinrich.schuchardt@canonical.com> <20220916005805.GA45676@laputa> <933e5bf9-1eef-3e8b-c55d-dad943f9177f@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <933e5bf9-1eef-3e8b-c55d-dad943f9177f@canonical.com> 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.6 at phobos.denx.de X-Virus-Status: Clean On Mon, Sep 26, 2022 at 08:06:52AM +0200, Heinrich Schuchardt wrote: > > > On 9/16/22 02:58, AKASHI Takahiro wrote: > > On Thu, Sep 15, 2022 at 10:02:40PM +0200, Heinrich Schuchardt wrote: > > > The medium a device like 'mmc 0' or 'usb 0' points to may change over > > > time. Hence device type and number are not sufficient to identify the > > > inserted medium. The same is true for the device path generated for > > > such a device. > > > > Well, it depends on how a device path is generated in U-Boot's UEFI > > implementation. I believe that a device path represents an "unique path" > > to a given device however this device is enumerated. > > In this sense, the current dp_fill()/efi_dp_from_part() is not a right > > implementation as it relies on device numbers. > > Furthermore, a generated device path here is different from one generated > > by EDK2 (even if both software are run on the same board). > > > > This is an issue that I used to tackle in > > https://lists.denx.de/pipermail/u-boot/2021-November/468216.html > > although I have since had no progress. > > > > > This is why the EFI_BLOCK_IO_PROTOCOL provides a field > > > MediaId. > > > > > > Whenever a removable medium is changed or a new block device with a > > > previously used device path is created we should provide a different > > > MediaID. > > > > > > This series adds a field media_id to the block device descriptor and fills > > > it after probing. The value of the field is then copied to the > > > EFI_BLOCK_IO_PROTOCOL. > > > > I'm afraid that your patch doesn't always work as you expect. > > When "scsi rescan" or "usb stop; usb start", for instance, is invoked, > > all the existing devices and associated blk_desc structures are once freed > > and even if nothing is changed, i.e. a device is neither removed nor added, > > the exact same structures will be re-created. > > With your patch applied, however, a new (and different) "media_id" will be > > assigned to an existing device. UEFI User may be notified of "media change". > > (To be honest, this is quite unlikely because the current UEFI implementation > > doesn't use BLOCK_IO_PROTOCOL internally, say, for file system access.) > > This behavior matches what EDK II does if you remove a device and create a > new device. I don't think that EDK2 has "scsi rescan" or others, which users can invoke at any time. Moreover, I believe that EDK2 code (drivers) checks whether a device is really changed or not before updating a MediaId. > If a device is removed and recreated anything could have happened in between > like complete repartitioning. We cannot assume that any cached state is > valid anymore even if GUIDs are the same. I'm not sure if you fully understand my point. My assumption is the case where a device is NOT removed around "scsi rescan" (or usb stop/start) and stays online. In this case, 1. access to, say, "scsi 0:1", via UEFI BLOCK_IO succeeds 2. "scsi rescan" 3. access to the same device, "scsi 0:1", via UEFI BLOCK_IO currently (3) succeeds, but with your patch, it may potentially fail because of media_id altered. I admit that it will not happen under the current UEFI implementation because non of UEFI applications will survive across command lines and none of information, including media_id or handle, can be carried over from (1) to (3). But unconditionally incrementing an internally-held media_id, as in your patch, is a wrong behavior. -Takahiro Akashi > > So it is correct to change the media ID in this case. > Commands like scsi rescan are needed because we don't monitor media changes > in the DM drivers yet. Simon's suggestion to use provide an event for media > changes looks like the right approach to me. > > Best regards > > Heinrich > > > > > -Takahiro Akashi > > > > > With future patches we can refine this in sub-systems like USB, MMC, SCSI > > > to indicate media changes > > > > > > Heinrich Schuchardt (2): > > > dm: blk: assign media ID to block devices > > > efi_loader: fill media_id from block device descriptor > > > > > > drivers/block/blk-uclass.c | 16 +++++++++++++++- > > > include/blk.h | 11 +++++++++++ > > > lib/efi_loader/efi_disk.c | 6 +----- > > > 3 files changed, 27 insertions(+), 6 deletions(-) > > > > > > -- > > > 2.37.2 > > >