All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pratyush Yadav <p.yadav@ti.com>
To: u-boot@lists.denx.de
Subject: [PATCH 05/14] spi: spi-mem: Add debug message for spi-mem ops
Date: Mon, 1 Feb 2021 22:04:09 +0530	[thread overview]
Message-ID: <20210201163407.4nq5pwqlqsgoqjr3@ti.com> (raw)
In-Reply-To: <7581f477-c0c3-c30a-c35b-01036f0953ad@gmail.com>

On 01/02/21 10:33AM, Sean Anderson wrote:
> On 2/1/21 7:18 AM, Pratyush Yadav wrote:
> > On 31/01/21 07:34PM, Sean Anderson wrote:
> > > This prints some basic metadata about the SPI memory op. This information
> > > may be used to debug SPI drivers (e.g. determining the expected SPI mode).
> > > It is also helpful for verifying that the data on the wire matches the data
> > > intended to be transmitted (e.g. with a logic analyzer). The opcode is
> > > printed with a format of %02Xh to match the notation commonly used in flash
> > > datasheets.
> > > 
> > > Signed-off-by: Sean Anderson <seanga2@gmail.com>
> > > ---
> > > 
> > >   drivers/spi/spi-mem.c | 6 ++++++
> > >   1 file changed, 6 insertions(+)
> > > 
> > > diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c
> > > index c095ae9505..eb83c11910 100644
> > > --- a/drivers/spi/spi-mem.c
> > > +++ b/drivers/spi/spi-mem.c
> > > @@ -220,6 +220,12 @@ int spi_mem_exec_op(struct spi_slave *slave, const struct spi_mem_op *op)
> > >   	int ret;
> > >   	int i;
> > > +	dev_dbg(slave->dev, "exec %02Xh %u-%u-%u addr=%llx wait=%u len=%u\n",
> > > +		op->cmd.opcode, op->cmd.buswidth, op->addr.buswidth,
> > > +		op->data.buswidth, op->addr.val,
> > > +		op->dummy.buswidth ? op->dummy.nbytes * 8 / op->dummy.buswidth : 0,
> > 
> > SPI MEM deals with dummy bytes not cycles [0]. Just print them directly
> > instead of converting them to cycles first.
> 
> I chose to do it this way, since as far as I can tell, most quad-spi
> drivers (with the exception of mtk_snfi_spi.c, octeon_spi.c, spi-sifive.c,
> and ti_qspi.c) deal with cycles and not bytes. The spi-nor system also
> specifies dummies in cycles and only converts them to bytes when
> creating a struct spi_mem_op. SPI flash datasheets also typically refer
> to dummies in cycles; since there is no data being transmitted, they
> cannot be truly measured in bytes. Lastly, it is much easier to only
> work in cycles when looking at logic analyzer traces. When switching
> between 1-1-4 and 1-4-4 instructions, the meaning of "cycles" remains
> the same, while "bytes" has a variable amount of time.

I agree that dummy cycles is a better unit than dummy bytes, but that is 
not what is currently being used. You are interpreting the dummy.nbytes 
field rather than simply printing it and letting the reader see what it 
means. We don't pass dummy cycles to the controller. We pass dummy 
bytes. So it makes sense to print that in the debug message.

Anyway, I feel like we are getting into bikeshedding territory. So 
either is fine by me. Choose whichever makes more sense to you, keeping 
my arguments in mind.
 
> > Also agree with Bin that "dummy cycles=" (or dummy bytes if you are
> > printing bytes directly) is clearer.
> 
> Sure.
> > 
> > [0] For now. This might change later. See
> > https://lore.kernel.org/linux-mtd/6396018a-485f-6eb4-7742-bdb5c4335ed4 at microchip.com/
> 
> Would be nice :)
> 
> --Sean
> 
> > 
> > With these fixed,
> > 
> > Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
> > 
> > > +		op->data.nbytes);
> > > +
> > >   	if (!spi_mem_supports_op(slave, op))
> > >   		return -ENOTSUPP;
> > 
> 

-- 
Regards,
Pratyush Yadav
Texas Instruments Inc.

  reply	other threads:[~2021-02-01 16:34 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-01  0:34 [PATCH 00/14] spi: dw: Add support for DUAL/QUAD/OCTAL modes Sean Anderson
2021-02-01  0:34 ` [PATCH 01/14] cmd: sf: Display errno on erase failure Sean Anderson
2021-02-01  5:06   ` Bin Meng
2021-02-01 12:51   ` Pratyush Yadav
2021-02-01  0:34 ` [PATCH 02/14] cmd: sf: Print error on test failure Sean Anderson
2021-02-01  5:06   ` Bin Meng
2021-02-01 12:54   ` Pratyush Yadav
2021-02-01  0:34 ` [PATCH 03/14] mtd: spi-nor-core: Fix typo in documentation Sean Anderson
2021-02-01  5:06   ` Bin Meng
2021-02-01 12:23   ` Pratyush Yadav
2021-02-01  0:34 ` [PATCH 04/14] mtd: spi-mem: Export spi_mem_default_supports_op Sean Anderson
2021-02-01  5:06   ` Bin Meng
2021-02-01 12:07   ` Pratyush Yadav
2021-02-01 15:15     ` Sean Anderson
2021-02-01  0:34 ` [PATCH 05/14] spi: spi-mem: Add debug message for spi-mem ops Sean Anderson
2021-02-01  5:06   ` Bin Meng
2021-02-01 12:18   ` Pratyush Yadav
2021-02-01 15:33     ` Sean Anderson
2021-02-01 16:34       ` Pratyush Yadav [this message]
2021-02-01  0:34 ` [PATCH 06/14] spi: dw: Log status register on timeout Sean Anderson
2021-02-01  0:34 ` [PATCH 07/14] spi: dw: Mask all possible interrupts Sean Anderson
2021-02-04  4:51   ` Sean Anderson
2021-02-01  0:34 ` [PATCH 08/14] spi: dw: Switch to capabilities Sean Anderson
2021-02-01  0:34 ` [PATCH 09/14] spi: dw: Rewrite poll_transfer logic Sean Anderson
2021-02-01  0:34 ` [PATCH 10/14] spi: dw: Add DUAL/QUAD/OCTAL caps Sean Anderson
2021-02-01 18:00   ` Sean Anderson
2021-02-01  0:34 ` [PATCH 11/14] spi: dw: Add registers necessary for DUAL/QUAD/OCTAL Sean Anderson
2021-02-01  0:34 ` [PATCH 12/14] spi: dw: Support DUAL/QUAD/OCTAL Sean Anderson
2021-02-01  0:34 ` [PATCH 13/14] spi: dw: Support clock stretching Sean Anderson
2021-02-01  0:34 ` [PATCH 14/14] riscv: k210: Enable QSPI for spi3 Sean Anderson
2021-02-01  5:16   ` Bin Meng
2021-02-04  2:32   ` Leo Liang

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-all 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=20210201163407.4nq5pwqlqsgoqjr3@ti.com \
    --to=p.yadav@ti.com \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.