From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Warren Date: Wed, 20 Aug 2014 13:29:57 -0600 Subject: [U-Boot] [PATCH 7/9] net: rtl8169: Properly align buffers In-Reply-To: <1408348852-30894-8-git-send-email-thierry.reding@gmail.com> References: <1408348852-30894-1-git-send-email-thierry.reding@gmail.com> <1408348852-30894-8-git-send-email-thierry.reding@gmail.com> Message-ID: <53F4F735.90302@wwwdotorg.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 08/18/2014 02:00 AM, Thierry Reding wrote: > From: Thierry Reding > > RX and TX descriptor rings should be aligned to 256 byte boundaries. Use > the DEFINE_ALIGN_BUFFER() macro to define the buffers so that they don't > have to be manually aligned later on. Also make sure that the buffers do > align to cache-line boundaries in case the cache-line is higher than the > 256 byte alignment requirements of the NIC. > > Also add a warning if the cache-line size is larger than the descriptor > size, because the driver may discard changes to descriptors made by the > hardware when requeuing RX buffers. > @@ -909,6 +899,18 @@ static int rtl_init(struct eth_device *dev, bd_t *bis) > + /* > + * Warn if the cache-line size is larger than the descriptor size. In > + * such cases the driver will likely fail because the CPU needs to > + * flush the cache when requeuing RX buffers, therefore descriptors > + * written by the hardware may be discarded. > + */ > + if (ARCH_DMA_MINALIGN > sizeof(struct RxDesc)) > + printf("WARNING: cache-line size is larger than descriptor size\n"); I'd be tempted to make that a compile-time #error (or perhaps just a #warning) Perhaps #error would break compilation of existing boards though?