net: stmmac: Add support for MDIO interrupts
Subsystems (4)
PATCH v2 1/1 net: stmmac: Add support for MDIO interrupts
From: "Chuah, Kim Tatt" <[email protected]>
DW EQoS v5.xx controllers added capability for interrupt generation when MDIO interface is done (GMII Busy bit is cleared). This patch adds support for this interrupt on supported HW to avoid polling on GMII Busy bit.
stmmac_mdio_read() & stmmac_mdio_write() will sleep until wake_up() is called by the interrupt handler.
drivers/net/ethernet/stmicro/stmmac/common.h +2 -0
@@ -448,6 +448,8 @@ struct mac_device_info {unsigned int pcs;unsigned int pmt;unsigned int ps; +bool mdio_intr_en; +wait_queue_head_t mdio_busy_wait; };struct stmmac_rx_routing {
drivers/net/ethernet/stmicro/stmmac/dwmac4.h +1 -0
@@ -106,6 +106,7 @@ enum dwmac4_irq_status { mmc_irq =0x00000100 , lpi_irq =0x00000020 , pmt_irq =0x00000010 , + mdio_irq = 0x00040000, };/* MAC PMT bitmap */
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +7 -0
@@ -59,6 +59,9 @@ static void dwmac4_core_init(struct mac_device_info *hw,if (hw->pcs) value |=GMAC_PCS_IRQ_DEFAULT ; +if (hw->mdio_intr_en) + value |=GMAC_INT_MDIO_EN ; +writel (value, ioaddr +GMAC_INT_EN ); }
@@ -629,6 +632,9 @@ static int dwmac4_irq_status(struct mac_device_info *hw, x->irq_rx_path_exit_lpi_mode_n++; } +if (intr_status & mdio_irq) +wake_up (&hw->mdio_busy_wait); +dwmac_pcs_isr (ioaddr,GMAC_PCS_BASE , intr_status, x);if (intr_status &PCS_RGSMIIIS_IRQ )dwmac4_phystatus (ioaddr, x);
@@ -836,6 +842,7 @@ static void dwmac4_set_mac_loopback(void __iomem *ioaddr, bool enable) .rxp_config = dwmac5_rxp_config, .flex_pps_config = dwmac5_flex_pps_config, .set_mac_loopback = dwmac4_set_mac_loopback, + .mdio_intr_dis = dwmac5_mdio_intr_dis, };int dwmac4_setup (struct stmmac_priv *priv)
drivers/net/ethernet/stmicro/stmmac/dwmac5.c +8 -0
@@ -549,3 +549,11 @@ int dwmac5_flex_pps_config(void __iomem *ioaddr, int index,writel (val, ioaddr +MAC_PPS_CONTROL );return 0 ; } + +void dwmac5_mdio_intr_dis (void __iomem *ioaddr) +{ +u32 val =readl (ioaddr +GMAC_INT_EN ); + + val &= ~GMAC_INT_MDIO_EN ; +writel (val, ioaddr +GMAC_INT_EN ); +}
drivers/net/ethernet/stmicro/stmmac/dwmac5.h +4 -0
@@ -72,6 +72,9 @@#define TCEIE BIT(0)#define DMA_ECC_INT_STATUS 0x00001088 +/* MDIO interrupt enable in MAC_Interrupt_Enable register */ +#define GMAC_INT_MDIO_EN BIT(18) +int dwmac5_safety_feat_config (void __iomem *ioaddr,unsigned int asp); int dwmac5_safety_feat_irq_status(struct net_device *ndev, void __iomem *ioaddr, unsigned int asp,
@@ -83,5 +86,6 @@ int dwmac5_rxp_config(void __iomem *ioaddr, struct stmmac_tc_entry *entries,int dwmac5_flex_pps_config (void __iomem *ioaddr,int index,struct stmmac_pps_cfg *cfg,bool enable,u32 sub_second_inc,u32 systime_flags); +void dwmac5_mdio_intr_dis (void __iomem *ioaddr);#endif /* __DWMAC5_H__ */
drivers/net/ethernet/stmicro/stmmac/hwif.c +9 -0
@@ -73,6 +73,7 @@ static int stmmac_dwmac4_quirks(struct stmmac_priv *priv)bool gmac;bool gmac4;bool xgmac; +bool mdio_intr_en;u32 min_id;const struct stmmac_regs_off regs;const void *desc;
@@ -90,6 +91,7 @@ static int stmmac_dwmac4_quirks(struct stmmac_priv *priv) .gmac = false, .gmac4 = false, .xgmac = false, + .mdio_intr_en = false, .min_id = 0, .regs = { .ptp_off = PTP_GMAC3_X_OFFSET,
@@ -108,6 +110,7 @@ static int stmmac_dwmac4_quirks(struct stmmac_priv *priv) .gmac = true, .gmac4 = false, .xgmac = false, + .mdio_intr_en = false, .min_id = 0, .regs = { .ptp_off = PTP_GMAC3_X_OFFSET,
@@ -126,6 +129,7 @@ static int stmmac_dwmac4_quirks(struct stmmac_priv *priv) .gmac = false, .gmac4 = true, .xgmac = false, + .mdio_intr_en = false, .min_id = 0, .regs = { .ptp_off = PTP_GMAC4_OFFSET,
@@ -144,6 +148,7 @@ static int stmmac_dwmac4_quirks(struct stmmac_priv *priv) .gmac = false, .gmac4 = true, .xgmac = false, + .mdio_intr_en = false, .min_id = DWMAC_CORE_4_00, .regs = { .ptp_off = PTP_GMAC4_OFFSET,
@@ -162,6 +167,7 @@ static int stmmac_dwmac4_quirks(struct stmmac_priv *priv) .gmac = false, .gmac4 = true, .xgmac = false, + .mdio_intr_en = false, .min_id = DWMAC_CORE_4_10, .regs = { .ptp_off = PTP_GMAC4_OFFSET,
@@ -180,6 +186,7 @@ static int stmmac_dwmac4_quirks(struct stmmac_priv *priv) .gmac = false, .gmac4 = true, .xgmac = false, + .mdio_intr_en = true, .min_id = DWMAC_CORE_5_10, .regs = { .ptp_off = PTP_GMAC4_OFFSET,
@@ -198,6 +205,7 @@ static int stmmac_dwmac4_quirks(struct stmmac_priv *priv) .gmac = false, .gmac4 = false, .xgmac = true, + .mdio_intr_en = false, .min_id = DWXGMAC_CORE_2_10, .regs = { .ptp_off = PTP_XGMAC_OFFSET,
@@ -276,6 +284,7 @@ int stmmac_hwif_init(struct stmmac_priv *priv) mac->mode = mac->mode ? : entry->mode; mac->tc = mac->tc ? : entry->tc; mac->mmc = mac->mmc ? : entry->mmc; + mac->mdio_intr_en = mac->mdio_intr_en ? : entry->mdio_intr_en; priv->hw = mac; priv->ptpaddr = priv->ioaddr + entry->regs.ptp_off;
drivers/net/ethernet/stmicro/stmmac/hwif.h +4 -0
@@ -363,6 +363,8 @@ struct stmmac_ops {int (*get_mac_tx_timestamp)(struct mac_device_info *hw,u64 *ts);/* Source Address Insertion / Replacement */ void (*sarc_configure)(void __iomem *ioaddr,int val); +/* Disable mdio interrupt */ +void (*mdio_intr_dis)(void __iomem *ioaddr); }; #define stmmac_core_init(__priv, __args...) \
@@ -443,6 +445,8 @@ struct stmmac_ops { stmmac_do_callback(__priv, mac, get_mac_tx_timestamp, __args) #define stmmac_sarc_configure(__priv, __args...) \ stmmac_do_void_callback(__priv, mac, sarc_configure, __args) +#define stmmac_mdio_intr_dis(__priv, __args...) \ + stmmac_do_void_callback(__priv, mac, mdio_intr_dis, __args)/* PTP and HW Timer helpers */ struct stmmac_hwtimestamp {
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +5 -0
@@ -2768,6 +2768,8 @@ static int stmmac_release(struct net_device *dev)phylink_stop (priv->phylink);phylink_disconnect_phy (priv->phylink); +stmmac_mdio_intr_dis (priv, priv->ioaddr); +stmmac_stop_all_queues (priv);stmmac_disable_all_queues (priv);
@@ -4463,6 +4465,9 @@ int stmmac_dvr_probe(struct device *device,if (ret) goto error_hw_init; +/* mdio intr wait queue */ +init_waitqueue_head (&priv->hw->mdio_busy_wait); +stmmac_check_ether_addr (priv);/* Configure real RX and TX queues */
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +49 -8
112 lines not on this page · raw message
Signature · 6 lines
Changelog v2 *mdio interrupt mode or polling mode will depends on mdio interrupt enable bit *Disable the mdio interrupt enable bit in stmmac_release *Remove the condition for initialize wait queues *Applied reverse Christmas tree 1.9.1
Quoted 10 lines · Voon Weifeng
From: "Chuah, Kim Tatt" <[email protected]>
DW EQoS v5.xx controllers added capability for interrupt generation when MDIO interface is done (GMII Busy bit is cleared). This patch adds support for this interrupt on supported HW to avoid polling on GMII Busy bit.
stmmac_mdio_read()&stmmac_mdio_write()will sleep untilwake_up()is called by the interrupt handler.
Quoted 6 lines
Reviewed-by Voon Weifeng <[email protected]>Reviewed-by Kweh, Hock Leong <[email protected]>Reviewed-by Ong Boon Leong <[email protected]>Signed-off-by Chuah, Kim Tatt <[email protected]>Signed-off-by Ong Boon Leong <[email protected]>Signed-off-by Voon Weifeng <[email protected]>
Hi Voon
It is normal to include a short description of what you changed between the previous version and this version.
The formatting of this patch also looks a bit odd. Did you use git format-patch ; git send-email?
Thanks
Andrew
Quoted 18 lines · Voon Weifeng
Quoted 10 lines
From: "Chuah, Kim Tatt" <[email protected]>
DW EQoS v5.xx controllers added capability for interrupt generation when MDIO interface is done (GMII Busy bit is cleared). This patch adds support for this interrupt on supported HW to avoid polling on GMII Busy bit.
stmmac_mdio_read()&stmmac_mdio_write()will sleep untilwake_up()is called by the interrupt handler.Quoted 6 lines
Reviewed-by Voon Weifeng <[email protected]>Reviewed-by Kweh, Hock Leong <[email protected]>Reviewed-by Ong Boon Leong <[email protected]>Signed-off-by Chuah, Kim Tatt <[email protected]>Signed-off-by Ong Boon Leong <[email protected]>Signed-off-by Voon Weifeng <[email protected]>
Quoted 4 lines
Hi Voon
It is normal to include a short description of what you changed between the previous version and this version.
The change log is near the end of the patch:
/**
--
Changelog v2
*mdio interrupt mode or polling mode will depends on mdio interrupt enable bit *Disable the mdio interrupt enable bit in stmmac_release
*Remove the condition for initialize wait queues
*Applied reverse Christmas tree
1.9.1
Quoted 3 lines
The formatting of this patch also looks a bit odd. Did you use git format-patch ; git send-email?
Yes, I do git format-patch, then ./scripts/checkpatch.pl. Lastly git send-email
Quoted 3 lines
Thanks
Andrew
Quoted 10 lines
The change log is near the end of the patch:
/**
--
Changelog v2
*mdio interrupt mode or polling mode will depends on mdio interrupt enable bit *Disable the mdio interrupt enable bit instmmac_release
*Remove the condition for initialize wait queues
*Applied reverse Christmas tree
1.9.1
At the end, nobody sees it, because everybody else does it at the beginning.
This talks about the ---. David prefers to see the change log before the ---. Other maintainers want it after the ---.
Quoted 7 lines
Quoted 4 lines
The formatting of this patch also looks a bit odd. Did you use git format-patch ; git send-email?
Yes, I do git format-patch, then
./scripts/checkpatch.pl. Lastly git send-email
What looked odd is the missing --- marker. git format-patch should of create that as part of the patch.
Andrew
Quoted 24 lines
Quoted 9 lines
The change log is near the end of the patch:
/**
--
Changelog v2
*mdio interrupt mode or polling mode will depends on mdio interrupt enable bit *Disable the mdio interrupt enable bit instmmac_release*Remove the condition for initialize wait queues *Applied reverse Christmas tree
1.9.1At the end, nobody sees it, because everybody else does it at the beginning.
https://www.kernel.org/doc/html/latest/process/submitting-
patches.html?highlight=submitting#the-canonical-patch-formatThis talks about the ---. David prefers to see the change log before the ---. Other maintainers want it after the ---.
Quoted 5 lines
Quoted 4 lines
The formatting of this patch also looks a bit odd. Did you use git format-patch ; git send-email?
Quoted 7 lines
Quoted 2 lines
Yes, I do git format-patch, then
./scripts/checkpatch.pl. Lastly git send-emailWhat looked odd is the missing --- marker. git format-patch should of create that as part of the patch.
Andrew
I found out why as I did a git format-patch with -p which is without the Stat. I will resent v3 to using correct format.
Weifeng