From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-x22f.google.com (mail-pf0-x22f.google.com [IPv6:2607:f8b0:400e:c00::22f]) (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 3512581D67 for ; Tue, 8 Nov 2016 07:22:25 -0800 (PST) Received: by mail-pf0-x22f.google.com with SMTP id i88so109012351pfk.2 for ; Tue, 08 Nov 2016 07:22:28 -0800 (PST) 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=5EdaXW2QZxO079kDzg8fCVmABAzOBvUycPsRHkp/xLQ=; b=dYvAQadZvRRPIlfKjlbskhqrr2zrsmS9L1kmJGtOnwVtRILyrNvFPr/IkFzldFkUjy TxuQKpPEDk28OiFr8oaiv2100W+g07jHIh3xKfyCjgPiufrzlfTONZidXdpAVgtJkBZg LnbCBEOzdMwumd4MfBu4v6kI5BeS56DsIfdp0= 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=5EdaXW2QZxO079kDzg8fCVmABAzOBvUycPsRHkp/xLQ=; b=LlRNoa9rJ1O0nTA/GHYLaFGwSW17h4h16ASaKIHvcjVCEOZyxnYLJM1yzJTtskG+gt YSB3ZKgG0F3Kd+VlmCSwRJXHFT8uaTYlLWBhWA/dRP+l7chiN+zSpFVD8qNKSAIdjxEt 5QDITq6dqdW1PyW2i9+yGxbwp7EvaWW2E3ez9ZRHmV2idaErBMQyH2ooiPrUid3m2J/N vRyaywi3kit+r1+4nHPyF2nt2fPikAcNvTyCH4eLR8xcifRTYrAOtpY+xc5ASq7+ERN6 16YJABEkdsTIIqPxoDLDMLeS7cMZmBg1xwtXrN+7ASlbmyq146NNNekjd/OjpZyy9RJx u8pg== X-Gm-Message-State: ABUngvfBNJrX6VGDszQKazg811txiSdga6jSJxgYm6enr7+m5+6LHs4hSy+2gTCVpHJPUehv X-Received: by 10.98.35.211 with SMTP id q80mr7889539pfj.26.1478618548180; Tue, 08 Nov 2016 07:22:28 -0800 (PST) Received: from localhost.localdomain ([45.56.159.76]) by smtp.gmail.com with ESMTPSA id g10sm7971804pac.14.2016.11.08.07.22.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 08 Nov 2016 07:22:27 -0800 (PST) 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: Tue, 8 Nov 2016 23:21:12 +0800 Message-Id: <1478618476-12608-8-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1478618476-12608-1-git-send-email-haojian.zhuang@linaro.org> References: <1478618476-12608-1-git-send-email-haojian.zhuang@linaro.org> Subject: [PATCH v4 07/11] 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: Tue, 08 Nov 2016 15:22:25 -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 cefc2b6..5b802c0 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