Re: sdcard read error with nokia n8 as mass storage

2013-02-19 Thread Alexander Motin
On 19.02.2013 09:14, Hans Petter Selasky wrote:
 On Monday 18 February 2013 22:57:25 Jan Beich wrote:
 Hans Petter Selasky hsela...@c2i.net writes:
 On Monday 18 February 2013 07:11:56 Jan Beich wrote:
 Hans Petter Selasky hsela...@c2i.net writes:
 On Sunday 17 February 2013 17:24:23 Jan Beich wrote:
 The phone has 16G of on-board and 16G sdcard memory. FreeBSD 10.0
 detects both but only the former can be mounted. And there is no
 issue mounting the sdcard on Ubuntu or on FreeBSD via iSCSI
 (fileio).

 [...]

 $ usbdump -i usbus7 -s 0 -vvv # on attach
 http://pastebin.com/mQ472uQJ

 forgotten linux usbmon dump - http://pastebin.com/Df9Zp6T5

 [...]

 forgotten debug log - http://pastebin.com/NzpSJBRA

 http://pastebin.com/P9474rw4 # no quirks (via source edit)

 Why UQ_MSC_NO_SYNC_CACHE is always added for the device? on-board (da0)
 memory seems to mount/work just fine without + Medium not present
 is gone.

 $ usbconfig dump_device_quirks | fgrep 421
 empty

 $ kenv | fgrep usb
 hw.usb.no_boot_wait=1
 hw.usb.umass.debug=-1

 Try this quirk:

 usbconfig -d x.y add_quirk UQ_MSC_NO_INQUIRY

 http://pastebin.com/4R0MYTUK # UQ_MSC_NO_INQUIRY
 http://pastebin.com/AGHGiC3n # UQ_MSC_NO_INQUIRY + UQ_MSC_NO_SYNC_CACHE

 I've tried a few more (at random) with no luck either.

 http://pastebin.com/RW2cg51S # UQ_MSC_FORCE_SHORT_INQ
 http://pastebin.com/ahiUvS7f # UQ_MSC_WRONG_CSWSIG
 http://pastebin.com/Wf6Be9uN # UQ_MSC_IGNORE_RESIDUE
 http://pastebin.com/0W4pcKmY # UQ_MSC_READ_CAP_OFFBY1

 Linux seems to use only CAPACITY_HEURISTICS quirk.
 
 Hi,
 
 The device fails on READ_10. Maybe this command is not supported. I'm not 
 sure 
 how to reprogram CAM/SCSI layers to use READ_6 instead.

CAM DA driver uses shortest possible command, but no shorter then
kern.cam.da.X.minimum_cmd_size value, that is 10 by default for umass
due to cpi-hba_misc = PIM_NO_6_BYTE set in umass.c.

-- 
Alexander Motin
___
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


Insufficient memory reserved for xfer-dma_page_ptr?

2013-02-19 Thread Aman Sawrup

Hi Hans,

I think I might have found a bug in usbd_transfer_setup_sub that causes 
insufficient memory allocated for xfer-dma_page_ptr.  The code in 
question is:


#if USB_HAVE_BUSDMA
if (xfer-flags_int.bdma_enable) {
/*
 * Setup dma_page_ptr.
 *
 * Proof for formula below:
 *
 * Assume there are three USB frames having length a, b and
 * c. These USB frames will at maximum need z
 * usb_page structures. z is given by:
 *
 * z = ((a / USB_PAGE_SIZE) + 2) + ((b / USB_PAGE_SIZE) + 2) +
 * ((c / USB_PAGE_SIZE) + 2);
 *
 * Constraining a, b and c like this:
 *
 * (a + b + c) = parm-bufsize
 *
 * We know that:
 *
 * z = ((parm-bufsize / USB_PAGE_SIZE) + (3*2));
 *
 * Here is the general formula:
 */
xfer-dma_page_ptr = parm-dma_page_ptr;
parm-dma_page_ptr += (2 * n_frbuffers);
parm-dma_page_ptr += (parm-bufsize / USB_PAGE_SIZE);
}
#endif

What I observe happening on a 64-bit x86 system is 4608 bytes reserved 
for xfer-dma_page_ptr.  For example, this is what I see:


(gdb) p parm-dma_page_ptr
$75 = (struct usb_page *) 0x6dad46e0

(gdb) p xfer-dma_page_ptr
$76 = (struct usb_page *) 0x6dad34e0

(gdb) p /d 0x6dad46e0 - 0x6dad34e0
$79 = 4608

(gdb) p /d sizeof(struct usb_page)
$74 = 16

(gdb) p /d n_frbuffers
$68 = 128

(gdb) p /d parm-bufsize
$70 = 131072

I believe the amount of memory reserved needs to be much higher.  For 
example, if sizeof(struct usb_page) is 16 bytes, then for n_frbuffers of 
128 and parm-bufsize of 131072, we need the following amount of memory 
reserved:


parm-bufsize / USB_PAGE_SIZE * n_frbuffers * sizeof(struct usb_page)
= 131072 / 4096 * 128 * 16
= 65536

Thanks
Aman

___
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: Insufficient memory reserved for xfer-dma_page_ptr?

2013-02-19 Thread Hans Petter Selasky
On Tuesday 19 February 2013 23:26:19 Aman Sawrup wrote:
 I believe the amount of memory reserved needs to be much higher.  For 
 example, if sizeof(struct usb_page) is 16 bytes, then for n_frbuffers of 
 128 and parm-bufsize of 131072, we need the following amount of memory 
 reserved:
 
 parm-bufsize / USB_PAGE_SIZE * n_frbuffers * sizeof(struct usb_page)
 = 131072 / 4096 * 128 * 16
 = 65536

Hi,

The parm-bufsize is shared for all frbuffers, so the formula should be 
correct. In your computation you assume that parm-bufsize gives the maximum 
for each frbuffer. That is not the case.

That means, when you configure bufsize, you must not exceed that size as a 
total when setting up frames. This include all transfer types. I think there 
are asserts for that so you should get a panic fairly quickly.

--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