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 C91FAC4332F for ; Wed, 12 Oct 2022 00:31:06 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CCA8C84DAA; Wed, 12 Oct 2022 02:31:03 +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="V+K4O7nL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2845C84D9F; Wed, 12 Oct 2022 02:31:01 +0200 (CEST) Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D3DB284D2F for ; Wed, 12 Oct 2022 02:30:56 +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-pj1-x102a.google.com with SMTP id pq16so13904726pjb.2 for ; Tue, 11 Oct 2022 17:30:56 -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:message-id:reply-to; bh=MdzC2EyiW0rRnzYc113HT0i+dHgYZSzeAuDlKZQoiOQ=; b=V+K4O7nLdh9GMsB0bRlGf3Juh/Edrd3K9x0TOG3qoZV2P9biWXznlxAmVbKKohpXqY jP8Qv1JoJmg4FEIRnRzh6T6w3HxFxdfCyxjMUW5BL/J/3HMgGf61x15eBZ+JLxMjkXHV KMCn21qR6uGcgit8BD9zcyt7Tq+KKXx18ySUX3Huun9/Kxox6EXpA3Z1Db9lJl80bi/w R6Hd7twSMtpzjav5vVJBQXg09alomwcLTAfUuJ4OopRprjkO4edW1qSJ4DekKhK57vWH Iq49VKZv3QeahuJcR0VzDCsQnwJa1sffA2wIA8sQGPeNEwZyhVbVdxdX6a7jLG4mWC5K jd6A== 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:message-id:reply-to; bh=MdzC2EyiW0rRnzYc113HT0i+dHgYZSzeAuDlKZQoiOQ=; b=ug5U+YZxf02xr4K8aptJYqbyhJuvL9XJ1C6WLivoSpc1+Wf0jzNvCHPq4dLMmo/kdW 6QvazG1c4uS67/fGh9DvX89j1GmHFDp0MCsI6tWCzaeHuNb6Bwl97BdYXJPhBkkhrv9P iUNWxcc9BQ0s92sasu/DgRs2svz9Bn3/Q3+dxBmMVJlAX1tLALXzNEXwPPsBho/X4Xte mfNi3vYc+K2bDZ2vFeaSUSJ/znH9CJfNLAzHtj7PtKbqKw6/b2L4FJ2ZVtl9EGw2J/hV m7kaFyNSBv83Cz2VXXazrmLfakDYPNCri1R524HGkgZmw6H5vvD+E8V0bdMhZJO8PG8l wZOg== X-Gm-Message-State: ACrzQf1QM9lB705TzKyMT/PjNo8CMjueZPw57HPZThZVBTRmdtGCTY08 iK1YBxcvd1P4vwTI4jZIL13BrQ== X-Google-Smtp-Source: AMsMyM5L/BMJ2NLdju8q4VQlq0U68pvQHG00L8sVKEBLX7RBtKdA7zPkzQYRDBGXQhZcjQy/kDr00A== X-Received: by 2002:a17:90a:b28d:b0:20d:6790:19fa with SMTP id c13-20020a17090ab28d00b0020d679019famr2014635pjr.68.1665534655027; Tue, 11 Oct 2022 17:30:55 -0700 (PDT) Received: from laputa ([2400:4050:c3e1:100:886e:2a2f:de1a:53f4]) by smtp.gmail.com with ESMTPSA id y8-20020a17090322c800b00176b63535adsm9294208plg.260.2022.10.11.17.30.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 17:30:54 -0700 (PDT) Date: Wed, 12 Oct 2022 09:30:50 +0900 From: AKASHI Takahiro To: Simon Glass Cc: Heinrich Schuchardt , U-Boot Mailing List , Ilias Apalodimas Subject: Re: [PATCH 1/1] dm: fix blk_get_devnum_by_uclass_idname() Message-ID: <20221012003050.GC49651@laputa> Mail-Followup-To: AKASHI Takahiro , Simon Glass , Heinrich Schuchardt , U-Boot Mailing List , Ilias Apalodimas References: <684aecdd-6882-a9a5-906f-69653b7a2348@canonical.com> <04f240d7-4c57-a35e-b793-860324b3a09e@canonical.com> <59d9f769-408b-e4ec-258a-1d5a65aba204@canonical.com> <2b9b1e7c-9331-4d8d-796c-da2a6b3ca6c7@canonical.com> <728cbb5f-1636-8bec-52be-927630f942a7@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Tue, Oct 11, 2022 at 03:54:32PM -0600, Simon Glass wrote: > Hi Heinrich, > > On Tue, 11 Oct 2022 at 14:17, Heinrich Schuchardt > wrote: > > > > On 10/11/22 16:16, Simon Glass wrote: > > > Hi Heinrich, > > > > > > On Tue, 11 Oct 2022 at 04:38, Heinrich Schuchardt > > > wrote: > > >> > > >> > > >> > > >> On 10/11/22 07:46, Heinrich Schuchardt wrote: > > >>> > > >>> > > >>> On 10/11/22 01:49, Simon Glass wrote: > > >>>> Hi Heinrich, > > >>>> > > >>>> On Thu, 6 Oct 2022 at 14:05, Heinrich Schuchardt > > >>>> wrote: > > >>>>> > > >>>>> On 10/3/22 18:44, Simon Glass wrote: > > >>>>>> Hi Heinrich, > > >>>>>> > > >>>>>> On Mon, 3 Oct 2022 at 10:33, Heinrich Schuchardt > > >>>>>> wrote: > > >>>>>>> > > >>>>>>> > > >>>>>>> > > >>>>>>> On 10/3/22 16:57, Simon Glass wrote: > > >>>>>>>> Hi Heinrich, > > >>>>>>>> > > >>>>>>>> On Mon, 3 Oct 2022 at 03:36, Heinrich Schuchardt > > >>>>>>>> wrote: > > >>>>>>>>> > > >>>>>>>>> On the sandbox I run: > > >>>>>>>>> > > >>>>>>>>> => setenv efi_selftest block device > > >>>>>>>>> => bootefi selftest > > >>>>>>>>> > > >>>>>>>>> and see the following output: > > >>>>>>>>> > > >>>>>>>>> ** Bad device specification host 0 ** > > >>>>>>>>> Couldn't find partition host 0:0 > > >>>>>>>>> Cannot read EFI system partition > > >>>>>>>>> > > >>>>>>>>> Running > > >>>>>>>>> > > >>>>>>>>> => lsblk > > >>>>>>>>> > > >>>>>>>>> yields > > >>>>>>>>> > > >>>>>>>>> Block Driver Devices > > >>>>>>>>> ----------------------------- > > >>>>>>>>> efi_blk : efiloader 0 > > >>>>>>>>> ide_blk : > > >>>>>>>>> mmc_blk : mmc 2, mmc 1, mmc 0 > > >>>>>>>>> nvme-blk : > > >>>>>>>>> sandbox_host_blk : > > >>>>>>>>> scsi_blk : > > >>>>>>>>> usb_storage_blk : > > >>>>>>>>> virtio-blk : > > >>>>>>>>> > > >>>>>>>>> So a efi_blk device was mistaken for a host device. > > >>>>>>>>> > > >>>>>>>>> I continue with > > >>>>>>>>> > > >>>>>>>>> => host bind 0 ../sandbox.img > > >>>>>>>>> => ls host 0:1 > > >>>>>>>>> > > >>>>>>>>> and get the following output: > > >>>>>>>>> > > >>>>>>>>> 13 hello.txt > > >>>>>>>>> 7 u-boot.txt > > >>>>>>>>> > > >>>>>>>>> 2 file(s), 0 dir(s) > > >>>>>>>>> > > >>>>>>>>> This is the content of efiblock 0:1 and not of host 0:1 (sic!). > > >>>>>>>>> > > >>>>>>>>> The uclass of the parent device is irrelevant for the > > >>>>>>>>> determination of the > > >>>>>>>>> uclass of the block device. We must use the uclass stored in the > > >>>>>>>>> block > > >>>>>>>>> device descriptor. > > >>>>>>>>> > > >>>>>>>>> This issue has been raised repeatedly: > > >>>>>>>>> > > >>>>>>>>> [PATCH 1/1] block: fix blk_get_devnum_by_typename() > > >>>>>>>>> https://lore.kernel.org/u-boot/20220802094933.69170-1-heinrich.schuchardt@canonical.com/ > > >>>>>>>>> [PATCH 1/1] blk: simplify blk_get_devnum_by_typename() > > >>>>>>>>> https://lore.kernel.org/u-boot/20211023140647.7661-1-heinrich.schuchardt@canonical.com/ > > >>>>>>>> > > >>>>>>>> Yes and you were not able/willing to take on the required work, so > > >>>>>>>> this carried on longer than it should have. I finally did this myself > > >>>>>>>> and it is now in -next. > > >>>>>>> > > >>>>>>> The refactoring was orthogonal to the problem that I reported and > > >>>>>>> which > > >>>>>>> you unfortunately did not consider in the process. > > >>>>>> > > >>>>>> Well it involved using if_type to work around a problem, just making > > >>>>>> it harder to get rid of. Overall I am in favour of a faster pace of > > >>>>>> migration that we have been following and it would help if people took > > >>>>>> on some of this, instead of fixing their little issue. > > >>>>>> > > >>>>>>> > > >>>>>>>> > > >>>>>>>> So we might finally be able to fix this problem properly, since > > >>>>>>>> if_type is mostly just a work-around concept in -next, with just the > > >>>>>>>> fake uclass_id being used at present. > > >>>>>>>> > > >>>>>>>> Can you use if_type_to_uclass_id() here, which is the work-around > > >>>>>>>> function for now? > > >>>>>>> > > >>>>>>> This function does not exist in origin/next. We won't apply this patch > > >>>>>>> in the 2022-10 cycle. > > >>>>>> > > >>>>>> I think I mean conv_uclass_id() which is the new name. > > >>>>>> > > >>>>>>> > > >>>>>>> Let's fix the bug first before thinking about future refactoring. > > >>>>>>> > > >>>>>>> You may determine the uclass ID for field bdev in struct blk_desc > > >>>>>>> using > > >>>>>>> function device_get_uclass_id() when refactoring. > > >>>>>> > > >>>>>> So if you call conv_uclass_id() (without any other refactoring) does > > >>>>>> that fix the problem? > > >>>>> > > >>>>> Except for UCLASS_USB that function is a NOP. How could it help to > > >>>>> differentiate between devices with the same parent device? > > >>>> > > >>>> It can't. But the root node should not have UCLASS_BLK children. I > > >>>> think I mentioned that a few months back? > > >>>> > > >>>>> > > >>>>> Would you agree that blk_get_devnum_by_uclass_idname() should not look > > >>>>> at the parent but on the actual device? > > >>>> > > >>>> No, looking at the parent is exactly what it should do. A block device > > >>>> is generic, to the extent possible. Its methods are implemented in the > > >>>> parent uclass and are tightly bound to it. See for example > > >>>> U_BOOT_DRIVER(mmc_blk) in the MMC uclass. > > >>> > > >>> Let's look at an MMC device > > >>> > > >>> root_driver/soc/mmc@1c0f000/mmc@1c0f000.blk is a block device. > > >>> > > >>> What do we need to find out that it can be addressed as mmc 0? The > > >>> driver is mmc_blk and its index is 0. We don't need any information > > >>> about the parent device at all. > > > > > > If blk is the MMC block device, the fact that is mmc 0 is determined > > > by dev_seq(dev_get_parent(blk)). We are not parsing strings to find > > > that out. It is part of the design. > > > > > >>> > > >>>> > > >>>> Unfortunately this confusion is my fault since I used the root device > > >>>> for the sandbox block devices. That was a convenience and a way to > > >>>> reduce somewhat the crushing load of driver model migration. But the > > >>>> time for that convenience is gone and we should create a sandbox host > > >>>> parent node for the sandbox block devices and tidy up EFI too. > > >>> > > >>> The only confusion is in the current blk_get_devnum_by_uclass_idname() > > >>> code looking into the parent device. > > >>> > > >>> The parent device is totally irrelevant here. Stop using it. > > > > > > See below. > > > > > >> > > >> You already noted when writing conv_uclass_id() that using the uclass > > >> name does not work properly to find out the CLI name of a devie. > > >> > > >> Can we put the CLI name for device types ("mmc", "scsi" ...) into struct > > >> blk_ops? Then we have a clear separation of the block device from the > > >> parent device. > > > > > > There really isn't any separation in driver model...the parent device > > > does determine the type of the block device. It creates the block > > > device, using its own uclass. See for example mmc-uclass.c in > > > mmc_bind(): > > > > > > ret = blk_create_devicef(dev, "mmc_blk", "blk", UCLASS_MMC, > > > dev_seq(dev), 512, 0, &bdev); > > > > > > The following fields in blk_desc will be dropped at some point: > > > > > > - uclass_id since it is the same as the parent* > > > - bdev (point to block device) since we will stop passing around > > > blk_desc and will use the block device instead > > > - devnum since it is the save as dev_seq(blk) > > > > > > * Except for the USB weirdness in conv_uclass_id() which we need to fix > > > > > > Why do you want this 'separation'? Is this another strange EFI thing > > > due to it not using driver model properly? > > > > > > Also you have not yet replied to my point about needing to create a > > > parent 'media' device for every block device. That is also part of the > > > design. Have you done that for EFI, or is your reluctance to do that > > > behind continued discussions and misalignments on UCLASS_BLK ? > > > > If I look at physical devices for MMC I might find: > > > > SoC -> PCI root -> MMC controller -> SD card > > > > What you call MMC parent device is the MMC controller. > > > > This is also what can easily modeled as a device path in EFI. > > OK good. That covers all devices in U-Boot present, I believe. > > > > > In the case of an iSCSI drive provided by iPXE U-boot would provide a > > network device which currently has a device path VenHW(root)/MAC(). > > > > iPXE creates a virtual network card VenHW(root)/MAC()/MAC() consuming > > the services of the physical one. > > > > Next it creates a virtual device VenHW(root)/MAC()/MAC()/IPv6() which > > exposes the block IO protocol for reading the iSCSI drive. > > > > The parent for the block device in the EFI world is a network interface. > > But the block operations are provided by the block IO protocol which is > > provided by the virtual device that iPXE has created and not by a > > network interface. So the parent is irrelevant here. > > Then the virtual device should be the parent? Are we trying to skip > one level of hierarchy? +1 IMO, the virtual device is a handle (in UEFI term) of UEFI application, i.e. iPXE since it actually implements and provides block IO protocol. In this sense, I don't think that the current implementation of efi_driver is appropriate. (I mentioned this in the past.) What I'm not sure, however, is whether the network device card should be a *parent* of the application because application may potentially implement functionality other than block IO using another device. Furthermore, what I don't understand yet is what the hierarchy of DM tree means for parent-children relationship other than block device case. -Takahiro Akashi > > > > Sure you could create a single root2 device as parent for all efi_loader > > devices like you have root for the host devices. But such a device would > > have no functionality at all except carrying a dummy Uclass to store the > > CLI string "efiblk" for all of its children. > > I don't think it should be a root2 device. It should really be a child > of the network device, so far as I understand what you have written > above. > > > > > Why can't we have the CLI string for the device type in the driver's > > struct blk_ops? > > It isn't just about the CLI string. It's also about having a sensible > device hierarchy with 'dm tree', being able to put things in the > device tree in a sensible way, etc. This feels like a symptom of the > lack of alignment between EFI and driver model. > > +Ilias Apalodimas please do see if you can help here. > > Regards, > Simon