From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: linux-kernel@vger.kernel.org
Cc: Viresh Kumar <viresh.linux@gmail.com>,
Vinod Koul <vinod.koul@intel.com>,
Dan Williams <dan.j.williams@intel.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCHv2 08/10] dw_dmac: introduce dwc_fast_fls()
Date: Tue, 19 Jun 2012 13:34:08 +0300 [thread overview]
Message-ID: <1340102050-12697-9-git-send-email-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <1340102050-12697-1-git-send-email-andriy.shevchenko@linux.intel.com>
There were three places where such function is used. We still avoid to use
native fls() because in one case it requires to use 64bit version which is
suboptimal in our case.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/dma/dw_dmac.c | 46 ++++++++++++++++++----------------------------
1 file changed, 18 insertions(+), 28 deletions(-)
diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
index 42cffe8..9c47279 100644
--- a/drivers/dma/dw_dmac.c
+++ b/drivers/dma/dw_dmac.c
@@ -193,6 +193,21 @@ static void dwc_initialize(struct dw_dma_chan *dwc)
/*----------------------------------------------------------------------*/
+static inline unsigned int dwc_fast_fls(unsigned long long v)
+{
+ /*
+ * We can be a lot more clever here, but this should take care
+ * of the most common optimization.
+ */
+ if (!(v & 7))
+ return 3;
+ else if (!(v & 3))
+ return 2;
+ else if (!(v & 1))
+ return 1;
+ return 0;
+}
+
static void dwc_dump_chan_regs(struct dw_dma_chan *dwc)
{
dev_err(chan2dev(&dwc->chan),
@@ -643,18 +658,7 @@ dwc_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src,
return NULL;
}
- /*
- * We can be a lot more clever here, but this should take care
- * of the most common optimization.
- */
- if (!((src | dest | len) & 7))
- src_width = dst_width = 3;
- else if (!((src | dest | len) & 3))
- src_width = dst_width = 2;
- else if (!((src | dest | len) & 1))
- src_width = dst_width = 1;
- else
- src_width = dst_width = 0;
+ src_width = dst_width = dwc_fast_fls(src | dest | len);
ctllo = DWC_DEFAULT_CTLLO(chan)
| DWC_CTLL_DST_WIDTH(dst_width)
@@ -754,14 +758,7 @@ dwc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
mem = sg_dma_address(sg);
len = sg_dma_len(sg);
- if (!((mem | len) & 7))
- mem_width = 3;
- else if (!((mem | len) & 3))
- mem_width = 2;
- else if (!((mem | len) & 1))
- mem_width = 1;
- else
- mem_width = 0;
+ mem_width = dwc_fast_fls(mem | len);
slave_sg_todev_fill_desc:
desc = dwc_desc_get(dwc);
@@ -821,14 +818,7 @@ slave_sg_todev_fill_desc:
mem = sg_dma_address(sg);
len = sg_dma_len(sg);
- if (!((mem | len) & 7))
- mem_width = 3;
- else if (!((mem | len) & 3))
- mem_width = 2;
- else if (!((mem | len) & 1))
- mem_width = 1;
- else
- mem_width = 0;
+ mem_width = dwc_fast_fls(mem | len);
slave_sg_fromdev_fill_desc:
desc = dwc_desc_get(dwc);
--
1.7.10
next prev parent reply other threads:[~2012-06-19 10:34 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-15 7:05 [PATCH 0/9] dw_dmac: set of cleanups and small fixes Andy Shevchenko
2012-06-15 7:05 ` [PATCH 1/9] dw_dmac: fix constant in the comment Andy Shevchenko
2012-06-15 7:05 ` [PATCH 2/9] dw_dmac: use proper casting to print dma_addr_t values Andy Shevchenko
2012-06-15 7:05 ` [PATCH 3/9] dw_dmac: introduce dwc_dump_chan_regs to dump registers Andy Shevchenko
2012-06-15 7:05 ` [PATCH 4/9] dw_dmac: print correct number of scanned descriptors Andy Shevchenko
2012-06-15 7:05 ` [PATCH 5/9] dw_dmac: use __func__ constant in the debug prints Andy Shevchenko
2012-06-15 7:05 ` [PATCH 6/9] dw_dmac: disable dma in optimal way in probe Andy Shevchenko
2012-06-15 7:05 ` [PATCH 7/9] dw_dmac: disable BLOCK interrupts Andy Shevchenko
2012-06-15 7:05 ` [PATCH 8/9] dw_dmac: introduce dwc_fast_fls() Andy Shevchenko
2012-06-15 7:05 ` [PATCH 9/9] dw_dmac: move from __init to __devinit Andy Shevchenko
2012-06-19 10:34 ` [PATCHv2 00/10] dw_dmac: set of cleanups and small fixes Andy Shevchenko
2012-06-19 10:34 ` [PATCHv2 01/10] dw_dmac: fix constant in the comment Andy Shevchenko
2012-06-19 10:34 ` [PATCHv2 02/10] dw_dmac: use proper casting to print dma_addr_t values Andy Shevchenko
2012-06-19 10:34 ` [PATCHv2 03/10] dw_dmac: introduce dwc_dump_chan_regs to dump registers Andy Shevchenko
2012-06-19 10:34 ` [PATCHv2 04/10] dw_dmac: print correct number of scanned descriptors Andy Shevchenko
2012-06-19 10:34 ` [PATCHv2 05/10] dw_dmac: use __func__ constant in the debug prints Andy Shevchenko
2012-06-19 10:34 ` [PATCHv2 06/10] dw_dmac: disable dma in optimal way in probe Andy Shevchenko
2012-06-19 10:34 ` [PATCHv2 07/10] dw_dmac: disable BLOCK interrupts Andy Shevchenko
2012-06-19 10:34 ` Andy Shevchenko [this message]
2012-06-19 10:34 ` [PATCHv2 09/10] dw_dmac: move from __init to __devinit Andy Shevchenko
2012-06-19 10:34 ` [PATCHv2 10/10] dw_dmac: introduce dwc_chan_reset Andy Shevchenko
2012-06-19 10:39 ` viresh kumar
2012-06-19 10:46 ` [PATCHv2.1] dw_dmac: introduce dwc_chan_disable Andy Shevchenko
2012-06-19 10:52 ` viresh kumar
2012-06-21 2:39 ` Vinod Koul
2012-06-19 10:40 ` [PATCHv2 00/10] dw_dmac: set of cleanups and small fixes viresh kumar
2012-06-21 2:39 ` Vinod Koul
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=1340102050-12697-9-git-send-email-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=dan.j.williams@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=vinod.koul@intel.com \
--cc=viresh.linux@gmail.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