public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/6] acpi-dma: fix sparse warning
@ 2013-07-15 12:04 Andy Shevchenko
  2013-07-15 12:04 ` [PATCH 2/6] dma: dw: append MODULE_DEVICE_TABLE for ACPI case Andy Shevchenko
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Andy Shevchenko @ 2013-07-15 12:04 UTC (permalink / raw)
  To: Viresh Kumar, Vinod Koul, linux-kernel, spear-devel; +Cc: Andy Shevchenko

This patch fixes sparse warning:
	drivers/dma/acpi-dma.c:76:21: sparse: cast to restricted __le32

Since everything in all ACPI tables is little-endian, by definition, the used
types in practice are uXX. Thus, we have to enforce __leXX if we want to
convert them to CPU order.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/dma/acpi-dma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/acpi-dma.c b/drivers/dma/acpi-dma.c
index 5a18f82..ba7f932 100644
--- a/drivers/dma/acpi-dma.c
+++ b/drivers/dma/acpi-dma.c
@@ -73,7 +73,7 @@ static int acpi_dma_parse_resource_group(const struct acpi_csrt_group *grp,
 	if (si->mmio_base_low != mem || si->gsi_interrupt != irq)
 		return 0;
 
-	vendor_id = le32_to_cpu(grp->vendor_id);
+	vendor_id = le32_to_cpu((__force __le32)grp->vendor_id);
 	dev_dbg(&adev->dev, "matches with %.4s%04X (rev %u)\n",
 		(char *)&vendor_id, grp->device_id, grp->revision);
 
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/6] dma: dw: append MODULE_DEVICE_TABLE for ACPI case
  2013-07-15 12:04 [PATCH 1/6] acpi-dma: fix sparse warning Andy Shevchenko
@ 2013-07-15 12:04 ` Andy Shevchenko
  2013-07-15 12:04 ` [PATCH 3/6] dma: dw: improve comparison with ~0 Andy Shevchenko
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2013-07-15 12:04 UTC (permalink / raw)
  To: Viresh Kumar, Vinod Koul, linux-kernel, spear-devel; +Cc: Andy Shevchenko

In rare cases (mostly for the testing purposes) the dw_dmac driver might be
compiled as a module as well as the other LPSS device drivers (I2C, SPI,
HSUART). When udev handles the event of the devices appearing the dw_dmac
module is missing. This patch will fix that.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/dma/dw/platform.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/dma/dw/platform.c b/drivers/dma/dw/platform.c
index 6c9449c..e35d975 100644
--- a/drivers/dma/dw/platform.c
+++ b/drivers/dma/dw/platform.c
@@ -253,6 +253,7 @@ static const struct acpi_device_id dw_dma_acpi_id_table[] = {
 	{ "INTL9C60", 0 },
 	{ }
 };
+MODULE_DEVICE_TABLE(acpi, dw_dma_acpi_id_table);
 #endif
 
 #ifdef CONFIG_PM_SLEEP
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/6] dma: dw: improve comparison with ~0
  2013-07-15 12:04 [PATCH 1/6] acpi-dma: fix sparse warning Andy Shevchenko
  2013-07-15 12:04 ` [PATCH 2/6] dma: dw: append MODULE_DEVICE_TABLE for ACPI case Andy Shevchenko
@ 2013-07-15 12:04 ` Andy Shevchenko
  2013-07-15 12:04 ` [PATCH 4/6] dma: dw: allow shared interrupts Andy Shevchenko
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2013-07-15 12:04 UTC (permalink / raw)
  To: Viresh Kumar, Vinod Koul, linux-kernel, spear-devel; +Cc: Andy Shevchenko

In general ~0 does not fit some integer types. Let's do a helper to make a
comparison with that constant properly.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/dma/dw/core.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/dw/core.c b/drivers/dma/dw/core.c
index bd6b0de..a0aa6f9 100644
--- a/drivers/dma/dw/core.c
+++ b/drivers/dma/dw/core.c
@@ -37,16 +37,22 @@
  * which does not support descriptor writeback.
  */
 
+static inline bool is_request_line_unset(struct dw_dma_chan *dwc)
+{
+	return dwc->request_line == (typeof(dwc->request_line))~0;
+}
+
 static inline void dwc_set_masters(struct dw_dma_chan *dwc)
 {
 	struct dw_dma *dw = to_dw_dma(dwc->chan.device);
 	struct dw_dma_slave *dws = dwc->chan.private;
 	unsigned char mmax = dw->nr_masters - 1;
 
-	if (dwc->request_line == ~0) {
-		dwc->src_master = min_t(unsigned char, mmax, dwc_get_sms(dws));
-		dwc->dst_master = min_t(unsigned char, mmax, dwc_get_dms(dws));
-	}
+	if (!is_request_line_unset(dwc))
+		return;
+
+	dwc->src_master = min_t(unsigned char, mmax, dwc_get_sms(dws));
+	dwc->dst_master = min_t(unsigned char, mmax, dwc_get_dms(dws));
 }
 
 #define DWC_DEFAULT_CTLLO(_chan) ({				\
@@ -984,7 +990,7 @@ set_runtime_config(struct dma_chan *chan, struct dma_slave_config *sconfig)
 	dwc->direction = sconfig->direction;
 
 	/* Take the request line from slave_id member */
-	if (dwc->request_line == ~0)
+	if (is_request_line_unset(dwc))
 		dwc->request_line = sconfig->slave_id;
 
 	convert_burst(&dwc->dma_sconfig.src_maxburst);
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/6] dma: dw: allow shared interrupts
  2013-07-15 12:04 [PATCH 1/6] acpi-dma: fix sparse warning Andy Shevchenko
  2013-07-15 12:04 ` [PATCH 2/6] dma: dw: append MODULE_DEVICE_TABLE for ACPI case Andy Shevchenko
  2013-07-15 12:04 ` [PATCH 3/6] dma: dw: improve comparison with ~0 Andy Shevchenko
@ 2013-07-15 12:04 ` Andy Shevchenko
  2013-07-15 12:04 ` [PATCH 5/6] dma: dw: return DMA_SUCCESS immediately from device_tx_status() Andy Shevchenko
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2013-07-15 12:04 UTC (permalink / raw)
  To: Viresh Kumar, Vinod Koul, linux-kernel, spear-devel; +Cc: Andy Shevchenko

In the PC world is quite possible that devices are sharing the same interrupt
line. The patch prepares dw_dmac driver to such cases.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/dma/dw/core.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/dw/core.c b/drivers/dma/dw/core.c
index a0aa6f9..f70c6b4 100644
--- a/drivers/dma/dw/core.c
+++ b/drivers/dma/dw/core.c
@@ -650,10 +650,13 @@ static void dw_dma_tasklet(unsigned long data)
 static irqreturn_t dw_dma_interrupt(int irq, void *dev_id)
 {
 	struct dw_dma *dw = dev_id;
-	u32 status;
+	u32 status = dma_readl(dw, STATUS_INT);
 
-	dev_vdbg(dw->dma.dev, "%s: status=0x%x\n", __func__,
-			dma_readl(dw, STATUS_INT));
+	dev_vdbg(dw->dma.dev, "%s: status=0x%x\n", __func__, status);
+
+	/* Check if we have any interrupt from the DMAC */
+	if (!status)
+		return IRQ_NONE;
 
 	/*
 	 * Just disable the interrupts. We'll turn them back on in the
@@ -1567,8 +1570,8 @@ int dw_dma_probe(struct dw_dma_chip *chip, struct dw_dma_platform_data *pdata)
 	/* Disable BLOCK interrupts as well */
 	channel_clear_bit(dw, MASK.BLOCK, dw->all_chan_mask);
 
-	err = devm_request_irq(chip->dev, chip->irq, dw_dma_interrupt, 0,
-			       "dw_dmac", dw);
+	err = devm_request_irq(chip->dev, chip->irq, dw_dma_interrupt,
+			       IRQF_SHARED, "dw_dmac", dw);
 	if (err)
 		return err;
 
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 5/6] dma: dw: return DMA_SUCCESS immediately from device_tx_status()
  2013-07-15 12:04 [PATCH 1/6] acpi-dma: fix sparse warning Andy Shevchenko
                   ` (2 preceding siblings ...)
  2013-07-15 12:04 ` [PATCH 4/6] dma: dw: allow shared interrupts Andy Shevchenko
@ 2013-07-15 12:04 ` Andy Shevchenko
  2013-07-15 12:04 ` [PATCH 6/6] dma: dw: return DMA_PAUSED only if cookie status is DMA_IN_PROGRESS Andy Shevchenko
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2013-07-15 12:04 UTC (permalink / raw)
  To: Viresh Kumar, Vinod Koul, linux-kernel, spear-devel; +Cc: Andy Shevchenko

There is no point to go throught the rest of the function if first call to
dma_cookie_status() returned DMA_SUCCESS.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/dma/dw/core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/dw/core.c b/drivers/dma/dw/core.c
index f70c6b4..22fc7b3 100644
--- a/drivers/dma/dw/core.c
+++ b/drivers/dma/dw/core.c
@@ -1098,12 +1098,12 @@ dwc_tx_status(struct dma_chan *chan,
 	enum dma_status		ret;
 
 	ret = dma_cookie_status(chan, cookie, txstate);
-	if (ret != DMA_SUCCESS) {
-		dwc_scan_descriptors(to_dw_dma(chan->device), dwc);
+	if (ret == DMA_SUCCESS)
+		return ret;
 
-		ret = dma_cookie_status(chan, cookie, txstate);
-	}
+	dwc_scan_descriptors(to_dw_dma(chan->device), dwc);
 
+	ret = dma_cookie_status(chan, cookie, txstate);
 	if (ret != DMA_SUCCESS)
 		dma_set_residue(txstate, dwc_get_residue(dwc));
 
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 6/6] dma: dw: return DMA_PAUSED only if cookie status is DMA_IN_PROGRESS
  2013-07-15 12:04 [PATCH 1/6] acpi-dma: fix sparse warning Andy Shevchenko
                   ` (3 preceding siblings ...)
  2013-07-15 12:04 ` [PATCH 5/6] dma: dw: return DMA_SUCCESS immediately from device_tx_status() Andy Shevchenko
@ 2013-07-15 12:04 ` Andy Shevchenko
  2013-07-16 10:18 ` [PATCH 1/6] acpi-dma: fix sparse warning Viresh Kumar
  2013-07-22  9:15 ` Vinod Koul
  6 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2013-07-15 12:04 UTC (permalink / raw)
  To: Viresh Kumar, Vinod Koul, linux-kernel, spear-devel; +Cc: Andy Shevchenko

To obey a usual practice let's return DMA_PAUSED status only if
dma_cookie_status returned DMA_IN_PROGRESS.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/dma/dw/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/dw/core.c b/drivers/dma/dw/core.c
index 22fc7b3..062b3be 100644
--- a/drivers/dma/dw/core.c
+++ b/drivers/dma/dw/core.c
@@ -1107,7 +1107,7 @@ dwc_tx_status(struct dma_chan *chan,
 	if (ret != DMA_SUCCESS)
 		dma_set_residue(txstate, dwc_get_residue(dwc));
 
-	if (dwc->paused)
+	if (dwc->paused && ret == DMA_IN_PROGRESS)
 		return DMA_PAUSED;
 
 	return ret;
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/6] acpi-dma: fix sparse warning
  2013-07-15 12:04 [PATCH 1/6] acpi-dma: fix sparse warning Andy Shevchenko
                   ` (4 preceding siblings ...)
  2013-07-15 12:04 ` [PATCH 6/6] dma: dw: return DMA_PAUSED only if cookie status is DMA_IN_PROGRESS Andy Shevchenko
@ 2013-07-16 10:18 ` Viresh Kumar
  2013-07-22  9:15 ` Vinod Koul
  6 siblings, 0 replies; 8+ messages in thread
From: Viresh Kumar @ 2013-07-16 10:18 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Vinod Koul, linux-kernel, spear-devel

On Mon, Jul 15, 2013 at 5:34 PM, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> This patch fixes sparse warning:
>         drivers/dma/acpi-dma.c:76:21: sparse: cast to restricted __le32
>
> Since everything in all ACPI tables is little-endian, by definition, the used
> types in practice are uXX. Thus, we have to enforce __leXX if we want to
> convert them to CPU order.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> ---
>  drivers/dma/acpi-dma.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

For the complete series:

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/6] acpi-dma: fix sparse warning
  2013-07-15 12:04 [PATCH 1/6] acpi-dma: fix sparse warning Andy Shevchenko
                   ` (5 preceding siblings ...)
  2013-07-16 10:18 ` [PATCH 1/6] acpi-dma: fix sparse warning Viresh Kumar
@ 2013-07-22  9:15 ` Vinod Koul
  6 siblings, 0 replies; 8+ messages in thread
From: Vinod Koul @ 2013-07-22  9:15 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Viresh Kumar, linux-kernel, spear-devel

On Mon, Jul 15, 2013 at 03:04:36PM +0300, Andy Shevchenko wrote:
> This patch fixes sparse warning:
> 	drivers/dma/acpi-dma.c:76:21: sparse: cast to restricted __le32
> 
> Since everything in all ACPI tables is little-endian, by definition, the used
> types in practice are uXX. Thus, we have to enforce __leXX if we want to
> convert them to CPU order.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Applied all, thanks

--
~Vinod

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-07-22  9:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-15 12:04 [PATCH 1/6] acpi-dma: fix sparse warning Andy Shevchenko
2013-07-15 12:04 ` [PATCH 2/6] dma: dw: append MODULE_DEVICE_TABLE for ACPI case Andy Shevchenko
2013-07-15 12:04 ` [PATCH 3/6] dma: dw: improve comparison with ~0 Andy Shevchenko
2013-07-15 12:04 ` [PATCH 4/6] dma: dw: allow shared interrupts Andy Shevchenko
2013-07-15 12:04 ` [PATCH 5/6] dma: dw: return DMA_SUCCESS immediately from device_tx_status() Andy Shevchenko
2013-07-15 12:04 ` [PATCH 6/6] dma: dw: return DMA_PAUSED only if cookie status is DMA_IN_PROGRESS Andy Shevchenko
2013-07-16 10:18 ` [PATCH 1/6] acpi-dma: fix sparse warning Viresh Kumar
2013-07-22  9:15 ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox