From a02c232336c626b96e8473f67471d2b82fc0f9d4 Mon Sep 17 00:00:00 2001 From: karl beldan Date: Sun, 14 Aug 2016 15:03:15 +0000 Subject: net: davinci_emac: Remove useless dcache ops on descriptors ATM the rx and tx descriptors are handled as cached memory while they lie in a dedicated RAM of the SoCs, which is an uncached area. Removing the said dcache ops, while optimizing the logic and clarifying the code, also gets rid of most of the check_cache_range() incurred warnings: CACHE: Misaligned operation at range Signed-off-by: Karl Beldan Acked-by: Joe Hershberger --- drivers/net/davinci_emac.c | 28 ---------------------------- 1 file changed, 28 deletions(-) (limited to 'drivers') diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c index ca457b8..c591773 100644 --- a/drivers/net/davinci_emac.c +++ b/drivers/net/davinci_emac.c @@ -108,26 +108,6 @@ static u_int8_t num_phy; phy_t phy[CONFIG_SYS_DAVINCI_EMAC_PHY_COUNT]; -static inline void davinci_flush_rx_descs(void) -{ - /* flush the whole RX descs area */ - flush_dcache_range(EMAC_WRAPPER_RAM_ADDR + EMAC_RX_DESC_BASE, - EMAC_WRAPPER_RAM_ADDR + EMAC_TX_DESC_BASE); -} - -static inline void davinci_invalidate_rx_descs(void) -{ - /* invalidate the whole RX descs area */ - invalidate_dcache_range(EMAC_WRAPPER_RAM_ADDR + EMAC_RX_DESC_BASE, - EMAC_WRAPPER_RAM_ADDR + EMAC_TX_DESC_BASE); -} - -static inline void davinci_flush_desc(emac_desc *desc) -{ - flush_dcache_range((unsigned long)desc, - (unsigned long)desc + sizeof(*desc)); -} - static int davinci_eth_set_mac_addr(struct eth_device *dev) { unsigned long mac_hi; @@ -496,8 +476,6 @@ static int davinci_eth_open(struct eth_device *dev, bd_t *bis) emac_rx_active_tail = rx_desc; emac_rx_queue_active = 1; - davinci_flush_rx_descs(); - /* Enable TX/RX */ writel(EMAC_MAX_ETHERNET_PKT_SIZE, &adap_emac->RXMAXLEN); writel(0, &adap_emac->RXBUFFEROFFSET); @@ -660,7 +638,6 @@ static int davinci_eth_send_packet (struct eth_device *dev, flush_dcache_range((unsigned long)packet, (unsigned long)packet + length); - davinci_flush_desc(emac_tx_desc); /* Send the packet */ writel(BD_TO_HW((unsigned long)emac_tx_desc), &adap_emac->TX0HDP); @@ -694,8 +671,6 @@ static int davinci_eth_rcv_packet (struct eth_device *dev) volatile emac_desc *tail_desc; int status, ret = -1; - davinci_invalidate_rx_descs(); - rx_curr_desc = emac_rx_active_head; if (!rx_curr_desc) return 0; @@ -734,7 +709,6 @@ static int davinci_eth_rcv_packet (struct eth_device *dev) rx_curr_desc->buff_off_len = EMAC_MAX_ETHERNET_PKT_SIZE; rx_curr_desc->pkt_flag_len = EMAC_CPPI_OWNERSHIP_BIT; rx_curr_desc->next = 0; - davinci_flush_desc(rx_curr_desc); if (emac_rx_active_head == 0) { printf ("INFO: emac_rcv_pkt: active queue head = 0\n"); @@ -752,13 +726,11 @@ static int davinci_eth_rcv_packet (struct eth_device *dev) tail_desc->next = BD_TO_HW((ulong) curr_desc); status = tail_desc->pkt_flag_len; if (status & EMAC_CPPI_EOQ_BIT) { - davinci_flush_desc(tail_desc); writel(BD_TO_HW((ulong)curr_desc), &adap_emac->RX0HDP); status &= ~EMAC_CPPI_EOQ_BIT; tail_desc->pkt_flag_len = status; } - davinci_flush_desc(tail_desc); } return (ret); } -- cgit v1.1 From 6202b8f28c10977a9533ba4c49574b136a64ce82 Mon Sep 17 00:00:00 2001 From: karl beldan Date: Mon, 15 Aug 2016 17:23:00 +0000 Subject: net: davinci_emac: Round up top tx buffer boundaries for dcache ops check_cache_range() warns that the top boundaries are not properly aligned when flushing or invalidating the buffers and make these operations fail. This gets rid of the remaining warnings: CACHE: Misaligned operation at range Signed-off-by: Karl Beldan Acked-by: Joe Hershberger Reviewed-by: Tom Rini Reviewed-by: Mugunthan V N --- drivers/net/davinci_emac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c index c591773..187137c 100644 --- a/drivers/net/davinci_emac.c +++ b/drivers/net/davinci_emac.c @@ -637,7 +637,7 @@ static int davinci_eth_send_packet (struct eth_device *dev, EMAC_CPPI_EOP_BIT); flush_dcache_range((unsigned long)packet, - (unsigned long)packet + length); + (unsigned long)packet + ALIGN(length, PKTALIGN)); /* Send the packet */ writel(BD_TO_HW((unsigned long)emac_tx_desc), &adap_emac->TX0HDP); -- cgit v1.1 From a51897b6c1e517ea2ce95da59784e84c5992dd00 Mon Sep 17 00:00:00 2001 From: karl beldan Date: Mon, 15 Aug 2016 17:23:01 +0000 Subject: net: davinci_emac: Invalidate only the received portion of a buffer ATM when receiving a packet the whole buffer is invalidated, this change optimizes this behaviour. Signed-off-by: Karl Beldan Acked-by: Joe Hershberger Reviewed-by: Tom Rini Reviewed-by: Mugunthan V N --- drivers/net/davinci_emac.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c index 187137c..6283487 100644 --- a/drivers/net/davinci_emac.c +++ b/drivers/net/davinci_emac.c @@ -681,12 +681,12 @@ static int davinci_eth_rcv_packet (struct eth_device *dev) printf ("WARN: emac_rcv_pkt: Error in packet\n"); } else { unsigned long tmp = (unsigned long)rx_curr_desc->buffer; + unsigned short len = + rx_curr_desc->buff_off_len & 0xffff; - invalidate_dcache_range(tmp, tmp + EMAC_RXBUF_SIZE); - net_process_received_packet( - rx_curr_desc->buffer, - rx_curr_desc->buff_off_len & 0xffff); - ret = rx_curr_desc->buff_off_len & 0xffff; + invalidate_dcache_range(tmp, tmp + ALIGN(len, PKTALIGN)); + net_process_received_packet(rx_curr_desc->buffer, len); + ret = len; } /* Ack received packet descriptor */ -- cgit v1.1 From c23c7d461fc52f03f784dee9792f8547d14e731d Mon Sep 17 00:00:00 2001 From: Hou Zhiqiang Date: Fri, 19 Aug 2016 11:35:35 +0800 Subject: net/fm: Remove unused code of FMan QMI The QMan is not used in FMan IM mode, so no QMI enqueue or QMI dequeue are performed. Signed-off-by: Hou Zhiqiang Acked-by: Joe Hershberger --- drivers/net/fm/fm.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers') diff --git a/drivers/net/fm/fm.c b/drivers/net/fm/fm.c index 00cdfd4..5eb773e 100644 --- a/drivers/net/fm/fm.c +++ b/drivers/net/fm/fm.c @@ -336,9 +336,6 @@ static int fm_init_bmi(int fm_idx, struct fm_bmi_common *bmi) static void fm_init_qmi(struct fm_qmi_common *qmi) { - /* disable enqueue and dequeue of QMI */ - clrbits_be32(&qmi->fmqm_gc, FMQM_GC_ENQ_EN | FMQM_GC_DEQ_EN); - /* disable all error interrupts */ out_be32(&qmi->fmqm_eien, FMQM_EIEN_DISABLE_ALL); /* clear all error events */ -- cgit v1.1 From 05237f735e5f325e03db8ff153cb5266e337a2fe Mon Sep 17 00:00:00 2001 From: karl beldan Date: Sat, 20 Aug 2016 08:56:53 +0000 Subject: net: davinci_emac: Restore the internal MDIO accessors return values The spatch series converting legacy drivers from miiphy_register to mdio_register changed the return convention of the davinci_emac internal MDIO accessors, making the internal code relying on it misbehaving: no mdiodev get registered and U-Boot crashes when using net cmds in the context of the old legacy net API. ATM davinci_emac_initialize and cpu_eth_init don't return a proper value in that case but fixing them would not avoid the crash. This change is just a follow-up to the spatch pass, the MDIO accessors of the mdiodev introduced by the spatch pass retain their proper values. Signed-off-by: Karl Beldan Acked-by: Joe Hershberger --- drivers/net/davinci_emac.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'drivers') diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c index 6283487..5e7ebc8 100644 --- a/drivers/net/davinci_emac.c +++ b/drivers/net/davinci_emac.c @@ -223,10 +223,10 @@ int davinci_eth_phy_read(u_int8_t phy_addr, u_int8_t reg_num, u_int16_t *data) if (tmp & MDIO_USERACCESS0_ACK) { *data = tmp & 0xffff; - return 0; + return 1; } - return -EIO; + return 0; } /* Write to a PHY register via MDIO inteface. Blocks until operation is complete. */ @@ -247,7 +247,7 @@ int davinci_eth_phy_write(u_int8_t phy_addr, u_int8_t reg_num, u_int16_t data) while (readl(&adap_mdio->USERACCESS0) & MDIO_USERACCESS0_GO) ; - return 0; + return 1; } /* PHY functions for a generic PHY */ @@ -374,15 +374,14 @@ static int davinci_mii_phy_read(struct mii_dev *bus, int addr, int devad, { unsigned short value = 0; int retval = davinci_eth_phy_read(addr, reg, &value); - if (retval < 0) - return retval; - return value; + + return retval ? value : -EIO; } static int davinci_mii_phy_write(struct mii_dev *bus, int addr, int devad, int reg, u16 value) { - return davinci_eth_phy_write(addr, reg, value); + return davinci_eth_phy_write(addr, reg, value) ? 0 : 1; } #endif -- cgit v1.1