From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Kazuya Mizuguchi <kazuya.mizuguchi.ks@renesas.com>,
Simon Horman <horms+renesas@verge.net.au>,
"David S . Miller" <davem@davemloft.net>,
Sasha Levin <alexander.levin@microsoft.com>
Subject: [PATCH AUTOSEL 4.14 20/32] ravb: do not write 1 to reserved bits
Date: Mon, 8 Oct 2018 11:26:17 -0400 [thread overview]
Message-ID: <20181008152629.70812-20-sashal@kernel.org> (raw)
In-Reply-To: <20181008152629.70812-1-sashal@kernel.org>
From: Kazuya Mizuguchi <kazuya.mizuguchi.ks@renesas.com>
[ Upstream commit 2fe397a3959de8a472f165e6d152f64cb77fa2cc ]
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>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
drivers/net/ethernet/renesas/ravb.h | 5 +++++
drivers/net/ethernet/renesas/ravb_main.c | 11 ++++++-----
drivers/net/ethernet/renesas/ravb_ptp.c | 2 +-
3 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index 96a27b00c90e..897bd33c2c50 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -431,6 +431,7 @@ enum EIS_BIT {
EIS_CULF1 = 0x00000080,
EIS_TFFF = 0x00000100,
EIS_QFS = 0x00010000,
+ EIS_RESERVED = (GENMASK(31, 17) | GENMASK(15, 11)),
};
/* RIC0 */
@@ -475,6 +476,7 @@ enum RIS0_BIT {
RIS0_FRF15 = 0x00008000,
RIS0_FRF16 = 0x00010000,
RIS0_FRF17 = 0x00020000,
+ RIS0_RESERVED = GENMASK(31, 18),
};
/* RIC1 */
@@ -531,6 +533,7 @@ enum RIS2_BIT {
RIS2_QFF16 = 0x00010000,
RIS2_QFF17 = 0x00020000,
RIS2_RFFF = 0x80000000,
+ RIS2_RESERVED = GENMASK(30, 18),
};
/* TIC */
@@ -547,6 +550,7 @@ enum TIS_BIT {
TIS_FTF1 = 0x00000002, /* Undocumented? */
TIS_TFUF = 0x00000100,
TIS_TFWF = 0x00000200,
+ TIS_RESERVED = (GENMASK(31, 20) | GENMASK(15, 12) | GENMASK(7, 4))
};
/* ISS */
@@ -620,6 +624,7 @@ enum GIC_BIT {
enum GIS_BIT {
GIS_PTCF = 0x00000001, /* Undocumented? */
GIS_PTMF = 0x00000004,
+ GIS_RESERVED = GENMASK(15, 10),
};
/* GIE (R-Car Gen3 only) */
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index e87a779bfcfe..ff3a293ffe36 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -721,10 +721,11 @@ static void ravb_error_interrupt(struct net_device *ndev)
u32 eis, ris2;
eis = ravb_read(ndev, EIS);
- ravb_write(ndev, ~EIS_QFS, EIS);
+ ravb_write(ndev, ~(EIS_QFS | EIS_RESERVED), EIS);
if (eis & EIS_QFS) {
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 */
if (ris2 & RIS2_QFF0)
@@ -777,7 +778,7 @@ static bool ravb_timestamp_interrupt(struct net_device *ndev)
u32 tis = ravb_read(ndev, TIS);
if (tis & TIS_TFUF) {
- ravb_write(ndev, ~TIS_TFUF, TIS);
+ ravb_write(ndev, ~(TIS_TFUF | TIS_RESERVED), TIS);
ravb_get_tx_tstamp(ndev);
return true;
}
@@ -912,7 +913,7 @@ static int ravb_poll(struct napi_struct *napi, int budget)
/* Processing RX Descriptor Ring */
if (ris0 & mask) {
/* Clear RX interrupt */
- ravb_write(ndev, ~mask, RIS0);
+ ravb_write(ndev, ~(mask | RIS0_RESERVED), RIS0);
if (ravb_rx(ndev, "a, q))
goto out;
}
@@ -920,7 +921,7 @@ static int ravb_poll(struct napi_struct *napi, int budget)
if (tis & mask) {
spin_lock_irqsave(&priv->lock, flags);
/* Clear TX interrupt */
- ravb_write(ndev, ~mask, TIS);
+ ravb_write(ndev, ~(mask | TIS_RESERVED), TIS);
ravb_tx_free(ndev, q, true);
netif_wake_subqueue(ndev, q);
mmiowb();
diff --git a/drivers/net/ethernet/renesas/ravb_ptp.c b/drivers/net/ethernet/renesas/ravb_ptp.c
index eede70ec37f8..9e3222fd69f9 100644
--- a/drivers/net/ethernet/renesas/ravb_ptp.c
+++ b/drivers/net/ethernet/renesas/ravb_ptp.c
@@ -319,7 +319,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)
--
2.17.1
next prev parent reply other threads:[~2018-10-08 15:26 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-08 15:25 [PATCH AUTOSEL 4.14 01/32] media: af9035: prevent buffer overflow on write Sasha Levin
2018-10-08 15:25 ` [PATCH AUTOSEL 4.14 02/32] batman-adv: Avoid probe ELP information leak Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.14 03/32] batman-adv: Fix segfault when writing to throughput_override Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.14 04/32] batman-adv: Fix segfault when writing to sysfs elp_interval Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.14 05/32] batman-adv: Prevent duplicated gateway_node entry Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.14 06/32] batman-adv: Prevent duplicated nc_node entry Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.14 07/32] batman-adv: Prevent duplicated softif_vlan entry Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.14 08/32] batman-adv: Prevent duplicated global TT entry Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.14 09/32] batman-adv: Prevent duplicated tvlv handler Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.14 10/32] batman-adv: fix backbone_gw refcount on queue_work() failure Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.14 11/32] batman-adv: fix hardif_neigh " Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.14 12/32] clocksource/drivers/ti-32k: Add CLOCK_SOURCE_SUSPEND_NONSTOP flag for non-am43 SoCs Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.14 13/32] ucma: fix a use-after-free in ucma_resolve_ip() Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.14 14/32] scsi: ibmvscsis: Fix a stringop-overflow warning Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.14 15/32] scsi: ibmvscsis: Ensure partition name is properly NUL terminated Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.14 16/32] intel_th: pci: Add Ice Lake PCH support Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.14 17/32] Input: atakbd - fix Atari keymap Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.14 18/32] Input: atakbd - fix Atari CapsLock behaviour Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.14 19/32] net: emac: fix fixed-link setup for the RTL8363SB switch Sasha Levin
2018-10-08 15:26 ` Sasha Levin [this message]
2018-10-08 15:26 ` [PATCH AUTOSEL 4.14 21/32] bnxt_en: don't try to offload VLAN 'modify' action Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.14 22/32] PCI: dwc: Fix scheduling while atomic issues Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.14 23/32] drm: mali-dp: Call drm_crtc_vblank_reset on device init Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.14 24/32] scsi: ipr: System hung while dlpar adding primary ipr adapter back Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.14 25/32] scsi: sd: don't crash the host on invalid commands Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.14 26/32] net/mlx4: Use cpumask_available for eq->affinity_mask Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.14 27/32] clocksource/drivers/fttmr010: Fix set_next_event handler Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.14 28/32] net: aquantia: memory corruption on jumbo frames Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.14 29/32] RISC-V: include linux/ftrace.h in asm-prototypes.h Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.14 30/32] powerpc/tm: Fix userspace r13 corruption Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.14 31/32] powerpc/tm: Avoid possible userspace r1 corruption on reclaim Sasha Levin
2018-10-08 15:26 ` [PATCH AUTOSEL 4.14 32/32] iommu/amd: Return devid as alias for ACPI HID devices Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181008152629.70812-20-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=alexander.levin@microsoft.com \
--cc=davem@davemloft.net \
--cc=horms+renesas@verge.net.au \
--cc=kazuya.mizuguchi.ks@renesas.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox