[RFC 1/3] ata: bump ATA_MAX_SECTORS_LBA48 to 65536

2016-07-12 Thread tom . ty89
From: Tom Yan 

ATA_MAX_SECTORS_LBA48 is only used for setting the queue limit
"max_hw_sectors", which only serves as the cap for "max_sectors",
which is in turn the actual limit being used. Therefore, it should
be alright for us to bump ATA_MAX_SECTORS_LBA48 to 65536. Also,
lba_48_ok() has been accepting the number of blocks to be 65536.

Signed-off-by: Tom Yan 

diff --git a/include/linux/ata.h b/include/linux/ata.h
index 99346be..24f886c 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -46,7 +46,7 @@ enum {
ATA_MAX_SECTORS_128 = 128,
ATA_MAX_SECTORS = 256,
ATA_MAX_SECTORS_1024= 1024,
-   ATA_MAX_SECTORS_LBA48   = 65535,/* TODO: 65536? */
+   ATA_MAX_SECTORS_LBA48   = 65536,
ATA_MAX_SECTORS_TAPE= 65535,
 
ATA_ID_WORDS= 256,
-- 
2.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC 2/3] ata: make lba_{28,48}_ok() use ATA_MAX_SECTORS{,_LBA48}

2016-07-12 Thread tom . ty89
From: Tom Yan 

Signed-off-by: Tom Yan 

diff --git a/include/linux/ata.h b/include/linux/ata.h
index 24f886c..d4bb802 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -1095,13 +1095,13 @@ static inline bool ata_ok(u8 status)
 static inline bool lba_28_ok(u64 block, u32 n_block)
 {
/* check the ending block number: must be LESS THAN 0x0fff */
-   return ((block + n_block) < ((1 << 28) - 1)) && (n_block <= 256);
+   return ((block + n_block) < ((1 << 28) - 1)) && (n_block <= 
ATA_MAX_SECTORS);
 }
 
 static inline bool lba_48_ok(u64 block, u32 n_block)
 {
/* check the ending block number */
-   return ((block + n_block - 1) < ((u64)1 << 48)) && (n_block <= 65536);
+   return ((block + n_block - 1) < ((u64)1 << 48)) && (n_block <= 
ATA_MAX_SECTORS_LBA48);
 }
 
 #define sata_pmp_gscr_vendor(gscr) ((gscr)[SATA_PMP_GSCR_PROD_ID] & 0x)
-- 
2.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC 3/3] libata-scsi: add optimal transfer length to block limits VPD

2016-07-12 Thread tom . ty89
From: Tom Yan 

As of commit 6b7e9cde4969 ("sd: Fix rw_max for devices that report
an optimal xfer size"), the scsi disk driver (correctly) derive both
of the queue limits "io_opt" and "max_sectors" from the optimal
transfer length field.

In case we would like the two limits to be derived from a value
other than BLK_DEF_MAX_SECTORS for ATA disks in the future, this
patch has made it easy.

Signed-off-by: Tom Yan 

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index bfec66f..ab75b5e 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -2305,6 +2305,13 @@ static unsigned int ata_scsiop_inq_b0(struct 
ata_scsi_args *args, u8 *rbuf)
put_unaligned_be16(min_io_sectors, [6]);
 
/*
+* Optimal transfer length.
+*
+* This is used to derive the queue limit "max_sector" and "io_opt".
+*/
+   put_unaligned_be32(BLK_DEF_MAX_SECTORS, [12]);
+
+   /*
 * Optimal unmap granularity.
 *
 * The ATA spec doesn't even know about a granularity or alignment
-- 
2.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] scsi: remove the disable_blk_mq host flag

2016-07-12 Thread Christoph Hellwig
We've had scsi-mq for 2.5 years now, so we can remove the unused flag
to disable the code on a per-host basis that was put in for unexpected
emergencies during bringup.

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/hosts.c | 2 --
 drivers/scsi/scsi.c  | 1 +
 include/scsi/scsi_host.h | 6 ++
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 1547bd9..ba9af4a 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -486,8 +486,6 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template 
*sht, int privsize)
else
shost->dma_boundary = 0x;
 
-   shost->use_blk_mq = scsi_use_blk_mq && !shost->hostt->disable_blk_mq;
-
device_initialize(>shost_gendev);
dev_set_name(>shost_gendev, "host%d", shost->host_no);
shost->shost_gendev.bus = _bus_type;
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 1deb6ad..1f36aca 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -1160,6 +1160,7 @@ bool scsi_use_blk_mq = true;
 bool scsi_use_blk_mq = false;
 #endif
 module_param_named(use_blk_mq, scsi_use_blk_mq, bool, S_IWUSR | S_IRUGO);
+EXPORT_SYMBOL_GPL(scsi_use_blk_mq);
 
 static int __init init_scsi(void)
 {
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 76e9d27..0dee7af 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -495,9 +495,6 @@ struct scsi_host_template {
 */
unsigned int cmd_size;
struct scsi_host_cmd_pool *cmd_pool;
-
-   /* temporary flag to disable blk-mq I/O path */
-   bool disable_blk_mq;
 };
 
 /*
@@ -778,7 +775,8 @@ extern bool scsi_use_blk_mq;
 
 static inline bool shost_use_blk_mq(struct Scsi_Host *shost)
 {
-   return shost->use_blk_mq;
+   return scsi_use_blk_mq;
+
 }
 
 extern int scsi_queue_work(struct Scsi_Host *, struct work_struct *);
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/3] ipr: Add scsi multi-queue support

2016-07-12 Thread Christoph Hellwig
On Tue, Jul 12, 2016 at 04:02:09PM -0500, wenxi...@linux.vnet.ibm.com wrote:
> From: Wen Xiong 
> 
> Add scsi multi-queue support in ipr driver. This feature
> is enabled by setting ipr_use_blk_mq=1 when loading ipr
> module and scsi blk-mq is enabled in the kernel.

This is not a useful option, as using of blk-mq is not up to the
driver.  If you want to control the number of queues used please
add a nr_queues option instead.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] ipr: Add new CCIN for new adapters support

2016-07-12 Thread Brian King
Acked-by: Brian King 


-- 
Brian King
Power Linux I/O
IBM Linux Technology Center

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/3] ipr: Increase MSIX vectors number

2016-07-12 Thread Brian King
Acked-by: Brian King 

-- 
Brian King
Power Linux I/O
IBM Linux Technology Center

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/3] ipr: Add scsi multi-queue support

2016-07-12 Thread Brian King
On 07/12/2016 04:02 PM, wenxi...@linux.vnet.ibm.com wrote:
> From: Wen Xiong 
> 
> Add scsi multi-queue support in ipr driver. This feature
> is enabled by setting ipr_use_blk_mq=1 when loading ipr
> module and scsi blk-mq is enabled in the kernel.
> 
> Signed-off-by: Wen Xiong 
> ---
>  drivers/scsi/ipr.c |   16 ++--
>  drivers/scsi/ipr.h |1 +
>  2 files changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
> index 1f539c2..21b6da6 100644
> --- a/drivers/scsi/ipr.c
> +++ b/drivers/scsi/ipr.c
> @@ -100,6 +100,7 @@ static unsigned int ipr_max_devs = IPR_DEFAULT_SIS64_DEVS;
>  static unsigned int ipr_dual_ioa_raid = 1;
>  static unsigned int ipr_number_of_msix = 16;
>  static unsigned int ipr_fast_reboot;
> +static unsigned int ipr_use_blk_mq = 0;

No need to initialize a static to 0. Can you be sure to run 
scripts/checkpatch.pl
in future? 


> @@ -6329,7 +6333,12 @@ static int ipr_queuecommand(struct Scsi_Host *shost,
>   return rc;
>   }
> 
> - hrrq_id = ipr_get_hrrq_index(ioa_cfg);
> + if (ioa_cfg->use_blk_mq && shost_use_blk_mq(scsi_cmd->device->host)) {
> + tag = blk_mq_unique_tag(scsi_cmd->request);
> + hrrq_id = blk_mq_unique_tag_to_hwq(tag);
> + } else
> + hrrq_id = ipr_get_hrrq_index(ioa_cfg);
> +
>   hrrq = _cfg->hrrq[hrrq_id];
> 
>   spin_lock_irqsave(hrrq->lock, hrrq_flags);
> @@ -10144,6 +10153,8 @@ static int ipr_probe_ioa(struct pci_dev *pdev,
>   (unsigned int)num_online_cpus(),
>   (unsigned int)IPR_MAX_HRRQ_NUM);
> 
> + host->nr_hw_queues = ioa_cfg->hrrq_num;

Prior to this patch we reserved HRRQ 0 for error interrupts. This changes that
to use it also for normal I/O interrupts. One side effect of this is that we
can now no longer use iopoll for HRRQ 0. It would be nice to not change this
behavior and keep using HRRQ 0 for errors only, since we have an MMIO read
in that path we wanted to avoid in the normal I/O path.

I think if we just change the line above to:

host->nr_hw_queues = ioa_cfg->hrrq_num - 1;

Then this should resolve this. Can you verify this doesn't break anything?

Thanks,

Brian

-- 
Brian King
Power Linux I/O
IBM Linux Technology Center

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/3] ipr: Increase MSIX vectors number

2016-07-12 Thread Gabriel Krisman Bertazi
wenxi...@linux.vnet.ibm.com writes:

> From: Wen Xiong 
>
> Increase MSIX vectors from 2 to 16 by default.
>
> Signed-off-by: Wen Xiong 
> ---

Reviewed-by: Gabriel Krisman Bertazi 

Thanks,

-- 
Gabriel Krisman Bertazi

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] ipr: Add new CCIN for new adapters support

2016-07-12 Thread Gabriel Krisman Bertazi
wenxi...@linux.vnet.ibm.com writes:

> From: Wen Xiong 
>
> Add the appropriate definitions and table entries for new
> adapters support.
>
> Signed-off-by: Wen Xiong 

Reviewed-by: Gabriel Krisman Bertazi 


-- 
Gabriel Krisman Bertazi

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] ipr: Add scsi multi-queue support

2016-07-12 Thread wenxiong
From: Wen Xiong 

Add scsi multi-queue support in ipr driver. This feature
is enabled by setting ipr_use_blk_mq=1 when loading ipr
module and scsi blk-mq is enabled in the kernel.

Signed-off-by: Wen Xiong 
---
 drivers/scsi/ipr.c |   16 ++--
 drivers/scsi/ipr.h |1 +
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 1f539c2..21b6da6 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -100,6 +100,7 @@ static unsigned int ipr_max_devs = IPR_DEFAULT_SIS64_DEVS;
 static unsigned int ipr_dual_ioa_raid = 1;
 static unsigned int ipr_number_of_msix = 16;
 static unsigned int ipr_fast_reboot;
+static unsigned int ipr_use_blk_mq = 0;
 static DEFINE_SPINLOCK(ipr_driver_lock);
 
 /* This table describes the differences between DMA controller chips */
@@ -225,6 +226,8 @@ module_param_named(number_of_msix, ipr_number_of_msix, int, 
0);
 MODULE_PARM_DESC(number_of_msix, "Specify the number of MSIX interrupts to use 
on capable adapters (1 - 16).  (default:16)");
 module_param_named(fast_reboot, ipr_fast_reboot, int, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(fast_reboot, "Skip adapter shutdown during reboot. Set to 1 
to enable. (default: 0)");
+module_param_named(use_blk_mq, ipr_use_blk_mq, uint, S_IRUGO);
+MODULE_PARM_DESC(use_blk_mq, "ipr use block mq enable/disable. (default: 0)");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(IPR_DRIVER_VERSION);
 
@@ -6316,6 +6319,7 @@ static int ipr_queuecommand(struct Scsi_Host *shost,
int rc;
struct ipr_hrr_queue *hrrq;
int hrrq_id;
+   uint32_t tag;
 
ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
 
@@ -6329,7 +6333,12 @@ static int ipr_queuecommand(struct Scsi_Host *shost,
return rc;
}
 
-   hrrq_id = ipr_get_hrrq_index(ioa_cfg);
+   if (ioa_cfg->use_blk_mq && shost_use_blk_mq(scsi_cmd->device->host)) {
+   tag = blk_mq_unique_tag(scsi_cmd->request);
+   hrrq_id = blk_mq_unique_tag_to_hwq(tag);
+   } else
+   hrrq_id = ipr_get_hrrq_index(ioa_cfg);
+
hrrq = _cfg->hrrq[hrrq_id];
 
spin_lock_irqsave(hrrq->lock, hrrq_flags);
@@ -10144,6 +10153,8 @@ static int ipr_probe_ioa(struct pci_dev *pdev,
(unsigned int)num_online_cpus(),
(unsigned int)IPR_MAX_HRRQ_NUM);
 
+   host->nr_hw_queues = ioa_cfg->hrrq_num;
+
if ((rc = ipr_save_pcix_cmd_reg(ioa_cfg)))
goto out_msi_disable;
 
@@ -10377,7 +10388,7 @@ static int ipr_probe(struct pci_dev *pdev, const struct 
pci_device_id *dev_id)
return rc;
}
 
-   rc = scsi_add_host(ioa_cfg->host, >dev);
+   rc = scsi_add_host_with_dma(ioa_cfg->host, >dev, >dev);
 
if (rc) {
__ipr_remove(pdev);
@@ -10406,6 +10417,7 @@ static int ipr_probe(struct pci_dev *pdev, const struct 
pci_device_id *dev_id)
 
scsi_scan_host(ioa_cfg->host);
ioa_cfg->iopoll_weight = ioa_cfg->chip_cfg->iopoll_weight;
+   ioa_cfg->use_blk_mq = ipr_use_blk_mq;
 
if (ioa_cfg->iopoll_weight && ioa_cfg->sis64 && ioa_cfg->nvectors > 1) {
for (i = 1; i < ioa_cfg->hrrq_num; i++) {
diff --git a/drivers/scsi/ipr.h b/drivers/scsi/ipr.h
index 1d42c74..f79c96b 100644
--- a/drivers/scsi/ipr.h
+++ b/drivers/scsi/ipr.h
@@ -1597,6 +1597,7 @@ struct ipr_ioa_cfg {
} vectors_info[IPR_MAX_MSIX_VECTORS];
 
u32 iopoll_weight;
+   u32 use_blk_mq;
 
 }; /* struct ipr_ioa_cfg */
 
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] ipr: Add new CCIN for new adapters support

2016-07-12 Thread wenxiong
From: Wen Xiong 

Add the appropriate definitions and table entries for new
adapters support.

Signed-off-by: Wen Xiong 
---
 drivers/scsi/ipr.c |7 ++-
 drivers/scsi/ipr.h |3 +++
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index d6803a9..01dc065 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -194,7 +194,8 @@ static const struct ipr_chip_t ipr_chip[] = {
{ PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_SNIPE, IPR_USE_LSI, IPR_SIS32, 
IPR_PCI_CFG, _chip_cfg[1] },
{ PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP, IPR_USE_LSI, 
IPR_SIS32, IPR_PCI_CFG, _chip_cfg[1] },
{ PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CROC_FPGA_E2, IPR_USE_MSI, 
IPR_SIS64, IPR_MMIO, _chip_cfg[2] },
-   { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CROCODILE, IPR_USE_MSI, 
IPR_SIS64, IPR_MMIO, _chip_cfg[2] }
+   { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CROCODILE, IPR_USE_MSI, 
IPR_SIS64, IPR_MMIO, _chip_cfg[2] },
+   { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_RATTLESNAKE, IPR_USE_MSI, 
IPR_SIS64, IPR_MMIO, _chip_cfg[2] }
 };
 
 static int ipr_max_bus_speeds[] = {
@@ -10565,6 +10566,10 @@ static struct pci_device_id ipr_pci_table[] = {
PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_2CD2, 0, 0, 0 },
{ PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CROCODILE,
PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_2CCD, 0, 0, 0 },
+   { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_RATTLESNAKE,
+   PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_580A, 0, 0, 0 },
+   { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_RATTLESNAKE,
+   PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_580B, 0, 0, 0 },
{ }
 };
 MODULE_DEVICE_TABLE(pci, ipr_pci_table);
diff --git a/drivers/scsi/ipr.h b/drivers/scsi/ipr.h
index 56c5706..1d42c74 100644
--- a/drivers/scsi/ipr.h
+++ b/drivers/scsi/ipr.h
@@ -60,6 +60,7 @@
 
 #define PCI_DEVICE_ID_IBM_CROC_FPGA_E2  0x033D
 #define PCI_DEVICE_ID_IBM_CROCODILE 0x034A
+#define PCI_DEVICE_ID_IBM_RATTLESNAKE  0x04DA
 
 #define IPR_SUBS_DEV_ID_2780   0x0264
 #define IPR_SUBS_DEV_ID_5702   0x0266
@@ -111,6 +112,8 @@
 #define IPR_SUBS_DEV_ID_2CCA   0x04C7
 #define IPR_SUBS_DEV_ID_2CD2   0x04C8
 #define IPR_SUBS_DEV_ID_2CCD   0x04C9
+#define IPR_SUBS_DEV_ID_580A   0x04FC
+#define IPR_SUBS_DEV_ID_580B   0x04FB
 #define IPR_NAME   "ipr"
 
 /*
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] ipr: Increase MSIX vectors number

2016-07-12 Thread wenxiong
From: Wen Xiong 

Increase MSIX vectors from 2 to 16 by default.

Signed-off-by: Wen Xiong 
---
 drivers/scsi/ipr.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 01dc065..1f539c2 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -98,7 +98,7 @@ static unsigned int ipr_transop_timeout = 0;
 static unsigned int ipr_debug = 0;
 static unsigned int ipr_max_devs = IPR_DEFAULT_SIS64_DEVS;
 static unsigned int ipr_dual_ioa_raid = 1;
-static unsigned int ipr_number_of_msix = 2;
+static unsigned int ipr_number_of_msix = 16;
 static unsigned int ipr_fast_reboot;
 static DEFINE_SPINLOCK(ipr_driver_lock);
 
@@ -222,7 +222,7 @@ module_param_named(max_devs, ipr_max_devs, int, 0);
 MODULE_PARM_DESC(max_devs, "Specify the maximum number of physical devices. "
 "[Default=" __stringify(IPR_DEFAULT_SIS64_DEVS) "]");
 module_param_named(number_of_msix, ipr_number_of_msix, int, 0);
-MODULE_PARM_DESC(number_of_msix, "Specify the number of MSIX interrupts to use 
on capable adapters (1 - 16).  (default:2)");
+MODULE_PARM_DESC(number_of_msix, "Specify the number of MSIX interrupts to use 
on capable adapters (1 - 16).  (default:16)");
 module_param_named(fast_reboot, ipr_fast_reboot, int, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(fast_reboot, "Skip adapter shutdown during reboot. Set to 1 
to enable. (default: 0)");
 MODULE_LICENSE("GPL");
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6 2/2] libata-scsi: avoid repeated calculation of number of TRIM ranges

2016-07-12 Thread Tejun Heo
On Wed, Jul 13, 2016 at 04:31:23AM +0800, tom.t...@gmail.com wrote:
> From: Tom Yan 
> 
> Currently libata statically allows only 1-block (512-byte) payload
> for each TRIM command. Each payload can carry 64 TRIM ranges since
> each range requires 8 bytes.
> 
> It is silly to keep doing the calculation (512 / 8) in different
> places. Hence, define the new ATA_MAX_TRIM_RNUM for the result.
> 
> Signed-off-by: Tom Yan 

Applied 1-2 to libata/for-4.8.

Thanks.

-- 
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v6 1/2] libata-scsi: reject WRITE SAME (16) with n_block that exceeds limit

2016-07-12 Thread tom . ty89
From: Tom Yan 

Currently if a WRITE SAME (16) command is issued to the SATL with
"number of blocks" that is larger than the "Maximum write same length"
(which is the maximum number of blocks per TRIM command allowed in
libata, currently 65535 * 512 / 8 blocks), the SATL will accept the
command and translate it to a TRIM command with the upper limit.

However, according to SBC (as of sbc4r11.pdf), the "device server"
should terminate the command with "Invalid field in CDB" in that case.

Signed-off-by: Tom Yan 

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index bfec66f..392aebb 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -3305,7 +3305,13 @@ static unsigned int ata_scsi_write_same_xlat(struct 
ata_queued_cmd *qc)
goto invalid_param_len;
 
buf = page_address(sg_page(scsi_sglist(scmd)));
-   size = ata_set_lba_range_entries(buf, 512, block, n_block);
+
+   if (n_block <= 65535 * 512 / 8) {
+   size = ata_set_lba_range_entries(buf, 512, block, n_block);
+   } else {
+   fp = 2;
+   goto invalid_fld;
+   }
 
if (ata_ncq_enabled(dev) && ata_fpdma_dsm_supported(dev)) {
/* Newer devices support queued TRIM commands */
-- 
2.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v6 2/2] libata-scsi: avoid repeated calculation of number of TRIM ranges

2016-07-12 Thread tom . ty89
From: Tom Yan 

Currently libata statically allows only 1-block (512-byte) payload
for each TRIM command. Each payload can carry 64 TRIM ranges since
each range requires 8 bytes.

It is silly to keep doing the calculation (512 / 8) in different
places. Hence, define the new ATA_MAX_TRIM_RNUM for the result.

Signed-off-by: Tom Yan 

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 392aebb..62fb5b9 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -2314,7 +2314,7 @@ static unsigned int ata_scsiop_inq_b0(struct 
ata_scsi_args *args, u8 *rbuf)
 * with the unmap bit set.
 */
if (ata_id_has_trim(args->id)) {
-   put_unaligned_be64(65535 * 512 / 8, [36]);
+   put_unaligned_be64(65535 * ATA_MAX_TRIM_RNUM, [36]);
put_unaligned_be32(1, [28]);
}
 
@@ -3306,8 +3306,8 @@ static unsigned int ata_scsi_write_same_xlat(struct 
ata_queued_cmd *qc)
 
buf = page_address(sg_page(scsi_sglist(scmd)));
 
-   if (n_block <= 65535 * 512 / 8) {
-   size = ata_set_lba_range_entries(buf, 512, block, n_block);
+   if (n_block <= 65535 * ATA_MAX_TRIM_RNUM) {
+   size = ata_set_lba_range_entries(buf, ATA_MAX_TRIM_RNUM, block, 
n_block);
} else {
fp = 2;
goto invalid_fld;
diff --git a/include/linux/ata.h b/include/linux/ata.h
index 99346be..2d2d072 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -48,6 +48,7 @@ enum {
ATA_MAX_SECTORS_1024= 1024,
ATA_MAX_SECTORS_LBA48   = 65535,/* TODO: 65536? */
ATA_MAX_SECTORS_TAPE= 65535,
+   ATA_MAX_TRIM_RNUM   = 64,   /* 512-byte payload / (6-byte LBA + 
2-byte range per entry) */
 
ATA_ID_WORDS= 256,
ATA_ID_CONFIG   = 0,
@@ -1066,12 +1067,12 @@ static inline void ata_id_to_hd_driveid(u16 *id)
  * TO NV CACHE PINNED SET.
  */
 static inline unsigned ata_set_lba_range_entries(void *_buffer,
-   unsigned buf_size, u64 sector, unsigned long count)
+   unsigned num, u64 sector, unsigned long count)
 {
__le64 *buffer = _buffer;
unsigned i = 0, used_bytes;
 
-   while (i < buf_size / 8 ) { /* 6-byte LBA + 2-byte range per entry */
+   while (i < num) {
u64 entry = sector |
((u64)(count > 0x ? 0x : count) << 48);
buffer[i++] = __cpu_to_le64(entry);
-- 
2.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] cxl: remove dead Kconfig options

2016-07-12 Thread Matthew R. Ochs
> On Jul 4, 2016, at 2:12 AM, Andrew Donnellan  
> wrote:
> 
> Remove the CXL_KERNEL_API and CXL_EEH Kconfig options, as they were only
> needed to coordinate the merging of the cxlflash driver. Also remove the
> stub implementation of cxl_perst_reloads_same_image() in cxlflash which is
> only used if CXL_EEH isn't defined (i.e. never).
> 
> Suggested-by: Ian Munsie 
> Signed-off-by: Andrew Donnellan 

Acked-by: Matthew R. Ochs 


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 1/2] libata-scsi: reject WRITE SAME (16) with n_block that exceeds limit

2016-07-12 Thread Tejun Heo
On Thu, Jul 07, 2016 at 01:19:05AM +0800, tom.t...@gmail.com wrote:
> From: Tom Yan 
> 
> Currently if a WRITE SAME (16) command is issued to the SATL with
> "number of blocks" that is larger than the "Maximum write same length"
> (which is the maximum number of blocks per TRIM command allowed in
> libata, currently 65535 * 512 / 8 blocks), the SATL will accept the
> command and translate it to a TRIM command with the upper limit.
> 
> However, according to SBC (as of sbc4r11.pdf), the "device server"
> should terminate the command with "Invalid field in CDB" in that case.
> 
> Signed-off-by: Tom Yan 
> 
> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
> index bfec66f..a1f061a 100644
> --- a/drivers/ata/libata-scsi.c
> +++ b/drivers/ata/libata-scsi.c
> @@ -3305,7 +3305,11 @@ static unsigned int ata_scsi_write_same_xlat(struct 
> ata_queued_cmd *qc)
>   goto invalid_param_len;
>  
>   buf = page_address(sg_page(scsi_sglist(scmd)));
> - size = ata_set_lba_range_entries(buf, 512, block, n_block);
> +
> + if (n_block <= 65535 * 512 / 8)
> + size = ata_set_lba_range_entries(buf, 512, block, n_block);
> + else
> + goto invalid_fld;

This triggers compiler warning about @fp used w/o initializing it.  I
reverted the patch.  Can you please update the patch?

Thanks.

-- 
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 2/2] libata-scsi: avoid repeated calculation of number of TRIM ranges

2016-07-12 Thread Tejun Heo
Hello,

On Thu, Jul 07, 2016 at 01:19:06AM +0800, tom.t...@gmail.com wrote:
> @@ -1071,7 +1072,7 @@ static inline unsigned ata_set_lba_range_entries(void 
> *_buffer,
>   __le64 *buffer = _buffer;
>   unsigned i = 0, used_bytes;
>  
> - while (i < buf_size / 8 ) { /* 6-byte LBA + 2-byte range per entry */
> + while (i < buf_size) {

Please rename @buf_size.  It's confusing for a variable named size to
contain something other than bytes.

Thanks.

-- 
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 2/2] libata-scsi: rename ata_msense_ctl_mode() to ata_msense_control()

2016-07-12 Thread Tejun Heo
On Wed, Jul 13, 2016 at 02:54:12AM +0800, tom.t...@gmail.com wrote:
> From: Tom Yan 
> 
> To make it consistent with the recently added ata_mselect_control().
> We probably shouldn't have the word "mode" in its name anyway, since
> that's not the case for other ata_msense_*() / ata_mselect_*() either.
> 
> Signed-off-by: Tom Yan 

Applied 1-2 to libata/for-4.8.

In the future, can you please link patches in the same series?  If
there are only several, either chain-replying or replying to the first
patch is fine.  If there are more, people usually write up a head
message and makes all patches replies to that message.

Thanks.

-- 
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 1/2] libata-scsi: fix D_SENSE bit relection in control mode page

2016-07-12 Thread tom . ty89
From: Tom Yan 

The bit should always be set to 1 when the requested version of
page is "changeable" because we've made it so in ata_mselect_control().
Also, it should always be set to 1 if ATA_DFLAG_D_SENSE is set (when
the requested version of page is "current" or "default").

Signed-off-by: Tom Yan 

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index bfec66f..7e24f0a 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -2446,7 +2446,7 @@ static unsigned int ata_msense_ctl_mode(struct ata_device 
*dev, u8 *buf,
bool changeable)
 {
modecpy(buf, def_control_mpage, sizeof(def_control_mpage), changeable);
-   if (changeable && (dev->flags & ATA_DFLAG_D_SENSE))
+   if (changeable || (dev->flags & ATA_DFLAG_D_SENSE))
buf[2] |= (1 << 2); /* Descriptor sense requested */
return sizeof(def_control_mpage);
 }
-- 
2.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 2/2] libata-scsi: rename ata_msense_ctl_mode() to ata_msense_control()

2016-07-12 Thread tom . ty89
From: Tom Yan 

To make it consistent with the recently added ata_mselect_control().
We probably shouldn't have the word "mode" in its name anyway, since
that's not the case for other ata_msense_*() / ata_mselect_*() either.

Signed-off-by: Tom Yan 

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 7e24f0a..bf4cb21 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -2432,7 +2432,7 @@ static unsigned int ata_msense_caching(u16 *id, u8 *buf, 
bool changeable)
 }
 
 /**
- * ata_msense_ctl_mode - Simulate MODE SENSE control mode page
+ * ata_msense_control - Simulate MODE SENSE control mode page
  * @dev: ATA device of interest
  * @buf: output buffer
  * @changeable: whether changeable parameters are requested
@@ -2442,7 +2442,7 @@ static unsigned int ata_msense_caching(u16 *id, u8 *buf, 
bool changeable)
  * LOCKING:
  * None.
  */
-static unsigned int ata_msense_ctl_mode(struct ata_device *dev, u8 *buf,
+static unsigned int ata_msense_control(struct ata_device *dev, u8 *buf,
bool changeable)
 {
modecpy(buf, def_control_mpage, sizeof(def_control_mpage), changeable);
@@ -2566,13 +2566,13 @@ static unsigned int ata_scsiop_mode_sense(struct 
ata_scsi_args *args, u8 *rbuf)
break;
 
case CONTROL_MPAGE:
-   p += ata_msense_ctl_mode(args->dev, p, page_control == 1);
+   p += ata_msense_control(args->dev, p, page_control == 1);
break;
 
case ALL_MPAGES:
p += ata_msense_rw_recovery(p, page_control == 1);
p += ata_msense_caching(args->id, p, page_control == 1);
-   p += ata_msense_ctl_mode(args->dev, p, page_control == 1);
+   p += ata_msense_control(args->dev, p, page_control == 1);
break;
 
default:/* invalid page code */
@@ -3667,7 +3667,7 @@ static int ata_mselect_control(struct ata_queued_cmd *qc,
/*
 * Check that read-only bits are not modified.
 */
-   ata_msense_ctl_mode(dev, mpage, false);
+   ata_msense_control(dev, mpage, false);
for (i = 0; i < CONTROL_MPAGE_LEN - 2; i++) {
if (i == 0)
continue;
-- 
2.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] libata-scsi: do not return designator for serial number

2016-07-12 Thread Tejun Heo
On Thu, Jul 07, 2016 at 06:12:12AM +0800, tom.t...@gmail.com wrote:
> From: Tom Yan 
> 
> SAT (as of sat4r05f.pdf) does not require this vendor specific
> designator. Besides, we already have the Unit Serial Number VPD.
> 
> Signed-off-by: Tom Yan 
> 
> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
> index bfec66f..9f478ad 100644
> --- a/drivers/ata/libata-scsi.c
> +++ b/drivers/ata/libata-scsi.c
> @@ -2210,14 +2210,6 @@ static unsigned int ata_scsiop_inq_83(struct 
> ata_scsi_args *args, u8 *rbuf)
>   rbuf[1] = 0x83; /* this page code */
>   num = 4;
>  
> - /* piv=0, assoc=lu, code_set=ACSII, designator=vendor */
> - rbuf[num + 0] = 2;
> - rbuf[num + 3] = ATA_ID_SERNO_LEN;
> - num += 4;
> - ata_id_string(args->id, (unsigned char *) rbuf + num,
> -   ATA_ID_SERNO, ATA_ID_SERNO_LEN);
> - num += ATA_ID_SERNO_LEN;
> -

If it isn't actually broken, I don't want to change it.  It's a
userland visible change which is gratuitous.

Thanks.

-- 
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 2/2] libata-scsi: better style in ata_msense_caching()

2016-07-12 Thread Tom Yan
Sure. I was checking whether other MODE SENSE functions have the same
problem. It turns out the recently rewritten ata_msense_ctl_mode() is
actually bugged, seemingly because of the original arcane style. Sent
the patch for that, fixing it in the original style.

So I am wondering if I should further fix the style of
ata_msense_ctl_mode() when I resend this patch. If so, how should I
make `dev->flags & ATA_DFLAG_D_SENSE` a boolean, so that it can be bit
shifted? Double negation? Type casting? Or should I just use an `else
if` clause?

On 13 July 2016 at 01:20, Tejun Heo  wrote:
> On Wed, Jul 13, 2016 at 12:20:40AM +0800, Tom Yan wrote:
>> First of all "changeable" is the "version" of mode page requested by
>> the user, while ata_id_*_enabled(id) are the value of setting reported
>> by the device. I think it's ugly and confusing to check values of
>> totally different nature "together".
>>
>> The worse thing is, since we have implemented MODE SELECT /
>> ata_mselect_caching() to serve exclusively the write cache feature,
>> the difference in the two if-conditions made the code look even more
>> arcane.
>>
>> In my version, it is clear that when the user request the changeable
>> mode page, the value for the WCE bit will always be "1" / "y", since
>> we've made (only) it changeable in ata_mselect_caching(); and when the
>> user request the current / default page, the values reflect the
>> settings from the drive.
>
> Can you please put the rationale in the patch description and repost?
>
> Thanks.
>
> --
> tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] libata-scsi: fix D_SENSE bit relection in control mode page

2016-07-12 Thread Tom Yan
Btw, why is the MODE SELECT function called ata_mselect_control()
while the MODE SENSE function is called ata_msense_ctl_mode()?
Shouldn't we make their names consistent?

On 13 July 2016 at 01:35,   wrote:
> From: Tom Yan 
>
> The bit should always be set to 1 when the requested version of
> page is "changeable" because we've made it so in ata_mselect_control().
> Also, it should always be set to 1 if ATA_DFLAG_D_SENSE is set (when
> the requested version of page is "current" or "default").
>
> Signed-off-by: Tom Yan 
>
> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
> index bfec66f..7e24f0a 100644
> --- a/drivers/ata/libata-scsi.c
> +++ b/drivers/ata/libata-scsi.c
> @@ -2446,7 +2446,7 @@ static unsigned int ata_msense_ctl_mode(struct 
> ata_device *dev, u8 *buf,
> bool changeable)
>  {
> modecpy(buf, def_control_mpage, sizeof(def_control_mpage), 
> changeable);
> -   if (changeable && (dev->flags & ATA_DFLAG_D_SENSE))
> +   if (changeable || (dev->flags & ATA_DFLAG_D_SENSE))
> buf[2] |= (1 << 2); /* Descriptor sense requested */
> return sizeof(def_control_mpage);
>  }
> --
> 2.9.0
>
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] libata-scsi: fix D_SENSE bit relection in control mode page

2016-07-12 Thread tom . ty89
From: Tom Yan 

The bit should always be set to 1 when the requested version of
page is "changeable" because we've made it so in ata_mselect_control().
Also, it should always be set to 1 if ATA_DFLAG_D_SENSE is set (when
the requested version of page is "current" or "default").

Signed-off-by: Tom Yan 

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index bfec66f..7e24f0a 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -2446,7 +2446,7 @@ static unsigned int ata_msense_ctl_mode(struct ata_device 
*dev, u8 *buf,
bool changeable)
 {
modecpy(buf, def_control_mpage, sizeof(def_control_mpage), changeable);
-   if (changeable && (dev->flags & ATA_DFLAG_D_SENSE))
+   if (changeable || (dev->flags & ATA_DFLAG_D_SENSE))
buf[2] |= (1 << 2); /* Descriptor sense requested */
return sizeof(def_control_mpage);
 }
-- 
2.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 2/2] libata-scsi: better style in ata_msense_caching()

2016-07-12 Thread Tejun Heo
On Wed, Jul 13, 2016 at 12:20:40AM +0800, Tom Yan wrote:
> First of all "changeable" is the "version" of mode page requested by
> the user, while ata_id_*_enabled(id) are the value of setting reported
> by the device. I think it's ugly and confusing to check values of
> totally different nature "together".
> 
> The worse thing is, since we have implemented MODE SELECT /
> ata_mselect_caching() to serve exclusively the write cache feature,
> the difference in the two if-conditions made the code look even more
> arcane.
> 
> In my version, it is clear that when the user request the changeable
> mode page, the value for the WCE bit will always be "1" / "y", since
> we've made (only) it changeable in ata_mselect_caching(); and when the
> user request the current / default page, the values reflect the
> settings from the drive.

Can you please put the rationale in the patch description and repost?

Thanks.

-- 
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 2/2] libata-scsi: better style in ata_msense_caching()

2016-07-12 Thread Tom Yan
First of all "changeable" is the "version" of mode page requested by
the user, while ata_id_*_enabled(id) are the value of setting reported
by the device. I think it's ugly and confusing to check values of
totally different nature "together".

The worse thing is, since we have implemented MODE SELECT /
ata_mselect_caching() to serve exclusively the write cache feature,
the difference in the two if-conditions made the code look even more
arcane.

In my version, it is clear that when the user request the changeable
mode page, the value for the WCE bit will always be "1" / "y", since
we've made (only) it changeable in ata_mselect_caching(); and when the
user request the current / default page, the values reflect the
settings from the drive.

On 12 July 2016 at 22:48, Tejun Heo  wrote:
> On Tue, Jul 12, 2016 at 09:37:03PM +0800, tom.t...@gmail.com wrote:
>> From: Tom Yan 
>>
>> Signed-off-by: Tom Yan 
>>
>> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
>> index bfec66f..48ea887 100644
>> --- a/drivers/ata/libata-scsi.c
>> +++ b/drivers/ata/libata-scsi.c
>> @@ -2424,10 +2424,12 @@ static void modecpy(u8 *dest, const u8 *src, int n, 
>> bool changeable)
>>  static unsigned int ata_msense_caching(u16 *id, u8 *buf, bool changeable)
>>  {
>>   modecpy(buf, def_cache_mpage, sizeof(def_cache_mpage), changeable);
>> - if (changeable || ata_id_wcache_enabled(id))
>> - buf[2] |= (1 << 2); /* write cache enable */
>> - if (!changeable && !ata_id_rahead_enabled(id))
>> - buf[12] |= (1 << 5);/* disable read ahead */
>> + if (changeable) {
>> + buf[2] |= 1 << 2; /* ata_mselect_caching() */
>> + } else {
>> + buf[2] |= ata_id_wcache_enabled(id) << 2;   /* write cache 
>> enable */
>> + buf[12] |= !ata_id_rahead_enabled(id) << 5; /* disable 
>> read ahead */
>> + }
>
> It's different but I'm not sure this is better.
>
> Thanks.
>
> --
> tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH resend 2/2] libata-scsi: correct SPC version descriptor

2016-07-12 Thread Tejun Heo
On Tue, Jul 12, 2016 at 09:29:35PM +0800, tom.t...@gmail.com wrote:
> From: Tom Yan 
> 
> The comment suggests we should be having an SPC-3 version descriptor
> but the 0260h is the code for "SPC-2 (no version claimed)". Correct
> it to 0300h so that it has the "SPC-3 (no version claimed)" descriptor.
> 
> Note that we are claiming SPC-3 version compatibility in the VERSION
> field of the standard INQUIRY data. Therefore, I assume the typo was
> on the code but not on the comment.
> 
> Signed-off-by: Tom Yan 

Applied 1-2 to libata/for-4.8.

Thanks.

-- 
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 2/2] libata-scsi: better style in ata_msense_caching()

2016-07-12 Thread Tejun Heo
On Tue, Jul 12, 2016 at 09:28:23PM +0800, tom.t...@gmail.com wrote:
> From: Tom Yan 
> 
> Signed-off-by: Tom Yan 
> 
> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
> index bfec66f..6f7c626 100644
> --- a/drivers/ata/libata-scsi.c
> +++ b/drivers/ata/libata-scsi.c
> @@ -2424,10 +2424,13 @@ static void modecpy(u8 *dest, const u8 *src, int n, 
> bool changeable)
>  static unsigned int ata_msense_caching(u16 *id, u8 *buf, bool changeable)
>  {
>   modecpy(buf, def_cache_mpage, sizeof(def_cache_mpage), changeable);
> - if (changeable || ata_id_wcache_enabled(id))
> - buf[2] |= (1 << 2); /* write cache enable */
> - if (!changeable && !ata_id_rahead_enabled(id))
> - buf[12] |= (1 << 5);/* disable read ahead */
> + if (changeable) {
> + buf[2] |= 1 << 2; /* ata_mselect_caching() */
> + }
> + else {
> + buf[2] |= ata_id_wcache_enabled(id) << 2;   /* write cache 
> enable */
> + buf[12] |= !ata_id_rahead_enabled(id) << 5; /* disable read 
> ahead */
> + }

Again, why is this better?

Thanks.

-- 
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 1/2] libata-scsi: fix SET FEATURES "filtering" for ata_msense_caching()

2016-07-12 Thread Tejun Heo
On Tue, Jul 12, 2016 at 09:37:02PM +0800, tom.t...@gmail.com wrote:
> From: Tom Yan 
> 
> Without this fix, the DRA bit of the caching mode page would not
> be updated when the read look-ahead feature is toggled (e.g. with
> `smartctl --set`), but will only be until, for example, the write
> cache feature is touched.
> 
> Signed-off-by: Tom Yan 

Applied to libata/for-4.8.

Thanks.

-- 
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 2/2] libata-scsi: better style in ata_msense_caching()

2016-07-12 Thread Tejun Heo
On Tue, Jul 12, 2016 at 09:37:03PM +0800, tom.t...@gmail.com wrote:
> From: Tom Yan 
> 
> Signed-off-by: Tom Yan 
> 
> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
> index bfec66f..48ea887 100644
> --- a/drivers/ata/libata-scsi.c
> +++ b/drivers/ata/libata-scsi.c
> @@ -2424,10 +2424,12 @@ static void modecpy(u8 *dest, const u8 *src, int n, 
> bool changeable)
>  static unsigned int ata_msense_caching(u16 *id, u8 *buf, bool changeable)
>  {
>   modecpy(buf, def_cache_mpage, sizeof(def_cache_mpage), changeable);
> - if (changeable || ata_id_wcache_enabled(id))
> - buf[2] |= (1 << 2); /* write cache enable */
> - if (!changeable && !ata_id_rahead_enabled(id))
> - buf[12] |= (1 << 5);/* disable read ahead */
> + if (changeable) {
> + buf[2] |= 1 << 2; /* ata_mselect_caching() */
> + } else {
> + buf[2] |= ata_id_wcache_enabled(id) << 2;   /* write cache 
> enable */
> + buf[12] |= !ata_id_rahead_enabled(id) << 5; /* disable read 
> ahead */
> + }

It's different but I'm not sure this is better.

Thanks.

-- 
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] libata-scsi: set correct VERSION field for ZAC devices

2016-07-12 Thread Tejun Heo
On Tue, Jul 12, 2016 at 10:12:01PM +0800, tom.t...@gmail.com wrote:
> From: Tom Yan 
> 
> Commit 856c46639309 ("libata: support device-managed ZAC devices")
> had the line that "bumps" the VERSION field in standard INQUIRY data
> removed. Add it back and claim SPC-5 version compatibility, which
> matches with the current version descriptor "SPC-5 (no version claimed)"
> that is used for ZAC devices.
> 
> Signed-off-by: Tom Yan 

Applied to libata/for-4.8.

Thanks.

-- 
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] libata-scsi: set correct VERSION field for ZAC devices

2016-07-12 Thread tom . ty89
From: Tom Yan 

Commit 856c46639309 ("libata: support device-managed ZAC devices")
had the line that "bumps" the VERSION field in standard INQUIRY data
removed. Add it back and claim SPC-5 version compatibility, which
matches with the current version descriptor "SPC-5 (no version claimed)"
that is used for ZAC devices.

Signed-off-by: Tom Yan 

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index bfec66f..27e29e1 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -2109,8 +2109,10 @@ static unsigned int ata_scsiop_inq_std(struct 
ata_scsi_args *args, u8 *rbuf)
(args->dev->link->ap->pflags & ATA_PFLAG_EXTERNAL))
hdr[1] |= (1 << 7);
 
-   if (args->dev->class == ATA_DEV_ZAC)
+   if (args->dev->class == ATA_DEV_ZAC) {
hdr[0] = TYPE_ZBC;
+   hdr[2] = 0x7; /* claim SPC-5 version compatibility */
+   }
 
memcpy(rbuf, hdr, sizeof(hdr));
memcpy([8], "ATA ", 8);
-- 
2.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/1] scsi: ufs: tc-dwc-g210 driver fix for 20-bit RMMI

2016-07-12 Thread Manjunath M B
The code was checking on PA_CONNECTEDRXLANES and
PA_CONNECTEDTXLANES attributes to program the Lane#1
attributes. The correct attributes are PA_AVAILRXDATALANES and
PA_AVAILTXDATALANES respectively.

Signed-off-by: Manjunath M B 
---
 drivers/scsi/ufs/tc-dwc-g210.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/ufs/tc-dwc-g210.c b/drivers/scsi/ufs/tc-dwc-g210.c
index d6c5388..70db6d9 100644
--- a/drivers/scsi/ufs/tc-dwc-g210.c
+++ b/drivers/scsi/ufs/tc-dwc-g210.c
@@ -187,9 +187,9 @@ static int tc_dwc_g210_setup_20bit_rmmi_lane1(struct 
ufs_hba *hba)
};
 
/* Get the available lane count */
-   ufshcd_dme_get(hba, UIC_ARG_MIB(PA_CONNECTEDRXDATALANES),
+   ufshcd_dme_get(hba, UIC_ARG_MIB(PA_AVAILRXDATALANES),
_rx_lanes);
-   ufshcd_dme_get(hba, UIC_ARG_MIB(PA_CONNECTEDTXDATALANES),
+   ufshcd_dme_get(hba, UIC_ARG_MIB(PA_AVAILTXDATALANES),
_tx_lanes);
 
if (connected_tx_lanes == 2) {
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 2/2] libata-scsi: better style in ata_msense_caching()

2016-07-12 Thread tom . ty89
From: Tom Yan 

Signed-off-by: Tom Yan 

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index bfec66f..48ea887 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -2424,10 +2424,12 @@ static void modecpy(u8 *dest, const u8 *src, int n, 
bool changeable)
 static unsigned int ata_msense_caching(u16 *id, u8 *buf, bool changeable)
 {
modecpy(buf, def_cache_mpage, sizeof(def_cache_mpage), changeable);
-   if (changeable || ata_id_wcache_enabled(id))
-   buf[2] |= (1 << 2); /* write cache enable */
-   if (!changeable && !ata_id_rahead_enabled(id))
-   buf[12] |= (1 << 5);/* disable read ahead */
+   if (changeable) {
+   buf[2] |= 1 << 2; /* ata_mselect_caching() */
+   } else {
+   buf[2] |= ata_id_wcache_enabled(id) << 2;   /* write cache 
enable */
+   buf[12] |= !ata_id_rahead_enabled(id) << 5; /* disable read 
ahead */
+   }
return sizeof(def_cache_mpage);
 }
 
-- 
2.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 1/2] libata-scsi: fix SET FEATURES "filtering" for ata_msense_caching()

2016-07-12 Thread tom . ty89
From: Tom Yan 

Without this fix, the DRA bit of the caching mode page would not
be updated when the read look-ahead feature is toggled (e.g. with
`smartctl --set`), but will only be until, for example, the write
cache feature is touched.

Signed-off-by: Tom Yan 

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 6be7770..077daf0 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -5127,7 +5127,9 @@ void ata_qc_complete(struct ata_queued_cmd *qc)
switch (qc->tf.command) {
case ATA_CMD_SET_FEATURES:
if (qc->tf.feature != SETFEATURES_WC_ON &&
-   qc->tf.feature != SETFEATURES_WC_OFF)
+   qc->tf.feature != SETFEATURES_WC_OFF &&
+   qc->tf.feature != SETFEATURES_RA_ON &&
+   qc->tf.feature != SETFEATURES_RA_OFF)
break;
/* fall through */
case ATA_CMD_INIT_DEV_PARAMS: /* CHS translation changed */
diff --git a/include/linux/ata.h b/include/linux/ata.h
index 99346be..2d68793 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -409,6 +409,9 @@ enum {
SETFEATURES_WC_ON   = 0x02, /* Enable write cache */
SETFEATURES_WC_OFF  = 0x82, /* Disable write cache */
 
+   SETFEATURES_RA_ON   = 0xaa, /* Enable read look-ahead */
+   SETFEATURES_RA_OFF  = 0x55, /* Disable read look-ahead */
+
/* Enable/Disable Automatic Acoustic Management */
SETFEATURES_AAM_ON  = 0x42,
SETFEATURES_AAM_OFF = 0xC2,
-- 
2.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 2/2] libata-scsi: better style in ata_msense_caching()

2016-07-12 Thread Sergei Shtylyov

Hello.

On 7/12/2016 4:28 PM, tom.t...@gmail.com wrote:


From: Tom Yan 

Signed-off-by: Tom Yan 

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index bfec66f..6f7c626 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -2424,10 +2424,13 @@ static void modecpy(u8 *dest, const u8 *src, int n, 
bool changeable)
 static unsigned int ata_msense_caching(u16 *id, u8 *buf, bool changeable)
 {
modecpy(buf, def_cache_mpage, sizeof(def_cache_mpage), changeable);
-   if (changeable || ata_id_wcache_enabled(id))
-   buf[2] |= (1 << 2);   /* write cache enable */
-   if (!changeable && !ata_id_rahead_enabled(id))
-   buf[12] |= (1 << 5);  /* disable read ahead */
+   if (changeable) {
+   buf[2] |= 1 << 2; /* ata_mselect_caching() */
+   }
+   else {


   CodingStyle: } else {


+   buf[2] |= ata_id_wcache_enabled(id) << 2; /* write cache enable 
*/
+   buf[12] |= !ata_id_rahead_enabled(id) << 5;   /* disable 
read ahead */
+   }
return sizeof(def_cache_mpage);
 }



MBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH resend 2/2] libata-scsi: correct SPC version descriptor

2016-07-12 Thread tom . ty89
From: Tom Yan 

The comment suggests we should be having an SPC-3 version descriptor
but the 0260h is the code for "SPC-2 (no version claimed)". Correct
it to 0300h so that it has the "SPC-3 (no version claimed)" descriptor.

Note that we are claiming SPC-3 version compatibility in the VERSION
field of the standard INQUIRY data. Therefore, I assume the typo was
on the code but not on the comment.

Signed-off-by: Tom Yan 

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 0a35164..8221800 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -2075,8 +2075,8 @@ static unsigned int ata_scsiop_inq_std(struct 
ata_scsi_args *args, u8 *rbuf)
0x03,
0x20,   /* SBC-2 (no version claimed) */
 
-   0x02,
-   0x60/* SPC-3 (no version claimed) */
+   0x03,
+   0x00/* SPC-3 (no version claimed) */
};
const u8 versions_zbc[] = {
0x00,
-- 
2.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH resend 1/2] libata-scsi: set CmdQue bit in standard INQUIRY data to 1

2016-07-12 Thread tom . ty89
From: Tom Yan 

Avoid performance bottleneck when being SCSI pass-through'd to
virtual machines with other OSes (e.g. Windows) via virtio-scsi
and scsi-block in qemu.

Ref.: https://github.com/YanVugenfirer/kvm-guest-drivers-windows/issues/63

Signed-off-by: Tom Yan 

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index bfec66f..0a35164 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -2097,7 +2097,10 @@ static unsigned int ata_scsiop_inq_std(struct 
ata_scsi_args *args, u8 *rbuf)
0,
0x5,/* claim SPC-3 version compatibility */
2,
-   95 - 4
+   95 - 4,
+   0,
+   0,
+   2
};
 
VPRINTK("ENTER\n");
-- 
2.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 2/2] libata-scsi: better style in ata_msense_caching()

2016-07-12 Thread tom . ty89
From: Tom Yan 

Signed-off-by: Tom Yan 

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index bfec66f..6f7c626 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -2424,10 +2424,13 @@ static void modecpy(u8 *dest, const u8 *src, int n, 
bool changeable)
 static unsigned int ata_msense_caching(u16 *id, u8 *buf, bool changeable)
 {
modecpy(buf, def_cache_mpage, sizeof(def_cache_mpage), changeable);
-   if (changeable || ata_id_wcache_enabled(id))
-   buf[2] |= (1 << 2); /* write cache enable */
-   if (!changeable && !ata_id_rahead_enabled(id))
-   buf[12] |= (1 << 5);/* disable read ahead */
+   if (changeable) {
+   buf[2] |= 1 << 2; /* ata_mselect_caching() */
+   }
+   else {
+   buf[2] |= ata_id_wcache_enabled(id) << 2;   /* write cache 
enable */
+   buf[12] |= !ata_id_rahead_enabled(id) << 5; /* disable read 
ahead */
+   }
return sizeof(def_cache_mpage);
 }
 
-- 
2.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 1/2] libata-scsi: fix SET FEATURES "filtering" for ata_msense_caching()

2016-07-12 Thread tom . ty89
From: Tom Yan 

Without this fix, the DRA bit of the caching mode page would not
be updated when the read look-ahead feature is toggled (e.g. with
`smartctl --set`), but will only be until, for example, the write
cache feature is touched.

Signed-off-by: Tom Yan 

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 6be7770..077daf0 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -5127,7 +5127,9 @@ void ata_qc_complete(struct ata_queued_cmd *qc)
switch (qc->tf.command) {
case ATA_CMD_SET_FEATURES:
if (qc->tf.feature != SETFEATURES_WC_ON &&
-   qc->tf.feature != SETFEATURES_WC_OFF)
+   qc->tf.feature != SETFEATURES_WC_OFF &&
+   qc->tf.feature != SETFEATURES_RA_ON &&
+   qc->tf.feature != SETFEATURES_RA_OFF)
break;
/* fall through */
case ATA_CMD_INIT_DEV_PARAMS: /* CHS translation changed */
diff --git a/include/linux/ata.h b/include/linux/ata.h
index 99346be..2d68793 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -409,6 +409,9 @@ enum {
SETFEATURES_WC_ON   = 0x02, /* Enable write cache */
SETFEATURES_WC_OFF  = 0x82, /* Disable write cache */
 
+   SETFEATURES_RA_ON   = 0xaa, /* Enable read look-ahead */
+   SETFEATURES_RA_OFF  = 0x55, /* Disable read look-ahead */
+
/* Enable/Disable Automatic Acoustic Management */
SETFEATURES_AAM_ON  = 0x42,
SETFEATURES_AAM_OFF = 0xC2,
-- 
2.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RFE: sdparm: return mode page "Write parameters" for only MMC devices

2016-07-12 Thread Tom Yan
Since version 1.10, sdparm would return the mode page "Write
parameters" if the MODE SENSE data from the device has a 05h mode
page. However, the page number was also used for mode page called
"Flexible geometry":

[tom@localhost ~]$ sudo sdparm /dev/sdb
/dev/sdb: SanDisk   Ultra II 240GB0
Write parameters (MMC) mode page:
  BUFE  0  [cha: n, def:  0, sav:  0]

[tom@localhost ~]$ sudo sg_modes /dev/sdb
SanDisk   Ultra II 240GB0  peripheral_type: disk [0x0]
Mode parameter header from MODE SENSE(10):
  Mode data length=40, medium type=0x00, WP=0, DpoFua=0, longlba=0
  Block descriptor length=0
>> Flexible geometry (obsolete), page_control: current
 00 05 1e 00 00 10 3f 02 00  3f ff 00 00 00 00 00 00
 10 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00

Therefore, it would be nice if sdparm can be made to return the mode
page "wp" only when the device is an MMC device (PERIPHERAL DEVICE
TYPE = 05h).
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] mpt3sas: Fix panic when aer correct error occured

2016-07-12 Thread Kefeng Wang
The _scsih_pci_mmio_enabled called if scsih_pci_error_detected returns
PCI_ERS_RESULT_CAN_RECOVER, at this point, read/write to the device
still works, no need to reset slot.

Or the mpt3sas_base_map_resources in scsih_pci_slot_reset will fail,
and iounamp ioc->chip, then we will meet issue when read ioc->chip
in mpt3sas_base_get_iocstate from _base_fault_reset_work.

Cc: Sathya Prakash 
Cc: Chaitra P B 
Cc: Suganath Prabu Subramani 
Signed-off-by: Kefeng Wang 
---

NOTE: I found this with an earlier kernel version, but the logic is not changed.

 drivers/scsi/mpt3sas/mpt3sas_scsih.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c 
b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index 6bff13e..eedd62e3 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -9033,8 +9033,11 @@ scsih_pci_mmio_enabled(struct pci_dev *pdev)
 
/* TODO - dump whatever for debugging purposes */
 
-   /* Request a slot reset. */
-   return PCI_ERS_RESULT_NEED_RESET;
+   /* This called only if scsih_pci_error_detected returns
+* PCI_ERS_RESULT_CAN_RECOVER, read/write to the device
+* still works, not need to reset slot.
+*/
+   return PCI_ERS_RESULT_RECOVERED;
 }
 
 /*
-- 
1.7.12.4

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] scsi: introduce a quirk for false cache reporting

2016-07-12 Thread Oliver Neukum
Some SATA to USB bridges fail to cooperate with some
drives resulting in no cache being present being reported
to the host. That causes the host to skip sending
a command to synchronize caches. That causes data loss
when the drive is powered down.

Signed-off-by: Oliver Neukum 
---
 Documentation/kernel-parameters.txt | 2 ++
 drivers/scsi/sd.c   | 6 +++---
 drivers/usb/storage/scsiglue.c  | 4 
 drivers/usb/storage/usb.c   | 6 +-
 include/linux/usb_usual.h   | 2 ++
 include/scsi/scsi_device.h  | 1 +
 6 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/Documentation/kernel-parameters.txt 
b/Documentation/kernel-parameters.txt
index 82b42c9..c8c682e 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -4182,6 +4182,8 @@ bytes respectively. Such letter suffixes can also be 
entirely omitted.
u = IGNORE_UAS (don't bind to the uas driver);
w = NO_WP_DETECT (don't test whether the
medium is write-protected).
+   y = ALWAYS_SYNC (issue a SYNCHRONIZE_CACHE
+   even if the device claims no cache)
Example: quirks=0419:aaf5:rl,0421:0433:rc
 
user_debug= [KNL,ARM]
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 60bff78..3e8a6f1 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -139,7 +139,7 @@ static void sd_set_flush_flag(struct scsi_disk *sdkp)
 {
bool wc = false, fua = false;
 
-   if (sdkp->WCE) {
+   if (sdkp->WCE || sdkp->device->always_sync) {
wc = true;
if (sdkp->DPOFUA)
fua = true;
@@ -3228,7 +3228,7 @@ static void sd_shutdown(struct device *dev)
if (pm_runtime_suspended(dev))
return;
 
-   if (sdkp->WCE && sdkp->media_present) {
+   if ((sdkp->WCE || sdkp->device->always_sync) && sdkp->media_present)  {
sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n");
sd_sync_cache(sdkp);
}
@@ -3247,7 +3247,7 @@ static int sd_suspend_common(struct device *dev, bool 
ignore_stop_errors)
if (!sdkp)  /* E.g.: runtime suspend following sd_remove() */
return 0;
 
-   if (sdkp->WCE && sdkp->media_present) {
+   if ((sdkp->WCE || sdkp->device->always_sync) && sdkp->media_present) {
sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n");
ret = sd_sync_cache(sdkp);
if (ret) {
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index 33eb923..43e76ae 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -296,6 +296,10 @@ static int slave_configure(struct scsi_device *sdev)
if (us->fflags & US_FL_BROKEN_FUA)
sdev->broken_fua = 1;
 
+   /* Some even totally fail to indicate a cache */
+   if (us->fflags & US_FL_ALWAYS_SYNC)
+   sdev->always_sync = 1;
+
} else {
 
/*
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index ef2d8cd..19255f1 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -498,7 +498,8 @@ void usb_stor_adjust_quirks(struct usb_device *udev, 
unsigned long *fflags)
US_FL_NO_READ_DISC_INFO | US_FL_NO_READ_CAPACITY_16 |
US_FL_INITIAL_READ10 | US_FL_WRITE_CACHE |
US_FL_NO_ATA_1X | US_FL_NO_REPORT_OPCODES |
-   US_FL_MAX_SECTORS_240 | US_FL_NO_REPORT_LUNS);
+   US_FL_MAX_SECTORS_240 | US_FL_NO_REPORT_LUNS |
+   US_FL_ALWAYS_SYNC);
 
p = quirks;
while (*p) {
@@ -581,6 +582,9 @@ void usb_stor_adjust_quirks(struct usb_device *udev, 
unsigned long *fflags)
case 'w':
f |= US_FL_NO_WP_DETECT;
break;
+   case 'y':
+   f |= US_FL_ALWAYS_SYNC;
+   break;
/* Ignore unrecognized flag characters */
}
}
diff --git a/include/linux/usb_usual.h b/include/linux/usb_usual.h
index 245f57d..0aae1b2 100644
--- a/include/linux/usb_usual.h
+++ b/include/linux/usb_usual.h
@@ -81,6 +81,8 @@
/* Sets max_sectors to 240 */   \
US_FLAG(NO_REPORT_LUNS, 0x1000) \
/* Cannot handle REPORT_LUNS */ \
+   US_FLAG(ALWAYS_SYNC, 0x2000)\
+   /* lies about caching, so always sync */\
 
 #define US_FLAG(name, value)   US_FL_##name = value ,
 enum { US_DO_ALL_FLAGS };
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 

Re: [PATCH v2] xen_pvscsi: reclaim the ring request when the prepairing failed

2016-07-12 Thread Juergen Gross
On 12/07/16 02:36, Bin Wu wrote:
> During scsi command queueing or exception handling, if prepairing
> fails, we need to reclaim the failed request. Otherwise, the garbage
> request will be pushed into the ring for the backend to work.
> 
> Signed-off-by: Bin Wu 

Reviewed-by: Juergen Gross 

> ---
>  drivers/scsi/xen-scsifront.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/xen-scsifront.c b/drivers/scsi/xen-scsifront.c
> index 9dc8687..8646db1 100644
> --- a/drivers/scsi/xen-scsifront.c
> +++ b/drivers/scsi/xen-scsifront.c
> @@ -184,8 +184,6 @@ static struct vscsiif_request *scsifront_pre_req(struct 
> vscsifrnt_info *info)
>  
>   ring_req = RING_GET_REQUEST(&(info->ring), ring->req_prod_pvt);
>  
> - ring->req_prod_pvt++;
> -
>   ring_req->rqid = (uint16_t)id;
>  
>   return ring_req;
> @@ -196,6 +194,8 @@ static void scsifront_do_request(struct vscsifrnt_info 
> *info)
>   struct vscsiif_front_ring *ring = &(info->ring);
>   int notify;
>  
> + ring->req_prod_pvt++;
> +
>   RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(ring, notify);
>   if (notify)
>   notify_remote_via_irq(info->irq);
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 13/13] cxgbit: add files for cxgbit.ko

2016-07-12 Thread Or Gerlitz
On Fri, Jul 8, 2016 at 9:36 PM, Steve Wise  wrote:
>> > > In first series libcxgb.ko will have common
>> > > iSCSI DDP Page Pod Manager that will be shared
>> > > by three Chelsio iSCSI drivers
>> > > cxgb3i, cxgb4i, cxgbit.
>> >
>> > cool
>> >
>> > > In subsequent series I will add common connection
>> > > management and other hardware specific common code
>> > > in this module.
>> >
>> > any chance to get that ready for 4.8 too?
>>
>> I am working on common connection management, it is a
>> big change as it involves multiple modules, so it is
>> difficult to get it ready for 4.8.
>
> Let's shoot for 4.9 for the common CM.  Nice work on the PPOD unification!


Taking into account that this was a reviewer comment that basically
should have been addressed for
the initial merge into 4.7 and that there's more time for 4.8 work
[1], could you try and get that for 4.8?

[1] https://lwn.net/Articles/694055/
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html