From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-in7.apple.com (mail-out7.apple.com [17.151.62.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id CBE6321A08D8A for ; Mon, 12 Jun 2017 21:24:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; d=apple.com; s=mailout2048s; c=relaxed/simple; q=dns/txt; i=@apple.com; t=1497327938; h=From:Sender:Reply-To:Subject:Date:Message-id:To:Cc:MIME-version:Content-type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-reply-to:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=SJYw1ADfmqR/2NQr5Z8tw79nLInvHPjPzhnVCT97450=; b=o6/7oefeh0TfV1ulH7jpF7oUGqNeRlxqbj9SpZlrShJq/8M+5JDasi6QQBP2I2Am nmzu1lvE2yW36mi9EQfSO/YrzIdayQMHjhV/Vkrx9pUf1LFW2DYwYThPFdB/iho5 l/n9IW54gPxj7gjZyGqsO6ll7g8WWCFrZcePPExOiU3TwFKyYFZQv9kbxQ6cjUzW oen1Dz2ieY1TMXYBcsOD5np9pjzVblMI4enZt9MM8jSFc9JdreXcYKux6A5wnI0Y UNOGwvgFdNsHydQfAxMR4V9XM/UhzByP3b4kMQgXH6+0tgBGqx/WluXhKfoS+qUl vuK8sAty+edSiK5eg9Jz4A==; Received: from relay2.apple.com (relay2.apple.com [17.128.113.67]) (using TLS with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail-in7.apple.com (Apple Secure Mail Relay) with SMTP id 7C.46.07949.2496F395; Mon, 12 Jun 2017 21:25:38 -0700 (PDT) X-AuditID: 11973e16-0c7789a000001f0d-31-593f69424a81 Received: from nwk-mmpp-sz12.apple.com (nwk-mmpp-sz12.apple.com [17.128.115.204]) by relay2.apple.com (Apple SCV relay) with SMTP id C1.FA.07829.1496F395; Mon, 12 Jun 2017 21:25:38 -0700 (PDT) MIME-version: 1.0 Received: from [17.153.95.126] (unknown [17.153.95.126]) by nwk-mmpp-sz12.apple.com (Oracle Communications Messaging Server 8.0.1.2.20170210 64bit (built Feb 10 2017)) with ESMTPSA id <0ORG004NWXMMU630@nwk-mmpp-sz12.apple.com>; Mon, 12 Jun 2017 21:25:37 -0700 (PDT) Sender: afish@apple.com From: Andrew Fish Message-id: Date: Mon, 12 Jun 2017 21:25:33 -0700 In-reply-to: Cc: Ard Biesheuvel , Jason Liu , edk2-devel@lists.01.org, Leif Lindholm , Haojian Zhuang , Shawn Guo To: Jun Nie References: <1497232768-8993-1-git-send-email-jun.nie@linaro.org> <20170612155315.GK26676@bivouac.eciton.net> <0C3C4FE2-0357-42D5-8DD2-28C840179A1A@apple.com> X-Mailer: Apple Mail (2.3273) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDLMWRmVeSWpSXmKPExsUi2FDorOuUaR9psOG2qMX/D7sZLfYcOsps cfncYUaL90evMFosefKQ3eLT7j0sFk/XLWF2YPe4c20Pm0f37H8sAUxRXDYpqTmZZalF+nYJ XBmXfp9lKWhZw1jxab1bA+OXqYxdjBwcEgImEgv/1XQxcnEICaxmkji8bSd7FyMnWHzl3qls ILaQwCFGiZ7XwSA2r4CgxI/J91hAbGaBMImmCSuYIJonMkncWPmGCSQhLCAu8e7MJmYQm01A WWLF/A/sEM02Eoc3r2aHqPGTON1/lw3kCBYBVYkj05xBwpwCwRL9DzewgcxkFnjOKDHx7G+w ehEBBYmud22sEAdtYJJYuS8d4lBZiVuzLzGDNEgIvGeTeHxiJdsERqFZSI6dheRYCFtL4vuj VqA4B5AtL3HwvCxEWFPi2b1P7BC2tsSTdxdYFzCyrWIUyk3MzNHNzDPXSywoyEnVS87P3cQI ip7pdmI7GB+usjrEKMDBqMTDu2KSXaQQa2JZcWXuIUZpDh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AF+Z2OOoCAAA= X-Content-Filtered-By: Mailman/MimeDel 2.1.22 Subject: Re: [PATCH v2] EmbeddedPkg/MmcDxe: Add alignment for ECSD data X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Jun 2017 04:24:25 -0000 Content-Type: text/plain; CHARSET=US-ASCII Content-Transfer-Encoding: 7BIT > On Jun 12, 2017, at 9:13 PM, Jun Nie wrote: > > 2017-06-13 12:01 GMT+08:00 Andrew Fish >: >> >>> On Jun 12, 2017, at 7:14 PM, Jun Nie wrote: >>> >>> 2017-06-12 23:53 GMT+08:00 Leif Lindholm : >>>> 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? > Sure type struct { UINT16 RCA; UINT8 CardType; UINT32 OCRData; ... Has different alignment than: type struct { UINT16 RCA; UINT32 CardType; UINT32 OCRData; ... Both are legal things for the C compiler to due given the type is an enum. 1st example OCRData starts at offset 4 2nd example OCRData starts at offset 8 An integer type is not an int. Thanks, Andrew Fish > Thank you! > Jun > >>> >>>> >>>>> Contributed-under: TianoCore Contribution Agreement 1.0 >>>>> Signed-off-by: Jun Nie >>>>> --- >>>>> 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 >> > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel