[PATCH net-next] ravb: Remove manual pause frame transmit

2016-06-01 Thread Yoshihiro Kaneko
From: Masaru Nagai <masaru.nagai...@renesas.com>

Writing a non-zero value to the manual PAUSE frame register (MPR) starts
the transmission of a PAUSE frame.
A PAUSE frame is sent in ravb_emac_init(), but it is not expected behavior.

Signed-off-by: Masaru Nagai <masaru.nagai...@renesas.com>
Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
---

This patch is based on the master branch of David Miller's next networking
tree.

 drivers/net/ethernet/renesas/ravb_main.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c 
b/drivers/net/ethernet/renesas/ravb_main.c
index 867caf6..37dd068 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -362,8 +362,6 @@ static void ravb_emac_init(struct net_device *ndev)
ravb_write(ndev,
   (ndev->dev_addr[4] << 8)  | (ndev->dev_addr[5]), MALR);
 
-   ravb_write(ndev, 1, MPR);
-
/* E-MAC status register clear */
ravb_write(ndev, ECSR_ICD | ECSR_MPD, ECSR);
 
-- 
1.9.1



[PATCH net-next v2] ravb: Add ESF in RCR for enabling separation filter

2016-05-31 Thread Yoshihiro Kaneko
From: Masaru Nagai <masaru.nagai...@renesas.com>

The H/W manual recommends B'10 or B'11 in a value of the separation
filtering select bits in the receive configuration register (RCR.ESF).
When B'10 is set, frames from non-matching streams are discarded.
When B'11 is set, frames from non-matching streams are processed in
reception queue 0 (best effort).
This patch sets B'11 in ESF.

[ykaneko0...@gmail.com: revised this commit message]
Signed-off-by: Masaru Nagai <masaru.nagai...@renesas.com>
Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
Acked-by: Sergei Shtylyov <sergei.shtyl...@cogentembedded.com>
---

This patch is based on the master branch of David Miller's next networking
tree.

v2 [Yoshihiro Kaneko]
  - Revised the commit message
  - Added Acked-by

 drivers/net/ethernet/renesas/ravb_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c 
b/drivers/net/ethernet/renesas/ravb_main.c
index 867caf6..1ceadbf 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -402,7 +402,8 @@ static int ravb_dmac_init(struct net_device *ndev)
 #endif
 
/* Set AVB RX */
-   ravb_write(ndev, RCR_EFFS | RCR_ENCF | RCR_ETS0 | 0x1800, RCR);
+   ravb_write(ndev,
+  RCR_EFFS | RCR_ENCF | RCR_ETS0 | RCR_ESF | 0x1800, RCR);
 
/* Set FIFO size */
ravb_write(ndev, TGC_TQP_AVBMODE1 | 0x0000, TGC);
-- 
1.9.1



Re: [PATCH net-next] ravb: Add ESF in RCR for enabling separation filter

2016-05-31 Thread Yoshihiro Kaneko
Hi Sergei,

2016-05-31 6:19 GMT+09:00 Sergei Shtylyov <sergei.shtyl...@cogentembedded.com>:
> On 05/30/2016 05:30 PM, Sergei Shtylyov wrote:
>
>>> From: Masaru Nagai <masaru.nagai...@renesas.com>
>>>
>>> This patch adds enabling separation filter(ESF) is setting value of B'11.
>>> This setting filter for separating AVB stream frames from non-AVB stream
>>> frames is enabled. Non-matching frames from a stream are processed in
>>> queue 0(best effort). H/W manual recommends B'11 or B'10.
>>> When B'10 is setting, Non-mating frames are discarded.
>>
>>
>>It was somewhat hard for me to parse that...
>
>
>Forgot about s/Non-mating/Non-matching/.

Thanks for your review.
I will revise the commit message.

Thanks,
kaneko

>
>
>>> Signed-off-by: Masaru Nagai <masaru.nagai...@renesas.com>
>>> Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>>> Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
>>
>>
>> Acked-by: Sergei Shtylyov <sergei.shtyl...@cogentembedded.com>
>
>
> MBR, Sergei
>


[PATCH net-next] ravb: Add SET_RUNTIME_PM_OPS macro

2016-05-29 Thread Yoshihiro Kaneko
From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>

Use SET_RUNTIME_PM_OPS macro instead of assigning a member of
dev_pm_ops directly.

Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
---

This patch is based on the master branch of David Miller's next networking
tree.

 drivers/net/ethernet/renesas/ravb_main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c 
b/drivers/net/ethernet/renesas/ravb_main.c
index 867caf6..da8da86 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -2111,8 +2111,7 @@ static int ravb_runtime_nop(struct device *dev)
 }
 
 static const struct dev_pm_ops ravb_dev_pm_ops = {
-   .runtime_suspend = ravb_runtime_nop,
-   .runtime_resume = ravb_runtime_nop,
+   SET_RUNTIME_PM_OPS(ravb_runtime_nop, ravb_runtime_nop, NULL)
 };
 
 #define RAVB_PM_OPS (_dev_pm_ops)
-- 
1.9.1



[PATCH net-next] ravb: Add ESF in RCR for enabling separation filter

2016-05-29 Thread Yoshihiro Kaneko
From: Masaru Nagai <masaru.nagai...@renesas.com>

This patch adds enabling separation filter(ESF) is setting value of B'11.
This setting filter for separating AVB stream frames from non-AVB stream
frames is enabled. Non-matching frames from a stream are processed in
queue 0(best effort). H/W manual recommends B'11 or B'10.
When B'10 is setting, Non-mating frames are discarded.

Signed-off-by: Masaru Nagai <masaru.nagai...@renesas.com>
Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
---

This patch is based on the master branch of David Miller's next networking
tree.

 drivers/net/ethernet/renesas/ravb_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c 
b/drivers/net/ethernet/renesas/ravb_main.c
index 867caf6..1ceadbf 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -402,7 +402,8 @@ static int ravb_dmac_init(struct net_device *ndev)
 #endif
 
/* Set AVB RX */
-   ravb_write(ndev, RCR_EFFS | RCR_ENCF | RCR_ETS0 | 0x1800, RCR);
+   ravb_write(ndev,
+  RCR_EFFS | RCR_ENCF | RCR_ETS0 | RCR_ESF | 0x1800, RCR);
 
/* Set FIFO size */
ravb_write(ndev, TGC_TQP_AVBMODE1 | 0x0000, TGC);
-- 
1.9.1



[PATCH net-next v2] ravb: Remove rx buffer ALIGN

2016-05-01 Thread Yoshihiro Kaneko
From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>

Aligning the reception data size is not required.

Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
Tested-by: Simon Horman <horms+rene...@verge.net.au>
---

This patch is based on the master branch of David Miller's next networking
tree.

v2 [Yoshihiro Kaneko]
* As suggested by Sergei Shtylyov
  remove re-formattings which is not related to the subject of this patch.

 drivers/net/ethernet/renesas/ravb_main.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c 
b/drivers/net/ethernet/renesas/ravb_main.c
index 238b56f..34066e0 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -246,10 +246,9 @@ static void ravb_ring_format(struct net_device *ndev, int 
q)
for (i = 0; i < priv->num_rx_ring[q]; i++) {
/* RX descriptor */
rx_desc = >rx_ring[q][i];
-   /* The size of the buffer should be on 16-byte boundary. */
-   rx_desc->ds_cc = cpu_to_le16(ALIGN(PKT_BUF_SZ, 16));
+   rx_desc->ds_cc = cpu_to_le16(PKT_BUF_SZ);
dma_addr = dma_map_single(ndev->dev.parent, 
priv->rx_skb[q][i]->data,
- ALIGN(PKT_BUF_SZ, 16),
+ PKT_BUF_SZ,
  DMA_FROM_DEVICE);
/* We just set the data size to 0 for a failed mapping which
 * should prevent DMA from happening...
@@ -558,7 +557,7 @@ static bool ravb_rx(struct net_device *ndev, int *quota, 
int q)
skb = priv->rx_skb[q][entry];
priv->rx_skb[q][entry] = NULL;
dma_unmap_single(ndev->dev.parent, 
le32_to_cpu(desc->dptr),
-ALIGN(PKT_BUF_SZ, 16),
+PKT_BUF_SZ,
 DMA_FROM_DEVICE);
get_ts &= (q == RAVB_NC) ?
RAVB_RXTSTAMP_TYPE_V2_L2_EVENT :
@@ -588,8 +587,7 @@ static bool ravb_rx(struct net_device *ndev, int *quota, 
int q)
for (; priv->cur_rx[q] - priv->dirty_rx[q] > 0; priv->dirty_rx[q]++) {
entry = priv->dirty_rx[q] % priv->num_rx_ring[q];
desc = >rx_ring[q][entry];
-   /* The size of the buffer should be on 16-byte boundary. */
-   desc->ds_cc = cpu_to_le16(ALIGN(PKT_BUF_SZ, 16));
+   desc->ds_cc = cpu_to_le16(PKT_BUF_SZ);
 
if (!priv->rx_skb[q][entry]) {
skb = netdev_alloc_skb(ndev,
-- 
1.9.1



Re: [PATCH net-next] ravb: Remove rx buffer ALIGN

2016-05-01 Thread Yoshihiro Kaneko
Hi Simon-san,

Thank you for testing this patch!

Thanks,
kaneko

2016-04-29 8:34 GMT+09:00 Simon Horman <ho...@verge.net.au>:
> Hi Sergei, Hi Kaneko-san,
>
> On Tue, Apr 26, 2016 at 10:14:41PM +0300, Sergei Shtylyov wrote:
>> Hello.
>>
>> On 04/24/2016 07:16 PM, Yoshihiro Kaneko wrote:
>>
>> >From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>> >
>> >Aligning the reception data size is not required.
>>
>>OK, the gen 2/3 manuals indeed don't require this. I assume the patch has
>> been tested...
>
> This morning I tested this patch applied on net-next using the
> r8a7795/salvator-x  (Gen-3). My test was to boot to a user-space prompt
> using NFS root which was successful. I can run further tests on this setup
> if it would be useful.
>
> Unfortunately I do not have access to hardware to allow me to test this
> on Gen-2.
>
>> >Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>> >Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
>
> Tested-by: Simon Horman <horms+rene...@verge.net.au>
>
>>I have a few comments though...
>
> [...]


Re: [PATCH net-next] ravb: Remove rx buffer ALIGN

2016-05-01 Thread Yoshihiro Kaneko
Hi Sergei,

Sorry for the late reply.

2016-04-27 4:14 GMT+09:00 Sergei Shtylyov <sergei.shtyl...@cogentembedded.com>:
> Hello.
>
> On 04/24/2016 07:16 PM, Yoshihiro Kaneko wrote:
>
>> From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>>
>> Aligning the reception data size is not required.
>
>
>OK, the gen 2/3 manuals indeed don't require this. I assume the patch has
> been tested...
>
>> Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>> Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
>
>
>I have a few comments though...
>
>> diff --git a/drivers/net/ethernet/renesas/ravb_main.c
>> b/drivers/net/ethernet/renesas/ravb_main.c
>> index 238b56f..66ed80c 100644
>> --- a/drivers/net/ethernet/renesas/ravb_main.c
>> +++ b/drivers/net/ethernet/renesas/ravb_main.c
>> @@ -246,10 +246,10 @@ static void ravb_ring_format(struct net_device
>> *ndev, int q)
>> for (i = 0; i < priv->num_rx_ring[q]; i++) {
>> /* RX descriptor */
>> rx_desc = >rx_ring[q][i];
>> -   /* The size of the buffer should be on 16-byte boundary.
>> */
>> -   rx_desc->ds_cc = cpu_to_le16(ALIGN(PKT_BUF_SZ, 16));
>> -   dma_addr = dma_map_single(ndev->dev.parent,
>> priv->rx_skb[q][i]->data,
>> - ALIGN(PKT_BUF_SZ, 16),
>> +   rx_desc->ds_cc = cpu_to_le16(PKT_BUF_SZ);
>> +   dma_addr = dma_map_single(ndev->dev.parent,
>> + priv->rx_skb[q][i]->data,
>
>
>Please don't reformat the lines above.

Got it.

>
>> + PKT_BUF_SZ,
>>   DMA_FROM_DEVICE);
>> /* We just set the data size to 0 for a failed mapping
>> which
>>  * should prevent DMA from happening...
>> @@ -557,8 +557,9 @@ static bool ravb_rx(struct net_device *ndev, int
>> *quota, int q)
>>
>> skb = priv->rx_skb[q][entry];
>> priv->rx_skb[q][entry] = NULL;
>> -   dma_unmap_single(ndev->dev.parent,
>> le32_to_cpu(desc->dptr),
>> -ALIGN(PKT_BUF_SZ, 16),
>> +   dma_unmap_single(ndev->dev.parent,
>> +le32_to_cpu(desc->dptr),
>
>
>   Same here.

Likewise.

>
> [...]
>
> MBR, Sergei
>

Thanks,
kaneko


[PATCH net-next] ravb: Remove rx buffer ALIGN

2016-04-24 Thread Yoshihiro Kaneko
From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>

Aligning the reception data size is not required.

Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
---

This patch is based on the master branch of David Miller's next networking
tree.

 drivers/net/ethernet/renesas/ravb_main.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c 
b/drivers/net/ethernet/renesas/ravb_main.c
index 238b56f..66ed80c 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -246,10 +246,10 @@ static void ravb_ring_format(struct net_device *ndev, int 
q)
for (i = 0; i < priv->num_rx_ring[q]; i++) {
/* RX descriptor */
rx_desc = >rx_ring[q][i];
-   /* The size of the buffer should be on 16-byte boundary. */
-   rx_desc->ds_cc = cpu_to_le16(ALIGN(PKT_BUF_SZ, 16));
-   dma_addr = dma_map_single(ndev->dev.parent, 
priv->rx_skb[q][i]->data,
- ALIGN(PKT_BUF_SZ, 16),
+   rx_desc->ds_cc = cpu_to_le16(PKT_BUF_SZ);
+   dma_addr = dma_map_single(ndev->dev.parent,
+ priv->rx_skb[q][i]->data,
+ PKT_BUF_SZ,
  DMA_FROM_DEVICE);
/* We just set the data size to 0 for a failed mapping which
 * should prevent DMA from happening...
@@ -557,8 +557,9 @@ static bool ravb_rx(struct net_device *ndev, int *quota, 
int q)
 
skb = priv->rx_skb[q][entry];
priv->rx_skb[q][entry] = NULL;
-   dma_unmap_single(ndev->dev.parent, 
le32_to_cpu(desc->dptr),
-ALIGN(PKT_BUF_SZ, 16),
+   dma_unmap_single(ndev->dev.parent,
+le32_to_cpu(desc->dptr),
+PKT_BUF_SZ,
 DMA_FROM_DEVICE);
get_ts &= (q == RAVB_NC) ?
RAVB_RXTSTAMP_TYPE_V2_L2_EVENT :
@@ -588,8 +589,7 @@ static bool ravb_rx(struct net_device *ndev, int *quota, 
int q)
for (; priv->cur_rx[q] - priv->dirty_rx[q] > 0; priv->dirty_rx[q]++) {
entry = priv->dirty_rx[q] % priv->num_rx_ring[q];
desc = >rx_ring[q][entry];
-   /* The size of the buffer should be on 16-byte boundary. */
-   desc->ds_cc = cpu_to_le16(ALIGN(PKT_BUF_SZ, 16));
+   desc->ds_cc = cpu_to_le16(PKT_BUF_SZ);
 
if (!priv->rx_skb[q][entry]) {
skb = netdev_alloc_skb(ndev,
-- 
1.9.1



[PATCH v9 net-next] ravb: Add dma queue interrupt support

2016-04-03 Thread Yoshihiro Kaneko
From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>

This patch supports the following interrupts.

- One interrupt for multiple (timestamp, error, gPTP)
- One interrupt for emac
- Four interrupts for dma queue (best effort rx/tx, network control rx/tx)

This patch improve efficiency of the interrupt handler by adding the
interrupt handler corresponding to each interrupt source described
above. Additionally, it reduces the number of times of the access to
EthernetAVB IF.
Also this patch prevent this driver depends on the whim of a boot loader.

[ykaneko0...@gmail.com: define bit names of registers]
[ykaneko0...@gmail.com: add comment for gen3 only registers]
[ykaneko0...@gmail.com: fix coding style]
[ykaneko0...@gmail.com: update changelog]
[ykaneko0...@gmail.com: gen3: fix initialization of interrupts]
[ykaneko0...@gmail.com: gen3: fix clearing interrupts]
[ykaneko0...@gmail.com: gen3: add helper function for request_irq()]
[ykaneko0...@gmail.com: gen3: remove IRQF_SHARED flag for request_irq()]
[ykaneko0...@gmail.com: revert ravb_close() and ravb_ptp_stop()]
[ykaneko0...@gmail.com: avoid calling free_irq() to non-hooked interrupts]
[ykaneko0...@gmail.com: make NC/BE interrupt handler a function]
[ykaneko0...@gmail.com: make timestamp interrupt handler a function]
[ykaneko0...@gmail.com: timestamp interrupt is handled in multiple
 interrupt handler instead of dma queue interrupt handler]
Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
Acked-by: Sergei Shtylyov <sergei.shtyl...@cogentembedded.com>
---

This patch is based on the master branch of David Miller's next networking
tree.

v9 [Yoshihiro Kaneko]
 - Added Acked-by Sergei Shtylyov

v8 [Yoshihiro Kaneko]
  - rebased

v7 [Yoshihiro Kaneko]
  drivers/net/ethernet/renesas/ravb_main.c:
  - read TIS in ravb_timestamp_interrupt()
  - avoid overwriting the 'result' by a return value of ravb_ptp_interrupt()
* As suggested by Sergei Shtylyov
  drivers/net/ethernet/renesas/ravb_main.c:
  - read RIS, RIC, TIS and TIC in ravb_queue_interrupt()
  - rename ravb_rx_tx_interrupt to ravb_dma_interrupt
  - shorten argument ravb_queue of ravb_dma_interrupt()

v6 [Yoshihiro Kaneko]
* As suggested by Sergei Shtylyov
  drivers/net/ethernet/renesas/ravb_main.c:
- rename ravb_nc_be_interrupt to ravb_queue_interrupt, change the type
   of return value to 'bool', rename ravb_queue to 'q'
- stop use of 'for' loop for queue interrupt in ravb_interrupt()
- fix comment for ravb_multi_interrupt()
- rename ravb_dmaq_interrupt to ravb_rx_tx_interrupt
- move timestamp interrupt handler into ravb_multi_interrupt()
- make timestamp interrupt handler a funtion
- rename out_free_irq2 label to out_free_irq_nc_tx
- remove IRQF_SHARED flag for request_irq()
  drivers/net/ethernet/renesas/ravb_ptp.c:
- fix coding style

v5 [Yoshihiro Kaneko]
* As suggested by Sergei Shtylyov
  drivers/net/ethernet/renesas/ravb_main.c:
- stop copying ravb_queue parameter in ravb_dmaq_interrupt()
- clear TFUF instead of disabling
- factored out NC/BE interrupt handler
- rename hook_irq() in ravb_hook_irq()
- add calling free_irq() for the EMAC IRQ
- stop using a loop for free_irq() to avoid calling free_irq() for
  non-hooked interrupt handlers
- add test for failure of devm_kasprintf in ravb_hook_irq()
- update changelog

v4 [Yoshihiro Kaneko]
* compile tested only
* As suggested by Sergei Shtylyov
  drivers/net/ethernet/renesas/ravb.h:
- make two lines of comment into one line.
- remove unused definition of xxx_ALL.
  drivers/net/ethernet/renesas/ravb_main.c:
- remove unrelated change (fix indentation).
- output warning messages when napi_schedule_prep() fails in ravb_dmaq_
  interrupt() like ravb_interrupt().
- change the function name from req_irq to hook_irq.
- fix programming error in hook_irq().
- do free_irq() for rx_irqs[] and tx_irqs[] for only gen3 in out_free_
  irq label in ravb_open().

v3 [Yoshihiro Kaneko]
* compile tested only
* As suggested by Sergei Shtylyov
  - update changelog
  drivers/net/ethernet/renesas/ravb.h:
- add comments to the additional registers like CIE
  drivers/net/ethernet/renesas/ravb_main.c:
- fix the initialization of the interrupt in ravb_dmac_init()
- revert ravb_error_interrupt() because gen3 code is wrong
- change the comment "Management" in ravb_multi_interrupt()
- add a helper function for request_irq() in ravb_open()
- revert ravb_close() because atomicity is not necessary here
  drivers/net/ethernet/renesas/ravb_ptp.c:
- revert ravb_ptp_stop() because atomicity is not necessary here

v2 [Yoshihiro Kaneko]
* compile tested only
* As suggested by Sergei Shtylyov
  - add comment to CIE
  - remove comments from CIE bits
  - fix value of TIx_ALL
  - define each bits for CIE, GIE, GID, RIE0, RID0, RIE2, RID2, TI

Re: [PATCH v8 net-next] ravb: Add dma queue interrupt support

2016-03-28 Thread Yoshihiro Kaneko
Hello.

2016-03-27 22:02 GMT+09:00 Sergei Shtylyov <sergei.shtyl...@cogentembedded.com>:
> Hello.
>
>
> On 03/22/2016 06:22 PM, Yoshihiro Kaneko wrote:
>
>> From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>>
>> This patch supports the following interrupts.
>>
>> - One interrupt for multiple (timestamp, error, gPTP)
>> - One interrupt for emac
>> - Four interrupts for dma queue (best effort rx/tx, network control rx/tx)
>>
>> This patch improve efficiency of the interrupt handler by adding the
>> interrupt handler corresponding to each interrupt source described
>> above. Additionally, it reduces the number of times of the access to
>> EthernetAVB IF.
>> Also this patch prevent this driver depends on the whim of a boot loader.
>>
>> [ykaneko0...@gmail.com: define bit names of registers]
>> [ykaneko0...@gmail.com: add comment for gen3 only registers]
>> [ykaneko0...@gmail.com: fix coding style]
>> [ykaneko0...@gmail.com: update changelog]
>> [ykaneko0...@gmail.com: gen3: fix initialization of interrupts]
>> [ykaneko0...@gmail.com: gen3: fix clearing interrupts]
>> [ykaneko0...@gmail.com: gen3: add helper function for request_irq()]
>> [ykaneko0...@gmail.com: gen3: remove IRQF_SHARED flag for request_irq()]
>> [ykaneko0...@gmail.com: revert ravb_close() and ravb_ptp_stop()]
>> [ykaneko0...@gmail.com: avoid calling free_irq() to non-hooked interrupts]
>> [ykaneko0...@gmail.com: make NC/BE interrupt handler a function]
>> [ykaneko0...@gmail.com: make timestamp interrupt handler a function]
>> [ykaneko0...@gmail.com: timestamp interrupt is handled in multiple
>>   interrupt handler instead of dma queue interrupt handler]
>> Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>> Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
>
> [...]
>
> Acked-by: Sergei Shtylyov <sergei.shtyl...@cogentembedded.com>

Many thanks for your review and much help!

>
> MBR, Sergei
>

Thanks,
kaneko


Re: [PATCH v8 net-next] ravb: Add dma queue interrupt support

2016-03-23 Thread Yoshihiro Kaneko
2016-03-23 4:55 GMT+09:00 David Miller <da...@redhat.com>:
> From: Yoshihiro Kaneko <ykaneko0...@gmail.com>
> Date: Wed, 23 Mar 2016 00:22:00 +0900
>
>> From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>>
>> This patch supports the following interrupts.
>>
>> - One interrupt for multiple (timestamp, error, gPTP)
>> - One interrupt for emac
>> - Four interrupts for dma queue (best effort rx/tx, network control rx/tx)
>>
>> This patch improve efficiency of the interrupt handler by adding the
>> interrupt handler corresponding to each interrupt source described
>> above. Additionally, it reduces the number of times of the access to
>> EthernetAVB IF.
>> Also this patch prevent this driver depends on the whim of a boot loader.
>>
>> [ykaneko0...@gmail.com: define bit names of registers]
>> [ykaneko0...@gmail.com: add comment for gen3 only registers]
>> [ykaneko0...@gmail.com: fix coding style]
>> [ykaneko0...@gmail.com: update changelog]
>> [ykaneko0...@gmail.com: gen3: fix initialization of interrupts]
>> [ykaneko0...@gmail.com: gen3: fix clearing interrupts]
>> [ykaneko0...@gmail.com: gen3: add helper function for request_irq()]
>> [ykaneko0...@gmail.com: gen3: remove IRQF_SHARED flag for request_irq()]
>> [ykaneko0...@gmail.com: revert ravb_close() and ravb_ptp_stop()]
>> [ykaneko0...@gmail.com: avoid calling free_irq() to non-hooked interrupts]
>> [ykaneko0...@gmail.com: make NC/BE interrupt handler a function]
>> [ykaneko0...@gmail.com: make timestamp interrupt handler a function]
>> [ykaneko0...@gmail.com: timestamp interrupt is handled in multiple
>>  interrupt handler instead of dma queue interrupt handler]
>> Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>> Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
>
> Sorry, it is not appropriate to submit new features and major optimizations
> at this time.
>
> Please wait until some reasonable time after the merge window closes to
> resubmit this.

I'm sorry to bother you.
I will re-post this patch after net-next reopened.

>
> Thanks.

Best regards,
kaneko


[PATCH v8 net-next] ravb: Add dma queue interrupt support

2016-03-22 Thread Yoshihiro Kaneko
From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>

This patch supports the following interrupts.

- One interrupt for multiple (timestamp, error, gPTP)
- One interrupt for emac
- Four interrupts for dma queue (best effort rx/tx, network control rx/tx)

This patch improve efficiency of the interrupt handler by adding the
interrupt handler corresponding to each interrupt source described
above. Additionally, it reduces the number of times of the access to
EthernetAVB IF.
Also this patch prevent this driver depends on the whim of a boot loader.

[ykaneko0...@gmail.com: define bit names of registers]
[ykaneko0...@gmail.com: add comment for gen3 only registers]
[ykaneko0...@gmail.com: fix coding style]
[ykaneko0...@gmail.com: update changelog]
[ykaneko0...@gmail.com: gen3: fix initialization of interrupts]
[ykaneko0...@gmail.com: gen3: fix clearing interrupts]
[ykaneko0...@gmail.com: gen3: add helper function for request_irq()]
[ykaneko0...@gmail.com: gen3: remove IRQF_SHARED flag for request_irq()]
[ykaneko0...@gmail.com: revert ravb_close() and ravb_ptp_stop()]
[ykaneko0...@gmail.com: avoid calling free_irq() to non-hooked interrupts]
[ykaneko0...@gmail.com: make NC/BE interrupt handler a function]
[ykaneko0...@gmail.com: make timestamp interrupt handler a function]
[ykaneko0...@gmail.com: timestamp interrupt is handled in multiple
 interrupt handler instead of dma queue interrupt handler]
Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
---

This patch is based on the master branch of David Miller's next networking
tree.

v8 [Yoshihiro Kaneko]
  - rebased

v7 [Yoshihiro Kaneko]
  drivers/net/ethernet/renesas/ravb_main.c:
  - read TIS in ravb_timestamp_interrupt()
  - avoid overwriting the 'result' by a return value of ravb_ptp_interrupt()
* As suggested by Sergei Shtylyov
  drivers/net/ethernet/renesas/ravb_main.c:
  - read RIS, RIC, TIS and TIC in ravb_queue_interrupt()
  - rename ravb_rx_tx_interrupt to ravb_dma_interrupt
  - shorten argument ravb_queue of ravb_dma_interrupt()

v6 [Yoshihiro Kaneko]
* As suggested by Sergei Shtylyov
  drivers/net/ethernet/renesas/ravb_main.c:
- rename ravb_nc_be_interrupt to ravb_queue_interrupt, change the type
   of return value to 'bool', rename ravb_queue to 'q'
- stop use of 'for' loop for queue interrupt in ravb_interrupt()
- fix comment for ravb_multi_interrupt()
- rename ravb_dmaq_interrupt to ravb_rx_tx_interrupt
- move timestamp interrupt handler into ravb_multi_interrupt()
- make timestamp interrupt handler a funtion
- rename out_free_irq2 label to out_free_irq_nc_tx
- remove IRQF_SHARED flag for request_irq()
  drivers/net/ethernet/renesas/ravb_ptp.c:
- fix coding style

v5 [Yoshihiro Kaneko]
* As suggested by Sergei Shtylyov
  drivers/net/ethernet/renesas/ravb_main.c:
- stop copying ravb_queue parameter in ravb_dmaq_interrupt()
- clear TFUF instead of disabling
- factored out NC/BE interrupt handler
- rename hook_irq() in ravb_hook_irq()
- add calling free_irq() for the EMAC IRQ
- stop using a loop for free_irq() to avoid calling free_irq() for
  non-hooked interrupt handlers
- add test for failure of devm_kasprintf in ravb_hook_irq()
- update changelog

v4 [Yoshihiro Kaneko]
* compile tested only
* As suggested by Sergei Shtylyov
  drivers/net/ethernet/renesas/ravb.h:
- make two lines of comment into one line.
- remove unused definition of xxx_ALL.
  drivers/net/ethernet/renesas/ravb_main.c:
- remove unrelated change (fix indentation).
- output warning messages when napi_schedule_prep() fails in ravb_dmaq_
  interrupt() like ravb_interrupt().
- change the function name from req_irq to hook_irq.
- fix programming error in hook_irq().
- do free_irq() for rx_irqs[] and tx_irqs[] for only gen3 in out_free_
  irq label in ravb_open().

v3 [Yoshihiro Kaneko]
* compile tested only
* As suggested by Sergei Shtylyov
  - update changelog
  drivers/net/ethernet/renesas/ravb.h:
- add comments to the additional registers like CIE
  drivers/net/ethernet/renesas/ravb_main.c:
- fix the initialization of the interrupt in ravb_dmac_init()
- revert ravb_error_interrupt() because gen3 code is wrong
- change the comment "Management" in ravb_multi_interrupt()
- add a helper function for request_irq() in ravb_open()
- revert ravb_close() because atomicity is not necessary here
  drivers/net/ethernet/renesas/ravb_ptp.c:
- revert ravb_ptp_stop() because atomicity is not necessary here

v2 [Yoshihiro Kaneko]
* compile tested only
* As suggested by Sergei Shtylyov
  - add comment to CIE
  - remove comments from CIE bits
  - fix value of TIx_ALL
  - define each bits for CIE, GIE, GID, RIE0, RID0, RIE2, RID2, TIE, TID
  - reversed Christmas tree declaration ordered
  - rename _ravb_emac_interrupt() to ravb_emac_interrupt_unlocked()
  - remove

[PATCH net] ravb: fix result value overwrite

2016-03-15 Thread Yoshihiro Kaneko
The result value is overwritten by a return value of
ravb_ptp_interrupt().

Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
---

This patch is based on the master branch of David Miller's networking tree.

 drivers/net/ethernet/renesas/ravb_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c 
b/drivers/net/ethernet/renesas/ravb_main.c
index 86449c3..d369af8 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -765,8 +765,8 @@ static irqreturn_t ravb_interrupt(int irq, void *dev_id)
result = IRQ_HANDLED;
}
 
-   if (iss & ISS_CGIS)
-   result = ravb_ptp_interrupt(ndev);
+   if ((iss & ISS_CGIS) && ravb_ptp_interrupt(ndev) == IRQ_HANDLED)
+   result = IRQ_HANDLED;
 
mmiowb();
spin_unlock(>lock);
-- 
1.9.1



Re: [PATCH v7 net-next] ravb: Add dma queue interrupt support

2016-03-15 Thread Yoshihiro Kaneko
Hi,

2016-03-15 5:48 GMT+09:00 Sergei Shtylyov <sergei.shtyl...@cogentembedded.com>:
> Hello.
>
>
> On 03/13/2016 09:11 PM, Yoshihiro Kaneko wrote:
>
>> From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>>
>> This patch supports the following interrupts.
>>
>> - One interrupt for multiple (timestamp, error, gPTP)
>> - One interrupt for emac
>> - Four interrupts for dma queue (best effort rx/tx, network control rx/tx)
>>
>> This patch improve efficiency of the interrupt handler by adding the
>> interrupt handler corresponding to each interrupt source described
>> above. Additionally, it reduces the number of times of the access to
>> EthernetAVB IF.
>> Also this patch prevent this driver depends on the whim of a boot loader.
>>
>> [ykaneko0...@gmail.com: define bit names of registers]
>> [ykaneko0...@gmail.com: add comment for gen3 only registers]
>> [ykaneko0...@gmail.com: fix coding style]
>> [ykaneko0...@gmail.com: update changelog]
>> [ykaneko0...@gmail.com: gen3: fix initialization of interrupts]
>> [ykaneko0...@gmail.com: gen3: fix clearing interrupts]
>> [ykaneko0...@gmail.com: gen3: add helper function for request_irq()]
>> [ykaneko0...@gmail.com: gen3: remove IRQF_SHARED flag for request_irq()]
>> [ykaneko0...@gmail.com: revert ravb_close() and ravb_ptp_stop()]
>> [ykaneko0...@gmail.com: avoid calling free_irq() to non-hooked interrupts]
>> [ykaneko0...@gmail.com: make NC/BE interrupt handler a function]
>> [ykaneko0...@gmail.com: make timestamp interrupt handler a function]
>> [ykaneko0...@gmail.com: timestamp interrupt is handled in multiple
>>   interrupt handler instead of dma queue interrupt handler]
>> Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>> Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
>
> [...]
>>
>> diff --git a/drivers/net/ethernet/renesas/ravb_main.c
>> b/drivers/net/ethernet/renesas/ravb_main.c
>> index 8f2c4fb..8fa8ffe 100644
>> --- a/drivers/net/ethernet/renesas/ravb_main.c
>> +++ b/drivers/net/ethernet/renesas/ravb_main.c
>
> [...]
>>
>> @@ -757,14 +806,73 @@ static irqreturn_t ravb_interrupt(int irq, void
>> *dev_id)
>> result = IRQ_HANDLED;
>> }
>>
>> -   if (iss & ISS_CGIS)
>> -   result = ravb_ptp_interrupt(ndev);
>> +   /* gPTP interrupt status summary */
>> +   if ((iss & ISS_CGIS) && ravb_ptp_interrupt(ndev) == IRQ_HANDLED)
>> +   result = IRQ_HANDLED;
>
>
>Wait, this seems like a bug in the existing driver! Please do fix it with
> a separate patch against net.git. Sorry about missing (or even adding) it
> while cleaning up the driver before submission...

Thanks, I will do so.

>
> [...]
>
>Looks fine otherwise, however the new features and the fixes shouldn't be
> mixed together, so I couldn't ACK yet. I'll go test it on gen2...

Thanks in advance.

>
> MBR, Sergei
>

Thanks,
kaneko


[PATCH v7 net-next] ravb: Add dma queue interrupt support

2016-03-13 Thread Yoshihiro Kaneko
From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>

This patch supports the following interrupts.

- One interrupt for multiple (timestamp, error, gPTP)
- One interrupt for emac
- Four interrupts for dma queue (best effort rx/tx, network control rx/tx)

This patch improve efficiency of the interrupt handler by adding the
interrupt handler corresponding to each interrupt source described
above. Additionally, it reduces the number of times of the access to
EthernetAVB IF.
Also this patch prevent this driver depends on the whim of a boot loader.

[ykaneko0...@gmail.com: define bit names of registers]
[ykaneko0...@gmail.com: add comment for gen3 only registers]
[ykaneko0...@gmail.com: fix coding style]
[ykaneko0...@gmail.com: update changelog]
[ykaneko0...@gmail.com: gen3: fix initialization of interrupts]
[ykaneko0...@gmail.com: gen3: fix clearing interrupts]
[ykaneko0...@gmail.com: gen3: add helper function for request_irq()]
[ykaneko0...@gmail.com: gen3: remove IRQF_SHARED flag for request_irq()]
[ykaneko0...@gmail.com: revert ravb_close() and ravb_ptp_stop()]
[ykaneko0...@gmail.com: avoid calling free_irq() to non-hooked interrupts]
[ykaneko0...@gmail.com: make NC/BE interrupt handler a function]
[ykaneko0...@gmail.com: make timestamp interrupt handler a function]
[ykaneko0...@gmail.com: timestamp interrupt is handled in multiple
 interrupt handler instead of dma queue interrupt handler]
Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
---

This patch is based on the master branch of David Miller's next networking
tree.

v7 [Yoshihiro Kaneko]
  drivers/net/ethernet/renesas/ravb_main.c:
  - read TIS in ravb_timestamp_interrupt()
  - avoid overwriting the 'result' by a return value of ravb_ptp_interrupt()
* As suggested by Sergei Shtylyov
  drivers/net/ethernet/renesas/ravb_main.c:
  - read RIS, RIC, TIS and TIC in ravb_queue_interrupt()
  - rename ravb_rx_tx_interrupt to ravb_dma_interrupt
  - shorten argument ravb_queue of ravb_dma_interrupt()

v6 [Yoshihiro Kaneko]
* As suggested by Sergei Shtylyov
  drivers/net/ethernet/renesas/ravb_main.c:
- rename ravb_nc_be_interrupt to ravb_queue_interrupt, change the type
   of return value to 'bool', rename ravb_queue to 'q'
- stop use of 'for' loop for queue interrupt in ravb_interrupt()
- fix comment for ravb_multi_interrupt()
- rename ravb_dmaq_interrupt to ravb_rx_tx_interrupt
- move timestamp interrupt handler into ravb_multi_interrupt()
- make timestamp interrupt handler a funtion
- rename out_free_irq2 label to out_free_irq_nc_tx
- remove IRQF_SHARED flag for request_irq()
  drivers/net/ethernet/renesas/ravb_ptp.c:
- fix coding style

v5 [Yoshihiro Kaneko]
* As suggested by Sergei Shtylyov
  drivers/net/ethernet/renesas/ravb_main.c:
- stop copying ravb_queue parameter in ravb_dmaq_interrupt()
- clear TFUF instead of disabling
- factored out NC/BE interrupt handler
- rename hook_irq() in ravb_hook_irq()
- add calling free_irq() for the EMAC IRQ
- stop using a loop for free_irq() to avoid calling free_irq() for
  non-hooked interrupt handlers
- add test for failure of devm_kasprintf in ravb_hook_irq()
- update changelog

v4 [Yoshihiro Kaneko]
* compile tested only
* As suggested by Sergei Shtylyov
  drivers/net/ethernet/renesas/ravb.h:
- make two lines of comment into one line.
- remove unused definition of xxx_ALL.
  drivers/net/ethernet/renesas/ravb_main.c:
- remove unrelated change (fix indentation).
- output warning messages when napi_schedule_prep() fails in ravb_dmaq_
  interrupt() like ravb_interrupt().
- change the function name from req_irq to hook_irq.
- fix programming error in hook_irq().
- do free_irq() for rx_irqs[] and tx_irqs[] for only gen3 in out_free_
  irq label in ravb_open().

v3 [Yoshihiro Kaneko]
* compile tested only
* As suggested by Sergei Shtylyov
  - update changelog
  drivers/net/ethernet/renesas/ravb.h:
- add comments to the additional registers like CIE
  drivers/net/ethernet/renesas/ravb_main.c:
- fix the initialization of the interrupt in ravb_dmac_init()
- revert ravb_error_interrupt() because gen3 code is wrong
- change the comment "Management" in ravb_multi_interrupt()
- add a helper function for request_irq() in ravb_open()
- revert ravb_close() because atomicity is not necessary here
  drivers/net/ethernet/renesas/ravb_ptp.c:
- revert ravb_ptp_stop() because atomicity is not necessary here

v2 [Yoshihiro Kaneko]
* compile tested only
* As suggested by Sergei Shtylyov
  - add comment to CIE
  - remove comments from CIE bits
  - fix value of TIx_ALL
  - define each bits for CIE, GIE, GID, RIE0, RID0, RIE2, RID2, TIE, TID
  - reversed Christmas tree declaration ordered
  - rename _ravb_emac_interrupt() to ravb_emac_interrupt_unlocked()
  - remove unnecessary clearing of CIE
  - 

Re: [PATCH/RFC v6 net-next] ravb: Add dma queue interrupt support

2016-03-08 Thread Yoshihiro Kaneko
Hi Sergei-san,

2016-02-29 0:41 GMT+09:00 Yoshihiro Kaneko <ykaneko0...@gmail.com>:

[snip]

> +static bool ravb_timestamp_interrupt(struct net_device *ndev, u32 tis)
> +{

I'd like to read TIS here like ravb_queue_interrupt().


> +   if (tis & TIS_TFUF) {
> +   ravb_write(ndev, ~TIS_TFUF, TIS);
> +   ravb_get_tx_tstamp(ndev);
> +   return true;
> +   }
> +   return false;
> +}

[snip]

> +/* Timestamp/Error/gPTP interrupt handler */
> +static irqreturn_t ravb_multi_interrupt(int irq, void *dev_id)
> +{
> +   struct net_device *ndev = dev_id;
> +   struct ravb_private *priv = netdev_priv(ndev);
> +   irqreturn_t result = IRQ_NONE;
> +   u32 iss, tis;
> +
> +   spin_lock(>lock);
> +   /* Get interrupt status */
> +   iss = ravb_read(ndev, ISS);
> +
> +   /* Timestamp updated */
> +   if (iss & ISS_TFUS) {
> +   tis  = ravb_read(ndev, TIS);
> +   if (ravb_timestamp_interrupt(ndev, tis))
> +   result = IRQ_HANDLED;
> +   }
> +
> +   /* Error status summary */
> +   if (iss & ISS_ES) {
> +   ravb_error_interrupt(ndev);
> +   result = IRQ_HANDLED;
> +   }
> +
> +   /* gPTP interrupt status summary */
> +   if (iss & ISS_CGIS)
> +   result = ravb_ptp_interrupt(ndev);

This assignment overwrites the result above.
How about this?
if ((iss & ISS_CGIS) && ravb_ptp_interrupt(ndev) == IRQ_HANDLED)
result = IRQ_HANDLED;


> +
> +   mmiowb();
> +   spin_unlock(>lock);
> +   return result;
> +}
[snip]


Thanks,
kaneko


Re: [PATCH/RFC v6 net-next] ravb: Add dma queue interrupt support

2016-03-07 Thread Yoshihiro Kaneko
2016-03-03 3:50 GMT+09:00 Sergei Shtylyov <sergei.shtyl...@cogentembedded.com>:
> On 03/02/2016 09:16 PM, Yoshihiro Kaneko wrote:
>
>>>> From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>>>>
>>>> This patch supports the following interrupts.
>>>>
>>>> - One interrupt for multiple (timestamp, error, gPTP)
>>>> - One interrupt for emac
>>>> - Four interrupts for dma queue (best effort rx/tx, network control
>>>> rx/tx)
>>>>
>>>> This patch improve efficiency of the interrupt handler by adding the
>>>> interrupt handler corresponding to each interrupt source described
>>>> above. Additionally, it reduces the number of times of the access to
>>>> EthernetAVB IF.
>>>> Also this patch prevent this driver depends on the whim of a boot
>>>> loader.
>>>>
>>>> [ykaneko0...@gmail.com: define bit names of registers]
>>>> [ykaneko0...@gmail.com: add comment for gen3 only registers]
>>>> [ykaneko0...@gmail.com: fix coding style]
>>>> [ykaneko0...@gmail.com: update changelog]
>>>> [ykaneko0...@gmail.com: gen3: fix initialization of interrupts]
>>>> [ykaneko0...@gmail.com: gen3: fix clearing interrupts]
>>>> [ykaneko0...@gmail.com: gen3: add helper function for request_irq()]
>>>> [ykaneko0...@gmail.com: gen3: remove IRQF_SHARED flag for request_irq()]
>>>> [ykaneko0...@gmail.com: revert ravb_close() and ravb_ptp_stop()]
>>>> [ykaneko0...@gmail.com: avoid calling free_irq() to non-hooked
>>>> interrupts]
>>>> [ykaneko0...@gmail.com: make NC/BE interrupt handler a function]
>>>> [ykaneko0...@gmail.com: make timestamp interrupt handler a function]
>>>> [ykaneko0...@gmail.com: timestamp interrupt is handled in multiple
>>>>interrupt handler instead of dma queue interrupt handler]
>>>> Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>>>> Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
>>>
>>>
>>> OK, you are very close now! Just a few comments...
>>>
> [...]
>>>>
>>>> diff --git a/drivers/net/ethernet/renesas/ravb_main.c
>>>> b/drivers/net/ethernet/renesas/ravb_main.c
>>>> index c936682..22ef65d 100644
>>>> --- a/drivers/net/ethernet/renesas/ravb_main.c
>>>> +++ b/drivers/net/ethernet/renesas/ravb_main.c
>
> [...]
>>>>
>>>>
>>>> +static irqreturn_t ravb_rx_tx_interrupt(int irq, void *dev_id, int
>>>> ravb_queue)
>>>
>>>
>>>Please, please shorten this 'ravb_queue'...
>>
>>
>> I will fix it.
>>
>>> Also, would make sense to rename it to ravb_dma_interrupt()...
>>
>>
>> I have renamed it from ravb_dmaq_interrupt() in this version as you
>> suggested in the previous review. Did you not mean it?
>
>
>Yes, I meant that, though perhaps got somewhat muddled up. Another
> variant is to call the current ravb_queue_interrupt()
> ravb_dma_interrupt_unlocked() (after adding the register reads there)
> calling this one ravb_dma_interrupt() but I don't insist on the former,
> ravb_queue_interrupt() is good enough as is; just rename this function
> please.

Thanks for the clarification. I understand.
I will rename this function to ravb_dma_interrupt().

>
>>> [...]
>>>
>>> Unfortunately, I still can't do a full gen2 regression testing as
>>> both
>>> Alt and Porter boards don't work with the recent kernel due to AVB_MDIO
>>> stuck at 1... But perhaps such testing isn't even necessary.
>>
>>
>> Thanks,
>> kaneko
>
>
> MBR, Sergei
>

Thanks,
kaneko


Re: [PATCH/RFC v5 net-next] ravb: Add dma queue interrupt support

2016-03-02 Thread Yoshihiro Kaneko
2016-03-01 5:55 GMT+09:00 Sergei Shtylyov <sergei.shtyl...@cogentembedded.com>:
> On 02/28/2016 05:13 PM, Yoshihiro Kaneko wrote:
>
>>>> From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>>>>
>>>> This patch supports the following interrupts.
>>>>
>>>> - One interrupt for multiple (error, gPTP)
>>>> - One interrupt for emac
>>>> - Four interrupts for dma queue (best effort rx/tx, network control
>>>> rx/tx)
>>>>
>>>> This patch improve efficiency of the interrupt handler by adding the
>>>> interrupt handler corresponding to each interrupt source described
>>>> above. Additionally, it reduces the number of times of the access to
>>>> EthernetAVB IF.
>>>> Also this patch prevent this driver depends on the whim of a boot
>>>> loader.
>>>>
>>>> [ykaneko0...@gmail.com: define bit names of registers]
>>>> [ykaneko0...@gmail.com: add comment for gen3 only registers]
>>>> [ykaneko0...@gmail.com: fix coding style]
>>>> [ykaneko0...@gmail.com: update changelog]
>>>> [ykaneko0...@gmail.com: gen3: fix initialization of interrupts]
>>>> [ykaneko0...@gmail.com: gen3: fix clearing interrupts]
>>>> [ykaneko0...@gmail.com: gen3: add helper function for request_irq()]
>>>> [ykaneko0...@gmail.com: revert ravb_close() and ravb_ptp_stop()]
>>>> [ykaneko0...@gmail.com: avoid calling free_irq() to non-hooked
>>>> interrupts]
>>>> [ykaneko0...@gmail.com: make NC/BE interrupt handler a function]
>>>> Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>>>> Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
>>>
>>>
>>>
>>> [...]
>>>
>>>> diff --git a/drivers/net/ethernet/renesas/ravb_main.c
>>>> b/drivers/net/ethernet/renesas/ravb_main.c
>>>> index c936682..1bec71e 100644
>>>> --- a/drivers/net/ethernet/renesas/ravb_main.c
>>>> +++ b/drivers/net/ethernet/renesas/ravb_main.c
>>>
>>>
>>> [...]
>>>>
>>>>
>>>> @@ -697,6 +726,39 @@ static void ravb_error_interrupt(struct net_device
>>>> *ndev)
>>>>  }
>>>>}
>>>>
>>>> +static int ravb_nc_be_interrupt(struct net_device *ndev, int
>>>> ravb_queue,
>>>
>>>
>>>
>>> I'd call this function e.g. ravb_queue_interrupt(). And make it
>>> return
>>> 'bool' or even 'irqreturn_t' directly. And I'd suggest a shorter name for
>>> the 'ravb_queue' parameter, like 'queue' or even 'q'...
>>
>>
>> Agreed.
>>
>>>
>>>> +   u32 ris0, u32 *ric0, u32 tis, u32 *tic)
>>>
>>>
>>>
>>> You don't seem to need 'ric0' and 'tic' past the call sites, so no
>>> real
>>> need to pass them by reference.
>>
>>
>> When Rx/Tx interrupt for NC and BE is issued at the same time,
>> this function is called twice (for NC, BE) from ravb_interrupt.
>> The interrupt mask of NC set in the first call will be reset in the next
>> call for BE. So it is necessary to keep the modified value of "ric0" and
>> "tic".
>
>
>OK, but we still can simplify this by reading these registers right in
> ravb_queue_interrupt()...

OK.

>
>
> [...]
>>>>
>>>> @@ -725,31 +787,15 @@ static irqreturn_t ravb_interrupt(int irq, void
>>>> *dev_id)
>>>>
>>>>  /* Network control and best effort queue RX/TX */
>>>>  for (q = RAVB_NC; q >= RAVB_BE; q--) {
>>>> -   if (((ris0 & ric0) & BIT(q)) ||
>>>> -   ((tis  & tic)  & BIT(q))) {
>>>> -   if (napi_schedule_prep(>napi[q]))
>>>> {
>>>> -   /* Mask RX and TX interrupts */
>>>> -   ric0 &= ~BIT(q);
>>>> -   tic &= ~BIT(q);
>>>> -   ravb_write(ndev, ric0, RIC0);
>>>> -   ravb_write(ndev, tic, TIC);
>>>> -   __napi_schedule(>napi[q]);
>>>> -   } else {
>>>> - 

Re: [PATCH/RFC v6 net-next] ravb: Add dma queue interrupt support

2016-03-02 Thread Yoshihiro Kaneko
2016-03-01 5:30 GMT+09:00 Sergei Shtylyov <sergei.shtyl...@cogentembedded.com>:
> Hello.
>
>
> On 02/28/2016 06:41 PM, Yoshihiro Kaneko wrote:
>
>> From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>>
>> This patch supports the following interrupts.
>>
>> - One interrupt for multiple (timestamp, error, gPTP)
>> - One interrupt for emac
>> - Four interrupts for dma queue (best effort rx/tx, network control rx/tx)
>>
>> This patch improve efficiency of the interrupt handler by adding the
>> interrupt handler corresponding to each interrupt source described
>> above. Additionally, it reduces the number of times of the access to
>> EthernetAVB IF.
>> Also this patch prevent this driver depends on the whim of a boot loader.
>>
>> [ykaneko0...@gmail.com: define bit names of registers]
>> [ykaneko0...@gmail.com: add comment for gen3 only registers]
>> [ykaneko0...@gmail.com: fix coding style]
>> [ykaneko0...@gmail.com: update changelog]
>> [ykaneko0...@gmail.com: gen3: fix initialization of interrupts]
>> [ykaneko0...@gmail.com: gen3: fix clearing interrupts]
>> [ykaneko0...@gmail.com: gen3: add helper function for request_irq()]
>> [ykaneko0...@gmail.com: gen3: remove IRQF_SHARED flag for request_irq()]
>> [ykaneko0...@gmail.com: revert ravb_close() and ravb_ptp_stop()]
>> [ykaneko0...@gmail.com: avoid calling free_irq() to non-hooked interrupts]
>> [ykaneko0...@gmail.com: make NC/BE interrupt handler a function]
>> [ykaneko0...@gmail.com: make timestamp interrupt handler a function]
>> [ykaneko0...@gmail.com: timestamp interrupt is handled in multiple
>>   interrupt handler instead of dma queue interrupt handler]
>> Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>> Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
>
>
>OK, you are very close now! Just a few comments...
>
> [...]
>>
>> diff --git a/drivers/net/ethernet/renesas/ravb_main.c
>> b/drivers/net/ethernet/renesas/ravb_main.c
>> index c936682..22ef65d 100644
>> --- a/drivers/net/ethernet/renesas/ravb_main.c
>> +++ b/drivers/net/ethernet/renesas/ravb_main.c
>
> [...]
>>
>> @@ -697,6 +726,47 @@ static void ravb_error_interrupt(struct net_device
>> *ndev)
>> }
>>   }
>>
>> +static bool ravb_queue_interrupt(struct net_device *ndev, int q,
>> +u32 ris0, u32 *ric0, u32 tis, u32 *tic)
>> +{
>> +   struct ravb_private *priv = netdev_priv(ndev);
>> +
>
>
>Perhaps it makes sense to read the RI[CS]0/TI[CS] here instead of passing
> them (by reference)?

OK, I will do.

>
> [...]
>
>> @@ -714,42 +784,21 @@ static irqreturn_t ravb_interrupt(int irq, void
>> *dev_id)
>> u32 ric0 = ravb_read(ndev, RIC0);
>> u32 tis  = ravb_read(ndev, TIS);
>> u32 tic  = ravb_read(ndev, TIC);
>> -   int q;
>>
>> /* Timestamp updated */
>> -   if (tis & TIS_TFUF) {
>> -   ravb_write(ndev, ~TIS_TFUF, TIS);
>> -   ravb_get_tx_tstamp(ndev);
>> +   if (ravb_timestamp_interrupt(ndev, tis))
>> result = IRQ_HANDLED;
>> -   }
>>
>> /* Network control and best effort queue RX/TX */
>> -   for (q = RAVB_NC; q >= RAVB_BE; q--) {
>> -   if (((ris0 & ric0) & BIT(q)) ||
>> -   ((tis  & tic)  & BIT(q))) {
>> -   if (napi_schedule_prep(>napi[q])) {
>> -   /* Mask RX and TX interrupts */
>> -   ric0 &= ~BIT(q);
>> -   tic &= ~BIT(q);
>> -   ravb_write(ndev, ric0, RIC0);
>> -   ravb_write(ndev, tic, TIC);
>> -   __napi_schedule(>napi[q]);
>> -   } else {
>> -   netdev_warn(ndev,
>> -   "ignoring interrupt,
>> rx status 0x%08x, rx mask 0x%08x,\n",
>> -   ris0, ric0);
>> -   netdev_warn(ndev,
>> -   "
>> tx status 0x%08x, tx mask 0x%08x.\n",
>> -

[PATCH/RFC v6 net-next] ravb: Add dma queue interrupt support

2016-02-28 Thread Yoshihiro Kaneko
From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>

This patch supports the following interrupts.

- One interrupt for multiple (timestamp, error, gPTP)
- One interrupt for emac
- Four interrupts for dma queue (best effort rx/tx, network control rx/tx)

This patch improve efficiency of the interrupt handler by adding the
interrupt handler corresponding to each interrupt source described
above. Additionally, it reduces the number of times of the access to
EthernetAVB IF.
Also this patch prevent this driver depends on the whim of a boot loader.

[ykaneko0...@gmail.com: define bit names of registers]
[ykaneko0...@gmail.com: add comment for gen3 only registers]
[ykaneko0...@gmail.com: fix coding style]
[ykaneko0...@gmail.com: update changelog]
[ykaneko0...@gmail.com: gen3: fix initialization of interrupts]
[ykaneko0...@gmail.com: gen3: fix clearing interrupts]
[ykaneko0...@gmail.com: gen3: add helper function for request_irq()]
[ykaneko0...@gmail.com: gen3: remove IRQF_SHARED flag for request_irq()]
[ykaneko0...@gmail.com: revert ravb_close() and ravb_ptp_stop()]
[ykaneko0...@gmail.com: avoid calling free_irq() to non-hooked interrupts]
[ykaneko0...@gmail.com: make NC/BE interrupt handler a function]
[ykaneko0...@gmail.com: make timestamp interrupt handler a function]
[ykaneko0...@gmail.com: timestamp interrupt is handled in multiple
 interrupt handler instead of dma queue interrupt handler]
Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
---

This patch is based on the master branch of David Miller's next networking
tree.

v6 [Yoshihiro Kaneko]
* As suggested by Sergei Shtylyov
  drivers/net/ethernet/renesas/ravb_main.c:
- rename ravb_nc_be_interrupt to ravb_queue_interrupt, change the type
   of return value to 'bool', rename ravb_queue to 'q'
- stop use of 'for' loop for queue interrupt in ravb_interrupt()
- fix comment for ravb_multi_interrupt()
- rename ravb_dmaq_interrupt to ravb_rx_tx_interrupt
- move timestamp interrupt handler into ravb_multi_interrupt()
- make timestamp interrupt handler a funtion
- rename out_free_irq2 label to out_free_irq_nc_tx
- remove IRQF_SHARED flag for request_irq()
  drivers/net/ethernet/renesas/ravb_ptp.c:
- fix coding style

v5 [Yoshihiro Kaneko]
* As suggested by Sergei Shtylyov
  drivers/net/ethernet/renesas/ravb_main.c:
- stop copying ravb_queue parameter in ravb_dmaq_interrupt()
- clear TFUF instead of disabling
- factored out NC/BE interrupt handler
- rename hook_irq() in ravb_hook_irq()
- add calling free_irq() for the EMAC IRQ
- stop using a loop for free_irq() to avoid calling free_irq() for
  non-hooked interrupt handlers
- add test for failure of devm_kasprintf in ravb_hook_irq()
- update changelog

v4 [Yoshihiro Kaneko]
* compile tested only
* As suggested by Sergei Shtylyov
  drivers/net/ethernet/renesas/ravb.h:
- make two lines of comment into one line.
- remove unused definition of xxx_ALL.
  drivers/net/ethernet/renesas/ravb_main.c:
- remove unrelated change (fix indentation).
- output warning messages when napi_schedule_prep() fails in ravb_dmaq_
  interrupt() like ravb_interrupt().
- change the function name from req_irq to hook_irq.
- fix programming error in hook_irq().
- do free_irq() for rx_irqs[] and tx_irqs[] for only gen3 in out_free_
  irq label in ravb_open().

v3 [Yoshihiro Kaneko]
* compile tested only
* As suggested by Sergei Shtylyov
  - update changelog
  drivers/net/ethernet/renesas/ravb.h:
- add comments to the additional registers like CIE
  drivers/net/ethernet/renesas/ravb_main.c:
- fix the initialization of the interrupt in ravb_dmac_init()
- revert ravb_error_interrupt() because gen3 code is wrong
- change the comment "Management" in ravb_multi_interrupt()
- add a helper function for request_irq() in ravb_open()
- revert ravb_close() because atomicity is not necessary here
  drivers/net/ethernet/renesas/ravb_ptp.c:
- revert ravb_ptp_stop() because atomicity is not necessary here

v2 [Yoshihiro Kaneko]
* compile tested only
* As suggested by Sergei Shtylyov
  - add comment to CIE
  - remove comments from CIE bits
  - fix value of TIx_ALL
  - define each bits for CIE, GIE, GID, RIE0, RID0, RIE2, RID2, TIE, TID
  - reversed Christmas tree declaration ordered
  - rename _ravb_emac_interrupt() to ravb_emac_interrupt_unlocked()
  - remove unnecessary clearing of CIE
  - use a bit name corresponding to the target register, RIE0, RIE2, TIE,
TID, RID2, GID, GIE

 drivers/net/ethernet/renesas/ravb.h  | 204 +++
 drivers/net/ethernet/renesas/ravb_main.c | 274 ++-
 drivers/net/ethernet/renesas/ravb_ptp.c  |  17 +-
 3 files changed, 447 insertions(+), 48 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h 
b/drivers/net/ethernet/renesas/r

Re: [PATCH/RFC v5 net-next] ravb: Add dma queue interrupt support

2016-02-28 Thread Yoshihiro Kaneko
2016-02-22 4:05 GMT+09:00 Sergei Shtylyov <sergei.shtyl...@cogentembedded.com>:
> On 02/14/2016 10:39 PM, Yoshihiro Kaneko wrote:
>
>> From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>>
>> This patch supports the following interrupts.
>>
>> - One interrupt for multiple (error, gPTP)
>> - One interrupt for emac
>> - Four interrupts for dma queue (best effort rx/tx, network control rx/tx)
>>
>> This patch improve efficiency of the interrupt handler by adding the
>> interrupt handler corresponding to each interrupt source described
>> above. Additionally, it reduces the number of times of the access to
>> EthernetAVB IF.
>> Also this patch prevent this driver depends on the whim of a boot loader.
>>
>> [ykaneko0...@gmail.com: define bit names of registers]
>> [ykaneko0...@gmail.com: add comment for gen3 only registers]
>> [ykaneko0...@gmail.com: fix coding style]
>> [ykaneko0...@gmail.com: update changelog]
>> [ykaneko0...@gmail.com: gen3: fix initialization of interrupts]
>> [ykaneko0...@gmail.com: gen3: fix clearing interrupts]
>> [ykaneko0...@gmail.com: gen3: add helper function for request_irq()]
>> [ykaneko0...@gmail.com: revert ravb_close() and ravb_ptp_stop()]
>> [ykaneko0...@gmail.com: avoid calling free_irq() to non-hooked interrupts]
>> [ykaneko0...@gmail.com: make NC/BE interrupt handler a function]
>> Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>> Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
>
>
> [...]
>
>> diff --git a/drivers/net/ethernet/renesas/ravb_main.c
>> b/drivers/net/ethernet/renesas/ravb_main.c
>> index c936682..1bec71e 100644
>> --- a/drivers/net/ethernet/renesas/ravb_main.c
>> +++ b/drivers/net/ethernet/renesas/ravb_main.c
>
> [...]
>>
>> @@ -697,6 +726,39 @@ static void ravb_error_interrupt(struct net_device
>> *ndev)
>> }
>>   }
>>
>> +static int ravb_nc_be_interrupt(struct net_device *ndev, int ravb_queue,
>
>
>I'd call this function e.g. ravb_queue_interrupt(). And make it return
> 'bool' or even 'irqreturn_t' directly. And I'd suggest a shorter name for
> the 'ravb_queue' parameter, like 'queue' or even 'q'...

Agreed.

>
>> +   u32 ris0, u32 *ric0, u32 tis, u32 *tic)
>
>
>You don't seem to need 'ric0' and 'tic' past the call sites, so no real
> need to pass them by reference.

When Rx/Tx interrupt for NC and BE is issued at the same time,
this function is called twice (for NC, BE) from ravb_interrupt.
The interrupt mask of NC set in the first call will be reset in the next
call for BE. So it is necessary to keep the modified value of "ric0" and
"tic".

>
> [...]
>>
>> @@ -725,31 +787,15 @@ static irqreturn_t ravb_interrupt(int irq, void
>> *dev_id)
>>
>> /* Network control and best effort queue RX/TX */
>> for (q = RAVB_NC; q >= RAVB_BE; q--) {
>> -   if (((ris0 & ric0) & BIT(q)) ||
>> -   ((tis  & tic)  & BIT(q))) {
>> -   if (napi_schedule_prep(>napi[q])) {
>> -   /* Mask RX and TX interrupts */
>> -   ric0 &= ~BIT(q);
>> -   tic &= ~BIT(q);
>> -   ravb_write(ndev, ric0, RIC0);
>> -   ravb_write(ndev, tic, TIC);
>> -   __napi_schedule(>napi[q]);
>> -   } else {
>> -   netdev_warn(ndev,
>> -   "ignoring interrupt,
>> rx status 0x%08x, rx mask 0x%08x,\n",
>> -   ris0, ric0);
>> -   netdev_warn(ndev,
>> -   "
>> tx status 0x%08x, tx mask 0x%08x.\n",
>> -   tis, tic);
>> -   }
>> +   if (ravb_nc_be_interrupt(ndev, q, ris0, ,
>> tis,
>> +))
>> result = IRQ_HANDLED;
>> -   }
>> }
>
>
>Unroll this *for* loop please...

OK.

>
>> }
>
> [...]
>>
>> @@ -767,6 +813,73 @@ static irqreturn_t ravb_interrupt(i

[PATCH/RFC v5 net-next] ravb: Add dma queue interrupt support

2016-02-14 Thread Yoshihiro Kaneko
From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>

This patch supports the following interrupts.

- One interrupt for multiple (error, gPTP)
- One interrupt for emac
- Four interrupts for dma queue (best effort rx/tx, network control rx/tx)

This patch improve efficiency of the interrupt handler by adding the
interrupt handler corresponding to each interrupt source described
above. Additionally, it reduces the number of times of the access to
EthernetAVB IF.
Also this patch prevent this driver depends on the whim of a boot loader.

[ykaneko0...@gmail.com: define bit names of registers]
[ykaneko0...@gmail.com: add comment for gen3 only registers]
[ykaneko0...@gmail.com: fix coding style]
[ykaneko0...@gmail.com: update changelog]
[ykaneko0...@gmail.com: gen3: fix initialization of interrupts]
[ykaneko0...@gmail.com: gen3: fix clearing interrupts]
[ykaneko0...@gmail.com: gen3: add helper function for request_irq()]
[ykaneko0...@gmail.com: revert ravb_close() and ravb_ptp_stop()]
[ykaneko0...@gmail.com: avoid calling free_irq() to non-hooked interrupts]
[ykaneko0...@gmail.com: make NC/BE interrupt handler a function]
Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
---

This patch is based on the master branch of David Miller's next networking
tree.

v5 [Yoshihiro Kaneko]
* As suggested by Sergei Shtylyov
  drivers/net/ethernet/renesas/ravb_main.c:
- stop copying ravb_queue parameter in ravb_dmaq_interrupt()
- clear TFUF instead of disabling
- factored out NC/BE interrupt handler
- rename hook_irq() in ravb_hook_irq()
- add calling free_irq() for the EMAC IRQ
- stop using a loop for free_irq() to avoid calling free_irq() for
  non-hooked interrupt handlers
- add test for failure of devm_kasprintf in ravb_hook_irq()
- update changelog

v4 [Yoshihiro Kaneko]
* compile tested only
* As suggested by Sergei Shtylyov
  drivers/net/ethernet/renesas/ravb.h:
- make two lines of comment into one line.
- remove unused definition of xxx_ALL.
  drivers/net/ethernet/renesas/ravb_main.c:
- remove unrelated change (fix indentation).
- output warning messages when napi_schedule_prep() fails in ravb_dmaq_
  interrupt() like ravb_interrupt().
- change the function name from req_irq to hook_irq.
- fix programming error in hook_irq().
- do free_irq() for rx_irqs[] and tx_irqs[] for only gen3 in out_free_
  irq label in ravb_open().

v3 [Yoshihiro Kaneko]
* compile tested only
* As suggested by Sergei Shtylyov
  - update changelog
  drivers/net/ethernet/renesas/ravb.h:
- add comments to the additional registers like CIE
  drivers/net/ethernet/renesas/ravb_main.c:
- fix the initialization of the interrupt in ravb_dmac_init()
- revert ravb_error_interrupt() because gen3 code is wrong
- change the comment "Management" in ravb_multi_interrupt()
- add a helper function for request_irq() in ravb_open()
- revert ravb_close() because atomicity is not necessary here
  drivers/net/ethernet/renesas/ravb_ptp.c:
- revert ravb_ptp_stop() because atomicity is not necessary here

v2 [Yoshihiro Kaneko]
* compile tested only
* As suggested by Sergei Shtylyov
  - add comment to CIE
  - remove comments from CIE bits
  - fix value of TIx_ALL
  - define each bits for CIE, GIE, GID, RIE0, RID0, RIE2, RID2, TIE, TID
  - reversed Christmas tree declaration ordered
  - rename _ravb_emac_interrupt() to ravb_emac_interrupt_unlocked()
  - remove unnecessary clearing of CIE
  - use a bit name corresponding to the target register, RIE0, RIE2, TIE,
TID, RID2, GID, GIE

 drivers/net/ethernet/renesas/ravb.h  | 204 +
 drivers/net/ethernet/renesas/ravb_main.c | 251 ++-
 drivers/net/ethernet/renesas/ravb_ptp.c  |  19 ++-
 3 files changed, 436 insertions(+), 38 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h 
b/drivers/net/ethernet/renesas/ravb.h
index b2160d1..5c16241 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -157,6 +157,7 @@ enum ravb_reg {
TIC = 0x0378,
TIS = 0x037C,
ISS = 0x0380,
+   CIE = 0x0384,   /* R-Car Gen3 only */
GCCR= 0x0390,
GMTT= 0x0394,
GPTC= 0x0398,
@@ -170,6 +171,15 @@ enum ravb_reg {
GCT0= 0x03B8,
GCT1= 0x03BC,
GCT2= 0x03C0,
+   GIE = 0x03CC,   /* R-Car Gen3 only */
+   GID = 0x03D0,   /* R-Car Gen3 only */
+   DIL = 0x0440,   /* R-Car Gen3 only */
+   RIE0= 0x0460,   /* R-Car Gen3 only */
+   RID0= 0x0464,   /* R-Car Gen3 only */
+   RIE2= 0x0470,   /* R-Car Gen3 only */
+   RID2= 0x0474,   /* R-Car Gen3 only */
+   TIE = 0x0478,   /* R-Car Gen3 only */
+   TID = 0x047c,   /* R-Car Gen3 only */

Re: [PATCH/RFC v4 net-next] ravb: Add dma queue interrupt support

2016-02-08 Thread Yoshihiro Kaneko
Hi Sergei-san,

2016-02-08 2:09 GMT+09:00 Sergei Shtylyov <sergei.shtyl...@cogentembedded.com>:
> Hello.
>
> On 02/07/2016 07:50 PM, Yoshihiro Kaneko wrote:
>
>> I apologize for not responding to you earlier.
>
>
>Absolutely no problem, these reviews/tests take time from my main tasks
> anyway. :-)
>
>
>>>> From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>>>>
>>>> This patch supports the following interrupts.
>>>>
>>>> - One interrupt for multiple (descriptor, error, management)
>>>> - One interrupt for emac
>>>> - Four interrupts for dma queue (best effort rx/tx, network control
>>>> rx/tx)
>>>>
>>>> This patch improve efficiency of the interrupt handler by adding the
>>>> interrupt handler corresponding to each interrupt source described
>>>> above. Additionally, it reduces the number of times of the access to
>>>> EthernetAVB IF.
>>>>
>>>> Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>>>> Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
>>>> ---
>>>>
>>>> This patch is based on the master branch of David Miller's next
>>>> networking
>>>> tree.
>>>>
>>>> v4 [Yoshihiro Kaneko]
>>>> * compile tested only
>>>> * As suggested by Sergei Shtylyov
>>>> drivers/net/ethernet/renesas/ravb.h:
>>>>   - make two lines of comment into one line.
>>>>   - remove unused definition of xxx_ALL.
>>>> drivers/net/ethernet/renesas/ravb_main.c:
>>>>   - remove unrelated change (fix indentation).
>>>>   - output warning messages when napi_schedule_prep() fails in
>>>> ravb_dmaq_
>>>> interrupt() like ravb_interrupt().
>>>>   - change the function name from req_irq to hook_irq.
>>>>   - fix programming error in hook_irq().
>>>>   - do free_irq() for rx_irqs[] and tx_irqs[] for only gen3 in
>>>> out_free_
>>>> irq label in ravb_open().
>>>>
>>>> v3 [Yoshihiro Kaneko]
>>>> * compile tested only
>>>> * As suggested by Sergei Shtylyov
>>>> - update changelog
>>>> drivers/net/ethernet/renesas/ravb.h:
>>>>   - add comments to the additional registers like CIE
>>>> drivers/net/ethernet/renesas/ravb_main.c:
>>>>   - fix the initialization of the interrupt in ravb_dmac_init()
>>>>   - revert ravb_error_interrupt() because gen3 code is wrong
>>>>   - change the comment "Management" in ravb_multi_interrupt()
>>>>   - add a helper function for request_irq() in ravb_open()
>>>>   - revert ravb_close() because atomicity is not necessary here
>>>> drivers/net/ethernet/renesas/ravb_ptp.c:
>>>>   - revert ravb_ptp_stop() because atomicity is not necessary here
>>>>
>>>> v2 [Yoshihiro Kaneko]
>>>> * compile tested only
>>>> * As suggested by Sergei Shtylyov
>>>> - add comment to CIE
>>>> - remove comments from CIE bits
>>>> - fix value of TIx_ALL
>>>> - define each bits for CIE, GIE, GID, RIE0, RID0, RIE2, RID2, TIE,
>>>> TID
>>>> - reversed Christmas tree declaration ordered
>>>> - rename _ravb_emac_interrupt() to ravb_emac_interrupt_unlocked()
>>>> - remove unnecessary clearing of CIE
>>>> - use a bit name corresponding to the target register, RIE0, RIE2,
>>>> TIE,
>>>>   TID, RID2, GID, GIE
>>>
>>>
>>>
>>> As I already noted, the changes made to the original patch are
>>> supposed
>>> to be documented above --- (no need to separate diff versions there
>>> though).
>>> Either that, or just say that it's your patch, based on
>>> Mizuguchi-san's
>>> work (the amount of changes makes that possible, I think).
>>
>>
>> I will record that I made a change to this patch in the commit log of
>> the next version.
>> I don't think that I changed the essence of this patch. I changed
>> various trivial things, or fixed bugs you pointed out.
>
>
>OK, as you wish. But in case this gets too tedious, I'll understand if
> you change the authorship.
>
>>> [...]
>>>>
>>>>
>>>> diff --git a/drivers/net/ethernet/renesas/ravb_ma

Re: [PATCH/RFC v4 net-next] ravb: Add dma queue interrupt support

2016-02-07 Thread Yoshihiro Kaneko
Hi Sergei,

I apologize for not responding to you earlier.

2016-01-29 1:48 GMT+09:00 Sergei Shtylyov <sergei.shtyl...@cogentembedded.com>:
> Hello.
>
>
> On 01/24/2016 06:52 PM, Yoshihiro Kaneko wrote:
>
>> From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>>
>> This patch supports the following interrupts.
>>
>> - One interrupt for multiple (descriptor, error, management)
>> - One interrupt for emac
>> - Four interrupts for dma queue (best effort rx/tx, network control rx/tx)
>>
>> This patch improve efficiency of the interrupt handler by adding the
>> interrupt handler corresponding to each interrupt source described
>> above. Additionally, it reduces the number of times of the access to
>> EthernetAVB IF.
>>
>> Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>> Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
>> ---
>>
>> This patch is based on the master branch of David Miller's next networking
>> tree.
>>
>> v4 [Yoshihiro Kaneko]
>> * compile tested only
>> * As suggested by Sergei Shtylyov
>>drivers/net/ethernet/renesas/ravb.h:
>>  - make two lines of comment into one line.
>>  - remove unused definition of xxx_ALL.
>>drivers/net/ethernet/renesas/ravb_main.c:
>>  - remove unrelated change (fix indentation).
>>  - output warning messages when napi_schedule_prep() fails in
>> ravb_dmaq_
>>interrupt() like ravb_interrupt().
>>      - change the function name from req_irq to hook_irq.
>>  - fix programming error in hook_irq().
>>  - do free_irq() for rx_irqs[] and tx_irqs[] for only gen3 in
>> out_free_
>>irq label in ravb_open().
>>
>> v3 [Yoshihiro Kaneko]
>> * compile tested only
>> * As suggested by Sergei Shtylyov
>>- update changelog
>>drivers/net/ethernet/renesas/ravb.h:
>>  - add comments to the additional registers like CIE
>>drivers/net/ethernet/renesas/ravb_main.c:
>>  - fix the initialization of the interrupt in ravb_dmac_init()
>>  - revert ravb_error_interrupt() because gen3 code is wrong
>>  - change the comment "Management" in ravb_multi_interrupt()
>>  - add a helper function for request_irq() in ravb_open()
>>  - revert ravb_close() because atomicity is not necessary here
>>drivers/net/ethernet/renesas/ravb_ptp.c:
>>  - revert ravb_ptp_stop() because atomicity is not necessary here
>>
>> v2 [Yoshihiro Kaneko]
>> * compile tested only
>> * As suggested by Sergei Shtylyov
>>- add comment to CIE
>>- remove comments from CIE bits
>>- fix value of TIx_ALL
>>- define each bits for CIE, GIE, GID, RIE0, RID0, RIE2, RID2, TIE, TID
>>- reversed Christmas tree declaration ordered
>>- rename _ravb_emac_interrupt() to ravb_emac_interrupt_unlocked()
>>- remove unnecessary clearing of CIE
>>- use a bit name corresponding to the target register, RIE0, RIE2, TIE,
>>  TID, RID2, GID, GIE
>
>
>As I already noted, the changes made to the original patch are supposed
> to be documented above --- (no need to separate diff versions there though).
>Either that, or just say that it's your patch, based on Mizuguchi-san's
> work (the amount of changes makes that possible, I think).

I will record that I made a change to this patch in the commit log of
the next version.
I don't think that I changed the essence of this patch. I changed
various trivial things, or fixed bugs you pointed out.

>
> [...]
>>
>> diff --git a/drivers/net/ethernet/renesas/ravb_main.c
>> b/drivers/net/ethernet/renesas/ravb_main.c
>> index ac43ed9..076f25f 100644
>> --- a/drivers/net/ethernet/renesas/ravb_main.c
>> +++ b/drivers/net/ethernet/renesas/ravb_main.c
>
> [...]
>>
>> +static irqreturn_t ravb_dmaq_interrupt(int irq, void *dev_id, int
>> ravb_queue)
>> +{
>> +   struct net_device *ndev = dev_id;
>> +   struct ravb_private *priv = netdev_priv(ndev);
>> +   irqreturn_t result = IRQ_NONE;
>> +   u32 ris0, ric0, tis, tic;
>> +   int q = ravb_queue;
>
>
>Just give a shorter name to the 'ravb_queue' parameter, no need to copy
> it.

Agreed.

>
>> +
>> +   spin_lock(>lock);
>> +
>> +   ris0 = ravb_read(ndev, RIS0);
>> +   ric0 = ravb_read(ndev, RIC0);
>> +   tis  = ravb_read(ndev, TIS);
>> +   tic  = ravb_read(ndev, TIC);
>> +
>> +   /* Timestamp updated */
>> +   if (tis & TIS_TFUF) {
>

Re: [PATCH/RFC v4 net-next] ravb: Add dma queue interrupt support

2016-02-07 Thread Yoshihiro Kaneko
2016-01-29 2:32 GMT+09:00 Sergei Shtylyov <sergei.shtyl...@cogentembedded.com>:
> On 01/24/2016 06:52 PM, Yoshihiro Kaneko wrote:
>
>> From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>>
>> This patch supports the following interrupts.
>>
>> - One interrupt for multiple (descriptor, error, management)
>> - One interrupt for emac
>> - Four interrupts for dma queue (best effort rx/tx, network control rx/tx)
>>
>> This patch improve efficiency of the interrupt handler by adding the
>> interrupt handler corresponding to each interrupt source described
>> above. Additionally, it reduces the number of times of the access to
>> EthernetAVB IF.
>>
>> Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>> Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
>
>
> [...]
>
>> diff --git a/drivers/net/ethernet/renesas/ravb_main.c
>> b/drivers/net/ethernet/renesas/ravb_main.c
>> index ac43ed9..076f25f 100644
>> --- a/drivers/net/ethernet/renesas/ravb_main.c
>> +++ b/drivers/net/ethernet/renesas/ravb_main.c
>
> [...]
>>
>> @@ -1215,29 +1332,64 @@ static const struct ethtool_ops ravb_ethtool_ops =
>> {
>> .get_ts_info= ravb_get_ts_info,
>>   };
>>
>> +static inline int hook_irq(unsigned int irq, irq_handler_t handler,
>> +  struct net_device *ndev, struct device *dev,
>> +  const char *ch)
>> +{
>> +   char *name;
>> +   int error;
>> +
>> +   name = devm_kasprintf(dev, GFP_KERNEL, "%s:%s", ndev->name, ch);
>
>
>BTW, shouldn't we test 'name' for NULL here?

Thanks.
I will fix it to return -ENOMEM if 'name' is NULL.

>
>> +   error = request_irq(irq, handler, IRQF_SHARED, name, ndev);
>> +   if (error)
>> +   netdev_err(ndev, "cannot request IRQ %s\n", name);
>> +
>> +   return error;
>> +}
>> +
>
>
> MBR, Sergei
>

Thanks,
kaneko


Re: [PATCH/RFC v4 net-next] ravb: Add dma queue interrupt support

2016-02-07 Thread Yoshihiro Kaneko
2016-01-29 2:51 GMT+09:00 Sergei Shtylyov <sergei.shtyl...@cogentembedded.com>:
> On 01/24/2016 06:52 PM, Yoshihiro Kaneko wrote:
>
>> From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>>
>> This patch supports the following interrupts.
>>
>> - One interrupt for multiple (descriptor, error, management)
>
>
>Looking at the code again, ravb_multi_interrupot() only handles error and
> gPTP interrupt now.

Indeed, it is.

>
>> - One interrupt for emac
>> - Four interrupts for dma queue (best effort rx/tx, network control rx/tx)
>>
>> This patch improve efficiency of the interrupt handler by adding the
>> interrupt handler corresponding to each interrupt source described
>> above. Additionally, it reduces the number of times of the access to
>> EthernetAVB IF.
>
>
>I'd still like to see there a statement about not being dependent on the
> whim of a boot loader any more...

I agreed.

>
>>
>> Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>> Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
>
>
> [...]
>
> MBR, Sergei
>

Thanks,
kaneko


Re: [PATCH/RFC v3 net-next] ravb: Add dma queue interrupt support

2016-01-24 Thread Yoshihiro Kaneko
Hi Sergei,

2016-01-24 7:17 GMT+09:00 Sergei Shtylyov <sergei.shtyl...@cogentembedded.com>:
> Hello.
>
> On 01/17/2016 01:55 PM, Yoshihiro Kaneko wrote:
>
>> From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>>
>> This patch supports the following interrupts.
>>
>> - One interrupt for multiple (descriptor, error, management)
>> - One interrupt for emac
>> - Four interrupts for dma queue (best effort rx/tx, network control rx/tx)
>>
>> This patch improve efficiency of the interrupt handler by adding the
>> interrupt handler corresponding to each interrupt source described
>> above. Additionally, it reduces the number of times of the access to
>> EthernetAVB IF.
>
>
>Not sure I got the last sentence right... Did you mean that we save on
> the register reads?

Yes, I meant that.

>Yet another reason could be that we don't want to depend on the boot
> loader's whim any more...
>
>> Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>> Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
>> ---
>>
>> This patch is based on the master branch of David Miller's next networking
>> tree.
>>
>> v3 [Yoshihiro Kaneko]
>> * compile tested only
>
>
>Doesn't sound very encouraging... couldn't you manage to re-test the
> patch before Dave merges it?

I will talk to Simon Horman.

>
> [...]
>>
>> diff --git a/drivers/net/ethernet/renesas/ravb.h
>> b/drivers/net/ethernet/renesas/ravb.h
>> index 9fbe92a..385f06b 100644
>> --- a/drivers/net/ethernet/renesas/ravb.h
>> +++ b/drivers/net/ethernet/renesas/ravb.h
>
> [...]
>>
>> @@ -556,6 +566,18 @@ enum ISS_BIT {
>> ISS_DPS15   = 0x8000,
>>   };
>>
>> +/* CIE
>> + * R-Car Gen3 only
>> + */
>
>
>I'd be more happy with one line comment like:
>
> /* CIE (R-Car Gen3 only) */

Agreed.

>
> [...]
>>
>> @@ -592,6 +614,212 @@ enum GIS_BIT {
>> GIS_PTMF= 0x0004,
>>   };
>>
>> +/* GIE
>> + * R-Car Gen3 only
>> + */
>> +enum GIE_BIT {
>
> [...]
>>
>> +   GIE_ALL = 0x03ff,
>
>
>GIE_ALL isn't used, no need to define it.

Agreed.

>
>> +};
>> +
>> +/* GID
>> + * R-Car Gen3 only
>> + */
>> +enum GID_BIT {
>
> [...]
>>
>> +   GID_ALL = 0x03ff,
>
>
>Not used any more.
>
>> +};
>> +
>> +/* RIE0
>> + * R-Car Gen3 only
>> + */
>> +enum RIE0_BIT {
>
> [...]
>>
>> +   RIE0_ALL= 0x0003,
>
>
>Likewise.
>
>> +};
>> +
>> +/* RID0
>> + * R-Car Gen3 only
>> + */
>> +enum RID0_BIT {
>
> [...]
>>
>> +   RID0_ALL= 0x0003,
>
>
>Likewise.
>
>> +};
>> +
>> +/* RIE2
>> + * R-Car Gen3 only
>> + */
>> +enum RIE2_BIT {
>
> [...]
>>
>> +   RIE2_ALL= 0x8003,
>
>
>Likewise.
>
>> +};
>> +
>> +/* RID2
>> + * R-Car Gen3 only
>> + */
>> +enum RID2_BIT {
>
>
>> +   RID2_ALL= 0x8003,
>
>
> Likewise.
>
>> +};
>> +
>> +/* TIE
>> + * R-Car Gen3 only
>> + */
>> +enum TIE_BIT {
>
> [...]
>>
>> +   TIE_ALL = 0x000f0f0f,
>
>
>Likewise.
>
>> +};
>> +
>> +/* TID
>> + * R-Car Gen3 only
>> + */
>> +enum TID_BIT {
>
> [...]
>>
>> +   TID_ALL = 0x000f0f0f,
>
>
>Likewise.
>
> [...]
>>
>> diff --git a/drivers/net/ethernet/renesas/ravb_main.c
>> b/drivers/net/ethernet/renesas/ravb_main.c
>> index ac43ed9..4c4912e0 100644
>> --- a/drivers/net/ethernet/renesas/ravb_main.c
>> +++ b/drivers/net/ethernet/renesas/ravb_main.c
>> @@ -42,6 +42,16 @@
>>  NETIF_MSG_RX_ERR | \
>>  NETIF_MSG_TX_ERR)
>>
>> +static const char *ravb_rx_irqs[NUM_RX_QUEUE] = {
>> +   "ch0", /* RAVB_BE */
>> +   "ch1", /* RAVB_NC */
>> +};
>> +
>> +static const char *ravb_tx_irqs[NUM_TX_QUEUE] = {
>> +   "ch18", /* RAVB_BE */
>> +   "ch19", /* RAVB_NC */
>> +};
>> +
>
>
>Do what you wish but I don't like these...

I think there is no problem.

>
> [...]
>>
>> @@ -693,7 +722,7 @@ static void ravb_error_interrupt(struct net_device
>> *ndev)
>> if (ri

[PATCH/RFC v4 net-next] ravb: Add dma queue interrupt support

2016-01-24 Thread Yoshihiro Kaneko
From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>

This patch supports the following interrupts.

- One interrupt for multiple (descriptor, error, management)
- One interrupt for emac
- Four interrupts for dma queue (best effort rx/tx, network control rx/tx)

This patch improve efficiency of the interrupt handler by adding the
interrupt handler corresponding to each interrupt source described
above. Additionally, it reduces the number of times of the access to
EthernetAVB IF.

Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
---

This patch is based on the master branch of David Miller's next networking
tree.

v4 [Yoshihiro Kaneko]
* compile tested only
* As suggested by Sergei Shtylyov
  drivers/net/ethernet/renesas/ravb.h:
- make two lines of comment into one line.
- remove unused definition of xxx_ALL.
  drivers/net/ethernet/renesas/ravb_main.c:
- remove unrelated change (fix indentation).
- output warning messages when napi_schedule_prep() fails in ravb_dmaq_
  interrupt() like ravb_interrupt().
- change the function name from req_irq to hook_irq.
- fix programming error in hook_irq().
- do free_irq() for rx_irqs[] and tx_irqs[] for only gen3 in out_free_
  irq label in ravb_open().

v3 [Yoshihiro Kaneko]
* compile tested only
* As suggested by Sergei Shtylyov
  - update changelog
  drivers/net/ethernet/renesas/ravb.h:
- add comments to the additional registers like CIE
  drivers/net/ethernet/renesas/ravb_main.c:
- fix the initialization of the interrupt in ravb_dmac_init()
- revert ravb_error_interrupt() because gen3 code is wrong
- change the comment "Management" in ravb_multi_interrupt()
- add a helper function for request_irq() in ravb_open()
- revert ravb_close() because atomicity is not necessary here
  drivers/net/ethernet/renesas/ravb_ptp.c:
- revert ravb_ptp_stop() because atomicity is not necessary here

v2 [Yoshihiro Kaneko]
* compile tested only
* As suggested by Sergei Shtylyov
  - add comment to CIE
  - remove comments from CIE bits
  - fix value of TIx_ALL
  - define each bits for CIE, GIE, GID, RIE0, RID0, RIE2, RID2, TIE, TID
  - reversed Christmas tree declaration ordered
  - rename _ravb_emac_interrupt() to ravb_emac_interrupt_unlocked()
  - remove unnecessary clearing of CIE
  - use a bit name corresponding to the target register, RIE0, RIE2, TIE,
TID, RID2, GID, GIE
 drivers/net/ethernet/renesas/ravb.h  | 204 ++
 drivers/net/ethernet/renesas/ravb_main.c | 207 ---
 drivers/net/ethernet/renesas/ravb_ptp.c  |  37 --
 3 files changed, 421 insertions(+), 27 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h 
b/drivers/net/ethernet/renesas/ravb.h
index 9fbe92a..28314ea 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -157,6 +157,7 @@ enum ravb_reg {
TIC = 0x0378,
TIS = 0x037C,
ISS = 0x0380,
+   CIE = 0x0384,   /* R-Car Gen3 only */
GCCR= 0x0390,
GMTT= 0x0394,
GPTC= 0x0398,
@@ -170,6 +171,15 @@ enum ravb_reg {
GCT0= 0x03B8,
GCT1= 0x03BC,
GCT2= 0x03C0,
+   GIE = 0x03CC,   /* R-Car Gen3 only */
+   GID = 0x03D0,   /* R-Car Gen3 only */
+   DIL = 0x0440,   /* R-Car Gen3 only */
+   RIE0= 0x0460,   /* R-Car Gen3 only */
+   RID0= 0x0464,   /* R-Car Gen3 only */
+   RIE2= 0x0470,   /* R-Car Gen3 only */
+   RID2= 0x0474,   /* R-Car Gen3 only */
+   TIE = 0x0478,   /* R-Car Gen3 only */
+   TID = 0x047c,   /* R-Car Gen3 only */
 
/* E-MAC registers */
ECMR= 0x0500,
@@ -556,6 +566,16 @@ enum ISS_BIT {
ISS_DPS15   = 0x8000,
 };
 
+/* CIE (R-Car Gen3 only) */
+enum CIE_BIT {
+   CIE_CRIE= 0x0001,
+   CIE_CTIE= 0x0100,
+   CIE_RQFM= 0x0001,
+   CIE_CL0M= 0x0002,
+   CIE_RFWL= 0x0004,
+   CIE_RFFL= 0x0008,
+};
+
 /* GCCR */
 enum GCCR_BIT {
GCCR_TCR= 0x0003,
@@ -592,6 +612,188 @@ enum GIS_BIT {
GIS_PTMF= 0x0004,
 };
 
+/* GIE (R-Car Gen3 only) */
+enum GIE_BIT {
+   GIE_PTCS= 0x0001,
+   GIE_PTOS= 0x0002,
+   GIE_PTMS0   = 0x0004,
+   GIE_PTMS1   = 0x0008,
+   GIE_PTMS2   = 0x0010,
+   GIE_PTMS3   = 0x0020,
+   GIE_PTMS4   = 0x0040,
+   GIE_PTMS5   = 0x0080,
+   GIE_PTMS6   = 0x0100,
+   GIE_PTMS7   = 0x0200,
+   GIE_ATCS0   = 0x0001,
+   GIE_ATCS1   = 0x0002,
+   GIE_ATCS2   = 0x0004,
+   GIE_ATCS3   = 0x0008,
+   GIE_ATCS4   = 0

Re: [PATCH/RFC v2 net-next] ravb: Add dma queue interrupt support

2015-12-26 Thread Yoshihiro Kaneko
Hello,

2015-12-23 0:02 GMT+09:00 Sergei Shtylyov <sergei.shtyl...@cogentembedded.com>:
> Hello.
>
> On 12/20/2015 12:15 PM, Yoshihiro Kaneko wrote:
>
>> From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>>
>> This patch supports the following interrupts.
>>
>> - One interrupt for multiple (descriptor, error, management)
>> - One interrupt for emac
>> - Four interrupts for dma queue (best effort rx/tx, network control rx/tx)
>
>
>You still don't say why it's better than the current scheme...

I missed the comment for some reason.
I will think about updating the changelog.

>
>
>> Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>> Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
>> ---
>>
>> This patch is based on the master branch of David Miller's next networking
>> tree.
>>
>> v2 [Yoshihiro Kaneko]
>> * compile tested only
>> * As suggested by Sergei Shtylyov
>>- add comment to CIE
>>- remove comments from CIE bits
>>- fix value of TIx_ALL
>>- define each bits for CIE, GIE, GID, RIE0, RID0, RIE2, RID2, TIE, TID
>>- reversed Christmas tree declaration ordered
>>- rename _ravb_emac_interrupt() to ravb_emac_interrupt_unlocked()
>>- remove unnecessary clearing of CIE
>>- use a bit name corresponding to the target register, RIE0, RIE2, TIE,
>>  TID, RID2, GID, GIE
>>
>>   drivers/net/ethernet/renesas/ravb.h  | 213
>> ++
>>   drivers/net/ethernet/renesas/ravb_main.c | 247
>> +++
>>   drivers/net/ethernet/renesas/ravb_ptp.c  |  45 --
>>   3 files changed, 464 insertions(+), 41 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/renesas/ravb.h
>> b/drivers/net/ethernet/renesas/ravb.h
>> index 9fbe92a..71badd6d 100644
>> --- a/drivers/net/ethernet/renesas/ravb.h
>> +++ b/drivers/net/ethernet/renesas/ravb.h
>> @@ -157,6 +157,7 @@ enum ravb_reg {
>> TIC = 0x0378,
>> TIS = 0x037C,
>> ISS = 0x0380,
>> +   CIE = 0x0384,   /* R-Car Gen3 only */
>> GCCR= 0x0390,
>> GMTT= 0x0394,
>> GPTC= 0x0398,
>> @@ -170,6 +171,15 @@ enum ravb_reg {
>> GCT0= 0x03B8,
>> GCT1= 0x03BC,
>> GCT2= 0x03C0,
>> +   GIE = 0x03CC,
>> +   GID = 0x03D0,
>> +   DIL = 0x0440,
>> +   RIE0= 0x0460,
>> +   RID0= 0x0464,
>> +   RIE2= 0x0470,
>> +   RID2= 0x0474,
>> +   TIE = 0x0478,
>> +   TID = 0x047c,
>
>
>So you only commented on CIE and considered it done? :-)

I will add comment to the added things above as well.

>
> [...]
>
>> @@ -411,14 +422,27 @@ static int ravb_dmac_init(struct net_device *ndev)
>> ravb_write(ndev, TCCR_TFEN, TCCR);
>>
>> /* Interrupt init: */
>> -   /* Frame receive */
>> -   ravb_write(ndev, RIC0_FRE0 | RIC0_FRE1, RIC0);
>> -   /* Disable FIFO full warning */
>> -   ravb_write(ndev, 0, RIC1);
>> -   /* Receive FIFO full error, descriptor empty */
>> -   ravb_write(ndev, RIC2_QFE0 | RIC2_QFE1 | RIC2_RFFE, RIC2);
>> -   /* Frame transmitted, timestamp FIFO updated */
>> -   ravb_write(ndev, TIC_FTE0 | TIC_FTE1 | TIC_TFUE, TIC);
>> +   if (priv->chip_id == RCAR_GEN2) {
>> +   /* Frame receive */
>> +   ravb_write(ndev, RIC0_FRE0 | RIC0_FRE1, RIC0);
>> +   /* Disable FIFO full warning */
>> +   ravb_write(ndev, 0, RIC1);
>> +   /* Receive FIFO full error, descriptor empty */
>> +   ravb_write(ndev, RIC2_QFE0 | RIC2_QFE1 | RIC2_RFFE, RIC2);
>> +   /* Frame transmitted, timestamp FIFO updated */
>> +   ravb_write(ndev, TIC_FTE0 | TIC_FTE1 | TIC_TFUE, TIC);
>> +   } else {
>> +   /* Clear DIL.DPLx */
>> +   ravb_write(ndev, 0, DIL);
>> +   /* Set queue specific interrupt */
>> +   ravb_write(ndev, CIE_CRIE | CIE_CTIE | CIE_CL0M, CIE);
>> +   /* Frame receive */
>> +   ravb_write(ndev, RIE0_FRS0 | RIE0_FRS1, RIE0);
>> +   /* Receive FIFO full error, descriptor empty */
>> +   ravb_write(ndev, RIE2_QFS0 | RIE2_QFS1 | RIE2_RFFS, RIE2);
>> +   /* Frame transmitted, timestamp FIFO updated */
>> +   ravb_write(ndev, TIE_

Re: [PATCH/RFC net-next] ravb: Add dma queue interrupt support

2015-12-20 Thread Yoshihiro Kaneko
Hi,

2015-12-18 2:42 GMT+09:00 Sergei Shtylyov <sergei.shtyl...@cogentembedded.com>:
> Hello.
>
> On 12/17/2015 07:29 PM, Yoshihiro Kaneko wrote:
>
>>>> From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>>>>
>>>> This patch supports the following interrupts.
>>>>
>>>> - One interrupt for multiple (descriptor, error, management)
>>>> - One interrupt for emac
>>>> - Four interrupts for dma queue (best effort rx/tx, network control
>>>> rx/tx)
>>>
>>>
>>>
>>> You don't say why the current 2-interrupt scheme (implemented by
>>> Simon's
>>> patch) isn't enpough...
>>>
>>>> Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>>>> Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
>>>
>>>
>>> [...]
>>>
>>>> diff --git a/drivers/net/ethernet/renesas/ravb.h
>>>> b/drivers/net/ethernet/renesas/ravb.h
>>>> index 9fbe92a..eada5a1 100644
>>>> --- a/drivers/net/ethernet/renesas/ravb.h
>>>> +++ b/drivers/net/ethernet/renesas/ravb.h
>>>> @@ -157,6 +157,7 @@ enum ravb_reg {
>
> [...]
>>>>
>>>> +#define RAVB_RIx2_ALL  0x8003
>>>
>>>
>>> No prefix. And there's bit 31 in this register, according to my gen3
>>> manual. So, your _ALL isn't really "all bits". I'd rather call it
>>> RIx2_QFx.
>>> Or even RIE2_QFS and RID2_QFD.
>>
>>
>> I think that bit 31 is included in the value 0x8003. Or I'm
>> missing something?
>
>
>Sorry, I misread the code.
>
>>>> +
>>>> +/* TIx */
>>>
>>>
>>> TIE/TID.
>>>
>>>> +#define RAVB_TIx_ALL   0x000f
>>>
>>>
>>> No prefix. And there's bit 31 in this register, according to my gen3
>>> manual.
>
>
>Oops, no bit 31 in these regs.
>
>> So, your _ALL isn't really "all bits".
>>
>> I think the correct value is 0x000f0f0f.
>
>
>Indeed, please fix.
>
>>> [...]
>>>>
>>>>
>>>> diff --git a/drivers/net/ethernet/renesas/ravb_main.c
>>>> b/drivers/net/ethernet/renesas/ravb_main.c
>>>> index 120cc25..753b67d 100644
>>>> --- a/drivers/net/ethernet/renesas/ravb_main.c
>>>> +++ b/drivers/net/ethernet/renesas/ravb_main.c
>
> [...]
>>>>
>>>> @@ -654,7 +679,7 @@ static int ravb_stop_dma(struct net_device *ndev)
>>>>}
>>>>
>>>>/* E-MAC interrupt handler */
>>>> -static void ravb_emac_interrupt(struct net_device *ndev)
>>>> +static void _ravb_emac_interrupt(struct net_device *ndev)
>>>
>>>
>>>
>>> ravb_emac_interrupt_[un]locked() perhaps? Not sure which is more
>>> correct... :-)
>>
>>
>> How about ravb_process_emac_interrupt() ?
>
>
>I've made up my mind -- I'd prefer ravb_emac_interrupt_unlocked().

Got it.

>
> [...]
>>>>
>>>> +static irqreturn_t ravb_multi_interrupt(int irq, void *dev_id)
>>>> +{
>>>> +   struct net_device *ndev = dev_id;
>>>> +   struct ravb_private *priv = netdev_priv(ndev);
>>>> +   irqreturn_t result = IRQ_NONE;
>>>> +   u32 iss;
>>>> +
>>>> +   spin_lock(>lock);
>>>> +   /* Get interrupt status */
>>>> +   iss = ravb_read(ndev, ISS);
>>>> +
>>>>  /* Error status summary */
>>>>  if (iss & ISS_ES) {
>>>>  ravb_error_interrupt(ndev);
>>>>  result = IRQ_HANDLED;
>>>>  }
>>>>
>>>> +   /* Management */
>>>
>>>
>>>
>>> Really? I thought that's gPTP Interrupt...
>>
>>
>> gPTP seems to be a part of Management related interrupts.
>
>
>ISS.CGIM is still described as gPTP interrupt mirror in my gen3 manual.

It is true.
And also gPTP interrupt belongs to the interrupt Group 2, Management
related interrupt.

>
>>>>  if (iss & ISS_CGIS)
>>>>  result = ravb_ptp_interrupt(ndev);
>>>>
>>>> @@ -776,6 +843,55 @@ static irqreturn_t ravb_interrupt(int irq, void
>>>> *dev_id)
>
> [...]
>
>> Thanks,
>> kaneko
>
>
> MBR, Sergei
>

Thanks,
kaneko
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH/RFC v2 net-next] ravb: Add dma queue interrupt support

2015-12-20 Thread Yoshihiro Kaneko
From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>

This patch supports the following interrupts.

- One interrupt for multiple (descriptor, error, management)
- One interrupt for emac
- Four interrupts for dma queue (best effort rx/tx, network control rx/tx)

Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
---

This patch is based on the master branch of David Miller's next networking
tree.

v2 [Yoshihiro Kaneko]
* compile tested only
* As suggested by Sergei Shtylyov
  - add comment to CIE
  - remove comments from CIE bits
  - fix value of TIx_ALL
  - define each bits for CIE, GIE, GID, RIE0, RID0, RIE2, RID2, TIE, TID
  - reversed Christmas tree declaration ordered
  - rename _ravb_emac_interrupt() to ravb_emac_interrupt_unlocked()
  - remove unnecessary clearing of CIE
  - use a bit name corresponding to the target register, RIE0, RIE2, TIE,
TID, RID2, GID, GIE

 drivers/net/ethernet/renesas/ravb.h  | 213 ++
 drivers/net/ethernet/renesas/ravb_main.c | 247 +++
 drivers/net/ethernet/renesas/ravb_ptp.c  |  45 --
 3 files changed, 464 insertions(+), 41 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h 
b/drivers/net/ethernet/renesas/ravb.h
index 9fbe92a..71badd6d 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -157,6 +157,7 @@ enum ravb_reg {
TIC = 0x0378,
TIS = 0x037C,
ISS = 0x0380,
+   CIE = 0x0384,   /* R-Car Gen3 only */
GCCR= 0x0390,
GMTT= 0x0394,
GPTC= 0x0398,
@@ -170,6 +171,15 @@ enum ravb_reg {
GCT0= 0x03B8,
GCT1= 0x03BC,
GCT2= 0x03C0,
+   GIE = 0x03CC,
+   GID = 0x03D0,
+   DIL = 0x0440,
+   RIE0= 0x0460,
+   RID0= 0x0464,
+   RIE2= 0x0470,
+   RID2= 0x0474,
+   TIE = 0x0478,
+   TID = 0x047c,
 
/* E-MAC registers */
ECMR= 0x0500,
@@ -556,6 +566,17 @@ enum ISS_BIT {
ISS_DPS15   = 0x8000,
 };
 
+/* CIE */
+/* R-Car Gen3 only */
+enum CIE_BIT {
+   CIE_CRIE= 0x0001,
+   CIE_CTIE= 0x0100,
+   CIE_RQFM= 0x0001,
+   CIE_CL0M= 0x0002,
+   CIE_RFWL= 0x0004,
+   CIE_RFFL= 0x0008,
+};
+
 /* GCCR */
 enum GCCR_BIT {
GCCR_TCR= 0x0003,
@@ -592,6 +613,196 @@ enum GIS_BIT {
GIS_PTMF= 0x0004,
 };
 
+/* GIE */
+enum GIE_BIT {
+   GIE_PTCS= 0x0001,
+   GIE_PTOS= 0x0002,
+   GIE_PTMS0   = 0x0004,
+   GIE_PTMS1   = 0x0008,
+   GIE_PTMS2   = 0x0010,
+   GIE_PTMS3   = 0x0020,
+   GIE_PTMS4   = 0x0040,
+   GIE_PTMS5   = 0x0080,
+   GIE_PTMS6   = 0x0100,
+   GIE_PTMS7   = 0x0200,
+   GIE_ATCS0   = 0x0001,
+   GIE_ATCS1   = 0x0002,
+   GIE_ATCS2   = 0x0004,
+   GIE_ATCS3   = 0x0008,
+   GIE_ATCS4   = 0x0010,
+   GIE_ATCS5   = 0x0020,
+   GIE_ATCS6   = 0x0040,
+   GIE_ATCS7   = 0x0080,
+   GIE_ATCS8   = 0x0100,
+   GIE_ATCS9   = 0x0200,
+   GIE_ATCS10  = 0x0400,
+   GIE_ATCS11  = 0x0800,
+   GIE_ATCS12  = 0x1000,
+   GIE_ATCS13  = 0x2000,
+   GIE_ATCS14  = 0x4000,
+   GIE_ATCS15  = 0x8000,
+   GIE_ALL = 0x03ff,
+};
+
+/* GID */
+enum GID_BIT {
+   GID_PTCD= 0x0001,
+   GID_PTOD= 0x0002,
+   GID_PTMD0   = 0x0004,
+   GID_PTMD1   = 0x0008,
+   GID_PTMD2   = 0x0010,
+   GID_PTMD3   = 0x0020,
+   GID_PTMD4   = 0x0040,
+   GID_PTMD5   = 0x0080,
+   GID_PTMD6   = 0x0100,
+   GID_PTMD7   = 0x0200,
+   GID_ATCD0   = 0x0001,
+   GID_ATCD1   = 0x0002,
+   GID_ATCD2   = 0x0004,
+   GID_ATCD3   = 0x0008,
+   GID_ATCD4   = 0x0010,
+   GID_ATCD5   = 0x0020,
+   GID_ATCD6   = 0x0040,
+   GID_ATCD7   = 0x0080,
+   GID_ATCD8   = 0x0100,
+   GID_ATCD9   = 0x0200,
+   GID_ATCD10  = 0x0400,
+   GID_ATCD11  = 0x0800,
+   GID_ATCD12  = 0x1000,
+   GID_ATCD13  = 0x2000,
+   GID_ATCD14  = 0x4000,
+   GID_ATCD15  = 0x8000,
+   GID_ALL = 0x03ff,
+};
+
+/* RIE0 */
+enum RIE0_BIT {
+   RIE0_FRS0   = 0x0001,
+   RIE0_FRS1   = 0x0002,
+   RIE0_FRS2   = 0x0004,
+   RIE0_FRS3   = 0x0008,
+   RIE0_FRS4   = 0x0010,
+   RIE0_FRS5   = 0x0020,

Re: [PATCH/RFC net-next] ravb: Add dma queue interrupt support

2015-12-17 Thread Yoshihiro Kaneko
Hi,

2015-12-16 4:00 GMT+09:00 Sergei Shtylyov <sergei.shtyl...@cogentembedded.com>:
> Hello.
>
> On 12/15/2015 03:23 PM, Yoshihiro Kaneko wrote:
>
>> From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>>
>> This patch supports the following interrupts.
>>
>> - One interrupt for multiple (descriptor, error, management)
>> - One interrupt for emac
>> - Four interrupts for dma queue (best effort rx/tx, network control rx/tx)
>
>
>You don't say why the current 2-interrupt scheme (implemented by Simon's
> patch) isn't enpough...
>
>> Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>> Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
>
> [...]
>
>> diff --git a/drivers/net/ethernet/renesas/ravb.h
>> b/drivers/net/ethernet/renesas/ravb.h
>> index 9fbe92a..eada5a1 100644
>> --- a/drivers/net/ethernet/renesas/ravb.h
>> +++ b/drivers/net/ethernet/renesas/ravb.h
>> @@ -157,6 +157,7 @@ enum ravb_reg {
>> TIC = 0x0378,
>> TIS = 0x037C,
>> ISS = 0x0380,
>> +   CIE = 0x0384,
>
>
>I'd like to see some comment clarifying that this is R-Car gen3 only reg.
>
> [./..]
>>
>> @@ -556,6 +566,16 @@ enum ISS_BIT {
>> ISS_DPS15   = 0x8000,
>>   };
>>
>> +/* CIE */
>
>
>And here as well.
>
>> +enum CIE_BIT {
>> +   CIE_CRIE= 0x0001, /* Common Receive Interrupt Enable
>> */
>> +   CIE_CTIE= 0x0100, /* Common Transmit Interrupt Enable
>> */
>> +   CIE_RQFM= 0x0001, /* Reception Queue Full Mode */
>> +   CIE_CL0M= 0x0002, /* Common Line 0 Mode */
>> +   CIE_RFWL= 0x0004, /* Rx-FIFO Warning interrupt Line */
>
>
>You forgot "Select" at the end.
>
>> +   CIE_RFFL= 0x0008, /* Rx-FIFO Full interrupt Line */
>
>
>Here as well.
>Well, generally we don't have such comments for the other registers, so
> this will look somewhat out of line...

I agree. I will remove those comment.

>
> [...]
>>
>> @@ -592,6 +612,18 @@ enum GIS_BIT {
>> GIS_PTMF= 0x0004,
>>   };
>>
>> +/* GIx */
>
>
>I'd prefer GIC/GIS.
>
>> +#define RAVB_GIx_ALL   0x03ff
>
>
>No RAVB_ prefix please.
>
>> +
>> +/* RIx0 */
>
>
>RIE0/RID0.
>
>> +#define RAVB_RIx0_ALL  0x0003
>
>
>No prefix. And I'd rather call it RIx0_FRx. Or even RIE0_FRS and
> RID0_FRD.
>
>> +
>> +/* RIx2 */
>
>
>RIE2/RID2.
>
>> +#define RAVB_RIx2_ALL  0x8003
>
>
>No prefix. And there's bit 31 in this register, according to my gen3
> manual. So, your _ALL isn't really "all bits". I'd rather call it RIx2_QFx.
> Or even RIE2_QFS and RID2_QFD.

I think that bit 31 is included in the value 0x8003. Or I'm
missing something?

>
>> +
>> +/* TIx */
>
>
>TIE/TID.
>
>> +#define RAVB_TIx_ALL   0x000f
>
>
>No prefix. And there's bit 31 in this register, according to my gen3
> manual. So, your _ALL isn't really "all bits".

I think the correct value is 0x000f0f0f.

>
> [...]
>>
>> diff --git a/drivers/net/ethernet/renesas/ravb_main.c
>> b/drivers/net/ethernet/renesas/ravb_main.c
>> index 120cc25..753b67d 100644
>> --- a/drivers/net/ethernet/renesas/ravb_main.c
>> +++ b/drivers/net/ethernet/renesas/ravb_main.c
>
> [...]
>>
>> @@ -376,6 +386,7 @@ static void ravb_emac_init(struct net_device *ndev)
>>   static int ravb_dmac_init(struct net_device *ndev)
>>   {
>> int error;
>> +   struct ravb_private *priv = netdev_priv(ndev);
>
>
>Please declare this variable before 'error' -- DaveM really prefers
> "reversed Christmas tree" declaration order.
>
> [...]
>>
>> @@ -411,14 +422,28 @@ static int ravb_dmac_init(struct net_device *ndev)
>> ravb_write(ndev, TCCR_TFEN, TCCR);
>>
>> /* Interrupt init: */
>> -   /* Frame receive */
>> -   ravb_write(ndev, RIC0_FRE0 | RIC0_FRE1, RIC0);
>> -   /* Disable FIFO full warning */
>> -   ravb_write(ndev, 0, RIC1);
>> -   /* Receive FIFO full error, descriptor empty */
>> -   ravb_write(ndev, RIC2_QFE0 | RIC2_QFE1 | RIC2_RFFE, RIC2);
>> -   /* Frame transmitted, timestamp FIFO updated */
>> -   ravb_write(ndev, TIC_FTE0 | TIC_FTE1 | TIC_TFUE, TIC);
>> +   if (priv->chip_id == RCAR_GEN2) {
>> +  

Re: [PATCH net-next] ravb: Add fixed-link support

2015-12-15 Thread Yoshihiro Kaneko
Hi,

2015-12-14 6:00 GMT+09:00 Sergei Shtylyov <sergei.shtyl...@cogentembedded.com>:
> Hello.
>
> On 12/13/2015 06:16 PM, Yoshihiro Kaneko wrote:
>
>> From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>>
>> This patch adds support of the fixed PHY.
>> This patch is based on commit 87009814cdbb ("ucc_geth: use the new fixed
>> PHY helpers").
>>
>> Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>> Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
>> ---
>>
>> This patch is based on the master branch of David Miller's next networking
>> tree.
>>
>>   drivers/net/ethernet/renesas/ravb_main.c | 12 
>>   1 file changed, 12 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/renesas/ravb_main.c
>> b/drivers/net/ethernet/renesas/ravb_main.c
>> index 1cf1226..300acb3 100644
>> --- a/drivers/net/ethernet/renesas/ravb_main.c
>> +++ b/drivers/net/ethernet/renesas/ravb_main.c
>
> [...]
>>
>> @@ -887,6 +888,17 @@ static int ravb_phy_init(struct net_device *ndev)
>>
>> /* Try connecting to PHY */
>> pn = of_parse_phandle(np, "phy-handle", 0);
>> +   if (!pn) {
>> +   /* In the case of a fixed PHY, the DT node associated
>> +* to the PHY is the Ethernet MAC DT node.
>> +*/
>> +   if (of_phy_is_fixed_link(np)) {
>> +   err = of_phy_register_fixed_link(np);
>> +   if (err)
>> +   return err;
>> +   }
>> +   pn = np;
>
>
>I'm seeing that other drivers call of_node_get() here, why don't you?

Thanks.
I sent v2.

>
> [...]
>
> MBR, Sergei
>

Thanks,
kaneko
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH/RFC net-next] ravb: Add dma queue interrupt support

2015-12-15 Thread Yoshihiro Kaneko
From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>

This patch supports the following interrupts.

- One interrupt for multiple (descriptor, error, management)
- One interrupt for emac
- Four interrupts for dma queue (best effort rx/tx, network control rx/tx)

Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
---

This patch is based on the master branch of David Miller's next networking
tree.

 drivers/net/ethernet/renesas/ravb.h  |  34 +
 drivers/net/ethernet/renesas/ravb_main.c | 248 +++
 drivers/net/ethernet/renesas/ravb_ptp.c  |  42 --
 3 files changed, 283 insertions(+), 41 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h 
b/drivers/net/ethernet/renesas/ravb.h
index 9fbe92a..eada5a1 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -157,6 +157,7 @@ enum ravb_reg {
TIC = 0x0378,
TIS = 0x037C,
ISS = 0x0380,
+   CIE = 0x0384,
GCCR= 0x0390,
GMTT= 0x0394,
GPTC= 0x0398,
@@ -170,6 +171,15 @@ enum ravb_reg {
GCT0= 0x03B8,
GCT1= 0x03BC,
GCT2= 0x03C0,
+   GIE = 0x03CC,
+   GID = 0x03D0,
+   DIL = 0x0440,
+   RIE0= 0x0460,
+   RID0= 0x0464,
+   RIE2= 0x0470,
+   RID2= 0x0474,
+   TIE = 0x0478,
+   TID = 0x047c,
 
/* E-MAC registers */
ECMR= 0x0500,
@@ -556,6 +566,16 @@ enum ISS_BIT {
ISS_DPS15   = 0x8000,
 };
 
+/* CIE */
+enum CIE_BIT {
+   CIE_CRIE= 0x0001, /* Common Receive Interrupt Enable */
+   CIE_CTIE= 0x0100, /* Common Transmit Interrupt Enable */
+   CIE_RQFM= 0x0001, /* Reception Queue Full Mode */
+   CIE_CL0M= 0x0002, /* Common Line 0 Mode */
+   CIE_RFWL= 0x0004, /* Rx-FIFO Warning interrupt Line */
+   CIE_RFFL= 0x0008, /* Rx-FIFO Full interrupt Line */
+};
+
 /* GCCR */
 enum GCCR_BIT {
GCCR_TCR= 0x0003,
@@ -592,6 +612,18 @@ enum GIS_BIT {
GIS_PTMF= 0x0004,
 };
 
+/* GIx */
+#define RAVB_GIx_ALL   0x03ff
+
+/* RIx0 */
+#define RAVB_RIx0_ALL  0x0003
+
+/* RIx2 */
+#define RAVB_RIx2_ALL  0x8003
+
+/* TIx */
+#define RAVB_TIx_ALL   0x000f
+
 /* ECMR */
 enum ECMR_BIT {
ECMR_PRM= 0x0001,
@@ -817,6 +849,8 @@ struct ravb_private {
int duplex;
int emac_irq;
enum ravb_chip_id chip_id;
+   int rx_irqs[NUM_RX_QUEUE];
+   int tx_irqs[NUM_TX_QUEUE];
 
unsigned no_avb_link:1;
unsigned avb_link_active_low:1;
diff --git a/drivers/net/ethernet/renesas/ravb_main.c 
b/drivers/net/ethernet/renesas/ravb_main.c
index 120cc25..753b67d 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -42,6 +42,16 @@
 NETIF_MSG_RX_ERR | \
 NETIF_MSG_TX_ERR)
 
+static const char *ravb_rx_irqs[NUM_RX_QUEUE] = {
+   "ch0", /* RAVB_BE */
+   "ch1", /* RAVB_NC */
+};
+
+static const char *ravb_tx_irqs[NUM_TX_QUEUE] = {
+   "ch18", /* RAVB_BE */
+   "ch19", /* RAVB_NC */
+};
+
 int ravb_wait(struct net_device *ndev, enum ravb_reg reg, u32 mask, u32 value)
 {
int i;
@@ -376,6 +386,7 @@ static void ravb_emac_init(struct net_device *ndev)
 static int ravb_dmac_init(struct net_device *ndev)
 {
int error;
+   struct ravb_private *priv = netdev_priv(ndev);
 
/* Set CONFIG mode */
error = ravb_config(ndev);
@@ -411,14 +422,28 @@ static int ravb_dmac_init(struct net_device *ndev)
ravb_write(ndev, TCCR_TFEN, TCCR);
 
/* Interrupt init: */
-   /* Frame receive */
-   ravb_write(ndev, RIC0_FRE0 | RIC0_FRE1, RIC0);
-   /* Disable FIFO full warning */
-   ravb_write(ndev, 0, RIC1);
-   /* Receive FIFO full error, descriptor empty */
-   ravb_write(ndev, RIC2_QFE0 | RIC2_QFE1 | RIC2_RFFE, RIC2);
-   /* Frame transmitted, timestamp FIFO updated */
-   ravb_write(ndev, TIC_FTE0 | TIC_FTE1 | TIC_TFUE, TIC);
+   if (priv->chip_id == RCAR_GEN2) {
+   /* Frame receive */
+   ravb_write(ndev, RIC0_FRE0 | RIC0_FRE1, RIC0);
+   /* Disable FIFO full warning */
+   ravb_write(ndev, 0, RIC1);
+   /* Receive FIFO full error, descriptor empty */
+   ravb_write(ndev, RIC2_QFE0 | RIC2_QFE1 | RIC2_RFFE, RIC2);
+   /* Frame transmitted, timestamp FIFO updated */
+   ravb_write(ndev, TIC_FTE0 | TIC_FTE1 | TIC_TFUE, TIC);
+   } else {
+   /* Clear CIE.CTIE, CIE.CRIE, DIL.DPLx */
+   ravb_write(ndev, 0, CIE);
+   ravb_write(ndev, 0, DIL);
+   /* Set queue specific inte

[PATCH v2 net-next] ravb: Add fixed-link support

2015-12-15 Thread Yoshihiro Kaneko
From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>

This patch adds support of the fixed PHY.
This patch is based on commit 87009814cdbb ("ucc_geth: use the new fixed
PHY helpers").

Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
---

This patch is based on the master branch of David Miller's next networking
tree.

v2 [Yoshihiro Kaneko]
* compile tested only
* As suggested by Sergei Shtylyov
  - use of_node_get() to increment refcount.

 drivers/net/ethernet/renesas/ravb_main.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c 
b/drivers/net/ethernet/renesas/ravb_main.c
index 120cc25..3448eb0 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -882,6 +882,7 @@ static int ravb_phy_init(struct net_device *ndev)
struct ravb_private *priv = netdev_priv(ndev);
struct phy_device *phydev;
struct device_node *pn;
+   int err;
 
priv->link = 0;
priv->speed = 0;
@@ -889,6 +890,17 @@ static int ravb_phy_init(struct net_device *ndev)
 
/* Try connecting to PHY */
pn = of_parse_phandle(np, "phy-handle", 0);
+   if (!pn) {
+   /* In the case of a fixed PHY, the DT node associated
+* to the PHY is the Ethernet MAC DT node.
+*/
+   if (of_phy_is_fixed_link(np)) {
+   err = of_phy_register_fixed_link(np);
+   if (err)
+   return err;
+   }
+   pn = of_node_get(np);
+   }
phydev = of_phy_connect(ndev, pn, ravb_adjust_link, 0,
priv->phy_interface);
if (!phydev) {
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 net] ravb: clear RIC1 in init instead of stop

2015-12-14 Thread Yoshihiro Kaneko
From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>

AVB-DMAC Receive FIFO Warning interrupt is not enabled, so it is not
necessary to disable the interrupt in ravb_close().
On the other hand, this patch disables the interrupt in ravb_dmac_init() to
prevent the possibility that the interrupt is issued by the state that
a boot loader left.

Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
---

This patch is based on the master branch of David Miller's networking
tree.

v3 [Yoshihiro Kaneko]
* compile tested only
* As suggested by Sergei Shtylyov
  - update the subject to reflect what this patch is doing.
  - clear RIC1 in ravb_dmac_init() instead of ravb_open().

v2 [Yoshihiro Kaneko]
* compile tested only
* As suggested by Sergei Shtylyov
  - clear RIC1 in ndo_open() to disable the interrupt regardless of
a left state from a bootloader.

 drivers/net/ethernet/renesas/ravb_main.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c 
b/drivers/net/ethernet/renesas/ravb_main.c
index b69e0c2..b76303e 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -405,9 +405,11 @@ static int ravb_dmac_init(struct net_device *ndev)
/* Timestamp enable */
ravb_write(ndev, TCCR_TFEN, TCCR);
 
-   /* Interrupt enable: */
+   /* Interrupt init: */
/* Frame receive */
ravb_write(ndev, RIC0_FRE0 | RIC0_FRE1, RIC0);
+   /* Disable FIFO full warning */
+   ravb_write(ndev, 0, RIC1);
/* Receive FIFO full error, descriptor empty */
ravb_write(ndev, RIC2_QFE0 | RIC2_QFE1 | RIC2_RFFE, RIC2);
/* Frame transmitted, timestamp FIFO updated */
@@ -1471,7 +1473,6 @@ static int ravb_close(struct net_device *ndev)
 
/* Disable interrupts by clearing the interrupt masks. */
ravb_write(ndev, 0, RIC0);
-   ravb_write(ndev, 0, RIC1);
ravb_write(ndev, 0, RIC2);
ravb_write(ndev, 0, TIC);
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 net] ravb: Remove clear unhandled interrupt

2015-12-14 Thread Yoshihiro Kaneko
Hi,

2015-12-14 1:25 GMT+09:00 Sergei Shtylyov <sergei.shtyl...@cogentembedded.com>:
> Hello.
>
> On 12/13/2015 06:12 PM, Yoshihiro Kaneko wrote:
>
>The subject doesn't seem to reflect what the patch is doing.
>
>
>> From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>>
>> AVB-DMAC Receive FIFO Warning interrupt is not enabled, so it is not
>> necessary to disable the interrupt in ndo_close().
>> On the other hand, this patch disables the interrupt in ndo_open() to
>> prevent the possibility that the interrupt is issued by the state that
>> a boot loader left.
>>
>> Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>> Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
>> ---
>>
>> This patch is based on the master branch of David Miller's networking
>> tree.
>>
>> v2 [Yoshihiro Kaneko]
>> * compile tested only
>> * As suggested by Sergei Shtylyov
>>- clear RIC1 in ndo_open() to disable the interrupt regardless of
>>  a left state from a bootloader.
>>
>>
>>   drivers/net/ethernet/renesas/ravb_main.c | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/renesas/ravb_main.c
>> b/drivers/net/ethernet/renesas/ravb_main.c
>> index b69e0c2..5e34a88 100644
>> --- a/drivers/net/ethernet/renesas/ravb_main.c
>> +++ b/drivers/net/ethernet/renesas/ravb_main.c
>> @@ -1228,6 +1228,9 @@ static int ravb_open(struct net_device *ndev)
>> goto out_free_irq2;
>> ravb_emac_init(ndev);
>>
>> +   /* Disable unhandled interrupt */
>> +   ravb_write(ndev, 0, RIC1);
>> +
>
>
>Oh, I thought the interrupt masks are programmed here but they are set in
> ravb_dmac_init() that this function calls. Please do it there instead (where
> it was originally done).

done.

>
> [...]
>
> MBR, Sergei
>

Thanks,
kaneko
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 net] ravb: Remove clear unhandled interrupt

2015-12-13 Thread Yoshihiro Kaneko
From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>

AVB-DMAC Receive FIFO Warning interrupt is not enabled, so it is not
necessary to disable the interrupt in ndo_close().
On the other hand, this patch disables the interrupt in ndo_open() to
prevent the possibility that the interrupt is issued by the state that
a boot loader left.

Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
---

This patch is based on the master branch of David Miller's networking
tree.

v2 [Yoshihiro Kaneko]
* compile tested only
* As suggested by Sergei Shtylyov
  - clear RIC1 in ndo_open() to disable the interrupt regardless of
a left state from a bootloader.


 drivers/net/ethernet/renesas/ravb_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c 
b/drivers/net/ethernet/renesas/ravb_main.c
index b69e0c2..5e34a88 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -1228,6 +1228,9 @@ static int ravb_open(struct net_device *ndev)
goto out_free_irq2;
ravb_emac_init(ndev);
 
+   /* Disable unhandled interrupt */
+   ravb_write(ndev, 0, RIC1);
+
/* Initialise PTP Clock driver */
ravb_ptp_init(ndev, priv->pdev);
 
@@ -1471,7 +1474,6 @@ static int ravb_close(struct net_device *ndev)
 
/* Disable interrupts by clearing the interrupt masks. */
ravb_write(ndev, 0, RIC0);
-   ravb_write(ndev, 0, RIC1);
ravb_write(ndev, 0, RIC2);
ravb_write(ndev, 0, TIC);
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net] ravb: Add disable 10base

2015-12-13 Thread Yoshihiro Kaneko
From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>

Ethernet AVB does not support 10 Mbps transfer speed.

Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
---

This patch is based on the master branch of David Miller's networking
tree.

 drivers/net/ethernet/renesas/ravb_main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c 
b/drivers/net/ethernet/renesas/ravb_main.c
index b69e0c2..467d416 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -905,6 +905,9 @@ static int ravb_phy_init(struct net_device *ndev)
netdev_info(ndev, "limited PHY to 100Mbit/s\n");
}
 
+   /* 10BASE is not supported */
+   phydev->supported &= ~PHY_10BT_FEATURES;
+
netdev_info(ndev, "attached PHY %d (IRQ %d) to driver %s\n",
phydev->addr, phydev->irq, phydev->drv->name);
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next] ravb: Add fixed-link support

2015-12-13 Thread Yoshihiro Kaneko
From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>

This patch adds support of the fixed PHY.
This patch is based on commit 87009814cdbb ("ucc_geth: use the new fixed
PHY helpers").

Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
---

This patch is based on the master branch of David Miller's next networking
tree.

 drivers/net/ethernet/renesas/ravb_main.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c 
b/drivers/net/ethernet/renesas/ravb_main.c
index 1cf1226..300acb3 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -880,6 +880,7 @@ static int ravb_phy_init(struct net_device *ndev)
struct ravb_private *priv = netdev_priv(ndev);
struct phy_device *phydev;
struct device_node *pn;
+   int err;
 
priv->link = 0;
priv->speed = 0;
@@ -887,6 +888,17 @@ static int ravb_phy_init(struct net_device *ndev)
 
/* Try connecting to PHY */
pn = of_parse_phandle(np, "phy-handle", 0);
+   if (!pn) {
+   /* In the case of a fixed PHY, the DT node associated
+* to the PHY is the Ethernet MAC DT node.
+*/
+   if (of_phy_is_fixed_link(np)) {
+   err = of_phy_register_fixed_link(np);
+   if (err)
+   return err;
+   }
+   pn = np;
+   }
phydev = of_phy_connect(ndev, pn, ravb_adjust_link, 0,
priv->phy_interface);
if (!phydev) {
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH net-next] ravb: ptp: fix misplaced ravb_ptp_stop() calling in ravb_probe()

2015-12-13 Thread Yoshihiro Kaneko
2015-12-09 23:20 GMT+09:00 Sergei Shtylyov <sergei.shtyl...@cogentembedded.com>:
> Hello.
>
> On 12/8/2015 9:39 PM, Yoshihiro Kaneko wrote:
>
>> 'commit  ("ravb: ptp: Add CONFIG mode support")' added
>> a calling of ravb_ptp_stop() in a wrong place in ravb_probe().
>>
>> Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
>
>
>Well, this patch is good to apply anyway:

I thought that the interrupt should be disabled before freeing memory.
anyway, thanks.

>
> Acked-by: Sergei Shtylyov <sergei.shtyl...@cogentembedded.com>
>
> MBR, Sergei
>
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next] ravb: ptp: fix misplaced ravb_ptp_stop() calling in ravb_probe()

2015-12-08 Thread Yoshihiro Kaneko
'commit  ("ravb: ptp: Add CONFIG mode support")' added
a calling of ravb_ptp_stop() in a wrong place in ravb_probe().

Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
---

This patch is based on the master branch of David Miller's next networking
tree.

Compile tested only.

 drivers/net/ethernet/renesas/ravb_main.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c 
b/drivers/net/ethernet/renesas/ravb_main.c
index 1cf1226..93be519 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -1875,12 +1875,12 @@ out_napi_del:
netif_napi_del(>napi[RAVB_BE]);
ravb_mdio_release(priv);
 out_dma_free:
-   dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat,
- priv->desc_bat_dma);
-
/* Stop PTP Clock driver */
if (chip_id != RCAR_GEN2)
ravb_ptp_stop(ndev);
+
+   dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat,
+ priv->desc_bat_dma);
 out_release:
if (ndev)
free_netdev(ndev);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH net-next] ravb: ptp: Add CONFIG mode support

2015-12-07 Thread Yoshihiro Kaneko
Hello Sergei,

2015-12-07 4:19 GMT+09:00 Sergei Shtylyov <sergei.shtyl...@cogentembedded.com>:
> Hello.
>
> On 12/05/2015 01:01 PM, Yoshihiro Kaneko wrote:
>
>> Thanks for your review.
>
>
>From now on, it'll be my duty. :-)

Thank you always for your help.

>
>> 2015-12-04 6:09 GMT+09:00 Sergei Shtylyov
>> <sergei.shtyl...@cogentembedded.com>:
>>>
>>> Hello.
>>>
>>> On 12/01/2015 08:04 PM, Yoshihiro Kaneko wrote:
>>>
>>>> From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>>>>
>>>> This patch makes PTP support active in CONFIG mode on R-Car Gen3.
>>>>
>>>> Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>>>> Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
>>>> ---
>>>>
>>>> This patch is based on the master branch of David Miller's next
>>>> networking
>>>> tree.
>>>>
>>>>drivers/net/ethernet/renesas/ravb.h  |  1 +
>>>>drivers/net/ethernet/renesas/ravb_main.c | 33
>>>> +++-
>>>>2 files changed, 29 insertions(+), 5 deletions(-)
>>>>
>>>> diff --git a/drivers/net/ethernet/renesas/ravb.h
>>>> b/drivers/net/ethernet/renesas/ravb.h
>>>> index f9dee74..9fbe92a 100644
>>>> --- a/drivers/net/ethernet/renesas/ravb.h
>>>> +++ b/drivers/net/ethernet/renesas/ravb.h
>
> [...]
>
>>>> diff --git a/drivers/net/ethernet/renesas/ravb_main.c
>>>> b/drivers/net/ethernet/renesas/ravb_main.c
>>>> index 990dc55..293046d 100644
>>>> --- a/drivers/net/ethernet/renesas/ravb_main.c
>>>> +++ b/drivers/net/ethernet/renesas/ravb_main.c
>
> [...]
>>>>
>>>> @@ -1855,6 +1870,10 @@ out_napi_del:
>>>>out_dma_free:
>>>>  dma_free_coherent(ndev->dev.parent, priv->desc_bat_size,
>>>> priv->desc_bat,
>>>>priv->desc_bat_dma);
>>>> +
>>>> +   /* Stop PTP Clock driver */
>>>> +   if (chip_id != RCAR_GEN2)
>>>> +   ravb_ptp_stop(ndev);
>>>
>>>
>>>
>>> This is clearly misplaced.
>>
>>
>> It's my fault.
>
>
>Should we expect a new patch fixing this issue?

Sure, I will do.

>
> [...]
>
>> Regards,
>> Kaneko
>
>
> MBR, Sergei
>

Thanks,
Kaneko
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH net] ravb: Remove clear unhandled interrupt

2015-12-07 Thread Yoshihiro Kaneko
Hello,

2015-12-07 4:18 GMT+09:00 Sergei Shtylyov <sergei.shtyl...@cogentembedded.com>:
> Hello.
>
> On 12/06/2015 02:42 PM, Yoshihiro Kaneko wrote:
>
>> From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>>
>> AVB-DMAC Reception Warning interrupt is not enabled, so it is not
>> necessary to clear the interrupt.
>>
>> Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>> Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
>
>
>In principle I agree but perhaps we should clear RIC1 in probe() to not
> depend on a state left from a bootloader?

I think that it is a good idea.
I'll add it to v2.

>
> MBR, Sergei
>

Thanks,
Kaneko
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net] ravb: Remove clear unhandled interrupt

2015-12-06 Thread Yoshihiro Kaneko
From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>

AVB-DMAC Reception Warning interrupt is not enabled, so it is not
necessary to clear the interrupt.

Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
---

This patch is based on the master branch of David Miller's networking
tree.

 drivers/net/ethernet/renesas/ravb_main.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c 
b/drivers/net/ethernet/renesas/ravb_main.c
index ed5da4d..b8fd5a5 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -1471,7 +1471,6 @@ static int ravb_close(struct net_device *ndev)
 
/* Disable interrupts by clearing the interrupt masks. */
ravb_write(ndev, 0, RIC0);
-   ravb_write(ndev, 0, RIC1);
ravb_write(ndev, 0, RIC2);
ravb_write(ndev, 0, TIC);
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH net-next] ravb: ptp: Add CONFIG mode support

2015-12-05 Thread Yoshihiro Kaneko
Hello Sergei,

Thanks for your review.

2015-12-04 6:09 GMT+09:00 Sergei Shtylyov <sergei.shtyl...@cogentembedded.com>:
> Hello.
>
> On 12/01/2015 08:04 PM, Yoshihiro Kaneko wrote:
>
>> From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>>
>> This patch makes PTP support active in CONFIG mode on R-Car Gen3.
>>
>> Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
>> Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
>> ---
>>
>> This patch is based on the master branch of David Miller's next networking
>> tree.
>>
>>   drivers/net/ethernet/renesas/ravb.h  |  1 +
>>   drivers/net/ethernet/renesas/ravb_main.c | 33
>> +++-
>>   2 files changed, 29 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/renesas/ravb.h
>> b/drivers/net/ethernet/renesas/ravb.h
>> index f9dee74..9fbe92a 100644
>> --- a/drivers/net/ethernet/renesas/ravb.h
>> +++ b/drivers/net/ethernet/renesas/ravb.h
>> @@ -206,6 +206,7 @@ enum CCC_BIT {
>> CCC_OPC_RESET   = 0x,
>> CCC_OPC_CONFIG  = 0x0001,
>> CCC_OPC_OPERATION = 0x0002,
>> +   CCC_GAC = 0x0080,
>
>
>I'd have added a comment that it's gen3 specific.
>
> [...]
>>
>> diff --git a/drivers/net/ethernet/renesas/ravb_main.c
>> b/drivers/net/ethernet/renesas/ravb_main.c
>> index 990dc55..293046d 100644
>> --- a/drivers/net/ethernet/renesas/ravb_main.c
>> +++ b/drivers/net/ethernet/renesas/ravb_main.c
>
> [...]
>>
>> @@ -1814,6 +1825,10 @@ static int ravb_probe(struct platform_device *pdev)
>> /* Initialise HW timestamp list */
>> INIT_LIST_HEAD(>ts_skb_list);
>>
>> +   /* Initialise PTP Clock driver */
>> +   if (chip_id != RCAR_GEN2)
>> +   ravb_ptp_init(ndev, pdev);
>> +
>> /* Debug message level */
>> priv->msg_enable = RAVB_DEF_MSG_ENABLE;
>>
>> @@ -1855,6 +1870,10 @@ out_napi_del:
>>   out_dma_free:
>> dma_free_coherent(ndev->dev.parent, priv->desc_bat_size,
>> priv->desc_bat,
>>   priv->desc_bat_dma);
>> +
>> +   /* Stop PTP Clock driver */
>> +   if (chip_id != RCAR_GEN2)
>> +   ravb_ptp_stop(ndev);
>
>
>This is clearly misplaced.

It's my fault.

>
> [...]
>
> MBR, Sergei
>

Regards,
Kaneko
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next] ravb: ptp: Add CONFIG mode support

2015-12-01 Thread Yoshihiro Kaneko
From: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>

This patch makes PTP support active in CONFIG mode on R-Car Gen3.

Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi...@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
---

This patch is based on the master branch of David Miller's next networking
tree.

 drivers/net/ethernet/renesas/ravb.h  |  1 +
 drivers/net/ethernet/renesas/ravb_main.c | 33 +++-
 2 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h 
b/drivers/net/ethernet/renesas/ravb.h
index f9dee74..9fbe92a 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -206,6 +206,7 @@ enum CCC_BIT {
CCC_OPC_RESET   = 0x,
CCC_OPC_CONFIG  = 0x0001,
CCC_OPC_OPERATION = 0x0002,
+   CCC_GAC = 0x0080,
CCC_DTSR= 0x0100,
CCC_CSEL= 0x0003,
CCC_CSEL_HPB= 0x0001,
diff --git a/drivers/net/ethernet/renesas/ravb_main.c 
b/drivers/net/ethernet/renesas/ravb_main.c
index 990dc55..293046d 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -1231,7 +1231,8 @@ static int ravb_open(struct net_device *ndev)
ravb_emac_init(ndev);
 
/* Initialise PTP Clock driver */
-   ravb_ptp_init(ndev, priv->pdev);
+   if (priv->chip_id == RCAR_GEN2)
+   ravb_ptp_init(ndev, priv->pdev);
 
netif_tx_start_all_queues(ndev);
 
@@ -1244,7 +1245,8 @@ static int ravb_open(struct net_device *ndev)
 
 out_ptp_stop:
/* Stop PTP Clock driver */
-   ravb_ptp_stop(ndev);
+   if (priv->chip_id == RCAR_GEN2)
+   ravb_ptp_stop(ndev);
 out_free_irq:
free_irq(ndev->irq, ndev);
free_irq(priv->emac_irq, ndev);
@@ -1476,7 +1478,8 @@ static int ravb_close(struct net_device *ndev)
ravb_write(ndev, 0, TIC);
 
/* Stop PTP Clock driver */
-   ravb_ptp_stop(ndev);
+   if (priv->chip_id == RCAR_GEN2)
+   ravb_ptp_stop(ndev);
 
/* Set the config mode to stop the AVB-DMAC's processes */
if (ravb_stop_dma(ndev) < 0)
@@ -1781,8 +1784,16 @@ static int ravb_probe(struct platform_device *pdev)
ndev->ethtool_ops = _ethtool_ops;
 
/* Set AVB config mode */
-   ravb_write(ndev, (ravb_read(ndev, CCC) & ~CCC_OPC) | CCC_OPC_CONFIG,
-  CCC);
+   if (chip_id == RCAR_GEN2) {
+   ravb_write(ndev, (ravb_read(ndev, CCC) & ~CCC_OPC) |
+  CCC_OPC_CONFIG, CCC);
+   /* Set CSEL value */
+   ravb_write(ndev, (ravb_read(ndev, CCC) & ~CCC_CSEL) |
+  CCC_CSEL_HPB, CCC);
+   } else {
+   ravb_write(ndev, (ravb_read(ndev, CCC) & ~CCC_OPC) |
+  CCC_OPC_CONFIG | CCC_GAC | CCC_CSEL_HPB, CCC);
+   }
 
/* Set CSEL value */
ravb_write(ndev, (ravb_read(ndev, CCC) & ~CCC_CSEL) | CCC_CSEL_HPB,
@@ -1814,6 +1825,10 @@ static int ravb_probe(struct platform_device *pdev)
/* Initialise HW timestamp list */
INIT_LIST_HEAD(>ts_skb_list);
 
+   /* Initialise PTP Clock driver */
+   if (chip_id != RCAR_GEN2)
+   ravb_ptp_init(ndev, pdev);
+
/* Debug message level */
priv->msg_enable = RAVB_DEF_MSG_ENABLE;
 
@@ -1855,6 +1870,10 @@ out_napi_del:
 out_dma_free:
dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat,
  priv->desc_bat_dma);
+
+   /* Stop PTP Clock driver */
+   if (chip_id != RCAR_GEN2)
+   ravb_ptp_stop(ndev);
 out_release:
if (ndev)
free_netdev(ndev);
@@ -1869,6 +1888,10 @@ static int ravb_remove(struct platform_device *pdev)
struct net_device *ndev = platform_get_drvdata(pdev);
struct ravb_private *priv = netdev_priv(ndev);
 
+   /* Stop PTP Clock driver */
+   if (priv->chip_id != RCAR_GEN2)
+   ravb_ptp_stop(ndev);
+
dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat,
  priv->desc_bat_dma);
/* Set reset mode */
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net] ravb: remove unhandle int cause

2015-11-15 Thread Yoshihiro Kaneko
From: Masaru Nagai <masaru.nagai...@renesas.com>

This driver does not handle the AVB-DMAC Receive FIFO Warning interrupt
now, so the interrupt should not be enabled.

Signed-off-by: Masaru Nagai <masaru.nagai...@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
---

This patch is based on the master branch of David Miller's networking tree.

 drivers/net/ethernet/renesas/ravb_main.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c 
b/drivers/net/ethernet/renesas/ravb_main.c
index aa7b208..3d5c4ac 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -408,8 +408,6 @@ static int ravb_dmac_init(struct net_device *ndev)
/* Interrupt enable: */
/* Frame receive */
ravb_write(ndev, RIC0_FRE0 | RIC0_FRE1, RIC0);
-   /* Receive FIFO full warning */
-   ravb_write(ndev, RIC1_RFWE, RIC1);
/* Receive FIFO full error, descriptor empty */
ravb_write(ndev, RIC2_QFE0 | RIC2_QFE1 | RIC2_RFFE, RIC2);
/* Frame transmitted, timestamp FIFO updated */
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net] ravb: Fix int mask value overwritten issue

2015-11-13 Thread Yoshihiro Kaneko
From: Masaru Nagai <masaru.nagai...@renesas.com>

When RX/TX interrupt for Network Control queue and Best Effort queue
is issued at the same time, the interrupt mask of Network Control
queue will be reset when the mask of Best Effort queue is set.
This patch fixes this problem.

Signed-off-by: Masaru Nagai <masaru.nagai...@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0...@gmail.com>
---

This patch is based on the master branch of David Miller's networking tree.

 drivers/net/ethernet/renesas/ravb_main.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c 
b/drivers/net/ethernet/renesas/ravb_main.c
index aa7b208..7180e26 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -733,8 +733,10 @@ static irqreturn_t ravb_interrupt(int irq, void *dev_id)
((tis  & tic)  & BIT(q))) {
if (napi_schedule_prep(>napi[q])) {
/* Mask RX and TX interrupts */
-   ravb_write(ndev, ric0 & ~BIT(q), RIC0);
-   ravb_write(ndev, tic  & ~BIT(q), TIC);
+   ric0 &= ~BIT(q);
+   tic &= ~BIT(q);
+   ravb_write(ndev, ric0, RIC0);
+   ravb_write(ndev, tic, TIC);
__napi_schedule(>napi[q]);
} else {
netdev_warn(ndev,
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html