linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: g.liakhovetski@gmx.de (Guennadi Liakhovetski)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 06/13] atmel-isi: check ISI_SR's flags by polling instead of interrupt
Date: Tue, 26 Jan 2016 15:38:13 +0100 (CET)	[thread overview]
Message-ID: <Pine.LNX.4.64.1601261528560.28816@axis700.grange> (raw)
In-Reply-To: <CAJe_HAeKRtAzcz+s7D_5sXp9pnnM1Mhvu_3L1HQGPLsJLJbTSw@mail.gmail.com>

On Tue, 26 Jan 2016, Josh Wu wrote:

> Hi, Guennadi
> 
> 2016-01-25 0:58 GMT+08:00 Guennadi Liakhovetski <g.liakhovetski@gmx.de>:
> > On Mon, 18 Jan 2016, Josh Wu wrote:
> >
> >> In current code, we use a interrupt to check whether ISI reset/disable
> >> action is done. Actually, we also can check ISI SR to check the
> >> reset/disable action by polling, and it is simpler and straight forward.
> >>
> >> So this patch use isi_hw_wait_status() to check the action status. As
> >> the interrupt checking the status is useless, so just remove the interrupt
> >> & completion code.
> >
> > Sorry, I'm not convinced. Switching from interrupt-driven to polling seems
> > counter-productive to me. Why do you want this?
> 
> Yes, it is counter-productive If such code is called very frequently.
> But here we only used for reset and disable the hardware.
> 
> I think it is more straightforward and simple when we just check
> status register after write the reset or disable the ISI control
> register. Using interrupt here is over designed.

I still don't see how you're gaining from this. If you were writing new 
code and you would say: "you know, this path will only be hit rarely, we 
don't know whether interrupt would work, but we have here this simple 
polling solution, that works" I would understand. But you already have a 
technically-superior solution in place! And it works, right? Why change 
it? On the one hand it's your hardware and it's up to you which direction 
to develop it, and my task is just to help you integrate your work into 
the mainline. On the other hand I really don't see any benefits, sorry. 
I'd prefer not to do this unless you can explain the benefits.

> for the sake of performance I should use cpu_releax() instead of
> msleep() when waiting for the status bit.

Don't think that's a good idea. cpu_relax() allows the scheduler to switch 
over to a different task, but if none is active, it'll come back instead 
of going to sleep. Unless of course your event really kicks in very 
quickly - much faster than 1ms. But depending on your architecture 
implementation, msleep(1) might also be implemented as a busy look, then 
cpu_relax() would be better.

Thanks
Guennadi

> 
> Best Regards,
> Josh Wu
> 
> >
> > Thanks
> > Guennadi
> >
> >>
> >> Signed-off-by: Josh Wu <rainyfeeling@gmail.com>
> >> ---
> >>
> >>  drivers/media/platform/soc_camera/atmel-isi.c | 59 ++++++---------------------
> >>  1 file changed, 13 insertions(+), 46 deletions(-)
> >>
> >> diff --git a/drivers/media/platform/soc_camera/atmel-isi.c b/drivers/media/platform/soc_camera/atmel-isi.c
> >> index f0508ea..4ddc309 100644
> >> --- a/drivers/media/platform/soc_camera/atmel-isi.c
> >> +++ b/drivers/media/platform/soc_camera/atmel-isi.c
> >> @@ -12,7 +12,6 @@
> >>   */
> >>
> >>  #include <linux/clk.h>
> >> -#include <linux/completion.h>
> >>  #include <linux/delay.h>
> >>  #include <linux/fs.h>
> >>  #include <linux/init.h>
> >> @@ -81,7 +80,6 @@ struct atmel_isi {
> >>       struct isi_dma_desc             dma_desc[MAX_BUFFER_NUM];
> >>       bool                            enable_preview_path;
> >>
> >> -     struct completion               complete;
> >>       /* ISI peripherial clock */
> >>       struct clk                      *pclk;
> >>       unsigned int                    irq;
> >> @@ -281,51 +279,14 @@ static irqreturn_t isi_interrupt(int irq, void *dev_id)
> >>       mask = isi_readl(isi, ISI_INTMASK);
> >>       pending = status & mask;
> >>
> >> -     if (pending & ISI_CTRL_SRST) {
> >> -             complete(&isi->complete);
> >> -             isi_writel(isi, ISI_INTDIS, ISI_CTRL_SRST);
> >> -             ret = IRQ_HANDLED;
> >> -     } else if (pending & ISI_CTRL_DIS) {
> >> -             complete(&isi->complete);
> >> -             isi_writel(isi, ISI_INTDIS, ISI_CTRL_DIS);
> >> -             ret = IRQ_HANDLED;
> >> -     } else {
> >> -             if (likely(pending & ISI_SR_CXFR_DONE) ||
> >> -                             likely(pending & ISI_SR_PXFR_DONE))
> >> -                     ret = atmel_isi_handle_streaming(isi);
> >> -     }
> >> +     if (likely(pending & ISI_SR_CXFR_DONE) ||
> >> +         likely(pending & ISI_SR_PXFR_DONE))
> >> +             ret = atmel_isi_handle_streaming(isi);
> >>
> >>       spin_unlock(&isi->lock);
> >>       return ret;
> >>  }
> >>
> >> -#define      WAIT_ISI_RESET          1
> >> -#define      WAIT_ISI_DISABLE        0
> >> -static int atmel_isi_wait_status(struct atmel_isi *isi, int wait_reset)
> >> -{
> >> -     unsigned long timeout;
> >> -     /*
> >> -      * The reset or disable will only succeed if we have a
> >> -      * pixel clock from the camera.
> >> -      */
> >> -     init_completion(&isi->complete);
> >> -
> >> -     if (wait_reset) {
> >> -             isi_writel(isi, ISI_INTEN, ISI_CTRL_SRST);
> >> -             isi_writel(isi, ISI_CTRL, ISI_CTRL_SRST);
> >> -     } else {
> >> -             isi_writel(isi, ISI_INTEN, ISI_CTRL_DIS);
> >> -             isi_writel(isi, ISI_CTRL, ISI_CTRL_DIS);
> >> -     }
> >> -
> >> -     timeout = wait_for_completion_timeout(&isi->complete,
> >> -                     msecs_to_jiffies(500));
> >> -     if (timeout == 0)
> >> -             return -ETIMEDOUT;
> >> -
> >> -     return 0;
> >> -}
> >> -
> >>  /* ------------------------------------------------------------------
> >>       Videobuf operations
> >>     ------------------------------------------------------------------*/
> >> @@ -493,8 +454,11 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
> >>       pm_runtime_get_sync(ici->v4l2_dev.dev);
> >>
> >>       /* Reset ISI */
> >> -     ret = atmel_isi_wait_status(isi, WAIT_ISI_RESET);
> >> -     if (ret < 0) {
> >> +     isi_writel(isi, ISI_CTRL, ISI_CTRL_SRST);
> >> +
> >> +     /* Check Reset status */
> >> +     ret  = isi_hw_wait_status(isi, ISI_CTRL_SRST, 500);
> >> +     if (ret) {
> >>               dev_err(icd->parent, "Reset ISI timed out\n");
> >>               pm_runtime_put(ici->v4l2_dev.dev);
> >>               return ret;
> >> @@ -549,8 +513,11 @@ static void stop_streaming(struct vb2_queue *vq)
> >>                       ISI_SR_CXFR_DONE | ISI_SR_PXFR_DONE);
> >>
> >>       /* Disable ISI and wait for it is done */
> >> -     ret = atmel_isi_wait_status(isi, WAIT_ISI_DISABLE);
> >> -     if (ret < 0)
> >> +     isi_writel(isi, ISI_CTRL, ISI_CTRL_DIS);
> >> +
> >> +     /* Check Reset status */
> >> +     ret  = isi_hw_wait_status(isi, ISI_CTRL_DIS, 500);
> >> +     if (ret)
> >>               dev_err(icd->parent, "Disable ISI timed out\n");
> >>
> >>       pm_runtime_put(ici->v4l2_dev.dev);
> >> --
> >> 1.9.1
> >>
> 

  reply	other threads:[~2016-01-26 14:38 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-18 12:21 [PATCH 00/13] media: atmel-isi: extract the hw releated functions into structure Josh Wu
2016-01-18 12:21 ` [PATCH 01/13] atmel-isi: use try_or_set_fmt() for both set_fmt() and try_fmt() Josh Wu
2016-01-24 16:11   ` Guennadi Liakhovetski
2016-01-18 12:21 ` [PATCH 02/13] atmel-isi: move the is_support() close to try/set format function Josh Wu
2016-01-24 16:12   ` Guennadi Liakhovetski
2016-01-18 12:21 ` [PATCH 03/13] atmel-isi: add isi_hw_initialize() function to handle hw setup Josh Wu
2016-01-18 12:21 ` [PATCH 04/13] atmel-isi: move the cfg1 initialize to isi_hw_initialize() Josh Wu
2016-01-18 12:21 ` [PATCH 05/13] atmel-isi: add a function: isi_hw_wait_status() to check ISI_SR status Josh Wu
2016-01-18 12:52 ` [PATCH 06/13] atmel-isi: check ISI_SR's flags by polling instead of interrupt Josh Wu
2016-01-18 12:52   ` [PATCH 07/13] atmel-isi: move hw code into isi_hw_initialize() Josh Wu
2016-01-24 18:09     ` Guennadi Liakhovetski
2016-01-26 14:07       ` Josh Wu
2016-01-18 12:52   ` [PATCH 08/13] atmel-isi: remove the function set_dma_ctrl() as it just use once Josh Wu
2016-01-18 12:52   ` [PATCH 09/13] atmel-isi: add a function start_isi() Josh Wu
2016-01-18 12:52   ` [PATCH 10/13] atmel-isi: reuse start_dma() function in isi interrupt handler Josh Wu
2016-01-18 12:52   ` [PATCH 11/13] atmel-isi: add hw_uninitialize() in stop_streaming() Josh Wu
2016-01-18 12:52   ` [PATCH 11/13] atmel-isi: add hw_uninitialize() Josh Wu
2016-01-18 12:52   ` [PATCH 12/13] atmel-isi: use union for the fbd (frame buffer descriptor) Josh Wu
2016-01-24 19:31     ` Guennadi Liakhovetski
2016-01-26 14:04       ` Josh Wu
2016-01-26 14:10         ` Guennadi Liakhovetski
2016-01-26 14:24           ` Josh Wu
2016-01-26 14:39             ` Guennadi Liakhovetski
2016-01-18 12:52   ` [PATCH 13/13] atmel-isi: use an hw_data structure according compatible string Josh Wu
2016-01-24 16:58   ` [PATCH 06/13] atmel-isi: check ISI_SR's flags by polling instead of interrupt Guennadi Liakhovetski
2016-01-26 14:16     ` Josh Wu
2016-01-26 14:38       ` Guennadi Liakhovetski [this message]
2016-01-19 14:52 ` [PATCH 00/13] media: atmel-isi: extract the hw releated functions into structure Ludovic Desroches
2016-01-21 14:19   ` Josh Wu

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=Pine.LNX.4.64.1601261528560.28816@axis700.grange \
    --to=g.liakhovetski@gmx.de \
    --cc=linux-arm-kernel@lists.infradead.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).