[PATCH resend v3 3/5] libata-scsi: use u8 array to store mode page copy

2016-07-22 Thread tom . ty89
From: Tom Yan ata_mselect_*() would initialize a char array for storing a copy of the current mode page. However, char could be signed char. In that case, bytes larger than 127 would be converted to negative number. For example, 0xff from def_control_mpage[] would become -1. This prevented ata_m

[PATCH resend v2 3/5] libata-scsi: use u8 array to store mode page copy

2016-07-21 Thread tom . ty89
From: Tom Yan ata_mselect_*() would initialize a char array for storing a copy of the current mode page. However, char could be signed char. In that case, bytes larger than 127 would be converted to negative number. For example, 0xff from def_control_mpage[] would become -1. This prevented ata_m

[PATCH resend v2 2/5] libata-scsi: fix read-only bits checking in ata_mselect_*()

2016-07-21 Thread tom . ty89
From: Tom Yan Commit 7780081c1f04 ("libata-scsi: Set information sense field for invalid parameter") changed how ata_mselect_*() make sure read-only bits are not modified. The new implementation introduced a bug that the read-only bits in the byte that has a changeable bit will not be checked. M

[PATCH resend v2 3/5] libata-scsi: use u8 array to store mode page copy

2016-07-21 Thread tom . ty89
From: Tom Yan ata_mselect_*() would initialize a char array for storing a copy of the current mode page. However, char could be signed char. In that case, bytes larger than 127 would be converted to negative number. For example, 0xff from def_control_mpage[] would become -1. This prevented ata_m

[PATCH resend v2 2/5] libata-scsi: fix read-only bits checking in ata_mselect_*()

2016-07-21 Thread tom . ty89
From: Tom Yan Commit 7780081c1f04 ("libata-scsi: Set information sense field for invalid parameter") changed how ata_mselect_*() make sure read-only bits are not modified. The new implementation introduced a bug that the read-only bits in the byte that has a changeable bit will not be checked. M

[PATCH resend 4/5] libata-scsi: have all checks done before calling ata_mselect_*()

2016-07-21 Thread tom . ty89
From: Tom Yan The one-page-at-a-time check in ata_scsi_mode_select_xlat() should be done before either of the ata_mselect_*() is called. Also updated the comment. We have more than one mode page that has changeable bit since commit 06dbde5f3a44 ("libata: Implement control mode page to select sen

[PATCH resend 5/5] libata-scsi: fix MODE SELECT translation for Control mode page

2016-07-21 Thread tom . ty89
From: Tom Yan scsi_done() was called repeatedly and apparently because of that, the kernel would call trace when we touch the Control mode page: Call Trace: [] dump_stack+0x63/0x81 [] __warn+0xcb/0xf0 [] warn_slowpath_null+0x1d/0x20 [] ata_eh_finish+0xe0/0xf0 [libata] [] sata_pmp_error_hand

[PATCH resend 2/5] libata-scsi: fix read-only bits checking in ata_mselect_*()

2016-07-21 Thread tom . ty89
From: Tom Yan Commit 7780081c1f04 ("libata-scsi: Set information sense field for invalid parameter") changed how ata_mselect_*() make sure read-only bits are not modified. The new implementation introduced a bug that the read-only bits in the byte that has a changeable bit will not be checked. A

[PATCH resend 3/5] libata-scsi: fix overflow in mode page copy

2016-07-21 Thread tom . ty89
From: Tom Yan ata_mselect_*() would initialize a char array for storing a copy of the current mode page. However, if char was actually signed char, overflow could occur. For example, `0xff` from def_control_mpage[] would be "truncated" to `-1`. This prevented ata_mselect_control() from working a

[PATCH resend 1/5] libata-scsi: minor cleanup in ata_mselect_*()

2016-07-21 Thread tom . ty89
From: Tom Yan 1. Removed a repeated bit masking in ata_mselect_control() 2. Moved `wce`/`d_sense` assignment below the page validity checks 3. Added/Removed empty lines where appropriate Signed-off-by: Tom Yan diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 2bdb5da..eb