Commit 2fe397a3 authored by Kazuya Mizuguchi's avatar Kazuya Mizuguchi Committed by David S. Miller

ravb: do not write 1 to reserved bits

EtherAVB hardware requires 0 to be written to status register bits in
order to clear them, however, care must be taken not to:

1. Clear other bits, by writing zero to them
2. Write one to reserved bits

This patch corrects the ravb driver with respect to the second point above.
This is done by defining reserved bit masks for the affected registers and,
after auditing the code, ensure all sites that may write a one to a
reserved bit use are suitably masked.
Signed-off-by: default avatarKazuya Mizuguchi <kazuya.mizuguchi.ks@renesas.com>
Signed-off-by: default avatarSimon Horman <horms+renesas@verge.net.au>
Reviewed-by: default avatarSergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 65fac4fe
...@@ -428,6 +428,7 @@ enum EIS_BIT { ...@@ -428,6 +428,7 @@ enum EIS_BIT {
EIS_CULF1 = 0x00000080, EIS_CULF1 = 0x00000080,
EIS_TFFF = 0x00000100, EIS_TFFF = 0x00000100,
EIS_QFS = 0x00010000, EIS_QFS = 0x00010000,
EIS_RESERVED = (GENMASK(31, 17) | GENMASK(15, 11)),
}; };
/* RIC0 */ /* RIC0 */
...@@ -472,6 +473,7 @@ enum RIS0_BIT { ...@@ -472,6 +473,7 @@ enum RIS0_BIT {
RIS0_FRF15 = 0x00008000, RIS0_FRF15 = 0x00008000,
RIS0_FRF16 = 0x00010000, RIS0_FRF16 = 0x00010000,
RIS0_FRF17 = 0x00020000, RIS0_FRF17 = 0x00020000,
RIS0_RESERVED = GENMASK(31, 18),
}; };
/* RIC1 */ /* RIC1 */
...@@ -528,6 +530,7 @@ enum RIS2_BIT { ...@@ -528,6 +530,7 @@ enum RIS2_BIT {
RIS2_QFF16 = 0x00010000, RIS2_QFF16 = 0x00010000,
RIS2_QFF17 = 0x00020000, RIS2_QFF17 = 0x00020000,
RIS2_RFFF = 0x80000000, RIS2_RFFF = 0x80000000,
RIS2_RESERVED = GENMASK(30, 18),
}; };
/* TIC */ /* TIC */
...@@ -544,6 +547,7 @@ enum TIS_BIT { ...@@ -544,6 +547,7 @@ enum TIS_BIT {
TIS_FTF1 = 0x00000002, /* Undocumented? */ TIS_FTF1 = 0x00000002, /* Undocumented? */
TIS_TFUF = 0x00000100, TIS_TFUF = 0x00000100,
TIS_TFWF = 0x00000200, TIS_TFWF = 0x00000200,
TIS_RESERVED = (GENMASK(31, 20) | GENMASK(15, 12) | GENMASK(7, 4))
}; };
/* ISS */ /* ISS */
...@@ -617,6 +621,7 @@ enum GIC_BIT { ...@@ -617,6 +621,7 @@ enum GIC_BIT {
enum GIS_BIT { enum GIS_BIT {
GIS_PTCF = 0x00000001, /* Undocumented? */ GIS_PTCF = 0x00000001, /* Undocumented? */
GIS_PTMF = 0x00000004, GIS_PTMF = 0x00000004,
GIS_RESERVED = GENMASK(15, 10),
}; };
/* GIE (R-Car Gen3 only) */ /* GIE (R-Car Gen3 only) */
......
...@@ -739,10 +739,11 @@ static void ravb_error_interrupt(struct net_device *ndev) ...@@ -739,10 +739,11 @@ static void ravb_error_interrupt(struct net_device *ndev)
u32 eis, ris2; u32 eis, ris2;
eis = ravb_read(ndev, EIS); eis = ravb_read(ndev, EIS);
ravb_write(ndev, ~EIS_QFS, EIS); ravb_write(ndev, ~(EIS_QFS | EIS_RESERVED), EIS);
if (eis & EIS_QFS) { if (eis & EIS_QFS) {
ris2 = ravb_read(ndev, RIS2); ris2 = ravb_read(ndev, RIS2);
ravb_write(ndev, ~(RIS2_QFF0 | RIS2_RFFF), RIS2); ravb_write(ndev, ~(RIS2_QFF0 | RIS2_RFFF | RIS2_RESERVED),
RIS2);
/* Receive Descriptor Empty int */ /* Receive Descriptor Empty int */
if (ris2 & RIS2_QFF0) if (ris2 & RIS2_QFF0)
...@@ -795,7 +796,7 @@ static bool ravb_timestamp_interrupt(struct net_device *ndev) ...@@ -795,7 +796,7 @@ static bool ravb_timestamp_interrupt(struct net_device *ndev)
u32 tis = ravb_read(ndev, TIS); u32 tis = ravb_read(ndev, TIS);
if (tis & TIS_TFUF) { if (tis & TIS_TFUF) {
ravb_write(ndev, ~TIS_TFUF, TIS); ravb_write(ndev, ~(TIS_TFUF | TIS_RESERVED), TIS);
ravb_get_tx_tstamp(ndev); ravb_get_tx_tstamp(ndev);
return true; return true;
} }
...@@ -930,7 +931,7 @@ static int ravb_poll(struct napi_struct *napi, int budget) ...@@ -930,7 +931,7 @@ static int ravb_poll(struct napi_struct *napi, int budget)
/* Processing RX Descriptor Ring */ /* Processing RX Descriptor Ring */
if (ris0 & mask) { if (ris0 & mask) {
/* Clear RX interrupt */ /* Clear RX interrupt */
ravb_write(ndev, ~mask, RIS0); ravb_write(ndev, ~(mask | RIS0_RESERVED), RIS0);
if (ravb_rx(ndev, &quota, q)) if (ravb_rx(ndev, &quota, q))
goto out; goto out;
} }
...@@ -938,7 +939,7 @@ static int ravb_poll(struct napi_struct *napi, int budget) ...@@ -938,7 +939,7 @@ static int ravb_poll(struct napi_struct *napi, int budget)
if (tis & mask) { if (tis & mask) {
spin_lock_irqsave(&priv->lock, flags); spin_lock_irqsave(&priv->lock, flags);
/* Clear TX interrupt */ /* Clear TX interrupt */
ravb_write(ndev, ~mask, TIS); ravb_write(ndev, ~(mask | TIS_RESERVED), TIS);
ravb_tx_free(ndev, q, true); ravb_tx_free(ndev, q, true);
netif_wake_subqueue(ndev, q); netif_wake_subqueue(ndev, q);
mmiowb(); mmiowb();
......
...@@ -315,7 +315,7 @@ void ravb_ptp_interrupt(struct net_device *ndev) ...@@ -315,7 +315,7 @@ void ravb_ptp_interrupt(struct net_device *ndev)
} }
} }
ravb_write(ndev, ~gis, GIS); ravb_write(ndev, ~(gis | GIS_RESERVED), GIS);
} }
void ravb_ptp_init(struct net_device *ndev, struct platform_device *pdev) void ravb_ptp_init(struct net_device *ndev, struct platform_device *pdev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment