public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Leif Lindholm <leif.lindholm@linaro.org>
To: Marcin Wojtas <mw@semihalf.com>
Cc: edk2-devel-01 <edk2-devel@lists.01.org>,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	nadavh@marvell.com, Neta Zur Hershkovits <neta@marvell.com>,
	Kostya Porotchkin <kostap@marvell.com>,
	Hua Jing <jinghua@marvell.com>,
	semihalf-dabros-jan <jsd@semihalf.com>
Subject: Re: [platforms: PATCH 1/6] Marvell/Drivers: MvSpiFlash: Improve ReadId
Date: Wed, 1 Nov 2017 03:14:13 +0000	[thread overview]
Message-ID: <20171101031413.kwvnyuzfyl4mlo7z@bivouac.eciton.net> (raw)
In-Reply-To: <CAPv3WKfAgdDBaSBE-USbVB0qWmPVym=VGmxzr2uY_V0OmZmm0Q@mail.gmail.com>

On Tue, Oct 31, 2017 at 10:22:50AM +0100, Marcin Wojtas wrote:
> 2017-10-31 10:07 GMT+01:00 Leif Lindholm <leif.lindholm@linaro.org>:
> > 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 <mw@semihalf.com>
> >> ---
> >>  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


  reply	other threads:[~2017-11-01  3:10 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-31  3:59 [platforms: PATCH 0/6] Armada 7k/8k SPI improvements pt 2 Marcin Wojtas
2017-10-31  3:59 ` [platforms: PATCH 1/6] Marvell/Drivers: MvSpiFlash: Improve ReadId Marcin Wojtas
2017-10-31  9:07   ` Leif Lindholm
2017-10-31  9:22     ` Marcin Wojtas
2017-11-01  3:14       ` Leif Lindholm [this message]
2017-11-01 16:28         ` Marcin Wojtas
2017-10-31  3:59 ` [platforms: PATCH 2/6] Marvell/Drivers: MvSpiFlash: Enable dynamic SPI Flash detection Marcin Wojtas
2017-11-01  3:25   ` Leif Lindholm
2017-11-01 16:35     ` Marcin Wojtas
2017-10-31  3:59 ` [platforms: PATCH 3/6] Marvell/Drivers: MvSpiFlash: Remove duplicated macros Marcin Wojtas
2017-11-01  3:27   ` Leif Lindholm
2017-11-01 16:36     ` Marcin Wojtas
2017-10-31  3:59 ` [platforms: PATCH 4/6] Marvell/Applications: SpiTool: Do not override existing slave device Marcin Wojtas
2017-11-01  3:45   ` Leif Lindholm
2017-11-01 16:40     ` Marcin Wojtas
2017-11-01 17:15       ` Ard Biesheuvel
2017-10-31  3:59 ` [platforms: PATCH 5/6] Marvell/Drivers: MvSpiFlash: Fix bank selection for Spansion Marcin Wojtas
2017-11-01  3:50   ` Leif Lindholm
2017-11-01 16:41     ` Marcin Wojtas
2017-10-31  3:59 ` [platforms: PATCH 6/6] Marvell/Drivers: MvSpiDxe: Keep data in SPI_DEVICE structure Marcin Wojtas
2017-11-01  3:54   ` Leif Lindholm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171101031413.kwvnyuzfyl4mlo7z@bivouac.eciton.net \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox