From patchwork Thu Oct 20 08:34:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dhruva Gole X-Patchwork-Id: 1692296 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.a=rsa-sha256 header.s=ti-com-17Q1 header.b=VSaPVqIY; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MtLWF4LByz1ygT for ; Thu, 20 Oct 2022 19:34:47 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7BD9884DCD; Thu, 20 Oct 2022 10:34:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="VSaPVqIY"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3196C84DE2; Thu, 20 Oct 2022 10:34:34 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 719D584C7D for ; Thu, 20 Oct 2022 10:34:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=d-gole@ti.com Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 29K8YSR0051231; Thu, 20 Oct 2022 03:34:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1666254868; bh=uThWmSQRW+aOZFETKnY0Nzg9aDlbdGlFnkcqbsh04Nk=; h=From:To:CC:Subject:Date; b=VSaPVqIY1J3ajNZJqqiWmk9goe+3n33mvG1aNo8yGu+y3Ur0DfzvJfsZlscgbBbiw n/397amjGJl048sBLXyGOid3qqj93NOQLy9+FjoMDZBtRv3MpqxObad+fKkxeh6YGM 1chAsvycwoXabEI6yVuxcHgadG7nRfL+4pA+NUb4= Received: from DLEE103.ent.ti.com (dlee103.ent.ti.com [157.170.170.33]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 29K8YR4X031520 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 20 Oct 2022 03:34:27 -0500 Received: from DLEE108.ent.ti.com (157.170.170.38) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.6; Thu, 20 Oct 2022 03:34:27 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.6 via Frontend Transport; Thu, 20 Oct 2022 03:34:27 -0500 Received: from localhost (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 29K8YQW1066370; Thu, 20 Oct 2022 03:34:26 -0500 From: Dhruva Gole To: Tom Rini CC: Vaishnav Achath , Nishanth Menon , Dhruva Gole , Vignesh Raghavendra , Subject: [PATCH] spi: spi-mem: ease checks in dtr_supports_op() Date: Thu, 20 Oct 2022 14:04:24 +0530 Message-ID: <20221020083424.86848-1-d-gole@ti.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 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 Remove the extra conditions that cause some cases to fail prematurely like if the data number of bytes is odd. The controller can handle odd number of bytes data read in DTR Mode. Don't fail supports op for this condition. Signed-off-by: Dhruva Gole --- For a deeper context, refer to a cover letter from an earlier patch series: https://lore.kernel.org/u-boot/20221019064759.493607-1-d-gole@ti.com/T/#m3fd93bdcc30b3b5faada6abe45a4104388afc300 Here, I am trying to boot from OSPI Flash present on board the AM62-SK EVM. However, despite enabling the necessary configs and DT nodes, my boot flow seemed to be failing. I then came to know that the condition causing this failure was that my generated DTB was of odd number of bytes. So, while loading the dtb from the Octal SPI NOR Flash to the memory, the data.nbytes was odd which made the supports_op function return false. This check feels a little too strict at the spi-mem stage and we should let the controller decide what to do in case of odd bytes in DTR. After applying this patch, I was able to succesfully boot the AM62SK EVM without any issues. I would also like to justify this patch by pointing the community to the equivalent code in the linux kernel, in drivers/spi/spi-mem.c, where this check is absent as well. The controller does work with odd number of bytes and I have not seen any sort of bugs in the absence of this supports_op check. Hence, feel that it is safe enough to discard this check from here. drivers/spi/spi-mem.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c index 8e8995fc537f..eecc13bec90d 100644 --- a/drivers/spi/spi-mem.c +++ b/drivers/spi/spi-mem.c @@ -181,10 +181,6 @@ bool spi_mem_dtr_supports_op(struct spi_slave *slave, if (op->dummy.nbytes && op->dummy.buswidth == 8 && op->dummy.nbytes % 2) return false; - if (op->data.dir != SPI_MEM_NO_DATA && - op->dummy.buswidth == 8 && op->data.nbytes % 2) - return false; - return spi_mem_check_buswidth(slave, op); } EXPORT_SYMBOL_GPL(spi_mem_dtr_supports_op);