From patchwork Tue Nov 8 15:21:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 81344 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp1604137qge; Tue, 8 Nov 2016 07:22:31 -0800 (PST) X-Received: by 10.98.148.26 with SMTP id m26mr8647272pfe.17.1478618550052; Tue, 08 Nov 2016 07:22:30 -0800 (PST) Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id 20si37485124pgy.294.2016.11.08.07.22.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Nov 2016 07:22:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 7004281D7B; Tue, 8 Nov 2016 07:22:26 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org 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 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: [edk2] [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: , Cc: Haojian Zhuang MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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(-) -- 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel 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);