[RFC PATCH V4 4/6] RISC-V: Implement arch_sync_dma* functions

Guo Ren guoren at kernel.org
Wed Sep 15 18:32:41 PDT 2021


On Wed, Sep 15, 2021 at 3:50 PM Christoph Hellwig <hch at lst.de> wrote:
>
> On Sat, Sep 11, 2021 at 05:21:37PM +0800, guoren at kernel.org wrote:
> > +static void __dma_sync(phys_addr_t paddr, size_t size, enum dma_data_direction dir)
> > +{
> > +     if ((dir == DMA_FROM_DEVICE) && (dma_cache_sync->cache_invalidate))
> > +             dma_cache_sync->cache_invalidate(paddr, size);
> > +     else if ((dir == DMA_TO_DEVICE) && (dma_cache_sync->cache_clean))
> > +             dma_cache_sync->cache_clean(paddr, size);
> > +     else if ((dir == DMA_BIDIRECTIONAL) && dma_cache_sync->cache_flush)
> > +             dma_cache_sync->cache_flush(paddr, size);
> > +}
>
> Despite various snipplets this is a still pretty much the broken previous
> versions.  These need to use the CMO instructions directly which are
> about to go into review, and then your SBI can trap on those can call
> whatever non-standard mess you're using.
I think you mean put an ALTERNATIVE slot in the prologue of __dma_sync?

#define ALT_DMA_SYNC()                                           \
asm(ALTERNATIVE(".rept 64\n nop\n .endr\n", "<vendor code>",
XXX_VENDOR_ID,        \
                ERRATA_XXX, CONFIG_ERRATA_XXX)  \
                : : : "memory")

static void __dma_sync(phys_addr_t paddr, size_t size, enum
dma_data_direction dir)
{
        ALT_DMA_SYNC();

        /* future cmo codes */
}




-- 
Best Regards
 Guo Ren

ML: https://lore.kernel.org/linux-csky/



More information about the linux-riscv mailing list