From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aaro Koskinen Subject: Re: [PATCH] of/device: Really only set bus DMA mask when appropriate Date: Tue, 6 Nov 2018 21:16:56 +0200 Message-ID: <20181106191655.GB14958@darkstar.musicnaut.iki.fi> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=m.gmane.org@lists.infradead.org To: Robin Murphy Cc: devicetree@vger.kernel.org, linux-mips@linux-mips.org, jean-philippe.brucker@arm.com, iommu@lists.linux-foundation.org, robh+dt@kernel.org, john.stultz@linaro.org, hch@lst.de, linux-arm-kernel@lists.infradead.org, m.szyprowski@samsung.com List-Id: devicetree@vger.kernel.org Hi, On Tue, Nov 06, 2018 at 11:54:15AM +0000, Robin Murphy wrote: > of_dma_configure() was *supposed* to be following the same logic as > acpi_dma_configure() and only setting bus_dma_mask if some range was > specified by the firmware. However, it seems that subtlety got lost in > the process of fitting it into the differently-shaped control flow, and > as a result the force_dma==true case ends up always setting the bus mask > to the 32-bit default, which is not what anyone wants. > > Make sure we only touch it if the DT actually said so. > > Fixes: 6c2fb2ea7636 ("of/device: Set bus DMA mask as appropriate") > Reported-by: Aaro Koskinen > Reported-by: Jean-Philippe Brucker > Signed-off-by: Robin Murphy Tested-by: Aaro Koskinen This fixes the MMC driver DMA mask issue on OCTEON. Thanks, A. > --- > > Sorry about that... I guess I only have test setups that either have > dma-ranges or where a 32-bit bus mask goes unnoticed :( > > The Octeon and SMMU issues sound like they're purely down to this, and > it's probably related to at least one of John's Hikey woes. > > Robin. > > drivers/of/device.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/of/device.c b/drivers/of/device.c > index 0f27fad9fe94..757ae867674f 100644 > --- a/drivers/of/device.c > +++ b/drivers/of/device.c > @@ -149,7 +149,8 @@ int of_dma_configure(struct device *dev, struct device_node *np, bool force_dma) > * set by the driver. > */ > mask = DMA_BIT_MASK(ilog2(dma_addr + size - 1) + 1); > - dev->bus_dma_mask = mask; > + if (!ret) > + dev->bus_dma_mask = mask; > dev->coherent_dma_mask &= mask; > *dev->dma_mask &= mask; > > -- > 2.19.1.dirty > From mboxrd@z Thu Jan 1 00:00:00 1970 Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 06 Nov 2018 20:17:01 +0100 (CET) Received: from emh03.mail.saunalahti.fi ([62.142.5.109]:48624 "EHLO emh03.mail.saunalahti.fi" rhost-flags-OK-OK-OK-OK) by eddie.linux-mips.org with ESMTP id S23992824AbeKFTQ6DQWlr (ORCPT ); Tue, 6 Nov 2018 20:16:58 +0100 Received: from darkstar.musicnaut.iki.fi (85-76-84-88-nat.elisa-mobile.fi [85.76.84.88]) by emh03.mail.saunalahti.fi (Postfix) with ESMTP id 4F4E440037; Tue, 6 Nov 2018 21:16:56 +0200 (EET) Date: Tue, 6 Nov 2018 21:16:56 +0200 From: Aaro Koskinen To: Robin Murphy Cc: hch@lst.de, robh+dt@kernel.org, m.szyprowski@samsung.com, jean-philippe.brucker@arm.com, john.stultz@linaro.org, iommu@lists.linux-foundation.org, devicetree@vger.kernel.org, linux-mips@linux-mips.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] of/device: Really only set bus DMA mask when appropriate Message-ID: <20181106191655.GB14958@darkstar.musicnaut.iki.fi> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Return-Path: X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0) X-Orcpt: rfc822;linux-mips@linux-mips.org Original-Recipient: rfc822;linux-mips@linux-mips.org X-archive-position: 67103 X-ecartis-version: Ecartis v1.0.0 Sender: linux-mips-bounce@linux-mips.org Errors-to: linux-mips-bounce@linux-mips.org X-original-sender: aaro.koskinen@iki.fi Precedence: bulk List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: linux-mips X-List-ID: linux-mips List-subscribe: List-owner: List-post: List-archive: X-list: linux-mips Hi, On Tue, Nov 06, 2018 at 11:54:15AM +0000, Robin Murphy wrote: > of_dma_configure() was *supposed* to be following the same logic as > acpi_dma_configure() and only setting bus_dma_mask if some range was > specified by the firmware. However, it seems that subtlety got lost in > the process of fitting it into the differently-shaped control flow, and > as a result the force_dma==true case ends up always setting the bus mask > to the 32-bit default, which is not what anyone wants. > > Make sure we only touch it if the DT actually said so. > > Fixes: 6c2fb2ea7636 ("of/device: Set bus DMA mask as appropriate") > Reported-by: Aaro Koskinen > Reported-by: Jean-Philippe Brucker > Signed-off-by: Robin Murphy Tested-by: Aaro Koskinen This fixes the MMC driver DMA mask issue on OCTEON. Thanks, A. > --- > > Sorry about that... I guess I only have test setups that either have > dma-ranges or where a 32-bit bus mask goes unnoticed :( > > The Octeon and SMMU issues sound like they're purely down to this, and > it's probably related to at least one of John's Hikey woes. > > Robin. > > drivers/of/device.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/of/device.c b/drivers/of/device.c > index 0f27fad9fe94..757ae867674f 100644 > --- a/drivers/of/device.c > +++ b/drivers/of/device.c > @@ -149,7 +149,8 @@ int of_dma_configure(struct device *dev, struct device_node *np, bool force_dma) > * set by the driver. > */ > mask = DMA_BIT_MASK(ilog2(dma_addr + size - 1) + 1); > - dev->bus_dma_mask = mask; > + if (!ret) > + dev->bus_dma_mask = mask; > dev->coherent_dma_mask &= mask; > *dev->dma_mask &= mask; > > -- > 2.19.1.dirty > From mboxrd@z Thu Jan 1 00:00:00 1970 From: aaro.koskinen@iki.fi (Aaro Koskinen) Date: Tue, 6 Nov 2018 21:16:56 +0200 Subject: [PATCH] of/device: Really only set bus DMA mask when appropriate In-Reply-To: References: Message-ID: <20181106191655.GB14958@darkstar.musicnaut.iki.fi> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Hi, On Tue, Nov 06, 2018 at 11:54:15AM +0000, Robin Murphy wrote: > of_dma_configure() was *supposed* to be following the same logic as > acpi_dma_configure() and only setting bus_dma_mask if some range was > specified by the firmware. However, it seems that subtlety got lost in > the process of fitting it into the differently-shaped control flow, and > as a result the force_dma==true case ends up always setting the bus mask > to the 32-bit default, which is not what anyone wants. > > Make sure we only touch it if the DT actually said so. > > Fixes: 6c2fb2ea7636 ("of/device: Set bus DMA mask as appropriate") > Reported-by: Aaro Koskinen > Reported-by: Jean-Philippe Brucker > Signed-off-by: Robin Murphy Tested-by: Aaro Koskinen This fixes the MMC driver DMA mask issue on OCTEON. Thanks, A. > --- > > Sorry about that... I guess I only have test setups that either have > dma-ranges or where a 32-bit bus mask goes unnoticed :( > > The Octeon and SMMU issues sound like they're purely down to this, and > it's probably related to at least one of John's Hikey woes. > > Robin. > > drivers/of/device.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/of/device.c b/drivers/of/device.c > index 0f27fad9fe94..757ae867674f 100644 > --- a/drivers/of/device.c > +++ b/drivers/of/device.c > @@ -149,7 +149,8 @@ int of_dma_configure(struct device *dev, struct device_node *np, bool force_dma) > * set by the driver. > */ > mask = DMA_BIT_MASK(ilog2(dma_addr + size - 1) + 1); > - dev->bus_dma_mask = mask; > + if (!ret) > + dev->bus_dma_mask = mask; > dev->coherent_dma_mask &= mask; > *dev->dma_mask &= mask; > > -- > 2.19.1.dirty >