blk-mq/libata/scsi: SCSI driver tagging improvements Part II
Subsystems (7)
v3 cover blk-mq/libata/scsi: SCSI driver tagging improvements Part II
This is a follow on to Part I in the following:
https://lore.kernel.org/linux-scsi/[email protected]/T/#ta
This mostly focuses on libata changes to queue internal commands as requests.
This is less complete than Part I series, due to:
- not tested on SATA PMP
- not support for ipr.c, which does not
support ata_port_operations.error_handler
- Not tested enough - for example, there are prob lots of issues lurking in libata qc iter functions now that ata_port.qcmd[] is deleted
John Garry (7):
ata: libata-scsi: Add ata_scsi_queue_internal()
ata: libata-scsi: Add ata_internal_queuecommand()
ata: libata: Make space for ATA queue command in scmd payload
ata: libata: Add ata_internal_timeout()
ata: libata: Queue ATA internal commands as requests
scsi: mvsas: Remove internal tag handling
scsi: hisi_sas: Remove internal tag handling for reserved commands
drivers/ata/libata-core.c | 141 ++++++++++++++----------- drivers/ata/libata-eh.c | 11 +- drivers/ata/libata-sata.c | 5 +- drivers/ata/libata-scsi.c | 76 ++++++++++++- drivers/ata/libata.h | 3 +- drivers/scsi/aic94xx/aic94xx_init.c | 2 + drivers/scsi/hisi_sas/hisi_sas.h | 3 - drivers/scsi/hisi_sas/hisi_sas_main.c | 82 +++----------- drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 2 + drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 2 + drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 11 +- drivers/scsi/isci/init.c | 2 + drivers/scsi/libsas/sas_scsi_host.c | 20 +++- drivers/scsi/mvsas/mv_init.c | 13 +-- drivers/scsi/mvsas/mv_sas.c | 55 +--------- drivers/scsi/mvsas/mv_sas.h | 1 - drivers/scsi/pm8001/pm8001_init.c | 2 + include/linux/libata.h | 64 ++++++++++- include/scsi/libsas.h | 8 +- 19 files changed, 281 insertions(+), 222 deletions(-)
Signature · 1 line
2.35.3
RFC PATCH v3 1/7 ata: libata-scsi: Add ata_scsi_queue_internal()
Add a function to handle queued ATA internal SCSI cmnds - does much the same as ata_exec_internal_sg() does (which will be fixed up later to actually queue internal cmnds through this function).
--- drivers/ata/libata-sata.c | 3 +++ drivers/ata/libata-scsi.c | 43 +++++++++++++++++++++++++++++++++++++++ drivers/ata/libata.h | 3 ++- include/linux/libata.h | 6 ++++++ 4 files changed, 54 insertions(+), 1 deletion(-)
drivers/ata/libata-sata.c +3 -0
@@ -1258,6 +1258,9 @@ int ata_sas_queuecmd(struct scsi_cmnd *cmd, struct ata_port *ap) {int rc =0 ; +if (blk_mq_is_reserved_rq (scsi_cmd_to_rq (cmd))) +return ata_scsi_queue_internal (cmd, ap->link.device); +if (likely (ata_dev_enabled (ap->link.device))) rc =__ata_scsi_queuecmd (cmd, ap->link.device);else {
drivers/ata/libata-scsi.c +43 -0
49 lines not on this page · raw message
drivers/ata/libata.h +2 -1
@@ -82,7 +82,6 @@ extern int ata_port_probe(struct ata_port *ap);extern void __ata_port_probe (struct ata_port *ap);extern unsigned int ata_read_log_page (struct ata_device *dev,u8 log,u8 page,void *buf,unsigned int sectors); -#define to_ata_port (d) container_of(d, struct ata_port, tdev)/* libata-acpi.c */
@@ -130,6 +129,8 @@ extern int ata_scsi_user_scan(struct Scsi_Host *shost, unsigned int channel,void ata_scsi_sdev_config (struct scsi_device *sdev);int ata_scsi_dev_config (struct scsi_device *sdev,struct ata_device *dev);int __ata_scsi_queuecmd (struct scsi_cmnd *scmd,struct ata_device *dev); +unsigned int ata_scsi_queue_internal (struct scsi_cmnd *scmd, +struct ata_device *dev);/* libata-eh.c */ extern unsigned int ata_internal_cmd_timeout (struct ata_device *dev,u8 cmd);
include/linux/libata.h +6 -0
@@ -764,7 +764,9 @@ struct ata_link {struct device tdev;unsigned int active_tag;/* active tag on this link */ +unsigned int preempted_tag;u32 sactive;/* active NCQ commands */ +u32 preempted_sactive;unsigned int flags;/* ATA_LFLAG_xxx */
@@ -857,6 +859,10 @@ struct ata_port {#ifdef CONFIG_ATA_ACPI struct ata_acpi_gtm __acpi_init_gtm;/* use ata_acpi_init_gtm() */ #endif + +u64 preempted_qc_active; +int preempted_nr_active_links; +/* owned by EH */ u8 sector_buf[ATA_SECT_SIZE ]____cacheline_aligned ; };
Signature · 1 line
2.35.3
Re: [PATCH RFC v3 1/7] ata: libata-scsi: Add ata_scsi_queue_internal()
Quoted 59 lines · John Garry
Add a function to handle queued ATA internal SCSI cmnds - does much the same as
ata_exec_internal_sg()does (which will be fixed up later to actually queue internal cmnds through this function).Signed-off-by John Garry <[email protected]>--- drivers/ata/libata-sata.c | 3 +++ drivers/ata/libata-scsi.c | 43 +++++++++++++++++++++++++++++++++++++++ drivers/ata/libata.h | 3 ++- include/linux/libata.h | 6 ++++++ 4 files changed, 54 insertions(+), 1 deletion(-)drivers/ata/libata-sata.c +3
-0@@ -1258,6 +1258,9 @@ int ata_sas_queuecmd(struct scsi_cmnd *cmd, struct ata_port *ap) {int rc =0 ; +if (blk_mq_is_reserved_rq (scsi_cmd_to_rq (cmd))) +return ata_scsi_queue_internal (cmd, ap->link.device); +if (likely (ata_dev_enabled (ap->link.device))) rc =__ata_scsi_queuecmd (cmd, ap->link.device);else {drivers/ata/libata-scsi.c +25
-0@@ -3965,6 +3965,49 @@ static inline ata_xlat_func_t ata_get_xlat_func(struct ata_device *dev, u8 cmd)return NULL ; } +unsigned int ata_scsi_queue_internal (struct scsi_cmnd *scmd, +struct ata_device *dev) +{ +struct ata_link *link = dev->link; +struct ata_port *ap = link->ap; +struct ata_queued_cmd *qc; + +/* no internal command while frozen */ +if (ap->pflags &ATA_PFLAG_FROZEN ) + goto did_err; + +/* initialize internal qc */ + qc =__ata_qc_from_tag (ap,ATA_TAG_INTERNAL ); + link->preempted_tag = link->active_tag; + link->preempted_sactive = link->sactive; + ap->preempted_qc_active = ap->qc_active; + ap->preempted_nr_active_links = ap->nr_active_links; + link->active_tag =ATA_TAG_POISON ; + link->sactive =0 ; + ap->qc_active =0 ; + ap->nr_active_links =0 ; + +if (qc->dma_dir !=DMA_NONE ) { +int n_elem; +
drivers/ata/libata-scsi.c static inline ata_xlat_func_t ata_get_xlat_func(struct ata_device *dev, u8 cmd) · line 4002
Quoted 10 lines
drivers/ata/libata-scsi.c +10
-0+ n_elem =1 ; + qc->n_elem = n_elem; + qc->sg =scsi_sglist (scmd); + qc->nbytes = qc->sg->length; +ata_sg_init (qc, qc->sg, n_elem); + } + + scmd->submitter =SUBMITTED_BY_BLOCK_LAYER ; + +ata_qc_issue (qc);
Arg, no ! This potentially mixes NCQ and non-NCQ commands, which is forbidden by ATA spec. You need to use something like:
if (ap->ops->qc_defer) {
if ((rc = ap->ops->qc_defer(qc)))
goto defer;
}
ata_qc_issue(qc);which is done in __ata_scsi_queuecmd() -> ata_scsi_translate()
Unless you guarantee that ata_scsi_queue_internal() is always called from libata EH context ?
Quoted 57 lines
drivers/ata/libata-scsi.c +8
-0+ +return 0 ; +did_err: + scmd->result = (DID_ERROR <<16 ); +scsi_done (scmd); +return 0 ; +} +int __ata_scsi_queuecmd (struct scsi_cmnd *scmd,struct ata_device *dev) {u8 scsi_op = scmd->cmnd[0 ];drivers/ata/libata.h +2
-1@@ -82,7 +82,6 @@ extern int ata_port_probe(struct ata_port *ap);extern void __ata_port_probe (struct ata_port *ap);extern unsigned int ata_read_log_page (struct ata_device *dev,u8 log,u8 page,void *buf,unsigned int sectors); -#define to_ata_port (d) container_of(d, struct ata_port, tdev)/* libata-acpi.c */ @@ -130,6 +129,8 @@ extern int ata_scsi_user_scan(struct Scsi_Host *shost, unsigned int channel,void ata_scsi_sdev_config (struct scsi_device *sdev);int ata_scsi_dev_config (struct scsi_device *sdev,struct ata_device *dev);int __ata_scsi_queuecmd (struct scsi_cmnd *scmd,struct ata_device *dev); +unsigned int ata_scsi_queue_internal (struct scsi_cmnd *scmd, +struct ata_device *dev);/* libata-eh.c */ extern unsigned int ata_internal_cmd_timeout (struct ata_device *dev,u8 cmd);include/linux/libata.h +6
-0@@ -764,7 +764,9 @@ struct ata_link {struct device tdev;unsigned int active_tag;/* active tag on this link */ +unsigned int preempted_tag;u32 sactive;/* active NCQ commands */ +u32 preempted_sactive;unsigned int flags;/* ATA_LFLAG_xxx */ @@ -857,6 +859,10 @@ struct ata_port {#ifdef CONFIG_ATA_ACPI struct ata_acpi_gtm __acpi_init_gtm;/* use ata_acpi_init_gtm() */ #endif + +u64 preempted_qc_active; +int preempted_nr_active_links; +/* owned by EH */ u8 sector_buf[ATA_SECT_SIZE ]____cacheline_aligned ; };
Signature · 2 lines
Damien Le Moal Western Digital Research
Re: [PATCH RFC v3 1/7] ata: libata-scsi: Add ata_scsi_queue_internal()
Quoted 81 lines · Damien Le Moal
Quoted 59 lines · John Garry
Add a function to handle queued ATA internal SCSI cmnds - does much the same as
ata_exec_internal_sg()does (which will be fixed up later to actually queue internal cmnds through this function).Signed-off-by John Garry <[email protected]>--- drivers/ata/libata-sata.c | 3 +++ drivers/ata/libata-scsi.c | 43 +++++++++++++++++++++++++++++++++++++++ drivers/ata/libata.h | 3 ++- include/linux/libata.h | 6 ++++++ 4 files changed, 54 insertions(+), 1 deletion(-)drivers/ata/libata-sata.c +3
-0@@ -1258,6 +1258,9 @@ int ata_sas_queuecmd(struct scsi_cmnd *cmd, struct ata_port *ap) {int rc =0 ; +if (blk_mq_is_reserved_rq (scsi_cmd_to_rq (cmd))) +return ata_scsi_queue_internal (cmd, ap->link.device); +if (likely (ata_dev_enabled (ap->link.device))) rc =__ata_scsi_queuecmd (cmd, ap->link.device);else {drivers/ata/libata-scsi.c +25
-0@@ -3965,6 +3965,49 @@ static inline ata_xlat_func_t ata_get_xlat_func(struct ata_device *dev, u8 cmd)return NULL ; } +unsigned int ata_scsi_queue_internal (struct scsi_cmnd *scmd, +struct ata_device *dev) +{ +struct ata_link *link = dev->link; +struct ata_port *ap = link->ap; +struct ata_queued_cmd *qc; + +/* no internal command while frozen */ +if (ap->pflags &ATA_PFLAG_FROZEN ) + goto did_err; + +/* initialize internal qc */ + qc =__ata_qc_from_tag (ap,ATA_TAG_INTERNAL ); + link->preempted_tag = link->active_tag; + link->preempted_sactive = link->sactive; + ap->preempted_qc_active = ap->qc_active; + ap->preempted_nr_active_links = ap->nr_active_links; + link->active_tag =ATA_TAG_POISON ; + link->sactive =0 ; + ap->qc_active =0 ; + ap->nr_active_links =0 ; + +if (qc->dma_dir !=DMA_NONE ) { +int n_elem; +drivers/ata/libata-scsi.c static inline ata_xlat_func_t ata_get_xlat_func(struct ata_device *dev, u8 cmd) · line 4002
Quoted 10 lines
drivers/ata/libata-scsi.c +10
-0+ n_elem =1 ; + qc->n_elem = n_elem; + qc->sg =scsi_sglist (scmd); + qc->nbytes = qc->sg->length; +ata_sg_init (qc, qc->sg, n_elem); + } + + scmd->submitter =SUBMITTED_BY_BLOCK_LAYER ; + +ata_qc_issue (qc);Arg, no ! This potentially mixes NCQ and non-NCQ commands, which is forbidden by ATA spec. You need to use something like:
if (ap->ops->qc_defer) { if ((rc = ap->ops->qc_defer(qc))) goto defer; } ata_qc_issue(qc);
Quoted 4 lines
which is done in
__ata_scsi_queuecmd()->ata_scsi_translate()Unless you guarantee that
ata_scsi_queue_internal()is always called from libata EH context ?
This will be called synchronously called from ata_exec_internal_sg(), so the same rules on NCQ vs non-NCQ would apply here. As I see, ata_exec_internal_sg() assumes non-NCQ mode and is not multi-thread safe.
Thanks,
John
Quoted 59 lines
Quoted 58 lines
drivers/ata/libata-scsi.c +8
-0+ +return 0 ; +did_err: + scmd->result = (DID_ERROR <<16 ); +scsi_done (scmd); +return 0 ; +} +int __ata_scsi_queuecmd (struct scsi_cmnd *scmd,struct ata_device *dev) {u8 scsi_op = scmd->cmnd[0 ];drivers/ata/libata.h +2
-1@@ -82,7 +82,6 @@ extern int ata_port_probe(struct ata_port *ap);extern void __ata_port_probe (struct ata_port *ap);extern unsigned int ata_read_log_page (struct ata_device *dev,u8 log,u8 page,void *buf,unsigned int sectors); -#define to_ata_port (d) container_of(d, struct ata_port, tdev)/* libata-acpi.c */ @@ -130,6 +129,8 @@ extern int ata_scsi_user_scan(struct Scsi_Host *shost, unsigned int channel,void ata_scsi_sdev_config (struct scsi_device *sdev);int ata_scsi_dev_config (struct scsi_device *sdev,struct ata_device *dev);int __ata_scsi_queuecmd (struct scsi_cmnd *scmd,struct ata_device *dev); +unsigned int ata_scsi_queue_internal (struct scsi_cmnd *scmd, +struct ata_device *dev);/* libata-eh.c */ extern unsigned int ata_internal_cmd_timeout (struct ata_device *dev,u8 cmd);include/linux/libata.h +6
-0@@ -764,7 +764,9 @@ struct ata_link {struct device tdev;unsigned int active_tag;/* active tag on this link */ +unsigned int preempted_tag;u32 sactive;/* active NCQ commands */ +u32 preempted_sactive;unsigned int flags;/* ATA_LFLAG_xxx */ @@ -857,6 +859,10 @@ struct ata_port {#ifdef CONFIG_ATA_ACPI struct ata_acpi_gtm __acpi_init_gtm;/* use ata_acpi_init_gtm() */ #endif + +u64 preempted_qc_active; +int preempted_nr_active_links; +/* owned by EH */ u8 sector_buf[ATA_SECT_SIZE ]____cacheline_aligned ; };
Re: [PATCH RFC v3 1/7] ata: libata-scsi: Add ata_scsi_queue_internal()
Quoted 82 lines · John Garry
Quoted 81 lines · Damien Le Moal
Quoted 59 lines · John Garry
Add a function to handle queued ATA internal SCSI cmnds - does much the same as
ata_exec_internal_sg()does (which will be fixed up later to actually queue internal cmnds through this function).Signed-off-by John Garry <[email protected]>--- drivers/ata/libata-sata.c | 3 +++ drivers/ata/libata-scsi.c | 43 +++++++++++++++++++++++++++++++++++++++ drivers/ata/libata.h | 3 ++- include/linux/libata.h | 6 ++++++ 4 files changed, 54 insertions(+), 1 deletion(-)drivers/ata/libata-sata.c +3
-0@@ -1258,6 +1258,9 @@ int ata_sas_queuecmd(struct scsi_cmnd *cmd, struct ata_port *ap) {int rc =0 ; +if (blk_mq_is_reserved_rq (scsi_cmd_to_rq (cmd))) +return ata_scsi_queue_internal (cmd, ap->link.device); +if (likely (ata_dev_enabled (ap->link.device))) rc =__ata_scsi_queuecmd (cmd, ap->link.device);else {drivers/ata/libata-scsi.c +25
-0@@ -3965,6 +3965,49 @@ static inline ata_xlat_func_t ata_get_xlat_func(struct ata_device *dev, u8 cmd)return NULL ; } +unsigned int ata_scsi_queue_internal (struct scsi_cmnd *scmd, +struct ata_device *dev) +{ +struct ata_link *link = dev->link; +struct ata_port *ap = link->ap; +struct ata_queued_cmd *qc; + +/* no internal command while frozen */ +if (ap->pflags &ATA_PFLAG_FROZEN ) + goto did_err; + +/* initialize internal qc */ + qc =__ata_qc_from_tag (ap,ATA_TAG_INTERNAL ); + link->preempted_tag = link->active_tag; + link->preempted_sactive = link->sactive; + ap->preempted_qc_active = ap->qc_active; + ap->preempted_nr_active_links = ap->nr_active_links; + link->active_tag =ATA_TAG_POISON ; + link->sactive =0 ; + ap->qc_active =0 ; + ap->nr_active_links =0 ; + +if (qc->dma_dir !=DMA_NONE ) { +int n_elem; +drivers/ata/libata-scsi.c static inline ata_xlat_func_t ata_get_xlat_func(struct ata_device *dev, u8 cmd) · line 4002
Quoted 10 lines
drivers/ata/libata-scsi.c +10
-0+ n_elem =1 ; + qc->n_elem = n_elem; + qc->sg =scsi_sglist (scmd); + qc->nbytes = qc->sg->length; +ata_sg_init (qc, qc->sg, n_elem); + } + + scmd->submitter =SUBMITTED_BY_BLOCK_LAYER ; + +ata_qc_issue (qc);Arg, no ! This potentially mixes NCQ and non-NCQ commands, which is forbidden by ATA spec. You need to use something like:
if (ap->ops->qc_defer) { if ((rc = ap->ops->qc_defer(qc))) goto defer; } ata_qc_issue(qc);
Quoted 8 lines
Quoted 4 lines
which is done in
__ata_scsi_queuecmd()->ata_scsi_translate()Unless you guarantee that
ata_scsi_queue_internal()is always called from libata EH context ?This will be called synchronously called from
ata_exec_internal_sg(), so the same rules on NCQ vs non-NCQ would apply here. As I see,ata_exec_internal_sg()assumes non-NCQ mode and is not multi-thread safe.
Yep. No thread safety needed as we are always guaranteed to be in EH with the queue quiesced when this is executed. No other commands can come in at the same time.
Quoted 64 lines
Thanks,
JohnQuoted 59 lines
Quoted 58 lines
drivers/ata/libata-scsi.c +8
-0+ +return 0 ; +did_err: + scmd->result = (DID_ERROR <<16 ); +scsi_done (scmd); +return 0 ; +} +int __ata_scsi_queuecmd (struct scsi_cmnd *scmd,struct ata_device *dev) {u8 scsi_op = scmd->cmnd[0 ];drivers/ata/libata.h +2
-1@@ -82,7 +82,6 @@ extern int ata_port_probe(struct ata_port *ap);extern void __ata_port_probe (struct ata_port *ap);extern unsigned int ata_read_log_page (struct ata_device *dev,u8 log,u8 page,void *buf,unsigned int sectors); -#define to_ata_port (d) container_of(d, struct ata_port, tdev)/* libata-acpi.c */ @@ -130,6 +129,8 @@ extern int ata_scsi_user_scan(struct Scsi_Host *shost, unsigned int channel,void ata_scsi_sdev_config (struct scsi_device *sdev);int ata_scsi_dev_config (struct scsi_device *sdev,struct ata_device *dev);int __ata_scsi_queuecmd (struct scsi_cmnd *scmd,struct ata_device *dev); +unsigned int ata_scsi_queue_internal (struct scsi_cmnd *scmd, +struct ata_device *dev);/* libata-eh.c */ extern unsigned int ata_internal_cmd_timeout (struct ata_device *dev,u8 cmd);include/linux/libata.h +6
-0@@ -764,7 +764,9 @@ struct ata_link {struct device tdev;unsigned int active_tag;/* active tag on this link */ +unsigned int preempted_tag;u32 sactive;/* active NCQ commands */ +u32 preempted_sactive;unsigned int flags;/* ATA_LFLAG_xxx */ @@ -857,6 +859,10 @@ struct ata_port {#ifdef CONFIG_ATA_ACPI struct ata_acpi_gtm __acpi_init_gtm;/* use ata_acpi_init_gtm() */ #endif + +u64 preempted_qc_active; +int preempted_nr_active_links; +/* owned by EH */ u8 sector_buf[ATA_SECT_SIZE ]____cacheline_aligned ; };
Signature · 2 lines
Damien Le Moal Western Digital Research
RFC PATCH v3 2/7 ata: libata-scsi: Add ata_internal_queuecommand()
In reply to John GarryAdd callback to queue reserved commands - call it "internal" as this is what libata uses.
Also add it to the base ATA SHT.
--- drivers/ata/libata-scsi.c | 14 ++++++++++++++ include/linux/libata.h | 5 ++++- 2 files changed, 18 insertions(+), 1 deletion(-)
drivers/ata/libata-scsi.c +14 -0
@@ -1118,6 +1118,20 @@ int ata_scsi_dev_config(struct scsi_device *sdev, struct ata_device *dev)return 0 ; } +int ata_internal_queuecommand (struct Scsi_Host *shost,struct scsi_cmnd *scmd) +{ +struct ata_port *ap; +int res; + + ap =ata_shost_to_port (shost); +spin_lock_irq (ap->lock); + res =ata_sas_queuecmd (scmd, ap); +spin_unlock_irq (ap->lock); + +return res; +} +EXPORT_SYMBOL_GPL (ata_internal_queuecommand); +/** * ata_scsi_slave_config - Set SCSI device attributes * @sdev: SCSI device to examine
include/linux/libata.h +4 -1
@@ -1141,6 +1141,8 @@ extern int ata_std_bios_param(struct scsi_device *sdev, sector_t capacity, int geom[]);extern void ata_scsi_unlock_native_capacity (struct scsi_device *sdev);extern int ata_scsi_slave_config (struct scsi_device *sdev); +extern int ata_internal_queuecommand (struct Scsi_Host *shost, +struct scsi_cmnd *scmd);extern void ata_scsi_slave_destroy (struct scsi_device *sdev);extern int ata_scsi_change_queue_depth (struct scsi_device *sdev,int queue_depth);
@@ -1391,7 +1393,8 @@ extern const struct attribute_group *ata_common_sdev_groups[]; .slave_destroy = ata_scsi_slave_destroy, \ .bios_param = ata_std_bios_param, \ .unlock_native_capacity = ata_scsi_unlock_native_capacity,\ - .max_sectors = ATA_MAX_SECTORS_LBA48 + .max_sectors = ATA_MAX_SECTORS_LBA48,\ + .reserved_queuecommand = ata_internal_queuecommand#define ATA_SUBBASE_SHT (drv_name) \ __ATA_BASE_SHT(drv_name), \
Signature · 1 line
2.35.3
Re: [PATCH RFC v3 2/7] ata: libata-scsi: Add ata_internal_queuecommand()
Quoted 16 lines · John Garry
Add callback to queue reserved commands - call it "internal" as this is what libata uses.
Also add it to the base ATA SHT.
Signed-off-by John Garry <[email protected]>--- drivers/ata/libata-scsi.c | 14 ++++++++++++++ include/linux/libata.h | 5 ++++- 2 files changed, 18 insertions(+), 1 deletion(-)drivers/ata/libata-scsi.c +0
-0
drivers/ata/libata-scsi.c int ata_scsi_dev_config(struct scsi_device *sdev, struct ata_device *dev) · line 1126
Quoted 9 lines
drivers/ata/libata-scsi.c +6
-0@@ -1118,6 +1118,20 @@ int ata_scsi_dev_config(struct scsi_device *sdev, struct ata_device *dev)return 0 ; } +int ata_internal_queuecommand (struct Scsi_Host *shost,struct scsi_cmnd *scmd) +{ +struct ata_port *ap; +int res; + + ap =ata_shost_to_port (shost);
You can have this initialization together with the ap declaration.
drivers/ata/libata-scsi.c int ata_scsi_dev_config(struct scsi_device *sdev, struct ata_device *dev) · line 1133
Quoted 7 lines
drivers/ata/libata-scsi.c +7
-0+spin_lock_irq (ap->lock); + res =ata_sas_queuecmd (scmd, ap); +spin_unlock_irq (ap->lock); + +return res; +} +EXPORT_SYMBOL_GPL (ata_internal_queuecommand);
I am officially lost here. Do not see why this function is needed...
Quoted 27 lines
drivers/ata/libata-scsi.c +1
-0+/** * ata_scsi_slave_config - Set SCSI device attributes * @sdev: SCSI device to examine include/linux/libata.h +4
-1@@ -1141,6 +1141,8 @@ extern int ata_std_bios_param(struct scsi_device *sdev, sector_t capacity, int geom[]);extern void ata_scsi_unlock_native_capacity (struct scsi_device *sdev);extern int ata_scsi_slave_config (struct scsi_device *sdev); +extern int ata_internal_queuecommand (struct Scsi_Host *shost, +struct scsi_cmnd *scmd);extern void ata_scsi_slave_destroy (struct scsi_device *sdev);extern int ata_scsi_change_queue_depth (struct scsi_device *sdev,int queue_depth);@@ -1391,7 +1393,8 @@ extern const struct attribute_group *ata_common_sdev_groups[]; .slave_destroy = ata_scsi_slave_destroy, \ .bios_param = ata_std_bios_param, \ .unlock_native_capacity = ata_scsi_unlock_native_capacity,\ - .max_sectors = ATA_MAX_SECTORS_LBA48 + .max_sectors = ATA_MAX_SECTORS_LBA48,\ + .reserved_queuecommand = ata_internal_queuecommand#define ATA_SUBBASE_SHT (drv_name) \ __ATA_BASE_SHT(drv_name), \
Signature · 2 lines
Damien Le Moal Western Digital Research
Re: [PATCH RFC v3 2/7] ata: libata-scsi: Add ata_internal_queuecommand()
Quoted 29 lines · Damien Le Moal
Quoted 16 lines · John Garry
Add callback to queue reserved commands - call it "internal" as this is what libata uses.
Also add it to the base ATA SHT.
Signed-off-by John Garry <[email protected]>--- drivers/ata/libata-scsi.c | 14 ++++++++++++++ include/linux/libata.h | 5 ++++- 2 files changed, 18 insertions(+), 1 deletion(-)drivers/ata/libata-scsi.c +0
-0drivers/ata/libata-scsi.c int ata_scsi_dev_config(struct scsi_device *sdev, struct ata_device *dev) · line 1126
Quoted 9 lines
drivers/ata/libata-scsi.c +6
-0@@ -1118,6 +1118,20 @@ int ata_scsi_dev_config(struct scsi_device *sdev, struct ata_device *dev)return 0 ; } +int ata_internal_queuecommand (struct Scsi_Host *shost,struct scsi_cmnd *scmd) +{ +struct ata_port *ap; +int res; + + ap =ata_shost_to_port (shost);You can have this initialization together with the ap declaration.
Quoted 9 lines
drivers/ata/libata-scsi.c int ata_scsi_dev_config(struct scsi_device *sdev, struct ata_device *dev) · line 1133
Quoted 7 lines
drivers/ata/libata-scsi.c +7
-0+spin_lock_irq (ap->lock); + res =ata_sas_queuecmd (scmd, ap); +spin_unlock_irq (ap->lock); + +return res; +} +EXPORT_SYMBOL_GPL (ata_internal_queuecommand);I am officially lost here. Do not see why this function is needed...
The general idea in this series is to send ATA internal commands as requests. And this function is used as the SCSI midlayer to queue reserved commands. See how it is plugged into __ATA_BASE_SHT, below.
So we have this overall flow:
ata_exec_internal_sg():
-> alloc request
-> blk_execute_rq_nowait()
... -> scsi_queue_rq() -> sht->reserved_queuecommd() -> ata_internal_queuecommand()
And then we have ata_internal_queuecommand() -> ata_sas_queuecmd() -> ata_scsi_queue_internal() -> ata_qc_issue().
Hope it makes sense.
Thanks,
John
Quoted 29 lines
Quoted 28 lines
drivers/ata/libata-scsi.c +1
-0+/** * ata_scsi_slave_config - Set SCSI device attributes * @sdev: SCSI device to examine include/linux/libata.h +4
-1@@ -1141,6 +1141,8 @@ extern int ata_std_bios_param(struct scsi_device *sdev, sector_t capacity, int geom[]);extern void ata_scsi_unlock_native_capacity (struct scsi_device *sdev);extern int ata_scsi_slave_config (struct scsi_device *sdev); +extern int ata_internal_queuecommand (struct Scsi_Host *shost, +struct scsi_cmnd *scmd);extern void ata_scsi_slave_destroy (struct scsi_device *sdev);extern int ata_scsi_change_queue_depth (struct scsi_device *sdev,int queue_depth);@@ -1391,7 +1393,8 @@ extern const struct attribute_group *ata_common_sdev_groups[]; .slave_destroy = ata_scsi_slave_destroy, \ .bios_param = ata_std_bios_param, \ .unlock_native_capacity = ata_scsi_unlock_native_capacity,\ - .max_sectors = ATA_MAX_SECTORS_LBA48 + .max_sectors = ATA_MAX_SECTORS_LBA48,\ + .reserved_queuecommand = ata_internal_queuecommand#define ATA_SUBBASE_SHT (drv_name) \ __ATA_BASE_SHT(drv_name), \
Re: [PATCH RFC v3 2/7] ata: libata-scsi: Add ata_internal_queuecommand()
Quoted 52 lines · John Garry
Quoted 30 lines · Damien Le Moal
Quoted 16 lines · John Garry
Add callback to queue reserved commands - call it "internal" as this is what libata uses.
Also add it to the base ATA SHT.
Signed-off-by John Garry <[email protected]>---
drivers/ata/libata-scsi.c| 14 ++++++++++++++
include/linux/libata.h | 5 ++++-2 files changed, 18 insertions(+), 1 deletion(-)drivers/ata/libata-scsi.c +0
-0drivers/ata/libata-scsi.c int ata_scsi_dev_config(struct scsi_device · line 1127
Quoted 10 lines
drivers/ata/libata-scsi.c +6
-0@@ -1118,6 +1118,20 @@ int ata_scsi_dev_config(struct scsi_device *sdev, struct ata_device *dev) return 0; } +int ata_internal_queuecommand (struct Scsi_Host *shost,struct scsi_cmnd *scmd) +{ + struct ata_port *ap; + int res; + + ap = ata_shost_to_port(shost);You can have this initialization together with the ap declaration.
Quoted 9 lines
drivers/ata/libata-scsi.c int ata_scsi_dev_config(struct scsi_device *sdev, struct ata_device *dev) · line 1133
Quoted 7 lines
drivers/ata/libata-scsi.c +7
-0+ spin_lock_irq(ap->lock); + res = ata_sas_queuecmd(scmd, ap); + spin_unlock_irq(ap->lock); + + return res; +} +EXPORT_SYMBOL_GPL (ata_internal_queuecommand);I am officially lost here. Do not see why this function is needed...
The general idea in this series is to send ATA internal commands as requests. And this function is used as the SCSI midlayer to queue reserved commands. See how it is plugged into
__ATA_BASE_SHT, below.So we have this overall flow:
ata_exec_internal_sg():
-> alloc request
->blk_execute_rq_nowait()
... ->scsi_queue_rq()
->sht->reserved_queuecommd()
->ata_internal_queuecommand()
Quoted 38 lines
And then we have
ata_internal_queuecommand()->ata_sas_queuecmd()->ata_scsi_queue_internal()->ata_qc_issue().Hope it makes sense.
Thanks,
JohnQuoted 30 lines
Quoted 29 lines
drivers/ata/libata-scsi.c +1
-0+ /*** ata_scsi_slave_config - Set SCSI device attributes * @sdev: SCSI device to examine
include/linux/libata.h +2
-0@@ -1141,6 +1141,8 @@ extern int ata_std_bios_param(structscsi_device *sdev, sector_t capacity, int geom[]); extern void ata_scsi_unlock_native_capacity(struct scsi_device *sdev); extern int ata_scsi_slave_config(struct scsi_device *sdev); +extern int ata_internal_queuecommand (struct Scsi_Host *shost, + struct scsi_cmnd *scmd); extern void ata_scsi_slave_destroy(struct scsi_device *sdev); extern int ata_scsi_change_queue_depth(struct scsi_device *sdev,int
queue_depth);include/linux/libata.h +2
-1@@ -1391,7 +1393,8 @@ extern const struct attribute_group *ata_common_sdev_groups[]; .slave_destroy = ata_scsi_slave_destroy, \ .bios_param = ata_std_bios_param, \ .unlock_native_capacity = ata_scsi_unlock_native_capacity,\ - .max_sectors = ATA_MAX_SECTORS_LBA48 + .max_sectors = ATA_MAX_SECTORS_LBA48,\ + .reserved_queuecommand = ata_internal_queuecommand #define ATA_SUBBASE_SHT(drv_name) \ __ATA_BASE_SHT(drv_name), \
But that means we can't use it before the SCSI host is initialized; some HBAs require to send commands before the host can be initialized properly.
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman
Re: [PATCH RFC v3 2/7] ata: libata-scsi: Add ata_internal_queuecommand()
Quoted 30 lines · Hannes Reinecke
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
/**
*ata_scsi_slave_config- Set SCSI device attributes * @sdev: SCSI device to examineinclude/linux/libata.h +2
-0@@ -1141,6 +1141,8 @@ extern int ata_std_bios_param(structscsi_device *sdev, sector_t capacity, int geom[]); extern void ata_scsi_unlock_native_capacity(struct scsi_device *sdev); extern int ata_scsi_slave_config(struct scsi_device *sdev); +extern int ata_internal_queuecommand (struct Scsi_Host *shost, + struct scsi_cmnd *scmd); extern void ata_scsi_slave_destroy(struct scsi_device *sdev); extern int ata_scsi_change_queue_depth(struct scsi_device *sdev,int
queue_depth);include/linux/libata.h +0
-0@@ -1391,7 +1393,8 @@ extern const struct attribute_group *ata_common_sdev_groups[]; .slave_destroy = ata_scsi_slave_destroy, \Quoted 9 lines
Quoted 8 lines
include/linux/libata.h extern const struct attribute_group *ata_common_sdev_groups[]; · line 1400
Quoted 7 lines
include/linux/libata.h +2
-1.bios_param = ata_std_bios_param, \ .unlock_native_capacity = ata_scsi_unlock_native_capacity,\ - .max_sectors = ATA_MAX_SECTORS_LBA48 + .max_sectors = ATA_MAX_SECTORS_LBA48,\ + .reserved_queuecommand = ata_internal_queuecommand #define ATA_SUBBASE_SHT(drv_name) \ __ATA_BASE_SHT(drv_name), \
Quoted 1 line
But that means we can't use it before the SCSI host is initialized; some HBAs require to send commands before the host can be initialized properly.
At what stage do you want to send these commands? The tags for the shost are not setup until scsi_add_host() -> scsi_mq_setup_tags() is called, so can't expect blk-mq to manage reserved tags before then.
If you are required to send commands prior to scsi_add_host(), then I suppose the low-level driver still needs to manage tags until the shost is ready. I guess that some very simple scheme can be used, like always use tag 0, since most probe is done serially per-host. But that's not a case which I have had to deal with yet.
Thanks,
John
Re: [PATCH RFC v3 2/7] ata: libata-scsi: Add ata_internal_queuecommand()
Quoted 39 lines · John Garry
Quoted 31 lines · Hannes Reinecke
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
/**
*ata_scsi_slave_config- Set SCSI device attributes * @sdev: SCSI device to examineinclude/linux/libata.h +0
-0@@ -1141,6 +1141,8 @@ extern int ata_std_bios_param(structscsi_device *sdev, sector_t capacity, int geom[]);extern void
ata_scsi_unlock_native_capacity(struct scsi_device *sdev);
extern intata_scsi_slave_config(struct scsi_device *sdev); +extern intata_internal_queuecommand(struct Scsi_Host *shost, + struct scsi_cmnd *scmd);
extern voidata_scsi_slave_destroy(struct scsi_device *sdev); extern intata_scsi_change_queue_depth(struct scsi_device *sdev, int queue_depth);include/linux/libata.h +0
-0@@ -1391,7 +1393,8 @@ extern const struct attribute_group *ata_common_sdev_groups[]; .slave_destroy = ata_scsi_slave_destroy, \Quoted 9 lines
Quoted 8 lines
include/linux/libata.h extern const struct attribute_group *ata_common_sdev_groups[]; · line 1400
Quoted 7 lines
include/linux/libata.h +2
-1.bios_param = ata_std_bios_param, \ .unlock_native_capacity = ata_scsi_unlock_native_capacity,\ - .max_sectors = ATA_MAX_SECTORS_LBA48 + .max_sectors = ATA_MAX_SECTORS_LBA48,\ + .reserved_queuecommand = ata_internal_queuecommand #define ATA_SUBBASE_SHT(drv_name) \ __ATA_BASE_SHT(drv_name), \Quoted 2 lines
But that means we can't use it before the SCSI host is initialized; some HBAs require to send commands before the host can be initialized properly.
At what stage do you want to send these commands? The tags for the shost are not setup until
scsi_add_host()->scsi_mq_setup_tags()is called, so can't expect blk-mq to manage reserved tags before then.
Quoted 5 lines
If you are required to send commands prior to
scsi_add_host(), then I suppose the low-level driver still needs to manage tags until the shost is ready. I guess that some very simple scheme can be used, like always use tag 0, since most probe is done serially per-host. But that's not a case which I have had to deal with yet.
In libata case, ata_dev_configure() will cause a lot of ata_exec_internal_sg() calls for IDENTIFY and various READ LOG commands. That is all done with non-ncq commands, which means that we do not require a hw tag. But given that you are changing ata_exec_internal_sg() to call alloc_request + blk_execute_rq_nowait(), how would these work without a tag, at least a soft one ? Or we would need to keep the current code to use ata_qc_issue() directly for probe time ? That will look very ugly...
Quoted 3 lines
Thanks,
John
Signature · 2 lines
Damien Le Moal Western Digital Research
Re: [PATCH RFC v3 2/7] ata: libata-scsi: Add ata_internal_queuecommand()
Quoted 9 lines · Damien Le Moal
Quoted 9 lines
At what stage do you want to send these commands? The tags for the shost are not setup until
scsi_add_host()->scsi_mq_setup_tags()is called, so can't expect blk-mq to manage reserved tags before then.If you are required to send commands prior to
scsi_add_host(), then I suppose the low-level driver still needs to manage tags until the shost is ready. I guess that some very simple scheme can be used, like always use tag 0, since most probe is done serially per-host. But that's not a case which I have had to deal with yet.
Quoted 8 lines
In libata case,
ata_dev_configure()will cause a lot ofata_exec_internal_sg()calls for IDENTIFY and various READ LOG commands. That is all done with non-ncq commands, which means that we do not require a hw tag. But given that you are changingata_exec_internal_sg()to callalloc_request+blk_execute_rq_nowait(), how would these work without a tag, at least a soft one ? Or we would need to keep the current code to useata_qc_issue()directly for probe time ? That will look very ugly...
I am not sure if there is really a problem. So libata/libsas allocs the shost quite early, and that is before we try using ata_exec_internal_sg(). Also note that I added patch "ata: libata-scsi: Allocate sdev early in port probe" so that we have ata_device.sdev ready before issuing ata_exec_internal_sg() (sorry if I'm stating the obvious).
I think Hannes' issue is that some SCSI HBA driver needs to send "internal" commands to probe the HW for info, and this would be before shost is ready. He can tell us more.
Thanks,
John
Re: [PATCH RFC v3 2/7] ata: libata-scsi: Add ata_internal_queuecommand()
Quoted 25 lines · John Garry
Quoted 9 lines · Damien Le Moal
Quoted 9 lines
At what stage do you want to send these commands? The tags for the shost are not setup until
scsi_add_host()->scsi_mq_setup_tags()is called, so can't expect blk-mq to manage reserved tags before then.If you are required to send commands prior to
scsi_add_host(), then I suppose the low-level driver still needs to manage tags until the shost is ready. I guess that some very simple scheme can be used, like always use tag 0, since most probe is done serially per-host. But that's not a case which I have had to deal with yet.Quoted 8 lines
In libata case,
ata_dev_configure()will cause a lot ofata_exec_internal_sg()calls for IDENTIFY and various READ LOG commands. That is all done with non-ncq commands, which means that we do not require a hw tag. But given that you are changingata_exec_internal_sg()to callalloc_request+blk_execute_rq_nowait(), how would these work without a tag, at least a soft one ? Or we would need to keep the current code to useata_qc_issue()directly for probe time ? That will look very ugly...I am not sure if there is really a problem. So libata/libsas allocs the shost quite early, and that is before we try using
ata_exec_internal_sg(). Also note that I added patch "ata: libata-scsi:
Allocate sdev early in port probe" so that we have ata_device.sdev ready before issuingata_exec_internal_sg()(sorry if I'm stating the obvious).
Quoted 3 lines
I think Hannes' issue is that some SCSI HBA driver needs to send "internal" commands to probe the HW for info, and this would be before shost is ready. He can tell us more.
OK. Understood.
Quoted 3 lines
Thanks,
John
Signature · 2 lines
Damien Le Moal Western Digital Research
Re: [PATCH RFC v3 2/7] ata: libata-scsi: Add ata_internal_queuecommand()
In reply to John GarryQuoted 49 lines · John Garry
Quoted 29 lines · Damien Le Moal
Quoted 16 lines · John Garry
Add callback to queue reserved commands - call it "internal" as this is what libata uses.
Also add it to the base ATA SHT.
Signed-off-by John Garry <[email protected]>--- drivers/ata/libata-scsi.c | 14 ++++++++++++++ include/linux/libata.h | 5 ++++- 2 files changed, 18 insertions(+), 1 deletion(-)drivers/ata/libata-scsi.c +0
-0drivers/ata/libata-scsi.c int ata_scsi_dev_config(struct scsi_device *sdev, struct ata_device *dev) · line 1126
Quoted 9 lines
drivers/ata/libata-scsi.c +6
-0@@ -1118,6 +1118,20 @@ int ata_scsi_dev_config(struct scsi_device *sdev, struct ata_device *dev)return 0 ; } +int ata_internal_queuecommand (struct Scsi_Host *shost,struct scsi_cmnd *scmd) +{ +struct ata_port *ap; +int res; + + ap =ata_shost_to_port (shost);You can have this initialization together with the ap declaration.
Quoted 9 lines
drivers/ata/libata-scsi.c int ata_scsi_dev_config(struct scsi_device *sdev, struct ata_device *dev) · line 1133
Quoted 7 lines
drivers/ata/libata-scsi.c +7
-0+spin_lock_irq (ap->lock); + res =ata_sas_queuecmd (scmd, ap); +spin_unlock_irq (ap->lock); + +return res; +} +EXPORT_SYMBOL_GPL (ata_internal_queuecommand);I am officially lost here. Do not see why this function is needed...
The general idea in this series is to send ATA internal commands as requests. And this function is used as the SCSI midlayer to queue reserved commands. See how it is plugged into
__ATA_BASE_SHT, below.So we have this overall flow:
ata_exec_internal_sg():
-> alloc request
->blk_execute_rq_nowait()
Quoted 8 lines
... -> scsi_queue_rq() -> sht->reserved_queuecommd() -> ata_internal_queuecommand()And then we have
ata_internal_queuecommand()->ata_sas_queuecmd()->ata_scsi_queue_internal()->ata_qc_issue().Hope it makes sense.
OK. Got it.
However, ata_exec_internal_sg() being used only from EH context with the queue quiesced, will blk_execute_rq_nowait() work ? Is there an exception for internal reserved tags ?
Quoted 34 lines
Thanks,
JohnQuoted 29 lines
Quoted 28 lines
drivers/ata/libata-scsi.c +1
-0+/** * ata_scsi_slave_config - Set SCSI device attributes * @sdev: SCSI device to examine include/linux/libata.h +4
-1@@ -1141,6 +1141,8 @@ extern int ata_std_bios_param(struct scsi_device *sdev, sector_t capacity, int geom[]);extern void ata_scsi_unlock_native_capacity (struct scsi_device *sdev);extern int ata_scsi_slave_config (struct scsi_device *sdev); +extern int ata_internal_queuecommand (struct Scsi_Host *shost, +struct scsi_cmnd *scmd);extern void ata_scsi_slave_destroy (struct scsi_device *sdev);extern int ata_scsi_change_queue_depth (struct scsi_device *sdev,int queue_depth);@@ -1391,7 +1393,8 @@ extern const struct attribute_group *ata_common_sdev_groups[]; .slave_destroy = ata_scsi_slave_destroy, \ .bios_param = ata_std_bios_param, \ .unlock_native_capacity = ata_scsi_unlock_native_capacity,\ - .max_sectors = ATA_MAX_SECTORS_LBA48 + .max_sectors = ATA_MAX_SECTORS_LBA48,\ + .reserved_queuecommand = ata_internal_queuecommand#define ATA_SUBBASE_SHT (drv_name) \ __ATA_BASE_SHT(drv_name), \
Signature · 2 lines
Damien Le Moal Western Digital Research
Re: [PATCH RFC v3 2/7] ata: libata-scsi: Add ata_internal_queuecommand()
Quoted 9 lines · Damien Le Moal
Quoted 9 lines
So we have this overall flow:
ata_exec_internal_sg():-> alloc request -> blk_execute_rq_nowait() ... -> scsi_queue_rq() -> sht->reserved_queuecommd() -> ata_internal_queuecommand()
Quoted 9 lines
Quoted 4 lines
And then we have
ata_internal_queuecommand()->ata_sas_queuecmd()->ata_scsi_queue_internal()->ata_qc_issue().Hope it makes sense.
OK. Got it.
However,ata_exec_internal_sg()being used only from EH context with the queue quiesced, willblk_execute_rq_nowait()work ? Is there an exception for internal reserved tags ?
Well, yeah. So if some error happens and EH kicks in, then full queue depth of requests may be allocated. I have seen this for NCQ error. So this is why I make in very first patch change allow us to allocate reserved request from sdev request queue even when budget is fully allocated.
Please also note that for AHCI, I make reserved depth =1, while for SAS controllers it is greater. This means that in theory we could alloc > 1x reserved command for SATA disk, but I don't think it matters.
Thanks,
John
Re: [PATCH RFC v3 2/7] ata: libata-scsi: Add ata_internal_queuecommand()
Quoted 26 lines · John Garry
Quoted 9 lines · Damien Le Moal
Quoted 9 lines
So we have this overall flow:
ata_exec_internal_sg():-> alloc request -> blk_execute_rq_nowait() ... -> scsi_queue_rq() -> sht->reserved_queuecommd() -> ata_internal_queuecommand()Quoted 9 lines
Quoted 4 lines
And then we have
ata_internal_queuecommand()->ata_sas_queuecmd()->ata_scsi_queue_internal()->ata_qc_issue().Hope it makes sense.
OK. Got it.
However,ata_exec_internal_sg()being used only from EH context with the queue quiesced, willblk_execute_rq_nowait()work ? Is there an exception for internal reserved tags ?Well, yeah. So if some error happens and EH kicks in, then full queue depth of requests may be allocated. I have seen this for NCQ error. So this is why I make in very first patch change allow us to allocate reserved request from sdev request queue even when budget is fully allocated.
Quoted 3 lines
Please also note that for AHCI, I make reserved depth =1, while for SAS controllers it is greater. This means that in theory we could alloc > 1x reserved command for SATA disk, but I don't think it matters.
Yes, 1 is enough. However, is 1 reserved out of 32 total, meaning that the user can only use 31 tags ? or is it 32+1 reserved ? which we can do since when using the reserved request, we will not use a hw tag (all reserved requests will be non-ncq).
The 32 + 1 scheme will work. But for CDL command completion handling, we will need a NCQ command to do a read log, to avoid forcing a queue drain. For that to reliably work, we'll need a 31+1+1 setup...
Quoted 3 lines
Thanks,
John
Signature · 2 lines
Damien Le Moal Western Digital Research
Re: [PATCH RFC v3 2/7] ata: libata-scsi: Add ata_internal_queuecommand()
Quoted 9 lines · Damien Le Moal
Quoted 9 lines
Well, yeah. So if some error happens and EH kicks in, then full queue depth of requests may be allocated. I have seen this for NCQ error. So this is why I make in very first patch change allow us to allocate reserved request from sdev request queue even when budget is fully allocated.
Please also note that for AHCI, I make reserved depth =1, while for SAS controllers it is greater. This means that in theory we could alloc > 1x reserved command for SATA disk, but I don't think it matters.
Quoted 6 lines
Yes, 1 is enough. However, is 1 reserved out of 32 total, meaning that the user can only use 31 tags ? or is it 32+1 reserved ? which we can do since when using the reserved request, we will not use a hw tag (all reserved requests will be non-ncq).
The 32 + 1 scheme will work.
Yes, 32 + 1 is what we want. I now think that there is a mistake in my code in this series for ahci.
So I think we need for ahci:
can_queue = 33nr_reserved_cmds = 1
while I only have can_queue = 32
I need to check that again for ahci driver and AHCI SHT...
Quoted 4 lines
But for CDL command completion handling, we
will need a NCQ command to do a read log, to avoid forcing a queue drain. For that to reliably work, we'll need a 31+1+1 setup...
So is your idea to permanently reserve 1 more command from 32 commands ? Or re-use 1 from 32 (and still also have 1 separate internal command)?
Thanks,
John
Re: [PATCH RFC v3 2/7] ata: libata-scsi: Add ata_internal_queuecommand()
Quoted 17 lines · John Garry
Quoted 16 lines · Damien Le Moal
Quoted 9 lines
Well, yeah. So if some error happens and EH kicks in, then full queue depth of requests may be allocated. I have seen this for NCQ error. So this is why I make in very first patch change allow us to allocate reserved request from sdev request queue even when budget is fully allocated.
Please also note that for AHCI, I make reserved depth =1, while for SAS controllers it is greater. This means that in theory we could alloc > 1x reserved command for SATA disk, but I don't think it matters.
Yes, 1 is enough. However, is 1 reserved out of 32 total, meaning that the
user can only use 31 tags ? or is it 32+1 reserved ? which we can do since
when using the reserved request, we will not use a hw tag (all reserved requests will be non-ncq).
Quoted 8 lines
Quoted 1 line
The 32 + 1 scheme will work.
Yes, 32 + 1 is what we want. I now think that there is a mistake in my code in this series for ahci.
So I think we need for ahci:
can_queue= 33
Hmm.. For ATA, can_queue should be only 32. nr_tags is going to be 33 though as we include one tag for a reserved command. No ? (may be I misunderstand can_queue though).
Quoted 3 lines
nr_reserved_cmds= 1while I only have
can_queue= 32
Which seems right to me.
Quoted 9 lines
I need to check that again for ahci driver and AHCI SHT...
Quoted 4 lines
But for CDL command completion handling, we
will need a NCQ command to do a read log, to avoid forcing a queue drain. For that to reliably work, we'll need a 31+1+1 setup...So is your idea to permanently reserve 1 more command from 32 commands ?
Yes. Command Duration Limits has this weird case were commands may be failed when exceeding their duration limit with a "good status" and "sense data available bit" set. This case was defined to avoid the queue stall that happens with any NCQ error. The way to handle this without relying on EH (as that would also cause a queue drain) is to issue an NCQ read log command to fetch the "sense data for successful NCQ commands" log, to retrieve the sense data for the completed command and check if it really failed or not. So we absolutely need a reserved command for this, Without a reserved command, it is a nightmare to support (tag reuse would be another solution, but it is horrible).
Quoted 1 line
Or re-use 1 from 32 (and still also have 1 separate internal command)?
I am not yet 100% sure if we can treat that internal NCQ read log like any other read/write request... If we can, then the 1-out-of-32 reservation would not be needed. Need to revisit all the cases we need to take care of (because in the middle of this CDL completion handling, regular NCQ errors can happen, resulting in a drive reset that could wreck everything as we lose the sense data for the completed requests).
In any case, I think that we can deal with that extra reserved command on top of you current series. No need to worry about it for now I think.
Quoted 3 lines
Thanks,
John
Signature · 2 lines
Damien Le Moal Western Digital Research
John Garry
reviewerRe: [PATCH RFC v3 2/7] ata: libata-scsi: Add ata_internal_queuecommand()
Hi Damien,
Quoted 16 lines
Quoted 16 lines
Quoted 4 lines
Quoted 4 lines
Please also note that for AHCI, I make reserved depth =1, while for SAS controllers it is greater. This means that in theory we could alloc > 1x reserved command for SATA disk, but I don't think it matters.
Quoted 8 lines
Yes, 1 is enough. However, is 1 reserved out of 32 total, meaning that the
user can only use 31 tags ? or is it 32+1 reserved ? which we can do since
when using the reserved request, we will not use a hw tag (all reserved requests will be non-ncq).The 32 + 1 scheme will work.
Yes, 32 + 1 is what we want. I now think that there is a mistake in my code in this series for ahci.
Quoted 6 lines
Quoted 3 lines
So I think we need for ahci:
can_queue= 33 >Hmm.. For ATA,
can_queueshould be only 32.nr_tagsis going to be 33 though as we include one tag for a reserved command. No ? (may be I misunderstandcan_queuethough).
Yes, we want nr_tags=33. But according to semantics of can_queue, it includes total of regular and reserved tags. This is because tag_set depth is total of regular and reserved tags, and we subtract reserved tags from total depth in blk_mq_init_bitmaps():
int blk_mq_init_bitmaps(.., unsigned int queue_depth, unsigned int reserved, ..)
{
unsigned int depth = queue_depth - reserved;
...
if (bt_alloc(bitmap_tags, depth, round_robin, nodeSo we want a change like this as well:
drivers/ata/ahci.h +0 -0
@@ -390,7 +390,7 @@ extern const struct attribute_group *ahci_sdev_groups[];*/
#define AHCI_SHT(drv_name) \
__ATA_BASE_SHT(drv_name), \
- .can_queue = AHCI_MAX_CMDS, \
+ .can_queue = AHCI_MAX_CMDS + 1, \
.sg_tablesize = AHCI_MAX_SG, \
.dma_boundary = AHCI_DMA_BOUNDARY, \
.shost_groups = ahci_shost_groups,I know it seems strange, but still 32 tags will only ever be available for non-internal commands (as it is today) and 1 for ata internal command.
Quoted 37 lines
Quoted 4 lines
nr_reserved_cmds= 1while I only have
can_queue= 32Which seems right to me.
Quoted 9 lines
I need to check that again for ahci driver and AHCI SHT...
Quoted 4 lines
But for CDL command completion handling, we
will need a NCQ command to do a read log, to avoid forcing a queue drain. For that to reliably work, we'll need a 31+1+1 setup...So is your idea to permanently reserve 1 more command from 32 commands ?
Yes. Command Duration Limits has this weird case were commands may be failed when exceeding their duration limit with a "good status" and "sense data available bit" set. This case was defined to avoid the queue stall that happens with any NCQ error. The way to handle this without relying on EH (as that would also cause a queue drain) is to issue an NCQ read log command to fetch the "sense data for successful NCQ commands" log, to retrieve the sense data for the completed command and check if it really failed or not. So we absolutely need a reserved command for this, Without a reserved command, it is a nightmare to support (tag reuse would be another solution, but it is horrible).
Quoted 1 line
Or re-use 1 from 32 (and still also have 1 separate internal command)?
I am not yet 100% sure if we can treat that internal NCQ read log like any other read/write request... If we can, then the 1-out-of-32 reservation would not be needed. Need to revisit all the cases we need to take care of (because in the middle of this CDL completion handling, regular NCQ errors can happen, resulting in a drive reset that could wreck everything as we lose the sense data for the completed requests).
Quoted 3 lines
In any case, I think that we can deal with that extra reserved command on top of you current series. No need to worry about it for now I think.
So are you saying that you are basing current CDL support on libata internally managing this extra reserved tag (and so do not need this SCSI midlayer reserved tag support yet)?
Thanks,
John
Re: [PATCH RFC v3 2/7] ata: libata-scsi: Add ata_internal_queuecommand()
Quoted 96 lines · John Garry
Hi Damien,
Quoted 16 lines
Quoted 16 lines
Quoted 4 lines
Quoted 4 lines
Please also note that for AHCI, I make reserved depth =1, while for SAS controllers it is greater. This means that in theory we could alloc > 1x reserved command for SATA disk, but I don't think it matters.
Quoted 8 lines
Yes, 1 is enough. However, is 1 reserved out of 32 total, meaning that the
user can only use 31 tags ? or is it 32+1 reserved ? which we can do since
when using the reserved request, we will not use a hw tag (all reserved requests will be non-ncq).The 32 + 1 scheme will work.
Yes, 32 + 1 is what we want. I now think that there is a mistake in my code in this series for ahci.
Quoted 6 lines
Quoted 3 lines
So I think we need for ahci:
can_queue= 33 >Hmm.. For ATA,
can_queueshould be only 32.nr_tagsis going to be 33 though as we include one tag for a reserved command. No ? (may be I misunderstandcan_queuethough).Yes, we want nr_tags=33. But according to semantics of
can_queue, it includes total of regular and reserved tags. This is becausetag_setdepth is total of regular and reserved tags, and we subtract reserved tags from total depth inblk_mq_init_bitmaps():int
blk_mq_init_bitmaps(.., unsigned int queue_depth, unsigned int reserved, ..){ unsigned int depth = queue_depth - reserved; ... if (bt_alloc(bitmap_tags, depth, round_robin, nodeSo we want a change like this as well:
drivers/ata/ahci.h +1
-1@@ -390,7 +390,7 @@ extern const struct attribute_group*ahci_sdev_groups[]; */ #define AHCI_SHT (drv_name) \ __ATA_BASE_SHT(drv_name), \ - .can_queue = AHCI_MAX_CMDS, \ + .can_queue = AHCI_MAX_CMDS + 1, \ .sg_tablesize = AHCI_MAX_SG, \ .dma_boundary = AHCI_DMA_BOUNDARY, \.shost_groups =
ahci_shost_groups,I know it seems strange, but still 32 tags will only ever be available for non-internal commands (as it is today) and 1 for ata internal command.
Quoted 37 lines
Quoted 4 lines
nr_reserved_cmds= 1while I only have
can_queue= 32Which seems right to me.
Quoted 9 lines
I need to check that again for ahci driver and AHCI SHT...
Quoted 4 lines
But for CDL command completion handling, we
will need a NCQ command to do a read log, to avoid forcing a queue drain. For that to reliably work, we'll need a 31+1+1 setup...So is your idea to permanently reserve 1 more command from 32 commands ?
Yes. Command Duration Limits has this weird case were commands may be failed when exceeding their duration limit with a "good status" and "sense data available bit" set. This case was defined to avoid the queue stall that happens with any NCQ error. The way to handle this without relying on EH (as that would also cause a queue drain) is to issue an NCQ read log command to fetch the "sense data for successful NCQ commands" log, to retrieve the sense data for the completed command and check if it really failed or not. So we absolutely need a reserved command for this, Without a reserved command, it is a nightmare to support (tag reuse would be another solution, but it is horrible).
Quoted 1 line
Or re-use 1 from 32 (and still also have 1 separate internal command)?
I am not yet 100% sure if we can treat that internal NCQ read log like any other read/write request... If we can, then the 1-out-of-32 reservation would not be needed. Need to revisit all the cases we need to take care of (because in the middle of this CDL completion handling, regular NCQ errors can happen, resulting in a drive reset that could wreck everything as we lose the sense data for the completed requests).
Quoted 7 lines
Quoted 3 lines
In any case, I think that we can deal with that extra reserved command on top of you current series. No need to worry about it for now I think.
So are you saying that you are basing current CDL support on libata internally managing this extra reserved tag (and so do not need this SCSI midlayer reserved tag support yet)?
Not really. For now, it is using libata EH, that is, when we need the internal command for the read log, we know the device is idle and no command is on-going. So we send a non-NCQ command which does not have a tag.
Ideally, all of this should use a real reserved tag to allow for an NCQ read log outside of EH, avoiding the drive queue drain.
Quoted 3 lines
Thanks,
John
Signature · 2 lines
Damien Le Moal Western Digital Research
Re: [PATCH RFC v3 2/7] ata: libata-scsi: Add ata_internal_queuecommand()
Quoted 3 lines · Damien Le Moal
Quoted 2 lines · John Garry
Hi Damien,
[ .. ]
Quoted 17 lines
Quoted 9 lines
Quoted 9 lines
Quoted 1 line
Or re-use 1 from 32 (and still also have 1 separate internal command)?
I am not yet 100% sure if we can treat that internal NCQ read log like any other read/write request... If we can, then the 1-out-of-32 reservation would not be needed. Need to revisit all the cases we need to take care of (because in the middle of this CDL completion handling, regular NCQ errors can happen, resulting in a drive reset that could wreck everything as we lose the sense data for the completed requests).
Quoted 7 lines
Quoted 3 lines
In any case, I think that we can deal with that extra reserved command on top of you current series. No need to worry about it for now I think.
So are you saying that you are basing current CDL support on libata internally managing this extra reserved tag (and so do not need this SCSI midlayer reserved tag support yet)?
Quoted 7 lines
Not really. For now, it is using libata EH, that is, when we need the internal command for the read log, we know the device is idle and no command is on-going. So we send a non-NCQ command which does not have a tag.
Ideally, all of this should use a real reserved tag to allow for an NCQ read log outside of EH, avoiding the drive queue drain.
But with the current design you'll only get that if you reserve one precious tag.
OTOH, we might not need that tag at all, as _if_ we get an error for a specific command the tag associated with it is necessarily free after completion, right?
So we only need to find a way of 're-using' that tag, then we won't have to set aside a reserved tag and everything would be dandy...
Maybe we can stop processing when we receive an error (should be doing that anyway as otherwise the log might be overwritten), then we should be having a pretty good chance of getting that tag. Or, precisely, getting _any_ tag as at least one tag is free at that point.
Hmm?
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
Re: [PATCH RFC v3 2/7] ata: libata-scsi: Add ata_internal_queuecommand()
Quoted 26 lines · Hannes Reinecke
Quoted 3 lines · Damien Le Moal
Quoted 2 lines · John Garry
Hi Damien,
[ .. ]
Quoted 21 lines
Quoted 9 lines
Quoted 9 lines
Quoted 1 line
Or re-use 1 from 32 (and still also have 1 separate internal command)?
I am not yet 100% sure if we can treat that internal NCQ read log like any other read/write request... If we can, then the 1-out-of-32 reservation would not be needed. Need to revisit all the cases we need to take care of (because in the middle of this CDL completion handling, regular NCQ errors can happen, resulting in a drive reset that could wreck everything as we lose the sense data for the completed requests).
Quoted 7 lines
Quoted 3 lines
In any case, I think that we can deal with that extra reserved command on top of you current series. No need to worry about it for now I think.
So are you saying that you are basing current CDL support on libata internally managing this extra reserved tag (and so do not need this SCSI midlayer reserved tag support yet)?
Not really. For now, it is using libata EH, that is, when we need the internal command for the read log, we know the device is idle and no command is on-going. So we send a non-NCQ command which does not have a tag.
Quoted 5 lines
Quoted 3 lines
Ideally, all of this should use a real reserved tag to allow for an NCQ read log outside of EH, avoiding the drive queue drain.
But with the current design you'll only get that if you reserve one precious tag.
yes, which is annoying. Back to the days where ATA max qd was 31...
Quoted 3 lines
OTOH, we might not need that tag at all, as _if_ we get an error for a specific command the tag associated with it is necessarily free after completion, right?
Well, it is not really free. It is unused as far as the device is concerned since the command that needs to be checked completed. But not free yet since we need to do the read log first before being able to scsi-complete the command (which will free the tag). So if we use the regular submission path to issue the read log, we must be guaranteed that we can get a tag, otherwise we will deadlock. Hence the need to reserve one tag.
Quoted 2 lines
So we only need to find a way of 're-using' that tag, then we won't have to set aside a reserved tag and everything would be dandy...
I tried that. It is very ugly... Problem is that integration with EH in case a real NCQ error happens when all that read-log-complete dance is happening is hard. And don't get me started with the need to save/restore the scsi command context of the command we are reusing the tag from.
And given that the code is changing to use regular submission path for internal commands, right now, we need a reserved tag. Or a way to "borrow" the tag from a request that we need to check. Which means we need some additional api to not always try to allocate a tag.
Quoted 4 lines
Maybe we can stop processing when we receive an error (should be doing that anyway as otherwise the log might be overwritten), then we should be having a pretty good chance of getting that tag.
Hmmm.... that would be no better than using EH which does stop processing until the internal house keeping is done.
Quoted 2 lines
Or, precisely, getting _any_ tag as at least one tag is free at that point. Hmm?
See above. Not free, but usable as far as the device is concerned since we have at least on command we need to check completed at the device level (but not yet completed from scsi/block layer point of view).
Quoted 4 lines
Cheers,
Hannes
Signature · 2 lines
Damien Le Moal Western Digital Research
Re: [PATCH RFC v3 2/7] ata: libata-scsi: Add ata_internal_queuecommand()
Quoted 26 lines · Damien Le Moal
Quoted 6 lines · Hannes Reinecke
Quoted 3 lines · Damien Le Moal
Quoted 2 lines · John Garry
Hi Damien,
[ .. ] >> So we only need to find a way of 're-using' that tag, then we won't have to set aside a reserved tag and everything would be dandy...
I tried that. It is very ugly... Problem is that integration with EH in case a real NCQ error happens when all that read-log-complete dance is happening is hard. And don't get me started with the need to save/restore the scsi command context of the command we are reusing the tag from.
And given that the code is changing to use regular submission path for internal commands, right now, we need a reserved tag. Or a way to "borrow" the tag from a request that we need to check. Which means we need some additional api to not always try to allocate a tag.
Quoted 4 lines
Maybe we can stop processing when we receive an error (should be doing that anyway as otherwise the log might be overwritten), then we should be having a pretty good chance of getting that tag.
Hmmm.... that would be no better than using EH which does stop processing until the internal house keeping is done.
Quoted 7 lines
Quoted 2 lines
Or, precisely, getting _any_ tag as at least one tag is free at that point. Hmm?
See above. Not free, but usable as far as the device is concerned since we have at least on command we need to check completed at the device level (but not yet completed from scsi/block layer point of view).
So, having had an entire weekend pondering this issue why don't we allocate an _additional_ set of requests?
After all, we had been very generous with allocating queues and requests (what with us doing a full provisioning of the requests for all queues already for the non-shared tag case).
Idea would be to keep the single tag bitmap, but add eg a new rq state MQ_RQ_ERROR. Once that flag is set we'll fetch the error request instead of the normal one:
@@ -761,6 +763,8 @@ static inline struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags,
{
if (tag < tags->nr_tags) {
prefetch(tags->rqs[tag]);
+ if (unlikely(blk_mq_request_error(tags->rqs[tag])))
+ return tags->error_rqs[tag];
return tags->rqs[tag];
}and, of course, we would need to provision the error request first.
Rationale here is that this will be primarily for devices with a low number of tags, so doubling the number of request isn't much of an overhead (as we'll be doing it essentially anyway in the error case as we'll have to save the original request _somewhere_), and that it would remove quite some cruft from the subsystem; look at SCSI EH trying to store the original request contents and then after EH restoring them again.
Hmm?
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
Re: [PATCH RFC v3 2/7] ata: libata-scsi: Add ata_internal_queuecommand()
Quoted 54 lines · Hannes Reinecke
Quoted 26 lines · Damien Le Moal
Quoted 6 lines · Hannes Reinecke
Quoted 3 lines · Damien Le Moal
Quoted 2 lines · John Garry
Hi Damien,
[ .. ] >> So we only need to find a way of 're-using' that tag, then we won't have to set aside a reserved tag and everything would be dandy...
I tried that. It is very ugly... Problem is that integration with EH in case a real NCQ error happens when all that read-log-complete dance is happening is hard. And don't get me started with the need to save/restore the scsi command context of the command we are reusing the tag from.
And given that the code is changing to use regular submission path for internal commands, right now, we need a reserved tag. Or a way to "borrow" the tag from a request that we need to check. Which means we need some additional api to not always try to allocate a tag.
Quoted 4 lines
Maybe we can stop processing when we receive an error (should be doing that anyway as otherwise the log might be overwritten), then we should be having a pretty good chance of getting that tag.
Hmmm.... that would be no better than using EH which does stop processing until the internal house keeping is done.
Quoted 7 lines
Quoted 2 lines
Or, precisely, getting _any_ tag as at least one tag is free at that point. Hmm?
See above. Not free, but usable as far as the device is concerned since we have at least on command we need to check completed at the device level (but not yet completed from scsi/block layer point of view).
So, having had an entire weekend pondering this issue why don't we allocate an _additional_ set of requests?
After all, we had been very generous with allocating queues and requests (what with us doing a full provisioning of the requests for all queues already for the non-shared tag case).Idea would be to keep the single tag bitmap, but add eg a new rq state
MQ_RQ_ERROR. Once that flag is set we'll fetch the error request instead of the normal one:(quoted diff) +2
-0@@ -761,6 +763,8 @@ static inline struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, { if (tag < tags->nr_tags) { prefetch(tags->rqs[tag]); + if (unlikely(blk_mq_request_error(tags->rqs[tag]))) + return tags->error_rqs[tag]; return tags->rqs[tag]; }
Quoted 8 lines
and, of course, we would need to provision the error request first.
Rationale here is that this will be primarily for devices with a low number of tags, so doubling the number of request isn't much of an overhead (as we'll be doing it essentially anyway in the error case as we'll have to save the original request _somewhere_), and that it would remove quite some cruft from the subsystem; look at SCSI EH trying to store the original request contents and then after EH restoring them again.
Interesting idea. I like it. It is essentially a set of reserved requests without reserved tags: the tag to use for these requests would be provided "manually" by the user. Right ?
That should allow simplifying any processing that needs to reuse a tag, and currently its request. That is, CDL, but also usb-scsi, scsi EH and the few scsi LLDs using scsi_eh_prep_cmnd()+scsi_eh_restore_cmnd(). Ideally, these 2 functions could go away too.
Quoted 6 lines
Hmm?
Cheers,
Hannes
Signature · 2 lines
Damien Le Moal Western Digital Research
Re: [PATCH RFC v3 2/7] ata: libata-scsi: Add ata_internal_queuecommand()
Quoted 57 lines · Damien Le Moal
Quoted 56 lines · Hannes Reinecke
Quoted 26 lines · Damien Le Moal
Quoted 6 lines · Hannes Reinecke
Quoted 3 lines · Damien Le Moal
Quoted 2 lines · John Garry
Hi Damien,
[ .. ] >> So we only need to find a way of 're-using' that tag, then we won't have to set aside a reserved tag and everything would be dandy...
I tried that. It is very ugly... Problem is that integration with EH in case a real NCQ error happens when all that read-log-complete dance is happening is hard. And don't get me started with the need to save/restore the scsi command context of the command we are reusing the tag from.
And given that the code is changing to use regular submission path for internal commands, right now, we need a reserved tag. Or a way to "borrow" the tag from a request that we need to check. Which means we need some additional api to not always try to allocate a tag.
Quoted 4 lines
Maybe we can stop processing when we receive an error (should be doing that anyway as otherwise the log might be overwritten), then we should be having a pretty good chance of getting that tag.
Hmmm.... that would be no better than using EH which does stop processing until the internal house keeping is done.
Quoted 7 lines
Quoted 2 lines
Or, precisely, getting _any_ tag as at least one tag is free at that point. Hmm?
See above. Not free, but usable as far as the device is concerned since we have at least on command we need to check completed at the device level (but not yet completed from scsi/block layer point of view).
So, having had an entire weekend pondering this issue why don't we allocate an _additional_ set of requests?
After all, we had been very generous with allocating queues and requests (what with us doing a full provisioning of the requests for all queues already for the non-shared tag case).Idea would be to keep the single tag bitmap, but add eg a new rq state
MQ_RQ_ERROR. Once that flag is set we'll fetch the error request instead of the normal one:(quoted diff) +2
-0@@ -761,6 +763,8 @@ static inline struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, { if (tag < tags->nr_tags) { prefetch(tags->rqs[tag]); + if (unlikely(blk_mq_request_error(tags->rqs[tag]))) + return tags->error_rqs[tag]; return tags->rqs[tag]; }and, of course, we would need to provision the error request first.
Quoted 11 lines
Quoted 6 lines
Rationale here is that this will be primarily for devices with a low number of tags, so doubling the number of request isn't much of an overhead (as we'll be doing it essentially anyway in the error case as we'll have to save the original request _somewhere_), and that it would remove quite some cruft from the subsystem; look at SCSI EH trying to store the original request contents and then after EH restoring them again.
Interesting idea. I like it. It is essentially a set of reserved requests without reserved tags: the tag to use for these requests would be provided "manually" by the user. Right ?
Yes. Upon failure one would be calling something like 'blk_mq_get_error_rq(rq)', which would set the error flag in the original request, fetch the matching request from ->static_rqs, and return that one.
Just figured, we could simply enlarge 'static_rqs' to have double the size; then we can easily get the appropriate request from 'static_rqs' by just adding the queue size. Making things even easier ...
Quoted 5 lines
That should allow simplifying any processing that needs to reuse a tag, and currently its request. That is, CDL, but also usb-scsi, scsi EH and the few scsi LLDs using scsi_eh_prep_cmnd()+scsi_eh_restore_cmnd(). Ideally, these 2 functions could go away too.
Which was precisely the idea. We have quite some drivers/infrastructure which already require a similar functionality, and basically all of them cover devices with a really low tag space (32/31 in the libata NCQ case, 16 in the SCSI TCQ case, or even _1_ in the SCSI parallel case :-) So a request duplication wouldn't matter _that_ much here.
Drivers with a higher queue depth typically can do 'real' TMFs, where you need to allocate a new tag anyway, and so the whole operation doesn't apply here.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
RFC PATCH v3 3/7 ata: libata: Make space for ATA queue command in scmd payload
In reply to John GarryPrepare to put the ATA queue command in a scmd payload by using priv space per driver which uses libata.
The end goal is to remove ata_port.qcmd[].
--- drivers/ata/libata-scsi.c | 6 ++++++ drivers/scsi/aic94xx/aic94xx_init.c | 2 ++ drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 2 ++ drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 2 ++ drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 2 ++ drivers/scsi/isci/init.c | 2 ++ drivers/scsi/mvsas/mv_init.c | 2 ++ drivers/scsi/pm8001/pm8001_init.c | 2 ++ include/linux/libata.h | 5 ++++- 9 files changed, 24 insertions(+), 1 deletion(-)
drivers/ata/libata-scsi.c +6 -0
@@ -1118,6 +1118,12 @@ int ata_scsi_dev_config(struct scsi_device *sdev, struct ata_device *dev)return 0 ; } +int ata_init_cmd_priv (struct Scsi_Host *shost,struct scsi_cmnd *cmd) +{ +return 0 ; +} +EXPORT_SYMBOL_GPL (ata_init_cmd_priv); +int ata_internal_queuecommand (struct Scsi_Host *shost,struct scsi_cmnd *scmd) {struct ata_port *ap;
drivers/scsi/aic94xx/aic94xx_init.c +2 -0
@@ -63,6 +63,8 @@ static struct scsi_host_template aic94xx_sht = { .reserved_queuecommand = sas_queuecommand_internal, .reserved_timedout = sas_internal_timeout, .nr_reserved_cmds = 2, + .init_cmd_priv = ata_init_cmd_priv, + .cmd_size = sizeof(struct ata_queued_cmd), };static int asd_map_memio (struct asd_ha_struct *asd_ha)
drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +2 -0
@@ -1763,6 +1763,8 @@ static struct scsi_host_template sht_v1_hw = { .reserved_queuecommand = sas_queuecommand_internal, .reserved_timedout = sas_internal_timeout, .nr_reserved_cmds = 2, + .init_cmd_priv = ata_init_cmd_priv, + .cmd_size = sizeof(struct ata_queued_cmd), };static const struct hisi_sas_hw hisi_sas_v1_hw = {
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +2 -0
@@ -3581,6 +3581,8 @@ static struct scsi_host_template sht_v2_hw = { .reserved_queuecommand = sas_queuecommand_internal, .reserved_timedout = sas_internal_timeout, .nr_reserved_cmds = 2, + .init_cmd_priv = ata_init_cmd_priv, + .cmd_size = sizeof(struct ata_queued_cmd), };static const struct hisi_sas_hw hisi_sas_v2_hw = {
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +2 -0
@@ -3248,6 +3248,8 @@ static struct scsi_host_template sht_v3_hw = { .reserved_queuecommand = sas_queuecommand_internal, .reserved_timedout = sas_internal_timeout, .nr_reserved_cmds = 2, + .init_cmd_priv = ata_init_cmd_priv, + .cmd_size = sizeof(struct ata_queued_cmd), };static const struct hisi_sas_hw hisi_sas_v3_hw = {
drivers/scsi/isci/init.c +2 -0
@@ -180,6 +180,8 @@ static struct scsi_host_template isci_sht = { .reserved_queuecommand = sas_queuecommand_internal, .reserved_timedout = sas_internal_timeout, .nr_reserved_cmds = 2, + .init_cmd_priv = ata_init_cmd_priv, + .cmd_size = sizeof(struct ata_queued_cmd), };static struct sas_domain_function_template isci_transport_ops = {
drivers/scsi/mvsas/mv_init.c +2 -0
@@ -57,6 +57,8 @@ static struct scsi_host_template mvs_sht = { .reserved_queuecommand = sas_queuecommand_internal, .reserved_timedout = sas_internal_timeout, .nr_reserved_cmds = 2, + .init_cmd_priv = ata_init_cmd_priv, + .cmd_size = sizeof(struct ata_queued_cmd), };static struct sas_domain_function_template mvs_transport_ops = {
drivers/scsi/pm8001/pm8001_init.c +2 -0
@@ -126,6 +126,8 @@ static struct scsi_host_template pm8001_sht = { .reserved_queuecommand = sas_queuecommand_internal, .reserved_timedout = sas_internal_timeout, .nr_reserved_cmds = 2, + .init_cmd_priv = ata_init_cmd_priv, + .cmd_size = sizeof(struct ata_queued_cmd), };/*
include/linux/libata.h +4 -1
@@ -1143,6 +1143,7 @@ extern void ata_scsi_unlock_native_capacity(struct scsi_device *sdev);extern int ata_scsi_slave_config (struct scsi_device *sdev);extern int ata_internal_queuecommand (struct Scsi_Host *shost,struct scsi_cmnd *scmd); +extern int ata_init_cmd_priv (struct Scsi_Host *shost,struct scsi_cmnd *cmd);extern void ata_scsi_slave_destroy (struct scsi_device *sdev);extern int ata_scsi_change_queue_depth (struct scsi_device *sdev,int queue_depth);
@@ -1394,7 +1395,9 @@ extern const struct attribute_group *ata_common_sdev_groups[]; .bios_param = ata_std_bios_param, \ .unlock_native_capacity = ata_scsi_unlock_native_capacity,\ .max_sectors = ATA_MAX_SECTORS_LBA48,\ - .reserved_queuecommand = ata_internal_queuecommand + .reserved_queuecommand = ata_internal_queuecommand,\ + .cmd_size = sizeof(struct ata_queued_cmd),\ + .init_cmd_priv = ata_init_cmd_priv#define ATA_SUBBASE_SHT (drv_name) \ __ATA_BASE_SHT(drv_name), \
Signature · 1 line
2.35.3
RFC PATCH v3 4/7 ata: libata: Add ata_internal_timeout()
In reply to John GarryAdd a internal command timeout handler. Also hook into libsas timeout handler.
--- drivers/ata/libata-scsi.c | 10 ++++++++++ drivers/scsi/libsas/sas_scsi_host.c | 5 +++++ include/linux/libata.h | 2 ++ 3 files changed, 17 insertions(+)
drivers/ata/libata-scsi.c +10 -0
@@ -1138,6 +1138,16 @@ int ata_internal_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmd) }EXPORT_SYMBOL_GPL (ata_internal_queuecommand); +enum blk_eh_timer_return ata_internal_timeout (struct scsi_cmnd *scmd) +{ +struct request *rq =blk_mq_rq_from_pdu (scmd); +struct completion *wait = rq->end_io_data; + +complete (wait); +return BLK_EH_DONE ; +} +EXPORT_SYMBOL_GPL (ata_internal_timeout); +/** * ata_scsi_slave_config - Set SCSI device attributes * @sdev: SCSI device to examine
drivers/scsi/libsas/sas_scsi_host.c +5 -0
@@ -921,10 +921,15 @@ void sas_task_complete_internal(struct sas_task *task)enum blk_eh_timer_return sas_internal_timeout (struct scsi_cmnd *scmd) { +struct domain_device *dev =cmd_to_domain_dev (scmd);struct sas_task *task =TO_SAS_TASK (scmd);bool is_completed = true;unsigned long flags; +/* Handle libata internal command */ +if (dev_is_sata (dev) && !task->slow_task) +return ata_internal_timeout (scmd); +spin_lock_irqsave (&task->task_state_lock, flags);if (!(task->task_state_flags &SAS_TASK_STATE_DONE )) { task->task_state_flags |=SAS_TASK_STATE_ABORTED ;
include/linux/libata.h +2 -0
@@ -1143,6 +1143,7 @@ extern void ata_scsi_unlock_native_capacity(struct scsi_device *sdev);extern int ata_scsi_slave_config (struct scsi_device *sdev);extern int ata_internal_queuecommand (struct Scsi_Host *shost,struct scsi_cmnd *scmd); +extern enum blk_eh_timer_return ata_internal_timeout (struct scsi_cmnd *scmd);extern int ata_init_cmd_priv (struct Scsi_Host *shost,struct scsi_cmnd *cmd);extern void ata_scsi_slave_destroy (struct scsi_device *sdev); extern int ata_scsi_change_queue_depth(struct scsi_device *sdev,
@@ -1397,6 +1398,7 @@ extern const struct attribute_group *ata_common_sdev_groups[]; .max_sectors = ATA_MAX_SECTORS_LBA48,\ .reserved_queuecommand = ata_internal_queuecommand,\ .cmd_size = sizeof(struct ata_queued_cmd),\ + .reserved_timedout = ata_internal_timeout,\ .init_cmd_priv = ata_init_cmd_priv#define ATA_SUBBASE_SHT (drv_name) \
Signature · 1 line
2.35.3
RFC PATCH v3 5/7 ata: libata: Queue ATA internal commands as requests
In reply to John GarryFollow the normal path for requests and queue through the block layer.
Since we now have a scsi_cmnd for every ATA queued command, we can delete ata_port.qcmd[]. The ATA queue command iterators are fixed to use the blk-mq tagset iters.
For libsas it's hard to differentiate between a reserved request which is a libata internal command and SATA "tmf". Normally we can use the sas_task "is dev sata" check, but that does not work. For now just check the rq->end_io pointer.
At this point all libsas sas_task should have a rq associated, so let's WARN just in case.
--- drivers/ata/libata-core.c | 141 +++++++++++++++------------- drivers/ata/libata-eh.c | 11 ++- drivers/ata/libata-sata.c | 2 +- drivers/ata/libata-scsi.c | 5 +- drivers/scsi/libsas/sas_scsi_host.c | 15 ++- include/linux/libata.h | 48 +++++++++- include/scsi/libsas.h | 8 +- 7 files changed, 151 insertions(+), 79 deletions(-)
drivers/ata/libata-core.c +77 -64
@@ -1440,9 +1440,21 @@ EXPORT_SYMBOL_GPL(ata_id_xfermask);static void ata_qc_complete_internal (struct ata_queued_cmd *qc) { -struct completion *waiting = qc->private_data; +struct scsi_cmnd *scmd = qc->scsicmd; + +scsi_done (scmd); +} + +static enum rq_end_io_ret ata_internal_end_rq (struct request *rq, +blk_status_t error) +{ +struct completion *waiting = rq->end_io_data; + + rq->end_io_data = (void *)(uintptr_t )error;complete (waiting); + +return RQ_END_IO_NONE ; }/**
@@ -1450,9 +1462,9 @@ static void ata_qc_complete_internal(struct ata_queued_cmd *qc)* @dev: Device to which the command is sent * @tf: Taskfile registers for the command and the result * @cdb: CDB for packet command +* @buf: Data buffer of the command +* @buflen: Length of data buffer * @dma_dir: Data transfer direction of the command -* @sgl: sg list for the data buffer of the command -* @n_elem: Number of sg entries * @timeout: Timeout in msecs (0 for default) * * Executes libata internal command with timeout. @tf contains
@@ -1469,50 +1481,65 @@ static void ata_qc_complete_internal(struct ata_queued_cmd *qc)*/ static unsigned ata_exec_internal_sg (struct ata_device *dev,struct ata_taskfile *tf,const u8 *cdb, -int dma_dir,struct scatterlist *sgl, -unsigned int n_elem,unsigned int timeout) +int dma_dir,void *buf, +unsigned int buflen,unsigned int timeout) {struct ata_link *link = dev->link;struct ata_port *ap = link->ap; +struct scsi_device *sdev = dev->sdev;u8 command = tf->command;int auto_timeout =0 ;struct ata_queued_cmd *qc; -unsigned int preempted_tag; -u32 preempted_sactive; -u64 preempted_qc_active; -int preempted_nr_active_links;DECLARE_COMPLETION_ONSTACK (wait);unsigned long flags;unsigned int err_mask; -int rc; +struct scsi_cmnd *scmd; +struct request *rq; -spin_lock_irqsave (ap->lock, flags); +if (!sdev) +return AC_ERR_OTHER ; -/* no internal command while frozen */ -if (ap->pflags &ATA_PFLAG_FROZEN ) { -spin_unlock_irqrestore (ap->lock, flags); -return AC_ERR_SYSTEM ; + rq =scsi_alloc_request (sdev->request_queue, + dma_dir ==DMA_TO_DEVICE ? +REQ_OP_DRV_OUT :REQ_OP_DRV_IN , +BLK_MQ_REQ_RESERVED ); +if (IS_ERR (rq)) +return AC_ERR_OTHER ; + + +if (!timeout) { +if (ata_probe_timeout) + timeout = ata_probe_timeout *1000 ; +else { + timeout =ata_internal_cmd_timeout (dev, command); + auto_timeout =1 ; + } } -/* initialize internal qc */ - qc =__ata_qc_from_tag (ap,ATA_TAG_INTERNAL ); + scmd =blk_mq_rq_to_pdu (rq); + scmd->allowed =0 ; + rq->timeout =msecs_to_jiffies (timeout); + rq->rq_flags |=RQF_QUIET ; + scmd->device = sdev; + + qc =ata_scmd_to_qc (scmd); + +if (buflen) { +int ret =blk_rq_map_kern (sdev->request_queue, rq, + buf, buflen,GFP_NOIO ); +if (ret) { +blk_mq_free_request (rq); +return AC_ERR_OTHER ; + } + } qc->tag =ATA_TAG_INTERNAL ; qc->hw_tag =0 ; - qc->scsicmd =NULL ; + qc->scsicmd = scmd; qc->ap = ap; qc->dev = dev;ata_qc_reinit (qc); - preempted_tag = link->active_tag; - preempted_sactive = link->sactive; - preempted_qc_active = ap->qc_active; - preempted_nr_active_links = ap->nr_active_links; - link->active_tag =ATA_TAG_POISON ; - link->sactive =0 ; - ap->qc_active =0 ; - ap->nr_active_links =0 ; -/* prepare & issue qc */ qc->tf = *tf;if (cdb)
@@ -1525,44 +1552,26 @@ static unsigned ata_exec_internal_sg(struct ata_device *dev, qc->flags |=ATA_QCFLAG_RESULT_TF ; qc->dma_dir = dma_dir; -if (dma_dir !=DMA_NONE ) { -unsigned int i, buflen =0 ; -struct scatterlist *sg; - -for_each_sg (sgl, sg, n_elem, i) - buflen += sg->length; -ata_sg_init (qc, sgl, n_elem); - qc->nbytes = buflen; - } - - qc->private_data = &wait; + qc->private_data = ap; qc->complete_fn = ata_qc_complete_internal; -ata_qc_issue (qc); + rq->end_io_data = &wait; + rq->end_io = ata_internal_end_rq; -spin_unlock_irqrestore (ap->lock, flags); - -if (!timeout) { -if (ata_probe_timeout) - timeout = ata_probe_timeout *1000 ; -else { - timeout =ata_internal_cmd_timeout (dev, command); - auto_timeout =1 ; - } - } +blk_execute_rq_nowait (rq, true);if (ap->ops->error_handler)ata_eh_release (ap); - rc =wait_for_completion_timeout (&wait,msecs_to_jiffies (timeout)); +wait_for_completion (&wait);if (ap->ops->error_handler)ata_eh_acquire (ap);ata_sff_flush_pio_task (ap); -if (!rc) { +if (rq->rq_flags &RQF_TIMED_OUT ) {spin_lock_irqsave (ap->lock, flags);/* We're racing with irq here. If we lose, the
@@ -1610,13 +1619,15 @@ static unsigned ata_exec_internal_sg(struct ata_device *dev, err_mask = qc->err_mask;ata_qc_free (qc); - link->active_tag = preempted_tag; - link->sactive = preempted_sactive; - ap->qc_active = preempted_qc_active; - ap->nr_active_links = preempted_nr_active_links; + link->active_tag = link->preempted_tag; + link->sactive = link->preempted_sactive; + ap->qc_active = ap->preempted_qc_active; + ap->nr_active_links = ap->preempted_nr_active_links;spin_unlock_irqrestore (ap->lock, flags); +blk_mq_free_request (rq); +if ((err_mask &AC_ERR_TIMEOUT ) && auto_timeout)ata_internal_cmd_timed_out (dev, command);
@@ -1647,18 +1658,20 @@ unsigned ata_exec_internal(struct ata_device *dev, int dma_dir, void *buf, unsigned int buflen, unsigned int timeout) { - struct scatterlist *psg = NULL, sg; -unsigned int n_elem =0 ; + /* buf may not be aligned, so copy to/from an aligned buffer */ + void *tmpbuf = kmemdup(buf, buflen, GFP_KERNEL); +unsigned res; -if (dma_dir !=DMA_NONE ) { -WARN_ON (!buf); -sg_init_one (&sg, buf, buflen); - psg = &sg; - n_elem++; - } +if (!tmpbuf) +return AC_ERR_OTHER ; -return ata_exec_internal_sg (dev, tf, cdb, dma_dir, psg, n_elem, + res =ata_exec_internal_sg (dev, tf, cdb, dma_dir, tmpbuf, buflen, timeout); + +memcpy (buf, tmpbuf, buflen); +kfree (tmpbuf); + +return res; }/**
drivers/ata/libata-eh.c +7 -4
@@ -604,6 +604,9 @@ void ata_scsi_cmd_error_handler(struct Scsi_Host *host, struct ata_port *ap,struct ata_queued_cmd *qc;ata_qc_for_each_raw (ap, qc, i) { +if (!qc) +continue ; +if (qc->flags &ATA_QCFLAG_ACTIVE && qc->scsicmd == scmd)break ;
@@ -1946,7 +1949,7 @@ static void ata_eh_link_autopsy(struct ata_link *link) all_err_mask |= ehc->i.err_mask;ata_qc_for_each_raw (ap, qc, tag) { -if (!(qc->flags &ATA_QCFLAG_FAILED ) || +if (!qc || (qc->flags &ATA_QCFLAG_FAILED ) ||ata_dev_phys_link (qc->dev) != link)continue ;
@@ -2223,7 +2226,7 @@ static void ata_eh_link_report(struct ata_link *link) desc = ehc->i.desc;ata_qc_for_each_raw (ap, qc, tag) { -if (!(qc->flags &ATA_QCFLAG_FAILED ) || +if (!qc || !(qc->flags &ATA_QCFLAG_FAILED ) ||ata_dev_phys_link (qc->dev) != link || ((qc->flags &ATA_QCFLAG_QUIET ) && qc->err_mask ==AC_ERR_DEV ))
@@ -2289,7 +2292,7 @@ static void ata_eh_link_report(struct ata_link *link)char data_buf[20 ] ="" ;char cdb_buf[70 ] ="" ; -if (!(qc->flags &ATA_QCFLAG_FAILED ) || +if (!qc || !(qc->flags &ATA_QCFLAG_FAILED ) ||ata_dev_phys_link (qc->dev) != link || !qc->err_mask)continue ;
@@ -3795,7 +3798,7 @@ void ata_eh_finish(struct ata_port *ap)/* retry or finish qcs */ ata_qc_for_each_raw (ap, qc, tag) { -if (!(qc->flags &ATA_QCFLAG_FAILED )) +if (!qc || !(qc->flags &ATA_QCFLAG_FAILED ))continue ;if (qc->err_mask) {
drivers/ata/libata-sata.c +1 -1
@@ -1432,7 +1432,7 @@ void ata_eh_analyze_ncq_error(struct ata_link *link)/* has LLDD analyzed already? */ ata_qc_for_each_raw (ap, qc, tag) { -if (!(qc->flags &ATA_QCFLAG_FAILED )) +if (!qc || !(qc->flags &ATA_QCFLAG_FAILED ))continue ;if (qc->err_mask)
drivers/ata/libata-scsi.c +3 -2
@@ -657,7 +657,7 @@ static struct ata_queued_cmd *ata_scsi_qc_new(struct ata_device *dev, tag =scsi_cmd_to_rq (cmd)->tag; } - qc =__ata_qc_from_tag (ap, tag); + qc =ata_scmd_to_qc (cmd); qc->tag = qc->hw_tag = tag; qc->ap = ap; qc->dev = dev;
@@ -4007,7 +4007,8 @@ unsigned int ata_scsi_queue_internal(struct scsi_cmnd *scmd, goto did_err;/* initialize internal qc */ - qc =__ata_qc_from_tag (ap,ATA_TAG_INTERNAL ); + qc =ata_scmd_to_qc (scmd); + qc->scsicmd = scmd; link->preempted_tag = link->active_tag; link->preempted_sactive = link->sactive; ap->preempted_qc_active = ap->qc_active;
drivers/scsi/libsas/sas_scsi_host.c +14 -1
@@ -163,8 +163,21 @@ int sas_queuecommand_internal(struct Scsi_Host *shost, struct scsi_cmnd *cmnd)struct sas_ha_struct *ha =SHOST_TO_SAS_HA (shost);struct sas_internal *i =to_sas_internal (ha->core.shost->transportt);struct request *rq =blk_mq_rq_from_pdu (cmnd); -struct sas_task *task = rq->end_io_data; +struct sas_task *task; + +/* uh, I can't see a better check for now */ +if (rq->end_io != sas_blk_end_sync_rq) { +struct ata_queued_cmd *qc =ata_scmd_to_qc (cmnd); +struct ata_port *ap = qc->ap; +int res; + +spin_lock_irq (ap->lock); + res =ata_sas_queuecmd (cmnd, ap); +spin_unlock_irq (ap->lock); +return res; + } + task = rq->end_io_data;ASSIGN_SAS_TASK (cmnd, task);return i->dft->lldd_execute_task (task,GFP_KERNEL );
include/linux/libata.h +45 -3
75 lines not on this page · raw message
include/scsi/libsas.h +4 -4
@@ -644,15 +644,15 @@ static inline struct request *sas_task_find_rq(struct sas_task *task) {struct scsi_cmnd *scmd; -if (!task->slow_task && task->task_proto &SAS_PROTOCOL_STP_ALL ) { +if (task->slow_task || !(task->task_proto &SAS_PROTOCOL_STP_ALL )) { + scmd = task->uldd_task; + }else {struct ata_queued_cmd *qc = task->uldd_task; scmd = qc ? qc->scsicmd :NULL ; - }else { - scmd = task->uldd_task; } -if (!scmd) +if (WARN_ON_ONCE (!scmd))return NULL ;return scsi_cmd_to_rq (scmd);
Signature · 1 line
2.35.3
RFC PATCH v3 6/7 scsi: mvsas: Remove internal tag handling
In reply to John GarryNow that any sas_task which we're sent has a request associated, delete internal tag management.
--- drivers/scsi/mvsas/mv_init.c | 11 -------- drivers/scsi/mvsas/mv_sas.c | 55 ++---------------------------------- drivers/scsi/mvsas/mv_sas.h | 1 - 3 files changed, 2 insertions(+), 65 deletions(-)
drivers/scsi/mvsas/mv_init.c +0 -11
@@ -147,7 +147,6 @@ static void mvs_free(struct mvs_info *mvi)scsi_host_put (mvi->shost);list_for_each_entry (mwq, &mvi->wq_list, entry)cancel_delayed_work (&mwq->work_q); -kfree (mvi->rsvd_tags);kfree (mvi); }
@@ -371,10 +370,6 @@ static struct mvs_info *mvs_pci_alloc(struct pci_dev *pdev, mvi->sas = sha; mvi->shost = shost; - mvi->rsvd_tags =bitmap_zalloc (MVS_RSVD_SLOTS ,GFP_KERNEL ); -if (!mvi->rsvd_tags) - goto err_out; -if (MVS_CHIP_DISP ->chip_ioremap (mvi)) goto err_out;if (!mvs_alloc (mvi, shost))
@@ -473,12 +468,6 @@ static void mvs_post_sas_ha_init(struct Scsi_Host *shost,else can_queue =MVS_CHIP_SLOT_SZ ; -/* -* Carve out MVS_RSVD_SLOTS slots internally until every sas_task we're sent -* has a request associated. -*/ - can_queue -=MVS_RSVD_SLOTS ; - shost->sg_tablesize =min_t (u16,SG_ALL ,MVS_MAX_SG ); shost->can_queue = can_queue; mvi->shost->cmd_per_lun =MVS_QUEUE_SIZE ;
drivers/scsi/mvsas/mv_sas.c +2 -53
97 lines not on this page · raw message
drivers/scsi/mvsas/mv_sas.h +0 -1
@@ -370,7 +370,6 @@ struct mvs_info {u32 chip_id;const struct mvs_chip_info *chip; -unsigned long *rsvd_tags;/* further per-slot information */ struct mvs_phy phy[MVS_MAX_PHYS ];struct mvs_port port[MVS_MAX_PHYS ];
Signature · 1 line
2.35.3
RFC PATCH v3 7/7 scsi: hisi_sas: Remove internal tag handling for reserved commands
In reply to John GarryNow that any sas_task which we're sent has a request associated, we can use the request tag for slot IPTT.
However, since v2 HW has its own slot IPTT allocation scheme due to badly broken HW, continue to use it.
--- drivers/scsi/hisi_sas/hisi_sas.h | 3 - drivers/scsi/hisi_sas/hisi_sas_main.c | 82 +++++--------------------- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 9 +-- 3 files changed, 17 insertions(+), 77 deletions(-)
drivers/scsi/hisi_sas/hisi_sas.h +0 -3
@@ -39,9 +39,6 @@#define HISI_SAS_PM_BIT 2#define HISI_SAS_HW_FAULT_BIT 3#define HISI_SAS_MAX_COMMANDS (HISI_SAS_QUEUE_SLOTS) -#define HISI_SAS_RESERVED_IPTT 96 -#define HISI_SAS_UNRESERVED_IPTT \ - (HISI_SAS_MAX_COMMANDS - HISI_SAS_RESERVED_IPTT)#define HISI_SAS_IOST_ITCT_CACHE_NUM 64#define HISI_SAS_IOST_ITCT_CACHE_DW_SZ 10
drivers/scsi/hisi_sas/hisi_sas_main.c +14 -68
121 lines not on this page · raw message
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +3 -6
@@ -4862,12 +4862,9 @@ hisi_sas_v3_probe(struct pci_dev *pdev, const struct pci_device_id *id) shost->max_lun = ~0 ; shost->max_channel =1 ; shost->max_cmd_len =16 ; -/* -* Intentionally use HISI_SAS_UNRESERVED_IPTT for .can_queue until -* every sas_task we're sent has a request associated. -*/ - shost->can_queue =HISI_SAS_UNRESERVED_IPTT ; - shost->cmd_per_lun =HISI_SAS_UNRESERVED_IPTT ; + + shost->can_queue =HISI_SAS_MAX_COMMANDS ; + shost->cmd_per_lun =HISI_SAS_MAX_COMMANDS ; sha->sas_ha_name =DRV_NAME ; sha->dev = dev;
Signature · 1 line
2.35.3