[PATCH 0/3] PowerPC: ibm_newemac minor fixes.
These patches have some minor ibm_newemac fixes. Thanks, Valentine. - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/3] PowerPC: ibm_newemac correct opb_bus_freq value
The EMAC4_MR1_OBCI(freq) macro expects freg in MHz, while opb_bus_freq is kept in Hz. Correct this. Signed-off-by: Valentine Barshak [EMAIL PROTECTED] --- drivers/net/ibm_newemac/core.c |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) diff -pruN linux-2.6.orig/drivers/net/ibm_newemac/core.c linux-2.6/drivers/net/ibm_newemac/core.c --- linux-2.6.orig/drivers/net/ibm_newemac/core.c 2007-11-23 21:27:57.0 +0300 +++ linux-2.6/drivers/net/ibm_newemac/core.c2007-11-23 21:47:53.0 +0300 @@ -402,7 +402,7 @@ static u32 __emac_calc_base_mr1(struct e static u32 __emac4_calc_base_mr1(struct emac_instance *dev, int tx_size, int rx_size) { u32 ret = EMAC_MR1_VLE | EMAC_MR1_IST | EMAC4_MR1_TR | - EMAC4_MR1_OBCI(dev-opb_bus_freq); + EMAC4_MR1_OBCI(dev-opb_bus_freq / 100); DBG2(dev, __emac4_calc_base_mr1 NL); - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/3] PowerPC: ibm_newemac tah_ph typo fix
This patch fixes a typo in ibm_newemac/core.c (tah_port should be used instead of tah_ph) Signed-off-by: Valentine Barshak [EMAIL PROTECTED] --- drivers/net/ibm_newemac/core.c |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) diff -pruN linux-2.6.orig/drivers/net/ibm_newemac/core.c linux-2.6/drivers/net/ibm_newemac/core.c --- linux-2.6.orig/drivers/net/ibm_newemac/core.c 2007-11-23 21:27:57.0 +0300 +++ linux-2.6/drivers/net/ibm_newemac/core.c2007-11-23 21:36:00.0 +0300 @@ -2427,7 +2427,7 @@ static int __devinit emac_init_config(st if (emac_read_uint_prop(np, tah-device, dev-tah_ph, 0)) dev-tah_ph = 0; if (emac_read_uint_prop(np, tah-channel, dev-tah_port, 0)) - dev-tah_ph = 0; + dev-tah_port = 0; if (emac_read_uint_prop(np, mdio-device, dev-mdio_ph, 0)) dev-mdio_ph = 0; if (emac_read_uint_prop(np, zmii-device, dev-zmii_ph, 0)) - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/3] PowerPC: ibm_newemac call dev_set_drvdata() before tah_reset()
The patch moves dev_set_drvdata(ofdev-dev, dev) up before tah_reset(ofdev) is called to avoid a NULL pointer dereference, since tah_reset uses drvdata. Signed-off-by: Valentine Barshak [EMAIL PROTECTED] --- drivers/net/ibm_newemac/tah.c |3 ++- 1 files changed, 2 insertions(+), 1 deletion(-) diff -pruN linux-2.6.orig/drivers/net/ibm_newemac/tah.c linux-2.6/drivers/net/ibm_newemac/tah.c --- linux-2.6.orig/drivers/net/ibm_newemac/tah.c2007-11-23 21:27:57.0 +0300 +++ linux-2.6/drivers/net/ibm_newemac/tah.c 2007-11-23 21:35:12.0 +0300 @@ -116,13 +116,14 @@ static int __devinit tah_probe(struct of goto err_free; } + dev_set_drvdata(ofdev-dev, dev); + /* Initialize TAH and enable IPv4 checksum verification, no TSO yet */ tah_reset(ofdev); printk(KERN_INFO TAH %s initialized\n, ofdev-node-full_name); wmb(); - dev_set_drvdata(ofdev-dev, dev); return 0; - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] USB: net: Fix asix read transfer buffer allocations.
On systems with noncoherent cache, allocating dma buffers on the stack for USB IN transfers causes kernel crash, because usb map_urb_for_dma() code calls dma_map_single(), that invalidates data cache for DMA_FROM_DEVICE transfer direction and causes stack data loss if transfer size is less than cache line and not cache-line aligned. This patch makes asix usb network driver allocate USB IN transfer buffers with kmalloc instead of directly using variables on stack. It also sets data parameter to NULL for zero-length transfers and uses ETH_ALEN size for allocating MAC address buffer. Signed-off-by: Valentine Barshak [EMAIL PROTECTED] --- drivers/net/usb/asix.c | 44 +++- 1 files changed, 31 insertions(+), 13 deletions(-) diff -pruN linux-2.6.orig/drivers/net/usb/asix.c linux-2.6/drivers/net/usb/asix.c --- linux-2.6.orig/drivers/net/usb/asix.c 2007-10-23 20:52:11.0 +0400 +++ linux-2.6/drivers/net/usb/asix.c2007-10-23 20:57:38.0 +0400 @@ -568,15 +568,23 @@ static void asix_set_multicast(struct ne static int asix_mdio_read(struct net_device *netdev, int phy_id, int loc) { struct usbnet *dev = netdev_priv(netdev); + void *buf; u16 res; + buf = kmalloc(2, GFP_KERNEL); + if (!buf) + return -ENOMEM; + mutex_lock(dev-phy_mutex); asix_set_sw_mii(dev); asix_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id, - (__u16)loc, 2, (u16 *)res); + (__u16)loc, 2, buf); asix_set_hw_mii(dev); mutex_unlock(dev-phy_mutex); + res = *((u16 *)buf); + kfree(buf); + devdbg(dev, asix_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x, phy_id, loc, le16_to_cpu(res 0x)); return le16_to_cpu(res 0x); @@ -622,13 +630,22 @@ static void asix_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo) { struct usbnet *dev = netdev_priv(net); + void *buf; u8 opt; - if (asix_read_cmd(dev, AX_CMD_READ_MONITOR_MODE, 0, 0, 1, opt) 0) { + buf = kmalloc(1, GFP_KERNEL); + if (!buf) + return; + + if (asix_read_cmd(dev, AX_CMD_READ_MONITOR_MODE, 0, 0, 1, buf) 0) { wolinfo-supported = 0; wolinfo-wolopts = 0; + kfree(buf); return; } + opt = *((u8 *)buf); + kfree(buf); + wolinfo-supported = WAKE_PHY | WAKE_MAGIC; wolinfo-wolopts = 0; if (opt AX_MONITOR_MODE) { @@ -644,7 +661,6 @@ asix_set_wol(struct net_device *net, str { struct usbnet *dev = netdev_priv(net); u8 opt = 0; - u8 buf[1]; if (wolinfo-wolopts WAKE_PHY) opt |= AX_MONITOR_LINK; @@ -654,7 +670,7 @@ asix_set_wol(struct net_device *net, str opt |= AX_MONITOR_MODE; if (asix_write_cmd(dev, AX_CMD_WRITE_MONITOR_MODE, - opt, 0, 0, buf) 0) + opt, 0, 0, NULL) 0) return -EINVAL; return 0; @@ -820,7 +836,7 @@ static int ax88172_bind(struct usbnet *d for (i = 2; i = 0; i--) { if ((ret = asix_write_cmd(dev, AX_CMD_WRITE_GPIOS, (gpio_bits (i * 8)) 0xff, 0, 0, - buf)) 0) + NULL)) 0) goto out2; msleep(5); } @@ -831,7 +847,7 @@ static int ax88172_bind(struct usbnet *d /* Get the MAC address */ memset(buf, 0, ETH_ALEN); if ((ret = asix_read_cmd(dev, AX88172_CMD_READ_NODE_ID, - 0, 0, 6, buf)) 0) { + 0, 0, ETH_ALEN, buf)) 0) { dbg(read AX_CMD_READ_NODE_ID failed: %d, ret); goto out2; } @@ -909,7 +925,7 @@ static int ax88772_bind(struct usbnet *d usbnet_get_endpoints(dev,intf); - buf = kmalloc(6, GFP_KERNEL); + buf = kmalloc(ETH_ALEN, GFP_KERNEL); if(!buf) { dbg (Cannot allocate memory for buffer); ret = -ENOMEM; @@ -923,7 +939,7 @@ static int ax88772_bind(struct usbnet *d /* 0x10 is the phy id of the embedded 10/100 ethernet phy */ embd_phy = ((asix_get_phy_addr(dev) 0x1f) == 0x10 ? 1 : 0); if ((ret = asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, - embd_phy, 0, 0, buf)) 0) { + embd_phy, 0, 0, NULL)) 0) { dbg(Select PHY #1 failed: %d, ret); goto out2; } @@ -998,7 +1014,7 @@ static int ax88772_bind(struct usbnet *d if ((ret = asix_write_cmd(dev, AX_CMD_WRITE_IPG0, AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT, - AX88772_IPG2_DEFAULT, 0, buf)) 0
Re: [linux-usb-devel] [PATCH] USB: net: Fix asix read transfer buffer allocations.
Sorry, CC'ed Dave Brownell instead of Dave Hollis :) - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] USB: net: Fix asix read transfer buffer allocations.
On systems with noncoherent cache, allocating dma buffers on the stack for USB IN transfers causes kernel crash, because usb map_urb_for_dma() code calls dma_map_single(), that invalidates data cache for DMA_FROM_DEVICE transfer direction and causes stack data loss if transfer size is less than cache line and not cache-line aligned. This patch makes asix usb network driver allocate USB IN transfer buffers with kmalloc instead of directly using variables on stack. It also sets data parameter to NULL for zero-length transfers and uses ETH_ALEN size for allocating MAC address buffer. Signed-off-by: Valentine Barshak [EMAIL PROTECTED] --- drivers/net/usb/asix.c | 44 +++- 1 files changed, 31 insertions(+), 13 deletions(-) diff -pruN linux-2.6.orig/drivers/net/usb/asix.c linux-2.6/drivers/net/usb/asix.c --- linux-2.6.orig/drivers/net/usb/asix.c 2007-10-23 20:52:11.0 +0400 +++ linux-2.6/drivers/net/usb/asix.c2007-10-23 20:57:38.0 +0400 @@ -568,15 +568,23 @@ static void asix_set_multicast(struct ne static int asix_mdio_read(struct net_device *netdev, int phy_id, int loc) { struct usbnet *dev = netdev_priv(netdev); + void *buf; u16 res; + buf = kmalloc(2, GFP_KERNEL); + if (!buf) + return -ENOMEM; + mutex_lock(dev-phy_mutex); asix_set_sw_mii(dev); asix_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id, - (__u16)loc, 2, (u16 *)res); + (__u16)loc, 2, buf); asix_set_hw_mii(dev); mutex_unlock(dev-phy_mutex); + res = *((u16 *)buf); + kfree(buf); + devdbg(dev, asix_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x, phy_id, loc, le16_to_cpu(res 0x)); return le16_to_cpu(res 0x); @@ -622,13 +630,22 @@ static void asix_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo) { struct usbnet *dev = netdev_priv(net); + void *buf; u8 opt; - if (asix_read_cmd(dev, AX_CMD_READ_MONITOR_MODE, 0, 0, 1, opt) 0) { + buf = kmalloc(1, GFP_KERNEL); + if (!buf) + return; + + if (asix_read_cmd(dev, AX_CMD_READ_MONITOR_MODE, 0, 0, 1, buf) 0) { wolinfo-supported = 0; wolinfo-wolopts = 0; + kfree(buf); return; } + opt = *((u8 *)buf); + kfree(buf); + wolinfo-supported = WAKE_PHY | WAKE_MAGIC; wolinfo-wolopts = 0; if (opt AX_MONITOR_MODE) { @@ -644,7 +661,6 @@ asix_set_wol(struct net_device *net, str { struct usbnet *dev = netdev_priv(net); u8 opt = 0; - u8 buf[1]; if (wolinfo-wolopts WAKE_PHY) opt |= AX_MONITOR_LINK; @@ -654,7 +670,7 @@ asix_set_wol(struct net_device *net, str opt |= AX_MONITOR_MODE; if (asix_write_cmd(dev, AX_CMD_WRITE_MONITOR_MODE, - opt, 0, 0, buf) 0) + opt, 0, 0, NULL) 0) return -EINVAL; return 0; @@ -820,7 +836,7 @@ static int ax88172_bind(struct usbnet *d for (i = 2; i = 0; i--) { if ((ret = asix_write_cmd(dev, AX_CMD_WRITE_GPIOS, (gpio_bits (i * 8)) 0xff, 0, 0, - buf)) 0) + NULL)) 0) goto out2; msleep(5); } @@ -831,7 +847,7 @@ static int ax88172_bind(struct usbnet *d /* Get the MAC address */ memset(buf, 0, ETH_ALEN); if ((ret = asix_read_cmd(dev, AX88172_CMD_READ_NODE_ID, - 0, 0, 6, buf)) 0) { + 0, 0, ETH_ALEN, buf)) 0) { dbg(read AX_CMD_READ_NODE_ID failed: %d, ret); goto out2; } @@ -909,7 +925,7 @@ static int ax88772_bind(struct usbnet *d usbnet_get_endpoints(dev,intf); - buf = kmalloc(6, GFP_KERNEL); + buf = kmalloc(ETH_ALEN, GFP_KERNEL); if(!buf) { dbg (Cannot allocate memory for buffer); ret = -ENOMEM; @@ -923,7 +939,7 @@ static int ax88772_bind(struct usbnet *d /* 0x10 is the phy id of the embedded 10/100 ethernet phy */ embd_phy = ((asix_get_phy_addr(dev) 0x1f) == 0x10 ? 1 : 0); if ((ret = asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, - embd_phy, 0, 0, buf)) 0) { + embd_phy, 0, 0, NULL)) 0) { dbg(Select PHY #1 failed: %d, ret); goto out2; } @@ -998,7 +1014,7 @@ static int ax88772_bind(struct usbnet *d if ((ret = asix_write_cmd(dev, AX_CMD_WRITE_IPG0, AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT, - AX88772_IPG2_DEFAULT, 0, buf)) 0
Re: [PATCH] PowerPC: Add BCM5248 and Marvell 88E1111 PHY support to NEW EMAC.
Benjamin Herrenschmidt wrote: On Tue, 2007-10-23 at 20:57 -0500, Valentine Barshak wrote: +static int m88e_init(struct mii_phy *phy) +{ + printk(%s: Marvell 88E Ethernet\n, __FUNCTION__); + phy_write(phy, 0x14, 0x0ce3); + phy_write(phy, 0x18, 0x4101); + phy_write(phy, 0x09, 0x0e00); + phy_write(phy, 0x04, 0x01e1); + phy_write(phy, 0x00, 0x9140); + phy_write(phy, 0x00, 0x1140); + + return 0; +} Care to put a few comments on why the above is necessary and what it does ? I think this set's up Marvell ext control (0x14) and led control (0x18) registers with some default values, Also sets some bits in the CTRL1000, ADVERTISE and basic mode control registers and resets the phy for the changes to take effect. Unfortunately, I don't have a detailed 88E description and can't tell anything about it. Looks like the code was originally ported from u-boot and is needed to init the phy :) Stefan, do you have any info on this? Thanks, Valentine. Thanks ! Ben. +static struct mii_phy_ops m88e_phy_ops = { + .init = m88e_init, + .setup_aneg = genmii_setup_aneg, + .setup_forced = genmii_setup_forced, + .poll_link = genmii_poll_link, + .read_link = genmii_read_link +}; + +static struct mii_phy_def m88e_phy_def = { + + .phy_id = 0x01410CC0, + .phy_id_mask= 0x0ff0, + .name = Marvell 88E Ethernet, + .ops= m88e_phy_ops, +}; + static struct mii_phy_def *mii_phy_table[] = { cis8201_phy_def, + bcm5248_phy_def, + m88e_phy_def, genmii_phy_def, NULL }; - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [linux-usb-devel] [PATCH] USB: net: Fix asix read transfer buffer allocations.
Ingo Oeser wrote: Valentine Barshak schrieb: Oliver Neukum wrote: Am Montag 22 Oktober 2007 schrieb Valentine Barshak: static int asix_mdio_read(struct net_device *netdev, int phy_id, int loc) { struct usbnet *dev = netdev_priv(netdev); + void *buf; u16 res; mutex_lock(dev-phy_mutex); asix_set_sw_mii(dev); + + buf = kmalloc(2, GFP_KERNEL); This is done under lock. Can you allocate the buffer once and reuse it? I think we can use 2 bytes of the usbnet data buffer for this. I'll submit a new patch soon. If this cannot be done for some reason, then you can at least kmalloc() before you do mutex_lock(dev-phy_mutex); and kfree() after you did mutex_unlock(dev-phy_mutex); The reason to can do this, is that buf has a life time limited to this function. The reason you should do this, is that kmalloc(, GFP_KERNEL) is allowed to sleep, which will block the mutex for that time. While this is technically ok, since mutexes can sleep, it is not desireable, since other users of that mutex are blocked until the allocation is done. If you are able to implement the 2 bytes of usbnet data buffer version, please ignore that mail :-) Best Regards Ingo Oeser Looks like we cannot use usbnet data buffer for read transfers either, because it's just a part of the usbnet structure and we may still lose data while invalidating cache the same way we do using buffers on stack. Allocating a permanent buffer for phy transfer needs more driver changes: we should add unbind finction to the device_info for all asix devices to deallocate the buffer at exit. And we still need to allocate buffers for other transfers dynamically, so having just one permanent buffer for phy doesn't help much. I've reworked the original patch a bit: moved kmalloc out of the phy_mutex and added more clean-ups. Will submit shortly. Thanks, Valentine. - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] USB: net: Fix asix read transfer buffer allocations.
On systems with noncoherent cache, allocating dma buffers on the stack for USB IN transfers causes kernel crash, because usb map_urb_for_dma() code calls dma_map_single(), that invalidates data cache for DMA_FROM_DEVICE transfer direction and causes stack data loss if transfer size is less than cache line and not cache-line aligned. This patch makes asix usb network driver allocate USB IN transfer buffers with kmalloc instead of directly using variables on stack. It also sets data parameter to NULL for zero-length transfers and uses ETH_ALEN size for allocating MAC address buffer. diff -pruN linux-2.6.orig/drivers/net/usb/asix.c linux-2.6/drivers/net/usb/asix.c --- linux-2.6.orig/drivers/net/usb/asix.c 2007-10-23 20:52:11.0 +0400 +++ linux-2.6/drivers/net/usb/asix.c2007-10-23 20:57:38.0 +0400 @@ -568,15 +568,23 @@ static void asix_set_multicast(struct ne static int asix_mdio_read(struct net_device *netdev, int phy_id, int loc) { struct usbnet *dev = netdev_priv(netdev); + void *buf; u16 res; + buf = kmalloc(2, GFP_KERNEL); + if (!buf) + return -ENOMEM; + mutex_lock(dev-phy_mutex); asix_set_sw_mii(dev); asix_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id, - (__u16)loc, 2, (u16 *)res); + (__u16)loc, 2, buf); asix_set_hw_mii(dev); mutex_unlock(dev-phy_mutex); + res = *((u16 *)buf); + kfree(buf); + devdbg(dev, asix_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x, phy_id, loc, le16_to_cpu(res 0x)); return le16_to_cpu(res 0x); @@ -622,13 +630,22 @@ static void asix_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo) { struct usbnet *dev = netdev_priv(net); + void *buf; u8 opt; - if (asix_read_cmd(dev, AX_CMD_READ_MONITOR_MODE, 0, 0, 1, opt) 0) { + buf = kmalloc(1, GFP_KERNEL); + if (!buf) + return; + + if (asix_read_cmd(dev, AX_CMD_READ_MONITOR_MODE, 0, 0, 1, buf) 0) { wolinfo-supported = 0; wolinfo-wolopts = 0; + kfree(buf); return; } + opt = *((u8 *)buf); + kfree(buf); + wolinfo-supported = WAKE_PHY | WAKE_MAGIC; wolinfo-wolopts = 0; if (opt AX_MONITOR_MODE) { @@ -644,7 +661,6 @@ asix_set_wol(struct net_device *net, str { struct usbnet *dev = netdev_priv(net); u8 opt = 0; - u8 buf[1]; if (wolinfo-wolopts WAKE_PHY) opt |= AX_MONITOR_LINK; @@ -654,7 +670,7 @@ asix_set_wol(struct net_device *net, str opt |= AX_MONITOR_MODE; if (asix_write_cmd(dev, AX_CMD_WRITE_MONITOR_MODE, - opt, 0, 0, buf) 0) + opt, 0, 0, NULL) 0) return -EINVAL; return 0; @@ -820,7 +836,7 @@ static int ax88172_bind(struct usbnet *d for (i = 2; i = 0; i--) { if ((ret = asix_write_cmd(dev, AX_CMD_WRITE_GPIOS, (gpio_bits (i * 8)) 0xff, 0, 0, - buf)) 0) + NULL)) 0) goto out2; msleep(5); } @@ -831,7 +847,7 @@ static int ax88172_bind(struct usbnet *d /* Get the MAC address */ memset(buf, 0, ETH_ALEN); if ((ret = asix_read_cmd(dev, AX88172_CMD_READ_NODE_ID, - 0, 0, 6, buf)) 0) { + 0, 0, ETH_ALEN, buf)) 0) { dbg(read AX_CMD_READ_NODE_ID failed: %d, ret); goto out2; } @@ -909,7 +925,7 @@ static int ax88772_bind(struct usbnet *d usbnet_get_endpoints(dev,intf); - buf = kmalloc(6, GFP_KERNEL); + buf = kmalloc(ETH_ALEN, GFP_KERNEL); if(!buf) { dbg (Cannot allocate memory for buffer); ret = -ENOMEM; @@ -923,7 +939,7 @@ static int ax88772_bind(struct usbnet *d /* 0x10 is the phy id of the embedded 10/100 ethernet phy */ embd_phy = ((asix_get_phy_addr(dev) 0x1f) == 0x10 ? 1 : 0); if ((ret = asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, - embd_phy, 0, 0, buf)) 0) { + embd_phy, 0, 0, NULL)) 0) { dbg(Select PHY #1 failed: %d, ret); goto out2; } @@ -998,7 +1014,7 @@ static int ax88772_bind(struct usbnet *d if ((ret = asix_write_cmd(dev, AX_CMD_WRITE_IPG0, AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT, - AX88772_IPG2_DEFAULT, 0, buf)) 0) { + AX88772_IPG2_DEFAULT, 0, NULL)) 0) { dbg(Write IPG,IPG1,IPG2 failed: %d, ret); goto out2; } @@ -1202,20 +1218,22 @@ static int
[PATCH] USB: net: Fix asix read transfer buffer allocations.
On systems with noncoherent cache, allocating dma buffers on the stack for USB IN transfers causes kernel crash, because usb map_urb_for_dma() code calls dma_map_single(), that invalidates data cache for DMA_FROM_DEVICE transfer direction and causes stack data loss if transfer size is less than cache line and not cache-line aligned. This patch makes asix usb network driver allocate USB IN transfer buffers with kmalloc instead of directly using variables on stack. Signed-off-by: Valentine Barshak [EMAIL PROTECTED] --- drivers/net/usb/asix.c | 21 +++-- 1 files changed, 19 insertions(+), 2 deletions(-) diff -pruN linux-2.6.orig/drivers/net/usb/asix.c linux-2.6/drivers/net/usb/asix.c --- linux-2.6.orig/drivers/net/usb/asix.c 2007-10-19 20:10:18.0 +0400 +++ linux-2.6/drivers/net/usb/asix.c2007-10-19 20:35:33.0 +0400 @@ -568,12 +568,20 @@ static void asix_set_multicast(struct ne static int asix_mdio_read(struct net_device *netdev, int phy_id, int loc) { struct usbnet *dev = netdev_priv(netdev); + void *buf; u16 res; mutex_lock(dev-phy_mutex); asix_set_sw_mii(dev); + + buf = kmalloc(2, GFP_KERNEL); + if (!buf) + return -ENOMEM; asix_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id, - (__u16)loc, 2, (u16 *)res); + (__u16)loc, 2, buf); + res = *((u16 *)buf); + kfree(buf); + asix_set_hw_mii(dev); mutex_unlock(dev-phy_mutex); @@ -622,13 +630,22 @@ static void asix_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo) { struct usbnet *dev = netdev_priv(net); + void *buf; u8 opt; - if (asix_read_cmd(dev, AX_CMD_READ_MONITOR_MODE, 0, 0, 1, opt) 0) { + buf = kmalloc(1, GFP_KERNEL); + if (!buf) + return; + + if (asix_read_cmd(dev, AX_CMD_READ_MONITOR_MODE, 0, 0, 1, buf) 0) { wolinfo-supported = 0; wolinfo-wolopts = 0; + kfree(buf); return; } + opt = *((u8 *)buf); + kfree(buf); + wolinfo-supported = WAKE_PHY | WAKE_MAGIC; wolinfo-wolopts = 0; if (opt AX_MONITOR_MODE) { - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [linux-usb-devel] [PATCH] USB: net: Fix asix read transfer buffer allocations.
Oliver Neukum wrote: Am Montag 22 Oktober 2007 schrieb Valentine Barshak: static int asix_mdio_read(struct net_device *netdev, int phy_id, int loc) { struct usbnet *dev = netdev_priv(netdev); + void *buf; u16 res; mutex_lock(dev-phy_mutex); asix_set_sw_mii(dev); + + buf = kmalloc(2, GFP_KERNEL); This is done under lock. Can you allocate the buffer once and reuse it? Regards Oliver I think we can use 2 bytes of the usbnet data buffer for this. I'll submit a new patch soon. Thanks, Valentine. - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] PowerPC: Add BCM5248 and Marvell 88E1111 PHY support to NEW EMAC.
This patch adds BCM5248 and Marvell 88E PHY support to NEW EMAC driver. These PHY chips are used on PowerPC 440EPx boards. The PHY code is based on the previous work by Stefan Roese [EMAIL PROTECTED] Signed-off-by: Stefan Roese [EMAIL PROTECTED] Signed-off-by: Valentine Barshak [EMAIL PROTECTED] --- drivers/net/ibm_newemac/phy.c | 39 +++ 1 files changed, 39 insertions(+) --- linux.orig/drivers/net/ibm_newemac/phy.c2007-06-15 21:45:18.0 +0400 +++ linux/drivers/net/ibm_newemac/phy.c 2007-06-15 20:45:15.0 +0400 @@ -306,8 +306,47 @@ .ops= cis8201_phy_ops }; +static struct mii_phy_def bcm5248_phy_def = { + + .phy_id = 0x0143bc00, + .phy_id_mask= 0x0ff0, + .name = BCM5248 10/100 SMII Ethernet, + .ops= generic_phy_ops +}; + +static int m88e_init(struct mii_phy *phy) +{ + printk(%s: Marvell 88E Ethernet\n, __FUNCTION__); + phy_write(phy, 0x14, 0x0ce3); + phy_write(phy, 0x18, 0x4101); + phy_write(phy, 0x09, 0x0e00); + phy_write(phy, 0x04, 0x01e1); + phy_write(phy, 0x00, 0x9140); + phy_write(phy, 0x00, 0x1140); + + return 0; +} + +static struct mii_phy_ops m88e_phy_ops = { + .init = m88e_init, + .setup_aneg = genmii_setup_aneg, + .setup_forced = genmii_setup_forced, + .poll_link = genmii_poll_link, + .read_link = genmii_read_link +}; + +static struct mii_phy_def m88e_phy_def = { + + .phy_id = 0x01410CC0, + .phy_id_mask= 0x0ff0, + .name = Marvell 88E Ethernet, + .ops= m88e_phy_ops, +}; + static struct mii_phy_def *mii_phy_table[] = { cis8201_phy_def, + bcm5248_phy_def, + m88e_phy_def, genmii_phy_def, NULL }; - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] PowerPC: Enable NEW EMAC support for Sequoia 440EPx.
This patch enables NEW EMAC support for PowerPC 440EPx Sequoia board. Signed-off-by: Valentine Barshak [EMAIL PROTECTED] --- arch/powerpc/platforms/44x/Kconfig |7 +++ 1 files changed, 3 insertions(+), 4 deletions(-) --- linux.orig/arch/powerpc/platforms/44x/Kconfig 2007-07-30 15:05:50.0 +0400 +++ linux/arch/powerpc/platforms/44x/Kconfig2007-07-30 17:59:05.0 +0400 @@ -48,10 +48,9 @@ config 440EPX bool select PPC_FPU -# Disabled until the new EMAC Driver is merged. -# select IBM_NEW_EMAC_EMAC4 -# select IBM_NEW_EMAC_RGMII -# select IBM_NEW_EMAC_ZMII + select IBM_NEW_EMAC_EMAC4 + select IBM_NEW_EMAC_RGMII + select IBM_NEW_EMAC_ZMII config 440GP bool - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] NEW EMAC Fix RGMII build error: use of_device_is_compatible
Fix build RGMII error: use of_device_is_compatible() insteadof now deprecated device_is_compatible() function. Signed-off-by: Valentine Barshak [EMAIL PROTECTED] --- drivers/net/ibm_newemac/rgmii.c |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) diff -pruN linux-2.6.orig/drivers/net/ibm_newemac/rgmii.c linux-2.6/drivers/net/ibm_newemac/rgmii.c --- linux-2.6.orig/drivers/net/ibm_newemac/rgmii.c 2007-10-12 16:02:41.0 +0400 +++ linux-2.6/drivers/net/ibm_newemac/rgmii.c 2007-10-12 16:49:07.0 +0400 @@ -251,7 +251,7 @@ static int __devinit rgmii_probe(struct } /* Check for RGMII type */ - if (device_is_compatible(ofdev-node, ibm,rgmii-axon)) + if (of_device_is_compatible(ofdev-node, ibm,rgmii-axon)) dev-type = RGMII_AXON; else dev-type = RGMII_STANDARD; - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] pci: Fix e100 interrupt quirk
Andrew Morton wrote: On Tue, 18 Sep 2007 15:17:37 +0400 Valentine Barshak [EMAIL PROTECTED] wrote: PCI memory space may have a 64-bit offset on some architectures (for example, PowerPC 440) and the actual PCI memory address has to fixed up (an offset to PCI mem space shuld be added) before remapping. So, pci_iomap should be used instead of reading and remapping PCI BAR directly. This has been tested on Sequoia PowerPC 440EPx board. Signed-off-by: Valentine Barshak [EMAIL PROTECTED] --- --- linux-2.6.orig/drivers/pci/quirks.c 2007-09-04 21:15:43.0 +0400 +++ linux-2.6.bld/drivers/pci/quirks.c 2007-09-05 20:46:14.0 +0400 @@ -1444,9 +1444,9 @@ static void __devinit quirk_e100_interrupt(struct pci_dev *dev) { u16 command; - u32 bar; u8 __iomem *csr; u8 cmd_hi; + int rc; switch (dev-device) { /* PCI IDs taken from drivers/net/e100.c */ @@ -1476,16 +1476,17 @@ * re-enable them when it's ready. */ pci_read_config_word(dev, PCI_COMMAND, command); - pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, bar); - if (!(command PCI_COMMAND_MEMORY) || !bar) + rc = pci_request_region(dev, 0, e100_quirk); + + if (!(command PCI_COMMAND_MEMORY) || (rc 0)) return; Really? So if pci_request_region() failed and !(command PCI_COMMAND_MEMORY), we leak the region? So the next call to this function will fail? I've split command and request region checks and submitted new patch: http://lkml.org/lkml/2007/9/19/106 Please, take a look, Thanks, Valentine. - csr = ioremap(bar, 8); + csr = pci_iomap(dev, 0, 8); if (!csr) { printk(KERN_WARNING PCI: Can't map %s e100 registers\n, pci_name(dev)); - return; + goto e100_quirk_exit; } cmd_hi = readb(csr + 3); @@ -1495,7 +1496,9 @@ writeb(1, csr + 3); } - iounmap(csr); + pci_iounmap(dev, csr); +e100_quirk_exit: + pci_release_region(dev, 0); } DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_ANY_ID, quirk_e100_interrupt); - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] PPC440EPx/440GRx EMAC support.
Add PPC440EPx/440GRx EMAC along with Marvell 88E and ET1011C PHY support. The M88E chip can be found on Sequoia board. Signed-off-by: Valentine Barshak [EMAIL PROTECTED] diff -ruN linux.orig/drivers/net/ibm_emac/ibm_emac_core.c linux/drivers/net/ibm_emac/ibm_emac_core.c --- linux.orig/drivers/net/ibm_emac/ibm_emac_core.c 2007-03-16 18:03:51.0 +0300 +++ linux/drivers/net/ibm_emac/ibm_emac_core.c 2007-03-18 18:53:08.0 +0300 @@ -86,7 +86,8 @@ static u32 busy_phy_map; #if defined(CONFIG_IBM_EMAC_PHY_RX_CLK_FIX) \ -(defined(CONFIG_405EP) || defined(CONFIG_440EP) || defined(CONFIG_440GR)) +(defined(CONFIG_405EP) || defined(CONFIG_440EP) || defined(CONFIG_440GR) || \ + defined(CONFIG_440EPX) || defined(CONFIG_440GRX)) /* 405EP has EMAC to PHY Control Register (CPC0_EPCTL) which can help us * with PHY RX clock problem. * 440EP/440GR has more sane SDR0_MFR register implementation than 440GX, which diff -ruN linux.orig/drivers/net/ibm_emac/ibm_emac.h linux/drivers/net/ibm_emac/ibm_emac.h --- linux.orig/drivers/net/ibm_emac/ibm_emac.h 2007-03-16 18:03:51.0 +0300 +++ linux/drivers/net/ibm_emac/ibm_emac.h 2007-03-18 18:53:08.0 +0300 @@ -26,7 +26,7 @@ #if !defined(CONFIG_405GP) !defined(CONFIG_405GPR) !defined(CONFIG_405EP) \ !defined(CONFIG_440GP) !defined(CONFIG_440GX) !defined(CONFIG_440SP) \ !defined(CONFIG_440EP) !defined(CONFIG_NP405H) !defined(CONFIG_440SPE) \ -!defined(CONFIG_440GR) +!defined(CONFIG_440GR) !defined(CONFIG_440EPX) !defined(CONFIG_440GRX) #error Unknown SoC. Please, check chip user manual and make sure EMAC defines are OK #endif @@ -227,9 +227,15 @@ #define EMAC_STACR_PHYD_SHIFT 16 #define EMAC_STACR_OC 0x8000 #define EMAC_STACR_PHYE0x4000 +#if defined(CONFIG_IBM_EMAC4V4) +#define EMAC_STACR_STAC_MASK 0x3800 +#define EMAC_STACR_STAC_READ 0x1000 +#define EMAC_STACR_STAC_WRITE 0x0800 +#else #define EMAC_STACR_STAC_MASK 0x3000 #define EMAC_STACR_STAC_READ 0x1000 #define EMAC_STACR_STAC_WRITE 0x2000 +#endif #if !defined(CONFIG_IBM_EMAC4) #define EMAC_STACR_OPBC_MASK 0x0C00 #define EMAC_STACR_OPBC_50 0x @@ -250,8 +256,11 @@ /* * For the 440SPe, AMCC inexplicably changed the polarity of * the operation complete bit in the MII control register. + * + * This change is not associated to 440SPe but to EMAC core version used in + * 440SPe, 440EPx, 440GRx. */ -#if defined(CONFIG_440SPE) +#if defined(CONFIG_440SPE) || defined(CONFIG_IBM_EMAC4V4) static inline int emac_phy_done(u32 stacr) { return !(stacr EMAC_STACR_OC); diff -ruN linux.orig/drivers/net/ibm_emac/ibm_emac_mal.h linux/drivers/net/ibm_emac/ibm_emac_mal.h --- linux.orig/drivers/net/ibm_emac/ibm_emac_mal.h 2007-03-16 18:03:51.0 +0300 +++ linux/drivers/net/ibm_emac/ibm_emac_mal.h 2007-03-18 18:53:08.0 +0300 @@ -35,7 +35,7 @@ defined(CONFIG_440EP) || defined(CONFIG_440GR) || defined(CONFIG_NP405H) #define MAL_VERSION1 #elif defined(CONFIG_440GP) || defined(CONFIG_440GX) || defined(CONFIG_440SP) || \ - defined(CONFIG_440SPE) + defined(CONFIG_440SPE) || defined(CONFIG_440EPX) || defined(CONFIG_440GRX) #define MAL_VERSION2 #else #error Unknown SoC, please check chip manual and choose MAL 'version' diff -ruN linux.orig/drivers/net/ibm_emac/ibm_emac_phy.c linux/drivers/net/ibm_emac/ibm_emac_phy.c --- linux.orig/drivers/net/ibm_emac/ibm_emac_phy.c 2007-03-16 18:03:51.0 +0300 +++ linux/drivers/net/ibm_emac/ibm_emac_phy.c 2007-03-18 18:53:08.0 +0300 @@ -299,8 +299,71 @@ .ops= cis8201_phy_ops }; +/* Marvell 88E */ +static int m88e_init(struct mii_phy *phy) +{ + phy_write(phy, 0x14, 0x0ce3); + phy_write(phy, 0x18, 0x4101); + phy_write(phy, 0x09, 0x0e00); + phy_write(phy, 0x04, 0x01e1); + phy_write(phy, 0x00, 0x9140); + phy_write(phy, 0x00, 0x1140); + + return 0; +} + +static struct mii_phy_ops m88e_phy_ops = { + .init = m88e_init, + .setup_aneg = genmii_setup_aneg, + .setup_forced = genmii_setup_forced, + .poll_link = genmii_poll_link, + .read_link = genmii_read_link +}; + +static struct mii_phy_def m88e_phy_def = { + .phy_id = 0x01410CC0, + .phy_id_mask= 0x0ff0, + .name = Marvell 88E Ethernet, + .ops= m88e_phy_ops, +}; + +/* ET1011C */ +static int et1011c_init(struct mii_phy *phy) +{ + u16 reg_short; + + reg_short = (u16)(phy_read(phy,0x16)); + reg_short = ~(0x7); + reg_short |= 0x6; /* RGMII Trace Delay */ + phy_write(phy, 0x16, reg_short); + + reg_short = (u16)(phy_read(phy, 0x17