Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp934138ybh; Wed, 22 Jul 2020 17:44:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJA1o6OPidDpkGJ6cnhsIakJIy4wQp9Dsp/vSrRCcuSrg8IG00VueuhSGq0N/qfrRGM5T3 X-Received: by 2002:a17:906:ecb6:: with SMTP id qh22mr1909050ejb.230.1595465097980; Wed, 22 Jul 2020 17:44:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595465097; cv=none; d=google.com; s=arc-20160816; b=qKCBLGPWzKEAjR98ZwZAZsKLUlqBwU5P2WxN1Be5PDqLzz+w6JZpCnvKvUEwcXKI4R WUB/g8Uvfbhm3PG/VHqAwZcZQI9soda7vAC0qd2XmHEpR8TlGAQjIqKrjvRqWgCrLqLu WIbpLp9KYBcoPr4plBI6s6r8fJ6Y0u9jVTuHezJs26l+XysVfB2u2BK31Zi5AddA5HFO jdrQPPiBPd/FIuOG/V1y5GqTnG4C9zRI5evHFQrAkUpEHdwWicDbf/sA3KjL24qt6HUh cEMpS8BuhNleTcLlxWlaciq1EYJnX6zjTSBTOEFBfn2uIaxHrzrK3e9yFIetGcDjxwQB 2iLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=Badsa9gBhBNbuI48acVdZbu/qKlE1FkVnM0AwpsWyYQ=; b=XQJEHlb8Rtflva3MTJBp+yyKzAz8iyoAedzBXz4BdS5W+jGyfjLed2VDyQQsodq4X8 dhYtm/rf8oLBaND+CNMDVZgTYgYIHacVhgdmdzs8o78USMJmkbAzBT5rEz841d+RFJV2 8tNcHkVnHuhPWSudIMzZ9Ows/CHvUfm+saHVBPbG4o3cqS4U90zMywMwp5Kf11My09YL /rm/+0n2Kp2hiCYlfeKmlU7b6Zk0BN8f0EwGedA1EQCAha7Q9xGoSSzhDegzgVGVpjIg qNMHKJuJbInHNyLAbhjLraUdmgPL/bilwoBRN+ZxNslbytNUAR3ZkleAErKI7xNi5vlx 1/VA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r22si922237edq.411.2020.07.22.17.44.35; Wed, 22 Jul 2020 17:44:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733232AbgGWAoI (ORCPT + 99 others); Wed, 22 Jul 2020 20:44:08 -0400 Received: from lucky1.263xmail.com ([211.157.147.133]:58990 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726685AbgGWAoH (ORCPT ); Wed, 22 Jul 2020 20:44:07 -0400 Received: from localhost (unknown [192.168.167.209]) by lucky1.263xmail.com (Postfix) with ESMTP id 20FE2C5767; Thu, 23 Jul 2020 08:44:03 +0800 (CST) X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-ADDR-CHECKED4: 1 X-ANTISPAM-LEVEL: 2 X-ABS-CHECKED: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (postfix) whith ESMTP id P17009T140099499042560S1595465038112439_; Thu, 23 Jul 2020 08:44:02 +0800 (CST) X-IP-DOMAINF: 1 X-UNIQUE-TAG: <41dae99cf031fc69e412229f78683b26> X-RL-SENDER: jon.lin@rock-chips.com X-SENDER: jon.lin@rock-chips.com X-LOGIN-NAME: jon.lin@rock-chips.com X-FST-TO: broonie@kernel.org X-SENDER-IP: 58.22.7.114 X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 X-System-Flag: 0 From: Jon Lin To: broonie@kernel.org Cc: heiko@sntech.de, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@esmil.dk, Jon Lin Subject: [PATCH v3 3/3] spi: rockchip: Fix error in SPI slave pio read Date: Thu, 23 Jul 2020 08:43:56 +0800 Message-Id: <20200723004356.6390-3-jon.lin@rock-chips.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200723004356.6390-1-jon.lin@rock-chips.com> References: <20200723004356.6390-1-jon.lin@rock-chips.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The RXFLR is possible larger than rx_left in Rockchip SPI, fix it. Fixes: 01b59ce5dac8 ("spi: rockchip: use irq rather than polling") Signed-off-by: Jon Lin Reviewed-by: Heiko Stuebner Reviewed-by: Emil Renner Berthing Tested-by: Emil Renner Berthing --- drivers/spi/spi-rockchip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c index a451dacab5cf..75a8a9428ff8 100644 --- a/drivers/spi/spi-rockchip.c +++ b/drivers/spi/spi-rockchip.c @@ -291,7 +291,7 @@ static void rockchip_spi_pio_writer(struct rockchip_spi *rs) static void rockchip_spi_pio_reader(struct rockchip_spi *rs) { u32 words = readl_relaxed(rs->regs + ROCKCHIP_SPI_RXFLR); - u32 rx_left = rs->rx_left - words; + u32 rx_left = (rs->rx_left > words) ? rs->rx_left - words : 0; /* the hardware doesn't allow us to change fifo threshold * level while spi is enabled, so instead make sure to leave -- 2.17.1