Skip to content

Commit 2fe397a

Browse files
KAZUMIZUdavem330
authored andcommitted
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: Kazuya Mizuguchi <kazuya.mizuguchi.ks@renesas.com> Signed-off-by: Simon Horman <horms+renesas@verge.net.au> Reviewed-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 65fac4f commit 2fe397a

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

drivers/net/ethernet/renesas/ravb.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ enum EIS_BIT {
428428
EIS_CULF1 = 0x00000080,
429429
EIS_TFFF = 0x00000100,
430430
EIS_QFS = 0x00010000,
431+
EIS_RESERVED = (GENMASK(31, 17) | GENMASK(15, 11)),
431432
};
432433

433434
/* RIC0 */
@@ -472,6 +473,7 @@ enum RIS0_BIT {
472473
RIS0_FRF15 = 0x00008000,
473474
RIS0_FRF16 = 0x00010000,
474475
RIS0_FRF17 = 0x00020000,
476+
RIS0_RESERVED = GENMASK(31, 18),
475477
};
476478

477479
/* RIC1 */
@@ -528,6 +530,7 @@ enum RIS2_BIT {
528530
RIS2_QFF16 = 0x00010000,
529531
RIS2_QFF17 = 0x00020000,
530532
RIS2_RFFF = 0x80000000,
533+
RIS2_RESERVED = GENMASK(30, 18),
531534
};
532535

533536
/* TIC */
@@ -544,6 +547,7 @@ enum TIS_BIT {
544547
TIS_FTF1 = 0x00000002, /* Undocumented? */
545548
TIS_TFUF = 0x00000100,
546549
TIS_TFWF = 0x00000200,
550+
TIS_RESERVED = (GENMASK(31, 20) | GENMASK(15, 12) | GENMASK(7, 4))
547551
};
548552

549553
/* ISS */
@@ -617,6 +621,7 @@ enum GIC_BIT {
617621
enum GIS_BIT {
618622
GIS_PTCF = 0x00000001, /* Undocumented? */
619623
GIS_PTMF = 0x00000004,
624+
GIS_RESERVED = GENMASK(15, 10),
620625
};
621626

622627
/* GIE (R-Car Gen3 only) */

drivers/net/ethernet/renesas/ravb_main.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -739,10 +739,11 @@ static void ravb_error_interrupt(struct net_device *ndev)
739739
u32 eis, ris2;
740740

741741
eis = ravb_read(ndev, EIS);
742-
ravb_write(ndev, ~EIS_QFS, EIS);
742+
ravb_write(ndev, ~(EIS_QFS | EIS_RESERVED), EIS);
743743
if (eis & EIS_QFS) {
744744
ris2 = ravb_read(ndev, RIS2);
745-
ravb_write(ndev, ~(RIS2_QFF0 | RIS2_RFFF), RIS2);
745+
ravb_write(ndev, ~(RIS2_QFF0 | RIS2_RFFF | RIS2_RESERVED),
746+
RIS2);
746747

747748
/* Receive Descriptor Empty int */
748749
if (ris2 & RIS2_QFF0)
@@ -795,7 +796,7 @@ static bool ravb_timestamp_interrupt(struct net_device *ndev)
795796
u32 tis = ravb_read(ndev, TIS);
796797

797798
if (tis & TIS_TFUF) {
798-
ravb_write(ndev, ~TIS_TFUF, TIS);
799+
ravb_write(ndev, ~(TIS_TFUF | TIS_RESERVED), TIS);
799800
ravb_get_tx_tstamp(ndev);
800801
return true;
801802
}
@@ -930,15 +931,15 @@ static int ravb_poll(struct napi_struct *napi, int budget)
930931
/* Processing RX Descriptor Ring */
931932
if (ris0 & mask) {
932933
/* Clear RX interrupt */
933-
ravb_write(ndev, ~mask, RIS0);
934+
ravb_write(ndev, ~(mask | RIS0_RESERVED), RIS0);
934935
if (ravb_rx(ndev, &quota, q))
935936
goto out;
936937
}
937938
/* Processing TX Descriptor Ring */
938939
if (tis & mask) {
939940
spin_lock_irqsave(&priv->lock, flags);
940941
/* Clear TX interrupt */
941-
ravb_write(ndev, ~mask, TIS);
942+
ravb_write(ndev, ~(mask | TIS_RESERVED), TIS);
942943
ravb_tx_free(ndev, q, true);
943944
netif_wake_subqueue(ndev, q);
944945
mmiowb();

drivers/net/ethernet/renesas/ravb_ptp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ void ravb_ptp_interrupt(struct net_device *ndev)
315315
}
316316
}
317317

318-
ravb_write(ndev, ~gis, GIS);
318+
ravb_write(ndev, ~(gis | GIS_RESERVED), GIS);
319319
}
320320

321321
void ravb_ptp_init(struct net_device *ndev, struct platform_device *pdev)

0 commit comments

Comments
 (0)