USB: uss720 fixup refcount position 
My testprog do a lot of bitbang - after hours i got following warning and my machine lockups:

WARNING: at /build/buildd/linux-2.6.38/lib/kref.c:34

After debugging uss720 driver i discovered that the completion callback was called before usb_submit_urb returns.
The callback frees the request structure that is krefed on return by usb_submit_urb.
--- a/drivers/usb/misc/uss720.c
+++ b/drivers/usb/misc/uss720.c
@@ -177,12 +177,11 @@ static struct uss720_async_request *submit_async_request(...
spin_lock_irqsave(&priv->asynclock, flags);
list_add_tail(&rq->asynclist, &priv->asynclist);
spin_unlock_irqrestore(&priv->asynclock, flags);
+ kref_get(&rq->ref_count);
ret = usb_submit_urb(rq->urb, mem_flags);
- if (!ret) {
- kref_get(&rq->ref_count);
+ if (!ret)
return rq;
- }
- kref_put(&rq->ref_count, destroy_async);
+ destroy_async(&rq->ref_count);
err("submit_async_request submit_urb failed with %d", ret);
return NULL;
}

http://git.kernel.org/?p=linux/kernel/g ... 5b45be8688

[ view entry ] ( 1487 views )   |  print article
ffmpeg http Transfer-Encoding: chunked 
Today i a made a patch for ffmpeg to be able to fetch a png file from a cgi script

ffmpeg -f image2 -vcodec png -i 'http://server/cgi-bin/graph.cgi'

This didn't work because ffmpeg/libavformat/http could't handle "Transfer-Encoding: chunked"

0001-http-Transfer-Encoding-chunked.patch

[ view entry ] ( 2151 views )   |  print article
Intellon int51x1 PLC usb net driver for devolo dlan duo 
Here is how i made the patch for inclusion:

git config --global user.name "Peter Holik"
git config --global user.email "peter AT holik.at"


check kernel out with git

git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git

first i had to export usbnet_get_ethernet_addr from usbnet.c
and to fix cdc_ether.c

git commit -am "export get_ethernet_addr from cdc.ether.c in usbnet"

then copy my new driver int51x1.c to /usr/src/linux-2.6/drivers/net/usb/ and modify /usr/src/linux-2.6/drivers/net/usb/Kconfig and /usr/src/linux-2.6/drivers/net/usb/Makefile

git add /usr/src/linux-2.6/drivers/net/usb/int51x1.c

git commit -am "usb driver for intellon int51x1 based PLC like devolo dlan duo"

git format-patch -s origin/master

Then mail the created file to linux kernel mailinglist:

cat 0001-export-usbnet_get_ethernet_addr-from-usbnet-and-fixe.patch | \
mail linux-kernel@vger.kernel.org

cat 0002-usb-driver-for-intellon-int51x1-based-PLC-like-devol.patch | \
mail linux-kernel@vger.kernel.org


Many thanks to the guys at linux-kernel@vger.kernel.org for suggestions and improvements.

Undo last commit with git reset --soft HEAD^

My driver will be part of linux kernel 2.6.31

git quick reference

[ view entry ] ( 955 views )   |  print article
ftdi dongleid FT232/245R 
I used the library from FTDI (libftchipid - is only in binary and linked against old libc) to get the dongleid.

I had to "sudo chmod 666 /proc/bus/usb/001/021".

There is an opensource library (libftdi) from intra2net that lacks support of reading the dongleid.

After usb sniffing (LD_PRELOAD=/usr/lib/libusbsniff.so ~/ftdi/id/ChipID) and disassembling (ddd) parts of libftchipid (bitshift) i made a patch for libftdi.

libftdi-0.10/src:

--- ftdi.c.orig 2007-05-03 18:06:04.000000000 +0200
+++ ftdi.c 2007-10-18 16:05:50.000000000 +0200
@@ -1228,6 +1228,45 @@
}

/**
+ Read dongleid
+
+ \param ftdi pointer to ftdi_context
+
+ \retval 0: all fine
+ \retval -1: read failed
+*/
+int ftdi_read_dongleid(struct ftdi_context *ftdi, unsigned int *dongleid)
+{
+ unsigned char shift(unsigned char value)
+ {
+ return ((value & 1) << 1) |
+ ((value & 2) << 5) |
+ ((value & 4) >> 2) |
+ ((value & 8) << 4) |
+ ((value & 16) >> 1) |
+ ((value & 32) >> 1) |
+ ((value & 64) >> 4) |
+ ((value & 128) >> 2);
+ }
+
+ unsigned int a = 0, b = 0, result = -1;
+
+ if (usb_control_msg(ftdi->usb_dev, 0xC0, 0x90, 0, 0x43, (char *)&a, 2, ftdi->usb_read_timeout) == 2)
+ {
+ a = a << 8 | a >> 8;
+ if (usb_control_msg(ftdi->usb_dev, 0xC0, 0x90, 0, 0x44, (char *)&b, 2, ftdi->usb_read_timeout) == 2)
+ {
+ b = b << 8 | b >> 8;
+ a = (a << 16) | b;
+ a = shift(a) | shift(a>>8)<<8 | shift(a>>16)<<16 | shift(a>>24)<<24;
+ *dongleid = a ^ 0xa5f0f7d1;
+ result = 0;
+ }
+ }
+ return result;
+}
+
+/**
Write eeprom

\param ftdi pointer to ftdi_context


--- ftdi.h.orig 2007-10-18 15:47:57.000000000 +0200
+++ ftdi.h 2007-10-18 16:05:56.000000000 +0200
@@ -266,6 +266,7 @@
// "eeprom" needs to be valid 128 byte eeprom (generated by the eeprom generator)
// the checksum of the eeprom is valided
int ftdi_read_eeprom(struct ftdi_context *ftdi, unsigned char *eeprom);
+ int ftdi_read_dongleid(struct ftdi_context *ftdi, unsigned int *dongleid);
int ftdi_write_eeprom(struct ftdi_context *ftdi, unsigned char *eeprom);
int ftdi_erase_eeprom(struct ftdi_context *ftdi);


ftdi_eeprom-0.2/ftdi_eeprom:

--- main.c.orig 2004-03-25 19:58:08.000000000 +0100
+++ main.c 2007-10-18 16:08:11.000000000 +0200
@@ -64,6 +64,8 @@
struct ftdi_context ftdi;
struct ftdi_eeprom eeprom;

+ unsigned int dongleid;
+
printf("\nFTDI eeprom generator v%s\n", VERSION);
printf ("(c) Intra2net AG <opensource@intra2net.com>\n");

@@ -150,6 +152,8 @@
} else {
printf("Warning: Not writing eeprom, you must supply a valid filename\n");
}
+ printf("FTDI read dongleid: %d\n", ftdi_read_dongleid(&ftdi, &dongleid));
+ printf("FTDI dongleid: %X\n", dongleid);

goto cleanup;
}


[ view entry ] ( 805 views )   |  print article
raid1 with ubuntu feisty 

What i want from a raid1:



notiy if a disk fails


This is done by mdadm

boot degraded with only one disk


boot degraded does not work with ubuntu, because mdadm does not start a degraded raid :-(

my workaround is to add a bootmenue entry in grub

title           Ubuntu, kernel 2.6.20-16-generic (raid defect)
root (hd0,1)
kernel /boot/vmlinuz-2.6.20-16-generic root=/dev/md1 ro raid_degraded
initrd /boot/initrd.img-2.6.20-16-generic

and make an initrd (update-innitramfs -u) with /etc/initramfs-tools/scripts/init-premount/raid_degraded

#!/bin/sh

set -eu

PREREQ="udev"

prereqs()
{
echo "$PREREQ"
}

case ${1:-} in
prereqs)
prereqs
exit 0
;;
*)
. /scripts/functions
;;
esac

if [ -e /scripts/local-top/md ]; then
log_warning_msg "old md initialisation script found, getting out of its way..."
exit 1
fi

MDADM=$(command -v mdadm)
[ -x $MDADM ] || exit 0

if grep raid_degraded /proc/cmdline 2>/dev/null; then
echo "MD_DEGRADED_ARGS=' '" >> /conf/md.conf
fi

exit 0


reported to ubuntu https://bugs.launchpad.net/ubuntu/+source/mdadm/+bug/120375

easy change disk if one disk fails


Threrefore i made a script doing partitioning, adding to raid and installing bootloader of the new disk

#!/bin/sh

if grep -q sda /proc/mdstat; then
SRC_DISK=/dev/sda
DST_DISK=/dev/sdb
else
SRC_DISK=/dev/sdb
DST_DISK=/dev/sda
fi

if ! sfdisk -l 2>/dev/null | grep -q $SRC_DISK; then
echo $SRC_DISK not found
exit 1
fi

if ! sfdisk -l 2>/dev/null | grep -q $DST_DISK; then
echo $DST_DISK not found
exit 1
fi

sfdisk -d $SRC_DISK | sfdisk $DST_DISK

mdadm /dev/md0 -a ${DST_DISK}1
mdadm /dev/md1 -a ${DST_DISK}2

cat /proc/mdstat

/usr/sbin/grub --batch --device-map=/dev/null <<EOF
device (hd0) $DST_DISK
root (hd0,1)
setup (hd0)
quit
EOF

exit 0

set uuid


ubuntu cannot boot if any uuid of any disk is different - solution set uuid:

mdadm --stop /dev/md0
madmd --assemble --verbose /dev/md0 /dev/hda1 /dev/hdb1 \
--update=uuid --uuid=xxxxxxxx:xxxxxxxx:xxxxxxxx:xxxxxxxx

newer versions of mdadm should be able to set uuid with --create

why is my raid1 so slow ?


Reading from my raid1 is as fast as a single sata disc:

hdparm -t /dev/sda1

/dev/sda1:
Timing buffered disk reads: 172 MB in 3.00 seconds = 57.27 MB/sec

hdparm -t /dev/sdb1

/dev/sdb1:
Timing buffered disk reads: 172 MB in 3.01 seconds = 57.20 MB/sec

hdparm -t /dev/md0

/dev/md0:
Timing buffered disk reads: 172 MB in 3.00 seconds = 57.29 MB/sec

i tried

* different motherboard with a different sata onboard controller but also the same results

* different ubuntu kernels: 2.6.17, 2.60.20 and from gutsy 2.6.22rc

* different images:
linux-image-2.6.20-16-generic 2.6.20-16.29
linux-image-2.6.20-16-lowlatency 2.6.20-16.29
linux-image-2.6.20-16-server 2.6.20-16.29

* also a raid1 with PATA Disks

reported to ubuntu https://bugs.launchpad.net/ubuntu/+source/mdadm/+bug/120378

can anybody explain me why?


[ view entry ] ( 495 views )   |  print article

| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |