From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c09::241; helo=mail-wm0-x241.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) (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 85283203525FD for ; Thu, 26 Oct 2017 06:11:57 -0700 (PDT) Received: by mail-wm0-x241.google.com with SMTP id 196so19339977wma.1 for ; Thu, 26 Oct 2017 06:15:43 -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=9kFXEG9m+EHhW9cHlvFj8Cf3GsLg3Q8+5590+9v/CtA=; b=Pz1UNxJ8PjepNsHrWWWRs3YVDCp1X/mFdaJGFTB9e3nrzHo1/GDkq0Sd5nDx04IVqc jt95IDREPde5cAmPzBjrC5Iw4UzrhCKxRasvEcW7degr5azhYxTA7BRswGl+1fyxZgKp RQv9bBG8bki9fgQpDWOsKjEFO44ALWzySVxLQ= 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=9kFXEG9m+EHhW9cHlvFj8Cf3GsLg3Q8+5590+9v/CtA=; b=A9XAVzsZUT2Ytm5W7YNpZBSPkTBb3ctob+sCadCVHmMsIdEGdJHrHBtjORd6CFJOME fRk/4nh/sEmQFIB1aaS2gGTGex4B2K3pnSN+7NWjMUE/hEioxBHlA19G1g0kuf8AjFXe oU9vy0ynADotbNt8NcTX8TC/k/GCel0/4jmwTR3ydzrXDbg1j1CUoiGugtVXxUKWqini leW8umCL1KqsqcHYmDJL7HiDAGA9H/Exi7mBpqFwgenCBws9IHJb+rB/hNg/yxByaN+K wUaHD0oaf9GJvavP9S38THyBXpX8yrX+PkmVcxae+I/tQPdBi7HQnd94vpeVWscoUjEG 7KEg== X-Gm-Message-State: AMCzsaUBUrYKfJWBJLiX1AqLdGP+juKUlgNgneL4wcFnFJ9ZOFYBPuAF iTrJU3VcMwviriRi4Pr8dAzBiA== X-Google-Smtp-Source: ABhQp+QtnXnaTn9e9mleip6TPTIc1kqD+uneUY74BUdRfxTYSPNL/stvUGCdA2Q6Mw9T5TUQ2yjWsQ== X-Received: by 10.28.168.203 with SMTP id r194mr1545862wme.2.1509023742356; Thu, 26 Oct 2017 06:15:42 -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 188sm1652008wmg.45.2017.10.26.06.15.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 26 Oct 2017 06:15:41 -0700 (PDT) Date: Thu, 26 Oct 2017 14:15:39 +0100 From: Leif Lindholm To: Marcin Wojtas Cc: edk2-devel@lists.01.org, ard.biesheuvel@linaro.org, nadavh@marvell.com, neta@marvell.com, kostap@marvell.com, jinghua@marvell.com, jsd@semihalf.com, Joe Zhou Message-ID: <20171026131539.j47vcviyhpdi5vhr@bivouac.eciton.net> References: <1508980777-29006-1-git-send-email-mw@semihalf.com> <1508980777-29006-5-git-send-email-mw@semihalf.com> MIME-Version: 1.0 In-Reply-To: <1508980777-29006-5-git-send-email-mw@semihalf.com> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [platforms: PATCH 04/10] Marvell/Library: MppLib: Prevent overwriting PCD values 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, 26 Oct 2017 13:11:57 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Oct 26, 2017 at 03:19:31AM +0200, Marcin Wojtas wrote: > From: Joe Zhou > > After enabling dynamic PCDs, it is possible to reconfigure > MPP during platform initialization. It occurred that due to > a faulty way of passing temporary values, information obtained > from PCDs was overwritten. This patch fixes the issue, which > on the occasion simplifies PcdToMppRegs function. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Joe Zhou > Signed-off-by: Marcin Wojtas Reviewed-by: Leif Lindholm > --- > Platform/Marvell/Library/MppLib/MppLib.c | 21 ++++++++------------ > 1 file changed, 8 insertions(+), 13 deletions(-) > > diff --git a/Platform/Marvell/Library/MppLib/MppLib.c b/Platform/Marvell/Library/MppLib/MppLib.c > index c09acf9..383c820 100644 > --- a/Platform/Marvell/Library/MppLib/MppLib.c > +++ b/Platform/Marvell/Library/MppLib/MppLib.c > @@ -74,7 +74,7 @@ STATIC > VOID > SetRegisterValue ( > UINT8 RegCount, > - UINT8 **MppRegPcd, > + UINT8 MppRegPcd[][MPP_PINS_PER_REG], > UINTN BaseAddr, > BOOLEAN ReverseFlag > ) > @@ -99,10 +99,10 @@ STATIC > UINT8 > PcdToMppRegs ( > UINTN PinCount, > - UINT8 **MppRegPcd > + UINT8 **MppRegPcd, > + UINT8 MppRegPcdTmp[][MPP_PINS_PER_REG] > ) > { > - UINT8 MppRegPcdTmp[MPP_MAX_REGS][MPP_PINS_PER_REG]; > UINT8 PcdGroupCount, MppRegCount; > UINTN i, j, k, l; > > @@ -125,14 +125,7 @@ PcdToMppRegs ( > for (j = 0; j < PCD_PINS_PER_GROUP; j++) { > k = (PCD_PINS_PER_GROUP * i + j) / MPP_PINS_PER_REG; > l = (PCD_PINS_PER_GROUP * i + j) % MPP_PINS_PER_REG; > - MppRegPcdTmp[k][l] = MppRegPcd[i][j]; > - } > - } > - > - /* Update input table */ > - for (i = 0; i < MppRegCount; i++) { > - for (j = 0; j < MPP_PINS_PER_REG; j++) { > - MppRegPcd[i][j] = MppRegPcdTmp[i][j]; > + MppRegPcdTmp[k][l] = (UINT8)MppRegPcd[i][j]; > } > } > > @@ -191,6 +184,7 @@ MppInitialize ( > BOOLEAN ReverseFlag[MAX_CHIPS]; > UINT8 *MppRegPcd[MAX_CHIPS][MPP_MAX_REGS]; > UINT32 i, ChipCount; > + UINT8 TmpMppValue[MPP_MAX_REGS][MPP_PINS_PER_REG]; > > ChipCount = PcdGet32 (PcdMppChipCount); > > @@ -203,8 +197,9 @@ MppInitialize ( > for (i = 0; i < MAX_CHIPS; i++) { > if (i == ChipCount) > break; > - RegCount = PcdToMppRegs (PinCount[i], MppRegPcd[i]); > - SetRegisterValue (RegCount, MppRegPcd[i], BaseAddr[i], ReverseFlag[i]); > + > + RegCount = PcdToMppRegs (PinCount[i], MppRegPcd[i], TmpMppValue); > + SetRegisterValue (RegCount, TmpMppValue, BaseAddr[i], ReverseFlag[i]); > > /* > * eMMC PHY IP has its own MPP configuration. > -- > 2.7.4 >