All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fabrizio Castro <fabrizio.castro.jz@renesas.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>,
	Mark Brown <broonie@kernel.org>,
	"linux-spi@vger.kernel.org" <linux-spi@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Chris Paterson <Chris.Paterson2@renesas.com>,
	Biju Das <biju.das@bp.renesas.com>,
	Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>,
	"linux-renesas-soc@vger.kernel.org" 
	<linux-renesas-soc@vger.kernel.org>
Subject: RE: [PATCH 07/10] spi: rzv2m-csi: Switch to using {read,write}s{b,w}
Date: Mon, 17 Jul 2023 13:00:21 +0000	[thread overview]
Message-ID: <TYWPR01MB8775B01AB7A7FA59E38F77D6C23BA@TYWPR01MB8775.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <CAHp75VdNvWS04VN58r5VcSJskeVJF0g0_spSRb8f0_OP1P04QQ@mail.gmail.com>

Hi Andy,

Thanks for your reply.

> From: Andy Shevchenko <andy.shevchenko@gmail.com>
> Subject: Re: [PATCH 07/10] spi: rzv2m-csi: Switch to using
> {read,write}s{b,w}
> 
> On Mon, Jul 17, 2023 at 1:36 PM Fabrizio Castro
> <fabrizio.castro.jz@renesas.com> wrote:
> > > From: Geert Uytterhoeven <geert@linux-m68k.org>
> > > Subject: Re: [PATCH 07/10] spi: rzv2m-csi: Switch to using
> > > {read,write}s{b,w}
> > > On Sat, Jul 15, 2023 at 3:04 AM Fabrizio Castro
> > > <fabrizio.castro.jz@renesas.com> wrote:
> 
> ...
> 
> > > According to the hardware documentation[1], the access size for
> both
> > > the
> > > CSI_OFIFO and CSI_IFIFO registers is 32 bits, so you must use
> writel()
> > > resp. readl().  So please check with the hardware people first.
> > >
> > > [1] RZ/V2M User's Manual Hardware, Rev. 1.30.
> >
> > You are right, access is 32 bits (and although this patch works
> fine,
> > we should avoid accessing those regs any other way). Now I remember
> > why I decided to go for the bespoke loops in the first place,
> writesl
> > and readsl provide the right register access, but the wrong pointer
> > arithmetic for this use case.
> > For this patch I ended up selecting writesw/writesb/readsw/readsb to
> > get the right pointer arithmetic, but the register access is not as
> > per manual.
> >
> > I can either fallback to using the bespoke loops (I can still
> > remove the unnecessary u8* and u16* casting ;-) ), or I can add
> > new APIs for this sort of access to io.h (e.g. writesbl, writeswl,
> > readsbl, readswl, in order to get the pointer arithmetic right for
> > the type of array handled, while keeping memory access as expected).
> >
> > What are your thoughts on that?
> 
> I think that you need to use readsl() / writesl() on the custom buffer
> with something like
> 
> *_sparse() / *_condence() APIs added (perhaps locally to this driver)
> as they may be reused by others in the future.
> Having all flavours of read*()/write*() does not scale in my opinion.

Maybe a "generic" macro then (one for reading and one for writing)?
So that we can pass the data type (to get the pointer arithmetic
right) and the function name to use for the read/write operations
(to get the register operations right)?
Maybe that would scale and cater for most needs (including the one
from this patch)?

Cheers,
Fab

> 
> --
> With Best Regards,
> Andy Shevchenko

  reply	other threads:[~2023-07-17 13:01 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-15  1:03 [PATCH 00/10] spi: rzv2m-csi: Code refactoring Fabrizio Castro
2023-07-15  1:03 ` [PATCH 01/10] spi: rzv2m-csi: Add missing include Fabrizio Castro
2023-07-15  1:03 ` [PATCH 02/10] spi: rzv2m-csi: Adopt HZ_PER_MHZ for max spi clock Fabrizio Castro
2023-07-17  9:24   ` Geert Uytterhoeven
2023-07-15  1:04 ` [PATCH 03/10] spi: rzv2m-csi: Rework CSI_CKS_MAX definition Fabrizio Castro
2023-07-17  9:27   ` Geert Uytterhoeven
2023-07-15  1:04 ` [PATCH 04/10] spi: rzv2m-csi: Leave readl_poll_timeout calls for last Fabrizio Castro
2023-07-17  9:29   ` Geert Uytterhoeven
2023-07-15  1:04 ` [PATCH 05/10] spi: rzv2m-csi: Replace unnecessary ternary operators Fabrizio Castro
2023-07-17  9:30   ` Geert Uytterhoeven
2023-07-15  1:04 ` [PATCH 06/10] spi: rzv2m-csi: Squash timing settings into one statement Fabrizio Castro
2023-07-15  7:54   ` Andy Shevchenko
2023-07-17 10:44     ` Fabrizio Castro
2023-07-17 11:15       ` Andy Shevchenko
2023-07-15  1:04 ` [PATCH 07/10] spi: rzv2m-csi: Switch to using {read,write}s{b,w} Fabrizio Castro
2023-07-17  9:37   ` Geert Uytterhoeven
2023-07-17 10:36     ` Fabrizio Castro
2023-07-17 11:18       ` Andy Shevchenko
2023-07-17 13:00         ` Fabrizio Castro [this message]
2023-07-17 16:31           ` Fabrizio Castro
2023-07-15  1:04 ` [PATCH 08/10] spi: rzv2m-csi: Improve data types and alignment Fabrizio Castro
2023-07-17  9:44   ` Geert Uytterhoeven
2023-07-15  1:04 ` [PATCH 09/10] spi: rzv2m-csi: Get rid of the x_trg{_words} tables Fabrizio Castro
2023-07-15  7:57   ` Andy Shevchenko
2023-07-17  9:49   ` Geert Uytterhoeven
2023-07-15  1:04 ` [PATCH 10/10] spi: rzv2m-csi: Make use of device_set_node Fabrizio Castro
2023-07-15  7:58   ` Andy Shevchenko
2023-07-17 15:05     ` Fabrizio Castro
2023-07-15  8:00 ` [PATCH 00/10] spi: rzv2m-csi: Code refactoring Andy Shevchenko
2023-07-18 18:46 ` (subset) " Mark Brown

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=TYWPR01MB8775B01AB7A7FA59E38F77D6C23BA@TYWPR01MB8775.jpnprd01.prod.outlook.com \
    --to=fabrizio.castro.jz@renesas.com \
    --cc=Chris.Paterson2@renesas.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=biju.das@bp.renesas.com \
    --cc=broonie@kernel.org \
    --cc=geert@linux-m68k.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    /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.