Skip to contentSkip to conversation

use the generic dma-noncoherent code for hexagon

PATCH In review Christoph Hellwig 2 participants 11 messages Jul 19, 2018 – Aug 27, 2018 Qualcomm hexagon architecture

lore
Share & tools
lore
#0 lore raw

Hi Richard,

can you review these patches to switch hexagon to use the generic dma-noncoherent code? All the requirements are in mainline already and we've switched various architectures over to it already.

#1 lore raw

PATCH 1/3 hexagon: remove the sync_single_for_cpu DMA operation

hexagon does all the required cache maintainance at dma map time, and none at unmap time. It thus has to implement sync_single_for_device to match the map cace for buffer reuse, but there is no point in doing another invalidation in the sync_single_cpu_case, which in terms of cache maintainance is equivalent to the unmap case.

---
 arch/hexagon/kernel/dma.c | 8 --------
 1 file changed, 8 deletions(-)
arch/hexagon/kernel/dma.c +0 -8
index 77459df34e2e..d2b717f352f4 100644
@@ -181,13 +181,6 @@ static dma_addr_t hexagon_map_page(struct device *dev, struct page *page,
 	return bus;
 }
 
-static void hexagon_sync_single_for_cpu(struct device *dev,
-					dma_addr_t dma_handle, size_t size,
-					enum dma_data_direction dir)
-{
-	dma_sync(dma_addr_to_virt(dma_handle), size, dir);
-}
-
 static void hexagon_sync_single_for_device(struct device *dev,
 					dma_addr_t dma_handle, size_t size,
 					enum dma_data_direction dir)
@@ -205,7 +198,6 @@ const struct dma_map_ops hexagon_dma_ops = {
 	.free		= hexagon_free_coherent,
 	.map_sg		= hexagon_map_sg,
 	.map_page	= hexagon_map_page,
-	.sync_single_for_cpu = hexagon_sync_single_for_cpu,
 	.sync_single_for_device = hexagon_sync_single_for_device,
 	.mapping_error	= hexagon_mapping_error,
 };
Signature · 1 line
2.18.0
Acked-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] hexagon: remove the sync_single_for_cpu DMA operation

Quoted 11 lines · Christoph Hellwig

hexagon does all the required cache maintainance at dma map time, and none at unmap time. It thus has to implement sync_single_for_device to match the map cace for buffer reuse, but there is no point in doing another invalidation in the sync_single_cpu_case, which in terms of cache maintainance is equivalent to the unmap case.

---
 arch/hexagon/kernel/dma.c | 8 --------
 1 file changed, 8 deletions(-)

Patch series looks good. Definitely appreciate the cleanup.

I can take it through my tree, or if not:

Thanks!

Signature · 3 lines
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, 
a Linux Foundation Collaborative Project
#3 lore raw

Re: [PATCH 1/3] hexagon: remove the sync_single_for_cpu DMA operation

Quoted 5 lines · Richard Kuo

Patch series looks good. Definitely appreciate the cleanup.

I can take it through my tree, or if not:

Please take it through your tree, thanks!

#4 lore raw

Re: [PATCH 1/3] hexagon: remove the sync_single_for_cpu DMA operation

Quoted 8 lines · Christoph Hellwig
Quoted 5 lines · Richard Kuo

Patch series looks good. Definitely appreciate the cleanup.

I can take it through my tree, or if not:

Please take it through your tree, thanks!

I haven't seen it in linux-next yet, do you still plan to take it?

Otherwise I'll merge it in the dma-mapping tree.

#5 lore raw

Re: [PATCH 1/3] hexagon: remove the sync_single_for_cpu DMA operation

Quoted 6 lines · Christoph Hellwig
Quoted 5 lines · Christoph Hellwig
Quoted 4 lines · Richard Kuo

Patch series looks good. Definitely appreciate the cleanup.

I can take it through my tree, or if not:

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Please take it through your tree, thanks!

I haven't seen it in linux-next yet, do you still plan to take it?

Otherwise I'll merge it in the dma-mapping tree.

Given that I haven't seen this in linux-next nor haven't heard back from you I assume you are on your well deserved summer vacation.

If I don't hear back until tomorrow night I'll merge it through the dma-mapping tree, so that I have it in linux-next before heading out to my summer vacation.

#6 lore raw

Re: [PATCH 1/3] hexagon: remove the sync_single_for_cpu DMA operation

Quoted 13 lines · Christoph Hellwig
Quoted 12 lines · Christoph Hellwig
Quoted 8 lines · Christoph Hellwig
Quoted 5 lines · Richard Kuo

Patch series looks good. Definitely appreciate the cleanup.

I can take it through my tree, or if not:

Please take it through your tree, thanks!

I haven't seen it in linux-next yet, do you still plan to take it?

Quoted 8 lines
Quoted 1 line

Otherwise I'll merge it in the dma-mapping tree.

Given that I haven't seen this in linux-next nor haven't heard back from you I assume you are on your well deserved summer vacation.

If I don't hear back until tomorrow night I'll merge it through the dma-mapping tree, so that I have it in linux-next before heading out to my summer vacation.

I am here, and I have the patch queued up but it's waiting for approval before I get to push it out through my tree.

That said, I am perfectly fine with this going through a different tree if expedience is needed.

Thanks,
Richard Kuo

Signature · 3 lines
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, 
a Linux Foundation Collaborative Project
#7 lore raw

Re: [PATCH 1/3] hexagon: remove the sync_single_for_cpu DMA operation

Quoted 5 lines · Richard Kuo

I am here, and I have the patch queued up but it's waiting for approval before I get to push it out through my tree.

That said, I am perfectly fine with this going through a different tree if expedience is needed.

I just want to make sure it makes it for 4.19. In general going through the arch maintainer tree is preferred, I just don't want to lose it.

#8 lore raw

Re: [PATCH 1/3] hexagon: remove the sync_single_for_cpu DMA operation

In reply to Richard Kuo

Given that it didn't make 4.19-rc1, I'll pull this into the dma-mapping tree first thing for 4.20 as I have some other changes that will go on top of it.

#9 lore raw

PATCH 2/3 hexagon: implement the sync_sg_for_device DMA operation

In reply to Christoph Hellwig

This methods needs to provide the equivalent of sync_single_for_device for each S/G list element, but was missing.

---
 arch/hexagon/kernel/dma.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
arch/hexagon/kernel/dma.c +13 -0
index d2b717f352f4..9e46556a227d 100644
@@ -188,6 +188,18 @@ static void hexagon_sync_single_for_device(struct device *dev,
 	dma_sync(dma_addr_to_virt(dma_handle), size, dir);
 }
 
+static void hexagon_sync_sg_for_device(struct device *dev,
+		struct scatterlist *sgl, int nents, enum dma_data_direction dir)
+{
+	struct scatterlist *sg;
+	int i;
+
+	for_each_sg(sgl, sg, nents, i)
+		hexagon_sync_single_for_device(dev, sg_dma_address(sg),
+				sg->length, dir);
+}
+
+
 static int hexagon_mapping_error(struct device *dev, dma_addr_t dma_addr)
 {
 	return dma_addr == HEXAGON_MAPPING_ERROR;
@@ -199,6 +211,7 @@ const struct dma_map_ops hexagon_dma_ops = {
 	.map_sg		= hexagon_map_sg,
 	.map_page	= hexagon_map_page,
 	.sync_single_for_device = hexagon_sync_single_for_device,
+	.sync_sg_for_device = hexagon_sync_sg_for_device,
 	.mapping_error	= hexagon_mapping_error,
 };
 
Signature · 1 line
2.18.0
#10 lore raw

PATCH 3/3 hexagon: use generic dma_noncoherent_ops

In reply to Christoph Hellwig

Switch to the generic noncoherent direct mapping implementation.

---
 arch/hexagon/Kconfig                   |   2 +
 arch/hexagon/include/asm/Kbuild        |   1 +
 arch/hexagon/include/asm/dma-mapping.h |  40 -------
 arch/hexagon/kernel/dma.c              | 148 ++-----------------------
 4 files changed, 11 insertions(+), 180 deletions(-)
 delete mode 100644 arch/hexagon/include/asm/dma-mapping.h
arch/hexagon/Kconfig +2 -0
index 37adb2003033..bcbdcb32935c 100644
@@ -4,6 +4,7 @@ comment "Linux Kernel Configuration for Hexagon"
 
 config HEXAGON
 	def_bool y
+	select ARCH_HAS_SYNC_DMA_FOR_DEVICE
 	select HAVE_OPROFILE
 	# Other pending projects/to-do items.
 	# select HAVE_REGS_AND_STACK_ACCESS_API
@@ -28,6 +29,7 @@ config HEXAGON
 	select GENERIC_CLOCKEVENTS_BROADCAST
 	select MODULES_USE_ELF_RELA
 	select GENERIC_CPU_DEVICES
+	select DMA_NONCOHERENT_OPS
 	---help---
 	  Qualcomm Hexagon is a processor architecture designed for high
 	  performance and low power across a wide variety of applications.
arch/hexagon/include/asm/Kbuild +1 -0
index dd2fd9c0d292..47c4da3d64a4 100644
@@ -6,6 +6,7 @@ generic-y += compat.h
 generic-y += current.h
 generic-y += device.h
 generic-y += div64.h
+generic-y += dma-mapping.h
 generic-y += emergency-restart.h
 generic-y += extable.h
 generic-y += fb.h
arch/hexagon/include/asm/dma-mapping.h deleted +0 -40
deleted file mode 100644
index 263f6acbfb0f..000000000000
@@ -1,40 +0,0 @@
-/*
- * DMA operations for the Hexagon architecture
- *
- * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- */
-
-#ifndef _ASM_DMA_MAPPING_H
-#define _ASM_DMA_MAPPING_H
-
-#include <linux/types.h>
-#include <linux/cache.h>
-#include <linux/mm.h>
-#include <linux/scatterlist.h>
-#include <linux/dma-debug.h>
-#include <asm/io.h>
-
-struct device;
-
-extern const struct dma_map_ops *dma_ops;
-
-static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
-{
-	return dma_ops;
-}
-
-#endif
arch/hexagon/kernel/dma.c +8 -140

179 lines not on this page · raw message

Signature · 1 line
2.18.0