Linus Torvalds <[email protected]> wrote:
>
> There's a flush_dcache_range() thing too, but I don't see a single use
> of that function in generic code, so I suspect that one is currently
> purely for architecture-specific drivers and doesn't work in egneral.
> 
> So *this* is the kind of "bad in a different way" I could imagine:
> things that probably should be cleaned up and be available to generic
> code, but very few people have cared, and so they are used in ad-hoc
> places and haven't been sufficiently generalized and cleaned up.

There is no fallback implementation of flush_dcache_range for the
architectures that don't need it.

It would be nice to have that, as doing it by hand is pretty silly:

static inline void scatterwalk_done_dst(struct scatter_walk *walk,
                                        unsigned int nbytes)
{
        scatterwalk_unmap(walk);
        /*
         * Explicitly check ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE instead of just
         * relying on flush_dcache_page() being a no-op when not implemented,
         * since otherwise the BUG_ON in sg_page() does not get optimized out.
         * This also avoids having to consider whether the loop would get
         * reliably optimized out or not.
         */
        if (ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE) {
                struct page *base_page;
                unsigned int offset;
                int start, end, i;

                base_page = sg_page(walk->sg);
                offset = walk->offset;
                start = offset >> PAGE_SHIFT;
                end = start + (nbytes >> PAGE_SHIFT);
                end += (offset_in_page(offset) + offset_in_page(nbytes) +
                        PAGE_SIZE - 1) >> PAGE_SHIFT;
                for (i = start; i < end; i++)
                        flush_dcache_page(nth_page(base_page, i));
        }

Cheers,
-- 
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Reply via email to