All of lore.kernel.org
 help / color / mirror / Atom feed
From: vinod.koul@intel.com (Vinod Koul)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 4/4] dmaengine: xilinx_vdma: Use readl_poll_timeout instead of do while loop's
Date: Thu, 3 Mar 2016 20:59:57 +0530	[thread overview]
Message-ID: <20160303152957.GM11154@localhost> (raw)
In-Reply-To: <1456495434-11722-4-git-send-email-appanad@xilinx.com>

On Fri, Feb 26, 2016 at 07:33:54PM +0530, Kedareswara rao Appana wrote:

>  static void xilinx_vdma_halt(struct xilinx_vdma_chan *chan)
>  {
> -	int loop = XILINX_VDMA_LOOP_COUNT;
> +	int err = 0;
> +	u32 val;
>  
>  	vdma_ctrl_clr(chan, XILINX_VDMA_REG_DMACR, XILINX_VDMA_DMACR_RUNSTOP);
>  
>  	/* Wait for the hardware to halt */
> -	do {
> -		if (vdma_ctrl_read(chan, XILINX_VDMA_REG_DMASR) &
> -		    XILINX_VDMA_DMASR_HALTED)
> -			break;
> -	} while (loop--);
> +	err = xilinx_vdma_poll_timeout(chan, XILINX_VDMA_REG_DMASR, val,
> +				      (val & XILINX_VDMA_DMASR_HALTED), 0,
> +				      XILINX_VDMA_LOOP_COUNT);
>  
> -	if (!loop) {
> +	if (err) {
>  		dev_err(chan->dev, "Cannot stop channel %p: %x\n",
>  			chan, vdma_ctrl_read(chan, XILINX_VDMA_REG_DMASR));
>  		chan->err = true;
> @@ -576,18 +579,17 @@ static void xilinx_vdma_halt(struct xilinx_vdma_chan *chan)
>   */
>  static void xilinx_vdma_start(struct xilinx_vdma_chan *chan)
>  {
> -	int loop = XILINX_VDMA_LOOP_COUNT;
> +	int err = 0;

why is this initialization required here and other places?

> +	u32 val;
>  
>  	vdma_ctrl_set(chan, XILINX_VDMA_REG_DMACR, XILINX_VDMA_DMACR_RUNSTOP);
>  
>  	/* Wait for the hardware to start */
> -	do {
> -		if (!(vdma_ctrl_read(chan, XILINX_VDMA_REG_DMASR) &
> -		      XILINX_VDMA_DMASR_HALTED))
> -			break;
> -	} while (loop--);
> +	err = xilinx_vdma_poll_timeout(chan, XILINX_VDMA_REG_DMASR, val,
> +				      !(val & XILINX_VDMA_DMASR_HALTED), 0,
> +				      XILINX_VDMA_LOOP_COUNT);
>  
> -	if (!loop) {
> +	if (err) {
>  		dev_err(chan->dev, "Cannot start channel %p: %x\n",
>  			chan, vdma_ctrl_read(chan, XILINX_VDMA_REG_DMASR));
>  
> @@ -754,21 +756,17 @@ static void xilinx_vdma_complete_descriptor(struct xilinx_vdma_chan *chan)
>   */
>  static int xilinx_vdma_reset(struct xilinx_vdma_chan *chan)
>  {
> -	int loop = XILINX_VDMA_LOOP_COUNT;
> +	int err = 0;
>  	u32 tmp;
>  
>  	vdma_ctrl_set(chan, XILINX_VDMA_REG_DMACR, XILINX_VDMA_DMACR_RESET);
>  
> -	tmp = vdma_ctrl_read(chan, XILINX_VDMA_REG_DMACR) &
> -		XILINX_VDMA_DMACR_RESET;
> -
>  	/* Wait for the hardware to finish reset */
> -	do {
> -		tmp = vdma_ctrl_read(chan, XILINX_VDMA_REG_DMACR) &
> -			XILINX_VDMA_DMACR_RESET;
> -	} while (loop-- && tmp);
> +	err = xilinx_vdma_poll_timeout(chan, XILINX_VDMA_REG_DMACR, tmp,
> +				      !(tmp & XILINX_VDMA_DMACR_RESET), 0,
> +				      XILINX_VDMA_LOOP_COUNT);
>  
> -	if (!loop) {
> +	if (err) {



-- 
~Vinod

WARNING: multiple messages have this Message-ID (diff)
From: Vinod Koul <vinod.koul@intel.com>
To: Kedareswara rao Appana <appana.durga.rao@xilinx.com>
Cc: dan.j.williams@intel.com, michal.simek@xilinx.com,
	soren.brinkmann@xilinx.com, appanad@xilinx.com,
	moritz.fischer@ettus.com, laurent.pinchart@ideasonboard.com,
	luis@debethencourt.com, anirudh@xilinx.com,
	dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 4/4] dmaengine: xilinx_vdma: Use readl_poll_timeout instead of do while loop's
Date: Thu, 3 Mar 2016 20:59:57 +0530	[thread overview]
Message-ID: <20160303152957.GM11154@localhost> (raw)
In-Reply-To: <1456495434-11722-4-git-send-email-appanad@xilinx.com>

On Fri, Feb 26, 2016 at 07:33:54PM +0530, Kedareswara rao Appana wrote:

>  static void xilinx_vdma_halt(struct xilinx_vdma_chan *chan)
>  {
> -	int loop = XILINX_VDMA_LOOP_COUNT;
> +	int err = 0;
> +	u32 val;
>  
>  	vdma_ctrl_clr(chan, XILINX_VDMA_REG_DMACR, XILINX_VDMA_DMACR_RUNSTOP);
>  
>  	/* Wait for the hardware to halt */
> -	do {
> -		if (vdma_ctrl_read(chan, XILINX_VDMA_REG_DMASR) &
> -		    XILINX_VDMA_DMASR_HALTED)
> -			break;
> -	} while (loop--);
> +	err = xilinx_vdma_poll_timeout(chan, XILINX_VDMA_REG_DMASR, val,
> +				      (val & XILINX_VDMA_DMASR_HALTED), 0,
> +				      XILINX_VDMA_LOOP_COUNT);
>  
> -	if (!loop) {
> +	if (err) {
>  		dev_err(chan->dev, "Cannot stop channel %p: %x\n",
>  			chan, vdma_ctrl_read(chan, XILINX_VDMA_REG_DMASR));
>  		chan->err = true;
> @@ -576,18 +579,17 @@ static void xilinx_vdma_halt(struct xilinx_vdma_chan *chan)
>   */
>  static void xilinx_vdma_start(struct xilinx_vdma_chan *chan)
>  {
> -	int loop = XILINX_VDMA_LOOP_COUNT;
> +	int err = 0;

why is this initialization required here and other places?

> +	u32 val;
>  
>  	vdma_ctrl_set(chan, XILINX_VDMA_REG_DMACR, XILINX_VDMA_DMACR_RUNSTOP);
>  
>  	/* Wait for the hardware to start */
> -	do {
> -		if (!(vdma_ctrl_read(chan, XILINX_VDMA_REG_DMASR) &
> -		      XILINX_VDMA_DMASR_HALTED))
> -			break;
> -	} while (loop--);
> +	err = xilinx_vdma_poll_timeout(chan, XILINX_VDMA_REG_DMASR, val,
> +				      !(val & XILINX_VDMA_DMASR_HALTED), 0,
> +				      XILINX_VDMA_LOOP_COUNT);
>  
> -	if (!loop) {
> +	if (err) {
>  		dev_err(chan->dev, "Cannot start channel %p: %x\n",
>  			chan, vdma_ctrl_read(chan, XILINX_VDMA_REG_DMASR));
>  
> @@ -754,21 +756,17 @@ static void xilinx_vdma_complete_descriptor(struct xilinx_vdma_chan *chan)
>   */
>  static int xilinx_vdma_reset(struct xilinx_vdma_chan *chan)
>  {
> -	int loop = XILINX_VDMA_LOOP_COUNT;
> +	int err = 0;
>  	u32 tmp;
>  
>  	vdma_ctrl_set(chan, XILINX_VDMA_REG_DMACR, XILINX_VDMA_DMACR_RESET);
>  
> -	tmp = vdma_ctrl_read(chan, XILINX_VDMA_REG_DMACR) &
> -		XILINX_VDMA_DMACR_RESET;
> -
>  	/* Wait for the hardware to finish reset */
> -	do {
> -		tmp = vdma_ctrl_read(chan, XILINX_VDMA_REG_DMACR) &
> -			XILINX_VDMA_DMACR_RESET;
> -	} while (loop-- && tmp);
> +	err = xilinx_vdma_poll_timeout(chan, XILINX_VDMA_REG_DMACR, tmp,
> +				      !(tmp & XILINX_VDMA_DMACR_RESET), 0,
> +				      XILINX_VDMA_LOOP_COUNT);
>  
> -	if (!loop) {
> +	if (err) {



-- 
~Vinod

  reply	other threads:[~2016-03-03 15:29 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-26 14:03 [PATCH v3 1/4] dmaengine: xilinx_vdma: Improve SG engine handling Kedareswara rao Appana
2016-02-26 14:03 ` Kedareswara rao Appana
2016-02-26 14:03 ` [PATCH v3 2/4] dmaengine: xilinx_vdma: Simplify spin lock handling Kedareswara rao Appana
2016-02-26 14:03   ` Kedareswara rao Appana
2016-02-26 14:03 ` [PATCH v3 3/4] dmaengine: xilinx_vdma: Fix issues with non-parking mode Kedareswara rao Appana
2016-02-26 14:03   ` Kedareswara rao Appana
2016-02-26 14:03 ` [PATCH v3 4/4] dmaengine: xilinx_vdma: Use readl_poll_timeout instead of do while loop's Kedareswara rao Appana
2016-02-26 14:03   ` Kedareswara rao Appana
2016-03-03 15:29   ` Vinod Koul [this message]
2016-03-03 15:29     ` Vinod Koul
2016-03-03 17:12     ` Appana Durga Kedareswara Rao
2016-03-03 17:12       ` Appana Durga Kedareswara Rao
2016-03-03 15:33 ` [PATCH v3 1/4] dmaengine: xilinx_vdma: Improve SG engine handling Vinod Koul
2016-03-03 15:33   ` Vinod Koul
2016-03-03 16:28   ` Appana Durga Kedareswara Rao
2016-03-03 16:28     ` Appana Durga Kedareswara Rao

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=20160303152957.GM11154@localhost \
    --to=vinod.koul@intel.com \
    --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 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.