From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexey Brodkin Date: Thu, 26 Sep 2013 08:30:49 +0000 Subject: [U-Boot] [PATCH v2] drivers/net/designware - fix alignment of buffer descriptors In-Reply-To: References: <1380122868-5306-1-git-send-email-abrodkin@synopsys.com> <5243B390.4010708@st.com> Message-ID: <5243F0B8.2010608@synopsys.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 09/26/2013 09:26 AM, Mischa Jonker wrote: > Vipin wrote: >> I have also faced this problem before. May be a better solution is to >> place all the struct and buffer declarations at the very start of >> dw_eth_dev structure (off-course with a comment that these should not >> be moved). It may avoid the problem in later modifications > > I think that's why Alexey added the alignment to the struct dmamacdescr declaration, to make sure that it always aligned on a boundary of 16 bytes (so even 128-bit busses don't face this issue). > > I don't know though whether the __aligned attribute should be at the type definition of the struct or at the declaration of the "struct dmamacdescr" inside "struct dw_eth_dev". I'm guessing the declaration inside "struct dw_eth_dev" will inherit the alignment requirements of the type def though, but not sure. At least from what I see during my trials "__aligned" in definition of BD structure works as well. Both arrays of buffer descriptors were properly aligned compared to "dw_eth_dev" base address. And since "dw_eth_dev" structure is already aligned (it is allocated with "memalign") both BD arrays are also properly aligned. Initially I thought about move of BD arrays on top of the mother structure but then decided to go with "__aligned" specifiers. IMHO it is safe enough while still very clear - no need to worry about order of structure members and no need to add any comments on how to keep members in order. -Alexey