Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp340146ybl; Fri, 9 Aug 2019 06:50:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqxTsDpKaKp6mqnslM8A4PXY6Y4LEE4DeOgfNjNTJdwfJzqfDhUDJ53ASEv1dD0raEo2Bu9f X-Received: by 2002:a17:902:8a87:: with SMTP id p7mr19121617plo.124.1565358609376; Fri, 09 Aug 2019 06:50:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565358609; cv=none; d=google.com; s=arc-20160816; b=CvR5M3N3XtZoxKZTH3UL0I65rDaL5hmW3BcD2j2a9ZBMRhtHf6Cm0zJMgoBiTr1Dnb hw9xCg4BJF13607tM1w4m6zs8ucxn8cuvYBcoZWwvIDszTit7cLvNFccllhFv9cJ2VYt 6GHrrmu+JJkjDN8ba2CymEQBi1C7IS1GKm+FNXw8VX7dFNKDohpd3lDKLVEGxAT3wPBq gsi7TR7cHbEsUXdzOYFsS4RcY53Nvre5pQepNie0fJJQY7tf7V3oHImE4l6t+9fCZ5fd OHNpU/ecW3boXFjmlp0O13RAqY+gulqgVTv+jeKZG+I2OAMHFBQ0IXaBO7Qx10tKSFM9 NU5w== 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=nTP1YeIA0OVO53tkKVQLhypvqKJ2TVtM6hm+uXmfSYFGxRqTvjoBbOJxdgneY8pEaa ZlxDbhSFlABcpd0teTJZNnpAjl5T8LfrjOAvDlNXVgtfm5vI92jDu7Yhoo47HTBVxTnr HDYGEXwMYjaU7ctk4zUIlibp8o55DFOUd2riNQ9FJjmHtlxGYCZ0PkCzFZ4jLV85Hsox 0zvZ7Jc341SmQtiJ8IkjXlVaQbvKBexeDhdbK48oMHKHYUIQTM2b4t+SnUz/1aAD1G/B 95q1EIdD1lafbguJpnsjY5czCFK+gUfES5WjGXLmxi5qcyyg4+b5P1GLncgTG5OPA0YA L5Og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Yek1Y90z; 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 r16si52670149pgv.466.2019.08.09.06.49.53; Fri, 09 Aug 2019 06:50:09 -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=Yek1Y90z; 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 S2407317AbfHINsg (ORCPT + 99 others); Fri, 9 Aug 2019 09:48:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:37506 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2407254AbfHINr3 (ORCPT ); Fri, 9 Aug 2019 09:47:29 -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 1C7A72086D; Fri, 9 Aug 2019 13:47:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565358448; bh=9I+jFTe4CVg4SBn5kIG4JbU+BfzvJ6nCCHzgfhtmeII=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yek1Y90zATwVsSSv58GiD7fAcmOepLO67y8iotRaNAzI2gjs0GtgtJP7U4UoJAATv JduTGwM+jAjdFdglSsQrEzCXfKjN6l7C+C4b09r1rI9/vcz9C3eZO26d5VNK047DWK 1lF6552bIBBFbIICfd2ixbVoU6MArSxqEDVBvzz0= 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.9 27/32] spi: bcm2835: Fix 3-wire mode if DMA is enabled Date: Fri, 9 Aug 2019 15:45:30 +0200 Message-Id: <20190809133923.804420993@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190809133922.945349906@linuxfoundation.org> References: <20190809133922.945349906@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;