From patchwork Mon Aug 17 15:11:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 266457 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F25EAC433DF for ; Mon, 17 Aug 2020 15:42:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B534522CAE for ; Mon, 17 Aug 2020 15:42:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597678963; bh=e8/hC67URr55Z95bIdmfp2EdNaPne94nAC6wdFLFnB4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=QDt8EpsxUl/Bs4xvWAZ0G6qJMiIPyq1oiwPZnbbR/NENXXKVvBWvnbrxlHK4OLVeC QeFNtaKPW3Xs5R40HuQKNmO7XN+1ViPxOOx9qvb8snvLtJQP73V4AY1ODEh0VPr+tO nrop26aES/NHj5fPfELkeDjXj0AIXX4gdrj1YNR4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387568AbgHQPmm (ORCPT ); Mon, 17 Aug 2020 11:42:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:52824 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387566AbgHQPmk (ORCPT ); Mon, 17 Aug 2020 11:42:40 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 37A7A22BF3; Mon, 17 Aug 2020 15:42:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597678959; bh=e8/hC67URr55Z95bIdmfp2EdNaPne94nAC6wdFLFnB4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1KK2qOV1Q9zI//feRKDcYbQ13/h6rNfl0wAmKGkt9MAxu48ZTrktp8SAngbZht5Pn k6AEJXQd9tdFiAruHra71TCYV6ujKU1lz4UBqfcWti6uY2pFYu205XjWeJy7S7zztl eDPpXqNmZfodkoQ0njW8QFuuU3xyYi1aZRqNF8PE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jon Lin , Emil Renner Berthing , Heiko Stuebner , Mark Brown , Sasha Levin Subject: [PATCH 5.7 048/393] spi: rockchip: Fix error in SPI slave pio read Date: Mon, 17 Aug 2020 17:11:38 +0200 Message-Id: <20200817143821.946229031@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143819.579311991@linuxfoundation.org> References: <20200817143819.579311991@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jon Lin [ Upstream commit 4294e4accf8d695ea5605f6b189008b692e3e82c ] 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 Tested-by: Emil Renner Berthing Reviewed-by: Heiko Stuebner Reviewed-by: Emil Renner Berthing Link: https://lore.kernel.org/r/20200723004356.6390-3-jon.lin@rock-chips.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- 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 70ef63e0b6b8d..02e9205355910 100644 --- a/drivers/spi/spi-rockchip.c +++ b/drivers/spi/spi-rockchip.c @@ -286,7 +286,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