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::243; helo=mail-wm0-x243.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) (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 ABB442034C08E for ; Tue, 31 Oct 2017 20:10:25 -0700 (PDT) Received: by mail-wm0-x243.google.com with SMTP id t139so2446133wmt.1 for ; Tue, 31 Oct 2017 20:14:17 -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=P0XlVL/8ag3UHjL1LltTXRwo/iZAYxQwKGWvD0ypS2g=; b=M3RgfDsmGstWpWYP6NkSeEtl8pu/AScZMAAs1T3sQ60sEo6rpu9NgYr63Ic996A7u6 WFHWc4ykxYYFwNrQTzZ/iYd4Z9AxyzTn6cCI01JDuiSanItEcSKYZ0eZ29zOvEWyiOvT N4jmxB9B2qEbGLtIyoROZP7KW3UIuZBzpx1hw= 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=P0XlVL/8ag3UHjL1LltTXRwo/iZAYxQwKGWvD0ypS2g=; b=FpmKSH8jnvqZZYeFEQlf1tKzCOfHEMm8c7LM08SfcZEEfv1RPbWSp2NFlCNEfbXu3o CwidZ4hqIC/XWlNhLeRMColM5ZfdS/bIaUjPVbnUijRCjBp2b+eys4O/vhaqCElXuiqz yaItm8ARy4X3tg5R1Fd6CSi/04O6Zt4pABmhdE4GItCfpa1LMbQu1bqt1yW0tSZPgSit 1xLQjNgnlMZeS4lVNQL3uzwXT33HRsdt/xGaQ3H+4uQJRh878VyTc1Zrz0HJVAl7LEAI q1RbY3bRxcnW3eCDUN7FjbSDRHp5XyPXO57uCibvqknf/BeIkjyY99yB8EpyQrVpRcCI 0xiw== X-Gm-Message-State: AMCzsaVRkx6GXMHz8M1gc8nQdo5fiU86S3b03PlxOF+eYTojjnlZzt/n iegKIKVFRTsZLXm7GHDUAuhwyw== X-Google-Smtp-Source: ABhQp+Rf/rfndeE4a/ksEAXzFnIBTdq+vB3KRI3e6Ay8qtcdmN4yN1MbRdVMj05tKS7FnyreAY7wIQ== X-Received: by 10.28.236.216 with SMTP id h85mr3686530wmi.100.1509506056078; Tue, 31 Oct 2017 20:14:16 -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 o18sm1930901wrh.23.2017.10.31.20.14.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Oct 2017 20:14:15 -0700 (PDT) Date: Wed, 1 Nov 2017 03:14:13 +0000 From: Leif Lindholm To: Marcin Wojtas Cc: edk2-devel-01 , Ard Biesheuvel , nadavh@marvell.com, Neta Zur Hershkovits , Kostya Porotchkin , Hua Jing , semihalf-dabros-jan Message-ID: <20171101031413.kwvnyuzfyl4mlo7z@bivouac.eciton.net> References: <1509422375-20198-1-git-send-email-mw@semihalf.com> <1509422375-20198-2-git-send-email-mw@semihalf.com> <20171031090717.xwbjaitebmcfdiue@bivouac.eciton.net> MIME-Version: 1.0 In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [platforms: PATCH 1/6] Marvell/Drivers: MvSpiFlash: Improve ReadId 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: Wed, 01 Nov 2017 03:10:25 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Oct 31, 2017 at 10:22:50AM +0100, Marcin Wojtas wrote: > 2017-10-31 10:07 GMT+01:00 Leif Lindholm : > > On Tue, Oct 31, 2017 at 04:59:30AM +0100, Marcin Wojtas wrote: > >> Fix the ReadId routine by using master's ReadWrite callback > >> instead of the raw Transfer - no longer swapping and byte > >> shifting is needed. Simplify code by using local array > >> instead of dynamic allocation. Moreover store the FlashId > >> in an UINT8 array PCD instead of the concatenated UINT32 > >> format - this way less overhead in the driver is needed > >> for comparing the buffers. > >> > >> The new handling allowed for cleaning Fupdate and Sf > >> shell commands FlashProbe routines. > >> > >> Contributed-under: TianoCore Contribution Agreement 1.1 > >> Signed-off-by: Marcin Wojtas > >> --- > >> Platform/Marvell/Applications/FirmwareUpdate/FUpdate.c | 22 +++-------- > >> Platform/Marvell/Applications/SpiTool/SpiFlashCmd.c | 37 ++++++------------ > >> Platform/Marvell/Armada/Armada70x0.dsc | 2 +- > >> Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.c | 41 ++++++++++++-------- > >> Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.h | 2 + > >> Platform/Marvell/Include/Protocol/SpiFlash.h | 3 ++ > >> Platform/Marvell/Marvell.dec | 2 +- > >> 7 files changed, 48 insertions(+), 61 deletions(-) > >> > >> diff --git a/Platform/Marvell/Applications/FirmwareUpdate/FUpdate.c b/Platform/Marvell/Applications/FirmwareUpdate/FUpdate.c > >> index 664411a..d70645d 100644 > >> --- a/Platform/Marvell/Applications/FirmwareUpdate/FUpdate.c > >> +++ b/Platform/Marvell/Applications/FirmwareUpdate/FUpdate.c > >> @@ -94,28 +94,16 @@ SpiFlashProbe ( > >> ) > >> { > >> EFI_STATUS Status; > >> - UINT32 IdBuffer, Id, RefId; > >> + UINT8 *FlashId; > >> > >> - Id = PcdGet32 (PcdSpiFlashId); > >> - > >> - IdBuffer = CMD_READ_ID & 0xff; > >> + FlashId = (UINT8 *)PcdGetPtr (PcdSpiFlashId); > >> > >> // Read SPI flash ID > >> - SpiFlashProtocol->ReadId (Slave, sizeof (UINT32), (UINT8 *)&IdBuffer); > >> - > >> - // Swap and extract 3 bytes of the ID > >> - RefId = SwapBytes32 (IdBuffer) >> 8; > >> - > >> - if (RefId == 0) { > >> - Print (L"%s: No SPI flash detected"); > >> - return EFI_DEVICE_ERROR; > >> - } else if (RefId != Id) { > >> - Print (L"%s: Unsupported SPI flash detected with ID=%2x\n", CMD_NAME_STRING, RefId); > >> - return EFI_DEVICE_ERROR; > >> + Status = SpiFlashProtocol->ReadId (Slave, NOR_FLASH_ID_DEFAULT_LEN, FlashId); > > > > Is the length not possible to calculate somehow? > > Having a MAX_LEN defined and then using a DEFAULT_LEN or explicitly > > extracting 3 bytes from somewhere feels suboptimal. > > > > I know. It is however a change that was somewhat artificially > extracted, so that to make the next patch more readable > (NOR_FLASH_ID_DEFAULT_LEN is removed there). I will substitute it with > PcdGetSize (PcdSpiFlashId). Right, OK, that sort of thing is useful to mention in the cover letter. But there's also MAX_ID_LEN, which is added here only to allocate buffers that are hard-coded to always contain value of ID_DEFAULT_LEN. Surely this could just be left out? / Leif