Re: [PATCH v12] i2c: Add drivers for the AMD PCIe MP2 I2C controller

From: kbuild test robot
Date: Sat Dec 08 2018 - 21:17:35 EST


Hi Elie,

I love your patch! Perhaps something to improve:

[auto build test WARNING on wsa/i2c/for-next]
[also build test WARNING on v4.20-rc5 next-20181207]
[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/Elie-Morisse/i2c-Add-drivers-for-the-AMD-PCIe-MP2-I2C-controller/20181209-070352
base: https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next
config: i386-allmodconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386

All warnings (new ones prefixed by >>):

In file included from include/linux/printk.h:336:0,
from include/linux/kernel.h:14,
from include/linux/list.h:9,
from include/linux/wait.h:7,
from include/linux/wait_bit.h:8,
from include/linux/fs.h:6,
from include/linux/debugfs.h:15,
from drivers/i2c/busses/i2c-amd-mp2-pci.c:9:
drivers/i2c/busses/i2c-amd-mp2-pci.c: In function 'amd_mp2_dma_map':
>> drivers/i2c/busses/i2c-amd-mp2-pci.c:125:30: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 5 has type 'dma_addr_t {aka unsigned int}' [-Wformat=]
dev_dbg(ndev_dev(privdata), "%s dma_addr: %llx size: %u dir: %s\n",
^
include/linux/dynamic_debug.h:135:39: note: in definition of macro 'dynamic_dev_dbg'
__dynamic_dev_dbg(&descriptor, dev, fmt, \
^~~
include/linux/device.h:1463:23: note: in expansion of macro 'dev_fmt'
dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
^~~~~~~
>> drivers/i2c/busses/i2c-amd-mp2-pci.c:125:2: note: in expansion of macro 'dev_dbg'
dev_dbg(ndev_dev(privdata), "%s dma_addr: %llx size: %u dir: %s\n",
^~~~~~~
drivers/i2c/busses/i2c-amd-mp2-pci.c: In function 'amd_mp2_debugfs_read':
drivers/i2c/busses/i2c-amd-mp2-pci.c:384:16: warning: unused variable 'mmio' [-Wunused-variable]
void __iomem *mmio = privdata->mmio;
^~~~

vim +125 drivers/i2c/busses/i2c-amd-mp2-pci.c

> 9 #include <linux/debugfs.h>
10 #include <linux/dma-mapping.h>
11 #include <linux/interrupt.h>
12 #include <linux/module.h>
13 #include <linux/pci.h>
14 #include <linux/slab.h>
15
16 #include "i2c-amd-mp2.h"
17
18 #define DRIVER_NAME "i2c_amd_mp2"
19 #define DRIVER_DESC "AMD(R) PCI-E MP2 I2C Controller Driver"
20 #define DRIVER_VER "1.0"
21
22 static inline void write64(u64 val, void __iomem *mmio)
23 {
24 writel(val, mmio);
25 writel(val >> 32, mmio + sizeof(u32));
26 }
27
28 static inline u64 read64(void __iomem *mmio)
29 {
30 u64 low, high;
31
32 low = readl(mmio);
33 high = readl(mmio + sizeof(u32));
34 return low | (high << 32);
35 }
36
37 static void amd_mp2_c2p_mutex_lock(struct amd_i2c_common *i2c_common)
38 {
39 struct amd_mp2_dev *privdata = i2c_common->mp2_dev;
40
41 /* there is only one data mailbox for two i2c adapters */
42 mutex_lock(&privdata->c2p_lock);
43 privdata->c2p_lock_busid = i2c_common->bus_id;
44 }
45
46 static void amd_mp2_c2p_mutex_unlock(struct amd_i2c_common *i2c_common)
47 {
48 struct amd_mp2_dev *privdata = i2c_common->mp2_dev;
49
50 if (unlikely(privdata->c2p_lock_busid != i2c_common->bus_id)) {
51 dev_warn(ndev_dev(privdata),
52 "bus %d attempting to unlock C2P locked by bus %d\n",
53 i2c_common->bus_id, privdata->c2p_lock_busid);
54 return;
55 }
56
57 mutex_unlock(&privdata->c2p_lock);
58 }
59
60 static int amd_mp2_cmd(struct amd_i2c_common *i2c_common,
61 union i2c_cmd_base i2c_cmd_base)
62 {
63 struct amd_mp2_dev *privdata = i2c_common->mp2_dev;
64 void __iomem *reg;
65
66 i2c_common->reqcmd = i2c_cmd_base.s.i2c_cmd;
67
68 reg = privdata->mmio + ((i2c_cmd_base.s.bus_id == 1) ?
69 AMD_C2P_MSG1 : AMD_C2P_MSG0);
70 writel(i2c_cmd_base.ul, reg);
71
72 return 0;
73 }
74
75 int amd_mp2_bus_enable_set(struct amd_i2c_common *i2c_common, bool enable)
76 {
77 struct amd_mp2_dev *privdata = i2c_common->mp2_dev;
78 union i2c_cmd_base i2c_cmd_base;
79
80 dev_dbg(ndev_dev(privdata), "%s id: %d\n", __func__,
81 i2c_common->bus_id);
82
83 i2c_cmd_base.ul = 0;
84 i2c_cmd_base.s.i2c_cmd = enable ? i2c_enable : i2c_disable;
85 i2c_cmd_base.s.bus_id = i2c_common->bus_id;
86 i2c_cmd_base.s.i2c_speed = i2c_common->i2c_speed;
87
88 amd_mp2_c2p_mutex_lock(i2c_common);
89
90 return amd_mp2_cmd(i2c_common, i2c_cmd_base);
91 }
92
93 static void amd_mp2_cmd_rw_fill(struct amd_i2c_common *i2c_common,
94 union i2c_cmd_base *i2c_cmd_base,
95 enum i2c_cmd reqcmd)
96 {
97 i2c_cmd_base->s.i2c_cmd = reqcmd;
98 i2c_cmd_base->s.bus_id = i2c_common->bus_id;
99 i2c_cmd_base->s.i2c_speed = i2c_common->i2c_speed;
100 i2c_cmd_base->s.slave_addr = i2c_common->msg->addr;
101 i2c_cmd_base->s.length = i2c_common->msg->len;
102 }
103
104 static int amd_mp2_dma_map(struct amd_mp2_dev *privdata,
105 struct amd_i2c_common *i2c_common)
106 {
107 enum dma_data_direction dma_direction =
108 i2c_common->msg->flags & I2C_M_RD ?
109 DMA_FROM_DEVICE : DMA_TO_DEVICE;
110
111 i2c_common->dma_buf = i2c_get_dma_safe_msg_buf(i2c_common->msg, 0);
112 i2c_common->dma_addr = dma_map_single(&privdata->pci_dev->dev,
113 i2c_common->dma_buf,
114 i2c_common->msg->len,
115 dma_direction);
116
117 if (dma_mapping_error(&privdata->pci_dev->dev,
118 i2c_common->dma_addr)) {
119 dev_err(ndev_dev(privdata),
120 "Error while mapping dma buffer %p\n",
121 i2c_common->dma_buf);
122 return -EIO;
123 }
124
> 125 dev_dbg(ndev_dev(privdata), "%s dma_addr: %llx size: %u dir: %s\n",
126 __func__, i2c_common->dma_addr, i2c_common->msg->len,
127 dma_direction == DMA_FROM_DEVICE ? "from" : "to");
128
129 return 0;
130 }
131

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

Attachment: .config.gz
Description: application/gzip