diff mbox series

[2/2] mmc: mmci: Add and implement a ->dma_setup() callback for qcom dml

Message ID 20180713111536.26013-1-ulf.hansson@linaro.org
State Superseded
Headers show
Series [1/2] mmc: mmci: Initial support to manage variant specific callbacks | expand

Commit Message

Ulf Hansson July 13, 2018, 11:15 a.m. UTC
As a first step to improve the variant specific code for mmci, add a
->dma_setup() callback to the struct mmci_host_ops.

To show its use, let's deploy the callback for the qcom dml, which involves
also to the assign the mmci_host_ops pointer from the variant ->init()
callback.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

---

These two patches came out of a diuscussion with Ludovic, who are trying to add
support for a new ST variant.

I consider this as potentiall being the first steps of how we could move forward
to better support variants.

If we think this makes sense, a third step is to figure out if for example,
mmci_dma_setup(), should be turned into a library function, which means the
qcom dml ->dma_setup() callback should call it, rather than the opposite as of
now.

---
 drivers/mmc/host/mmci.c          |  6 ++----
 drivers/mmc/host/mmci.h          |  1 +
 drivers/mmc/host/mmci_qcom_dml.c | 18 ++++++++++++++----
 drivers/mmc/host/mmci_qcom_dml.h |  5 ++---
 4 files changed, 19 insertions(+), 11 deletions(-)

-- 
2.17.1

Comments

kernel test robot July 14, 2018, 5:04 a.m. UTC | #1
Hi Ulf,

I love your patch! Yet something to improve:

[auto build test ERROR on ulf.hansson-mmc/next]
[also build test ERROR on v4.18-rc4 next-20180713]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Ulf-Hansson/mmc-mmci-Initial-support-to-manage-variant-specific-callbacks/20180714-110602
base:   git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git next
config: arm-allmodconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.2.0 make.cross ARCH=arm 

All errors (new ones prefixed by >>):

   drivers/mmc/host/mmci_qcom_dml.c: In function 'qcom_dma_setup':
>> drivers/mmc/host/mmci_qcom_dml.c:133:3: error: 'variant' undeclared (first use in this function); did you mean 'vprintk'?

      variant->qcom_dml = false;
      ^~~~~~~
      vprintk
   drivers/mmc/host/mmci_qcom_dml.c:133:3: note: each undeclared identifier is reported only once for each function it appears in
   drivers/mmc/host/mmci_qcom_dml.c: At top level:
>> drivers/mmc/host/mmci_qcom_dml.c:181:3: error: 'const struct mmci_host_ops' has no member named 'dma_setup'

     .dma_setup = qcom_dma_setup,
      ^~~~~~~~~
   drivers/mmc/host/mmci_qcom_dml.c: In function 'qcom_variant_init':
>> drivers/mmc/host/mmci_qcom_dml.c:186:12: error: incompatible types when assigning to type 'struct mmci_host_ops *' from type 'const struct mmci_host_ops'

     host->ops = qcom_variant_ops;
               ^

vim +133 drivers/mmc/host/mmci_qcom_dml.c

   120	
   121	/* Initialize the dml hardware connected to SD Card controller */
   122	static void qcom_dma_setup(struct mmci_host *host)
   123	{
   124		u32 config;
   125		void __iomem *base;
   126		int consumer_id, producer_id;
   127		struct device_node *np = host->mmc->parent->of_node;
   128	
   129		consumer_id = of_get_dml_pipe_index(np, "tx");
   130		producer_id = of_get_dml_pipe_index(np, "rx");
   131	
   132		if (producer_id < 0 || consumer_id < 0) {
 > 133			variant->qcom_dml = false;

   134			return;
   135		}
   136	
   137		base = host->base + DML_OFFSET;
   138	
   139		/* Reset the DML block */
   140		writel_relaxed(1, base + DML_SW_RESET);
   141	
   142		/* Disable the producer and consumer CRCI */
   143		config = (PRODUCER_CRCI_DISABLE | CONSUMER_CRCI_DISABLE);
   144		/*
   145		 * Disable the bypass mode. Bypass mode will only be used
   146		 * if data transfer is to happen in PIO mode and don't
   147		 * want the BAM interface to connect with SDCC-DML.
   148		 */
   149		config &= ~BYPASS;
   150		/*
   151		 * Disable direct mode as we don't DML to MASTER the AHB bus.
   152		 * BAM connected with DML should MASTER the AHB bus.
   153		 */
   154		config &= ~DIRECT_MODE;
   155		/*
   156		 * Disable infinite mode transfer as we won't be doing any
   157		 * infinite size data transfers. All data transfer will be
   158		 * of finite data size.
   159		 */
   160		config &= ~INFINITE_CONS_TRANS;
   161		writel_relaxed(config, base + DML_CONFIG);
   162	
   163		/*
   164		 * Initialize the logical BAM pipe size for producer
   165		 * and consumer.
   166		 */
   167		writel_relaxed(PRODUCER_PIPE_LOGICAL_SIZE,
   168			       base + DML_PRODUCER_PIPE_LOGICAL_SIZE);
   169		writel_relaxed(CONSUMER_PIPE_LOGICAL_SIZE,
   170			       base + DML_CONSUMER_PIPE_LOGICAL_SIZE);
   171	
   172		/* Initialize Producer/consumer pipe id */
   173		writel_relaxed(producer_id | (consumer_id << CONSUMER_PIPE_ID_SHFT),
   174			       base + DML_PIPE_ID);
   175	
   176		/* Make sure dml initialization is finished */
   177		mb();
   178	}
   179	
   180	static const struct mmci_host_ops qcom_variant_ops = {
 > 181		.dma_setup = qcom_dma_setup,

   182	};
   183	
   184	void qcom_variant_init(struct mmci_host *host)
   185	{
 > 186		host->ops = qcom_variant_ops;


---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox series

Patch

diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index e907a0a866da..e3e8b2336cf2 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -417,7 +417,6 @@  static void mmci_init_sg(struct mmci_host *host, struct mmc_data *data)
 static void mmci_dma_setup(struct mmci_host *host)
 {
 	const char *rxname, *txname;
-	struct variant_data *variant = host->variant;
 
 	host->dma_rx_channel = dma_request_slave_channel(mmc_dev(host->mmc), "rx");
 	host->dma_tx_channel = dma_request_slave_channel(mmc_dev(host->mmc), "tx");
@@ -465,9 +464,8 @@  static void mmci_dma_setup(struct mmci_host *host)
 			host->mmc->max_seg_size = max_seg_size;
 	}
 
-	if (variant->qcom_dml && host->dma_rx_channel && host->dma_tx_channel)
-		if (dml_hw_init(host, host->mmc->parent->of_node))
-			variant->qcom_dml = false;
+	if (host->ops && host->ops->setup_dma)
+		host->ops->setup_dma(host);
 }
 
 /*
diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
index f2eff0cc6934..634ef65cd881 100644
--- a/drivers/mmc/host/mmci.h
+++ b/drivers/mmc/host/mmci.h
@@ -273,6 +273,7 @@  struct variant_data {
 
 /* mmci variant callbacks */
 struct mmci_host_ops {
+	void (*setup_dma)(struct mmci_host *host);
 };
 
 struct mmci_host_next {
diff --git a/drivers/mmc/host/mmci_qcom_dml.c b/drivers/mmc/host/mmci_qcom_dml.c
index 00750c9d3514..d8059ce1a17c 100644
--- a/drivers/mmc/host/mmci_qcom_dml.c
+++ b/drivers/mmc/host/mmci_qcom_dml.c
@@ -119,17 +119,20 @@  static int of_get_dml_pipe_index(struct device_node *np, const char *name)
 }
 
 /* Initialize the dml hardware connected to SD Card controller */
-int dml_hw_init(struct mmci_host *host, struct device_node *np)
+static void qcom_dma_setup(struct mmci_host *host)
 {
 	u32 config;
 	void __iomem *base;
 	int consumer_id, producer_id;
+	struct device_node *np = host->mmc->parent->of_node;
 
 	consumer_id = of_get_dml_pipe_index(np, "tx");
 	producer_id = of_get_dml_pipe_index(np, "rx");
 
-	if (producer_id < 0 || consumer_id < 0)
-		return -ENODEV;
+	if (producer_id < 0 || consumer_id < 0) {
+		variant->qcom_dml = false;
+		return;
+	}
 
 	base = host->base + DML_OFFSET;
 
@@ -172,6 +175,13 @@  int dml_hw_init(struct mmci_host *host, struct device_node *np)
 
 	/* Make sure dml initialization is finished */
 	mb();
+}
 
-	return 0;
+static const struct mmci_host_ops qcom_variant_ops = {
+	.dma_setup = qcom_dma_setup,
+};
+
+void qcom_variant_init(struct mmci_host *host)
+{
+	host->ops = qcom_variant_ops;
 }
diff --git a/drivers/mmc/host/mmci_qcom_dml.h b/drivers/mmc/host/mmci_qcom_dml.h
index 6e405d09d534..fa16f6f4d4ad 100644
--- a/drivers/mmc/host/mmci_qcom_dml.h
+++ b/drivers/mmc/host/mmci_qcom_dml.h
@@ -16,12 +16,11 @@ 
 #define __MMC_QCOM_DML_H__
 
 #ifdef CONFIG_MMC_QCOM_DML
-int dml_hw_init(struct mmci_host *host, struct device_node *np);
+void qcom_variant_init(struct mmci_host *host);
 void dml_start_xfer(struct mmci_host *host, struct mmc_data *data);
 #else
-static inline int dml_hw_init(struct mmci_host *host, struct device_node *np)
+static inline void qcom_variant_init(struct mmci_host *host)
 {
-	return -ENOSYS;
 }
 static inline void dml_start_xfer(struct mmci_host *host, struct mmc_data *data)
 {