linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
To: Mike Frysinger <vapier-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org>
Cc: uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b@public.gmane.org,
	Cliff Cai <cliff.cai-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>,
	David Brownell
	<dbrownell-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>,
	Michael Hennerich
	<michael.hennerich-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>,
	spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: [Uclinux-dist-devel] [PATCH] spi/bfin_sport_spi: new driver to emulate a SPI bus using Blackfin SPORT peripheral
Date: Mon, 10 Jan 2011 08:22:01 -0700	[thread overview]
Message-ID: <20110110152201.GA392@angua.secretlab.ca> (raw)
In-Reply-To: <AANLkTikpQHNRinCXOPFKfCqwCaNGa2VavFHG9juDw9cK-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

On Mon, Jan 10, 2011 at 09:39:40AM -0500, Mike Frysinger wrote:
> On Mon, Nov 1, 2010 at 01:56, Grant Likely wrote:
> > On Fri, Oct 22, 2010 at 02:53:35AM -0400, Mike Frysinger wrote:
> >> +     /* SPI framework hookup */
> >> +     struct spi_master *master;
> >> +
> >> +     /* Regs base of SPI controller */
> >> +     volatile struct sport_register __iomem *regs;
> >
> > Drop the volatile.  Registers must never be dereferenced directly
> > anyway.
> >
> >> +static void bfin_sport_spi_enable(struct master_data *drv_data)
> >> +{
> >> +     drv_data->regs->tcr1 |= TSPEN;
> >> +     drv_data->regs->rcr1 |= TSPEN;
> >
> > Illegal direct dereference; use ioread/iowrite instead.  Ditto through
> > rest of file.
> 
> that's not correct.  ioread/iowrite are fine if the devices were
> generically mapped through say the asynchronous memory bus, but these
> registers arent.  they're mapped directly into the Blackfin hardware
> system bus and have different semantics than the async memory bus.

It is not okay to use direct register dereference in Linux for well
documented reasons (see volatile-considered-harmful.txt).  In
particular, accessors prevent either the compiler or the CPU from
reordering or optimizing out accesses to registers in a predictable
way.  volatile is strongly discouraged.  I may have the specific
accessor routine name wrong for the blackfin use case, but direct
dereference is definitely not okay.

> 
> >> +     SSYNC();
> >
> > The SSYNC shouldn't be necessary with the correct accessors.
> 
> independently incorrect from the ioread/iowrite comment.  there's no
> way any register accessors function would ever impose a SSYNC on the
> Blackfin architecture.  this causes a *system* wide sync of *all*
> registers and as such, is used only when necessary.  if we did as you
> proposed and added them to every single read/write, it would kill
> performance.

Fair enough.

g.

  parent reply	other threads:[~2011-01-10 15:22 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-22  6:53 [PATCH] spi/bfin_sport_spi: new driver to emulate a SPI bus using Blackfin SPORT peripheral Mike Frysinger
     [not found] ` <1287730415-6246-1-git-send-email-vapier-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org>
2010-10-22  7:16   ` Grant Likely
     [not found]     ` <20101022071630.GA15440-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
2010-10-22  7:24       ` Mike Frysinger
     [not found]         ` <AANLkTi=_u_0FksCzJix1Dw9Ui-Xf5C9J46CUvppSqUCJ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-10-22  7:29           ` [Uclinux-dist-devel] " Grant Likely
2010-11-01  5:56   ` Grant Likely
     [not found]     ` <20101101055600.GC17587-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
2011-01-10 14:39       ` [Uclinux-dist-devel] " Mike Frysinger
     [not found]         ` <AANLkTikpQHNRinCXOPFKfCqwCaNGa2VavFHG9juDw9cK-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-01-10 15:22           ` Grant Likely [this message]
     [not found]             ` <20110110152201.GA392-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
2011-01-11 16:22               ` Mike Frysinger
2011-01-11 19:22   ` [PATCH v2] spi/bfin_sport_spi: new driver for a SPI bus via the " Mike Frysinger
     [not found]     ` <1294773725-4026-1-git-send-email-vapier-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org>
2011-02-15 21:20       ` Grant Likely
     [not found]         ` <20110215212052.GB28005-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
2011-03-28  9:55           ` Mike Frysinger
2011-03-28  8:57       ` [PATCH v3] spi/spi_bfin_sport: " Mike Frysinger
     [not found]         ` <1301302631-21857-1-git-send-email-vapier-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org>
2011-05-25 20:04           ` Mike Frysinger
2011-05-27  7:21           ` Grant Likely

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=20110110152201.GA392@angua.secretlab.ca \
    --to=grant.likely-s3s/wqlpoipyb63q8fvjnq@public.gmane.org \
    --cc=cliff.cai-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org \
    --cc=dbrownell-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=michael.hennerich-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org \
    --cc=spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b@public.gmane.org \
    --cc=vapier-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org \
    /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;
as well as URLs for NNTP newsgroup(s).