From: Andi Shyti <andi.shyti@kernel.org>
To: Yicong Yang <yangyicong@huawei.com>
Cc: yangyicong@hisilicon.com, wsa@kernel.org,
linux-i2c@vger.kernel.org, f.fangjian@huawei.com,
linuxarm@huawei.com
Subject: Re: [PATCH] i2c: hisi: Only handle the interrupt of the driver's transfer
Date: Wed, 9 Aug 2023 22:08:51 +0200 [thread overview]
Message-ID: <20230809200851.kwvjvc6cea7qgwgm@intel.intel> (raw)
In-Reply-To: <d50d5d19-4f5f-8c5b-2505-1195fa314976@huawei.com>
Hi Yicong,
[...]
> >>>> @@ -330,6 +330,14 @@ static irqreturn_t hisi_i2c_irq(int irq, void *context)
> >>>> struct hisi_i2c_controller *ctlr = context;
> >>>> u32 int_stat;
> >>>>
> >>>> + /*
> >>>> + * Don't handle the interrupt if cltr->completion is NULL. We may
> >>>> + * reach here because the interrupt is spurious or the transfer is
> >>>> + * started by another port rather than us.
> >>>> + */
> >>>> + if (!ctlr->completion)
> >>>> + return IRQ_NONE;
> >>>
> >>> Is this the place you should really check for completion being
> >>> NULL? By reading the code I don't exclude that completion at this
> >>> stage might be NULL.
> >>>
> >>> Can it be that the real fix is this one instead:
> >>
> >> Maybe not. If we handle the case as late as below, we'll operate the hardware
> >> which should be handled by the firmware which start the transfer. So we check
> >> it as early as possible.
> >
> > But if i2c_master_xfer() is not called and we receive an irq,
> > most probably ctrl->completion is NULL. Right? Can this happen?
> >
>
> Yes, this is the case.
>
> > I can't really tell the sequence for enabling/disabling the
> > interrupt in this device. They might happen in
> > hisi_i2c_start_xfer() for enabling and in hisi_i2c_xfer_msg() for
> > desabling at the last message; which makes the scenario above a
> > bit difficult, indeed.
> >
>
> The driver will keep the interrupt disabled if no transfer in progress.
> But since the transfer is driven by the interrupt so if the firmware
> start the transfer it will enable the interrupt. In such case the driver
> will receive an interrupt on the Tx FIFO empty, etc and since the
> transfer is not started by the driver ctlr->completion is not
> initialized.
OK... makes sense...
Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Thanks!
Andi
next prev parent reply other threads:[~2023-08-09 20:08 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-01 12:46 [PATCH] i2c: hisi: Only handle the interrupt of the driver's transfer Yicong Yang
2023-08-01 22:15 ` Andi Shyti
2023-08-02 2:39 ` Yicong Yang
2023-08-04 23:30 ` Andi Shyti
2023-08-08 13:11 ` Yicong Yang
2023-08-09 20:08 ` Andi Shyti [this message]
2023-08-09 20:43 ` Andi Shyti
2023-08-14 13:42 ` Wolfram Sang
2023-08-15 8:41 ` Geert Uytterhoeven
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=20230809200851.kwvjvc6cea7qgwgm@intel.intel \
--to=andi.shyti@kernel.org \
--cc=f.fangjian@huawei.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=wsa@kernel.org \
--cc=yangyicong@hisilicon.com \
--cc=yangyicong@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox