net: aquantia: Add missing descriptor cache invalidation on ATL2
Subsystems (3)
PATCH 1/1 net: aquantia: Add missing descriptor cache invalidation on ATL2
ATL2 hardware was missing descriptor cache invalidation in hw_stop(), causing SMMU translation faults during device shutdown and module removal.
Commit 7a1bb49461b1 ("net: aquantia: fix potential IOMMU fault after driver unbind") and commit ed4d81c4b3f2 ("net: aquantia: when cleaning hw cache it should be toggled") fixed cache invalidation for ATL B0, but ATL2 was left with only interrupt disabling. This allowed hardware to write to cached descriptors after DMA memory was unmapped, triggering SMMU faults.
Add shared aq_hw_invalidate_descriptor_cache() helper and use it in both ATL B0 and ATL2 hw_stop() implementations for consistent behavior.
--- .../ethernet/aquantia/atlantic/aq_hw_utils.c | 22 +++++++++++++++++++ .../ethernet/aquantia/atlantic/aq_hw_utils.h | 1 + .../aquantia/atlantic/hw_atl/hw_atl_b0.c | 19 +--------------- .../aquantia/atlantic/hw_atl2/hw_atl2.c | 2 +- 4 files changed, 25 insertions(+), 19 deletions(-)
drivers/net/ethernet/aquantia/atlantic/aq_hw_utils.c +22 -0
@@ -15,6 +15,7 @@#include "aq_hw.h" #include "aq_nic.h" +#include "hw_atl/hw_atl_llh.h" void aq_hw_write_reg_bit (struct aq_hw_s *aq_hw,u32 addr,u32 msk,u32 shift,u32 val)
@@ -81,6 +82,27 @@ void aq_hw_write_reg64(struct aq_hw_s *hw, u32 reg, u64 value)lo_hi_writeq (value, hw->mmio + reg); } +int aq_hw_invalidate_descriptor_cache (struct aq_hw_s *hw) +{ +int err; +u32 val; + +/* Invalidate Descriptor Cache to prevent writing to the cached +* descriptors and to the data pointer of those descriptors +*/ +hw_atl_rdm_rx_dma_desc_cache_init_tgl (hw); + + err =aq_hw_err_from_flags (hw); +if (err) + goto err_exit; + +readx_poll_timeout_atomic (hw_atl_rdm_rx_dma_desc_cache_init_done_get, + hw, val, val ==1 ,1000U ,10000U ); + +err_exit: +return err; +} +int aq_hw_err_from_flags (struct aq_hw_s *hw) {int err =0 ;
drivers/net/ethernet/aquantia/atlantic/aq_hw_utils.h +1 -0
@@ -35,6 +35,7 @@ u32 aq_hw_read_reg(struct aq_hw_s *hw, u32 reg);void aq_hw_write_reg (struct aq_hw_s *hw,u32 reg,u32 value);u64 aq_hw_read_reg64 (struct aq_hw_s *hw,u32 reg);void aq_hw_write_reg64 (struct aq_hw_s *hw,u32 reg,u64 value); +int aq_hw_invalidate_descriptor_cache (struct aq_hw_s *hw);int aq_hw_err_from_flags (struct aq_hw_s *hw);int aq_hw_num_tcs (struct aq_hw_s *hw);int aq_hw_q_per_tc (struct aq_hw_s *hw);
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c +1 -18
@@ -1198,26 +1198,9 @@ static int hw_atl_b0_hw_interrupt_moderation_set(struct aq_hw_s *self)static int hw_atl_b0_hw_stop (struct aq_hw_s *self) { -int err; -u32 val; -hw_atl_b0_hw_irq_disable (self,HW_ATL_B0_INT_MASK ); -/* Invalidate Descriptor Cache to prevent writing to the cached -* descriptors and to the data pointer of those descriptors -*/ -hw_atl_rdm_rx_dma_desc_cache_init_tgl (self); - - err =aq_hw_err_from_flags (self); - -if (err) - goto err_exit; - -readx_poll_timeout_atomic (hw_atl_rdm_rx_dma_desc_cache_init_done_get, - self, val, val ==1 ,1000U ,10000U ); - -err_exit: -return err; +return aq_hw_invalidate_descriptor_cache (self); }int hw_atl_b0_hw_ring_tx_stop (struct aq_hw_s *self,struct aq_ring_s *ring)
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +1 -1
@@ -759,7 +759,7 @@ static int hw_atl2_hw_stop(struct aq_hw_s *self) {hw_atl_b0_hw_irq_disable (self,HW_ATL2_INT_MASK ); -return 0 ; +return aq_hw_invalidate_descriptor_cache (self); }static struct aq_stats_s *hw_atl2_utils_get_hw_stats (struct aq_hw_s *self)
Signature · 1 line
2.43.0
Simon Horman
reviewerQuoted 10 lines · Kai-Heng Feng
ATL2 hardware was missing descriptor cache invalidation in
hw_stop(), causing SMMU translation faults during device shutdown and module removal.Commit
7a1bb49461b1("net: aquantia: fix potential IOMMU fault after driver unbind") and commited4d81c4b3f2("net: aquantia: when cleaning hw cache it should be toggled") fixed cache invalidation for ATL B0, but ATL2 was left with only interrupt disabling. This allowed hardware to write to cached descriptors after DMA memory was unmapped, triggering SMMU faults.
Quoted 2 lines
Add shared
aq_hw_invalidate_descriptor_cache()helper and use it in both ATL B0 and ATL2hw_stop()implementations for consistent behavior.
I think it would be useful to mention how this bug was found. And what sort of testing has been conducted: compilation only, exercised on real hardware, ...
As a bug fix I think this should have a Fixes tag denoting the commit that introduced the problem. In this case, perhaps:
The fixes tag should go immediately above your signed-off-by line, with no blank lines in between.
Quoted 1 line
Signed-off-by Kai-Heng Feng <[email protected]>
And lastly, for reference: as a fix for code present in the net tree, this should be targeted at that tree, which should be denoted in the Subject like this:
Subject: [PATCH net] ...
You can see more on process for Networking patches here:
https://docs.kernel.org/process/maintainer-netdev.html
...