All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 0/9] net: rtl8169: Fix cache maintenance issues
Date: Thu, 21 Aug 2014 16:11:22 +0200	[thread overview]
Message-ID: <20140821141121.GE19293@ulmo.nvidia.com> (raw)
In-Reply-To: <53F4F314.6070101@wwwdotorg.org>

On Wed, Aug 20, 2014 at 01:12:20PM -0600, Stephen Warren wrote:
> On 08/18/2014 02:00 AM, Thierry Reding wrote:
> >From: Thierry Reding <treding@nvidia.com>
> >
> >This series attempts to fix a long-standing problem in the rtl8169 driver
> >(though the same problem may exist in other drivers as well). Let me first
> >explain what exactly the issue is:
> >
> >The rtl8169 driver provides a set of RX and TX descriptors for the device to
> >use. Once they're set up, the device is told about their location so that it
> >can fetch the descriptors using DMA. The device will also write packet state
> >back into these descriptors using DMA. For this to work properly, whenever a
> >driver needs to access these descriptors it needs to invalidate the D-cache
> >line(s) associated with them. Similarly when changes to the descriptor have
> >been made by the driver, the cache lines need to be flushed to make sure the
> >changes are visible to the device.
> >
> >The descriptors are 16 bytes in size. This causes problems when used on CPUs
> >that have a cache-line size that is larger than 16 bytes. One example is the
> >NVIDIA Tegra124 which has 64-byte cache-lines. That means that 4 descriptors
> >fit into a single cache-line. So whenever the driver flushes a cache-line it
> >has the potential to discard changes made to another descriptor by the DMA
> >device. One typical symptom is that large transfers over TFTP will often not
> >complete and hang somewhere midway because a device marked a packet received
> >but the driver flushing the cache and causing the packet to be lost.
> >
> >Since the descriptors need to be consecutive in memory, I don't see a way to
> >fix this other than to use uncached memory. Therefore the solution proposed
> >in this patch series is to introduce a mechanism in U-Boot to allow a driver
> >to allocate from a pool of uncached memory. Currently an implementation is
> >provided only for ARM v7. The idea is that a region (of user-definable size)
> >immediately below (taking into account architecture-specific alignment
> >restrictions) the malloc() area is mapped uncacheable in the MMU. A driver
> >can use the new noncached_alloc() function to allocate a chunk of memory
> >from this pool dynamically for buffers that it can't or doesn't want to do
> >any explicit cache-maintainance on, yet needs to be shared with DMA devices.
> >
> >Patches 1-3 are minor preparatory work. Patch 1 cleans up some coding style
> >issues in the ARM v7 cache code and patch 2 uses more future-proof types for
> >the mmu_set_region_dcache_behaviour() function arguments. Patch 3 is purely
> >for debugging purposes. It will print out the region used by malloc() when
> >DEBUG is enabled. This can be useful to see where the malloc() region is in
> >the memory map (compared to the noncached region introduced in a later patch
> >for example).
> >
> >Patch 4 implements the noncached API for ARM v7. It obtains the start of the
> >malloc() area and places the noncached region immediately below it so that
> >noncached_alloc() can allocate from it. During boot, the noncached area will
> >be set up immediately after malloc().
> >
> >Patch 5 enables noncached memory for all Tegra boards. It uses a 1 MiB chunk
> >which should be plenty (it's also the minimum on ARM v7 because it matches
> >the MMU section size and therefore the granularity at which U-Boot can set
> >the cacheable attributes).
> 
> If LPAE were to be enabled, the minimum would be 2MiB, but I suppose we can
> deal with that if/when the time comes.

The code that sets up the noncached memory region will pad the size to a
multiple of the section size, and if LPAE were enabled I'd expect the
section size to be defined appropriately, too. It would still mean that
Tegra configured it to be 1 MiB but the code actually reserving 2 MiB of
addresses, but that's explicitly allowed in the documentation.

Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140821/148c4539/attachment.pgp>

      reply	other threads:[~2014-08-21 14:11 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-18  8:00 [U-Boot] [PATCH 0/9] net: rtl8169: Fix cache maintenance issues Thierry Reding
2014-08-18  8:00 ` [U-Boot] [PATCH 1/9] ARM: cache_v7: Various minor cleanups Thierry Reding
2014-08-18  8:00 ` [U-Boot] [PATCH 2/9] ARM: cache-cp15: Use unsigned long for address and size Thierry Reding
2014-08-20 19:15   ` Stephen Warren
2014-08-22  8:29     ` Thierry Reding
2014-08-18  8:00 ` [U-Boot] [PATCH 3/9] malloc: Output region when debugging Thierry Reding
2014-08-18  8:00 ` [U-Boot] [PATCH 4/9] ARM: Implement non-cached memory support Thierry Reding
2014-08-20 19:23   ` Stephen Warren
2014-08-21 15:31     ` Thierry Reding
2014-08-22  8:31     ` Thierry Reding
2014-08-18  8:00 ` [U-Boot] [PATCH 5/9] ARM: tegra: Enable non-cached memory Thierry Reding
2014-08-20 19:24   ` Stephen Warren
2014-08-18  8:00 ` [U-Boot] [PATCH 6/9] net: rtl8169: Honor CONFIG_SYS_RX_ETH_BUFFER Thierry Reding
2014-08-18  8:00 ` [U-Boot] [PATCH 7/9] net: rtl8169: Properly align buffers Thierry Reding
2014-08-20 19:29   ` Stephen Warren
2014-08-22  9:15     ` Thierry Reding
2014-11-12 16:23       ` Simon Glass
2014-11-12 23:38         ` Nobuhiro Iwamatsu
2014-11-13  1:22           ` Simon Glass
2014-08-18  8:00 ` [U-Boot] [PATCH 8/9] net: rtl8169: Use non-cached memory if available Thierry Reding
2014-08-20 19:33   ` Stephen Warren
2014-08-22  9:29     ` Thierry Reding
2014-08-18  8:00 ` [U-Boot] [PATCH 9/9] net: rtl8169: Add support for RTL-8168/8111g Thierry Reding
2014-08-20 19:12 ` [U-Boot] [PATCH 0/9] net: rtl8169: Fix cache maintenance issues Stephen Warren
2014-08-21 14:11   ` Thierry Reding [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140821141121.GE19293@ulmo.nvidia.com \
    --to=thierry.reding@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.