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: 11284925 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4E25615AB for ; Wed, 11 Dec 2019 13:26:41 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2974B208C3 for ; Wed, 11 Dec 2019 13:26:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="fsktAnSA"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="q1bdb59F" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2974B208C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bB/rrTNuN1Erh7fNWqlAUv+ev1XpLdLTqz9CosyKBpY=; b=fsktAnSAQm4mgP VzhfVJnhvl8UJpXcJZR89QJZpVZtEsCrZH8GqrC14tsLRSEWu2Ad0GRbMeBZTJk/+QfcdUmWiHGcA glox/eUNIQYz1dge4/n+NKzINwtGQvMNAIjID/vru9Tfa78fHanqD1bsqO5YEUv67JCnQ6pemKlHG z3/5F01plAw2k0fVRruvqgTcz5c/+mAIA9NOYfPl2CUeW771ZQy8sEMlNRBct/lSSwQ15p08QQuYu ZPjuOvy87G3oUhJlehtZF+kF1U49yqqnYUr4cR63tDzPkyhtWPVhDwiLtJiiystN8yzy8lY/NM90I V7dxJJF27Tf/CCtChfUw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1if20k-0007Yf-V9; Wed, 11 Dec 2019 13:26:38 +0000 Received: from mail-pj1-x1041.google.com ([2607:f8b0:4864:20::1041]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1if20h-0007XF-CX for linux-rockchip@lists.infradead.org; Wed, 11 Dec 2019 13:26:36 +0000 Received: by mail-pj1-x1041.google.com with SMTP id g4so8937670pjs.10 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=iECl4ZbbEFrEw4DO/PrXJPSHMySbWjR9f1Ze79N+66x54mLTm5BZp+w9FpelFXfNqr Iy311f0rEPQqlPkCYSTjxDgknIdGRf7AM4s1RaT+v1tkaHYuxlbZo6PMprf2vSbOQVy+ XqvmhPzCihxdTle2dvQyZOWya4B9AgE37Vw2K5FLUGUhwCPf9fRTJvuwhBwQ0EEZDkJE n8p/KytSgK2dQkwVkW60tbTvNscR/vk9PyL4s7H4s1GuhkWXyVWpwqqOEcmoE+g9Y2a/ Qxabk4d3btZux+x5W5Vtpx3LMgLzhy9jZe4TmsAem2vDRZQ7E6LVE8cj5HUtkwXPY9Lu /xMg== X-Gm-Message-State: APjAAAU66CdFR6SIBDH9Vctke/WvrqTA7OOYBzUY8hVObHY4qMSFjlxY vjQWPGyfJ6eAwxze/MKCPWo/GQ== 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191211_052635_427059_6CBF3179 X-CRM114-Status: GOOD ( 12.05 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: u-boot@lists.denx.de, linux-amarula , Jagan Teki , linux-rockchip@lists.infradead.org Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org 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: 11284927 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 66F2E15AB for ; Wed, 11 Dec 2019 13:26:43 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 44ED0208C3 for ; Wed, 11 Dec 2019 13:26:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="QLAEKdKt"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="I+EFHP+d" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 44ED0208C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=VKiIFIjXgEe/blLJInwgGjZQc6om0z4nAXqhZEKI/TY=; b=QLAEKdKtVk8NKj kmR2JRV/U35eflnKGuX5nJlG63hOeGCY7thNxk+ZJyniuvrw1M5370r1Zej5L/3tpuxPI1x5cqdod WIkPzVw0l/8gqOHZG3XthVm6lo9w2Zo5tIxT3KpjOQlWyryho+hW6kOYtYKAC13SUheg6gMQkr5OT cKBdsGumngXovQS5K+0Wl9hJWS0af1hWBR8YpKW8yx0MuiDXaKUhR4Lj0EvthvHWaXLpfiRUU2gHJ cnvilAoakoqEEOf8Vbv+SEVzmb7M0JlvCfpj1QgcILO3Ln2/CYKDbViaAgw5hWS0p8eYbasPx/dnP /ljuXPrmWP88fYh5r4Dg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1if20m-0007aE-Jy; Wed, 11 Dec 2019 13:26:40 +0000 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1if20j-0007Y1-VR for linux-rockchip@lists.infradead.org; Wed, 11 Dec 2019 13:26:39 +0000 Received: by mail-pf1-x442.google.com with SMTP id x185so1824262pfc.5 for ; Wed, 11 Dec 2019 05:26:37 -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=Z+5pBolsFWECajHT764tUCrI32bc3PpzXaN+gVIwy3usex+T84ESJYGfZFSlSZx5m2 GLFeM4n3d8ZR6smD61AKyvVSuHq8JNt553iQSbvLoel5eeE5UvxjLi715qW5Ky12I35b imm9iGjNrto4OaHMIdc7jRRwncvo6w6p0kzWVN58ADSqzfvHZjmfPs/4yVgcHRRpkQ9m dv8Vmb/BzTDB3GWFyFoz6vjZDwTk6wGnP3kA01DaVqBSaWctVIXc0K5Bdw5hjYVvwqmd XkoKWGb/dMbAlKKRzr5ZkAt+qkMJFPR4PnHUSnzzAbCZmZqBWdS/zqxNpDhq4A95dUsL 75PA== X-Gm-Message-State: APjAAAWnjuhvkjlhr9wvnDJl4C7SQeICJ0XUQsZrkpH2UV9FrwIXhWmx c4R8glIbG4ZIcQPnhB2vYO8pfg== 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191211_052638_024314_83DBCA14 X-CRM114-Status: GOOD ( 11.93 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:442 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: u-boot@lists.denx.de, linux-amarula , Jagan Teki , linux-rockchip@lists.infradead.org Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org 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);