Commit graph

982237 commits

Author SHA1 Message Date
Ahmed S. Darwish
3f901c81df scsi: libsas: docs: Remove notify_ha_event()
The ->notify_ha_event() hook has long been removed from the libsas event
interface.

Remove it from documentation.

Link: https://lore.kernel.org/r/20210118100955.1761652-2-a.darwish@linutronix.de
Fixes: 042ebd293b ("scsi: libsas: kill useless ha_event and do some cleanup")
Cc: stable@vger.kernel.org
Reviewed-by: John Garry <john.garry@huawei.com>
Reviewed-by: Jack Wang <jinpu.wang@cloud.ionos.com>
Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:31:07 -05:00
Hannes Reinecke
491152c7c3 scsi: ncr53c8xx: Use SAM status values
Use SAM status values instead of the driver-defined ones.  This also fixes
a potential bug as the driver-defined values declare 'COMMAND TERMINATED'
with a value of 0x20, whereas SCSI-II defines it with a value of 0x22.

Link: https://lore.kernel.org/r/20210113090500.129644-36-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:14:12 -05:00
Hannes Reinecke
aced5500ec scsi: advansys: Kill driver-defined status byte accessors
Replace the driver-defined status byte accessors with the mid-layer defined
ones.

Link: https://lore.kernel.org/r/20210113090500.129644-35-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:14:12 -05:00
Hannes Reinecke
6098c3005d scsi: qla2xxx: fc_remote_port_chkready() returns a SCSI result value
fc_remote_port_chkready() returns a SCSI result value, not the port
status. Fix the value returned when the remote port isn't set.

Link: https://lore.kernel.org/r/20210113090500.129644-34-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:14:12 -05:00
Hannes Reinecke
ecc751b27a scsi: storvsc: Return DID_ERROR for invalid commands
ILLEGAL_COMMAND is a sense code, not a driver byte.

Link: https://lore.kernel.org/r/20210113090500.129644-33-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:14:12 -05:00
Hannes Reinecke
88188179f3 scsi: ips: Use correct command completion on error
A non-zero queuecommand() return code means 'busy', i.e. the command hasn't
been submitted. So any command which should be failed need to be completed
via the ->scsi_done() callback with the appropriate result code set.

Link: https://lore.kernel.org/r/20210113090500.129644-32-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:14:12 -05:00
Hannes Reinecke
fc8e006c38 scsi: wd33c93: Use SCSI status
Use standard SCSI status and drop usage of the linux-specific ones.

Link: https://lore.kernel.org/r/20210113090500.129644-31-hare@suse.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:14:12 -05:00
Hannes Reinecke
809dadb15a scsi: esp_scsi: Do not set SCSI message byte
The message byte setting always devolves to COMMAND_COMPLETE so we can drop
setting the message byte in the SCSI result.

Link: https://lore.kernel.org/r/20210113090500.129644-30-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:14:11 -05:00
Hannes Reinecke
6b50529e2f scsi: esp_scsi: Use host byte as last argument to esp_cmd_is_done()
Just pass in the host byte to esp_cmd_is_done() and set the status or
message bytes if the host byte is DID_OK.

Link: https://lore.kernel.org/r/20210113090500.129644-29-hare@suse.de
Acked-by: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:14:11 -05:00
Hannes Reinecke
d37932a916 scsi: core: Add 'set_status_byte()' accessor
Add the missing 'set_status_byte()' accessor function.

Link: https://lore.kernel.org/r/20210113090500.129644-28-hare@suse.de
Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:14:11 -05:00
Hannes Reinecke
78c9efdd8d scsi: dpt_i2o: Use DID_ERROR instead of INITIATOR_ERROR message
Change the error code for an invalid SCSI opcode to DID_ERROR.
INITIATOR_ERROR is a scsi parallel message which doesn't apply for RAID
HBAs.

Link: https://lore.kernel.org/r/20210113090500.129644-27-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:14:11 -05:00
Hannes Reinecke
ddb99b1d1d scsi: mac53c94: Do not set invalid command result
CMD_ACCEPT_MSG is an internal definition and most certainly not a SCSI
status. As the latter gets set during command completion we can drop the
assignment here.

Link: https://lore.kernel.org/r/20210113090500.129644-26-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:14:11 -05:00
Hannes Reinecke
f3272258d7 scsi: atp870u: Use standard definitions
Use standard definitions for SCSI commands and return status instead of the
hardcoded values.

Link: https://lore.kernel.org/r/20210113090500.129644-25-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:14:11 -05:00
Hannes Reinecke
db83d8a5c8 scsi: ufs: ufshcd: Do not set COMMAND_COMPLETE
COMMAND_COMPLETE is defined as '0', so setting it is quite pointless.

Link: https://lore.kernel.org/r/20210113090500.129644-24-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:14:11 -05:00
Hannes Reinecke
7a64c81448 scsi: scsi_debug: Do not set COMMAND_COMPLETE
COMMAND_COMPLETE is defined as '0', so setting it is quite pointless.

Link: https://lore.kernel.org/r/20210113090500.129644-23-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Acked-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:14:10 -05:00
Hannes Reinecke
9df17f4679 scsi: initio: Drop internal SCSI message definition
Use the standard SCSI message definitions instead of the driver-internal
ones.

Link: https://lore.kernel.org/r/20210113090500.129644-22-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:14:10 -05:00
Hannes Reinecke
9c2d267073 scsi: dc395x: Drop internal SCSI message definitions
Drop the internal SCSI message definitions and use the functions provided
by the SPI transport class.

Link: https://lore.kernel.org/r/20210113090500.129644-21-hare@suse.de
Reported-by: kernel test robot <lkp@intel.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:14:10 -05:00
Hannes Reinecke
d8cd784ff7 scsi: aic7xxx: aic79xx: Drop internal SCSI message definition
Use the standard SCSI message definitions instead of the driver-internal
ones.

Link: https://lore.kernel.org/r/20210113090500.129644-20-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:14:10 -05:00
Hannes Reinecke
1c9eb798d5 scsi: nsp_cs: Drop internal SCSI message definition
Use the standard SCSI message definitions instead of the driver-internal
ones.

Link: https://lore.kernel.org/r/20210113090500.129644-19-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:14:10 -05:00
Hannes Reinecke
8959e81cf4 scsi: stex: Do not set COMMAND_COMPLETE
COMMAND_COMPLETE is defined as '0', so setting it is quite pointless.

Link: https://lore.kernel.org/r/20210113090500.129644-18-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:14:10 -05:00
Hannes Reinecke
0e310ac4ef scsi: hpsa: Do not set COMMAND_COMPLETE
COMMAND_COMPLETE is defined as '0', and it is a SCSI parallel message to
boot. Drop the call to set_msg_byte().

Link: https://lore.kernel.org/r/20210113090500.129644-17-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Acked-by: Don Brace <don.brace@microchip.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:14:09 -05:00
Hannes Reinecke
cdec16c117 scsi: aacraid: Avoid setting message byte on completion
The aacraid controller is a RAID controller and the driver will never see
any SCSI messages. Plus it's quite pointless to set the message byte if the
host byte is already set, as the latter takes precedence during error
recovery.  Drop the message byte values for the final result.

Link: https://lore.kernel.org/r/20210113090500.129644-16-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:14:09 -05:00
Hannes Reinecke
3273c91bbd scsi: zfcp: Do not set COMMAND_COMPLETE
COMMAND_COMPLETE is defined as '0', and it is a SCSI parallel message to
boot. So drop the call to set_msg_byte().

Link: https://lore.kernel.org/r/20210113090500.129644-15-hare@suse.de
Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:14:09 -05:00
Hannes Reinecke
35f1cad1f9 scsi: qla4xxx: Use standard SAM status definitions
Use standard SAM status definitions and drop the driver-defined ones.

Link: https://lore.kernel.org/r/20210113090500.129644-14-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:14:09 -05:00
Hannes Reinecke
f55475891e scsi: dc395: Drop private SAM status code definitions
We don't need to duplicate definitions from the common include files.

Link: https://lore.kernel.org/r/20210113090500.129644-13-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:14:09 -05:00
Hannes Reinecke
23d339f08f scsi: nsp32: Fixup status handling
SCp.status is always the SAM-defined status value, not the Linux
ones. Fixup the one wrong definition.

Link: https://lore.kernel.org/r/20210113090500.129644-12-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:14:09 -05:00
Hannes Reinecke
0eb198d2c3 scsi: acornscsi: Use standard defines
Use midlayer-defined values and drop the non-existing QUEUE_FULL case; we
are checking the SCSI messages in the switch statement, and QUEUE_FULL is a
SCSI status hence it can never occur here.

Link: https://lore.kernel.org/r/20210113090500.129644-11-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:14:09 -05:00
Hannes Reinecke
eb74b9322b scsi: bfa: Drop driver-defined SCSI status codes
Drop the driver-defined SCSI status codes and use the generic ones instead.

Link: https://lore.kernel.org/r/20210113090500.129644-10-hare@suse.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:14:08 -05:00
Hannes Reinecke
54c9f6fdef scsi: aic7xxx: aic79xx: Remove driver-defined SAM status definitions
Replace the driver-defined SAM status definitions with the standard
mid-layer defined ones.

Link: https://lore.kernel.org/r/20210113090500.129644-9-hare@suse.de
Reviewed-by: Bart van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:14:08 -05:00
Hannes Reinecke
c23435dbc7 scsi: aic7xxx: aic79xx: Kill pointless forward declarations
Link: https://lore.kernel.org/r/20210113090500.129644-8-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:14:08 -05:00
Hannes Reinecke
7662d92374 scsi: aic7xxx: aic79xx: Whitespace cleanup
Link: https://lore.kernel.org/r/20210113090500.129644-7-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:14:08 -05:00
Hannes Reinecke
bcd5c59f21 scsi: atp870u: Whitespace cleanup
Link: https://lore.kernel.org/r/20210113090500.129644-6-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:14:08 -05:00
Hannes Reinecke
1789671ded scsi: 3w-sas: Whitespace cleanup
Link: https://lore.kernel.org/r/20210113090500.129644-5-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:14:08 -05:00
Hannes Reinecke
bf4eebbf53 scsi: 3w-9xxx: Whitespace cleanup
Link: https://lore.kernel.org/r/20210113090500.129644-4-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:14:07 -05:00
Hannes Reinecke
8148dfba29 scsi: 3w-xxxx: Whitespace cleanup
Link: https://lore.kernel.org/r/20210113090500.129644-3-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:14:07 -05:00
Hannes Reinecke
0653c358d2 scsi: Drop gdth driver
The gdth driver refers to a SCSI parallel, PCI-only HBA RAID adapter which
was manufactured by the now-defunct ICP Vortex company, later acquired by
Adaptec and superseded by the aacraid series of controllers.  The driver
itself would require a major overhaul before any modifications can be
attempted, but seeing that it's unlikely to have any users left it should
rather be removed completely.

Link: https://lore.kernel.org/r/20210113090500.129644-2-hare@suse.de
Cautiously-Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 21:14:07 -05:00
Ahmed S. Darwish
bbb087679d scsi: target: core: Remove in_interrupt() check in transport_handle_cdb_direct()
transport_handle_cdb_direct() uses in_interrupt() to detect if it is safe
to sleep. It produces a stack trace and returns with an error which is
clearly for debugging.

The usage of in_interrupt() in drivers is phased out and Linus clearly
requested that code which changes behaviour depending on context should
either be separated or the context be conveyed in an argument passed by the
caller, which usually knows the context.

transport_handle_cdb_direct() has a comment saying that it may only be
invoked from process context. It invokes transport_generic_new_cmd() which
performs GFP_KERNEL memory allocations. in_interrupt() does not detect all
the contexts where it is invalid to sleep (for the blocking GFP_KERNEL
allocation) as it fails to detect sections with disabled preemption.

Replace the in_interrupt() based check with a might_sleep() annotation.

Link: https://lore.kernel.org/r/20201220203638.43615-7-bigeasy@linutronix.de
Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 20:25:25 -05:00
Sebastian Andrzej Siewior
513e29946a scsi: target: core: Replace in_interrupt() usage in target_submit_cmd_map_sgls()
target_submit_cmd_map_sgls() uses in_interrupt() to crash if it returns
true.

The usage of in_interrupt() in drivers is phased out and Linus clearly
requested that code which changes behaviour depending on context should
either be separated or the context be conveyed in an argument passed by the
caller, which usually knows the context.

The usage of in_interrupt() is clearly for debugging. might_sleep() is
better at this because it also detects other contexts in which it is not
allowed to sleep, like preempt-disabled section.

Replace BUG_ON(in_interrupt) with might_sleep().

Link: https://lore.kernel.org/r/20201220203638.43615-6-bigeasy@linutronix.de
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 20:25:25 -05:00
Sebastian Andrzej Siewior
a97451ac1e scsi: target: alua: Remove in_interrupt() usage in core_alua_check_nonop_delay()
core_alua_check_nonop_delay() uses in_interrupt() to decide if it is safe
to sleep.

The usage of in_interrupt() in drivers is phased out and Linus clearly
requested that code which changes behaviour depending on context should
either be separated or the context be conveyed in an argument passed by the
caller, which usually knows the context.

core_alua_check_nonop_delay() has two callers:

 - target_submit_cmd_map_sgls()
   Kernel doc says it that it must be called from process context. Also has
   a BUG_ON(in_interrupt()).

 - iscsit_setup_scsi_cmd()
   Invokes iscsit_add_reject_cmd() which does GFP_KERNEL allocation and
   target_cmd_init_cdb() which may do GFP_KERNEL allocations.

Remove the in_interrupt() check because all callers are from preemptible
context.

Link: https://lore.kernel.org/r/20201220203638.43615-5-bigeasy@linutronix.de
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 20:25:25 -05:00
Sebastian Andrzej Siewior
f88a10f80d scsi: target: iscsi: Redo iscsit_check_session_usage_count() return code
The return value of iscsit_check_session_usage_count() is only checked if
it was not allowed to sleep. If it returns `2' then a timer is prepared. If
it returns something else or if it was allowed to sleep then it is ignored.

Let iscsit_check_session_usage_count() return true if it needs to arm the
timer - otherwise false. This simplifies the code flow of the only caller.

Link: https://lore.kernel.org/r/20201220203638.43615-4-bigeasy@linutronix.de
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 20:25:25 -05:00
Sebastian Andrzej Siewior
efc9d73063 scsi: target: iscsi: Avoid in_interrupt() usage in iscsit_check_session_usage_count()
iscsit_check_session_usage_count() uses in_interrupt() to find out if it is
safe to invoke wait_for_completion().

The usage of in_interrupt() in drivers is phased out and Linus clearly
requested that code which changes behaviour depending on context should
either be separated or the context be conveyed in an argument passed by the
caller, which usually knows the context.

There is only one caller of iscsit_check_session_usage_count() which
already has an argument indicating if it is safe to sleep.

Extend iscsit_check_session_usage_count() by an argument indicating if it
may sleep.

Link: https://lore.kernel.org/r/20201220203638.43615-3-bigeasy@linutronix.de
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 20:25:25 -05:00
Sebastian Andrzej Siewior
433675486a scsi: target: iscsi: Avoid in_interrupt() usage in iscsit_close_session()
iscsit_close_session() uses in_interrupt() to decide if it needs to check
the return value of iscsit_check_session_usage_count() if it was not able
to sleep.

The usage of in_interrupt() in drivers is phased out and Linus clearly
requested that code which changes behaviour depending on context should
either be separated or the context be conveyed in an argument passed by the
caller, which usually knows the context.

iscsit_close_session() has two callers:

 - iscsit_handle_time2retain_timeout()
   A timer_list callback.

 - iscsit_close_connection()
   Runs in preemptible context, acquires a mutex.

Add an argument to iscsit_close_session() indicating if sleeping is
possible.

Link: https://lore.kernel.org/r/20201220203638.43615-2-bigeasy@linutronix.de
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-22 20:25:25 -05:00
Stanley Chu
348e1bc5f4 scsi: ufs: Clean up and refactor clk-scaling feature
Manipulate clock scaling related stuff only if the host capability supports
clock scaling feature to avoid redundant code execution.

Link: https://lore.kernel.org/r/20210120150142.5049-4-stanley.chu@mediatek.com
Reviewed-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-20 22:29:38 -05:00
Stanley Chu
b058fa8682 scsi: ufs: Remove redundant null checking of devfreq instance
hba->devfreq is zero-initialized thus it is not required to check its
existence in ufshcd_add_lus() function which is invoked during
initialization only.

Link: https://lore.kernel.org/r/20210120150142.5049-3-stanley.chu@mediatek.com
Reviewed-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-20 22:29:38 -05:00
Stanley Chu
f9a7fa345a scsi: ufs: Refactor cancelling clkscaling works
Cancelling suspend_work and resume_work is only required while suspending
clk-scaling. Move these two invocations into ufshcd_suspend_clkscaling()
function.

Link: https://lore.kernel.org/r/20210120150142.5049-2-stanley.chu@mediatek.com
Reviewed-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-20 22:29:37 -05:00
Can Guo
b02d51afca Revert "Make sure clk scaling happens only when HBA is runtime ACTIVE"
Commit 73cc291c27 ("scsi: ufs: Make sure clk scaling happens only
when HBA is runtime ACTIVE") is no longer needed since commit
0e9d4ca43b ("scsi: ufs: Protect some contexts from unexpected clock
scaling") is a more mature fix to protect UFS LLD stability from clock
scaling invoked through sysfs nodes by users.

Link: https://lore.kernel.org/r/1611137065-14266-4-git-send-email-cang@codeaurora.org
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-20 22:23:56 -05:00
Can Guo
4543d9d782 scsi: ufs: Refactor ufshcd_init/exit_clk_scaling/gating()
ufshcd_hba_exit() is always called after ufshcd_exit_clk_scaling() and
ufshcd_exit_clk_gating(). Move ufshcd_exit_clk_scaling/gating() to
ufshcd_hba_exit(). Meanwhile, add dedicated functions to initialize
and remove sysfs nodes of clock scaling/gating to make the code more
readable. Overall functionality remains same.

Link: https://lore.kernel.org/r/1611137065-14266-3-git-send-email-cang@codeaurora.org
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-20 22:23:23 -05:00
Can Guo
0e9d4ca43b scsi: ufs: Protect some contexts from unexpected clock scaling
In contexts like suspend, shutdown, and error handling we need to
suspend devfreq to make sure these contexts won't be disturbed by
clock scaling.  However, suspending devfreq is not enough since users
can still trigger a clock scaling by manipulating the devfreq sysfs
nodes like min/max_freq and governor even after devfreq is
suspended. Moreover, mere suspending devfreq cannot synchroinze a
clock scaling which has already been invoked through these sysfs
nodes. Add one more flag in struct clk_scaling and wrap the entire
func ufshcd_devfreq_scale() with the clk_scaling_lock, so that we can
use this flag and clk_scaling_lock to control and synchronize clock
scaling invoked through devfreq sysfs nodes.

Link: https://lore.kernel.org/r/1611137065-14266-2-git-send-email-cang@codeaurora.org
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-20 22:22:02 -05:00
Bean Huo
4cd4899564 scsi: ufs: Group UFS WB related flags in struct ufs_dev_info
UFS device-related flags should be grouped in ufs_dev_info. Move wb_enabled
and wb_buf_flush_enabled out from struct ufs_hba, group them in struct
ufs_dev_info, and align the names of the structure members vertically.

Link: https://lore.kernel.org/r/20210119163847.20165-6-huobean@gmail.com
Reviewed-by: Can Guo <cang@codeaurora.org>
Acked-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-20 22:21:38 -05:00
Bean Huo
e8d0381394 scsi: ufs: Remove two WB related fields from struct ufs_dev_info
d_wb_alloc_units and d_ext_ufs_feature_sup are only used during WB probe.
They are used to confirm the condition that "if bWriteBoosterBufferType
is set to 01h but dNumSharedWriteBoosterBufferAllocUnits is set to zero,
the WriteBooster feature is disabled", and if UFS device supports WB.

No need to keep them after probing is complete.

Link: https://lore.kernel.org/r/20210119163847.20165-5-huobean@gmail.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-20 22:12:30 -05:00