All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: "Fangjian (Jay)" <f.fangjian@huawei.com>
Cc: linux-spi@vger.kernel.org, huangdaode@huawei.com, linuxarm@huawei.com
Subject: Re: [PATCH] spi: Add HiSilicon SPI controller driver support
Date: Thu, 4 Mar 2021 12:34:25 +0000	[thread overview]
Message-ID: <20210304123425.GA4731@sirena.org.uk> (raw)
In-Reply-To: <79a0bb79-654b-8afc-f34a-c3a08bae275c@huawei.com>

[-- Attachment #1: Type: text/plain, Size: 1997 bytes --]

On Thu, Mar 04, 2021 at 10:54:40AM +0800, Fangjian (Jay) wrote:
> On 2021/3/1 21:54, Mark Brown wrote:
> > On Mon, Mar 01, 2021 at 07:56:11PM +0800, Jay Fang wrote:

> > > +/* Disable IRQ bits */
> > > +static void hisi_spi_mask_intr(struct hisi_spi *hs, u32 mask)
> > > +{
> > > +	u32 new_mask;
> > > +
> > > +	new_mask = readl(hs->regs + HISI_SPI_IMR) | mask;
> > > +	writel(new_mask, hs->regs + HISI_SPI_IMR);
> > > +}

> > This is a read/modify/write cycle and appears to be called from at least
> > process and interrupt context but I'm not seeing anything that stops two
> > different callers of it or the matching unmask function from running at
> > the same time.

> Those mask/unmask will not be called at the same time from process and
> interrupt context. In process context, unmask will be called after SPI
> controller be Disable and Flush (interrupt handing has ended).

Given that this is disabling the interrupt that doesn't sound like it's
going to be entirely robust - if we need to disable the interrupt
presumably there's some chance it might fire.

> > > +	struct hisi_spi *hs = spi_controller_get_devdata(master);
> > > +
> > > +	hs->n_bytes = hisi_spi_n_bytes(transfer);
> > > +	hs->tx = (void *)transfer->tx_buf;
> > If there's a need to cast to void * something is very wrong here.

> Yes, fix compile warning.

This cast just masks whatever the problem is, if the compiler is
complaining about using a void pointer it's spotted an issue.

> > > +	/* Ensure the data above is visible for all CPUs */
> > > +	smp_mb();

> > This memory barrier seems worrying...  are you *sure* this is the best
> > way to sync, and that the sync is best done here if it is needed rather
> > than after everything else is set up?

> The commit 0b6bfad ("spi: spi-dw: Remove extraneous locking") explains
> why memory barrier is needed here. And put it here to make it easier to
> understand.

The reader of this code won't have any kind of pointer to that commit,
this needs to be clearer.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  parent reply	other threads:[~2021-03-04 12:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-01 11:56 [PATCH] spi: Add HiSilicon SPI controller driver support Jay Fang
2021-03-01 13:54 ` Mark Brown
2021-03-04  6:54   ` Fangjian (Jay)
     [not found]   ` <79a0bb79-654b-8afc-f34a-c3a08bae275c@huawei.com>
2021-03-04 12:34     ` Mark Brown [this message]
2021-03-08 11:24       ` Jay Fang
2021-03-07 14:43   ` Lukas Wunner
2021-03-08 14:11     ` Mark Brown
2021-03-08 18:18       ` Lukas Wunner
2021-03-08 18:28         ` Mark Brown
2021-03-09  9:13     ` Jay Fang
2021-03-07 14:36 ` Lukas Wunner
2021-03-08  3:57   ` Jay Fang
2021-03-08  8:06     ` Lukas Wunner

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=20210304123425.GA4731@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=f.fangjian@huawei.com \
    --cc=huangdaode@huawei.com \
    --cc=linux-spi@vger.kernel.org \
    --cc=linuxarm@huawei.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.