* [PATCH] mfd: mc13xxx-spi: make SPI buffers DMA-safe
@ 2016-12-09 10:25 Marcus Folkesson
2016-12-19 22:43 ` kbuild test robot
0 siblings, 1 reply; 3+ messages in thread
From: Marcus Folkesson @ 2016-12-09 10:25 UTC (permalink / raw)
To: Eric Piel; +Cc: linux-kernel, Marcus Folkesson
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---
drivers/mfd/mc13xxx-spi.c | 14 +++++++-------
drivers/mfd/mc13xxx.h | 4 ++++
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/drivers/mfd/mc13xxx-spi.c b/drivers/mfd/mc13xxx-spi.c
index cbc1e5ed599c..f6bfbee9d9ef 100644
--- a/drivers/mfd/mc13xxx-spi.c
+++ b/drivers/mfd/mc13xxx-spi.c
@@ -63,14 +63,13 @@ static const struct regmap_config mc13xxx_regmap_spi_config = {
static int mc13xxx_spi_read(void *context, const void *reg, size_t reg_size,
void *val, size_t val_size)
{
- unsigned char w[4] = { *((unsigned char *) reg), 0, 0, 0};
- unsigned char r[4];
unsigned char *p = val;
struct device *dev = context;
struct spi_device *spi = to_spi_device(dev);
+ struct mc13xxx *mc13xxx = dev_get_drvdata(dev);
struct spi_transfer t = {
- .tx_buf = w,
- .rx_buf = r,
+ .tx_buf = mc13xxx->wbuf,
+ .rx_buf = mc13xxx->rbuf,
.len = 4,
};
@@ -80,11 +79,12 @@ static int mc13xxx_spi_read(void *context, const void *reg, size_t reg_size,
if (val_size != 3 || reg_size != 1)
return -ENOTSUPP;
+ mc13xxx->wbuf[0] = *(unsigned char *)reg;
spi_message_init(&m);
spi_message_add_tail(&t, &m);
ret = spi_sync(spi, &m);
- memcpy(p, &r[1], 3);
+ memcpy(p, &mc13xxx->rbuf[1], 3);
return ret;
}
@@ -100,9 +100,9 @@ static int mc13xxx_spi_write(void *context, const void *data, size_t count)
/* include errata fix for spi audio problems */
if (*reg == MC13783_AUDIO_CODEC || *reg == MC13783_AUDIO_DAC)
- spi_write(spi, data, count);
+ spi_write_then_read(spi, data, count, NULL, 0);
- return spi_write(spi, data, count);
+ return spi_write_then_read(spi, data, count, NULL, 0);
}
/*
diff --git a/drivers/mfd/mc13xxx.h b/drivers/mfd/mc13xxx.h
index 33677d1dcf66..1b35632e1d7e 100644
--- a/drivers/mfd/mc13xxx.h
+++ b/drivers/mfd/mc13xxx.h
@@ -44,6 +44,10 @@ struct mc13xxx {
int flags;
int adcflags;
+#ifdef CONFIG_MFD_MC13XXX_SPI
+ unsigned char wbuf[4] ____cacheline_aligned;
+ unsigned char rbuf[4];
+#endif
};
int mc13xxx_common_init(struct device *dev);
--
2.11.0.rc2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mfd: mc13xxx-spi: make SPI buffers DMA-safe
2016-12-09 10:25 [PATCH] mfd: mc13xxx-spi: make SPI buffers DMA-safe Marcus Folkesson
@ 2016-12-19 22:43 ` kbuild test robot
0 siblings, 0 replies; 3+ messages in thread
From: kbuild test robot @ 2016-12-19 22:43 UTC (permalink / raw)
To: Marcus Folkesson; +Cc: kbuild-all, Eric Piel, linux-kernel, Marcus Folkesson
[-- Attachment #1: Type: text/plain, Size: 1987 bytes --]
Hi Marcus,
[auto build test ERROR on ljones-mfd/for-mfd-next]
[also build test ERROR on v4.9 next-20161219]
[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/Marcus-Folkesson/mfd-mc13xxx-spi-make-SPI-buffers-DMA-safe/20161209-212034
base: https://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git for-mfd-next
config: s390-allmodconfig (attached as .config)
compiler: s390x-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=s390
All errors (new ones prefixed by >>):
drivers/mfd/mc13xxx-spi.c: In function 'mc13xxx_spi_read':
>> drivers/mfd/mc13xxx-spi.c:71:20: error: 'struct mc13xxx' has no member named 'wbuf'
.tx_buf = mc13xxx->wbuf,
^~
>> drivers/mfd/mc13xxx-spi.c:72:20: error: 'struct mc13xxx' has no member named 'rbuf'
.rx_buf = mc13xxx->rbuf,
^~
drivers/mfd/mc13xxx-spi.c:82:9: error: 'struct mc13xxx' has no member named 'wbuf'
mc13xxx->wbuf[0] = *(unsigned char *)reg;
^~
drivers/mfd/mc13xxx-spi.c:87:20: error: 'struct mc13xxx' has no member named 'rbuf'
memcpy(p, &mc13xxx->rbuf[1], 3);
^~
vim +71 drivers/mfd/mc13xxx-spi.c
65 {
66 unsigned char *p = val;
67 struct device *dev = context;
68 struct spi_device *spi = to_spi_device(dev);
69 struct mc13xxx *mc13xxx = dev_get_drvdata(dev);
70 struct spi_transfer t = {
> 71 .tx_buf = mc13xxx->wbuf,
> 72 .rx_buf = mc13xxx->rbuf,
73 .len = 4,
74 };
75
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 43192 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] mfd: mc13xxx-spi: make SPI buffers DMA-safe
@ 2016-12-09 10:24 Marcus Folkesson
0 siblings, 0 replies; 3+ messages in thread
From: Marcus Folkesson @ 2016-12-09 10:24 UTC (permalink / raw)
To: Lee Jones; +Cc: linux-kernel, Marcus Folkesson
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---
drivers/mfd/mc13xxx-spi.c | 14 +++++++-------
drivers/mfd/mc13xxx.h | 4 ++++
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/drivers/mfd/mc13xxx-spi.c b/drivers/mfd/mc13xxx-spi.c
index cbc1e5ed599c..f6bfbee9d9ef 100644
--- a/drivers/mfd/mc13xxx-spi.c
+++ b/drivers/mfd/mc13xxx-spi.c
@@ -63,14 +63,13 @@ static const struct regmap_config mc13xxx_regmap_spi_config = {
static int mc13xxx_spi_read(void *context, const void *reg, size_t reg_size,
void *val, size_t val_size)
{
- unsigned char w[4] = { *((unsigned char *) reg), 0, 0, 0};
- unsigned char r[4];
unsigned char *p = val;
struct device *dev = context;
struct spi_device *spi = to_spi_device(dev);
+ struct mc13xxx *mc13xxx = dev_get_drvdata(dev);
struct spi_transfer t = {
- .tx_buf = w,
- .rx_buf = r,
+ .tx_buf = mc13xxx->wbuf,
+ .rx_buf = mc13xxx->rbuf,
.len = 4,
};
@@ -80,11 +79,12 @@ static int mc13xxx_spi_read(void *context, const void *reg, size_t reg_size,
if (val_size != 3 || reg_size != 1)
return -ENOTSUPP;
+ mc13xxx->wbuf[0] = *(unsigned char *)reg;
spi_message_init(&m);
spi_message_add_tail(&t, &m);
ret = spi_sync(spi, &m);
- memcpy(p, &r[1], 3);
+ memcpy(p, &mc13xxx->rbuf[1], 3);
return ret;
}
@@ -100,9 +100,9 @@ static int mc13xxx_spi_write(void *context, const void *data, size_t count)
/* include errata fix for spi audio problems */
if (*reg == MC13783_AUDIO_CODEC || *reg == MC13783_AUDIO_DAC)
- spi_write(spi, data, count);
+ spi_write_then_read(spi, data, count, NULL, 0);
- return spi_write(spi, data, count);
+ return spi_write_then_read(spi, data, count, NULL, 0);
}
/*
diff --git a/drivers/mfd/mc13xxx.h b/drivers/mfd/mc13xxx.h
index 33677d1dcf66..1b35632e1d7e 100644
--- a/drivers/mfd/mc13xxx.h
+++ b/drivers/mfd/mc13xxx.h
@@ -44,6 +44,10 @@ struct mc13xxx {
int flags;
int adcflags;
+#ifdef CONFIG_MFD_MC13XXX_SPI
+ unsigned char wbuf[4] ____cacheline_aligned;
+ unsigned char rbuf[4];
+#endif
};
int mc13xxx_common_init(struct device *dev);
--
2.11.0.rc2
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-12-19 22:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-09 10:25 [PATCH] mfd: mc13xxx-spi: make SPI buffers DMA-safe Marcus Folkesson
2016-12-19 22:43 ` kbuild test robot
-- strict thread matches above, loose matches on Subject: below --
2016-12-09 10:24 Marcus Folkesson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).