Skip to contentSkip to conversation

bugfix based on csky linux-next

PATCH Superseded Guo Ren 2 participants 9 messages Sep 18, 2018 – Sep 25, 2018

Subsystems (2)

v7 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

Guo Ren

author
#0 lore raw

v7 cover bugfix based on csky linux-next

Because I've sent to Stephen Roth with the linux-4.19-rc3 git-tree for linux-next, I shouldn't rebase any more.

- Fixup smp.c irq mapping problem found by Marc Zyngier
- Fixup dma_sync_for_cpu/device in dma-mapping.c

Guo Ren (2):
csky/dma: bugfix dma_sync_for_cpu/device
csky: remove irq_mapping from smp.c.

 arch/csky/include/asm/smp.h |  4 ++++
 arch/csky/kernel/smp.c      | 18 +++++++++++++-----
 arch/csky/mm/dma-mapping.c  |  5 +++--
 3 files changed, 20 insertions(+), 7 deletions(-)
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH v7 1/2 csky/dma: bugfix dma_sync_for_cpu/device

ref: https://lkml.org/lkml/2018/5/18/1068

        map             for_cpu         for_device      unmap
TO_DEV  writeback       none            writeback       none
TO_CPU  invalidate      invalidate*     invalidate      invalidate*
BIDIR   writeback       invalidate      writeback       invalidate
---
 arch/csky/mm/dma-mapping.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/csky/mm/dma-mapping.c +3 -2
index 16c2087..30a2041 100644
@@ -217,7 +217,8 @@ void arch_sync_dma_for_device(struct device *dev, phys_addr_t paddr,
 		break;
 	case DMA_FROM_DEVICE:
 	case DMA_BIDIRECTIONAL:
-		BUG();
+		dma_wbinv_range(vaddr + offset, vaddr + offset + size);
+		break;
 	default:
 		BUG();
 	}
@@ -240,7 +241,7 @@ void arch_sync_dma_for_cpu(struct device *dev, phys_addr_t paddr,
 
 	switch (dir) {
 	case DMA_TO_DEVICE:
-		BUG();
+		break;
 	case DMA_FROM_DEVICE:
 	case DMA_BIDIRECTIONAL:
 		dma_wbinv_range(vaddr + offset, vaddr + offset + size);
Signature · 1 line
2.7.4
author
#6 lore raw

PATCH v7 2/2 csky: remove irq_mapping from smp.c.

In reply to Guo Ren

- remove irq_mapping from smp.c to irq-driver
- Add set_ipi_irq_mapping api to irq-driver
- update asm/smp.h

---
 arch/csky/include/asm/smp.h |  4 ++++
 arch/csky/kernel/smp.c      | 18 +++++++++++++-----
 2 files changed, 17 insertions(+), 5 deletions(-)
arch/csky/include/asm/smp.h +4 -0
index 9a53abf..fed3a5a 100644
@@ -7,6 +7,8 @@
 
 #ifdef CONFIG_SMP
 
+#define IPI_IRQ	15
+
 void __init setup_smp(void);
 
 void __init setup_smp_ipi(void);
@@ -19,6 +21,8 @@ void arch_send_call_function_single_ipi(int cpu);
 
 void __init set_send_ipi(void (*func)(const unsigned long *, unsigned long));
 
+void __init set_ipi_irq_mapping(int (*func)(void));
+
 #define raw_smp_processor_id()	(current_thread_info()->cpu)
 
 #endif /* CONFIG_SMP */
arch/csky/kernel/smp.c +13 -5
index 522c73f..f8343f6 100644
@@ -20,8 +20,6 @@
 #include <asm/mmu_context.h>
 #include <asm/pgalloc.h>
 
-#define IPI_IRQ	15
-
 static struct {
 	unsigned long bits ____cacheline_aligned;
 } ipi_data[NR_CPUS] __cacheline_aligned;
@@ -121,13 +119,23 @@ void __init enable_smp_ipi(void)
 	enable_percpu_irq(IPI_IRQ, 0);
 }
 
+static int (*arch_ipi_irq_mapping)(void) = NULL;
+
+void __init set_ipi_irq_mapping(int (*func)(void))
+{
+	if (arch_ipi_irq_mapping)
+		return;
+
+	arch_ipi_irq_mapping = func;
+}
+
 void __init setup_smp_ipi(void)
 {
-	int rc;
+	int rc, irq;
 
-	irq_create_mapping(NULL, IPI_IRQ);
+	irq = arch_ipi_irq_mapping();
 
-	rc = request_percpu_irq(IPI_IRQ, handle_ipi, "IPI Interrupt", &ipi_dummy_dev);
+	rc = request_percpu_irq(irq, handle_ipi, "IPI Interrupt", &ipi_dummy_dev);
 	if (rc)
 		panic("%s IRQ request failed\n", __func__);
 
Signature · 1 line
2.7.4
maintainer
#7 lore raw

Re: [PATCH V7 2/2] csky: remove irq_mapping from smp.c.

Quoted 6 lines · Guo Ren

- remove irq_mapping from smp.c to irq-driver
- Add set_ipi_irq_mapping api to irq-driver
- update asm/smp.h

The patch seems ok to me, but please try to improve the changelog comments. Generally speaking, use full English sentences instead of an enumerated list, and explain what the change is for rather than what you are doing. The text you have here can easily be derived from looking at the code changes, but I still don't understand what caused you to change it, and why this is better than the previous version.

Arnd

maintainer
#2 lore raw

Re: [PATCH V7 1/2] csky/dma: bugfix dma_sync_for_cpu/device

In reply to Guo Ren
Quoted 9 lines · Guo Ren

ref: https://lkml.org/lkml/2018/5/18/1068

        map             for_cpu         for_device      unmap
TO_DEV  writeback       none            writeback       none
TO_CPU  invalidate      invalidate*     invalidate      invalidate*
BIDIR   writeback       invalidate      writeback       invalidate

Same comment as for the other patch: Explain why the original version is wrong first. When giving a reference to some other discussion, use the "Link" tag above your Signed-off-by line. To point to a discussion on lkml, lore.kernel.org is the recommended archive, so it would become

Arnd

author
#8 lore raw

Re: [PATCH V7 2/2] csky: remove irq_mapping from smp.c.

In reply to Arnd Bergmann
Quoted 11 lines · Arnd Bergmann
Quoted 6 lines · Guo Ren

- remove irq_mapping from smp.c to irq-driver
- Add set_ipi_irq_mapping api to irq-driver
- update asm/smp.h

The patch seems ok to me, but please try to improve the changelog comments. Generally speaking, use full English sentences instead of an enumerated list, and explain what the change is for rather than what you are doing. The text

Ok, I'll improve it.

Quoted 3 lines

you have here can easily be derived from looking at the code changes, but I still don't understand what caused you to change it, and why this is better than the previous version.

The changelog comment will change to:

There are some feedbacks from irqchip, and we need to adjust "smp.c & smp.h" to match the csky_mptimer modification.
- Move IPI_IRQ define into drivers/irqchip/csky_mpintc.c, because it's a interrupt controller specific.
- Bugfix request_irq with IPI_IRQ, we must use irq_mapping return value not directly use IPI_IRQ. The modification also involves csky_mpintc.

Best Regards
Guo Ren

author
#3 lore raw

Re: [PATCH V7 1/2] csky/dma: bugfix dma_sync_for_cpu/device

In reply to Arnd Bergmann
Quoted 11 lines · Arnd Bergmann
Quoted 9 lines · Guo Ren

ref: https://lkml.org/lkml/2018/5/18/1068

        map             for_cpu         for_device      unmap
TO_DEV  writeback       none            writeback       none
TO_CPU  invalidate      invalidate*     invalidate      invalidate*
BIDIR   writeback       invalidate      writeback       invalidate
Quoted 7 lines

Same comment as for the other patch: Explain why the original version is wrong first. When giving a reference to some other discussion, use the "Link" tag above your Signed-off-by line. To point to a discussion on lkml, lore.kernel.org is the recommended archive, so it would become

Ok, I'll improve the comment:

Fixup dma_mapping error in linux-4.19-rc3, and we must implement all DMA_TO_DEVICE/FROM_DEVICE/BIDIRECTIONAL for both sync_dma_for_device/cpu. The implementation of arch should follow the following rules:

         map             for_cpu         for_device      unmap
 TO_DEV  writeback       none            writeback       none
 TO_CPU  invalidate      invalidate*     invalidate      invalidate*
 BIDIR   writeback       invalidate      writeback       invalidate

Best Regards
Guo Ren

maintainer
#4 lore raw

Re: [PATCH V7 1/2] csky/dma: bugfix dma_sync_for_cpu/device

Quoted 19 lines · Guo Ren
Quoted 17 lines · Arnd Bergmann
Quoted 9 lines · Guo Ren

ref: https://lkml.org/lkml/2018/5/18/1068

        map             for_cpu         for_device      unmap
TO_DEV  writeback       none            writeback       none
TO_CPU  invalidate      invalidate*     invalidate      invalidate*
BIDIR   writeback       invalidate      writeback       invalidate

Same comment as for the other patch: Explain why the original version is wrong first. When giving a reference to some other discussion, use the "Link" tag above your Signed-off-by line. To point to a discussion on lkml, lore.kernel.org is the recommended archive, so it would become

Quoted 8 lines
Quoted 1 line

Ok, I'll improve the comment:

Fixup dma_mapping error in linux-4.19-rc3, and we must implement all DMA_TO_DEVICE/FROM_DEVICE/BIDIRECTIONAL for both sync_dma_for_device/cpu. The implementation of arch should follow the following rules:

...

That seems ok, but it's better to start with a description of the problem rather than the 'Fixup dma_mapping error in linux-4.19-rc3' part. I would write this like:

| The arch_sync_dma_for_cpu()/arch_sync_dma_for_device()
| implementation is broken for some combinations that end up
| in a BUG() instead of performing the necessary flushes.
|
| The implementation of arch should follow the following rules:
| ...

The imperative 'Fix up dma_mapping error ...' is what belongs into the subject line, and is ideally revisited at the end of the changelog comment if you want to add more detail about what you do.

Arnd

author
#5 lore raw

Re: [PATCH V7 1/2] csky/dma: bugfix dma_sync_for_cpu/device

Quoted 40 lines · Arnd Bergmann
Quoted 19 lines · Guo Ren
Quoted 17 lines · Arnd Bergmann
Quoted 9 lines · Guo Ren

ref: https://lkml.org/lkml/2018/5/18/1068

        map             for_cpu         for_device      unmap
TO_DEV  writeback       none            writeback       none
TO_CPU  invalidate      invalidate*     invalidate      invalidate*
BIDIR   writeback       invalidate      writeback       invalidate

Same comment as for the other patch: Explain why the original version is wrong first. When giving a reference to some other discussion, use the "Link" tag above your Signed-off-by line. To point to a discussion on lkml, lore.kernel.org is the recommended archive, so it would become

Quoted 8 lines
Quoted 1 line

Ok, I'll improve the comment:

Fixup dma_mapping error in linux-4.19-rc3, and we must implement all DMA_TO_DEVICE/FROM_DEVICE/BIDIRECTIONAL for both sync_dma_for_device/cpu. The implementation of arch should follow the following rules:

...

That seems ok, but it's better to start with a description of the problem rather than the 'Fixup dma_mapping error in linux-4.19-rc3' part. I would write this like:

| The arch_sync_dma_for_cpu()/arch_sync_dma_for_device()
| implementation is broken for some combinations that end up
| in a BUG() instead of performing the necessary flushes.
|
| The implementation of arch should follow the following rules:
| ...
Quoted 4 lines

The imperative 'Fix up dma_mapping error ...' is what belongs into the subject line, and is ideally revisited at the end of the changelog comment if you want to add more detail about what you do.

Nice tips, Thx. I'll continue to improve my comments.

Best Regards
Guo Ren