Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1292639 > unrolled thread

[PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel

Started byMans Rullgard <mans@mansr.com>
First post2015-12-16 00:30 +0100
Last post2015-12-17 16:00 +0100
Articles 20 on this page of 88 — 6 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Mans Rullgard <mans@mansr.com> - 2015-12-16 00:30 +0100
    [PATCH 3/3] ata: sata_dwc_460ex: get rid of global data Mans Rullgard <mans@mansr.com> - 2015-12-16 00:30 +0100
      Re: [PATCH 3/3] ata: sata_dwc_460ex: get rid of global data Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2015-12-17 16:10 +0100
        Re: [PATCH 3/3] ata: sata_dwc_460ex: get rid of global data Måns Rullgård <mans@mansr.com> - 2015-12-17 16:20 +0100
          Re: [PATCH 3/3] ata: sata_dwc_460ex: get rid of global data Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2015-12-17 16:40 +0100
            Re: [PATCH 3/3] ata: sata_dwc_460ex: get rid of global data Måns Rullgård <mans@mansr.com> - 2015-12-17 17:00 +0100
    [PATCH 2/3] ata: sata_dwc_460ex: add phy support Mans Rullgard <mans@mansr.com> - 2015-12-16 00:30 +0100
      Re: [PATCH 2/3] ata: sata_dwc_460ex: add phy support Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2015-12-16 12:20 +0100
        Re: [PATCH 2/3] ata: sata_dwc_460ex: add phy support Måns Rullgård <mans@mansr.com> - 2015-12-16 12:30 +0100
    Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-16 00:40 +0100
      Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2015-12-17 16:10 +0100
        Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-17 16:20 +0100
          Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2015-12-17 17:00 +0100
            Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-17 17:10 +0100
              Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2015-12-17 18:00 +0100
                Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-17 19:00 +0100
                  Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-17 20:00 +0100
                    Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Julian Margetson <runaway@candw.ms> - 2015-12-18 02:00 +0100
                      Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-18 02:40 +0100
                    Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2015-12-18 11:10 +0100
                      Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-18 12:30 +0100
                    Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Julian Margetson <runaway@candw.ms> - 2015-12-18 12:50 +0100
                      Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-18 13:10 +0100
                        Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2015-12-18 13:30 +0100
                          Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-18 13:50 +0100
                            Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-18 18:20 +0100
                              Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2015-12-18 19:50 +0100
                              Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-18 23:40 +0100
                                Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-19 00:20 +0100
                                  Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Andy Shevchenko <andy.shevchenko@gmail.com> - 2015-12-19 03:40 +0100
                                    Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-19 16:50 +0100
                                      Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-19 17:50 +0100
                                      Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Andy Shevchenko <andy.shevchenko@gmail.com> - 2015-12-19 18:00 +0100
                                        Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-19 18:10 +0100
                                          Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Julian Margetson <runaway@candw.ms> - 2015-12-19 18:10 +0100
                                            Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Andy Shevchenko <andy.shevchenko@gmail.com> - 2015-12-19 18:20 +0100
                                            Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-19 18:30 +0100
                                              Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-19 20:10 +0100
                                                Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Andy Shevchenko <andy.shevchenko@gmail.com> - 2015-12-19 21:40 +0100
                                                  Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-19 21:50 +0100
                                                    Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Julian Margetson <runaway@candw.ms> - 2015-12-19 21:50 +0100
                                                    Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-20 18:20 +0100
                                                      Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Andy Shevchenko <andy.shevchenko@gmail.com> - 2015-12-20 18:50 +0100
                                                        Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-20 19:00 +0100
                                                      Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-20 19:50 +0100
                                                        Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Andy Shevchenko <andy.shevchenko@gmail.com> - 2015-12-20 21:20 +0100
                                                          Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Andy Shevchenko <andy.shevchenko@gmail.com> - 2015-12-20 22:00 +0100
                                                            Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-21 02:20 +0100
                                                              Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2015-12-21 20:10 +0100
                                                                Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-21 20:30 +0100
                                                                  Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2015-12-21 22:00 +0100
                                                                    Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-21 22:10 +0100
                                                                    Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-22 01:10 +0100
                                                                      Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2015-12-22 12:00 +0100
                                                            Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2015-12-21 18:00 +0100
                                                              Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Julian Margetson <runaway@candw.ms> - 2015-12-21 18:30 +0100
                                                              Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Andy Shevchenko <andy.shevchenko@gmail.com> - 2015-12-21 19:00 +0100
                                                                Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-21 19:30 +0100
                                                                Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-21 19:30 +0100
                                                                  Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Julian Margetson <runaway@candw.ms> - 2015-12-21 20:10 +0100
                                                                  Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-21 20:30 +0100
                                                                    Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Julian Margetson <runaway@candw.ms> - 2015-12-21 20:50 +0100
                                                                  Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Julian Margetson <runaway@candw.ms> - 2015-12-21 20:30 +0100
                                                                    Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Julian Margetson <runaway@candw.ms> - 2015-12-21 21:30 +0100
                                                                    Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2015-12-21 21:30 +0100
                                                                      Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-21 21:40 +0100
                                                                Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Julian Margetson <runaway@candw.ms> - 2015-12-21 19:30 +0100
                                                          Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-21 01:50 +0100
                                                            Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-21 02:00 +0100
                                                          Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-21 02:00 +0100
                                                            Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Andy Shevchenko <andy.shevchenko@gmail.com> - 2015-12-21 09:50 +0100
                                                              Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-21 13:20 +0100
                                                                Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Andy Shevchenko <andy.shevchenko@gmail.com> - 2015-12-21 18:30 +0100
                                                                  Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-21 19:20 +0100
                                                                    Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2015-12-21 20:30 +0100
                                                                      Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-21 21:00 +0100
                                                              Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-21 13:20 +0100
                                                                Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Julian Margetson <runaway@candw.ms> - 2015-12-21 14:20 +0100
                                                                  Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-21 16:30 +0100
                                                                    Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2015-12-21 17:50 +0100
                                                                      Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-21 19:20 +0100
                        Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Julian Margetson <runaway@candw.ms> - 2015-12-18 13:40 +0100
                          Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-18 13:50 +0100
                            Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2015-12-18 15:30 +0100
                            Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel Måns Rullgård <mans@mansr.com> - 2015-12-18 15:30 +0100
                          Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2015-12-18 13:50 +0100
                Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Julian Margetson <runaway@candw.ms> - 2015-12-17 19:10 +0100
    Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find  dma channel Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2015-12-17 16:00 +0100

Page 1 of 5  [1] 2 3 4 5  Next page →


#1292639 — [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel

FromMans Rullgard <mans@mansr.com>
Date2015-12-16 00:30 +0100
Subject[PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel
Message-ID<qG7cC-2o7-11@gated-at.bofh.it>
Currently this driver only works with a DesignWare DMA engine which it
registers manually using the second "reg" address range and interrupt
number from the DT node.

This patch makes the driver instead use the "dmas" property if present,
otherwise optionally falling back on the old way so existing device
trees can continue to work.

With this change, there is no longer any reason to depend on the 460EX
machine type so drop that from Kconfig.

Signed-off-by: Mans Rullgard <mans@mansr.com>
---
 drivers/ata/Kconfig          |  10 ++-
 drivers/ata/sata_dwc_460ex.c | 192 +++++++++++++++++++++++++++----------------
 2 files changed, 131 insertions(+), 71 deletions(-)

diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 3fc2a56..193c673 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -296,14 +296,20 @@ config ATA_PIIX
 
 config SATA_DWC
 	tristate "DesignWare Cores SATA support"
-	depends on 460EX
-	select DW_DMAC
 	help
 	  This option enables support for the on-chip SATA controller of the
 	  AppliedMicro processor 460EX.
 
 	  If unsure, say N.
 
+config SATA_DWC_OLD_DMA
+	bool "Support old device trees"
+	depends on SATA_DWC && 460EX
+	select DW_DMAC
+	help
+	  This option enables support for old device trees without the
+	  "dmas" property.
+
 config SATA_DWC_DEBUG
 	bool "Debugging driver version"
 	depends on SATA_DWC
diff --git a/drivers/ata/sata_dwc_460ex.c b/drivers/ata/sata_dwc_460ex.c
index 9020349..9985749 100644
--- a/drivers/ata/sata_dwc_460ex.c
+++ b/drivers/ata/sata_dwc_460ex.c
@@ -30,6 +30,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/device.h>
+#include <linux/dmaengine.h>
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
@@ -42,10 +43,6 @@
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_cmnd.h>
 
-/* Supported DMA engine drivers */
-#include <linux/platform_data/dma-dw.h>
-#include <linux/dma/dw.h>
-
 /* These two are defined in "libata.h" */
 #undef	DRV_NAME
 #undef	DRV_VERSION
@@ -148,7 +145,9 @@ struct sata_dwc_device {
 	struct ata_host		*host;
 	u8 __iomem		*reg_base;
 	struct sata_dwc_regs	*sata_dwc_regs;	/* DW Synopsys SATA specific */
+#ifdef CONFIG_SATA_DWC_OLD_DMA
 	struct dw_dma_chip	*dma;
+#endif
 };
 
 #define SATA_DWC_QCMD_MAX	32
@@ -159,7 +158,6 @@ struct sata_dwc_device_port {
 	int			dma_pending[SATA_DWC_QCMD_MAX];
 
 	/* DMA info */
-	struct dw_dma_slave		*dws;
 	struct dma_chan			*chan;
 	struct dma_async_tx_descriptor	*desc[SATA_DWC_QCMD_MAX];
 	u32				dma_interrupt_count;
@@ -198,13 +196,6 @@ struct sata_dwc_host_priv {
 
 static struct sata_dwc_host_priv host_pvt;
 
-static struct dw_dma_slave sata_dwc_dma_dws = {
-	.src_id = 0,
-	.dst_id = 0,
-	.src_master = 0,
-	.dst_master = 1,
-};
-
 /*
  * Prototypes
  */
@@ -215,6 +206,90 @@ static void sata_dwc_dma_xfer_complete(struct ata_port *ap, u32 check_status);
 static void sata_dwc_port_stop(struct ata_port *ap);
 static void sata_dwc_clear_dmacr(struct sata_dwc_device_port *hsdevp, u8 tag);
 
+#ifdef CONFIG_SATA_DWC_OLD_DMA
+
+#include <linux/platform_data/dma-dw.h>
+#include <linux/dma/dw.h>
+
+static struct dw_dma_slave sata_dwc_dma_dws = {
+	.src_id = 0,
+	.dst_id = 0,
+	.src_master = 0,
+	.dst_master = 1,
+};
+
+static bool sata_dwc_dma_filter(struct dma_chan *chan, void *param)
+{
+	struct dw_dma_slave *dws = &sata_dwc_dma_dws;
+
+	if (dws->dma_dev != chan->device->dev)
+		return false;
+
+	chan->private = dws;
+	return true;
+}
+
+static int sata_dwc_dma_get_channel_old(struct sata_dwc_device_port *hsdevp)
+{
+	struct sata_dwc_device *hsdev = hsdevp->hsdev;
+	struct dw_dma_slave *dws = &sata_dwc_dma_dws;
+	dma_cap_mask_t mask;
+
+	dws->dma_dev = hsdev->dev;
+
+	dma_cap_zero(mask);
+	dma_cap_set(DMA_SLAVE, mask);
+
+	/* Acquire DMA channel */
+	hsdevp->chan = dma_request_channel(mask, sata_dwc_dma_filter, hsdevp);
+	if (!hsdevp->chan) {
+		dev_err(hsdev->dev, "%s: dma channel unavailable\n",
+			 __func__);
+		return -EAGAIN;
+	}
+
+	return 0;
+}
+
+static int sata_dwc_dma_init_old(struct platform_device *pdev,
+				 struct sata_dwc_device *hsdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	int err;
+
+	hsdev->dma = devm_kzalloc(&pdev->dev, sizeof(*hsdev->dma), GFP_KERNEL);
+	if (!hsdev->dma)
+		return -ENOMEM;
+
+	hsdev->dma->dev = &pdev->dev;
+
+	/* Get SATA DMA interrupt number */
+	hsdev->dma->irq = irq_of_parse_and_map(np, 1);
+	if (hsdev->dma->irq == NO_IRQ) {
+		dev_err(&pdev->dev, "no SATA DMA irq\n");
+		return -ENODEV;
+	}
+
+	/* Get physical SATA DMA register base address */
+	hsdev->dma->regs = of_iomap(np, 1);
+	if (!hsdev->dma->regs) {
+		dev_err(&pdev->dev,
+			"ioremap failed for AHBDMA register address\n");
+		return -ENODEV;
+	}
+
+	/* Initialize AHB DMAC */
+	err = dw_dma_probe(hsdev->dma, NULL);
+	if (err) {
+		iounmap(hsdev->dma->regs);
+		return err;
+	}
+
+	return 0;
+}
+
+#endif
+
 static const char *get_prot_descript(u8 protocol)
 {
 	switch ((enum ata_tf_protocols)protocol) {
@@ -783,18 +858,6 @@ static void sata_dwc_enable_interrupts(struct sata_dwc_device *hsdev)
 		in_le32(&hsdev->sata_dwc_regs->errmr));
 }
 
-static bool sata_dwc_dma_filter(struct dma_chan *chan, void *param)
-{
-	struct sata_dwc_device_port *hsdevp = param;
-	struct dw_dma_slave *dws = hsdevp->dws;
-
-	if (dws->dma_dev != chan->device->dev)
-		return false;
-
-	chan->private = dws;
-	return true;
-}
-
 static void sata_dwc_setup_port(struct ata_ioports *port, unsigned long base)
 {
 	port->cmd_addr = (void __iomem *)base + 0x00;
@@ -817,6 +880,26 @@ static void sata_dwc_setup_port(struct ata_ioports *port, unsigned long base)
 	port->ctl_addr = (void __iomem *)base + 0x20;
 }
 
+static int sata_dwc_dma_get_channel(struct sata_dwc_device_port *hsdevp)
+{
+	struct sata_dwc_device *hsdev = hsdevp->hsdev;
+	struct device *dev = hsdev->dev;
+
+#ifdef CONFIG_SATA_DWC_OLD_DMA
+	if (!of_find_property(dev->of_node, "dmas", NULL))
+		return sata_dwc_dma_get_channel_old(hsdevp);
+#endif
+
+	hsdevp->chan = dma_request_slave_channel(dev, "sata-dma");
+	if (IS_ERR(hsdevp->chan)) {
+		dev_err(dev, "failed to allocate dma channel: %ld\n",
+			PTR_ERR(hsdevp->chan));
+		return PTR_ERR(hsdevp->chan);
+	}
+
+	return 0;
+}
+
 /*
  * Function : sata_dwc_port_start
  * arguments : struct ata_ioports *port
@@ -829,7 +912,6 @@ static int sata_dwc_port_start(struct ata_port *ap)
 	struct sata_dwc_device *hsdev;
 	struct sata_dwc_device_port *hsdevp = NULL;
 	struct device *pdev;
-	dma_cap_mask_t mask;
 	int i;
 
 	hsdev = HSDEV_FROM_AP(ap);
@@ -853,20 +935,9 @@ static int sata_dwc_port_start(struct ata_port *ap)
 	}
 	hsdevp->hsdev = hsdev;
 
-	hsdevp->dws = &sata_dwc_dma_dws;
-	hsdevp->dws->dma_dev = hsdev->dev;
-
-	dma_cap_zero(mask);
-	dma_cap_set(DMA_SLAVE, mask);
-
-	/* Acquire DMA channel */
-	hsdevp->chan = dma_request_channel(mask, sata_dwc_dma_filter, hsdevp);
-	if (!hsdevp->chan) {
-		dev_err(hsdev->dev, "%s: dma channel unavailable\n",
-			 __func__);
-		err = -EAGAIN;
+	err = sata_dwc_dma_get_channel(hsdevp);
+	if (err)
 		goto CLEANUP_ALLOC;
-	}
 
 	for (i = 0; i < SATA_DWC_QCMD_MAX; i++)
 		hsdevp->cmd_issued[i] = SATA_DWC_CMD_ISSUED_NOT;
@@ -1225,33 +1296,9 @@ static int sata_dwc_probe(struct platform_device *ofdev)
 	dev_notice(&ofdev->dev, "id %d, controller version %c.%c%c\n",
 		   idr, ver[0], ver[1], ver[2]);
 
-	/* Get SATA DMA interrupt number */
-	hsdev->dma->irq = irq_of_parse_and_map(np, 1);
-	if (hsdev->dma->irq == NO_IRQ) {
-		dev_err(&ofdev->dev, "no SATA DMA irq\n");
-		err = -ENODEV;
-		goto error_iomap;
-	}
-
-	/* Get physical SATA DMA register base address */
-	hsdev->dma->regs = of_iomap(np, 1);
-	if (!hsdev->dma->regs) {
-		dev_err(&ofdev->dev,
-			"ioremap failed for AHBDMA register address\n");
-		err = -ENODEV;
-		goto error_iomap;
-	}
-
 	/* Save dev for later use in dev_xxx() routines */
 	hsdev->dev = &ofdev->dev;
 
-	hsdev->dma->dev = &ofdev->dev;
-
-	/* Initialize AHB DMAC */
-	err = dw_dma_probe(hsdev->dma, NULL);
-	if (err)
-		goto error_dma_iomap;
-
 	/* Enable SATA Interrupts */
 	sata_dwc_enable_interrupts(hsdev);
 
@@ -1263,6 +1310,14 @@ static int sata_dwc_probe(struct platform_device *ofdev)
 		goto error_out;
 	}
 
+#ifdef CONFIG_SATA_DWC_OLD_DMA
+	if (!of_find_property(np, "dmas", NULL)) {
+		err = sata_dwc_dma_init_old(ofdev, hsdev);
+		if (err)
+			goto error_out;
+	}
+#endif
+
 	/*
 	 * Now, register with libATA core, this will also initiate the
 	 * device discovery process, invoking our port_start() handler &
@@ -1276,11 +1331,6 @@ static int sata_dwc_probe(struct platform_device *ofdev)
 	return 0;
 
 error_out:
-	/* Free SATA DMA resources */
-	dw_dma_remove(hsdev->dma);
-error_dma_iomap:
-	iounmap(hsdev->dma->regs);
-error_iomap:
 	iounmap(base);
 	return err;
 }
@@ -1293,10 +1343,14 @@ static int sata_dwc_remove(struct platform_device *ofdev)
 
 	ata_host_detach(host);
 
+#ifdef CONFIG_SATA_DWC_OLD_DMA
 	/* Free SATA DMA resources */
-	dw_dma_remove(hsdev->dma);
+	if (hsdev->dma) {
+		dw_dma_remove(hsdev->dma);
+		iounmap(hsdev->dma->regs);
+	}
+#endif
 
-	iounmap(hsdev->dma->regs);
 	iounmap(hsdev->reg_base);
 	dev_dbg(&ofdev->dev, "done\n");
 	return 0;
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1292641 — [PATCH 3/3] ata: sata_dwc_460ex: get rid of global data

FromMans Rullgard <mans@mansr.com>
Date2015-12-16 00:30 +0100
Subject[PATCH 3/3] ata: sata_dwc_460ex: get rid of global data
Message-ID<qG7cC-2o7-27@gated-at.bofh.it>
In reply to#1292639
This moves all global data into the driver private struct, thus
permitting multiple devices of this type to be used.

Signed-off-by: Mans Rullgard <mans@mansr.com>
---
 drivers/ata/sata_dwc_460ex.c | 80 ++++++++++++++++++++------------------------
 1 file changed, 36 insertions(+), 44 deletions(-)

diff --git a/drivers/ata/sata_dwc_460ex.c b/drivers/ata/sata_dwc_460ex.c
index d07aae1..919f870 100644
--- a/drivers/ata/sata_dwc_460ex.c
+++ b/drivers/ata/sata_dwc_460ex.c
@@ -146,6 +146,8 @@ struct sata_dwc_device {
 	struct ata_host		*host;
 	u8 __iomem		*reg_base;
 	struct sata_dwc_regs	*sata_dwc_regs;	/* DW Synopsys SATA specific */
+	u32			sactive_issued;
+	u32			sactive_queued;
 	struct phy		*phy;
 #ifdef CONFIG_SATA_DWC_OLD_DMA
 	struct dw_dma_chip	*dma;
@@ -190,14 +192,6 @@ enum {
 	SATA_DWC_DMA_PENDING_RX		= 2,
 };
 
-struct sata_dwc_host_priv {
-	void	__iomem	 *scr_addr_sstatus;
-	u32	sata_dwc_sactive_issued ;
-	u32	sata_dwc_sactive_queued ;
-};
-
-static struct sata_dwc_host_priv host_pvt;
-
 /*
  * Prototypes
  */
@@ -448,21 +442,22 @@ static int sata_dwc_scr_write(struct ata_link *link, unsigned int scr, u32 val)
 	return 0;
 }
 
-static u32 core_scr_read(unsigned int scr)
+static u32 core_scr_read(struct sata_dwc_device *hsdev, unsigned int scr)
 {
-	return in_le32(host_pvt.scr_addr_sstatus + (scr * 4));
+	return in_le32(hsdev->reg_base + SATA_DWC_SCR_OFFSET + (scr * 4));
 }
 
-static void core_scr_write(unsigned int scr, u32 val)
+static void core_scr_write(struct sata_dwc_device *hsdev, unsigned int scr,
+			   u32 val)
 {
-	out_le32(host_pvt.scr_addr_sstatus + (scr * 4), val);
+	out_le32(hsdev->reg_base + SATA_DWC_SCR_OFFSET + (scr * 4), val);
 }
 
-static void clear_serror(void)
+static void clear_serror(struct sata_dwc_device *hsdev)
 {
 	u32 val;
-	val = core_scr_read(SCR_ERROR);
-	core_scr_write(SCR_ERROR, val);
+	val = core_scr_read(hsdev, SCR_ERROR);
+	core_scr_write(hsdev, SCR_ERROR, val);
 }
 
 static void clear_interrupt_bit(struct sata_dwc_device *hsdev, u32 bit)
@@ -489,7 +484,7 @@ static void sata_dwc_error_intr(struct ata_port *ap,
 
 	ata_ehi_clear_desc(ehi);
 
-	serror = core_scr_read(SCR_ERROR);
+	serror = core_scr_read(hsdev, SCR_ERROR);
 	status = ap->ops->sff_check_status(ap);
 
 	tag = ap->link.active_tag;
@@ -500,7 +495,7 @@ static void sata_dwc_error_intr(struct ata_port *ap,
 		hsdevp->dma_pending[tag], hsdevp->cmd_issued[tag]);
 
 	/* Clear error register and interrupt bit */
-	clear_serror();
+	clear_serror(hsdev);
 	clear_interrupt_bit(hsdev, SATA_DWC_INTPR_ERR);
 
 	/* This is the only error happening now.  TODO check for exact error */
@@ -539,7 +534,7 @@ static irqreturn_t sata_dwc_isr(int irq, void *dev_instance)
 	int handled, num_processed, port = 0;
 	uint intpr, sactive, sactive2, tag_mask;
 	struct sata_dwc_device_port *hsdevp;
-	host_pvt.sata_dwc_sactive_issued = 0;
+	hsdev->sactive_issued = 0;
 
 	spin_lock_irqsave(&host->lock, flags);
 
@@ -568,7 +563,7 @@ static irqreturn_t sata_dwc_isr(int irq, void *dev_instance)
 		if (hsdevp->cmd_issued[tag] != SATA_DWC_CMD_ISSUED_PEND)
 			dev_warn(ap->dev, "CMD tag=%d not pending?\n", tag);
 
-		host_pvt.sata_dwc_sactive_issued |= qcmd_tag_to_mask(tag);
+		hsdev->sactive_issued |= qcmd_tag_to_mask(tag);
 
 		qc = ata_qc_from_tag(ap, tag);
 		/*
@@ -582,11 +577,11 @@ static irqreturn_t sata_dwc_isr(int irq, void *dev_instance)
 		handled = 1;
 		goto DONE;
 	}
-	sactive = core_scr_read(SCR_ACTIVE);
-	tag_mask = (host_pvt.sata_dwc_sactive_issued | sactive) ^ sactive;
+	sactive = core_scr_read(hsdev, SCR_ACTIVE);
+	tag_mask = (hsdev->sactive_issued | sactive) ^ sactive;
 
 	/* If no sactive issued and tag_mask is zero then this is not NCQ */
-	if (host_pvt.sata_dwc_sactive_issued == 0 && tag_mask == 0) {
+	if (hsdev->sactive_issued == 0 && tag_mask == 0) {
 		if (ap->link.active_tag == ATA_TAG_POISON)
 			tag = 0;
 		else
@@ -656,22 +651,19 @@ DRVSTILLBUSY:
 	 */
 
 	 /* process completed commands */
-	sactive = core_scr_read(SCR_ACTIVE);
-	tag_mask = (host_pvt.sata_dwc_sactive_issued | sactive) ^ sactive;
+	sactive = core_scr_read(hsdev, SCR_ACTIVE);
+	tag_mask = (hsdev->sactive_issued | sactive) ^ sactive;
 
-	if (sactive != 0 || (host_pvt.sata_dwc_sactive_issued) > 1 || \
-							tag_mask > 1) {
+	if (sactive != 0 || hsdev->sactive_issued > 1 ||  tag_mask > 1) {
 		dev_dbg(ap->dev,
 			"%s NCQ:sactive=0x%08x  sactive_issued=0x%08x tag_mask=0x%08x\n",
-			__func__, sactive, host_pvt.sata_dwc_sactive_issued,
-			tag_mask);
+			__func__, sactive, hsdev->sactive_issued, tag_mask);
 	}
 
-	if ((tag_mask | (host_pvt.sata_dwc_sactive_issued)) != \
-					(host_pvt.sata_dwc_sactive_issued)) {
+	if ((tag_mask | hsdev->sactive_issued) != hsdev->sactive_issued) {
 		dev_warn(ap->dev,
-			 "Bad tag mask?  sactive=0x%08x (host_pvt.sata_dwc_sactive_issued)=0x%08x  tag_mask=0x%08x\n",
-			 sactive, host_pvt.sata_dwc_sactive_issued, tag_mask);
+			 "Bad tag mask?  sactive=0x%08x sactive_issued=0x%08x  tag_mask=0x%08x\n",
+			 sactive, hsdev->sactive_issued, tag_mask);
 	}
 
 	/* read just to clear ... not bad if currently still busy */
@@ -733,7 +725,7 @@ STILLBUSY:
 	 * we were processing --we read status as part of processing a completed
 	 * command).
 	 */
-	sactive2 = core_scr_read(SCR_ACTIVE);
+	sactive2 = core_scr_read(hsdev, SCR_ACTIVE);
 	if (sactive2 != sactive) {
 		dev_dbg(ap->dev,
 			"More completed - sactive=0x%x sactive2=0x%x\n",
@@ -819,8 +811,9 @@ static int sata_dwc_qc_complete(struct ata_port *ap, struct ata_queued_cmd *qc,
 	u8 status = 0;
 	u32 mask = 0x0;
 	u8 tag = qc->tag;
+	struct sata_dwc_device *hsdev = HSDEV_FROM_AP(ap);
 	struct sata_dwc_device_port *hsdevp = HSDEVP_FROM_AP(ap);
-	host_pvt.sata_dwc_sactive_queued = 0;
+	hsdev->sactive_queued = 0;
 	dev_dbg(ap->dev, "%s checkstatus? %x\n", __func__, check_status);
 
 	if (hsdevp->dma_pending[tag] == SATA_DWC_DMA_PENDING_TX)
@@ -833,10 +826,8 @@ static int sata_dwc_qc_complete(struct ata_port *ap, struct ata_queued_cmd *qc,
 
 	/* clear active bit */
 	mask = (~(qcmd_tag_to_mask(tag)));
-	host_pvt.sata_dwc_sactive_queued = (host_pvt.sata_dwc_sactive_queued) \
-						& mask;
-	host_pvt.sata_dwc_sactive_issued = (host_pvt.sata_dwc_sactive_issued) \
-						& mask;
+	hsdev->sactive_queued = hsdev->sactive_queued & mask;
+	hsdev->sactive_issued = hsdev->sactive_issued & mask;
 	ata_qc_complete(qc);
 	return 0;
 }
@@ -961,7 +952,7 @@ static int sata_dwc_port_start(struct ata_port *ap)
 	}
 
 	/* Clear any error bits before libata starts issuing commands */
-	clear_serror();
+	clear_serror(hsdev);
 	ap->private_data = hsdevp;
 	dev_dbg(ap->dev, "%s: done\n", __func__);
 	return 0;
@@ -999,6 +990,7 @@ static void sata_dwc_exec_command_by_tag(struct ata_port *ap,
 {
 	unsigned long flags;
 	struct sata_dwc_device_port *hsdevp = HSDEVP_FROM_AP(ap);
+	struct sata_dwc_device *hsdev = HSDEV_FROM_AP(ap);
 
 	dev_dbg(ap->dev, "%s cmd(0x%02x): %s tag=%d\n", __func__, tf->command,
 		ata_get_cmd_descript(tf->command), tag);
@@ -1012,7 +1004,7 @@ static void sata_dwc_exec_command_by_tag(struct ata_port *ap,
 	 * managed SError register for the disk needs to be done before the
 	 * task file is loaded.
 	 */
-	clear_serror();
+	clear_serror(hsdev);
 	ata_sff_exec_command(ap, tf);
 }
 
@@ -1065,7 +1057,7 @@ static void sata_dwc_bmdma_start_by_tag(struct ata_queued_cmd *qc, u8 tag)
 	sata_dwc_tf_dump(ap, &qc->tf);
 
 	if (start_dma) {
-		reg = core_scr_read(SCR_ERROR);
+		reg = core_scr_read(hsdev, SCR_ERROR);
 		if (reg & SATA_DWC_SERROR_ERR_BITS) {
 			dev_err(ap->dev, "%s: ****** SError=0x%08x ******\n",
 				__func__, reg);
@@ -1128,6 +1120,7 @@ static unsigned int sata_dwc_qc_issue(struct ata_queued_cmd *qc)
 	u32 sactive;
 	u8 tag = qc->tag;
 	struct ata_port *ap = qc->ap;
+	struct sata_dwc_device *hsdev = HSDEV_FROM_AP(ap);
 
 #ifdef DEBUG_NCQ
 	if (qc->tag > 0 || ap->link.sactive > 1)
@@ -1144,9 +1137,9 @@ static unsigned int sata_dwc_qc_issue(struct ata_queued_cmd *qc)
 	sata_dwc_qc_prep_by_tag(qc, tag);
 
 	if (ata_is_ncq(qc->tf.protocol)) {
-		sactive = core_scr_read(SCR_ACTIVE);
+		sactive = core_scr_read(hsdev, SCR_ACTIVE);
 		sactive |= (0x00000001 << tag);
-		core_scr_write(SCR_ACTIVE, sactive);
+		core_scr_write(hsdev, SCR_ACTIVE, sactive);
 
 		dev_dbg(qc->ap->dev,
 			"%s: tag=%d ap->link.sactive = 0x%08x sactive=0x%08x\n",
@@ -1289,7 +1282,6 @@ static int sata_dwc_probe(struct platform_device *ofdev)
 	/* Setup port */
 	host->ports[0]->ioaddr.cmd_addr = base;
 	host->ports[0]->ioaddr.scr_addr = base + SATA_DWC_SCR_OFFSET;
-	host_pvt.scr_addr_sstatus = base + SATA_DWC_SCR_OFFSET;
 	sata_dwc_setup_port(&host->ports[0]->ioaddr, (unsigned long)base);
 
 	/* Read the ID and Version Registers */
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1293968 — Re: [PATCH 3/3] ata: sata_dwc_460ex: get rid of global data

FromAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Date2015-12-17 16:10 +0100
SubjectRe: [PATCH 3/3] ata: sata_dwc_460ex: get rid of global data
Message-ID<qGIlQ-154-19@gated-at.bofh.it>
In reply to#1292641
On Tue, 2015-12-15 at 23:25 +0000, Mans Rullgard wrote:
> This moves all global data into the driver private struct, thus
> permitting multiple devices of this type to be used.
> 

Nice!

Btw, last time Linus complained about new warnings. Most of them I have
fixed when moved to external DMA driver. Leftovers IIRC are related to
address space. Are you going to fix them? Otherwise it might be a
headache for him again with strong wording to our address I suppose.

> Signed-off-by: Mans Rullgard <mans@mansr.com>
> ---
>  drivers/ata/sata_dwc_460ex.c | 80 ++++++++++++++++++++------------
> ------------
>  1 file changed, 36 insertions(+), 44 deletions(-)
> 
> diff --git a/drivers/ata/sata_dwc_460ex.c
> b/drivers/ata/sata_dwc_460ex.c
> index d07aae1..919f870 100644
> --- a/drivers/ata/sata_dwc_460ex.c
> +++ b/drivers/ata/sata_dwc_460ex.c
> @@ -146,6 +146,8 @@ struct sata_dwc_device {
>  	struct ata_host		*host;
>  	u8 __iomem		*reg_base;
>  	struct sata_dwc_regs	*sata_dwc_regs;	/* DW
> Synopsys SATA specific */
> +	u32			sactive_issued;
> +	u32			sactive_queued;
>  	struct phy		*phy;
>  #ifdef CONFIG_SATA_DWC_OLD_DMA
>  	struct dw_dma_chip	*dma;
> @@ -190,14 +192,6 @@ enum {
>  	SATA_DWC_DMA_PENDING_RX		= 2,
>  };
>  
> -struct sata_dwc_host_priv {
> -	void	__iomem	 *scr_addr_sstatus;
> -	u32	sata_dwc_sactive_issued ;
> -	u32	sata_dwc_sactive_queued ;
> -};
> -
> -static struct sata_dwc_host_priv host_pvt;
> -
>  /*
>   * Prototypes
>   */
> @@ -448,21 +442,22 @@ static int sata_dwc_scr_write(struct ata_link
> *link, unsigned int scr, u32 val)
>  	return 0;
>  }
>  
> -static u32 core_scr_read(unsigned int scr)
> +static u32 core_scr_read(struct sata_dwc_device *hsdev, unsigned int
> scr)
>  {
> -	return in_le32(host_pvt.scr_addr_sstatus + (scr * 4));
> +	return in_le32(hsdev->reg_base + SATA_DWC_SCR_OFFSET + (scr
> * 4));
>  }
>  
> -static void core_scr_write(unsigned int scr, u32 val)
> +static void core_scr_write(struct sata_dwc_device *hsdev, unsigned
> int scr,
> +			   u32 val)
>  {
> -	out_le32(host_pvt.scr_addr_sstatus + (scr * 4), val);
> +	out_le32(hsdev->reg_base + SATA_DWC_SCR_OFFSET + (scr * 4),
> val);
>  }
>  
> -static void clear_serror(void)
> +static void clear_serror(struct sata_dwc_device *hsdev)
>  {
>  	u32 val;
> -	val = core_scr_read(SCR_ERROR);
> -	core_scr_write(SCR_ERROR, val);
> +	val = core_scr_read(hsdev, SCR_ERROR);
> +	core_scr_write(hsdev, SCR_ERROR, val);
>  }
>  
>  static void clear_interrupt_bit(struct sata_dwc_device *hsdev, u32
> bit)
> @@ -489,7 +484,7 @@ static void sata_dwc_error_intr(struct ata_port
> *ap,
>  
>  	ata_ehi_clear_desc(ehi);
>  
> -	serror = core_scr_read(SCR_ERROR);
> +	serror = core_scr_read(hsdev, SCR_ERROR);
>  	status = ap->ops->sff_check_status(ap);
>  
>  	tag = ap->link.active_tag;
> @@ -500,7 +495,7 @@ static void sata_dwc_error_intr(struct ata_port
> *ap,
>  		hsdevp->dma_pending[tag], hsdevp->cmd_issued[tag]);
>  
>  	/* Clear error register and interrupt bit */
> -	clear_serror();
> +	clear_serror(hsdev);
>  	clear_interrupt_bit(hsdev, SATA_DWC_INTPR_ERR);
>  
>  	/* This is the only error happening now.  TODO check for
> exact error */
> @@ -539,7 +534,7 @@ static irqreturn_t sata_dwc_isr(int irq, void
> *dev_instance)
>  	int handled, num_processed, port = 0;
>  	uint intpr, sactive, sactive2, tag_mask;
>  	struct sata_dwc_device_port *hsdevp;
> -	host_pvt.sata_dwc_sactive_issued = 0;
> +	hsdev->sactive_issued = 0;
>  
>  	spin_lock_irqsave(&host->lock, flags);
>  
> @@ -568,7 +563,7 @@ static irqreturn_t sata_dwc_isr(int irq, void
> *dev_instance)
>  		if (hsdevp->cmd_issued[tag] !=
> SATA_DWC_CMD_ISSUED_PEND)
>  			dev_warn(ap->dev, "CMD tag=%d not
> pending?\n", tag);
>  
> -		host_pvt.sata_dwc_sactive_issued |=
> qcmd_tag_to_mask(tag);
> +		hsdev->sactive_issued |= qcmd_tag_to_mask(tag);
>  
>  		qc = ata_qc_from_tag(ap, tag);
>  		/*
> @@ -582,11 +577,11 @@ static irqreturn_t sata_dwc_isr(int irq, void
> *dev_instance)
>  		handled = 1;
>  		goto DONE;
>  	}
> -	sactive = core_scr_read(SCR_ACTIVE);
> -	tag_mask = (host_pvt.sata_dwc_sactive_issued | sactive) ^
> sactive;
> +	sactive = core_scr_read(hsdev, SCR_ACTIVE);
> +	tag_mask = (hsdev->sactive_issued | sactive) ^ sactive;
>  
>  	/* If no sactive issued and tag_mask is zero then this is
> not NCQ */
> -	if (host_pvt.sata_dwc_sactive_issued == 0 && tag_mask == 0)
> {
> +	if (hsdev->sactive_issued == 0 && tag_mask == 0) {
>  		if (ap->link.active_tag == ATA_TAG_POISON)
>  			tag = 0;
>  		else
> @@ -656,22 +651,19 @@ DRVSTILLBUSY:
>  	 */
>  
>  	 /* process completed commands */
> -	sactive = core_scr_read(SCR_ACTIVE);
> -	tag_mask = (host_pvt.sata_dwc_sactive_issued | sactive) ^
> sactive;
> +	sactive = core_scr_read(hsdev, SCR_ACTIVE);
> +	tag_mask = (hsdev->sactive_issued | sactive) ^ sactive;
>  
> -	if (sactive != 0 || (host_pvt.sata_dwc_sactive_issued) > 1
> || \
> -							tag_mask >
> 1) {
> +	if (sactive != 0 || hsdev->sactive_issued > 1 ||  tag_mask >
> 1) {
>  		dev_dbg(ap->dev,
>  			"%s
> NCQ:sactive=0x%08x  sactive_issued=0x%08x tag_mask=0x%08x\n",
> -			__func__, sactive,
> host_pvt.sata_dwc_sactive_issued,
> -			tag_mask);
> +			__func__, sactive, hsdev->sactive_issued,
> tag_mask);
>  	}
>  
> -	if ((tag_mask | (host_pvt.sata_dwc_sactive_issued)) != \
> -					(host_pvt.sata_dwc_sactive_i
> ssued)) {
> +	if ((tag_mask | hsdev->sactive_issued) != hsdev-
> >sactive_issued) {
>  		dev_warn(ap->dev,
> -			 "Bad tag mask?  sactive=0x%08x
> (host_pvt.sata_dwc_sactive_issued)=0x%08x  tag_mask=0x%08x\n",
> -			 sactive, host_pvt.sata_dwc_sactive_issued,
> tag_mask);
> +			 "Bad tag mask?  sactive=0x%08x
> sactive_issued=0x%08x  tag_mask=0x%08x\n",
> +			 sactive, hsdev->sactive_issued, tag_mask);
>  	}
>  
>  	/* read just to clear ... not bad if currently still busy */
> @@ -733,7 +725,7 @@ STILLBUSY:
>  	 * we were processing --we read status as part of processing
> a completed
>  	 * command).
>  	 */
> -	sactive2 = core_scr_read(SCR_ACTIVE);
> +	sactive2 = core_scr_read(hsdev, SCR_ACTIVE);
>  	if (sactive2 != sactive) {
>  		dev_dbg(ap->dev,
>  			"More completed - sactive=0x%x
> sactive2=0x%x\n",
> @@ -819,8 +811,9 @@ static int sata_dwc_qc_complete(struct ata_port
> *ap, struct ata_queued_cmd *qc,
>  	u8 status = 0;
>  	u32 mask = 0x0;
>  	u8 tag = qc->tag;
> +	struct sata_dwc_device *hsdev = HSDEV_FROM_AP(ap);
>  	struct sata_dwc_device_port *hsdevp = HSDEVP_FROM_AP(ap);
> -	host_pvt.sata_dwc_sactive_queued = 0;
> +	hsdev->sactive_queued = 0;
>  	dev_dbg(ap->dev, "%s checkstatus? %x\n", __func__,
> check_status);
>  
>  	if (hsdevp->dma_pending[tag] == SATA_DWC_DMA_PENDING_TX)
> @@ -833,10 +826,8 @@ static int sata_dwc_qc_complete(struct ata_port
> *ap, struct ata_queued_cmd *qc,
>  
>  	/* clear active bit */
>  	mask = (~(qcmd_tag_to_mask(tag)));
> -	host_pvt.sata_dwc_sactive_queued =
> (host_pvt.sata_dwc_sactive_queued) \
> -						& mask;
> -	host_pvt.sata_dwc_sactive_issued =
> (host_pvt.sata_dwc_sactive_issued) \
> -						& mask;
> +	hsdev->sactive_queued = hsdev->sactive_queued & mask;
> +	hsdev->sactive_issued = hsdev->sactive_issued & mask;
>  	ata_qc_complete(qc);
>  	return 0;
>  }
> @@ -961,7 +952,7 @@ static int sata_dwc_port_start(struct ata_port
> *ap)
>  	}
>  
>  	/* Clear any error bits before libata starts issuing
> commands */
> -	clear_serror();
> +	clear_serror(hsdev);
>  	ap->private_data = hsdevp;
>  	dev_dbg(ap->dev, "%s: done\n", __func__);
>  	return 0;
> @@ -999,6 +990,7 @@ static void sata_dwc_exec_command_by_tag(struct
> ata_port *ap,
>  {
>  	unsigned long flags;
>  	struct sata_dwc_device_port *hsdevp = HSDEVP_FROM_AP(ap);
> +	struct sata_dwc_device *hsdev = HSDEV_FROM_AP(ap);
>  
>  	dev_dbg(ap->dev, "%s cmd(0x%02x): %s tag=%d\n", __func__,
> tf->command,
>  		ata_get_cmd_descript(tf->command), tag);
> @@ -1012,7 +1004,7 @@ static void sata_dwc_exec_command_by_tag(struct
> ata_port *ap,
>  	 * managed SError register for the disk needs to be done
> before the
>  	 * task file is loaded.
>  	 */
> -	clear_serror();
> +	clear_serror(hsdev);
>  	ata_sff_exec_command(ap, tf);
>  }
>  
> @@ -1065,7 +1057,7 @@ static void sata_dwc_bmdma_start_by_tag(struct
> ata_queued_cmd *qc, u8 tag)
>  	sata_dwc_tf_dump(ap, &qc->tf);
>  
>  	if (start_dma) {
> -		reg = core_scr_read(SCR_ERROR);
> +		reg = core_scr_read(hsdev, SCR_ERROR);
>  		if (reg & SATA_DWC_SERROR_ERR_BITS) {
>  			dev_err(ap->dev, "%s: ****** SError=0x%08x
> ******\n",
>  				__func__, reg);
> @@ -1128,6 +1120,7 @@ static unsigned int sata_dwc_qc_issue(struct
> ata_queued_cmd *qc)
>  	u32 sactive;
>  	u8 tag = qc->tag;
>  	struct ata_port *ap = qc->ap;
> +	struct sata_dwc_device *hsdev = HSDEV_FROM_AP(ap);
>  
>  #ifdef DEBUG_NCQ
>  	if (qc->tag > 0 || ap->link.sactive > 1)
> @@ -1144,9 +1137,9 @@ static unsigned int sata_dwc_qc_issue(struct
> ata_queued_cmd *qc)
>  	sata_dwc_qc_prep_by_tag(qc, tag);
>  
>  	if (ata_is_ncq(qc->tf.protocol)) {
> -		sactive = core_scr_read(SCR_ACTIVE);
> +		sactive = core_scr_read(hsdev, SCR_ACTIVE);
>  		sactive |= (0x00000001 << tag);
> -		core_scr_write(SCR_ACTIVE, sactive);
> +		core_scr_write(hsdev, SCR_ACTIVE, sactive);
>  
>  		dev_dbg(qc->ap->dev,
>  			"%s: tag=%d ap->link.sactive = 0x%08x
> sactive=0x%08x\n",
> @@ -1289,7 +1282,6 @@ static int sata_dwc_probe(struct
> platform_device *ofdev)
>  	/* Setup port */
>  	host->ports[0]->ioaddr.cmd_addr = base;
>  	host->ports[0]->ioaddr.scr_addr = base +
> SATA_DWC_SCR_OFFSET;
> -	host_pvt.scr_addr_sstatus = base + SATA_DWC_SCR_OFFSET;
>  	sata_dwc_setup_port(&host->ports[0]->ioaddr, (unsigned
> long)base);
>  
>  	/* Read the ID and Version Registers */

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1293972 — Re: [PATCH 3/3] ata: sata_dwc_460ex: get rid of global data

FromMåns Rullgård <mans@mansr.com>
Date2015-12-17 16:20 +0100
SubjectRe: [PATCH 3/3] ata: sata_dwc_460ex: get rid of global data
Message-ID<qGIvv-18F-1@gated-at.bofh.it>
In reply to#1293968
Andy Shevchenko <andriy.shevchenko@linux.intel.com> writes:

> On Tue, 2015-12-15 at 23:25 +0000, Mans Rullgard wrote:
>> This moves all global data into the driver private struct, thus
>> permitting multiple devices of this type to be used.
>> 
>
> Nice!
>
> Btw, last time Linus complained about new warnings. Most of them I have
> fixed when moved to external DMA driver. Leftovers IIRC are related to
> address space. Are you going to fix them? Otherwise it might be a
> headache for him again with strong wording to our address I suppose.

There are some issues with __iomem annotations.  Is that the warnings
you refer to?  I'm not getting any regular compiler warnings.

-- 
Måns Rullgård
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1293981 — Re: [PATCH 3/3] ata: sata_dwc_460ex: get rid of global data

FromAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Date2015-12-17 16:40 +0100
SubjectRe: [PATCH 3/3] ata: sata_dwc_460ex: get rid of global data
Message-ID<qGIOR-1gS-3@gated-at.bofh.it>
In reply to#1293972
On Thu, 2015-12-17 at 15:19 +0000, Måns Rullgård wrote:
> Andy Shevchenko <andriy.shevchenko@linux.intel.com> writes:
> 
> > On Tue, 2015-12-15 at 23:25 +0000, Mans Rullgard wrote:
> > > This moves all global data into the driver private struct, thus
> > > permitting multiple devices of this type to be used.
> > > 
> > 
> > Nice!
> > 
> > Btw, last time Linus complained about new warnings. Most of them I
> > have
> > fixed when moved to external DMA driver. Leftovers IIRC are related
> > to
> > address space. Are you going to fix them? Otherwise it might be a
> > headache for him again with strong wording to our address I
> > suppose.
> 
> There are some issues with __iomem annotations.  Is that the warnings
> you refer to?  I'm not getting any regular compiler warnings.
> 

I guess I got them because I'am checking sparse warnings as well.


There is the original Linus' complain.
http://permalink.gmane.org/gmane.linux.ide/59391

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1293997 — Re: [PATCH 3/3] ata: sata_dwc_460ex: get rid of global data

FromMåns Rullgård <mans@mansr.com>
Date2015-12-17 17:00 +0100
SubjectRe: [PATCH 3/3] ata: sata_dwc_460ex: get rid of global data
Message-ID<qGJ8e-1nC-15@gated-at.bofh.it>
In reply to#1293981
Andy Shevchenko <andriy.shevchenko@linux.intel.com> writes:

> On Thu, 2015-12-17 at 15:19 +0000, Måns Rullgård wrote:
>> Andy Shevchenko <andriy.shevchenko@linux.intel.com> writes:
>> 
>> > On Tue, 2015-12-15 at 23:25 +0000, Mans Rullgard wrote:
>> > > This moves all global data into the driver private struct, thus
>> > > permitting multiple devices of this type to be used.
>> > > 
>> > 
>> > Nice!
>> > 
>> > Btw, last time Linus complained about new warnings. Most of them I
>> > have
>> > fixed when moved to external DMA driver. Leftovers IIRC are related
>> > to
>> > address space. Are you going to fix them? Otherwise it might be a
>> > headache for him again with strong wording to our address I
>> > suppose.
>> 
>> There are some issues with __iomem annotations.  Is that the warnings
>> you refer to?  I'm not getting any regular compiler warnings.
>> 
>
> I guess I got them because I'am checking sparse warnings as well.
>
> There is the original Linus' complain.
> http://permalink.gmane.org/gmane.linux.ide/59391

He's right, those casts are ugly and possibly wrong.  I was thinking of
cleaning it up, but first I wanted to get it working at all with my
hardware.

-- 
Måns Rullgård
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1292642 — [PATCH 2/3] ata: sata_dwc_460ex: add phy support

FromMans Rullgard <mans@mansr.com>
Date2015-12-16 00:30 +0100
Subject[PATCH 2/3] ata: sata_dwc_460ex: add phy support
Message-ID<qG7cC-2o7-31@gated-at.bofh.it>
In reply to#1292639
This adds support for powering on an optional PHY when activating the
device.

Signed-off-by: Mans Rullgard <mans@mansr.com>
---
 drivers/ata/Kconfig          |  1 +
 drivers/ata/sata_dwc_460ex.c | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 193c673..b13c609 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -296,6 +296,7 @@ config ATA_PIIX
 
 config SATA_DWC
 	tristate "DesignWare Cores SATA support"
+	select GENERIC_PHY
 	help
 	  This option enables support for the on-chip SATA controller of the
 	  AppliedMicro processor 460EX.
diff --git a/drivers/ata/sata_dwc_460ex.c b/drivers/ata/sata_dwc_460ex.c
index 9985749..d07aae1 100644
--- a/drivers/ata/sata_dwc_460ex.c
+++ b/drivers/ata/sata_dwc_460ex.c
@@ -35,6 +35,7 @@
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
 #include <linux/platform_device.h>
+#include <linux/phy/phy.h>
 #include <linux/libata.h>
 #include <linux/slab.h>
 
@@ -145,6 +146,7 @@ struct sata_dwc_device {
 	struct ata_host		*host;
 	u8 __iomem		*reg_base;
 	struct sata_dwc_regs	*sata_dwc_regs;	/* DW Synopsys SATA specific */
+	struct phy		*phy;
 #ifdef CONFIG_SATA_DWC_OLD_DMA
 	struct dw_dma_chip	*dma;
 #endif
@@ -1318,6 +1320,21 @@ static int sata_dwc_probe(struct platform_device *ofdev)
 	}
 #endif
 
+	hsdev->phy = devm_phy_optional_get(hsdev->dev, "sata-phy");
+	if (IS_ERR(hsdev->phy)) {
+		err = PTR_ERR(hsdev->phy);
+		hsdev->phy = NULL;
+		goto error_out;
+	}
+
+	err = phy_init(hsdev->phy);
+	if (err)
+		goto error_out;
+
+	err = phy_power_on(hsdev->phy);
+	if (err)
+		goto error_out;
+
 	/*
 	 * Now, register with libATA core, this will also initiate the
 	 * device discovery process, invoking our port_start() handler &
@@ -1331,6 +1348,7 @@ static int sata_dwc_probe(struct platform_device *ofdev)
 	return 0;
 
 error_out:
+	phy_exit(hsdev->phy);
 	iounmap(base);
 	return err;
 }
@@ -1343,6 +1361,9 @@ static int sata_dwc_remove(struct platform_device *ofdev)
 
 	ata_host_detach(host);
 
+	phy_power_off(hsdev->phy);
+	phy_exit(hsdev->phy);
+
 #ifdef CONFIG_SATA_DWC_OLD_DMA
 	/* Free SATA DMA resources */
 	if (hsdev->dma) {
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1292900 — Re: [PATCH 2/3] ata: sata_dwc_460ex: add phy support

FromSergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Date2015-12-16 12:20 +0100
SubjectRe: [PATCH 2/3] ata: sata_dwc_460ex: add phy support
Message-ID<qGihI-12A-1@gated-at.bofh.it>
In reply to#1292642
Hello.

On 12/16/2015 2:25 AM, Mans Rullgard wrote:

> This adds support for powering on an optional PHY when activating the
> device.
>
> Signed-off-by: Mans Rullgard <mans@mansr.com>
[...]
> diff --git a/drivers/ata/sata_dwc_460ex.c b/drivers/ata/sata_dwc_460ex.c
> index 9985749..d07aae1 100644
> --- a/drivers/ata/sata_dwc_460ex.c
> +++ b/drivers/ata/sata_dwc_460ex.c
[...]
> @@ -1318,6 +1320,21 @@ static int sata_dwc_probe(struct platform_device *ofdev)
>   	}
>   #endif
>
> +	hsdev->phy = devm_phy_optional_get(hsdev->dev, "sata-phy");
> +	if (IS_ERR(hsdev->phy)) {
> +		err = PTR_ERR(hsdev->phy);
> +		hsdev->phy = NULL;
> +		goto error_out;
> +	}
> +
> +	err = phy_init(hsdev->phy);
> +	if (err)
> +		goto error_out;

    If phy_init() fails, do we really need to call phy_exit()?

> +
> +	err = phy_power_on(hsdev->phy);
> +	if (err)
> +		goto error_out;
> +
>   	/*
>   	 * Now, register with libATA core, this will also initiate the
>   	 * device discovery process, invoking our port_start() handler &
> @@ -1331,6 +1348,7 @@ static int sata_dwc_probe(struct platform_device *ofdev)
>   	return 0;
>
>   error_out:
> +	phy_exit(hsdev->phy);
>   	iounmap(base);
>   	return err;
>   }
[...]

MBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1292904 — Re: [PATCH 2/3] ata: sata_dwc_460ex: add phy support

FromMåns Rullgård <mans@mansr.com>
Date2015-12-16 12:30 +0100
SubjectRe: [PATCH 2/3] ata: sata_dwc_460ex: add phy support
Message-ID<qGirn-175-1@gated-at.bofh.it>
In reply to#1292900
Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> writes:

> Hello.
>
> On 12/16/2015 2:25 AM, Mans Rullgard wrote:
>
>> This adds support for powering on an optional PHY when activating the
>> device.
>>
>> Signed-off-by: Mans Rullgard <mans@mansr.com>
> [...]
>> diff --git a/drivers/ata/sata_dwc_460ex.c b/drivers/ata/sata_dwc_460ex.c
>> index 9985749..d07aae1 100644
>> --- a/drivers/ata/sata_dwc_460ex.c
>> +++ b/drivers/ata/sata_dwc_460ex.c
> [...]
>> @@ -1318,6 +1320,21 @@ static int sata_dwc_probe(struct platform_device *ofdev)
>>   	}
>>   #endif
>>
>> +	hsdev->phy = devm_phy_optional_get(hsdev->dev, "sata-phy");
>> +	if (IS_ERR(hsdev->phy)) {
>> +		err = PTR_ERR(hsdev->phy);
>> +		hsdev->phy = NULL;
>> +		goto error_out;
>> +	}
>> +
>> +	err = phy_init(hsdev->phy);
>> +	if (err)
>> +		goto error_out;
>
>    If phy_init() fails, do we really need to call phy_exit()?

No, but it doesn't hurt either, and it makes the code slightly simpler.
I can change it though.

>> +
>> +	err = phy_power_on(hsdev->phy);
>> +	if (err)
>> +		goto error_out;
>> +
>>   	/*
>>   	 * Now, register with libATA core, this will also initiate the
>>   	 * device discovery process, invoking our port_start() handler &
>> @@ -1331,6 +1348,7 @@ static int sata_dwc_probe(struct platform_device *ofdev)
>>   	return 0;
>>
>>   error_out:
>> +	phy_exit(hsdev->phy);
>>   	iounmap(base);
>>   	return err;
>>   }
> [...]
>
> MBR, Sergei
>

-- 
Måns Rullgård
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1292645

FromMåns Rullgård <mans@mansr.com>
Date2015-12-16 00:40 +0100
Message-ID<qG7mh-2sQ-9@gated-at.bofh.it>
In reply to#1292639
Mans Rullgard <mans@mansr.com> writes:

> Currently this driver only works with a DesignWare DMA engine which it
> registers manually using the second "reg" address range and interrupt
> number from the DT node.
>
> This patch makes the driver instead use the "dmas" property if present,
> otherwise optionally falling back on the old way so existing device
> trees can continue to work.
>
> With this change, there is no longer any reason to depend on the 460EX
> machine type so drop that from Kconfig.
>
> Signed-off-by: Mans Rullgard <mans@mansr.com>
> ---
>  drivers/ata/Kconfig          |  10 ++-
>  drivers/ata/sata_dwc_460ex.c | 192 +++++++++++++++++++++++++++----------------
>  2 files changed, 131 insertions(+), 71 deletions(-)

The corresponding patch for the canyonlands devicetree looks something
like this.  I don't have any such hardware or even a manual, so I don't
know what values to use for the various required DT properties of the
DMA controller node, nor can I test it.  The SATA driver works with a
different DMA controller on a Sigma Designs chip.

diff --git a/arch/powerpc/boot/dts/canyonlands.dts b/arch/powerpc/boot/dts/canyonlands.dts
index 3dc75de..959f36e 100644
--- a/arch/powerpc/boot/dts/canyonlands.dts
+++ b/arch/powerpc/boot/dts/canyonlands.dts
@@ -190,12 +190,22 @@
 					 /* DMA */ 0x2 &UIC0 0xc 0x4>;
 		};
 
+		DMA0: dma@bffd0800 {
+			compatible = "snps,dma-spear1340";
+			reg = <4 0xbffd0800 0x400>;
+			interrupt-parent = <&UIC3>;
+			interrupts = <0x5 0x4>;
+			#dma-cells = <3>;
+			/* required properties here */
+		};
+
 		SATA0: sata@bffd1000 {
 			compatible = "amcc,sata-460ex";
-			reg = <4 0xbffd1000 0x800 4 0xbffd0800 0x400>;
+			reg = <4 0xbffd1000 0x800>;
 			interrupt-parent = <&UIC3>;
-			interrupts = <0x0 0x4       /* SATA */
-				      0x5 0x4>;     /* AHBDMA */
+			interrupts = <0x0 0x4>;
+			dmas = <&DMA0 0 0 1>;
+			dma-names = "sata-dma";
 		};
 
 		POB0: opb {


-- 
Måns Rullgård
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1293963 — Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel

FromAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Date2015-12-17 16:10 +0100
SubjectRe: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel
Message-ID<qGIlP-154-5@gated-at.bofh.it>
In reply to#1292645
On Tue, 2015-12-15 at 23:34 +0000, Måns Rullgård wrote:
> Mans Rullgard <mans@mansr.com> writes:
> 
> > Currently this driver only works with a DesignWare DMA engine which
> > it
> > registers manually using the second "reg" address range and
> > interrupt
> > number from the DT node.
> > 
> > This patch makes the driver instead use the "dmas" property if
> > present,
> > otherwise optionally falling back on the old way so existing device
> > trees can continue to work.
> > 
> > With this change, there is no longer any reason to depend on the
> > 460EX
> > machine type so drop that from Kconfig.
> > 
> > Signed-off-by: Mans Rullgard <mans@mansr.com>
> > ---
> >  drivers/ata/Kconfig          |  10 ++-
> >  drivers/ata/sata_dwc_460ex.c | 192 +++++++++++++++++++++++++++--
> > --------------
> >  2 files changed, 131 insertions(+), 71 deletions(-)
> 
> The corresponding patch for the canyonlands devicetree looks
> something
> like this.  I don't have any such hardware or even a manual, so I
> don't
> know what values to use for the various required DT properties of the
> DMA controller node, nor can I test it.  The SATA driver works with a
> different DMA controller on a Sigma Designs chip.
> 
> diff --git a/arch/powerpc/boot/dts/canyonlands.dts
> b/arch/powerpc/boot/dts/canyonlands.dts
> index 3dc75de..959f36e 100644
> --- a/arch/powerpc/boot/dts/canyonlands.dts
> +++ b/arch/powerpc/boot/dts/canyonlands.dts
> @@ -190,12 +190,22 @@
>  					 /* DMA */ 0x2 &UIC0 0xc
> 0x4>;
>  		};
>  
> +		DMA0: dma@bffd0800 {
> +			compatible = "snps,dma-spear1340";
> +			reg = <4 0xbffd0800 0x400>;
> +			interrupt-parent = <&UIC3>;
> +			interrupts = <0x5 0x4>;
> +			#dma-cells = <3>;
> +			/* required properties here */

You have to move the master assignments and other custom dw_dmac
properties. Maybe at some point I will fix that in dw/platform.c.

> +		};
> +
>  		SATA0: sata@bffd1000 {
>  			compatible = "amcc,sata-460ex";
> -			reg = <4 0xbffd1000 0x800 4 0xbffd0800
> 0x400>;
> +			reg = <4 0xbffd1000 0x800>;
>  			interrupt-parent = <&UIC3>;
> -			interrupts = <0x0 0x4       /* SATA */
> -				      0x5 0x4>;     /* AHBDMA */
> +			interrupts = <0x0 0x4>;
> +			dmas = <&DMA0 0 0 1>;
> +			dma-names = "sata-dma";
>  		};
>  
>  		POB0: opb {
> 
> 

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1293975

FromMåns Rullgård <mans@mansr.com>
Date2015-12-17 16:20 +0100
Message-ID<qGIvw-18F-17@gated-at.bofh.it>
In reply to#1293963
Andy Shevchenko <andriy.shevchenko@linux.intel.com> writes:

> On Tue, 2015-12-15 at 23:34 +0000, Måns Rullgård wrote:
>> Mans Rullgard <mans@mansr.com> writes:
>> 
>> > Currently this driver only works with a DesignWare DMA engine which
>> > it
>> > registers manually using the second "reg" address range and
>> > interrupt
>> > number from the DT node.
>> > 
>> > This patch makes the driver instead use the "dmas" property if
>> > present,
>> > otherwise optionally falling back on the old way so existing device
>> > trees can continue to work.
>> > 
>> > With this change, there is no longer any reason to depend on the
>> > 460EX
>> > machine type so drop that from Kconfig.
>> > 
>> > Signed-off-by: Mans Rullgard <mans@mansr.com>
>> > ---
>> >  drivers/ata/Kconfig          |  10 ++-
>> >  drivers/ata/sata_dwc_460ex.c | 192 +++++++++++++++++++++++++++--
>> > --------------
>> >  2 files changed, 131 insertions(+), 71 deletions(-)
>> 
>> The corresponding patch for the canyonlands devicetree looks
>> something
>> like this.  I don't have any such hardware or even a manual, so I
>> don't
>> know what values to use for the various required DT properties of the
>> DMA controller node, nor can I test it.  The SATA driver works with a
>> different DMA controller on a Sigma Designs chip.
>> 
>> diff --git a/arch/powerpc/boot/dts/canyonlands.dts
>> b/arch/powerpc/boot/dts/canyonlands.dts
>> index 3dc75de..959f36e 100644
>> --- a/arch/powerpc/boot/dts/canyonlands.dts
>> +++ b/arch/powerpc/boot/dts/canyonlands.dts
>> @@ -190,12 +190,22 @@
>>  					 /* DMA */ 0x2 &UIC0 0xc
>> 0x4>;
>>  		};
>>  
>> +		DMA0: dma@bffd0800 {
>> +			compatible = "snps,dma-spear1340";
>> +			reg = <4 0xbffd0800 0x400>;
>> +			interrupt-parent = <&UIC3>;
>> +			interrupts = <0x5 0x4>;
>> +			#dma-cells = <3>;
>> +			/* required properties here */
>
> You have to move the master assignments and other custom dw_dmac
> properties. Maybe at some point I will fix that in dw/platform.c.
>
>> +		};

The current sata_dwc driver calls dw_dma_probe() with null pdata which
causes the dw_dma driver to auto-detect most parameters.  It looks like
simply omitting those properties here results in the same thing,
although in this case dw_dma_parse_dt() leaves a devm-allocated pdata
struct adrift.  Deferring the allocation of that and changing the DT
binding doc to make these properties optional for auto-detect-capable
hardware should just work.  Something like this:

diff --git a/drivers/dma/dw/platform.c b/drivers/dma/dw/platform.c
index 68a4815..f90c465 100644
--- a/drivers/dma/dw/platform.c
+++ b/drivers/dma/dw/platform.c
@@ -103,18 +103,21 @@ dw_dma_parse_dt(struct platform_device *pdev)
 	struct device_node *np = pdev->dev.of_node;
 	struct dw_dma_platform_data *pdata;
 	u32 tmp, arr[DW_DMA_MAX_NR_MASTERS];
+	u32 nr_channels;
 
 	if (!np) {
 		dev_err(&pdev->dev, "Missing DT data\n");
 		return NULL;
 	}
 
+	if (of_property_read_u32(np, "dma-channels", nr_channels))
+		return NULL;
+
 	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
 	if (!pdata)
 		return NULL;
 
-	if (of_property_read_u32(np, "dma-channels", &pdata->nr_channels))
-		return NULL;
+	pdata->nr_channels = nr_channels;
 
 	if (of_property_read_bool(np, "is_private"))
 		pdata->is_private = true;


-- 
Måns Rullgård
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1293992 — Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel

FromAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Date2015-12-17 17:00 +0100
SubjectRe: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel
Message-ID<qGJ8d-1nC-3@gated-at.bofh.it>
In reply to#1293975
On Thu, 2015-12-17 at 15:13 +0000, Måns Rullgård wrote:
> Andy Shevchenko <andriy.shevchenko@linux.intel.com> writes:
> 
> > On Tue, 2015-12-15 at 23:34 +0000, Måns Rullgård wrote:
> > > Mans Rullgard <mans@mansr.com> writes:
> > > 
> > > > Currently this driver only works with a DesignWare DMA engine
> > > > which
> > > > it
> > > > registers manually using the second "reg" address range and
> > > > interrupt
> > > > number from the DT node.
> > > > 
> > > > This patch makes the driver instead use the "dmas" property if
> > > > present,
> > > > otherwise optionally falling back on the old way so existing
> > > > device
> > > > trees can continue to work.
> > > > 
> > > > With this change, there is no longer any reason to depend on
> > > > the
> > > > 460EX
> > > > machine type so drop that from Kconfig.
> > > > 
> > > > Signed-off-by: Mans Rullgard <mans@mansr.com>
> > > > ---
> > > >  drivers/ata/Kconfig          |  10 ++-
> > > >  drivers/ata/sata_dwc_460ex.c | 192
> > > > +++++++++++++++++++++++++++--
> > > > --------------
> > > >  2 files changed, 131 insertions(+), 71 deletions(-)
> > > 
> > > The corresponding patch for the canyonlands devicetree looks
> > > something
> > > like this.  I don't have any such hardware or even a manual, so I
> > > don't
> > > know what values to use for the various required DT properties of
> > > the
> > > DMA controller node, nor can I test it.  The SATA driver works
> > > with a
> > > different DMA controller on a Sigma Designs chip.
> > > 
> > > diff --git a/arch/powerpc/boot/dts/canyonlands.dts
> > > b/arch/powerpc/boot/dts/canyonlands.dts
> > > index 3dc75de..959f36e 100644
> > > --- a/arch/powerpc/boot/dts/canyonlands.dts
> > > +++ b/arch/powerpc/boot/dts/canyonlands.dts
> > > @@ -190,12 +190,22 @@
> > >  					 /* DMA */ 0x2 &UIC0 0xc
> > > 0x4>;
> > >  		};
> > >  
> > > +		DMA0: dma@bffd0800 {
> > > +			compatible = "snps,dma-spear1340";
> > > +			reg = <4 0xbffd0800 0x400>;
> > > +			interrupt-parent = <&UIC3>;
> > > +			interrupts = <0x5 0x4>;
> > > +			#dma-cells = <3>;
> > > +			/* required properties here */
> > 
> > You have to move the master assignments and other custom dw_dmac
> > properties. Maybe at some point I will fix that in dw/platform.c.
> > 
> > > +		};
> 
> The current sata_dwc driver calls dw_dma_probe() with null pdata
> which
> causes the dw_dma driver to auto-detect most parameters.  It looks
> like
> simply omitting those properties here results in the same thing,
> although in this case dw_dma_parse_dt() leaves a devm-allocated pdata
> struct adrift.  Deferring the allocation of that and changing the DT
> binding doc to make these properties optional for auto-detect-capable
> hardware should just work.  

Yeah, I would like to allow autoconfiguration in case of DT as well and
translate it to use unified device property API.


> Something like this:

If it works for you, please, submit as a patch. Thanks.

> 
> diff --git a/drivers/dma/dw/platform.c b/drivers/dma/dw/platform.c
> index 68a4815..f90c465 100644
> --- a/drivers/dma/dw/platform.c
> +++ b/drivers/dma/dw/platform.c
> @@ -103,18 +103,21 @@ dw_dma_parse_dt(struct platform_device *pdev)
>  	struct device_node *np = pdev->dev.of_node;
>  	struct dw_dma_platform_data *pdata;
>  	u32 tmp, arr[DW_DMA_MAX_NR_MASTERS];
> +	u32 nr_channels;
>  
>  	if (!np) {
>  		dev_err(&pdev->dev, "Missing DT data\n");
>  		return NULL;
>  	}
>  
> +	if (of_property_read_u32(np, "dma-channels", nr_channels))
> +		return NULL;
> +
>  	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata),
> GFP_KERNEL);
>  	if (!pdata)
>  		return NULL;
>  
> -	if (of_property_read_u32(np, "dma-channels", &pdata-
> >nr_channels))
> -		return NULL;
> +	pdata->nr_channels = nr_channels;
>  
>  	if (of_property_read_bool(np, "is_private"))
>  		pdata->is_private = true;
> 
> 

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1294011

FromMåns Rullgård <mans@mansr.com>
Date2015-12-17 17:10 +0100
Message-ID<qGJhU-1Gz-23@gated-at.bofh.it>
In reply to#1293992
Andy Shevchenko <andriy.shevchenko@linux.intel.com> writes:

> On Thu, 2015-12-17 at 15:13 +0000, Måns Rullgård wrote:
>> Andy Shevchenko <andriy.shevchenko@linux.intel.com> writes:
>> 
>> > On Tue, 2015-12-15 at 23:34 +0000, Måns Rullgård wrote:
>> > > Mans Rullgard <mans@mansr.com> writes:
>> > > 
>> > > > Currently this driver only works with a DesignWare DMA engine
>> > > > which it registers manually using the second "reg" address
>> > > > range and interrupt number from the DT node.
>> > > > 
>> > > > This patch makes the driver instead use the "dmas" property if
>> > > > present, otherwise optionally falling back on the old way so
>> > > > existing device trees can continue to work.
>> > > > 
>> > > > With this change, there is no longer any reason to depend on
>> > > > the 460EX machine type so drop that from Kconfig.
>> > > > 
>> > > > Signed-off-by: Mans Rullgard <mans@mansr.com>
>> > > > ---
>> > > >  drivers/ata/Kconfig          |  10 ++-
>> > > >  drivers/ata/sata_dwc_460ex.c | 192
>> > > > +++++++++++++++++++++++++++--
>> > > > --------------
>> > > >  2 files changed, 131 insertions(+), 71 deletions(-)
>> > > 
>> > > The corresponding patch for the canyonlands devicetree looks
>> > > something
>> > > like this.  I don't have any such hardware or even a manual, so I
>> > > don't
>> > > know what values to use for the various required DT properties of
>> > > the
>> > > DMA controller node, nor can I test it.  The SATA driver works
>> > > with a
>> > > different DMA controller on a Sigma Designs chip.
>> > > 
>> > > diff --git a/arch/powerpc/boot/dts/canyonlands.dts
>> > > b/arch/powerpc/boot/dts/canyonlands.dts
>> > > index 3dc75de..959f36e 100644
>> > > --- a/arch/powerpc/boot/dts/canyonlands.dts
>> > > +++ b/arch/powerpc/boot/dts/canyonlands.dts
>> > > @@ -190,12 +190,22 @@
>> > >  					 /* DMA */ 0x2 &UIC0 0xc
>> > > 0x4>;
>> > >  		};
>> > >  
>> > > +		DMA0: dma@bffd0800 {
>> > > +			compatible = "snps,dma-spear1340";
>> > > +			reg = <4 0xbffd0800 0x400>;
>> > > +			interrupt-parent = <&UIC3>;
>> > > +			interrupts = <0x5 0x4>;
>> > > +			#dma-cells = <3>;
>> > > +			/* required properties here */
>> > 
>> > You have to move the master assignments and other custom dw_dmac
>> > properties. Maybe at some point I will fix that in dw/platform.c.
>> > 
>> > > +		};
>> 
>> The current sata_dwc driver calls dw_dma_probe() with null pdata
>> which causes the dw_dma driver to auto-detect most parameters.  It
>> looks like simply omitting those properties here results in the same
>> thing, although in this case dw_dma_parse_dt() leaves a
>> devm-allocated pdata struct adrift.  Deferring the allocation of that
>> and changing the DT binding doc to make these properties optional for
>> auto-detect-capable hardware should just work.
>
> Yeah, I would like to allow autoconfiguration in case of DT as well and
> translate it to use unified device property API.
>
>> Something like this:
>
> If it works for you, please, submit as a patch. Thanks.

I can't test it since I have no such hardware.

-- 
Måns Rullgård
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1294046 — Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel

FromAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Date2015-12-17 18:00 +0100
SubjectRe: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel
Message-ID<qGK4k-21x-47@gated-at.bofh.it>
In reply to#1294011
On Thu, 2015-12-17 at 16:04 +0000, Måns Rullgård wrote:
> Andy Shevchenko <andriy.shevchenko@linux.intel.com> writes:
> 
> > On Thu, 2015-12-17 at 15:13 +0000, Måns Rullgård wrote:
> > > Andy Shevchenko <andriy.shevchenko@linux.intel.com> writes:
> > > 
> > > > On Tue, 2015-12-15 at 23:34 +0000, Måns Rullgård wrote:
> > > > > Mans Rullgard <mans@mansr.com> writes:
> > > > > 
> > > > > > Currently this driver only works with a DesignWare DMA
> > > > > > engine
> > > > > > which it registers manually using the second "reg" address
> > > > > > range and interrupt number from the DT node.
> > > > > > 
> > > > > > This patch makes the driver instead use the "dmas" property
> > > > > > if
> > > > > > present, otherwise optionally falling back on the old way
> > > > > > so
> > > > > > existing device trees can continue to work.
> > > > > > 
> > > > > > With this change, there is no longer any reason to depend
> > > > > > on
> > > > > > the 460EX machine type so drop that from Kconfig.
> > > > > > 
> > > > > > Signed-off-by: Mans Rullgard <mans@mansr.com>
> > > > > > ---
> > > > > >  drivers/ata/Kconfig          |  10 ++-
> > > > > >  drivers/ata/sata_dwc_460ex.c | 192
> > > > > > +++++++++++++++++++++++++++--
> > > > > > --------------
> > > > > >  2 files changed, 131 insertions(+), 71 deletions(-)
> > > > > 
> > > > > The corresponding patch for the canyonlands devicetree looks
> > > > > something
> > > > > like this.  I don't have any such hardware or even a manual,
> > > > > so I
> > > > > don't
> > > > > know what values to use for the various required DT
> > > > > properties of
> > > > > the
> > > > > DMA controller node, nor can I test it.  The SATA driver
> > > > > works
> > > > > with a
> > > > > different DMA controller on a Sigma Designs chip.
> > > > > 
> > > > > diff --git a/arch/powerpc/boot/dts/canyonlands.dts
> > > > > b/arch/powerpc/boot/dts/canyonlands.dts
> > > > > index 3dc75de..959f36e 100644
> > > > > --- a/arch/powerpc/boot/dts/canyonlands.dts
> > > > > +++ b/arch/powerpc/boot/dts/canyonlands.dts
> > > > > @@ -190,12 +190,22 @@
> > > > >  					 /* DMA */ 0x2 &UIC0
> > > > > 0xc
> > > > > 0x4>;
> > > > >  		};
> > > > >  
> > > > > +		DMA0: dma@bffd0800 {
> > > > > +			compatible = "snps,dma-spear1340";
> > > > > +			reg = <4 0xbffd0800 0x400>;
> > > > > +			interrupt-parent = <&UIC3>;
> > > > > +			interrupts = <0x5 0x4>;
> > > > > +			#dma-cells = <3>;
> > > > > +			/* required properties here */
> > > > 
> > > > You have to move the master assignments and other custom
> > > > dw_dmac
> > > > properties. Maybe at some point I will fix that in
> > > > dw/platform.c.
> > > > 
> > > > > +		};
> > > 
> > > The current sata_dwc driver calls dw_dma_probe() with null pdata
> > > which causes the dw_dma driver to auto-detect most
> > > parameters.  It
> > > looks like simply omitting those properties here results in the
> > > same
> > > thing, although in this case dw_dma_parse_dt() leaves a
> > > devm-allocated pdata struct adrift.  Deferring the allocation of
> > > that
> > > and changing the DT binding doc to make these properties optional
> > > for
> > > auto-detect-capable hardware should just work.
> > 
> > Yeah, I would like to allow autoconfiguration in case of DT as well
> > and
> > translate it to use unified device property API.
> > 
> > > Something like this:
> > 
> > If it works for you, please, submit as a patch. Thanks.
> 
> I can't test it since I have no such hardware.

It's currently broken, last person who seems to have it is
(was?) Julian Margetson [1]

[1] https://patchwork.ozlabs.org/patch/439850/

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1294096

FromMåns Rullgård <mans@mansr.com>
Date2015-12-17 19:00 +0100
Message-ID<qGL0n-2Bm-23@gated-at.bofh.it>
In reply to#1294046
Julian Margetson <runaway@candw.ms> writes:

> I have been running my machine mostly configured for pciex1  thus with
> the sata_dwc disabled.
> The changes to sata_dwc-460ex do cause an oops.
> I will try to give more detailed info over this weekend .

The driver as is upstream would do that since it unconditionally
dereferences a null pointer in the probe function.  My patch fixes that
as a side-effect.

-- 
Måns Rullgård
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1294137

FromMåns Rullgård <mans@mansr.com>
Date2015-12-17 20:00 +0100
Message-ID<qGLWp-3f0-3@gated-at.bofh.it>
In reply to#1294096
Julian Margetson <runaway@candw.ms> writes:

> On 12/17/2015 1:59 PM, Måns Rullgård wrote:
>> Julian Margetson <runaway@candw.ms> writes:
>>
>>> I have been running my machine mostly configured for pciex1  thus with
>>> the sata_dwc disabled.
>>> The changes to sata_dwc-460ex do cause an oops.
>>> I will try to give more detailed info over this weekend .
>> The driver as is upstream would do that since it unconditionally
>> dereferences a null pointer in the probe function.  My patch fixes that
>> as a side-effect.
>>
>
> patching file drivers/ata/Kconfig
>
> Hunk #1 FAILED at 296.

[...]

> root@julian-VirtualBox:/usr/src/linux-3.18.25#

The patch is against 4.4-rc5.

-- 
Måns Rullgård
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1294364 — Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel

FromJulian Margetson <runaway@candw.ms>
Date2015-12-18 02:00 +0100
SubjectRe: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel
Message-ID<qGRyO-6Zc-5@gated-at.bofh.it>
In reply to#1294137
On 12/17/2015 8:06 PM, Måns Rullgård wrote:
> Julian Margetson <runaway@candw.ms> writes:
>
>> On 12/17/2015 3:53 PM, Måns Rullgård wrote:
>>> Julian Margetson <runaway@candw.ms> writes:
>>>
>>>> On 12/17/2015 2:51 PM, Måns Rullgård wrote:
>>>>> Julian Margetson <runaway@candw.ms> writes:
>>>>>
>>>>>> On 12/17/2015 1:59 PM, Måns Rullgård wrote:
>>>>>>> Julian Margetson <runaway@candw.ms> writes:
>>>>>>>
>>>>>>>> I have been running my machine mostly configured for pciex1  thus with
>>>>>>>> the sata_dwc disabled.
>>>>>>>> The changes to sata_dwc-460ex do cause an oops.
>>>>>>>> I will try to give more detailed info over this weekend .
>>>>>>> The driver as is upstream would do that since it unconditionally
>>>>>>> dereferences a null pointer in the probe function.  My patch fixes that
>>>>>>> as a side-effect.
>>>>>>>
>>>>>> patching file drivers/ata/Kconfig
>>>>>>
>>>>>> Hunk #1 FAILED at 296.
>>>>> [...]
>>>>>
>>>>>> root@julian-VirtualBox:/usr/src/linux-3.18.25#
>>>>> The patch is against 4.4-rc5.
>>>>>
>>>>    CC      drivers/ata/sata_dwc_460ex.o
>>>>
>>>> drivers/ata/sata_dwc_460ex.c:198:15: error: variable ‘sata_dwc_dma_dws’ has initializer but incomplete type
>>>>
>>>>    static struct dw_dma_slave sata_dwc_dma_dws = {
>>>>                  ^
>>> It builds, albeit with an unrelated warning, using the attached config.
>>> Maybe there's a missing config dependency somewhere.
>>>
>> I am attempting to cross compile under Ubuntu 14.04 X86 in Virtualbox
>> with your .config.
>> 4.4.0-rc5 builds ok with no patches applied .
>> Once your patch is applied it fails to build .
>>
>> CC      drivers/ata/sata_dwc_460ex.o
>> drivers/ata/sata_dwc_460ex.c:198:15: error: variable ‘sata_dwc_dma_dws’ has initializer but incomplete type
>>   static struct dw_dma_slave sata_dwc_dma_dws = {
>>                 ^
> Bizarre.  This is what it looks like here:
>
> mru@unicorn:/tmp/linux-sata$ git status
> On branch sata-dwc
> nothing to commit, working directory clean
> mru@unicorn:/tmp/linux-sata$ git describe
> v4.4-rc5
> mru@unicorn:/tmp/linux-sata$ sha1sum /tmp/0001-ata-sata_dwc_460ex-use-dmas-DT-property-to-find-dma-.patch
> e300971aa483390f82de2e9120dc16e460e74feb  /tmp/0001-ata-sata_dwc_460ex-use-dmas-DT-property-to-find-dma-.patch
> mru@unicorn:/tmp/linux-sata$ git am /tmp/0001-ata-sata_dwc_460ex-use-dmas-DT-property-to-find-dma-.patch
> Applying: ata: sata_dwc_460ex: use "dmas" DT property to find dma channel
> mru@unicorn:/tmp/linux-sata$ sha1sum .config
> 4e7615b8d2fa9a1c4b4ae9ffc363aefcaf3789ca  .config
> mru@unicorn:/tmp/linux-sata$ make ARCH=powerpc CROSS_COMPILE=powerpc64-none-linux-gnu- oldconfig
>    HOSTCC  scripts/basic/fixdep
>    HOSTCC  scripts/kconfig/conf.o
>    SHIPPED scripts/kconfig/zconf.tab.c
>    SHIPPED scripts/kconfig/zconf.lex.c
>    SHIPPED scripts/kconfig/zconf.hash.c
>    HOSTCC  scripts/kconfig/zconf.tab.o
>    HOSTLD  scripts/kconfig/conf
> scripts/kconfig/conf  --oldconfig Kconfig
> #
> # configuration written to .config
> #
> mru@unicorn:/tmp/linux-sata$ make ARCH=powerpc CROSS_COMPILE=powerpc64-none-linux-gnu- drivers/ata/sata_dwc_460ex.o
> scripts/kconfig/conf  --silentoldconfig Kconfig
>    CHK     include/config/kernel.release
>    UPD     include/config/kernel.release
>    WRAP    arch/powerpc/include/generated/asm/clkdev.h
>    WRAP    arch/powerpc/include/generated/asm/div64.h
>    WRAP    arch/powerpc/include/generated/asm/irq_regs.h
>    WRAP    arch/powerpc/include/generated/asm/irq_work.h
>    WRAP    arch/powerpc/include/generated/asm/local64.h
>    WRAP    arch/powerpc/include/generated/asm/mcs_spinlock.h
>    WRAP    arch/powerpc/include/generated/asm/preempt.h
>    WRAP    arch/powerpc/include/generated/asm/rwsem.h
>    WRAP    arch/powerpc/include/generated/asm/vtime.h
>    CHK     include/generated/uapi/linux/version.h
>    UPD     include/generated/uapi/linux/version.h
>    CHK     include/generated/utsrelease.h
>    UPD     include/generated/utsrelease.h
>    CC      kernel/bounds.s
>    CHK     include/generated/bounds.h
>    UPD     include/generated/bounds.h
>    CHK     include/generated/timeconst.h
>    UPD     include/generated/timeconst.h
>    CC      arch/powerpc/kernel/asm-offsets.s
>    CHK     include/generated/asm-offsets.h
>    UPD     include/generated/asm-offsets.h
>    CALL    scripts/checksyscalls.sh
>    HOSTCC  scripts/dtc/dtc.o
>    HOSTCC  scripts/dtc/flattree.o
>    HOSTCC  scripts/dtc/fstree.o
>    HOSTCC  scripts/dtc/data.o
>    HOSTCC  scripts/dtc/livetree.o
>    HOSTCC  scripts/dtc/treesource.o
>    HOSTCC  scripts/dtc/srcpos.o
>    HOSTCC  scripts/dtc/checks.o
>    HOSTCC  scripts/dtc/util.o
>    SHIPPED scripts/dtc/dtc-lexer.lex.c
>    SHIPPED scripts/dtc/dtc-parser.tab.h
>    HOSTCC  scripts/dtc/dtc-lexer.lex.o
>    SHIPPED scripts/dtc/dtc-parser.tab.c
>    HOSTCC  scripts/dtc/dtc-parser.tab.o
>    HOSTLD  scripts/dtc/dtc
>    CC      scripts/mod/empty.o
>    HOSTCC  scripts/mod/mk_elfconfig
>    MKELF   scripts/mod/elfconfig.h
>    HOSTCC  scripts/mod/modpost.o
>    CC      scripts/mod/devicetable-offsets.s
>    GEN     scripts/mod/devicetable-offsets.h
>    HOSTCC  scripts/mod/file2alias.o
>    HOSTCC  scripts/mod/sumversion.o
>    HOSTLD  scripts/mod/modpost
>    HOSTCC  scripts/kallsyms
>    CC      drivers/ata/sata_dwc_460ex.o
> drivers/ata/sata_dwc_460ex.c: In function 'dma_dwc_xfer_setup':
> drivers/ata/sata_dwc_460ex.c:383:20: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
>    dma_addr_t addr = (dma_addr_t)&hsdev->sata_dwc_regs->dmadr;
>                      ^
> mru@unicorn:/tmp/linux-sata$
>
> Patch file and .config attached.
>
> Looking into that warning, I doubt it works as is, but that's not caused
> by my patch.  I can try to come up with a fix, but again, I can't test it.
>
I am using

make ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu-

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1294385

FromMåns Rullgård <mans@mansr.com>
Date2015-12-18 02:40 +0100
Message-ID<qGSbw-7rk-13@gated-at.bofh.it>
In reply to#1294364
Julian Margetson <runaway@candw.ms> writes:

> On 12/17/2015 8:06 PM, Måns Rullgård wrote:
>> Julian Margetson <runaway@candw.ms> writes:
>>
>>> On 12/17/2015 3:53 PM, Måns Rullgård wrote:
>>>> Julian Margetson <runaway@candw.ms> writes:
>>>>
>>>>> On 12/17/2015 2:51 PM, Måns Rullgård wrote:
>>>>>> Julian Margetson <runaway@candw.ms> writes:
>>>>>>
>>>>>>> On 12/17/2015 1:59 PM, Måns Rullgård wrote:
>>>>>>>> Julian Margetson <runaway@candw.ms> writes:
>>>>>>>>
>>>>>>>>> I have been running my machine mostly configured for pciex1  thus with
>>>>>>>>> the sata_dwc disabled.
>>>>>>>>> The changes to sata_dwc-460ex do cause an oops.
>>>>>>>>> I will try to give more detailed info over this weekend .
>>>>>>>> The driver as is upstream would do that since it unconditionally
>>>>>>>> dereferences a null pointer in the probe function.  My patch fixes that
>>>>>>>> as a side-effect.
>>>>>>>>
>>>>>>> patching file drivers/ata/Kconfig
>>>>>>>
>>>>>>> Hunk #1 FAILED at 296.
>>>>>> [...]
>>>>>>
>>>>>>> root@julian-VirtualBox:/usr/src/linux-3.18.25#
>>>>>> The patch is against 4.4-rc5.
>>>>>>
>>>>>    CC      drivers/ata/sata_dwc_460ex.o
>>>>>
>>>>> drivers/ata/sata_dwc_460ex.c:198:15: error: variable ‘sata_dwc_dma_dws’ has initializer but incomplete type
>>>>>
>>>>>    static struct dw_dma_slave sata_dwc_dma_dws = {
>>>>>                  ^
>>>> It builds, albeit with an unrelated warning, using the attached config.
>>>> Maybe there's a missing config dependency somewhere.
>>>>
>>> I am attempting to cross compile under Ubuntu 14.04 X86 in Virtualbox
>>> with your .config.
>>> 4.4.0-rc5 builds ok with no patches applied .
>>> Once your patch is applied it fails to build .
>>>
>>> CC      drivers/ata/sata_dwc_460ex.o
>>> drivers/ata/sata_dwc_460ex.c:198:15: error: variable ‘sata_dwc_dma_dws’ has initializer but incomplete type
>>>   static struct dw_dma_slave sata_dwc_dma_dws = {
>>>                 ^
>> Bizarre.  This is what it looks like here:
>>
>> mru@unicorn:/tmp/linux-sata$ git status
>> On branch sata-dwc
>> nothing to commit, working directory clean
>> mru@unicorn:/tmp/linux-sata$ git describe
>> v4.4-rc5
>> mru@unicorn:/tmp/linux-sata$ sha1sum /tmp/0001-ata-sata_dwc_460ex-use-dmas-DT-property-to-find-dma-.patch
>> e300971aa483390f82de2e9120dc16e460e74feb  /tmp/0001-ata-sata_dwc_460ex-use-dmas-DT-property-to-find-dma-.patch
>> mru@unicorn:/tmp/linux-sata$ git am /tmp/0001-ata-sata_dwc_460ex-use-dmas-DT-property-to-find-dma-.patch
>> Applying: ata: sata_dwc_460ex: use "dmas" DT property to find dma channel
>> mru@unicorn:/tmp/linux-sata$ sha1sum .config
>> 4e7615b8d2fa9a1c4b4ae9ffc363aefcaf3789ca  .config
>> mru@unicorn:/tmp/linux-sata$ make ARCH=powerpc CROSS_COMPILE=powerpc64-none-linux-gnu- oldconfig
>>    HOSTCC  scripts/basic/fixdep
>>    HOSTCC  scripts/kconfig/conf.o
>>    SHIPPED scripts/kconfig/zconf.tab.c
>>    SHIPPED scripts/kconfig/zconf.lex.c
>>    SHIPPED scripts/kconfig/zconf.hash.c
>>    HOSTCC  scripts/kconfig/zconf.tab.o
>>    HOSTLD  scripts/kconfig/conf
>> scripts/kconfig/conf  --oldconfig Kconfig
>> #
>> # configuration written to .config
>> #
>> mru@unicorn:/tmp/linux-sata$ make ARCH=powerpc CROSS_COMPILE=powerpc64-none-linux-gnu- drivers/ata/sata_dwc_460ex.o
>> scripts/kconfig/conf  --silentoldconfig Kconfig

[...]

>>    CC      drivers/ata/sata_dwc_460ex.o
>> drivers/ata/sata_dwc_460ex.c: In function 'dma_dwc_xfer_setup':
>> drivers/ata/sata_dwc_460ex.c:383:20: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
>>    dma_addr_t addr = (dma_addr_t)&hsdev->sata_dwc_regs->dmadr;
>>                      ^
>> mru@unicorn:/tmp/linux-sata$
>>
>> Patch file and .config attached.
>>
>> Looking into that warning, I doubt it works as is, but that's not caused
>> by my patch.  I can try to come up with a fix, but again, I can't test it.
>>
> I am using
>
> make ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu-

Shouldn't matter since the compiler flags include -m32, and I only had a
powerpc64 toolchain built.  Anyhow, I built a 32-bit toolchain and it
still builds.

Just to make sure you applied the patch correctly:

mru@unicorn:/tmp/linux-sata$ sha1sum drivers/ata/sata_dwc_460ex.c 
c8a7927840aade75ac62b04a2c9acc8335a34d6f  drivers/ata/sata_dwc_460ex.c

Digging deeper into that warning, it is clearly a bug which has always
been there.  The reason it ever worked appears to be that the 460EX has
a dedicated DMA unit hard-wired to the SATA controller ignoring that
address.  The situation is similar on my hardware.

-- 
Måns Rullgård
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1294627 — Re: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel

FromAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Date2015-12-18 11:10 +0100
SubjectRe: [PATCH 1/3] ata: sata_dwc_460ex: use "dmas" DT property to find dma channel
Message-ID<qH093-4ey-3@gated-at.bofh.it>
In reply to#1294137
On Thu, 2015-12-17 at 17:41 -0400, Julian Margetson wrote:
> On 12/17/2015 3:53 PM, Måns Rullgård wrote:
> > Julian Margetson <runaway@candw.ms> writes:
> > 
> > > On 12/17/2015 2:51 PM, Måns Rullgård wrote:
> > > > Julian Margetson <runaway@candw.ms> writes:
> > > > 
> > > > > On 12/17/2015 1:59 PM, Måns Rullgård wrote:
> > > > > > Julian Margetson <runaway@candw.ms> writes:
> > > > > > 
> > > > > > > I have been running my machine mostly configured for
> > > > > > > pciex1  thus with
> > > > > > > the sata_dwc disabled.
> > > > > > > The changes to sata_dwc-460ex do cause an oops.
> > > > > > > I will try to give more detailed info over this weekend .
> > > > > > The driver as is upstream would do that since it
> > > > > > unconditionally
> > > > > > dereferences a null pointer in the probe function.  My
> > > > > > patch fixes that
> > > > > > as a side-effect.
> > > > > > 
> > > > > patching file drivers/ata/Kconfig
> > > > > 
> > > > > Hunk #1 FAILED at 296.
> > > > [...]
> > > > 
> > > > > root@julian-VirtualBox:/usr/src/linux-3.18.25#
> > > > The patch is against 4.4-rc5.
> > > > 
> > >  CC      drivers/ata/sata_dwc_460ex.o
> > > 
> > > drivers/ata/sata_dwc_460ex.c:198:15: error: variable
> > > ‘sata_dwc_dma_dws’ has initializer but incomplete type
> > > 
> > >  static struct dw_dma_slave sata_dwc_dma_dws = {
> > >                ^
> > It builds, albeit with an unrelated warning, using the attached
> > config.
> > Maybe there's a missing config dependency somewhere.
> > 
> I am attempting to cross compile under Ubuntu 14.04 X86 in Virtualbox
> with your .config.
> 4.4.0-rc5 builds ok with no patches applied .
> Once your patch is applied it fails to build .
> CC      drivers/ata/sata_dwc_460ex.o
> drivers/ata/sata_dwc_460ex.c:198:15: error: variable
> ‘sata_dwc_dma_dws’ has initializer but incomplete type
>  static struct dw_dma_slave sata_dwc_dma_dws = {
>                ^
> drivers/ata/sata_dwc_460ex.c:199:2: error: unknown field ‘src_id’
> specified in initializer
>   .src_id = 0,

This clearly means that header file that defines the struct
dw_dma_slave is not included.

After the patch it seems you have to explicitly enable DW_DMAC, so,
either via make nconfig, or by adding
CONFIG_DW_DMAC=y


>   ^
> drivers/ata/sata_dwc_460ex.c:199:2: warning: excess elements in
> struct initializer [enabled by default]
> drivers/ata/sata_dwc_460ex.c:199:2: warning: (near initialization for
> ‘sata_dwc_dma_dws’) [enabled by default]
> drivers/ata/sata_dwc_460ex.c:200:2: error: unknown field ‘dst_id’
> specified in initializer
>   .dst_id = 0,
>   ^
> drivers/ata/sata_dwc_460ex.c:200:2: warning: excess elements in
> struct initializer [enabled by default]
> drivers/ata/sata_dwc_460ex.c:200:2: warning: (near initialization for
> ‘sata_dwc_dma_dws’) [enabled by default]
> drivers/ata/sata_dwc_460ex.c:201:2: error: unknown field ‘src_master’
> specified in initializer
>   .src_master = 0,
>   ^
> drivers/ata/sata_dwc_460ex.c:201:2: warning: excess elements in
> struct initializer [enabled by default]
> drivers/ata/sata_dwc_460ex.c:201:2: warning: (near initialization for
> ‘sata_dwc_dma_dws’) [enabled by default]
> drivers/ata/sata_dwc_460ex.c:202:2: error: unknown field ‘dst_master’
> specified in initializer
>   .dst_master = 1,
>   ^
> drivers/ata/sata_dwc_460ex.c:202:2: warning: excess elements in
> struct initializer [enabled by default]
> drivers/ata/sata_dwc_460ex.c:202:2: warning: (near initialization for
> ‘sata_dwc_dma_dws’) [enabled by default]
> drivers/ata/sata_dwc_460ex.c: In function ‘dma_dwc_xfer_setup’:
> drivers/ata/sata_dwc_460ex.c:389:20: warning: cast from pointer to
> integer of different size [-Wpointer-to-int-cast]
>   dma_addr_t addr = (dma_addr_t)&hsdev->sata_dwc_regs->dmadr;
>                     ^
> drivers/ata/sata_dwc_460ex.c: In function ‘sata_dwc_dma_filter’:
> drivers/ata/sata_dwc_460ex.c:872:9: error: dereferencing pointer to
> incomplete type
>   if (dws->dma_dev != chan->device->dev)
>          ^
> drivers/ata/sata_dwc_460ex.c: In function ‘sata_dwc_port_start’:
> drivers/ata/sata_dwc_460ex.c:958:13: error: dereferencing pointer to
> incomplete type
>   hsdevp->dws->dma_dev = hsdev->dev;
>              ^
> drivers/ata/sata_dwc_460ex.c: In function ‘sata_dwc_probe’:
> drivers/ata/sata_dwc_460ex.c:1330:12: error: dereferencing pointer to
> incomplete type
>   hsdev->dma->irq = irq_of_parse_and_map(np, 1);
>             ^
> drivers/ata/sata_dwc_460ex.c:1331:16: error: dereferencing pointer to
> incomplete type
>   if (hsdev->dma->irq == NO_IRQ) {
>                 ^
> drivers/ata/sata_dwc_460ex.c:1338:12: error: dereferencing pointer to
> incomplete type
>   hsdev->dma->regs = of_iomap(np, 1);
>             ^
> drivers/ata/sata_dwc_460ex.c:1339:17: error: dereferencing pointer to
> incomplete type
>   if (!hsdev->dma->regs) {
>                  ^
> drivers/ata/sata_dwc_460ex.c:1349:12: error: dereferencing pointer to
> incomplete type
>   hsdev->dma->dev = &ofdev->dev;
>             ^
> drivers/ata/sata_dwc_460ex.c:1352:2: error: implicit declaration of
> function ‘dw_dma_probe’ [-Werror=implicit-function-declaration]
>   err = dw_dma_probe(hsdev->dma, NULL);
>   ^
> drivers/ata/sata_dwc_460ex.c:1381:2: error: implicit declaration of
> function ‘dw_dma_remove’ [-Werror=implicit-function-declaration]
>   dw_dma_remove(hsdev->dma);
>   ^
> drivers/ata/sata_dwc_460ex.c:1383:20: error: dereferencing pointer to
> incomplete type
>   iounmap(hsdev->dma->regs);
>                     ^
> drivers/ata/sata_dwc_460ex.c: In function ‘sata_dwc_remove’:
> drivers/ata/sata_dwc_460ex.c:1400:20: error: dereferencing pointer to
> incomplete type
>   iounmap(hsdev->dma->regs);
>                     ^
> drivers/ata/sata_dwc_460ex.c: At top level:
> drivers/ata/sata_dwc_460ex.c:901:12: warning:
> ‘sata_dwc_dma_get_channel’ defined but not used [-Wunused-function]
>  static int sata_dwc_dma_get_channel(struct sata_dwc_device_port
> *hsdevp)
>             ^
> cc1: some warnings being treated as errors
> make[2]: *** [drivers/ata/sata_dwc_460ex.o] Error 1
> make[1]: *** [drivers/ata] Error 2
> make: *** [drivers] Error 2
> root@julian-VirtualBox:/usr/src/linux-4.4-rc5# 
> 
> 
> 
> 

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


Page 1 of 5  [1] 2 3 4 5  Next page →

Back to top | Article view | linux.kernel


csiph-web