From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-x236.google.com (mail-wm0-x236.google.com [IPv6:2a00:1450:400c:c09::236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id AA2A521967BE1 for ; Thu, 8 Jun 2017 09:34:13 -0700 (PDT) Received: by mail-wm0-x236.google.com with SMTP id n195so34778872wmg.1 for ; Thu, 08 Jun 2017 09:35:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=7mKS4SeKo0PUAKAl/aWSRTcZomJgLVGpQQg1LBh5dPM=; b=IWuq3WWmKW6LXpD2vhaAgT4it7xlAzp7GZ4cAOx5xPCdSGrbvRyaz2q1DU/6/kdYHr 9HJRy8v5FCy0Cq639uMdDa36R4kuKHszJdDngYEm5XaG11A4UaIZQV5xvZCrw//Ne4no /hfZWFKZ6MxQqDhvk4pDQcTSFIdXRxv6edCbE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=7mKS4SeKo0PUAKAl/aWSRTcZomJgLVGpQQg1LBh5dPM=; b=bLLGmBDtIJQe4Zslapvmo5VN9lHf9XqZWWjDpHsI03wyzYZS7KHf68dL+TKIBJBc5Z AUXY8DZWwDugevh5qyrO+ebsP9vryWEwDDrqaxSWBn/nR3uxv4PfvnmFwLFtrGDSGL81 +HQKGmHmHwlMHk9FkrHJW2rPiVkItgmZolKtVUwVXLlMmmf4NqshksdicEMMKR41noBE AH0aktZUuwhDKDQeqTv8REEVHAsOw1W6Nso59XJrdm80Xn0SUVhkR6N4cPD6GR3HLyMD 4JmL2ZJ9Xymg4lxod12GlRdRPv0RdeB417LqEKoGhKclC3Of5CLhnfwmgBvGZfYllqYL uOrg== X-Gm-Message-State: AODbwcBdUqissxSf1siVvAvdYxslCa62hjiwvRriwRkfMicUBypbvgMW 0f9MF5S5PG/8oJWU X-Received: by 10.28.109.82 with SMTP id i79mr4164444wmc.113.1496939721264; Thu, 08 Jun 2017 09:35:21 -0700 (PDT) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id 22sm6305381wrt.36.2017.06.08.09.35.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Jun 2017 09:35:20 -0700 (PDT) Date: Thu, 8 Jun 2017 17:35:18 +0100 From: Leif Lindholm To: Andrew Fish Cc: Jun Nie , jason.liu@linaro.org, edk2-devel@lists.01.org, shawn.guo@linaro.org, haojian.zhuang@linaro.org, ard.biesheuvel@linaro.org Message-ID: <20170608163518.GL7556@bivouac.eciton.net> References: <1496909927-16812-1-git-send-email-jun.nie@linaro.org> <1235B084-B1C5-490B-89CC-BC88BF652FB5@apple.com> MIME-Version: 1.0 In-Reply-To: <1235B084-B1C5-490B-89CC-BC88BF652FB5@apple.com> User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [PATCH] 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: Thu, 08 Jun 2017 16:34:14 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Jun 08, 2017 at 07:55:11AM -0700, Andrew Fish wrote: > > > On Jun 8, 2017, at 1:18 AM, Jun Nie wrote: > > > > Add alignment for ECSD data for DMA access. Otherwise > > the data is corrupted on Sanechips platform. > > > > Contributed-under: TianoCore Contribution Agreement 1.0 > > Signed-off-by: Jun Nie > > > --- > > EmbeddedPkg/Universal/MmcDxe/Mmc.h | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/EmbeddedPkg/Universal/MmcDxe/Mmc.h b/EmbeddedPkg/Universal/MmcDxe/Mmc.h > > index 8a7d5a3..ca1a9d5 100644 > > --- a/EmbeddedPkg/Universal/MmcDxe/Mmc.h > > +++ b/EmbeddedPkg/Universal/MmcDxe/Mmc.h > > @@ -319,7 +319,7 @@ typedef struct { > > OCR OCRData; > > CID CIDData; > > CSD CSDData; > > - ECSD ECSDData; // MMC V4 extended card specific > > + ECSD ECSDData __attribute__((aligned(8))); // MMC V4 extended card specific > > } CARD_INFO; > > > > Jun, > > This structure does not look portable. > 1) CARD_TYPE is an ENUM and the size of an enum is not a standard > thing in C. Compiler is probably picking int and it seems to > work. > 2) I don't think __attribute__((aligned(8))) is supported by all > the edk2 compilers (VC++ for example). It is an GNU extensions to > C, not standard C, so we normally don't use it in edk2 code. > > While the alignment of types is not defined by the C standard, it is > defined in the EFI ABI to be natural alignment. So you can add > padding elements to a structure. You can also union with a UINT64 > for force 8 byte alignment. > > typedef struct { > UINT16 RCA; > UINT32 CardType; //CARD_TYPE > OCR OCRData; > CID CIDData; > CSD CSDData; > UINT32 Pad; > ECSD ECSDData; // MMC V4 extended card specific > } CARD_INFO; You could also cause the natural alignment of ECSD to become 8 byte. For example, by changing UINT8 VENDOR_SPECIFIC_FIELD[64]; to UINT64 VENDOR_SPECIFIC_FIELD[8]; Regards, Leif > > Thanks, > > Andrew Fish > > > typedef struct _MMC_HOST_INSTANCE { > > -- > > 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