Skip to contentSkip to conversation

can: Topcliff: PCH_CAN driver: Fix build warnings

PATCH In review Tomoya 5 participants 14 messages Oct 26, 2010 – Oct 27, 2010

Subsystems (3)
lore
Share & tools
lore

Tomoya

author
#0 lore raw

PATCH v2 1/1 can: Topcliff: PCH_CAN driver: Fix build warnings

Hi David,

Quoted 1 line

This patch has been corrupted by your email client.

Sorry, it seems my e-mail client setting was reset to default.

Thanks, Tomoya(OKI SEMICONDUCTOR CO., LTD.)
---

From: Tomoya MORINAGA <[email protected]>
- Fix build warnings when PM_CONFIG is disabled.
- Modify Copyright "Co" to "CO".

---
 drivers/net/can/pch_can.c |  208 ++++++++++++++++++++++----------------------
 1 files changed, 104 insertions(+), 104 deletions(-)
drivers/net/can/pch_can.c +104 -104
index 55ec324..2889e11 100755
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 1999 - 2010 Intel Corporation.
- * Copyright (C) 2010 OKI SEMICONDUCTOR Co., LTD.
+ * Copyright (C) 2010 OKI SEMICONDUCTOR CO., LTD.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -255,21 +255,21 @@ static void pch_can_set_optmode(struct pch_can_priv *priv)
 	iowrite32(reg_val, &priv->regs->opt);
 }
 
-static void pch_can_set_int_custom(struct pch_can_priv *priv)
+static void pch_can_check_if_busy(u32 __iomem *creq_addr, u32 num)
 {
-	/* Clearing the IE, SIE and EIE bits of Can control register. */
-	pch_can_bit_clear(&priv->regs->cont, CAN_CTRL_IE_SIE_EIE);
-
-	/* Appropriately setting them. */
-	pch_can_bit_set(&priv->regs->cont,
-			((priv->int_enables & MSK_CTRL_IE_SIE_EIE) << 1));
-}
+	u32 counter = COUNTER_LIMIT;
+	u32 ifx_creq;
 
-/* This function retrieves interrupt enabled for the CAN device. */
-static void pch_can_get_int_enables(struct pch_can_priv *priv, u32 *enables)
-{
-	/* Obtaining the status of IE, SIE and EIE interrupt bits. */
-	*enables = ((ioread32(&priv->regs->cont) & CAN_CTRL_IE_SIE_EIE) >> 1);
+	iowrite32(num, creq_addr);
+	while (counter) {
+		ifx_creq = ioread32(creq_addr) & CAN_IF_CREQ_BUSY;
+		if (!ifx_creq)
+			break;
+		counter--;
+		udelay(1);
+	}
+	if (!counter)
+		pr_err("%s:IF1 BUSY Flag is set forever.\n", __func__);
 }
 
 static void pch_can_set_int_enables(struct pch_can_priv *priv,
@@ -298,23 +298,6 @@ static void pch_can_set_int_enables(struct pch_can_priv *priv,
 	}
 }
 
-static void pch_can_check_if_busy(u32 __iomem *creq_addr, u32 num)
-{
-	u32 counter = COUNTER_LIMIT;
-	u32 ifx_creq;
-
-	iowrite32(num, creq_addr);
-	while (counter) {
-		ifx_creq = ioread32(creq_addr) & CAN_IF_CREQ_BUSY;
-		if (!ifx_creq)
-			break;
-		counter--;
-		udelay(1);
-	}
-	if (!counter)
-		pr_err("%s:IF1 BUSY Flag is set forever.\n", __func__);
-}
-
 static void pch_can_set_rx_enable(struct pch_can_priv *priv, u32 buff_num,
 				  u32 set)
 {
@@ -417,82 +400,11 @@ static void pch_can_tx_disable_all(struct pch_can_priv *priv)
 	}
 }
 
-static void pch_can_get_rx_enable(struct pch_can_priv *priv, u32 buff_num,
-				 u32 *enable)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&priv->msgif_reg_lock, flags);
-	iowrite32(CAN_CMASK_RX_TX_GET, &priv->regs->if1_cmask);
-	pch_can_check_if_busy(&priv->regs->if1_creq, buff_num);
-
-	if (((ioread32(&priv->regs->if1_id2)) & CAN_ID_MSGVAL) &&
-			((ioread32(&priv->regs->if1_mcont)) &
-			CAN_IF_MCONT_RXIE))
-		*enable = ENABLE;
-	else
-		*enable = DISABLE;
-	spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
-}
-
-static void pch_can_get_tx_enable(struct pch_can_priv *priv, u32 buff_num,
-				 u32 *enable)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&priv->msgif_reg_lock, flags);
-	iowrite32(CAN_CMASK_RX_TX_GET, &priv->regs->if2_cmask);
-	pch_can_check_if_busy(&priv->regs->if2_creq, buff_num);
-
-	if (((ioread32(&priv->regs->if2_id2)) & CAN_ID_MSGVAL) &&
-			((ioread32(&priv->regs->if2_mcont)) &
-			CAN_IF_MCONT_TXIE)) {
-		*enable = ENABLE;
-	} else {
-		*enable = DISABLE;
-	}
-	spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
-}
-
 static int pch_can_int_pending(struct pch_can_priv *priv)
 {
 	return ioread32(&priv->regs->intr) & 0xffff;
 }
 
-static void pch_can_set_rx_buffer_link(struct pch_can_priv *priv,
-				       u32 buffer_num, u32 set)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&priv->msgif_reg_lock, flags);
-	iowrite32(CAN_CMASK_RX_TX_GET, &priv->regs->if1_cmask);
-	pch_can_check_if_busy(&priv->regs->if1_creq, buffer_num);
-	iowrite32(CAN_CMASK_RDWR | CAN_CMASK_CTRL, &priv->regs->if1_cmask);
-	if (set == ENABLE)
-		pch_can_bit_clear(&priv->regs->if1_mcont, CAN_IF_MCONT_EOB);
-	else
-		pch_can_bit_set(&priv->regs->if1_mcont, CAN_IF_MCONT_EOB);
-
-	pch_can_check_if_busy(&priv->regs->if1_creq, buffer_num);
-	spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
-}
-
-static void pch_can_get_rx_buffer_link(struct pch_can_priv *priv,
-				       u32 buffer_num, u32 *link)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&priv->msgif_reg_lock, flags);
-	iowrite32(CAN_CMASK_RX_TX_GET, &priv->regs->if1_cmask);
-	pch_can_check_if_busy(&priv->regs->if1_creq, buffer_num);
-
-	if (ioread32(&priv->regs->if1_mcont) & CAN_IF_MCONT_EOB)
-		*link = DISABLE;
-	else
-		*link = ENABLE;
-	spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
-}
-
 static void pch_can_clear_buffers(struct pch_can_priv *priv)
 {
 	int i;
@@ -1121,13 +1033,13 @@ static netdev_tx_t pch_xmit(struct sk_buff *skb, struct net_device *ndev)
 	if (can_dropped_invalid_skb(ndev, skb))
 		return NETDEV_TX_OK;
 
-	if (priv->tx_obj == (PCH_OBJ_NUM + 1)) { /* Point tail Obj */
+	if (priv->tx_obj == (PCH_OBJ_NUM + 1)) { /* Point tail Obj + 1 */
 		while (pch_get_msg_obj_sts(ndev, (((1 << PCH_TX_OBJ_NUM)-1) <<
 					   PCH_RX_OBJ_NUM)))
 			udelay(500);
 
 		priv->tx_obj = PCH_RX_OBJ_NUM + 1; /* Point head of Tx Obj ID */
-		tx_buffer_avail = priv->tx_obj; /* Point Tail of Tx Obj */
+		tx_buffer_avail = priv->tx_obj;
 	} else {
 		tx_buffer_avail = priv->tx_obj;
 	}
@@ -1212,6 +1124,94 @@ static void __devexit pch_can_remove(struct pci_dev *pdev)
 }
 
 #ifdef CONFIG_PM
+static void pch_can_set_int_custom(struct pch_can_priv *priv)
+{
+	/* Clearing the IE, SIE and EIE bits of Can control register. */
+	pch_can_bit_clear(&priv->regs->cont, CAN_CTRL_IE_SIE_EIE);
+
+	/* Appropriately setting them. */
+	pch_can_bit_set(&priv->regs->cont,
+			((priv->int_enables & MSK_CTRL_IE_SIE_EIE) << 1));
+}
+
+/* This function retrieves interrupt enabled for the CAN device. */
+static void pch_can_get_int_enables(struct pch_can_priv *priv, u32 *enables)
+{
+	/* Obtaining the status of IE, SIE and EIE interrupt bits. */
+	*enables = ((ioread32(&priv->regs->cont) & CAN_CTRL_IE_SIE_EIE) >> 1);
+}
+
+static void pch_can_get_rx_enable(struct pch_can_priv *priv, u32 buff_num,
+				 u32 *enable)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&priv->msgif_reg_lock, flags);
+	iowrite32(CAN_CMASK_RX_TX_GET, &priv->regs->if1_cmask);
+	pch_can_check_if_busy(&priv->regs->if1_creq, buff_num);
+
+	if (((ioread32(&priv->regs->if1_id2)) & CAN_ID_MSGVAL) &&
+			((ioread32(&priv->regs->if1_mcont)) &
+			CAN_IF_MCONT_RXIE))
+		*enable = ENABLE;
+	else
+		*enable = DISABLE;
+	spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
+}
+
+static void pch_can_get_tx_enable(struct pch_can_priv *priv, u32 buff_num,
+				 u32 *enable)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&priv->msgif_reg_lock, flags);
+	iowrite32(CAN_CMASK_RX_TX_GET, &priv->regs->if2_cmask);
+	pch_can_check_if_busy(&priv->regs->if2_creq, buff_num);
+
+	if (((ioread32(&priv->regs->if2_id2)) & CAN_ID_MSGVAL) &&
+			((ioread32(&priv->regs->if2_mcont)) &
+			CAN_IF_MCONT_TXIE)) {
+		*enable = ENABLE;
+	} else {
+		*enable = DISABLE;
+	}
+	spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
+}
+
+static void pch_can_set_rx_buffer_link(struct pch_can_priv *priv,
+				       u32 buffer_num, u32 set)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&priv->msgif_reg_lock, flags);
+	iowrite32(CAN_CMASK_RX_TX_GET, &priv->regs->if1_cmask);
+	pch_can_check_if_busy(&priv->regs->if1_creq, buffer_num);
+	iowrite32(CAN_CMASK_RDWR | CAN_CMASK_CTRL, &priv->regs->if1_cmask);
+	if (set == ENABLE)
+		pch_can_bit_clear(&priv->regs->if1_mcont, CAN_IF_MCONT_EOB);
+	else
+		pch_can_bit_set(&priv->regs->if1_mcont, CAN_IF_MCONT_EOB);
+
+	pch_can_check_if_busy(&priv->regs->if1_creq, buffer_num);
+	spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
+}
+
+static void pch_can_get_rx_buffer_link(struct pch_can_priv *priv,
+				       u32 buffer_num, u32 *link)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&priv->msgif_reg_lock, flags);
+	iowrite32(CAN_CMASK_RX_TX_GET, &priv->regs->if1_cmask);
+	pch_can_check_if_busy(&priv->regs->if1_creq, buffer_num);
+
+	if (ioread32(&priv->regs->if1_mcont) & CAN_IF_MCONT_EOB)
+		*link = DISABLE;
+	else
+		*link = ENABLE;
+	spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
+}
+
 static int pch_can_suspend(struct pci_dev *pdev, pm_message_t state)
 {
 	int i;			/* Counter variable. */
Signature · 1 line
1.6.0.6
maintainer
#1 lore raw

From: Tomoya <[email protected]>
Date: Tue, 26 Oct 2010 09:04:43 +0900

Quoted 5 lines

Hi David,

Quoted 1 line

This patch has been corrupted by your email client.

Sorry, it seems my e-mail client setting was reset to default.

There are still problems.

This is beyond frustrating.

Quoted 1 line

index 55ec324..2889e11 100755

Why does the pch_can.c file have execute permission in your tree? It doesn't in net-next-2.6 and that is what you should be generating patches against.

maintainer
#2 lore raw

From: David Miller <[email protected]>
Date: Tue, 26 Oct 2010 10:52:06 -0700 (PDT)

Quoted 1 line

It doesn't in net-next-2.6 and that is what you should be generating

                ^^^^^^^^^^^^
Quoted 1 line

patches against.

I mean net-2.6 of course.

#3 lore raw

Hi David,

Quoted 8 lines · David Miller

From: David Miller <[email protected]>
Date: Tue, 26 Oct 2010 10:52:06 -0700 (PDT)

Quoted 1 line

It doesn't in net-next-2.6 and that is what you should be generating

                ^^^^^^^^^^^^
Quoted 1 line

patches against.

I mean net-2.6 of course.

Oh, this patch has various other issues, as Marc and I have already pointed out, which should be fixed before the driver hits the user. Unfortunately, the CC to netdev of our reviews got lost somehow, sorry for the inconvenience, but the original author should have received it. Tomoya, could you (or somebody else) please also fix the remaining issues quickly?

Thanks,

Wolfgang.

#4 lore raw
Quoted 3 lines · Wolfgang Grandegger

Oh, this patch has various other issues, as Marc and I have already pointed out, which should be fixed before the driver hits the user. Unfortunately, the CC to netdev of our reviews got lost somehow, sorry

After noticing my faul I resend my review to the netdev + socketcan mailinglists and the individual persons mentioned in the original patch.

Quoted 3 lines

for the inconvenience, but the original author should have received it. Tomoya, could you (or somebody else) please also fix the remaining issues quickly?

For reference, here it is:
http://www.spinics.net/lists/netdev/msg144852.html

Marc

Signature · 4 lines
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |

_______________________________________________
Socketcan-core mailing list [email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-core

#5 lore raw

Re: [PATCH net-next-2.6 v2] can: Topcliff: PCH_CAN driver: Fix buildwarnings

On Wednesday, October 27, 2010 3:52 AM : Marc Kleine-Budde and Wolfgang Grandegge wrote:

The following is some inarticulate points I have for your questions. Please give me more information.

Quoted 2 lines

Do I understand your code correctly? You have a big loop, but only do
two different things at certain values of the loop? Smells fishy.

Uh, I can't understand your intention.
Please show in detail.
This processing does configuration for all message objects.

Quoted 2 lines

what does this loop do? why is it nessecarry? I don't like delay loops
in the hot path of a driver.

This loop is for waiting for all tx Message Object completion. This is Topcliff CAN HW specification.

Quoted 2 lines

If you figured out how to use the endianess conversion functions from the cpu_to_{le,be}-{le,to}_to_cpup family use them here, too.

Uh,le32_to_cpu have been used already here.
I can't understand your intention.
Please show in detail.

Quoted 4 lines
Quoted 2 lines

All these check if busy in the code make me a bit nervous, can you please explain why they are needed. A pointer to the manual is okay, too.

Me too. I already ask in my previous mail how long that functions usually blocks.

When accessing read/write from/to Message RAM,
Since it takes much time for transferring between Register and Message RAM, SW must check busy flag of CAN register.
This is a Topcliff HW specification.

Quoted 1 line

is there some pdev->name instead of KBUILD_MODNAME that can be used?

I can't understand your intention.
pdev(struct pci_dev) doesn't have "name" member.
Please show in detail.

Thanks, Tomoya(OKI SEMICONDUCTOR CO., LTD.)

#6 lore raw

Re: [PATCH net-next-2.6 v2] can: Topcliff: PCH_CAN driver: Fix buildwarnings

Quoted 10 lines · Tomoya MORINAGA

On Wednesday, October 27, 2010 3:52 AM : Marc Kleine-Budde and Wolfgang Grandegge wrote:

The following is some inarticulate points I have for your questions. Please give me more information.

Quoted 2 lines

Do I understand your code correctly? You have a big loop, but only do
two different things at certain values of the loop? Smells fishy.

Uh, I can't understand your intention.
Please show in detail.
This processing does configuration for all message objects.

Not all, but just a few of them. We believe it can be implemented more efficiently.

Quoted 5 lines
Quoted 3 lines

what does this loop do? why is it nessecarry? I don't like delay loops
in the hot path of a driver.

This loop is for waiting for all tx Message Object completion. This is Topcliff CAN HW specification.

What do you mean with "tx Message Object completion"? Is TX done not signaled via interrupt? Please explain why you need to wait multiples of 500us here in the hot TX path.

Quoted 7 lines
Quoted 2 lines

If you figured out how to use the endianess conversion functions from the cpu_to_{le,be}-{le,to}_to_cpup family use them here, too.

Uh,le32_to_cpu have been used already here.
I can't understand your intention.
Please show in detail.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

All these check if busy in the code make me a bit nervous, can you please explain why they are needed. A pointer to the manual is okay, too.

Me too. I already ask in my previous mail how long that functions usually blocks.

When accessing read/write from/to Message RAM,
Since it takes much time for transferring between Register and Message RAM,

Much time means how many mirco-seconds?

Quoted 2 lines

SW must check busy flag of CAN register.
This is a Topcliff HW specification.

Maybe the busy check could also be done *before* the Message RAM is accessed to avoid (or minimize) waiting.

Quoted 4 lines
Quoted 1 line

is there some pdev->name instead of KBUILD_MODNAME that can be used?

I can't understand your intention.
pdev(struct pci_dev) doesn't have "name" member.
Please show in detail.

Using KBUILD_MODNAME is OK. It does hold the name of the driver as required.

Wolfgang.

#7 lore raw

Re: [PATCH net-next-2.6 v2] can: Topcliff: PCH_CAN driver: Fix buildwarnings

Quoted 6 lines · Wolfgang Grandegger
Quoted 5 lines · Tomoya MORINAGA

On Wednesday, October 27, 2010 3:52 AM : Marc Kleine-Budde and Wolfgang Grandegge wrote:

The following is some inarticulate points I have for your questions. Please give me more information.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Do I understand your code correctly? You have a big loop, but only do
two different things at certain values of the loop? Smells fishy.

Uh, I can't understand your intention.
Please show in detail.
This processing does configuration for all message objects.

Not all, but just a few of them. We believe it can be implemented more efficiently.

I misread the code...sorry - I'm just writing a longer answer.

cheers, Marc

Signature · 4 lines
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |

_______________________________________________
Socketcan-core mailing list [email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-core

#8 lore raw

Re: [PATCH net-next-2.6 v2] can: Topcliff: PCH_CAN driver: Fix buildwarnings

In reply to Tomoya MORINAGA
Quoted 6 lines · Tomoya MORINAGA
Quoted 2 lines · On Wednesday, October 27, 2010 3:52 AM : Marc Kleine-Budde and Wolfgang…

Do I understand your code correctly? You have a big loop, but only do
two different things at certain values of the loop? Smells fishy.

Uh, I can't understand your intention.
Please show in detail.

It's easier to talk about code when we can see it, pelase don't delete :)

Quoted 41 lines
Quoted 9 lines

+static void pch_can_config_rx_tx_buffers(struct pch_can_priv *priv)

drivers/net/can/pch_can.c static void __devexit pch_can_remove(struct pci_dev *pdev)

Quoted 8 lines
drivers/net/can/pch_can.c +8 -0
+{
+	int i;
+	unsigned long flags;
+
+	spin_lock_irqsave(&priv->msgif_reg_lock, flags);
+
+	for (i = 0; i < PCH_OBJ_NUM; i++) {
+		if (priv->msg_obj[i] == MSG_OBJ_RX) {
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Quoted 21 lines
Quoted 21 lines
(quoted diff) +21 -0
+			iowrite32(CAN_CMASK_RX_TX_GET,
+				&priv->regs->if1_cmask);
+			pch_can_check_if_busy(&priv->regs->if1_creq, i+1);
+
+			iowrite32(0x0, &priv->regs->if1_id1);
+			iowrite32(0x0, &priv->regs->if1_id2);
+
+			pch_can_bit_set(&priv->regs->if1_mcont,
+					CAN_IF_MCONT_UMASK);
+
+			/* Set FIFO mode set to 0 except last Rx Obj*/
+			pch_can_bit_clear(&priv->regs->if1_mcont,
+					  CAN_IF_MCONT_EOB);
+			/* In case FIFO mode, Last EoB of Rx Obj must be 1 */
+			if (i == (PCH_RX_OBJ_NUM - 1))
+				pch_can_bit_set(&priv->regs->if1_mcont,
+						  CAN_IF_MCONT_EOB);
+
+			iowrite32(0, &priv->regs->if1_mask1);
+			pch_can_bit_clear(&priv->regs->if1_mask2,
+					  0x1fff | CAN_MASK2_MDIR_MXTD);
Quoted 8 lines

Review

Quoted 8 lines
(quoted diff) +8 -0
+
+			/* Setting CMASK for writing */
+			iowrite32(CAN_CMASK_RDWR | CAN_CMASK_MASK |
+				  CAN_CMASK_ARB | CAN_CMASK_CTRL,
+				  &priv->regs->if1_cmask);
+
+			pch_can_check_if_busy(&priv->regs->if1_creq, i+1);
+		} else if (priv->msg_obj[i] == MSG_OBJ_TX) {
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Quoted 2 lines

Do I understand your code correctly? You have a big loop, but only do two different things at certain values of the loop? Smells fishy.

Looking again at the code it makes sense as it is :) Sorry for the confusion.

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
(quoted diff) +22 -0
+			iowrite32(CAN_CMASK_RX_TX_GET,
+				&priv->regs->if2_cmask);
+			pch_can_check_if_busy(&priv->regs->if2_creq, i+1);
+
+			/* Resetting DIR bit for reception */
+			iowrite32(0x0, &priv->regs->if2_id1);
+			iowrite32(0x0, &priv->regs->if2_id2);
+			pch_can_bit_set(&priv->regs->if2_id2, CAN_ID2_DIR);
+
+			/* Setting EOB bit for transmitter */
+			iowrite32(CAN_IF_MCONT_EOB, &priv->regs->if2_mcont);
+
+			pch_can_bit_set(&priv->regs->if2_mcont,
+					CAN_IF_MCONT_UMASK);
+
+			iowrite32(0, &priv->regs->if2_mask1);
+			pch_can_bit_clear(&priv->regs->if2_mask2, 0x1fff);
+
+			/* Setting CMASK for writing */
+			iowrite32(CAN_CMASK_RDWR | CAN_CMASK_MASK |
+				  CAN_CMASK_ARB | CAN_CMASK_CTRL,
+				  &priv->regs->if2_cmask);
Quoted 8 lines
Quoted 6 lines

drivers/net/can/pch_can.c static void __devexit pch_can_remove(struct pci_dev *pdev) · line 1160

Quoted 6 lines
drivers/net/can/pch_can.c +6 -0
+
+			pch_can_check_if_busy(&priv->regs->if2_creq, i+1);
+		}
+	}
+	spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
+}

This processing does configuration for all message objects.

Yeah, got it. However I think you can get rid of the priv->msg_obj variable altogether. Let me recapitulate:
- you setup priv->msg_obj[] in the probe function, which defines if a msg_obj is a rx or tx
- this definition is never changed
- all objects of one kind are in a row

So you can identify the purpose of a msg_obj by simply looking at it's number. If you need to loop over them you can even define helper functions like, for_each_rx_obj().

Quoted 4 lines
Quoted 2 lines

what does this loop do? why is it nessecarry? I don't like delay loops
in the hot path of a driver.

This loop is for waiting for all tx Message Object completion. This is Topcliff CAN HW specification.

Can you give us a pointer into intel's documentation?
I think Wolfgang already suggested to check if the chip is busy _before_ accessing it instead of waiting the chip to finish after accessing.

Quoted 3 lines
Quoted 2 lines

If you figured out how to use the endianess conversion functions from the cpu_to_{le,be}-{le,to}_to_cpup family use them here, too.

Uh,le32_to_cpu have been used already here.

Let's look at the code:

Quoted 7 lines
Quoted 7 lines
(quoted diff) +1 -0
+		for (i = 0, j = 0; i < cf->can_dlc; j++) {

Review

Quoted 6 lines
(quoted diff) +6 -0
+			reg = ioread32(&priv->regs->if1_dataa1 + j*4);
+			cf->data[i++] = cpu_to_le32(reg & 0xff);
+			if (i == cf->can_dlc)
+				break;
+			cf->data[i++] = cpu_to_le32((reg >> 8) & 0xff);
+		}

What does the code do? It swaps bytes because the data bytes in the can core is arranged differently compared to the data in the struct can_frame.

According to the datasheet if_dataa1 holds 1st byte in bits 07:00 and 2nd byte in 15:08. (The rest is reserved.) So in the memory it looks like this:

xx xx byte1 byte0

The can_frame has a different layout:

	__u8    data[8] __attribute__((aligned(8)));

which is in memory:

byte0 byte1 byte2 byte3 byte4 byte5 byte6 byte7

This is why you swap. However in Linux no need to do this by hand.

The if_dataXX have a little endian layout, while the can frame has a big endian layout. Further if_dataXX has only 16 bit of can data.

I think it should look like this:

	for (i = 0; i < cf->can_dlc; i += 2) {
		reg = ioread32(&priv->regs->if1_data[i >> 1]);
		*(__be16 *)cf->data[i] = cpu_to_be16(reg);
	}

You have to change the definition of the regs struct a bit:

Quoted 3 lines
	u32 if1_mcont;
	u32 if1_data[4];
	u32 reserve2;

Totally untested, though.
BTW: Where can I get this Intel Hardware to improve and test the driver?

Quoted 2 lines

I can't understand your intention.
Please show in detail.

Above we have the RX-Path, the TX-path would probably use a "be16_to_cpup", have a look at the flexcan driver. It uses the whole 32 bit for candata, though.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

All these check if busy in the code make me a bit nervous, can you please explain why they are needed. A pointer to the manual is okay, too.

Me too. I already ask in my previous mail how long that functions usually blocks.

When accessing read/write from/to Message RAM,
Since it takes much time for transferring between Register and Message RAM, SW must check busy flag of CAN register.
This is a Topcliff HW specification.

see above.

Quoted 3 lines
Quoted 1 line

is there some pdev->name instead of KBUILD_MODNAME that can be used?

I can't understand your intention.
pdev(struct pci_dev) doesn't have "name" member.

I was just asking :) As it doesn't have a name, KBUILD_MODNAME is fine.

regards,
Marc

Signature · 4 lines
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |

_______________________________________________
Socketcan-core mailing list [email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-core

#9 lore raw
In reply to Wolfgang Grandegger

Hi Wolfgang and Marc,

Quoted 3 lines · Wolfgang Grandegger

for the inconvenience, but the original author should have received it. Tomoya, could you (or somebody else) please also fix the remaining issues quickly?

"masa-korg-ECg8zkTtlr0C6LszWs/[email protected]" left this project. and this mail-address will be deleted soon. I (tomoya-linux-ECg8zkTtlr0C6LszWs/[email protected]) have taken over "pch can drive" from him.

I will modify your comments ASAP.

---
Hi David,

Quoted 9 lines · David Miller

There are still problems.

This is beyond frustrating.

Quoted 1 line

index 55ec324..2889e11 100755

Why does the pch_can.c file have execute permission in your tree? It doesn't in net-next-2.6 and that is what you should be generating patches against.

Sorry for the inconvenience.
After updating maintainer's comments and yours, I will post again.

---
Thanks, Tomoya(OKI SEMICONDUCTOR CO., LTD.)

#10 lore raw

can: About Socket CAN with MSI issue

In reply to David Miller

We have faced issue when our CAN diriver whose MSI is enabled, after installing the driver, once remove the driver and install the driver again,
As a result, interupt handler of the driver is not called again.

Do you have any information or suggestion about the above issue?

As to the our latest CAN driver,
please refer to followoing patch posted by me.
[PATCH net-next-2.6 v2] can: Topcliff: PCH_CAN driver: Fix build warnings

Thanks, Tomoya(OKI SEMICONDUCTOR CO., LTD.)

#11 lore raw

Re: can: About Socket CAN with MSI issue

Quoted 5 lines · Tomoya MORINAGA

We have faced issue when our CAN diriver whose MSI is enabled, after installing the driver, once remove the driver and install the driver again,
As a result, interupt handler of the driver is not called again.

Do you have any information or suggestion about the above issue?

Not really, the remove functions looks ok, apart from the fact, that pch_can_reset() is called *after* pci_iounmap().

Wolfgang.

#12 lore raw

Re: can: About Socket CAN with MSI issue

In reply to Tomoya MORINAGA
Quoted 5 lines · Tomoya MORINAGA

We have faced issue when our CAN diriver whose MSI is enabled, after installing the driver, once remove the driver and install the driver again,
As a result, interupt handler of the driver is not called again.

Do you have any information or suggestion about the above issue?

Its a bug in the PCI layer most likely,

http://amailbox.org/mailarchive/linux-kernel/2010/10/7/4629072

Dave.

#13 lore raw

Re: can: About Socket CAN with MSI issue

Quoted 1 line · Dave Airlie

Its a bug in the PCI layer most likely,

Thank you for your information.

This issue occurrs with Socket-CAN driver only.
Previous version our CAN driver(Not Socket-CAN but Tolapai ) works well. Thus, IMHO, PCI layer doesn't related to the issue.

Thanks, Tomoya(OKI SEMICONDUCTOR CO., LTD.)