As pointed by commit c0a9f4d396c9 ("can: c_can: Reduce register access")
the "driver casts the 16 message objects in stone, which is completely
braindead as contemporary hardware has up to 128 message objects".
The patch prepares the module to extend the number of message objects
beyond the 32 currently managed. This was achieved by transforming the
constants used to manage RX/TX messages into variables without changing
the driver policy.
Signed-off-by: Dario Binacchi <[email protected]>
---
drivers/net/can/c_can/c_can.c | 56 +++++++++++++++++---------
drivers/net/can/c_can/c_can.h | 23 +++++------
drivers/net/can/c_can/c_can_platform.c | 2 +-
3 files changed, 48 insertions(+), 33 deletions(-)
diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c
index 7081cfaf62e2..772b26685fea 100644
--- a/drivers/net/can/c_can/c_can.c
+++ b/drivers/net/can/c_can/c_can.c
@@ -173,9 +173,6 @@
/* Wait for ~1 sec for INIT bit */
#define INIT_WAIT_MS 1000
-/* napi related */
-#define C_CAN_NAPI_WEIGHT C_CAN_MSG_OBJ_RX_NUM
-
/* c_can lec values */
enum c_can_lec_type {
LEC_NO_ERROR = 0,
@@ -325,7 +322,7 @@ static void c_can_setup_tx_object(struct net_device *dev, int iface,
* first, i.e. clear the MSGVAL flag in the arbiter.
*/
if (rtr != (bool)test_bit(idx, &priv->tx_dir)) {
- u32 obj = idx + C_CAN_MSG_OBJ_TX_FIRST;
+ u32 obj = idx + priv->msg_obj_tx_first;
c_can_inval_msg_object(dev, iface, obj);
change_bit(idx, &priv->tx_dir);
@@ -463,10 +460,10 @@ static netdev_tx_t c_can_start_xmit(struct sk_buff *skb,
* prioritized. The lowest buffer number wins.
*/
idx = fls(atomic_read(&priv->tx_active));
- obj = idx + C_CAN_MSG_OBJ_TX_FIRST;
+ obj = idx + priv->msg_obj_tx_first;
/* If this is the last buffer, stop the xmit queue */
- if (idx == C_CAN_MSG_OBJ_TX_NUM - 1)
+ if (idx == priv->msg_obj_tx_num - 1)
netif_stop_queue(dev);
/*
* Store the message in the interface so we can call
@@ -549,17 +546,18 @@ static int c_can_set_bittiming(struct net_device *dev)
*/
static void c_can_configure_msg_objects(struct net_device *dev)
{
+ struct c_can_priv *priv = netdev_priv(dev);
int i;
/* first invalidate all message objects */
- for (i = C_CAN_MSG_OBJ_RX_FIRST; i <= C_CAN_NO_OF_OBJECTS; i++)
+ for (i = priv->msg_obj_rx_first; i <= priv->msg_obj_num; i++)
c_can_inval_msg_object(dev, IF_RX, i);
/* setup receive message objects */
- for (i = C_CAN_MSG_OBJ_RX_FIRST; i < C_CAN_MSG_OBJ_RX_LAST; i++)
+ for (i = priv->msg_obj_rx_first; i < priv->msg_obj_rx_last; i++)
c_can_setup_receive_object(dev, IF_RX, i, 0, 0, IF_MCONT_RCV);
- c_can_setup_receive_object(dev, IF_RX, C_CAN_MSG_OBJ_RX_LAST, 0, 0,
+ c_can_setup_receive_object(dev, IF_RX, priv->msg_obj_rx_last, 0, 0,
IF_MCONT_RCV_EOB);
}
@@ -730,7 +728,7 @@ static void c_can_do_tx(struct net_device *dev)
while ((idx = ffs(pend))) {
idx--;
pend &= ~(1 << idx);
- obj = idx + C_CAN_MSG_OBJ_TX_FIRST;
+ obj = idx + priv->msg_obj_tx_first;
c_can_inval_tx_object(dev, IF_TX, obj);
can_get_echo_skb(dev, idx, NULL);
bytes += priv->dlc[idx];
@@ -740,7 +738,7 @@ static void c_can_do_tx(struct net_device *dev)
/* Clear the bits in the tx_active mask */
atomic_sub(clr, &priv->tx_active);
- if (clr & (1 << (C_CAN_MSG_OBJ_TX_NUM - 1)))
+ if (clr & (1 << (priv->msg_obj_tx_num - 1)))
netif_wake_queue(dev);
if (pkts) {
@@ -755,11 +753,11 @@ static void c_can_do_tx(struct net_device *dev)
* raced with the hardware or failed to readout all upper
* objects in the last run due to quota limit.
*/
-static u32 c_can_adjust_pending(u32 pend)
+static u32 c_can_adjust_pending(u32 pend, u32 rx_mask)
{
u32 weight, lasts;
- if (pend == RECEIVE_OBJECT_BITS)
+ if (pend == rx_mask)
return pend;
/*
@@ -862,8 +860,7 @@ static int c_can_do_rx_poll(struct net_device *dev, int quota)
* It is faster to read only one 16bit register. This is only possible
* for a maximum number of 16 objects.
*/
- BUILD_BUG_ON_MSG(C_CAN_MSG_OBJ_RX_LAST > 16,
- "Implementation does not support more message objects than 16");
+ WARN_ON(priv->msg_obj_rx_last > 16);
while (quota > 0) {
if (!pend) {
@@ -874,7 +871,8 @@ static int c_can_do_rx_poll(struct net_device *dev, int quota)
* If the pending field has a gap, handle the
* bits above the gap first.
*/
- toread = c_can_adjust_pending(pend);
+ toread = c_can_adjust_pending(pend,
+ priv->msg_obj_rx_mask);
} else {
toread = pend;
}
@@ -1205,17 +1203,36 @@ static int c_can_close(struct net_device *dev)
return 0;
}
-struct net_device *alloc_c_can_dev(void)
+struct net_device *alloc_c_can_dev(int msg_obj_num)
{
struct net_device *dev;
struct c_can_priv *priv;
+ int msg_obj_tx_num = msg_obj_num / 2;
- dev = alloc_candev(sizeof(struct c_can_priv), C_CAN_MSG_OBJ_TX_NUM);
+ dev = alloc_candev(sizeof(struct c_can_priv), msg_obj_tx_num);
if (!dev)
return NULL;
priv = netdev_priv(dev);
- netif_napi_add(dev, &priv->napi, c_can_poll, C_CAN_NAPI_WEIGHT);
+ priv->msg_obj_num = msg_obj_num;
+ priv->msg_obj_rx_num = msg_obj_num - msg_obj_tx_num;
+ priv->msg_obj_rx_first = 1;
+ priv->msg_obj_rx_last =
+ priv->msg_obj_rx_first + priv->msg_obj_rx_num - 1;
+ priv->msg_obj_rx_mask = ((u64)1 << priv->msg_obj_rx_num) - 1;
+
+ priv->msg_obj_tx_num = msg_obj_tx_num;
+ priv->msg_obj_tx_first = priv->msg_obj_rx_last + 1;
+ priv->msg_obj_tx_last =
+ priv->msg_obj_tx_first + priv->msg_obj_tx_num - 1;
+
+ priv->dlc = kcalloc(msg_obj_tx_num, sizeof(*priv->dlc), GFP_KERNEL);
+ if (!priv->dlc) {
+ free_candev(dev);
+ return NULL;
+ }
+
+ netif_napi_add(dev, &priv->napi, c_can_poll, priv->msg_obj_rx_num);
priv->dev = dev;
priv->can.bittiming_const = &c_can_bittiming_const;
@@ -1320,6 +1337,7 @@ void free_c_can_dev(struct net_device *dev)
struct c_can_priv *priv = netdev_priv(dev);
netif_napi_del(&priv->napi);
+ kfree(priv->dlc);
free_candev(dev);
}
EXPORT_SYMBOL_GPL(free_c_can_dev);
diff --git a/drivers/net/can/c_can/c_can.h b/drivers/net/can/c_can/c_can.h
index 90d3d2e7a086..1dbe777320f5 100644
--- a/drivers/net/can/c_can/c_can.h
+++ b/drivers/net/can/c_can/c_can.h
@@ -22,18 +22,7 @@
#ifndef C_CAN_H
#define C_CAN_H
-/* message object split */
#define C_CAN_NO_OF_OBJECTS 32
-#define C_CAN_MSG_OBJ_RX_NUM 16
-#define C_CAN_MSG_OBJ_TX_NUM 16
-
-#define C_CAN_MSG_OBJ_RX_FIRST 1
-#define C_CAN_MSG_OBJ_RX_LAST (C_CAN_MSG_OBJ_RX_FIRST + \
- C_CAN_MSG_OBJ_RX_NUM - 1)
-
-#define C_CAN_MSG_OBJ_TX_FIRST (C_CAN_MSG_OBJ_RX_LAST + 1)
-
-#define RECEIVE_OBJECT_BITS 0x0000ffff
enum reg {
C_CAN_CTRL_REG = 0,
@@ -193,6 +182,14 @@ struct c_can_priv {
struct napi_struct napi;
struct net_device *dev;
struct device *device;
+ int msg_obj_num;
+ int msg_obj_rx_num;
+ int msg_obj_tx_num;
+ int msg_obj_rx_first;
+ int msg_obj_rx_last;
+ int msg_obj_tx_first;
+ int msg_obj_tx_last;
+ u32 msg_obj_rx_mask;
atomic_t tx_active;
atomic_t sie_pending;
unsigned long tx_dir;
@@ -209,10 +206,10 @@ struct c_can_priv {
void (*raminit) (const struct c_can_priv *priv, bool enable);
u32 comm_rcv_high;
u32 rxmasked;
- u32 dlc[C_CAN_MSG_OBJ_TX_NUM];
+ u32 *dlc;
};
-struct net_device *alloc_c_can_dev(void);
+struct net_device *alloc_c_can_dev(int msg_obj_num);
void free_c_can_dev(struct net_device *dev);
int register_c_can_dev(struct net_device *dev);
void unregister_c_can_dev(struct net_device *dev);
diff --git a/drivers/net/can/c_can/c_can_platform.c b/drivers/net/can/c_can/c_can_platform.c
index 05f425ceb53a..a5b9b1a93702 100644
--- a/drivers/net/can/c_can/c_can_platform.c
+++ b/drivers/net/can/c_can/c_can_platform.c
@@ -293,7 +293,7 @@ static int c_can_plat_probe(struct platform_device *pdev)
}
/* allocate the c_can device */
- dev = alloc_c_can_dev();
+ dev = alloc_c_can_dev(C_CAN_NO_OF_OBJECTS);
if (!dev) {
ret = -ENOMEM;
goto exit;
--
2.17.1
Hi Dario,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on mkl-can-next/testing]
[also build test ERROR on linux/master net-next/master net/master linus/master next-20210225]
[cannot apply to sparc-next/master v5.11]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Dario-Binacchi/can-c_can-add-support-to-64-messages-objects/20210225-070042
base: https://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git testing
config: x86_64-randconfig-a006-20210225 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project a921aaf789912d981cbb2036bdc91ad7289e1523)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# https://github.com/0day-ci/linux/commit/9bbfc6bc12c1d9a2445413bf6e710302f012c1ae
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Dario-Binacchi/can-c_can-add-support-to-64-messages-objects/20210225-070042
git checkout 9bbfc6bc12c1d9a2445413bf6e710302f012c1ae
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>
All errors (new ones prefixed by >>):
>> drivers/net/can/c_can/c_can_pci.c:152:24: error: too few arguments to function call, single argument 'msg_obj_num' was not specified
dev = alloc_c_can_dev();
~~~~~~~~~~~~~~~ ^
drivers/net/can/c_can/c_can.h:212:20: note: 'alloc_c_can_dev' declared here
struct net_device *alloc_c_can_dev(int msg_obj_num);
^
1 error generated.
vim +/msg_obj_num +152 drivers/net/can/c_can/c_can_pci.c
abcd7f750a7e97 Alexander Stein 2014-04-07 113
3c8ac0f2ad53a9 Bill Pemberton 2012-12-03 114 static int c_can_pci_probe(struct pci_dev *pdev,
5b92da0443c258 Federico Vaga 2012-06-14 115 const struct pci_device_id *ent)
5b92da0443c258 Federico Vaga 2012-06-14 116 {
5b92da0443c258 Federico Vaga 2012-06-14 117 struct c_can_pci_data *c_can_pci_data = (void *)ent->driver_data;
5b92da0443c258 Federico Vaga 2012-06-14 118 struct c_can_priv *priv;
5b92da0443c258 Federico Vaga 2012-06-14 119 struct net_device *dev;
5b92da0443c258 Federico Vaga 2012-06-14 120 void __iomem *addr;
5b92da0443c258 Federico Vaga 2012-06-14 121 int ret;
5b92da0443c258 Federico Vaga 2012-06-14 122
5b92da0443c258 Federico Vaga 2012-06-14 123 ret = pci_enable_device(pdev);
5b92da0443c258 Federico Vaga 2012-06-14 124 if (ret) {
5b92da0443c258 Federico Vaga 2012-06-14 125 dev_err(&pdev->dev, "pci_enable_device FAILED\n");
5b92da0443c258 Federico Vaga 2012-06-14 126 goto out;
5b92da0443c258 Federico Vaga 2012-06-14 127 }
5b92da0443c258 Federico Vaga 2012-06-14 128
5b92da0443c258 Federico Vaga 2012-06-14 129 ret = pci_request_regions(pdev, KBUILD_MODNAME);
5b92da0443c258 Federico Vaga 2012-06-14 130 if (ret) {
5b92da0443c258 Federico Vaga 2012-06-14 131 dev_err(&pdev->dev, "pci_request_regions FAILED\n");
5b92da0443c258 Federico Vaga 2012-06-14 132 goto out_disable_device;
5b92da0443c258 Federico Vaga 2012-06-14 133 }
5b92da0443c258 Federico Vaga 2012-06-14 134
78c181bc8a75d3 Wolfgang Grandegger 2014-04-03 135 ret = pci_enable_msi(pdev);
78c181bc8a75d3 Wolfgang Grandegger 2014-04-03 136 if (!ret) {
78c181bc8a75d3 Wolfgang Grandegger 2014-04-03 137 dev_info(&pdev->dev, "MSI enabled\n");
5b92da0443c258 Federico Vaga 2012-06-14 138 pci_set_master(pdev);
78c181bc8a75d3 Wolfgang Grandegger 2014-04-03 139 }
5b92da0443c258 Federico Vaga 2012-06-14 140
abcd7f750a7e97 Alexander Stein 2014-04-07 141 addr = pci_iomap(pdev, c_can_pci_data->bar,
abcd7f750a7e97 Alexander Stein 2014-04-07 142 pci_resource_len(pdev, c_can_pci_data->bar));
5b92da0443c258 Federico Vaga 2012-06-14 143 if (!addr) {
5b92da0443c258 Federico Vaga 2012-06-14 144 dev_err(&pdev->dev,
5b92da0443c258 Federico Vaga 2012-06-14 145 "device has no PCI memory resources, "
5b92da0443c258 Federico Vaga 2012-06-14 146 "failing adapter\n");
5b92da0443c258 Federico Vaga 2012-06-14 147 ret = -ENOMEM;
5b92da0443c258 Federico Vaga 2012-06-14 148 goto out_release_regions;
5b92da0443c258 Federico Vaga 2012-06-14 149 }
5b92da0443c258 Federico Vaga 2012-06-14 150
5b92da0443c258 Federico Vaga 2012-06-14 151 /* allocate the c_can device */
5b92da0443c258 Federico Vaga 2012-06-14 @152 dev = alloc_c_can_dev();
5b92da0443c258 Federico Vaga 2012-06-14 153 if (!dev) {
5b92da0443c258 Federico Vaga 2012-06-14 154 ret = -ENOMEM;
5b92da0443c258 Federico Vaga 2012-06-14 155 goto out_iounmap;
5b92da0443c258 Federico Vaga 2012-06-14 156 }
5b92da0443c258 Federico Vaga 2012-06-14 157
5b92da0443c258 Federico Vaga 2012-06-14 158 priv = netdev_priv(dev);
5b92da0443c258 Federico Vaga 2012-06-14 159 pci_set_drvdata(pdev, dev);
5b92da0443c258 Federico Vaga 2012-06-14 160 SET_NETDEV_DEV(dev, &pdev->dev);
5b92da0443c258 Federico Vaga 2012-06-14 161
5b92da0443c258 Federico Vaga 2012-06-14 162 dev->irq = pdev->irq;
5b92da0443c258 Federico Vaga 2012-06-14 163 priv->base = addr;
c97c52be78b846 Einar J?n 2016-08-12 164 priv->device = &pdev->dev;
5b92da0443c258 Federico Vaga 2012-06-14 165
5b92da0443c258 Federico Vaga 2012-06-14 166 if (!c_can_pci_data->freq) {
1aa2d1daf067c8 Marc Kleine-Budde 2012-06-20 167 dev_err(&pdev->dev, "no clock frequency defined\n");
5b92da0443c258 Federico Vaga 2012-06-14 168 ret = -ENODEV;
5b92da0443c258 Federico Vaga 2012-06-14 169 goto out_free_c_can;
5b92da0443c258 Federico Vaga 2012-06-14 170 } else {
5b92da0443c258 Federico Vaga 2012-06-14 171 priv->can.clock.freq = c_can_pci_data->freq;
5b92da0443c258 Federico Vaga 2012-06-14 172 }
5b92da0443c258 Federico Vaga 2012-06-14 173
5b92da0443c258 Federico Vaga 2012-06-14 174 /* Configure CAN type */
5b92da0443c258 Federico Vaga 2012-06-14 175 switch (c_can_pci_data->type) {
f27b1db95d047d AnilKumar Ch 2012-08-02 176 case BOSCH_C_CAN:
5b92da0443c258 Federico Vaga 2012-06-14 177 priv->regs = reg_map_c_can;
5b92da0443c258 Federico Vaga 2012-06-14 178 break;
f27b1db95d047d AnilKumar Ch 2012-08-02 179 case BOSCH_D_CAN:
5b92da0443c258 Federico Vaga 2012-06-14 180 priv->regs = reg_map_d_can;
5b92da0443c258 Federico Vaga 2012-06-14 181 break;
5b92da0443c258 Federico Vaga 2012-06-14 182 default:
5b92da0443c258 Federico Vaga 2012-06-14 183 ret = -EINVAL;
1aa2d1daf067c8 Marc Kleine-Budde 2012-06-20 184 goto out_free_c_can;
5b92da0443c258 Federico Vaga 2012-06-14 185 }
5b92da0443c258 Federico Vaga 2012-06-14 186
129eef2184218f Thomas Gleixner 2014-04-11 187 priv->type = c_can_pci_data->type;
129eef2184218f Thomas Gleixner 2014-04-11 188
5b92da0443c258 Federico Vaga 2012-06-14 189 /* Configure access to registers */
5b92da0443c258 Federico Vaga 2012-06-14 190 switch (c_can_pci_data->reg_align) {
5b92da0443c258 Federico Vaga 2012-06-14 191 case C_CAN_REG_ALIGN_32:
5b92da0443c258 Federico Vaga 2012-06-14 192 priv->read_reg = c_can_pci_read_reg_aligned_to_32bit;
5b92da0443c258 Federico Vaga 2012-06-14 193 priv->write_reg = c_can_pci_write_reg_aligned_to_32bit;
5b92da0443c258 Federico Vaga 2012-06-14 194 break;
5b92da0443c258 Federico Vaga 2012-06-14 195 case C_CAN_REG_ALIGN_16:
5b92da0443c258 Federico Vaga 2012-06-14 196 priv->read_reg = c_can_pci_read_reg_aligned_to_16bit;
5b92da0443c258 Federico Vaga 2012-06-14 197 priv->write_reg = c_can_pci_write_reg_aligned_to_16bit;
5b92da0443c258 Federico Vaga 2012-06-14 198 break;
abcd7f750a7e97 Alexander Stein 2014-04-07 199 case C_CAN_REG_32:
abcd7f750a7e97 Alexander Stein 2014-04-07 200 priv->read_reg = c_can_pci_read_reg_32bit;
abcd7f750a7e97 Alexander Stein 2014-04-07 201 priv->write_reg = c_can_pci_write_reg_32bit;
abcd7f750a7e97 Alexander Stein 2014-04-07 202 break;
5b92da0443c258 Federico Vaga 2012-06-14 203 default:
5b92da0443c258 Federico Vaga 2012-06-14 204 ret = -EINVAL;
1aa2d1daf067c8 Marc Kleine-Budde 2012-06-20 205 goto out_free_c_can;
5b92da0443c258 Federico Vaga 2012-06-14 206 }
ccbc5357db3098 Pavel Machek 2014-05-06 207 priv->read_reg32 = c_can_pci_read_reg32;
ccbc5357db3098 Pavel Machek 2014-05-06 208 priv->write_reg32 = c_can_pci_write_reg32;
5b92da0443c258 Federico Vaga 2012-06-14 209
abcd7f750a7e97 Alexander Stein 2014-04-07 210 priv->raminit = c_can_pci_data->init;
abcd7f750a7e97 Alexander Stein 2014-04-07 211
5b92da0443c258 Federico Vaga 2012-06-14 212 ret = register_c_can_dev(dev);
5b92da0443c258 Federico Vaga 2012-06-14 213 if (ret) {
5b92da0443c258 Federico Vaga 2012-06-14 214 dev_err(&pdev->dev, "registering %s failed (err=%d)\n",
5b92da0443c258 Federico Vaga 2012-06-14 215 KBUILD_MODNAME, ret);
1aa2d1daf067c8 Marc Kleine-Budde 2012-06-20 216 goto out_free_c_can;
5b92da0443c258 Federico Vaga 2012-06-14 217 }
5b92da0443c258 Federico Vaga 2012-06-14 218
5b92da0443c258 Federico Vaga 2012-06-14 219 dev_dbg(&pdev->dev, "%s device registered (regs=%p, irq=%d)\n",
5b92da0443c258 Federico Vaga 2012-06-14 220 KBUILD_MODNAME, priv->regs, dev->irq);
5b92da0443c258 Federico Vaga 2012-06-14 221
5b92da0443c258 Federico Vaga 2012-06-14 222 return 0;
5b92da0443c258 Federico Vaga 2012-06-14 223
5b92da0443c258 Federico Vaga 2012-06-14 224 out_free_c_can:
5b92da0443c258 Federico Vaga 2012-06-14 225 free_c_can_dev(dev);
5b92da0443c258 Federico Vaga 2012-06-14 226 out_iounmap:
5b92da0443c258 Federico Vaga 2012-06-14 227 pci_iounmap(pdev, addr);
5b92da0443c258 Federico Vaga 2012-06-14 228 out_release_regions:
5b92da0443c258 Federico Vaga 2012-06-14 229 pci_disable_msi(pdev);
5b92da0443c258 Federico Vaga 2012-06-14 230 pci_clear_master(pdev);
5b92da0443c258 Federico Vaga 2012-06-14 231 pci_release_regions(pdev);
5b92da0443c258 Federico Vaga 2012-06-14 232 out_disable_device:
5b92da0443c258 Federico Vaga 2012-06-14 233 pci_disable_device(pdev);
5b92da0443c258 Federico Vaga 2012-06-14 234 out:
5b92da0443c258 Federico Vaga 2012-06-14 235 return ret;
5b92da0443c258 Federico Vaga 2012-06-14 236 }
5b92da0443c258 Federico Vaga 2012-06-14 237
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]
On 25.02.2021 15:14:43, kernel test robot wrote:
> Hi Dario,
>
> Thank you for the patch! Yet something to improve:
>
> [auto build test ERROR on mkl-can-next/testing]
> [also build test ERROR on linux/master net-next/master net/master linus/master next-20210225]
> [cannot apply to sparc-next/master v5.11]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch]
>
> url: https://github.com/0day-ci/linux/commits/Dario-Binacchi/can-c_can-add-support-to-64-messages-objects/20210225-070042
> base: https://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git testing
> config: x86_64-randconfig-a006-20210225 (attached as .config)
> compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project a921aaf789912d981cbb2036bdc91ad7289e1523)
> reproduce (this is a W=1 build):
> wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # install x86_64 cross compiling tool for clang build
> # apt-get install binutils-x86-64-linux-gnu
> # https://github.com/0day-ci/linux/commit/9bbfc6bc12c1d9a2445413bf6e710302f012c1ae
> git remote add linux-review https://github.com/0day-ci/linux
> git fetch --no-tags linux-review Dario-Binacchi/can-c_can-add-support-to-64-messages-objects/20210225-070042
> git checkout 9bbfc6bc12c1d9a2445413bf6e710302f012c1ae
> # save the attached .config to linux build tree
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <[email protected]>
>
> All errors (new ones prefixed by >>):
>
> >> drivers/net/can/c_can/c_can_pci.c:152:24: error: too few arguments to function call, single argument 'msg_obj_num' was not specified
> dev = alloc_c_can_dev();
> ~~~~~~~~~~~~~~~ ^
> drivers/net/can/c_can/c_can.h:212:20: note: 'alloc_c_can_dev' declared here
> struct net_device *alloc_c_can_dev(int msg_obj_num);
> ^
> 1 error generated.
For now you can use 16, which means no change. I've added Alexander
and Federico to Cc, they added the intel pch and st micro support, maybe
they can help and add the correct size.
regards,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung West/Dortmund | Phone: +49-231-2826-924 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Hey Dario,
just a quick note...
On 24.02.2021 23:52:45, Dario Binacchi wrote:
> -struct net_device *alloc_c_can_dev(void)
> +struct net_device *alloc_c_can_dev(int msg_obj_num)
> {
> struct net_device *dev;
> struct c_can_priv *priv;
> + int msg_obj_tx_num = msg_obj_num / 2;
>
> - dev = alloc_candev(sizeof(struct c_can_priv), C_CAN_MSG_OBJ_TX_NUM);
> + dev = alloc_candev(sizeof(struct c_can_priv), msg_obj_tx_num);
> if (!dev)
> return NULL;
>
> priv = netdev_priv(dev);
> - netif_napi_add(dev, &priv->napi, c_can_poll, C_CAN_NAPI_WEIGHT);
> + priv->msg_obj_num = msg_obj_num;
> + priv->msg_obj_rx_num = msg_obj_num - msg_obj_tx_num;
> + priv->msg_obj_rx_first = 1;
> + priv->msg_obj_rx_last =
> + priv->msg_obj_rx_first + priv->msg_obj_rx_num - 1;
> + priv->msg_obj_rx_mask = ((u64)1 << priv->msg_obj_rx_num) - 1;
> +
> + priv->msg_obj_tx_num = msg_obj_tx_num;
> + priv->msg_obj_tx_first = priv->msg_obj_rx_last + 1;
> + priv->msg_obj_tx_last =
> + priv->msg_obj_tx_first + priv->msg_obj_tx_num - 1;
> +
> + priv->dlc = kcalloc(msg_obj_tx_num, sizeof(*priv->dlc), GFP_KERNEL);
You can pass a larger size to alloc_candev() so that it includes the mem
you allocate here.
> + if (!priv->dlc) {
> + free_candev(dev);
> + return NULL;
> + }
> +
> + netif_napi_add(dev, &priv->napi, c_can_poll, priv->msg_obj_rx_num);
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung West/Dortmund | Phone: +49-231-2826-924 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |