From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-x231.google.com (mail-pa0-x231.google.com [IPv6:2607:f8b0:400e:c03::231]) (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 B39B01A1EF5 for ; Wed, 21 Sep 2016 08:02:54 -0700 (PDT) Received: by mail-pa0-x231.google.com with SMTP id wk8so19265312pab.1 for ; Wed, 21 Sep 2016 08:02:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DvuqdVtDJUtx04dC0PX07Ah0PD3YUAnUoU7V7H17wn8=; b=dnyk5O90XvL/MJldIVkV0Oq+0432s5cxQ15lL3TsX0qNEYhkTltCvdoN/CH8wS/rPV wLpsZtf6nFKfvoyQ9Y/3d1DfCf+S6V1x7HMBpGlEZGIiNJNwvWXvDxm1FAVbK956AmbP KJVBDddmglgIKaW1xSLLV8ZIbrR1/mXaEedWo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DvuqdVtDJUtx04dC0PX07Ah0PD3YUAnUoU7V7H17wn8=; b=CoZCOH/z3KbJz+plJccjUhpbugWx1Tc4YnqEBRXVXOZD75PzfQvSLTwQCRIta1sdmy TgJe/IIOhMFoJV5LMW5v3fzzryqFxgQ+54EEfb9F3igoECxGnrrL5ZQgTW7pBlcWH+Xd F62XZLmOF8TJc2S0VUDW9294z7KTDwHDc8KChCVcpbZ/bU6ztQ1A305GFawJvhIGUO1g Iztcgs87ZCJw/KqjDutLXLgCO75TrsRnEcWL1Qg0fQgejiqzTo6993bj1M94itWzqTGe s5Bl+MTCi2Fq5VH5Bt5+U7ClGGax7CYmCfaAoROIaA8LxTbFWufznu6xBF4Lk6Getnm5 jfKw== X-Gm-Message-State: AE9vXwMz3uAtKroNUMl0Xom4Ing5eYeG689OsUvgYz21cQjEe2SZew/D71spu6KJGKGcoXiu X-Received: by 10.67.1.35 with SMTP id bd3mr66250560pad.16.1474470174397; Wed, 21 Sep 2016 08:02:54 -0700 (PDT) Received: from localhost.localdomain ([104.237.91.137]) by smtp.gmail.com with ESMTPSA id 85sm28914221pfw.92.2016.09.21.08.02.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Sep 2016 08:02:53 -0700 (PDT) From: Haojian Zhuang To: ryan.harkin@linaro.org, edk2-devel@lists.01.org, leif.lindholm@linaro.org, ard.biesheuvel@linaro.org Cc: Haojian Zhuang Date: Wed, 21 Sep 2016 23:02:24 +0800 Message-Id: <1474470147-23156-8-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1474470147-23156-1-git-send-email-haojian.zhuang@linaro.org> References: <1474470147-23156-1-git-send-email-haojian.zhuang@linaro.org> Subject: [PATCH v3 07/10] MmcDxe: Fix uninitialized mediaid for SD X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Sep 2016 15:02:54 -0000 When SD card is used, mediaid is not initialized and used directly. So fix it. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Haojian Zhuang --- EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c b/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c index a5915e4..f806bfc 100644 --- a/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c +++ b/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c @@ -57,6 +57,7 @@ typedef enum _EMMC_DEVICE_STATE { } EMMC_DEVICE_STATE; UINT32 mEmmcRcaCount = 0; +UINT32 CurrentMediaId = 0; STATIC EFI_STATUS @@ -231,6 +232,10 @@ EmmcIdentificationMode ( // Set up media Media->BlockSize = EMMC_CARD_SIZE; // 512-byte support is mandatory for eMMC cards Media->MediaId = MmcHostInstance->CardInfo.CIDData.PSN; + if (CurrentMediaId > Media->MediaId) + Media->MediaId = ++CurrentMediaId; + else + CurrentMediaId = Media->MediaId; Media->ReadOnly = MmcHostInstance->CardInfo.CSDData.PERM_WRITE_PROTECT; Media->LogicalBlocksPerPhysicalBlock = 1; Media->IoAlign = 4; @@ -344,7 +349,7 @@ InitializeSdMmcDevice ( MmcHostInstance->BlockIo.Media->BlockSize = BlockSize; MmcHostInstance->BlockIo.Media->ReadOnly = MmcHost->IsReadOnly (MmcHost); MmcHostInstance->BlockIo.Media->MediaPresent = TRUE; - MmcHostInstance->BlockIo.Media->MediaId++; + MmcHostInstance->BlockIo.Media->MediaId = ++CurrentMediaId; CmdArg = MmcHostInstance->CardInfo.RCA << 16; Status = MmcHost->SendCommand (MmcHost, MMC_CMD7, CmdArg); -- 2.7.4