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 B0971C76196 for ; Tue, 28 Mar 2023 14:24:07 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DCA79857BC; Tue, 28 Mar 2023 16:24:04 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=baylibre.com 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=baylibre-com.20210112.gappssmtp.com header.i=@baylibre-com.20210112.gappssmtp.com header.b="FPwFNjQy"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A41D5857BD; Tue, 28 Mar 2023 16:24:01 +0200 (CEST) Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) (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 5932C85746 for ; Tue, 28 Mar 2023 16:23:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=mkorpershoek@baylibre.com Received: by mail-wr1-x431.google.com with SMTP id h17so12394610wrt.8 for ; Tue, 28 Mar 2023 07:23:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; t=1680013438; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=OtM88Aqst0LR0A2msxwsGtFtsJdAo+WQAHmV4EZyvyM=; b=FPwFNjQyYd6D4IeXvlrXVSelrlFmsjLhNAgbepJ0xWFbqFeC9RWkV9EVsAVpbkxf7a Y7YVFW4HWIL6SbBfd84ywyIG1+kmbNiKsvny1izMx0kItYM6K1qz7mCfICKgWHzo9oYt T5m8KE/WiuvugC/JuTrwNtX6U0d/T5zFSOTFesu+ZCV8qP+u+UJbY4TqxcEGnFp9+Um0 reJxCcoLmr7AjIMYumkuX0L+zQdYwHRfQLVpBCRC3sGaSGJiB9qBqQXHi+n5stojXy9K kbYMLoCjsA7QdxYK76JoYJpoVuhe9p/AF7Bb/YzWQ9TO7Q+91W/XeKHD8e7C4L1tfk0l 2fdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680013438; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=OtM88Aqst0LR0A2msxwsGtFtsJdAo+WQAHmV4EZyvyM=; b=lBa/3zZXt3YLkhMcwXuDWKvlvWzE+yG0bUPPpMnvVn87mgwVMA4PRivhUcoaPJkV/U GGbrv211AaEoX9JPQGgAxLfYZzse7jaIcs/fDJ8VETXZEEHS96ZGZp372w5i/XKObyil EEBrwMVs3vQ4i5MYRNOHDg6IRsnQdvBFiN8/MR/eBQKRv6nRcr+JIsMxY5lH1u7MPIIi mbW0IOvFjoGuBp4ky/4GP64rmwIRCtRMPZmqo8zb9BPhSXMmuyXjsyteuhZlL6EqvxtD LXy9hejuBNXPiCP5a2HsXGbFQRwgTXmj8ii33fPyIXhtoglOXRRwflpuwbBHrE/xtiVM yTDQ== X-Gm-Message-State: AAQBX9dBI4G2elhCrlz233LG4oTOrdry8GMNJq8IVzREtOYji9n+zIhV h4TNVdtlsiOmBYl7nepRJkNyww== X-Google-Smtp-Source: AKy350YbQ/yjgZ6jmXrFRV3F01D25OmtetRJ/phOrAh8ccOlumZBtAT2ksRQud7PiUfMHuz6Cxh0gw== X-Received: by 2002:a5d:4381:0:b0:2d8:a7df:bce9 with SMTP id i1-20020a5d4381000000b002d8a7dfbce9mr11378781wrq.23.1680013437785; Tue, 28 Mar 2023 07:23:57 -0700 (PDT) Received: from localhost ([82.66.159.240]) by smtp.gmail.com with ESMTPSA id e4-20020a5d4e84000000b002ceac2ccc4asm27841562wru.23.2023.03.28.07.23.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Mar 2023 07:23:57 -0700 (PDT) From: Mattijs Korpershoek To: Simon Glass , U-Boot Mailing List Cc: Bin Meng , Simon Glass , Heinrich Schuchardt Subject: Re: [PATCH 10/30] ide: Correct use of ATAPI In-Reply-To: <20230328080702.10.Ia41ab329f6a5b52b15e58c5f405ce07c5b5545d1@changeid> References: <20230327190717.1796230-1-sjg@chromium.org> <20230328080702.10.Ia41ab329f6a5b52b15e58c5f405ce07c5b5545d1@changeid> Date: Tue, 28 Mar 2023 16:23:20 +0200 Message-ID: <87jzz10xbb.fsf@baylibre.com> MIME-Version: 1.0 Content-Type: text/plain 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.8 at phobos.denx.de X-Virus-Status: Clean On mar., mars 28, 2023 at 08:06, Simon Glass wrote: > The use of atapi_read() was incorrect dropped. Fix this so that it will > be used when needed. Use a udevice for the first argument of atapi_read() > so it is consistent with ide_read(). > > This requires much of the ATAPI code to be brought out from behind the > existing #ifdef. It will still be removed by the compiler if it is not > needed. > > Add an atapi flag to struct blk_desc so the information can be retained. > > Fixes: 145df842b44 ("dm: ide: Add support for driver-model block devices") > Fixes: d0075059e4d ("ide: Drop non-DM code for BLK") > > Signed-off-by: Simon Glass Reviewed-by: Mattijs Korpershoek > --- > > drivers/block/ide.c | 20 +++++++++++++++++--- > include/blk.h | 1 + > 2 files changed, 18 insertions(+), 3 deletions(-) > > diff --git a/drivers/block/ide.c b/drivers/block/ide.c > index fa5f68ffeb01..875192cba163 100644 > --- a/drivers/block/ide.c > +++ b/drivers/block/ide.c > @@ -155,7 +155,6 @@ OUT: > *last = '\0'; > } > > -#ifdef CONFIG_ATAPI > /**************************************************************************** > * ATAPI Support > */ > @@ -422,9 +421,10 @@ error: > #define ATAPI_READ_BLOCK_SIZE 2048 /* assuming CD part */ > #define ATAPI_READ_MAX_BLOCK (ATAPI_READ_MAX_BYTES/ATAPI_READ_BLOCK_SIZE) > > -ulong atapi_read(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt, > +ulong atapi_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, > void *buffer) > { > + struct blk_desc *block_dev = dev_get_uclass_plat(dev); > int device = block_dev->devnum; > ulong n = 0; > unsigned char ccb[12]; /* Command descriptor block */ > @@ -466,6 +466,8 @@ ulong atapi_read(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt, > return n; > } > > +#ifdef CONFIG_ATAPI > + > static void atapi_inquiry(struct blk_desc *dev_desc) > { > unsigned char ccb[12]; /* Command descriptor block */ > @@ -653,6 +655,7 @@ static void ide_ident(struct blk_desc *dev_desc) > > #ifdef CONFIG_ATAPI > if (is_atapi) { > + dev_desc->atapi = true; > atapi_inquiry(dev_desc); > return; > } > @@ -1010,6 +1013,17 @@ WR_OUT: > return n; > } > > +ulong ide_or_atapi_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, > + void *buffer) > +{ > + struct blk_desc *desc = dev_get_uclass_plat(dev); > + > + if (IS_ENABLED(CONFIG_ATAPI) && desc->atapi) > + return atapi_read(dev, blknr, blkcnt, buffer); > + > + return ide_read(dev, blknr, blkcnt, buffer); > +} > + > static int ide_blk_probe(struct udevice *udev) > { > struct blk_desc *desc = dev_get_uclass_plat(udev); > @@ -1029,7 +1043,7 @@ static int ide_blk_probe(struct udevice *udev) > } > > static const struct blk_ops ide_blk_ops = { > - .read = ide_read, > + .read = ide_or_atapi_read, > .write = ide_write, > }; > > diff --git a/include/blk.h b/include/blk.h > index 1db203c1baba..871922dcde07 100644 > --- a/include/blk.h > +++ b/include/blk.h > @@ -66,6 +66,7 @@ struct blk_desc { > /* device can use 48bit addr (ATA/ATAPI v7) */ > unsigned char lba48; > #endif > + unsigned char atapi; /* Use ATAPI protocol */ > lbaint_t lba; /* number of blocks */ > unsigned long blksz; /* block size */ > int log2blksz; /* for convenience: log2(blksz) */ > -- > 2.40.0.348.gf938b09366-goog