The macb debugging output printed the function entry for various functions. Especially for *_recv() this debugging flooded the serial output while conveying very little information. Remove printing of the function calls to make enabling debugging for the macb driver more useful. Signed-off-by: Michael Tretter <m.tretter@pengutronix.de> --- drivers/net/macb.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/drivers/net/macb.c b/drivers/net/macb.c index e3e039f67988..09b58ffd017f 100644 --- a/drivers/net/macb.c +++ b/drivers/net/macb.c @@ -144,8 +144,6 @@ static void reclaim_rx_buffers(struct macb_device *macb, { unsigned int i; - dev_dbg(macb->dev, "%s\n", __func__); - i = macb->rx_tail; while (i > new_tail) { macb->rx_ring[i].addr &= ~MACB_BIT(RX_USED); @@ -170,8 +168,6 @@ static int gem_recv(struct eth_device *edev) int length; u32 status; - dev_dbg(macb->dev, "%s\n", __func__); - for (;;) { barrier(); if (!(macb->rx_ring[macb->rx_tail].addr & MACB_BIT(RX_USED))) @@ -206,8 +202,6 @@ static int macb_recv(struct eth_device *edev) int wrapped = 0; u32 status; - dev_dbg(macb->dev, "%s\n", __func__); - for (;;) { barrier(); if (!(macb->rx_ring[rx_tail].addr & MACB_BIT(RX_USED))) @@ -288,8 +282,6 @@ static int macb_open(struct eth_device *edev) { struct macb_device *macb = edev->priv; - dev_dbg(macb->dev, "%s\n", __func__); - /* Enable TX and RX */ macb_writel(macb, NCR, MACB_BIT(TE) | MACB_BIT(RE)); @@ -350,8 +342,6 @@ static void macb_init(struct macb_device *macb) unsigned long paddr, val = 0; int i; - dev_dbg(macb->dev, "%s\n", __func__); - /* * macb_halt should have been called at some point before now, * so we'll assume the controller is idle. @@ -441,8 +431,6 @@ static int macb_phy_read(struct mii_bus *bus, int addr, int reg) int value; uint64_t start; - dev_dbg(macb->dev, "%s\n", __func__); - netctl = macb_readl(macb, NCR); netctl |= MACB_BIT(MPE); macb_writel(macb, NCR, netctl); @@ -478,8 +466,6 @@ static int macb_phy_write(struct mii_bus *bus, int addr, int reg, u16 value) unsigned long netctl; unsigned long frame; - dev_dbg(macb->dev, "%s\n", __func__); - netctl = macb_readl(macb, NCR); netctl |= MACB_BIT(MPE); macb_writel(macb, NCR, netctl); @@ -510,8 +496,6 @@ static int macb_get_ethaddr(struct eth_device *edev, unsigned char *adr) u8 addr[6]; int i; - dev_dbg(macb->dev, "%s\n", __func__); - /* Check all 4 address register for vaild address */ for (i = 0; i < 4; i++) { bottom = macb_or_gem_readl(macb, SA1B + i * 8); @@ -537,8 +521,6 @@ static int macb_set_ethaddr(struct eth_device *edev, const unsigned char *adr) { struct macb_device *macb = edev->priv; - dev_dbg(macb->dev, "%s\n", __func__); - /* set hardware address */ macb_or_gem_writel(macb, SA1B, adr[0] | adr[1] << 8 | adr[2] << 16 | adr[3] << 24); macb_or_gem_writel(macb, SA1T, adr[4] | adr[5] << 8); -- 2.20.1 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Changes of the link speed might require an adjustment of the clk_tx. Read the clk_tx from the device tree and change the rate if the link speed changes. If the clk_tx rate is already correct, changing the clock is not required and, thus, not being able to get the clock rate is not fatal. Signed-off-by: Michael Tretter <m.tretter@pengutronix.de> --- drivers/net/macb.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/drivers/net/macb.c b/drivers/net/macb.c index 09b58ffd017f..fa530cfe8e4c 100644 --- a/drivers/net/macb.c +++ b/drivers/net/macb.c @@ -258,9 +258,38 @@ static int macb_recv(struct eth_device *edev) return 0; } +static int macb_set_tx_clk(struct macb_device *macb, int speed) +{ + int rate; + int rate_rounded; + + if (!macb->txclk) { + dev_dbg(macb->dev, "txclk not available\n"); + return 0; + } + + switch (speed) { + case SPEED_100: + rate = 25000000; + break; + case SPEED_1000: + rate = 125000000; + break; + default: + return -EINVAL; + } + + rate_rounded = clk_round_rate(macb->txclk, rate); + if (rate_rounded <= 0) + return -EINVAL; + + return clk_set_rate(macb->txclk, rate_rounded); +} + static void macb_adjust_link(struct eth_device *edev) { struct macb_device *macb = edev->priv; + int err; u32 reg; reg = macb_readl(macb, NCFGR); @@ -276,6 +305,10 @@ static void macb_adjust_link(struct eth_device *edev) reg |= GEM_BIT(GBE); macb_or_gem_writel(macb, NCFGR, reg); + + err = macb_set_tx_clk(macb, edev->phydev->speed); + if (err) + dev_warn(macb->dev, "cannot set txclk\n"); } static int macb_open(struct eth_device *edev) @@ -724,6 +757,8 @@ static int macb_probe(struct device_d *dev) macb->txclk = clk_get(dev, "tx_clk"); if (!IS_ERR(macb->txclk)) clk_enable(macb->txclk); + else + macb->txclk = NULL; macb->rxclk = clk_get(dev, "rx_clk"); if (!IS_ERR(macb->rxclk)) -- 2.20.1 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
On arm64 the compiler prints the following warning, when the macb driver is enabled: warning: cast from pointer to integer of different size Add the same explicit cast as implemented for all other dma addresses in the macb driver. Fixes: befd110b5922 ("net: macb: init multiple dummy TX queues") Signed-off-by: Michael Tretter <m.tretter@pengutronix.de> --- drivers/net/macb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/macb.c b/drivers/net/macb.c index fa530cfe8e4c..188dbf2d8c15 100644 --- a/drivers/net/macb.c +++ b/drivers/net/macb.c @@ -365,7 +365,7 @@ static int gmac_init_dummy_tx_queues(struct macb_device *macb) MACB_BIT(TX_LAST) | MACB_BIT(TX_USED); for (i = 1; i < num_queues; i++) - gem_writel_queue_TBQP(macb, &macb->gem_q1_descs[0], i - 1); + gem_writel_queue_TBQP(macb, (ulong)macb->gem_q1_descs, i - 1); return 0; } -- 2.20.1 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Hello, On 10/15/20 3:20 PM, Michael Tretter wrote: > On arm64 the compiler prints the following warning, when the macb driver > is enabled: > > warning: cast from pointer to integer of different size > > Add the same explicit cast as implemented for all other dma addresses in > the macb driver. > > Fixes: befd110b5922 ("net: macb: init multiple dummy TX queues") I don't think this qualifies as a fix. You just silence the compiler warning you that your truncate the upper 32 bits of your buffer's address. This works because your SDRAM's location in physical memory is below 4G. > Signed-off-by: Michael Tretter <m.tretter@pengutronix.de> > --- > drivers/net/macb.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/macb.c b/drivers/net/macb.c > index fa530cfe8e4c..188dbf2d8c15 100644 > --- a/drivers/net/macb.c > +++ b/drivers/net/macb.c > @@ -365,7 +365,7 @@ static int gmac_init_dummy_tx_queues(struct macb_device *macb) > MACB_BIT(TX_LAST) | MACB_BIT(TX_USED); > > for (i = 1; i < num_queues; i++) > - gem_writel_queue_TBQP(macb, &macb->gem_q1_descs[0], i - 1); > + gem_writel_queue_TBQP(macb, (ulong)macb->gem_q1_descs, i - 1); > > return 0; > } > -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
On Thu, 15 Oct 2020 15:29:01 +0200, Ahmad Fatoum wrote: > On 10/15/20 3:20 PM, Michael Tretter wrote: > > On arm64 the compiler prints the following warning, when the macb driver > > is enabled: > > > > warning: cast from pointer to integer of different size > > > > Add the same explicit cast as implemented for all other dma addresses in > > the macb driver. > > > > Fixes: befd110b5922 ("net: macb: init multiple dummy TX queues") > > I don't think this qualifies as a fix. You just silence the compiler > warning you that your truncate the upper 32 bits of your buffer's > address. This works because your SDRAM's location in physical memory > is below 4G. Correct. Which is exactly the same as assumed by the entire driver... Michael > > > Signed-off-by: Michael Tretter <m.tretter@pengutronix.de> > > --- > > drivers/net/macb.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/net/macb.c b/drivers/net/macb.c > > index fa530cfe8e4c..188dbf2d8c15 100644 > > --- a/drivers/net/macb.c > > +++ b/drivers/net/macb.c > > @@ -365,7 +365,7 @@ static int gmac_init_dummy_tx_queues(struct macb_device *macb) > > MACB_BIT(TX_LAST) | MACB_BIT(TX_USED); > > > > for (i = 1; i < num_queues; i++) > > - gem_writel_queue_TBQP(macb, &macb->gem_q1_descs[0], i - 1); > > + gem_writel_queue_TBQP(macb, (ulong)macb->gem_q1_descs, i - 1); > > > > return 0; > > } > > _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Hi, On 10/15/20 4:04 PM, Michael Tretter wrote: > On Thu, 15 Oct 2020 15:29:01 +0200, Ahmad Fatoum wrote: >> On 10/15/20 3:20 PM, Michael Tretter wrote: >>> On arm64 the compiler prints the following warning, when the macb driver >>> is enabled: >>> >>> warning: cast from pointer to integer of different size >>> >>> Add the same explicit cast as implemented for all other dma addresses in >>> the macb driver. >>> >>> Fixes: befd110b5922 ("net: macb: init multiple dummy TX queues") >> >> I don't think this qualifies as a fix. You just silence the compiler >> warning you that your truncate the upper 32 bits of your buffer's >> address. This works because your SDRAM's location in physical memory >> is below 4G. > > Correct. Which is exactly the same as assumed by the entire driver... Ye, I am commenting on your Fixes: line though :-) > > Michael > >> >>> Signed-off-by: Michael Tretter <m.tretter@pengutronix.de> >>> --- >>> drivers/net/macb.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/drivers/net/macb.c b/drivers/net/macb.c >>> index fa530cfe8e4c..188dbf2d8c15 100644 >>> --- a/drivers/net/macb.c >>> +++ b/drivers/net/macb.c >>> @@ -365,7 +365,7 @@ static int gmac_init_dummy_tx_queues(struct macb_device *macb) >>> MACB_BIT(TX_LAST) | MACB_BIT(TX_USED); >>> >>> for (i = 1; i < num_queues; i++) >>> - gem_writel_queue_TBQP(macb, &macb->gem_q1_descs[0], i - 1); >>> + gem_writel_queue_TBQP(macb, (ulong)macb->gem_q1_descs, i - 1); >>> >>> return 0; >>> } >>> > -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
On Thu, Oct 15, 2020 at 03:20:46PM +0200, Michael Tretter wrote: > The macb debugging output printed the function entry for various > functions. Especially for *_recv() this debugging flooded the serial > output while conveying very little information. > > Remove printing of the function calls to make enabling debugging for the > macb driver more useful. > > Signed-off-by: Michael Tretter <m.tretter@pengutronix.de> > --- > drivers/net/macb.c | 18 ------------------ > 1 file changed, 18 deletions(-) Applied, thanks Sascha -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
On Thu, Oct 15, 2020 at 03:20:48PM +0200, Michael Tretter wrote: > On arm64 the compiler prints the following warning, when the macb driver > is enabled: > > warning: cast from pointer to integer of different size > > Add the same explicit cast as implemented for all other dma addresses in > the macb driver. > > Fixes: befd110b5922 ("net: macb: init multiple dummy TX queues") Well for me this updates the commit befd110b5922 to the state it should have looked like, so for me this qualifies as a fix. Anyway, it would be really good if we could at least catch runtime errors when we truncate pointers. Sascha -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox