From: Jun Nie <jun.nie@linaro.org>
To: Andrew Fish <afish@apple.com>
Cc: Leif Lindholm <leif.lindholm@linaro.org>,
Jason Liu <jason.liu@linaro.org>,
edk2-devel@lists.01.org, Shawn Guo <shawn.guo@linaro.org>,
Haojian Zhuang <haojian.zhuang@linaro.org>,
Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: Re: [PATCH v2] EmbeddedPkg/MmcDxe: Add alignment for ECSD data
Date: Tue, 13 Jun 2017 12:13:00 +0800 [thread overview]
Message-ID: <CABymUCNbGm4dekLdNoO=Et9Kwq_xUvkj5OYMT5rM2LK2ui3qwg@mail.gmail.com> (raw)
In-Reply-To: <0C3C4FE2-0357-42D5-8DD2-28C840179A1A@apple.com>
2017-06-13 12:01 GMT+08:00 Andrew Fish <afish@apple.com>:
>
>> On Jun 12, 2017, at 7:14 PM, Jun Nie <jun.nie@linaro.org> wrote:
>>
>> 2017-06-12 23:53 GMT+08:00 Leif Lindholm <leif.lindholm@linaro.org>:
>>> On Mon, Jun 12, 2017 at 09:59:28AM +0800, Jun Nie wrote:
>>>> Add alignment for ECSD data for DMA access. Otherwise
>>>> the data is corrupted on Sanechips platform.
>>>
>>> I never did see a reply to my proposed solution, and the below is not
>>> it. Can you explain why you prefer this one?
>>>
>>> /
>>> Leif
>>
>> Sorry, just see your email because that thread is not highlighted for
>> new email in gmail for unknown reason.
>> I have concern that "UINT64 VENDOR_SPECIFIC_FIELD[8]" cannot secure
>> the ECSD alignment because it is not the first member. Changing the
>> first member to "UINT64 RESERVED_1[2]" shall secure the alignment. But
>> I preferred Pad method. It is more readable if all ECSD member are
>> UINT8 type. It is also more clear to add alignment info in CARD_INFO,
>> just before ECSD member.
>> I do not get point of Andrew, maybe he share the same concern.
>>
>
> Jun
>
> typedef enum {
> UNKNOWN_CARD,
> MMC_CARD, //MMC card
> MMC_CARD_HIGH, //MMC Card with High capacity
> EMMC_CARD, //eMMC 4.41 card
> SD_CARD, //SD 1.1 card
> SD_CARD_2, //SD 2.0 or above standard card
> SD_CARD_2_HIGH //SD 2.0 or above high capacity card
> } CARD_TYPE;
>
> Per C spec sizeof(CARD_TYPE) can be 1, 2, 4, or 8 (64-bit integer), and it is legal for the compiler to pick any of these. So it is not portable C code to use an enum in a data structure when layout maters.
>
> Thanks,
>
> Andrew Fish
CARD_TYPE CardType is 2nd member of CARD_INFO, while ECSDData is the
last member and I just want to align it to 8 bytes. I had assume pad
will be added automatically by compiler if CARD_TYPE is not 8 bytes
aligned and UNIT64 type appear in following member. Does enum will
impact the later member alignment? Could you help elaborate more about
this?
Thank you!
Jun
>>
>>>
>>>> Contributed-under: TianoCore Contribution Agreement 1.0
>>>> Signed-off-by: Jun Nie <jun.nie@linaro.org>
>>>> ---
>>>> EmbeddedPkg/Universal/MmcDxe/Mmc.h | 1 +
>>>> 1 file changed, 1 insertion(+)
>>>>
>>>> diff --git a/EmbeddedPkg/Universal/MmcDxe/Mmc.h b/EmbeddedPkg/Universal/MmcDxe/Mmc.h
>>>> index 8a7d5a3..6e3ab17 100644
>>>> --- a/EmbeddedPkg/Universal/MmcDxe/Mmc.h
>>>> +++ b/EmbeddedPkg/Universal/MmcDxe/Mmc.h
>>>> @@ -319,6 +319,7 @@ typedef struct {
>>>> OCR OCRData;
>>>> CID CIDData;
>>>> CSD CSDData;
>>>> + UINT64 Pad; // For 8 bytes alignment of ECSDData
>>>> ECSD ECSDData; // MMC V4 extended card specific
>>>> } CARD_INFO;
>>>>
>>>> --
>>>> 1.9.1
>>>>
>> _______________________________________________
>> edk2-devel mailing list
>> edk2-devel@lists.01.org
>> https://lists.01.org/mailman/listinfo/edk2-devel
>
next prev parent reply other threads:[~2017-06-13 4:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-12 1:59 [PATCH v2] EmbeddedPkg/MmcDxe: Add alignment for ECSD data Jun Nie
2017-06-12 15:53 ` Leif Lindholm
2017-06-12 16:03 ` Andrew Fish
2017-06-13 2:14 ` Jun Nie
2017-06-13 4:01 ` Andrew Fish
2017-06-13 4:13 ` Jun Nie [this message]
2017-06-13 4:25 ` Andrew Fish
2017-06-13 4:44 ` Jun Nie
2017-06-13 9:18 ` Leif Lindholm
2017-06-14 2:50 ` Jun Nie
2017-06-14 15:18 ` Leif Lindholm
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-list 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='CABymUCNbGm4dekLdNoO=Et9Kwq_xUvkj5OYMT5rM2LK2ui3qwg@mail.gmail.com' \
--to=devel@edk2.groups.io \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox