Re: COMPAT_32BIT libusb ABI problem

2013-07-25 Thread Hans Petter Selasky

On 07/24/13 22:09, Damjan Jovanovic wrote:

Hi

The ioctl:
#define USB_FS_INIT _IOW ('U', 195, struct usb_fs_init)
when used by a COMPAT_32BIT libusb on amd64, fails (causing
libusb_open() to fail) due to:

freebsd32_ioctl(0x6,0x800c55c3,0xc710,0x0,0x0,0x0) ERR#25
'Inappropriate ioctl for device'
but when hacked a bit:
freebsd32_ioctl(0x6,0x801055c3,0xc710,0x0,0x0,0x0) = 0 (0x0)

because sizeof(struct usb_fs_init) is 12 bytes on i386, and 16 bytes on amd64.

But the failure of even libusb_open() - a fundamental libusb function
- must mean that the COMPAT_32BIT libusb never worked. Can we please
take this opportunity to kill it and do a real 32 bit compatibility
layer in the kernel that will work from 32 bit chroots and statically
linked 32 bit binaries? I'll help.


Hi,

How did you compile it? Is the structure the same size, compiled with 
GCC and LLVM?


The LIB32 for USB has been tested. I did a quick test and found on 9-stable:

cc -m32 -I . -L /usr/lib32 -lusb usbconfig.c dump.c
env LD_PRELOAD=/usr/lib32/libusb.so ./a.out
ugen0.1: UHCI root HUB Intel at usbus0, cfg=0 md=HOST spd=FULL 
(12Mbps) pwr=SAVE (0mA)
ugen1.1: UHCI root HUB Intel at usbus1, cfg=0 md=HOST spd=FULL 
(12Mbps) pwr=SAVE (0mA)


...

Your approach requires much more code. It is not just about some 
structures, but also about code accessing those structures. Feel free to 
submit a patch however.


I would rather fix this by adding the proper __aligned() to the 
structures in question.


--HPS

___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to freebsd-usb-unsubscr...@freebsd.org


umass (da) quirk ?

2013-07-25 Thread Patrick Lamaiziere
Hello,

9.2/amd64

I have to add a scsi_da quirk (Q_DA_NO_PREVENT) on a Kinston DT 101 G2
usb stick to make it works.

This quirk is confirmed by a PR on Netbsd but NetBSD adds also few
other Kingston usb keys with this quirk.
http://freshbsd.org/commit/netbsd/6920595603b43ca9e73ca9bcc95e63d9201c9ad3

So while I'm here, i would like to include these other devices in my
PR, but how can I know the match string to put in the quirk without the
hardware?

the quirk is:
{
/*
 * Kingston DT 101 G2 USB stick.
 * PR: 
 */
 {T_DIRECT, SIP_MEDIA_REMOVABLE, Kingston, DT 101 G2,
 *}, /*quirks*/ DA_Q_NO_PREVENT 
},

Another question, I'm sure this key worked on FreeBSD 9.0, and it works
fine on 8.3. I am asking why a quirk is needed now?

Thanks, Regards.
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to freebsd-usb-unsubscr...@freebsd.org


Re: umass (da) quirk ?

2013-07-25 Thread Hans Petter Selasky

On 07/25/13 14:23, Patrick Lamaiziere wrote:

Hello,

9.2/amd64

I have to add a scsi_da quirk (Q_DA_NO_PREVENT) on a Kinston DT 101 G2
usb stick to make it works.

This quirk is confirmed by a PR on Netbsd but NetBSD adds also few
other Kingston usb keys with this quirk.
http://freshbsd.org/commit/netbsd/6920595603b43ca9e73ca9bcc95e63d9201c9ad3

So while I'm here, i would like to include these other devices in my
PR, but how can I know the match string to put in the quirk without the
hardware?

the quirk is:
{
 /*
  * Kingston DT 101 G2 USB stick.
  * PR:
  */
  {T_DIRECT, SIP_MEDIA_REMOVABLE, Kingston, DT 101 G2,
  *}, /*quirks*/ DA_Q_NO_PREVENT
},

Another question, I'm sure this key worked on FreeBSD 9.0, and it works
fine on 8.3. I am asking why a quirk is needed now?



Hi,

I suspect the SCSI/CAM code has changed a bit since 8.3.

--HPS

___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to freebsd-usb-unsubscr...@freebsd.org


Re: COMPAT_32BIT libusb ABI problem

2013-07-25 Thread Damjan Jovanovic
On Thu, Jul 25, 2013 at 6:11 AM, Hans Petter Selasky h...@bitfrost.no wrote:
 On 07/24/13 22:09, Damjan Jovanovic wrote:

 Hi

 The ioctl:
 #define USB_FS_INIT _IOW ('U', 195, struct usb_fs_init)
 when used by a COMPAT_32BIT libusb on amd64, fails (causing
 libusb_open() to fail) due to:

 freebsd32_ioctl(0x6,0x800c55c3,0xc710,0x0,0x0,0x0) ERR#25
 'Inappropriate ioctl for device'
 but when hacked a bit:
 freebsd32_ioctl(0x6,0x801055c3,0xc710,0x0,0x0,0x0) = 0 (0x0)

 because sizeof(struct usb_fs_init) is 12 bytes on i386, and 16 bytes on
 amd64.

 But the failure of even libusb_open() - a fundamental libusb function
 - must mean that the COMPAT_32BIT libusb never worked. Can we please
 take this opportunity to kill it and do a real 32 bit compatibility
 layer in the kernel that will work from 32 bit chroots and statically
 linked 32 bit binaries? I'll help.


 Hi,

 How did you compile it? Is the structure the same size, compiled with GCC
 and LLVM?

GCC 4.2.1
gcc file.c -o file -lusb in a 32 bit chroot = 12 bytes
gcc file.c -o file -lusb 64 bit = 16 bytes

Clang 3.1
clang file.c -o file -lusb in a 32 bit chroot = 12 bytes
clang file.c -o file -lusb 64 bit = 16 bytes

The uint8_t ep_index_max field at the end of struct usb_fs_init must
be getting padded to a 4 byte boundary on 32 bit, and 8 byte boundary
on 64 bit.

 The LIB32 for USB has been tested. I did a quick test and found on 9-stable:

 cc -m32 -I . -L /usr/lib32 -lusb usbconfig.c dump.c
 env LD_PRELOAD=/usr/lib32/libusb.so ./a.out
 ugen0.1: UHCI root HUB Intel at usbus0, cfg=0 md=HOST spd=FULL (12Mbps)
 pwr=SAVE (0mA)
 ugen1.1: UHCI root HUB Intel at usbus1, cfg=0 md=HOST spd=FULL (12Mbps)
 pwr=SAVE (0mA)

 ...

But usbconfig uses the libusb20 API and never seems to get to that broken ioctl.

 Your approach requires much more code. It is not just about some structures,
 but also about code accessing those structures. Feel free to submit a patch
 however.

I'll see what I can do.

 I would rather fix this by adding the proper __aligned() to the structures
 in question.

Do that in the meanwhile?

 --HPS


Damjan
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to freebsd-usb-unsubscr...@freebsd.org


RE: COMPAT_32BIT libusb ABI problem

2013-07-25 Thread Hans Petter Selasky
Hi,

LibUSB 32-bit is compiled using -m32 in a 64-bit environment. What happens when 
you pass -m32 to the compiler?

Thank you for your report.

Another alternative is to use __packed attribute, but that has some 
implications too.

--HPS
 
-Original message-
 From:Damjan Jovanovic damjan@gmail.com mailto:damjan@gmail.com 
 Sent: Thursday 25th July 2013 20:55
 To: Hans Petter Selasky hans.petter.sela...@bitfrost.no 
 mailto:hans.petter.sela...@bitfrost.no 
 Cc: freebsd-usb@freebsd.org mailto:freebsd-usb@freebsd.org 
 Subject: Re: COMPAT_32BIT libusb ABI problem
 
 On Thu, Jul 25, 2013 at 6:11 AM, Hans Petter Selasky h...@bitfrost.no 
 mailto:h...@bitfrost.no  wrote:
  On 07/24/13 22:09, Damjan Jovanovic wrote:
 
  Hi
 
  The ioctl:
  #define USB_FS_INIT _IOW ('U', 195, struct usb_fs_init)
  when used by a COMPAT_32BIT libusb on amd64, fails (causing
  libusb_open() to fail) due to:
 
  freebsd32_ioctl(0x6,0x800c55c3,0xc710,0x0,0x0,0x0) ERR#25
  'Inappropriate ioctl for device'
  but when hacked a bit:
  freebsd32_ioctl(0x6,0x801055c3,0xc710,0x0,0x0,0x0) = 0 (0x0)
 
  because sizeof(struct usb_fs_init) is 12 bytes on i386, and 16 bytes on
  amd64.
 
  But the failure of even libusb_open() - a fundamental libusb function
  - must mean that the COMPAT_32BIT libusb never worked. Can we please
  take this opportunity to kill it and do a real 32 bit compatibility
  layer in the kernel that will work from 32 bit chroots and statically
  linked 32 bit binaries? I'll help.
 
 
  Hi,
 
  How did you compile it? Is the structure the same size, compiled with GCC
  and LLVM?
 
 GCC 4.2.1
 gcc file.c -o file -lusb in a 32 bit chroot = 12 bytes
 gcc file.c -o file -lusb 64 bit = 16 bytes
 
 Clang 3.1
 clang file.c -o file -lusb in a 32 bit chroot = 12 bytes
 clang file.c -o file -lusb 64 bit = 16 bytes
 
 The uint8_t ep_index_max field at the end of struct usb_fs_init must
 be getting padded to a 4 byte boundary on 32 bit, and 8 byte boundary
 on 64 bit.
 
  The LIB32 for USB has been tested. I did a quick test and found on 9-stable:
 
  cc -m32 -I . -L /usr/lib32 -lusb usbconfig.c dump.c
  env LD_PRELOAD=/usr/lib32/libusb.so ./a.out
  ugen0.1: UHCI root HUB Intel at usbus0, cfg=0 md=HOST spd=FULL (12Mbps)
  pwr=SAVE (0mA)
  ugen1.1: UHCI root HUB Intel at usbus1, cfg=0 md=HOST spd=FULL (12Mbps)
  pwr=SAVE (0mA)
 
  ...
 
 But usbconfig uses the libusb20 API and never seems to get to that broken 
 ioctl.
 
  Your approach requires much more code. It is not just about some structures,
  but also about code accessing those structures. Feel free to submit a patch
  however.
 
 I'll see what I can do.
 
  I would rather fix this by adding the proper __aligned() to the structures
  in question.
 
 Do that in the meanwhile?
 
  --HPS
 
 
 Damjan
 

___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to freebsd-usb-unsubscr...@freebsd.org


Re: usb/180837: [scsi_da] [patch] Kingston DT 101 G2 usb stick quirk (scsi_da quirk)

2013-07-25 Thread linimon
Old Synopsis: QUIRK: Kingston DT 101 G2 usb stick (scsi_da quirk)
New Synopsis: [scsi_da] [patch] Kingston DT 101 G2 usb stick quirk (scsi_da 
quirk)

Responsible-Changed-From-To: freebsd-bugs-freebsd-usb
Responsible-Changed-By: linimon
Responsible-Changed-When: Fri Jul 26 02:02:33 UTC 2013
Responsible-Changed-Why: 
Over to maintainer(s).

http://www.freebsd.org/cgi/query-pr.cgi?pr=180837
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to freebsd-usb-unsubscr...@freebsd.org