lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAJiQ=7AJn_qDfuD=4MEDpxisrGaZ8U+62nP=xNEhBtz77omF4w@mail.gmail.com>
Date:	Wed, 26 Nov 2014 14:54:49 -0800
From:	Kevin Cernekee <cernekee@...il.com>
To:	Arnd Bergmann <arnd@...db.de>
Cc:	Ralf Baechle <ralf@...ux-mips.org>,
	Florian Fainelli <f.fainelli@...il.com>,
	Jon Fraser <jfraser@...adcom.com>,
	Dmitry Torokhov <dtor@...omium.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	Jason Cooper <jason@...edaemon.net>,
	Jonas Gorski <jogo@...nwrt.org>,
	Brian Norris <computersforpeace@...il.com>,
	Linux MIPS Mailing List <linux-mips@...ux-mips.org>,
	"devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	Felix Fietkau <nbd@...nwrt.org>
Subject: Re: [PATCH V3 11/11] MIPS: Add multiplatform BMIPS target

On Wed, Nov 26, 2014 at 1:28 PM, Arnd Bergmann <arnd@...db.de> wrote:
>> For the BMIPS case:
>>
>> plat_map_dma_mem* and plat_dma_addr_to_phys are just performing
>> remapping, so dma-ranges would work.
>>
>> plat_unmap_dma_mem is used to perform an extra BMIPS-specific
>> cacheflush operation.
>
> Yes, the cacheflush again would have to be abstracted. This is normally
> done using either a platform-specific dma_map_ops struct, or using
> a further abstraction with another function pointer.
>
> I'm surprised that you need the special flush operation only
> for 'unmap' and not for 'dma_sync_*_for_cpu'. Can you check that
> you are actually doing the right thing for drivers that reuse
> a DMA buffer with the streaming API?

That's a fantastic question.  I checked an older BCM7xxx kernel tree
and noticed that we used to implement plat_extra_sync_for_device()
locally to do this, but the API was "garbage collected" last year:

commit 4e7f72660c39a81cc5745d5c6f23f9500f80d8d8
Author: Felix Fietkau <nbd@...nwrt.org>
Date:   Thu Aug 15 11:28:30 2013 +0200

    MIPS: Remove unnecessary platform dma helper functions

    The semantics stay the same - on Cavium Octeon the functions were dead
    code (it overrides the MIPS DMA ops) - on other platforms they contained
    no code at all.

    Signed-off-by: Felix Fietkau <nbd@...nwrt.org>
    Cc: linux-mips@...ux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/5720/
    Signed-off-by: Ralf Baechle <ralf@...ux-mips.org>


If nobody objects, I can revert this change and then add the extra
flush to arch/mips/bmips/dma.c.

Or I can add some BMIPS-specific code to dma-default.c, similar to
cpu_needs_post_dma_flush().  Could even add it to that function
directly, although that is less intuitive:

diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
index af5f046..ee6d12c 100644
--- a/arch/mips/mm/dma-default.c
+++ b/arch/mips/mm/dma-default.c
@@ -18,6 +18,7 @@
 #include <linux/highmem.h>
 #include <linux/dma-contiguous.h>

+#include <asm/bmips.h>
 #include <asm/cache.h>
 #include <asm/cpu-type.h>
 #include <asm/io.h>
@@ -69,6 +70,18 @@ static inline struct page *dma_addr_to_page(struct
device *dev,
  */
 static inline int cpu_needs_post_dma_flush(struct device *dev)
 {
+    if (boot_cpu_type() == CPU_BMIPS3300 ||
+        boot_cpu_type() == CPU_BMIPS4350 ||
+        boot_cpu_type() == CPU_BMIPS4380) {
+        void __iomem *cbr = BMIPS_GET_CBR();
+
+        /* Flush stale data out of the readahead cache */
+        __raw_writel(0x100, cbr + BMIPS_RAC_CONFIG);
+        __raw_readl(cbr + BMIPS_RAC_CONFIG);
+
+        return 0;
+    }
+
     return !plat_device_is_coherent(dev) &&
            (boot_cpu_type() == CPU_R10000 ||
         boot_cpu_type() == CPU_R12000 ||


This would allow for eliminating all flushes from
arch/mips/bmips/dma.c, so the entire file could go away when we switch
to the common dma-ranges code.

Any preferences?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ