From patchwork Wed Dec 11 13:26:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1207657 X-Patchwork-Delegate: ykai007@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="q1bdb59F"; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47XyQ459hKz9sP6 for ; Thu, 12 Dec 2019 00:26:52 +1100 (AEDT) Received: from phobos.denx.de (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 437718163B; Wed, 11 Dec 2019 14:26:42 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="q1bdb59F"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F2888814F9; Wed, 11 Dec 2019 14:26:38 +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=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) (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 121A9814F8 for ; Wed, 11 Dec 2019 14:26:36 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jagan@amarulasolutions.com Received: by mail-pl1-x644.google.com with SMTP id x17so1438970pln.1 for ; Wed, 11 Dec 2019 05:26:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gVIB5EpzB/rDAwAohidNPXnxHhhwcS3JjiItD99CNjU=; b=q1bdb59FCIwPErWWb7FBJGtn2X4XtmXfQE4V6wgCbKwF8AqJ3JUOHAVA5m8wwRzDiu I1e8fz1wWWBOgV4NliADznmDdTTKGwE93kdOUdHShkLuol32jwH+btsChBGWDbuKhdiZ 1aHAzgplq988tOfyR4oQpYsDJsMo6nnP9KDuw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gVIB5EpzB/rDAwAohidNPXnxHhhwcS3JjiItD99CNjU=; b=K0PvASGNimY1bMf81ZYFRIhyW6D414RLrMaiIm3zjGHicWygFem2BQrlqrKwEUgn6y hIF2qXmxO52Pl/rX0viQumtLH3gs1Lu8ye8DU0dJuffN8ICegP2s04kZDMKzlx4zfDun xD6FiqEoFJlz6Rf/zW8MOZry3LW79EMz59w40H5OsJXtcFq3w6T1MYse7hyNz0I14uLv uXVuUj85sAUAfi6h0D2eVqIQ+zzGqDj2gY6TiGe0R9sA/HhGmOVEpLMixVCV+1LCBg7l BousmZVNB871eYG7ywt1IVNdBKSOyQYDy2GudtTG77I4DCHSb2L5usMMHeiHGZWP5VSC iYcA== X-Gm-Message-State: APjAAAXtcuhGUCjlVZ6cf4N7bx5QxnyQlmsRmnP49uxxRoe23aghUSVg q265PZOiMBpXFjbDJr3aLwtJlQ== X-Google-Smtp-Source: APXvYqxEuSqifCyrjnHoLSgW0ud/i0zpjrs9OssyjTBkY1JzjCxNqA290D9MmhFF4RVI+rhVOUmTvQ== X-Received: by 2002:a17:90a:d682:: with SMTP id x2mr3601839pju.44.1576070794580; Wed, 11 Dec 2019 05:26:34 -0800 (PST) Received: from localhost.localdomain ([49.206.200.202]) by smtp.gmail.com with ESMTPSA id e23sm2716145pjt.23.2019.12.11.05.26.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2019 05:26:34 -0800 (PST) From: Jagan Teki To: Simon Glass , Kever Yang , Philipp Tomsich Subject: [PATCH 1/2] Revert "rockchip: spi: fix off-by-one in chunk size computation" Date: Wed, 11 Dec 2019 18:56:22 +0530 Message-Id: <20191211132623.430-2-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20191211132623.430-1-jagan@amarulasolutions.com> References: <20191211132623.430-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.26 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: u-boot@lists.denx.de, linux-amarula , linux-rockchip@lists.infradead.org Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.101.4 at phobos.denx.de X-Virus-Status: Clean The maximum transfer length (in a single transaction) for the Rockchip SPI controller is 64Kframes (i.e. 0x10000 frames) of 8bit or 16bit frames and is encoded as (num_frames - 1) in CTRLR1. So the 0x10000 is offset value for 64K but the actual size value would be 'minus 1' from 0x10000. With the existing code of 0x10000 transfer length leads to read failure when we try to read the flash with > 0x10000 size like, 1. sf read failure when with > 0x10000 2. Boot from SPI flash failed during spi_flash_read call in common/spl/spl_spi.c Observed and Tested in - Rockpro64 with Gigadevice flash - ROC-RK3399-PC with Winbond flash This reverts commit e647decdd93c7408741329432f26758fbec04c7a. Signed-off-by: Jagan Teki --- drivers/spi/rk_spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/rk_spi.c b/drivers/spi/rk_spi.c index c04535ac44..d9a310ce80 100644 --- a/drivers/spi/rk_spi.c +++ b/drivers/spi/rk_spi.c @@ -451,7 +451,7 @@ static int rockchip_spi_xfer(struct udevice *dev, unsigned int bitlen, /* This is the original 8bit reader/writer code */ while (len > 0) { - int todo = min(len, 0x10000); + int todo = min(len, 0xffff); rkspi_enable_chip(regs, false); writel(todo - 1, ®s->ctrlr1); From patchwork Wed Dec 11 13:26:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1207658 X-Patchwork-Delegate: ykai007@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="I+EFHP+d"; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47XyQH0TzDz9sP6 for ; Thu, 12 Dec 2019 00:27:03 +1100 (AEDT) Received: from phobos.denx.de (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 88F148161D; Wed, 11 Dec 2019 14:26:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="I+EFHP+d"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 857CA81657; Wed, 11 Dec 2019 14:26: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=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) (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 C87AD814F6 for ; Wed, 11 Dec 2019 14:26:38 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jagan@amarulasolutions.com Received: by mail-pg1-x543.google.com with SMTP id q127so10790344pga.4 for ; Wed, 11 Dec 2019 05:26:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ObG5oFXVgbJieCK61dlo5Mt5bEHKF5QSUTpfYMRFq74=; b=I+EFHP+dGfyQ+yElnzPem3XNKdvDDJ1k1RKkuGDLp4ikG2a8EFZYPE0FjtJx/4YLcP uQhztAX+uI9YczdqteV7KNygwOPTWxgycycdM+S/i+ucWDt6e19EWe9iokfASSuyBJuS aSYpCBADsuue7eZuUx+8P14N+aGQeCMQ2FTBc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ObG5oFXVgbJieCK61dlo5Mt5bEHKF5QSUTpfYMRFq74=; b=lSJJHUXcqamALaYSlgvJAMAsW/n/yRBj2+HO/MR3cBnp1mdqPTx9gDoRw8gOxTUdvf R60GOkiVdtZ31VQL4RhbV7WuMS7yVG43bCD3ubSbVCDOgwtGjhdYO1a0wz28EFU0XJwQ +L6Og+dc+YipgGydoN6HovpkIkqDnY+7PMSyTAgEexaYK8Ft+/lTGBSfr74MUVpjlOAw HWtW9xZj0MTUyodL8d3T7Ucz1rR2KIMJ8HodtvlgOZSDseE9wtYEc761g1ojBhcEmrBL QXPEe582uO0zgHR2viz6YfEVB7yg0K4W4A58z3EqryM9aoLbuXMV/XTdQkXOaDkHsfUv XPwg== X-Gm-Message-State: APjAAAWQEBaP86zOlS4tE16hiK+rvbcjAI2hHWEPN5Baj3dwzfVpaTnP EYEacko9U6IR2oySLcWM5e6Fig== X-Google-Smtp-Source: APXvYqwjCl5uFhWzaGrTZeEj6ejcJHd2Qhh7hVvyeS9g5X9qNJXzCKqPvUApRRlKL9jTCSwg6f+x7g== X-Received: by 2002:aa7:9808:: with SMTP id e8mr3822249pfl.32.1576070797214; Wed, 11 Dec 2019 05:26:37 -0800 (PST) Received: from localhost.localdomain ([49.206.200.202]) by smtp.gmail.com with ESMTPSA id e23sm2716145pjt.23.2019.12.11.05.26.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2019 05:26:36 -0800 (PST) From: Jagan Teki To: Simon Glass , Kever Yang , Philipp Tomsich Subject: [PATCH 2/2] spi: rk_spi: Fix overflow max chunk size Date: Wed, 11 Dec 2019 18:56:23 +0530 Message-Id: <20191211132623.430-3-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20191211132623.430-1-jagan@amarulasolutions.com> References: <20191211132623.430-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.26 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: u-boot@lists.denx.de, linux-amarula , linux-rockchip@lists.infradead.org Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.101.4 at phobos.denx.de X-Virus-Status: Clean The max chunk size (in a single transaction) for the Rockchip SPI controller is 64Kframes (i.e. 0x10000 frames) of 8bit or 16bit frames and is encoded as (num_frames - 1) in CTRLR1. So the 0x10000 is offset value for 64K but the actual size value would be 'minus 1' from 0x10000. With the existing code of 0x10000 max chunk size leads to read failure when we try to read the flash with > 0x10000 size like, 1. sf read failure when with > 0x10000 2. Boot from SPI flash failed during spi_flash_read call in common/spl/spl_spi.c Observed and Tested in - Rockpro64 with Gigadevice flash - ROC-RK3399-PC with Winbond flash Signed-off-by: Jagan Teki --- drivers/spi/rk_spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/rk_spi.c b/drivers/spi/rk_spi.c index d9a310ce80..6059f2415a 100644 --- a/drivers/spi/rk_spi.c +++ b/drivers/spi/rk_spi.c @@ -367,7 +367,7 @@ static inline int rockchip_spi_16bit_reader(struct udevice *dev, * represented in CTRLR1. */ if (data && data->master_manages_fifo) - max_chunk_size = 0x10000; + max_chunk_size = 0xffff; // rockchip_spi_configure(dev, mode, size) rkspi_enable_chip(regs, false);