Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2623299pxa; Mon, 17 Aug 2020 14:41:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXKjZBRuhGDNuWM/SKET/WQk0BCn/EyQmITV419MIbnPJbp3nb429s5RLDQRXGJbSSWejl X-Received: by 2002:a17:906:6004:: with SMTP id o4mr17804118ejj.411.1597700486352; Mon, 17 Aug 2020 14:41:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597700486; cv=none; d=google.com; s=arc-20160816; b=pkCp148nTEfs9UTYFkeYqU7jAE2vG9XN56Z3tQPUKVvdpvB/b135n3y9CXc/ybkad1 /AB1o6ckmrL/3hTPAVuWO+pOdM0kQDZFJHs8liWxoNTCnTHhDgmrDBKuDqT+iZN78FBS EQ3eT1e7TPbIi2Grn0tNOH+AdLGgyp3LJjGS1H14od6YRK8hSqR2l83Y28XjZ21KSgl5 BrkdOqTf16b/HDWtBpSSERd7xJUCg269ZrukMmPCONlPhOnHlWMXEXLI5ykzi3ogFRQ/ oCXnpyqCj8FeCND3kzgSSoYhaYsZoabJjEYI+cxKg+BYr5AhpRwSed9Ne1kTnoyvOzrY Iuhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VNgvvXY87NT+88OAplb53QhvrE6ZnqmkyWsQYP62NF4=; b=o8IeipUdDZYXhxyzeTyvReiSY2q38PCG3DZCRvl+Pg/KFtdPTk1iBSGdpWFCpAT2TK tH+TfMNpM11aiqVdYVZHdj2G0MVBMr5mSuWRfGoQuKBMLTHLDzvpw3vt/pNMQw/6ZXmx xgHm+AyieXpgKEyDtZG/ZhjM8L+1XWiErfB3+KuAdJmgjLLkD9PWVG7dYKYsMGfhA2fL cUm7WlAqMixukowd6wjqzxAGLT5pOLEzt+hFd+AlokaTI/zzVHkpmo9N8aEC4IgdG9z/ aMzghWRyhDpbLV4TSkU1rIQrNJFVuMNk04KzHTZyYwmc06yKgPHU7DjkhG00N3P/aUfM c+Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="RezhYY/D"; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cb11si11632029edb.344.2020.08.17.14.41.03; Mon, 17 Aug 2020 14:41:26 -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; dkim=pass header.i=@kernel.org header.s=default header.b="RezhYY/D"; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729509AbgHQPXA (ORCPT + 99 others); Mon, 17 Aug 2020 11:23:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:45634 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729421AbgHQPWK (ORCPT ); Mon, 17 Aug 2020 11:22:10 -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 167D322B45; Mon, 17 Aug 2020 15:22:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597677729; bh=IPrxSe+zlkAV1YF+9agKI2SRHHcxYLSZAX0ZjcL2ix0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RezhYY/DQYtb/ASe3/XqLlLY0D6PGdoLMXe7CHMCVgynyKJzqLiR73vvflIkvkcGO j7zjzen5+30nR08rB3FTsQjs5kc99ZRilnyPqEQNSUtjQNvsF5PrtWPX77HvzLot31 234Q/xElnUiqrAbgQFBjyw7eGD7iQFJ6au3XCaI0= 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.8 056/464] spi: rockchip: Fix error in SPI slave pio read Date: Mon, 17 Aug 2020 17:10:09 +0200 Message-Id: <20200817143836.444580437@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143833.737102804@linuxfoundation.org> References: <20200817143833.737102804@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 9b8a5e1233c06..4776aa815c3fa 100644 --- a/drivers/spi/spi-rockchip.c +++ b/drivers/spi/spi-rockchip.c @@ -288,7 +288,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.25.1