Hi Greg, this changes kaweth to use usb_buffer_alloc in the control and recieve paths, in which it is using fixed buffers which are not safe on some architectures. As a plus, it should get a little faster on some architectures. Please apply.
Regards Oliver You can import this changeset into BK by piping this whole message to: '| bk receive [path to repository]' or apply the patch as usual. =================================================================== [EMAIL PROTECTED], 2003-06-12 09:22:59+02:00, [EMAIL PROTECTED] - switch to usb_buffer_alloc kaweth.c | 51 +++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 41 insertions(+), 10 deletions(-) diff -Nru a/drivers/usb/net/kaweth.c b/drivers/usb/net/kaweth.c --- a/drivers/usb/net/kaweth.c Thu Jun 12 09:24:00 2003 +++ b/drivers/usb/net/kaweth.c Thu Jun 12 09:24:00 2003 @@ -56,6 +56,7 @@ #include <linux/usb.h> #include <linux/types.h> #include <linux/ethtool.h> +//#include <linux/dma-mapping.h> #include <asm/uaccess.h> #include <asm/semaphore.h> #include <asm/byteorder.h> @@ -223,13 +224,16 @@ struct urb *rx_urb; struct urb *tx_urb; struct urb *irq_urb; - + + dma_addr_t intbufferhandle; + __u8 *intbuffer; + dma_addr_t rxbufferhandle; + __u8 *rx_buf; + struct sk_buff *tx_skb; __u8 *firmware_buf; __u8 scratch[KAWETH_SCRATCH_SIZE]; - __u8 rx_buf[KAWETH_BUF_SIZE]; - __u8 intbuffer[INTBUFFERSIZE]; __u16 packet_filter_bitmap; struct kaweth_ethernet_configuration configuration; @@ -522,6 +526,8 @@ KAWETH_BUF_SIZE, kaweth_usb_receive, kaweth); + kaweth->rx_urb->transfer_flags |= URB_NO_DMA_MAP; + kaweth->rx_urb->transfer_dma = kaweth->rxbufferhandle; if((result = usb_submit_urb(kaweth->rx_urb, mem_flags))) { if (result == -ENOMEM) @@ -530,7 +536,7 @@ } else { kaweth->suspend_lowmem = 0; } - + return result; } @@ -628,6 +634,8 @@ int_callback, kaweth, HZ/4); + kaweth->irq_urb->transfer_dma = kaweth->intbufferhandle; + kaweth->irq_urb->transfer_flags |= URB_NO_DMA_MAP; res = usb_submit_urb(kaweth->irq_urb, GFP_KERNEL); if (res) { @@ -663,10 +671,10 @@ static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr) { u32 ethcmd; - + if (copy_from_user(ðcmd, useraddr, sizeof(ethcmd))) return -EFAULT; - + switch (ethcmd) { case ETHTOOL_GDRVINFO: { struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO}; @@ -676,7 +684,7 @@ return 0; } } - + return -EOPNOTSUPP; } @@ -1030,6 +1038,19 @@ kaweth->irq_urb = usb_alloc_urb(0, GFP_KERNEL); if (!kaweth->irq_urb) goto err_tx_and_rx; + kaweth->intbuffer = usb_buffer_alloc( kaweth->dev, + INTBUFFERSIZE, + GFP_KERNEL, + &kaweth->intbufferhandle); + if (!kaweth->intbuffer) + goto err_tx_and_rx_and_irq; + kaweth->rx_buf = usb_buffer_alloc( kaweth->dev, + KAWETH_BUF_SIZE, + GFP_KERNEL, + &kaweth->rxbufferhandle); + if (!kaweth->rx_buf) + goto err_all_but_rxbuf; + kaweth->net = netdev; memcpy(kaweth->net->broadcast, &bcast_addr, sizeof(bcast_addr)); @@ -1051,12 +1072,14 @@ kaweth->net->mtu = le16_to_cpu(kaweth->configuration.segment_size); memset(&kaweth->stats, 0, sizeof(kaweth->stats)); - + SET_MODULE_OWNER(netdev); + //if (dma_supported (kaweth->dev->dev, 0xffffffffffffffffULL)) + // kaweth->net->features |= NETIF_F_HIGHDMA; if (!init_etherdev(netdev, 0)) { kaweth_err("Error calling init_etherdev."); - goto err_tx_and_rx; + goto err_all; } kaweth_info("kaweth interface created at %s", kaweth->net->name); @@ -1065,7 +1088,12 @@ usb_set_intfdata(intf, kaweth); return 0; - +err_all: + usb_buffer_free(kaweth->dev, KAWETH_BUF_SIZE, (void *)kaweth->rx_buf, kaweth->rxbufferhandle); +err_all_but_rxbuf: + usb_buffer_free(kaweth->dev, INTBUFFERSIZE, (void *)kaweth->intbuffer, kaweth->intbufferhandle); +err_tx_and_rx_and_irq: + usb_free_urb(kaweth->irq_urb); err_tx_and_rx: usb_free_urb(kaweth->rx_urb); err_only_tx: @@ -1117,7 +1145,10 @@ usb_free_urb(kaweth->rx_urb); usb_free_urb(kaweth->tx_urb); + usb_free_urb(kaweth->irq_urb); + usb_buffer_free(kaweth->dev, KAWETH_BUF_SIZE, (void *)kaweth->rx_buf, kaweth->rxbufferhandle); + usb_buffer_free(kaweth->dev, INTBUFFERSIZE, (void *)kaweth->intbuffer, kaweth->intbufferhandle); kfree(kaweth); } =================================================================== This BitKeeper patch contains the following changesets: 1.1936 ## Wrapped with gzip_uu ## begin 664 bkpatch4396 M'XL(`)$JZ#X``[U6:V_B.!3]'/\*KRJM8*8A?N"0P(+:#M"B=CJ(*5II52D* MQ#P$)(R3M*R4'[\W":6DE+8[J]D(Z6+?U[G'QX$3/`REJFO!<[EMAIL PROTECTED] MU37XOHH]Z5=\&2_B52504_`-@@!\1B#]P)=&GF+<*2E#(PY'.JL(!%%]-QK/ M,+C"ND8K?+<3_;V6=6W0N1S>G`\0:C;QEYGK3^5W&>%F$XT69UXLEY6%"MQ9 MVC#9N1-&"*64"<*%247"+,ZK"37)R(.O'JO9DY%IHQS0V2O8BZ4X,2EA5-B4 M)%10BZ,VIA5J<Q,3;A#3H`P3N\Y87=B?":[EMAIL PROTECTED]@FZP/\=_Q<TQCH. M'^<96P$&3IU1/)E(Y;C+93!&UYB:U:I`_6?FD/XO'X2(2U#K%;B>2F?,CM)8 MN(\RFE7&S\BKQ&8DX<RB/#%-TZ.DZH[&+A6>:;U!3Z&J+Z-"Y?0@&*DQ)D1" MJA81F2J.9;PNDI]'C:[EMAIL PROTECTED](#P8@/"*8* MBJ'_FV0R7K]A73UF'U!`_RC%/Z&FGK`P189Q,O?'[EMAIL PROTECTED]&<^_'&\%:NOG+7 MZ[D_K<Q:J,V8"7&]U)CH'[EMAIL PROTECTED]/4TZ$YWZ48X;AO:5L(,[EMAIL PROTECTED]"N%J M\VJTVJ23-Z!VFW&*&2!C53!:/IS>@H!8C?16I%P_3!F:+-UIB),F'@XNG-MO M3OOKN?/UO-]X([EMAIL PROTECTED]"9^=A>1M`7GZ9"YN4<]DY-]!'/UX\UZAT0<[EMAIL PROTECTED] M3T'DYCY=V_G:WJYK^;J6KWN4<([EMAIL PROTECTED]:1?ER8=3I&5/[_;N8MCM M=@;?>W]UGC8ONWWGNC.X[=P\[?Q^9,XR##J?X-)O!_XR9$X#T+54</(;!\(= [EMAIL PROTECTED]'A0D/%1O-?G?W;NKAS`['P0<?&D#P#G[0MHH3OL14Z6F:F2$E%-B=_: MC'[EMAIL PROTECTED]>!BJ2'2WNX<_"8;"8OGN'-3;F<YN^FA-NLMR;2C6(E M,WG<=NYZ7:?K7/4NKT`CC0R'O<61VB+FS&]:N1^LB;:..M+VN)W`C_X^PE/\ MDE-<>@CF'OY4+G)T>N3R`*4'[EMAIL PROTECTED]>NV#;[EMAIL PROTECTED]"VC9..Z:WKO3B M%D):#][-&7GOQ['L%?"+N?OU1.W^QHUG<KP(XU53"FZ"E"?H'SXG"BE$"@`` ` end ------------------------------------------------------- This SF.NET email is sponsored by: eBay Great deals on office technology -- on eBay now! Click here: http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5 _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel