From: Brendan Higgins <brendanhiggins@google.com>
To: jae.hyun.yoo@linux.intel.com
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Joel Stanley <joel@jms.id.au>, Andrew Jeffery <andrew@aj.id.au>,
linux-i2c@vger.kernel.org,
OpenBMC Maillist <openbmc@lists.ozlabs.org>,
Linux ARM <linux-arm-kernel@lists.infradead.org>,
linux-aspeed@lists.ozlabs.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
jarkko.nikula@linux.intel.com, james.feist@linux.intel.com,
vernon.mauery@linux.intel.com
Subject: Re: [PATCH] i2c: aspeed: Adjust spinlock scope in the irq handler
Date: Thu, 12 Jul 2018 01:41:28 -0700 [thread overview]
Message-ID: <CAFd5g47nBCbF0mcYqEnQkDpz0Dhh0F0S1-wEL_yBHgs1b3yE5w@mail.gmail.com> (raw)
In-Reply-To: <20180702214011.16071-1-jae.hyun.yoo@linux.intel.com>
On Mon, Jul 2, 2018 at 2:40 PM Jae Hyun Yoo
<jae.hyun.yoo@linux.intel.com> wrote:
>
> This patch adjusts spinlock scope to make it wrap the whole irq
> handler using a single lock/unlock which covers both master and
> slave handlers.
>
> Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>
> ---
> drivers/i2c/busses/i2c-aspeed.c | 16 ++++++++++------
> 1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c
> index 60e4d0e939a3..9f02aa959a3e 100644
> --- a/drivers/i2c/busses/i2c-aspeed.c
> +++ b/drivers/i2c/busses/i2c-aspeed.c
> @@ -234,7 +234,6 @@ static bool aspeed_i2c_slave_irq(struct aspeed_i2c_bus *bus)
> bool irq_handled = true;
> u8 value;
>
> - spin_lock(&bus->lock);
> if (!slave) {
> irq_handled = false;
> goto out;
> @@ -325,7 +324,6 @@ static bool aspeed_i2c_slave_irq(struct aspeed_i2c_bus *bus)
> writel(status_ack, bus->base + ASPEED_I2C_INTR_STS_REG);
>
> out:
> - spin_unlock(&bus->lock);
> return irq_handled;
> }
> #endif /* CONFIG_I2C_SLAVE */
> @@ -389,7 +387,6 @@ static bool aspeed_i2c_master_irq(struct aspeed_i2c_bus *bus)
> u8 recv_byte;
> int ret;
>
> - spin_lock(&bus->lock);
> irq_status = readl(bus->base + ASPEED_I2C_INTR_STS_REG);
> /* Ack all interrupt bits. */
> writel(irq_status, bus->base + ASPEED_I2C_INTR_STS_REG);
> @@ -547,22 +544,29 @@ static bool aspeed_i2c_master_irq(struct aspeed_i2c_bus *bus)
> dev_err(bus->dev,
> "irq handled != irq. expected 0x%08x, but was 0x%08x\n",
> irq_status, status_ack);
> - spin_unlock(&bus->lock);
> return !!irq_status;
> }
>
> static irqreturn_t aspeed_i2c_bus_irq(int irq, void *dev_id)
> {
> struct aspeed_i2c_bus *bus = dev_id;
> + bool ret;
> +
> + spin_lock(&bus->lock);
>
> #if IS_ENABLED(CONFIG_I2C_SLAVE)
> if (aspeed_i2c_slave_irq(bus)) {
> dev_dbg(bus->dev, "irq handled by slave.\n");
> - return IRQ_HANDLED;
> + ret = true;
> + goto out;
> }
> #endif /* CONFIG_I2C_SLAVE */
>
> - return aspeed_i2c_master_irq(bus) ? IRQ_HANDLED : IRQ_NONE;
> + ret = aspeed_i2c_master_irq(bus);
> +
> +out:
> + spin_unlock(&bus->lock);
> + return ret ? IRQ_HANDLED : IRQ_NONE;
> }
>
> static int aspeed_i2c_master_xfer(struct i2c_adapter *adap,
> --
> 2.17.1
>
Reviewed-by: Brendan Higgins <brendanhiggins@google.com>
Thanks!
next prev parent reply other threads:[~2018-07-12 8:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-02 21:40 [PATCH] i2c: aspeed: Adjust spinlock scope in the irq handler Jae Hyun Yoo
2018-07-12 8:41 ` Brendan Higgins [this message]
2018-07-13 19:21 ` Jae Hyun Yoo
2018-07-13 20:33 ` Wolfram Sang
2018-07-13 20:37 ` Jae Hyun Yoo
2018-07-20 22:29 ` Wolfram Sang
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=CAFd5g47nBCbF0mcYqEnQkDpz0Dhh0F0S1-wEL_yBHgs1b3yE5w@mail.gmail.com \
--to=brendanhiggins@google.com \
--cc=andrew@aj.id.au \
--cc=benh@kernel.crashing.org \
--cc=jae.hyun.yoo@linux.intel.com \
--cc=james.feist@linux.intel.com \
--cc=jarkko.nikula@linux.intel.com \
--cc=joel@jms.id.au \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-aspeed@lists.ozlabs.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=openbmc@lists.ozlabs.org \
--cc=vernon.mauery@linux.intel.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 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).