--- zzzz-none-000/linux-3.10.107/include/scsi/scsi_host.h 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/include/scsi/scsi_host.h 2021-02-04 17:41:59.000000000 +0000 @@ -7,6 +7,7 @@ #include #include #include +#include #include struct request_queue; @@ -15,6 +16,7 @@ struct module; struct scsi_cmnd; struct scsi_device; +struct scsi_host_cmd_pool; struct scsi_target; struct Scsi_Host; struct scsi_host_cmd_pool; @@ -44,12 +46,6 @@ #define DISABLE_CLUSTERING 0 #define ENABLE_CLUSTERING 1 -enum { - SCSI_QDEPTH_DEFAULT, /* default requested change, e.g. from sysfs */ - SCSI_QDEPTH_QFULL, /* scsi-ml requested due to queue full */ - SCSI_QDEPTH_RAMP_UP, /* scsi-ml requested due to threshold event */ -}; - struct scsi_host_template { struct module *module; const char *name; @@ -131,27 +127,6 @@ int (* queuecommand)(struct Scsi_Host *, struct scsi_cmnd *); /* - * The transfer functions are used to queue a scsi command to - * the LLD. When the driver is finished processing the command - * the done callback is invoked. - * - * This is called to inform the LLD to transfer - * scsi_bufflen(cmd) bytes. scsi_sg_count(cmd) speciefies the - * number of scatterlist entried in the command and - * scsi_sglist(cmd) returns the scatterlist. - * - * return values: see queuecommand - * - * If the LLD accepts the cmd, it should set the result to an - * appropriate value when completed before calling the done function. - * - * STATUS: REQUIRED FOR TARGET DRIVERS - */ - /* TODO: rename */ - int (* transfer_response)(struct scsi_cmnd *, - void (*done)(struct scsi_cmnd *)); - - /* * This is an error handling strategy routine. You don't need to * define one of these if you don't want to - there is a default * routine that is present that should work in most cases. For those @@ -214,7 +189,7 @@ * Things currently recommended to be handled at this time include: * * 1. Setting the device queue depth. Proper setting of this is - * described in the comments for scsi_adjust_queue_depth. + * described in the comments for scsi_change_queue_depth. * 2. Determining if the device supports the various synchronous * negotiation protocols. The device struct will already have * responded to INQUIRY and the results of the standard items @@ -300,20 +275,7 @@ * * Status: OPTIONAL */ - int (* change_queue_depth)(struct scsi_device *, int, int); - - /* - * Fill in this function to allow the changing of tag types - * (this also allows the enabling/disabling of tag command - * queueing). An error should only be returned if something - * went wrong in the driver while trying to set the tag type. - * If the driver doesn't support the requested tag type, then - * it should set the closest type it does support without - * returning an error. Returns the actual tag type set. - * - * Status: OPTIONAL - */ - int (* change_queue_type)(struct scsi_device *, int); + int (* change_queue_depth)(struct scsi_device *, int); /* * This function determines the BIOS parameters for a given @@ -407,7 +369,7 @@ /* * Set this if the host adapter has limitations beside segment count. */ - unsigned short max_sectors; + unsigned int max_sectors; /* * DMA scatter gather segment boundary limit. A segment crossing this @@ -440,6 +402,14 @@ */ unsigned char present; + /* If use block layer to manage tags, this is tag allocation policy */ + int tag_alloc_policy; + + /* + * Track QUEUE_FULL events and reduce queue depth on demand. + */ + unsigned track_queue_depth:1; + /* * This specifies the mode that a LLD supports. */ @@ -470,15 +440,15 @@ */ unsigned skip_settle_delay:1; - /* - * True if we are using ordered write support. - */ - unsigned ordered_tag:1; - /* True if the controller does not support WRITE SAME */ unsigned no_write_same:1; /* + * True if asynchronous aborts are not supported + */ + unsigned no_async_abort:1; + + /* * Countdown for host blocking with no commands outstanding. */ unsigned int max_host_blocked; @@ -519,6 +489,15 @@ * scsi_netlink.h */ u64 vendor_id; + + /* + * Additional per-command data allocated for the driver. + */ + unsigned int cmd_size; + struct scsi_host_cmd_pool *cmd_pool; + + /* temporary flag to disable blk-mq I/O path */ + bool disable_blk_mq; }; /* @@ -560,7 +539,7 @@ * __devices is protected by the host_lock, but you should * usually use scsi_device_lookup / shost_for_each_device * to access it and don't care about locking yourself. - * In the rare case of beeing in irq context you can use + * In the rare case of being in irq context you can use * their __ prefixed variants with the lock held. NEVER * access this list directly from a driver. */ @@ -589,30 +568,34 @@ * Area to keep a shared tag map (if needed, will be * NULL if not). */ - struct blk_queue_tag *bqt; + union { + struct blk_queue_tag *bqt; + struct blk_mq_tag_set tag_set; + }; - /* - * The following two fields are protected with host_lock; - * however, eh routines can safely access during eh processing - * without acquiring the lock. - */ - unsigned int host_busy; /* commands actually active on low-level */ - unsigned int host_failed; /* commands that failed. */ + atomic_t host_busy; /* commands actually active on low-level */ + atomic_t host_blocked; + + unsigned int host_failed; /* commands that failed. + protected by host_lock */ unsigned int host_eh_scheduled; /* EH scheduled without command */ unsigned int host_no; /* Used for IOCTL_GET_IDLUN, /proc/scsi et al. */ - int resetting; /* if set, it means that last_reset is a valid value */ + + /* next two fields are used to bound the time spent in error handling */ + int eh_deadline; unsigned long last_reset; + /* * These three parameters can be used to allow for wide scsi, * and for host adapters that support multiple busses - * The first two should be set to 1 more than the actual max id - * or lun (i.e. 8 for normal systems). + * The last two should be set to 1 more than the actual max id + * or lun (e.g. 8 for SCSI parallel systems). */ - unsigned int max_id; - unsigned int max_lun; unsigned int max_channel; + unsigned int max_id; + u64 max_lun; /* * This is a unique identifier that must be assigned so that we @@ -637,8 +620,16 @@ short cmd_per_lun; short unsigned int sg_tablesize; short unsigned int sg_prot_tablesize; - short unsigned int max_sectors; + unsigned int max_sectors; unsigned long dma_boundary; + /* + * In scsi-mq mode, the number of hardware queues supported by the LLD. + * + * Note: it is assumed that each hardware queue has a queue depth of + * can_queue. In other words, the total queue depth per host + * is nr_hw_queues * can_queue. + */ + unsigned nr_hw_queues; /* * Used to assign serial numbers to the cmds. * Protected by the host lock. @@ -648,7 +639,6 @@ unsigned active_mode:2; unsigned unchecked_isa_dma:1; unsigned use_clustering:1; - unsigned use_blk_tcq:1; /* * Host has requested that no further requests come through for the @@ -663,11 +653,6 @@ */ unsigned reverse_ordering:1; - /* - * Ordered write support - */ - unsigned ordered_tag:1; - /* Task mgmt function in progress */ unsigned tmf_in_progress:1; @@ -680,6 +665,12 @@ /* The controller does not support WRITE SAME */ unsigned no_write_same:1; + unsigned use_blk_mq:1; + unsigned use_cmd_list:1; + + /* Host responded with short (<36 bytes) INQUIRY result */ + unsigned short_inquiry:1; + /* * Optional work queue to be utilized by the transport */ @@ -687,9 +678,12 @@ struct workqueue_struct *work_q; /* - * Host has rejected a command because it was busy. + * Task management function work queue */ - unsigned int host_blocked; + struct workqueue_struct *tmf_work_q; + + /* The transport requires the LUN bits NOT to be stored in CDB[1] */ + unsigned no_scsi2_lun_in_cdb:1; /* * Value host_blocked counts down from @@ -780,6 +774,13 @@ shost->tmf_in_progress; } +extern bool scsi_use_blk_mq; + +static inline bool shost_use_blk_mq(struct Scsi_Host *shost) +{ + return shost->use_blk_mq; +} + extern int scsi_queue_work(struct Scsi_Host *, struct work_struct *); extern void scsi_flush_work(struct Scsi_Host *); @@ -796,8 +797,6 @@ extern const char *scsi_host_state_name(enum scsi_host_state); extern void scsi_cmd_get_serial(struct Scsi_Host *, struct scsi_cmnd *); -extern u64 scsi_calculate_bounce_limit(struct Scsi_Host *); - static inline int __must_check scsi_add_host(struct Scsi_Host *host, struct device *dev) {