Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp7234025ybh; Thu, 8 Aug 2019 12:14:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqwx2V5C5muliVVWkoJSLw1hJAkgb6L8cUKg9jgG6CjFOxZ9kA24k47MHygvojYPtvD8mbbX X-Received: by 2002:a17:90a:77c5:: with SMTP id e5mr5389890pjs.109.1565291677616; Thu, 08 Aug 2019 12:14:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565291677; cv=none; d=google.com; s=arc-20160816; b=Ufbw43gI4HFKtepJ3/TE9dR/eSzq1q4urEKNb9tJyEZMtt0C7kvTlFhTGvBb8VP3/7 2HqHIOEil8fVgOhrCz/JKB+KWoZg5li2NVoGjGceZ0RNfHxP9n0RJX6my4X9F9R/aHV4 TfQmiTC0CeNrABgr2x8hv/nvGUuzC8F5fu6gpUteClhs3sDbqYnru1dc/sbRnJFH20GQ vj6ExQgXE41XY0tUefwaAxk3gj3f3TqC5SbXsBUY7pQcJaxXy4OTUSRKm1t4KkR5jg6v eOgLAZEdpSIRuGjs26ZXjj4lbJogXW+mpd2huhUYMnrd4guUqX9BM0+pGSR46i4xE1Ss cujg== 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=+dy6iIFpteOqIxWFDYGf/9MhJo3WPAjo3Dg9HygN/WQ=; b=oIWr6K2HmfYQglQ/a7gce8t9Lfj87+/hOzHImIlZVUBcu0YcMsRx0hvnQZG/jtGEYb U/REvouBJxW/nAVXxLtfgNGTCPVx+T5wci0jlZ4aM4xa6eCdoWOX3eOisy596ZvpFyOj leJSJMDnGRl00cadW103cifxY4ECKDx6tL/mkPXAB9sUXdK9mH4MPPRrJAnRnFendgSx HwAVPJAYUmWUMgysSSE9jWq92kB0taX+OMtyY0BSjHH2PxKeDy4M57Qa8Xlds3lHwWPI iKeAOWO9CEov/zDbJnl+JDU3jdJeCAcx25tElPOgjnxXILy/706Oqb6vqEE8i7Vg0QLb RCwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=htyD47eA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y4si53273921pfq.222.2019.08.08.12.14.22; Thu, 08 Aug 2019 12:14:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=htyD47eA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405553AbfHHTLu (ORCPT + 99 others); Thu, 8 Aug 2019 15:11:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:46422 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404932AbfHHTLr (ORCPT ); Thu, 8 Aug 2019 15:11:47 -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 5E2352173E; Thu, 8 Aug 2019 19:11:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565291506; bh=9I+jFTe4CVg4SBn5kIG4JbU+BfzvJ6nCCHzgfhtmeII=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=htyD47eA7NZ288D0IeGLT5CxIKGGotRcwhcNWcFwbw+vVehs0Feziwui4PQSCxcD0 BiDXra195k12Tlae4pv+y2uOPhdtQSbYSQv1vqbQeUFlVKiHuDAWAYlcZ48WgMPupJ gpkmo9eNu6bwbwXX7Z1wPULHh1Yh0tXPuoQx5pUk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Nuno=20S=C3=A1?= , Lukas Wunner , Martin Sperl , Stefan Wahren , Mark Brown Subject: [PATCH 4.14 33/33] spi: bcm2835: Fix 3-wire mode if DMA is enabled Date: Thu, 8 Aug 2019 21:05:40 +0200 Message-Id: <20190808190455.331001839@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190808190453.582417307@linuxfoundation.org> References: <20190808190453.582417307@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: Lukas Wunner commit 8d8bef50365847134b51c1ec46786bc2873e4e47 upstream. Commit 6935224da248 ("spi: bcm2835: enable support of 3-wire mode") added 3-wire support to the BCM2835 SPI driver by setting the REN bit (Read Enable) in the CS register when receiving data. The REN bit puts the transmitter in high-impedance state. The driver recognizes that data is to be received by checking whether the rx_buf of a transfer is non-NULL. Commit 3ecd37edaa2a ("spi: bcm2835: enable dma modes for transfers meeting certain conditions") subsequently broke 3-wire support because it set the SPI_MASTER_MUST_RX flag which causes spi_map_msg() to replace rx_buf with a dummy buffer if it is NULL. As a result, rx_buf is *always* non-NULL if DMA is enabled. Reinstate 3-wire support by not only checking whether rx_buf is non-NULL, but also checking that it is not the dummy buffer. Fixes: 3ecd37edaa2a ("spi: bcm2835: enable dma modes for transfers meeting certain conditions") Reported-by: Nuno Sá Signed-off-by: Lukas Wunner Cc: stable@vger.kernel.org # v4.2+ Cc: Martin Sperl Acked-by: Stefan Wahren Link: https://lore.kernel.org/r/328318841455e505370ef8ecad97b646c033dc8a.1562148527.git.lukas@wunner.de Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- drivers/spi/spi-bcm2835.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/spi/spi-bcm2835.c +++ b/drivers/spi/spi-bcm2835.c @@ -554,7 +554,8 @@ static int bcm2835_spi_transfer_one(stru bcm2835_wr(bs, BCM2835_SPI_CLK, cdiv); /* handle all the 3-wire mode */ - if ((spi->mode & SPI_3WIRE) && (tfr->rx_buf)) + if (spi->mode & SPI_3WIRE && tfr->rx_buf && + tfr->rx_buf != master->dummy_rx) cs |= BCM2835_SPI_CS_REN; else cs &= ~BCM2835_SPI_CS_REN;