Aquantia atlantic hot fixes 03-2018
Subsystems (3)
cover Aquantia atlantic hot fixes 03-2018
This is a set of atlantic driver hot fixes for various areas:
Some rare issues with hardware reset covered, Fixed napi_poll flood happening on some traffic conditions, Allow system to change MAC address on live device, Add pci shutdown handler.
Igor Russkikh (7):
net: aquantia: Fix hardware reset when SPI may rarely hangup
net: aquantia: Fix a regression with reset on old firmware
net: aquantia: Change inefficient wait loop on fw data reads
net: aquantia: Add aq_tx_clean_budget and valid budget handling logic
net: aquantia: Allow live mac address changes
net: aquantia: Implement pci shutdown callback
net: aquantia: driver version bump
drivers/net/ethernet/aquantia/atlantic/aq_nic.c | 26 +++++++++ drivers/net/ethernet/aquantia/atlantic/aq_nic.h | 3 + .../net/ethernet/aquantia/atlantic/aq_pci_func.c | 15 +++++ drivers/net/ethernet/aquantia/atlantic/aq_ring.c | 7 ++- drivers/net/ethernet/aquantia/atlantic/aq_ring.h | 2 +- drivers/net/ethernet/aquantia/atlantic/aq_vec.c | 7 +-- .../aquantia/atlantic/hw_atl/hw_atl_utils.c | 66 +++++++++++++++------- .../aquantia/atlantic/hw_atl/hw_atl_utils.h | 1 + drivers/net/ethernet/aquantia/atlantic/ver.h | 2 +- 9 files changed, 101 insertions(+), 28 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/7 net: aquantia: Fix hardware reset when SPI may rarely hangup
Under some circumstances (notably using thunderbolt interface) SPI on chip reset may be in active transaction.
Here we forcibly cleanup SPI to prevent possible hangups.
--- .../ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c +15 -5
@@ -80,15 +80,14 @@ int hw_atl_utils_initfw(struct aq_hw_s *self, const struct aq_fw_ops **fw_ops)static int hw_atl_utils_soft_reset_flb (struct aq_hw_s *self) {int k =0 ; -u32 gsr; +u32 gsr, val;aq_hw_write_reg (self,0x404 ,0x40e1 );AQ_HW_SLEEP (50 );/* Cleanup SPI */ -aq_hw_write_reg (self,0x534 ,0xA0 ); -aq_hw_write_reg (self,0x100 ,0x9F ); -aq_hw_write_reg (self,0x100 ,0x809F ); + val =aq_hw_read_reg (self,0x53C ); +aq_hw_write_reg (self,0x53C , val |0x10 ); gsr =aq_hw_read_reg (self,HW_ATL_GLB_SOFT_RES_ADR );aq_hw_write_reg (self,HW_ATL_GLB_SOFT_RES_ADR , (gsr &0xBFFF ) |0x8000 );
@@ -97,7 +96,14 @@ static int hw_atl_utils_soft_reset_flb(struct aq_hw_s *self)aq_hw_write_reg (self,0x404 ,0x80e0 );aq_hw_write_reg (self,0x32a8 ,0x0 );aq_hw_write_reg (self,0x520 ,0x1 ); + +/* Reset SPI again because of possible interrupted SPI burst */ + val =aq_hw_read_reg (self,0x53C ); +aq_hw_write_reg (self,0x53C , val |0x10 );AQ_HW_SLEEP (10 ); +/* Clear SPI reset state */ +aq_hw_write_reg (self,0x53C , val & ~0x10 ); +aq_hw_write_reg (self,0x404 ,0x180e0 );for (k =0 ; k <1000 ; k++) {
@@ -147,7 +153,7 @@ static int hw_atl_utils_soft_reset_flb(struct aq_hw_s *self)static int hw_atl_utils_soft_reset_rbl (struct aq_hw_s *self) { -u32 gsr, rbl_status; +u32 gsr, val, rbl_status;int k;aq_hw_write_reg (self,0x404 ,0x40e1 );
@@ -157,6 +163,10 @@ static int hw_atl_utils_soft_reset_rbl(struct aq_hw_s *self)/* Alter RBL status */ aq_hw_write_reg (self,0x388 ,0xDEAD ); +/* Cleanup SPI */ + val =aq_hw_read_reg (self,0x53C ); +aq_hw_write_reg (self,0x53C , val |0x10 ); +/* Global software reset*/ hw_atl_rx_rx_reg_res_dis_set (self,0U );hw_atl_tx_tx_reg_res_dis_set (self,0U );
Signature · 1 line
2.7.4
David Miller
maintainerRe: [PATCH net 1/7] net: aquantia: Fix hardware reset when SPI may rarely hangup
From: Igor Russkikh <[email protected]>
Date: Fri, 16 Mar 2018 13:53:44 +0300
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c int hw_atl_utils_initfw(struct aq_hw_s *self, const struct aq_fw_ops **fw_ops) · line 83
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c +1
-1@@ -80,15 +80,14 @@ int hw_atl_utils_initfw(struct aq_hw_s *self, const struct aq_fw_ops **fw_ops)static int hw_atl_utils_soft_reset_flb (struct aq_hw_s *self) {int k =0 ; -u32 gsr; +u32 gsr, val;
Please preserve the reverse christmas tree ordering (longest to shortest line) for variable declarations here.
PATCH 2/7 net: aquantia: Fix a regression with reset on old firmware
In reply to Igor RusskikhFW 1.5.58 and below needs a fixed delay even after 0x18 register is filled. Otherwise, setting MPI_INIT state too fast causes traffic hang.
--- drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c +4 -0
@@ -147,6 +147,8 @@ static int hw_atl_utils_soft_reset_flb(struct aq_hw_s *self)aq_pr_err ("FW kickstart failed\n" );return -EIO ; } +/* Old FW requires fixed delay after init */ +AQ_HW_SLEEP (15 );return 0 ; }
@@ -214,6 +216,8 @@ static int hw_atl_utils_soft_reset_rbl(struct aq_hw_s *self)aq_pr_err ("FW kickstart failed\n" );return -EIO ; } +/* Old FW requires fixed delay after init */ +AQ_HW_SLEEP (15 );return 0 ; }
Signature · 1 line
2.7.4
PATCH 3/7 net: aquantia: Change inefficient wait loop on fw data reads
In reply to Igor RusskikhB1 hardware changes behavior of mailbox interface, it has busy bit always raised. Data ready condition should be detected by increment of address register.
Old code has empty for loop, and that caused cpu overloads on B1 hardware. aq_nic_service_timer_cb consumed ~100ms because of that.
--- .../aquantia/atlantic/hw_atl/hw_atl_utils.c | 42 ++++++++++++++-------- .../aquantia/atlantic/hw_atl/hw_atl_utils.h | 1 + 2 files changed, 28 insertions(+), 15 deletions(-)
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c +27 -15
@@ -21,6 +21,10 @@#define HW_ATL_UCP_0X370_REG 0x0370U +#define HW_ATL_MIF_CMD 0x0200U +#define HW_ATL_MIF_ADDR 0x0208U +#define HW_ATL_MIF_VAL 0x020CU +#define HW_ATL_FW_SM_RAM 0x2U#define HW_ATL_MPI_FW_VERSION 0x18#define HW_ATL_MPI_CONTROL_ADR 0x0368U
@@ -269,18 +273,22 @@ int hw_atl_utils_fw_downld_dwords(struct aq_hw_s *self, u32 a, } } -aq_hw_write_reg (self,0x00000208U , a); - -for (++cnt; --cnt;) { -u32 i =0U ; +aq_hw_write_reg (self,HW_ATL_MIF_ADDR , a); -aq_hw_write_reg (self,0x00000200U ,0x00008000U ); +for (++cnt; --cnt && !err;) { +aq_hw_write_reg (self,HW_ATL_MIF_CMD ,0x00008000U ); -for (i =1024U ; - (0x100U &aq_hw_read_reg (self,0x00000200U )) && --i;) { - } +if (IS_CHIP_FEATURE (REVISION_B1 )) +AQ_HW_WAIT_FOR (a !=aq_hw_read_reg (self, +HW_ATL_MIF_ADDR ), +1 ,1000U ); +else +AQ_HW_WAIT_FOR (!(0x100 &aq_hw_read_reg (self, +HW_ATL_MIF_CMD )), +1 ,1000U ); - *(p++) =aq_hw_read_reg (self,0x0000020CU ); + *(p++) =aq_hw_read_reg (self,HW_ATL_MIF_VAL ); + a +=4 ; }hw_atl_reg_glb_cpu_sem_set (self,1U ,HW_ATL_FW_SM_RAM );
@@ -676,14 +684,18 @@ void hw_atl_utils_hw_chip_features_init(struct aq_hw_s *self, u32 *p)u32 val =hw_atl_reg_glb_mif_id_get (self);u32 mif_rev = val &0xFFU ; -if ((3U & mif_rev) ==1U ) { - chip_features |= -HAL_ATLANTIC_UTILS_CHIP_REVISION_A0 | +if ((0xFU & mif_rev) ==1U ) { + chip_features |=HAL_ATLANTIC_UTILS_CHIP_REVISION_A0 |HAL_ATLANTIC_UTILS_CHIP_MPI_AQ |HAL_ATLANTIC_UTILS_CHIP_MIPS ; - }else if ((3U & mif_rev) ==2U ) { - chip_features |= -HAL_ATLANTIC_UTILS_CHIP_REVISION_B0 | + }else if ((0xFU & mif_rev) ==2U ) { + chip_features |=HAL_ATLANTIC_UTILS_CHIP_REVISION_B0 | +HAL_ATLANTIC_UTILS_CHIP_MPI_AQ | +HAL_ATLANTIC_UTILS_CHIP_MIPS | +HAL_ATLANTIC_UTILS_CHIP_TPO2 | +HAL_ATLANTIC_UTILS_CHIP_RPF2 ; + }else if ((0xFU & mif_rev) ==0xAU ) { + chip_features |=HAL_ATLANTIC_UTILS_CHIP_REVISION_B1 |HAL_ATLANTIC_UTILS_CHIP_MPI_AQ |HAL_ATLANTIC_UTILS_CHIP_MIPS | HAL_ATLANTIC_UTILS_CHIP_TPO2 |
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h +1 -0
@@ -161,6 +161,7 @@ struct __packed hw_aq_atl_utils_mbox {#define HAL_ATLANTIC_UTILS_CHIP_MPI_AQ 0x00000010U#define HAL_ATLANTIC_UTILS_CHIP_REVISION_A0 0x01000000U#define HAL_ATLANTIC_UTILS_CHIP_REVISION_B0 0x02000000U +#define HAL_ATLANTIC_UTILS_CHIP_REVISION_B1 0x04000000U#define IS_CHIP_FEATURE (_F_) (HAL_ATLANTIC_UTILS_CHIP_##_F_ & \ self->chip_features)
Signature · 1 line
2.7.4
PATCH 4/7 net: aquantia: Add aq_tx_clean_budget and valid budget handling logic
In reply to Igor RusskikhWe should report to napi full budget only when we have more job to do. Before this fix, on any tx queue cleanup we forced napi to do poll again. Thats a waste of cpu resources and caused storming with napi polls when there was at least one tx on each interrupt.
With this fix we report full budget only when there is more job on TX to do. Or, as before, when rx budget was fully consumed.
--- drivers/net/ethernet/aquantia/atlantic/aq_nic.c | 4 ++++ drivers/net/ethernet/aquantia/atlantic/aq_nic.h | 2 ++ drivers/net/ethernet/aquantia/atlantic/aq_ring.c | 7 +++++-- drivers/net/ethernet/aquantia/atlantic/aq_ring.h | 2 +- drivers/net/ethernet/aquantia/atlantic/aq_vec.c | 7 +++---- 5 files changed, 15 insertions(+), 7 deletions(-)
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +4 -0
@@ -36,6 +36,10 @@ static unsigned int aq_itr_rx;module_param_named (aq_itr_rx, aq_itr_rx, uint,0644 );MODULE_PARM_DESC (aq_itr_rx,"RX interrupt throttle rate" ); +unsigned aq_tx_clean_budget =256 ; +module_param_named (aq_tx_clean_budget, aq_tx_clean_budget, uint,0644 ); +MODULE_PARM_DESC (aq_tx_clean_budget,"Maximum descriptors to cleanup on TX at once" ); +static void aq_nic_update_ndev_stats (struct aq_nic_s *self);static void aq_nic_rss_init (struct aq_nic_s *self,unsigned int num_rss_queues)
drivers/net/ethernet/aquantia/atlantic/aq_nic.h +2 -0
@@ -87,6 +87,8 @@ static inline struct device *aq_nic_get_dev(struct aq_nic_s *self)return self->ndev->dev.parent; } +extern unsigned aq_tx_clean_budget; +void aq_nic_ndev_init (struct aq_nic_s *self);struct aq_nic_s *aq_nic_alloc_hot (struct net_device *ndev); void aq_nic_set_tx_ring(struct aq_nic_s *self, unsigned int idx,
drivers/net/ethernet/aquantia/atlantic/aq_ring.c +5 -2
@@ -136,11 +136,12 @@ void aq_ring_queue_stop(struct aq_ring_s *ring)netif_stop_subqueue (ndev, ring->idx); } -void aq_ring_tx_clean (struct aq_ring_s *self) +bool aq_ring_tx_clean (struct aq_ring_s *self) {struct device *dev =aq_nic_get_dev (self->aq_nic); +unsigned int budget = aq_tx_clean_budget; -for (; self->sw_head != self->hw_head; +for (; self->sw_head != self->hw_head && budget--; self->sw_head =aq_ring_next_dx (self, self->sw_head)) {struct aq_ring_buff_s *buff = &self->buff_ring[self->sw_head];
@@ -167,6 +168,8 @@ void aq_ring_tx_clean(struct aq_ring_s *self) buff->pa =0U ; buff->eop_index =0xffffU ; } + +return !!budget; }#define AQ_SKB_ALIGN SKB_DATA_ALIGN(sizeof(struct skb_shared_info))
drivers/net/ethernet/aquantia/atlantic/aq_ring.h +1 -1
@@ -153,7 +153,7 @@ void aq_ring_free(struct aq_ring_s *self);void aq_ring_update_queue_state (struct aq_ring_s *ring);void aq_ring_queue_wake (struct aq_ring_s *ring);void aq_ring_queue_stop (struct aq_ring_s *ring); -void aq_ring_tx_clean (struct aq_ring_s *self); +bool aq_ring_tx_clean (struct aq_ring_s *self); int aq_ring_rx_clean(struct aq_ring_s *self, struct napi_struct *napi, int *work_done,
drivers/net/ethernet/aquantia/atlantic/aq_vec.c +3 -4
@@ -40,7 +40,7 @@ static int aq_vec_poll(struct napi_struct *napi, int budget)int err =0 ;unsigned int i =0U ;unsigned int sw_tail_old =0U ; -bool was_tx_cleaned = false; +bool was_tx_cleaned = true;if (!self) { err = -EINVAL ;
@@ -57,9 +57,8 @@ static int aq_vec_poll(struct napi_struct *napi, int budget)if (ring[AQ_VEC_TX_ID ].sw_head != ring[AQ_VEC_TX_ID ].hw_head) { -aq_ring_tx_clean (&ring[AQ_VEC_TX_ID ]); + was_tx_cleaned =aq_ring_tx_clean (&ring[AQ_VEC_TX_ID ]);aq_ring_update_queue_state (&ring[AQ_VEC_TX_ID ]); - was_tx_cleaned = true; } err = self->aq_hw_ops->hw_ring_rx_receive(self->aq_hw,
@@ -90,7 +89,7 @@ static int aq_vec_poll(struct napi_struct *napi, int budget) } } -if (was_tx_cleaned) +if (!was_tx_cleaned) work_done = budget;if (work_done < budget) {
Signature · 1 line
2.7.4
David Miller
maintainerRe: [PATCH net 4/7] net: aquantia: Add aq_tx_clean_budget and valid budget handling logic
From: Igor Russkikh <[email protected]>
Date: Fri, 16 Mar 2018 13:53:47 +0300
drivers/net/ethernet/aquantia/atlantic/aq_nic.c static unsigned int aq_itr_rx; · line 43
Quoted 13 lines
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +4
-0@@ -36,6 +36,10 @@ static unsigned int aq_itr_rx;module_param_named (aq_itr_rx, aq_itr_rx, uint,0644 );MODULE_PARM_DESC (aq_itr_rx,"RX interrupt throttle rate" ); +unsigned aq_tx_clean_budget =256 ; +module_param_named (aq_tx_clean_budget, aq_tx_clean_budget, uint,0644 ); +MODULE_PARM_DESC (aq_tx_clean_budget,"Maximum descriptors to cleanup on TX at once" ); +static void aq_nic_update_ndev_stats (struct aq_nic_s *self);
Please do not add driver private module parameter knobs like this.
Instead, please use a existing, device agnostic, runtime, configuration mechanism to control this.
Thank you.
Re: [PATCH net 4/7] net: aquantia: Add aq_tx_clean_budget and valid budget handling logic
Hi David,
Thanks for the comments.
Quoted 11 lines
drivers/net/ethernet/aquantia/atlantic/aq_nic.c static unsigned int aq_itr_rx; · line 43
Quoted 6 lines
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +4
-0+unsigned aq_tx_clean_budget =256 ; +module_param_named (aq_tx_clean_budget, aq_tx_clean_budget, uint,0644 ); +MODULE_PARM_DESC (aq_tx_clean_budget,"Maximum descriptors to cleanup on TX at once" ); +static void aq_nic_update_ndev_stats (struct aq_nic_s *self);Please do not add driver private module parameter knobs like this.
Instead, please use a existing, device agnostic, runtime, configuration mechanism to control this.
I'm not aware of any existing standard way to configure tx cleanup budget. Many drivers just have it hardcoded via define. Is that what you suggest then?
BR, Igor
David Miller
maintainerRe: [PATCH net 4/7] net: aquantia: Add aq_tx_clean_budget and valid budget handling logic
From: Igor Russkikh <[email protected]>
Date: Mon, 19 Mar 2018 14:18:55 +0300
Quoted 14 lines
Hi David,
Thanks for the comments.
Quoted 9 lines
drivers/net/ethernet/aquantia/atlantic/aq_nic.c static unsigned int aq_itr_rx; · line 43
Quoted 6 lines
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +4
-0+unsigned aq_tx_clean_budget =256 ; +module_param_named (aq_tx_clean_budget, aq_tx_clean_budget, uint,0644 ); +MODULE_PARM_DESC (aq_tx_clean_budget,"Maximum descriptors to cleanup on TX at once" ); +static void aq_nic_update_ndev_stats (struct aq_nic_s *self);Please do not add driver private module parameter knobs like this.
Quoted 5 lines
Quoted 2 lines
Instead, please use a existing, device agnostic, runtime, configuration mechanism to control this.
I'm not aware of any existing standard way to configure tx cleanup budget. Many drivers just have it hardcoded via define. Is that what you suggest then?
You can hard code it, or find some way to make ethtool support this and therefore make the configuration available generically for all drivers which may want to allow tweaking this.
PATCH 5/7 net: aquantia: Allow live mac address changes
In reply to Igor RusskikhThere is nothing prevents us from changing MAC on the running interface. Allow this with ndev priv flag.
--- drivers/net/ethernet/aquantia/atlantic/aq_nic.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +2 -0
@@ -251,6 +251,8 @@ void aq_nic_ndev_init(struct aq_nic_s *self) self->ndev->hw_features |= aq_hw_caps->hw_features; self->ndev->features = aq_hw_caps->hw_features; self->ndev->priv_flags = aq_hw_caps->hw_priv_flags; + self->ndev->priv_flags |=IFF_LIVE_ADDR_CHANGE ; + self->ndev->mtu = aq_nic_cfg->mtu -ETH_HLEN ; self->ndev->max_mtu = aq_hw_caps->mtu -ETH_FCS_LEN -ETH_HLEN ;
Signature · 1 line
2.7.4
PATCH 6/7 net: aquantia: Implement pci shutdown callback
In reply to Igor RusskikhWe should close link and all NIC operations during shutdown. On some systems graceful reboot never closes NIC interface on its own, but only indicates pci device shutdown. Without explicit handler, NIC rx rings continued to transfer DMA data into prepared buffers while CPU rebooted already. That caused memory corruptions on soft reboot.
--- drivers/net/ethernet/aquantia/atlantic/aq_nic.c | 20 ++++++++++++++++++++ drivers/net/ethernet/aquantia/atlantic/aq_nic.h | 1 + drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c | 15 +++++++++++++++ 3 files changed, 36 insertions(+)
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +20 -0
@@ -943,3 +943,23 @@ int aq_nic_change_pm_state(struct aq_nic_s *self, pm_message_t *pm_msg) out:return err; } + +void aq_nic_shutdown (struct aq_nic_s *self) +{ +int err =0 ; + +if (!self->ndev) +return ; + +rtnl_lock (); + +netif_device_detach (self->ndev); + + err =aq_nic_stop (self); +if (err <0 ) + goto err_exit; +aq_nic_deinit (self); + +err_exit: +rtnl_unlock (); +}
drivers/net/ethernet/aquantia/atlantic/aq_nic.h +1 -0
@@ -120,5 +120,6 @@ struct aq_nic_cfg_s *aq_nic_get_cfg(struct aq_nic_s *self);u32 aq_nic_get_fw_version (struct aq_nic_s *self);int aq_nic_change_pm_state (struct aq_nic_s *self,pm_message_t *pm_msg);int aq_nic_update_interrupt_moderation_settings (struct aq_nic_s *self); +void aq_nic_shutdown (struct aq_nic_s *self);#endif /* AQ_NIC_H */
drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c +15 -0
@@ -323,6 +323,20 @@ static void aq_pci_remove(struct pci_dev *pdev)pci_disable_device (pdev); } +static void aq_pci_shutdown (struct pci_dev *pdev) +{ +struct aq_nic_s *self =pci_get_drvdata (pdev); + +aq_nic_shutdown (self); + +pci_disable_device (pdev); + +if (system_state ==SYSTEM_POWER_OFF ) { +pci_wake_from_d3 (pdev, false); +pci_set_power_state (pdev, PCI_D3hot); + } +} +static int aq_pci_suspend (struct pci_dev *pdev,pm_message_t pm_msg) {struct aq_nic_s *self =pci_get_drvdata (pdev);
@@ -345,6 +359,7 @@ static struct pci_driver aq_pci_ops = { .remove = aq_pci_remove, .suspend = aq_pci_suspend, .resume = aq_pci_resume, + .shutdown = aq_pci_shutdown, };module_pci_driver (aq_pci_ops);
Signature · 1 line
2.7.4
PATCH 7/7 net: aquantia: driver version bump
In reply to Igor Russkikh--- drivers/net/ethernet/aquantia/atlantic/ver.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/aquantia/atlantic/ver.h +1 -1
@@ -13,7 +13,7 @@#define NIC_MAJOR_DRIVER_VERSION 2#define NIC_MINOR_DRIVER_VERSION 0#define NIC_BUILD_DRIVER_VERSION 2 -#define NIC_REVISION_DRIVER_VERSION 0 +#define NIC_REVISION_DRIVER_VERSION 1#define AQ_CFG_DRV_VERSION_SUFFIX "-kern"
Signature · 1 line
2.7.4