refs/heads/tmp-28ec98b: Linux 4.4.55 ext4: don't BUG when truncating encrypted inodes on the orphan list dm: flush queued bios when process blocks to avoid deadlock nfit, libnvdimm: fix interleave set cookie calculation s390/kdump: Use "LINUX" ELF note name instead of "CORE" KVM: s390: Fix guest migration for huge guests resulting in panic mvsas: fix misleading indentation serial: samsung: Continue to work if DMA request fails USB: serial: io_ti: fix information leak in completion handler USB: serial: io_ti: fix NULL-deref in interrupt callback USB: iowarrior: fix NULL-deref in write USB: iowarrior: fix NULL-deref at probe USB: serial: omninet: fix reference leaks at open USB: serial: safe_serial: fix information leak in completion handler usb: host: xhci-plat: Fix timeout on removal of hot pluggable xhci controllers usb: host: xhci-dbg: HCIVERSION should be a binary number usb: gadget: function: f_fs: pass companion descriptor along usb: dwc3: gadget: make Set Endpoint Configuration macros safe usb: gadget: dummy_hcd: clear usb_gadget region before registration powerpc: Emulation support for load/store instructions on LE tracing: Add #undef to fix compile error MIPS: Netlogic: Fix CP0_EBASE redefinition warnings MIPS: DEC: Avoid la pseudo-instruction in delay slots mm: memcontrol: avoid unused function warning cpmac: remove hopeless #warning MIPS: ralink: Remove unused rt*_wdt_reset functions MIPS: ralink: Cosmetic change to prom_init(). mtd: pmcmsp: use kstrndup instead of kmalloc+strncpy MIPS: Update lemote2f_defconfig for CPU_FREQ_STAT change MIPS: ip22: Fix ip28 build for modern gcc MIPS: Update ip27_defconfig for SCSI_DH change MIPS: ip27: Disable qlge driver in defconfig MIPS: Update defconfigs for NF_CT_PROTO_DCCP/UDPLITE change crypto: improve gcc optimization flags for serpent and wp512 USB: serial: digi_acceleport: fix OOB-event processing USB: serial: digi_acceleport: fix OOB data sanity check Linux 4.4.54 drivers: hv: Turn off write permission on the hypercall page fat: fix using uninitialized fields of fat_inode/fsinfo_inode libceph: use BUG() instead of BUG_ON(1) drm/i915/dsi: Do not clear DPOUNIT_CLOCK_GATE_DISABLE from vlv_init_display_clock_gating fakelb: fix schedule while atomic drm/atomic: fix an error code in mode_fixup() drm/ttm: Make sure BOs being swapped out are cacheable drm/edid: Add EDID_QUIRK_FORCE_8BPC quirk for Rotel RSX-1058 drm/ast: Fix AST2400 POST failure without BMC FW or VBIOS drm/ast: Call open_key before enable_mmio in POST code drm/ast: Fix test for VGA enabled drm/amdgpu: add more cases to DCE11 possible crtc mask setup mac80211: flush delayed work when entering suspend xtensa: move parse_tag_fdt out of #ifdef CONFIG_BLK_DEV_INITRD pwm: pca9685: Fix period change with same duty cycle nlm: Ensure callback code also checks that the files match target: Fix NULL dereference during LUN lookup + active I/O shutdown ceph: remove req from unsafe list when unregistering it ktest: Fix child exit code processing IB/srp: Fix race conditions related to task management IB/srp: Avoid that duplicate responses trigger a kernel bug IB/IPoIB: Add destination address when re-queue packet IB/ipoib: Fix deadlock between rmmod and set_mode mnt: Tuck mounts under others instead of creating shadow/side mounts. net: mvpp2: fix DMA address calculation in mvpp2_txq_inc_put() s390: use correct input data address for setup_randomness s390: make setup_randomness work s390: TASK_SIZE for kernel threads s390/dcssblk: fix device size calculation in dcssblk_direct_access() s390/qdio: clear DSCI prior to scanning multiple input queues Bluetooth: Add another AR3012 04ca:3018 device KVM: VMX: use correct vmcs_read/write for guest segment selector/base KVM: s390: Disable dirty log retrieval for UCONTROL guests serial: 8250_pci: Add MKS Tenta SCOM-0800 and SCOM-0801 cards tty: n_hdlc: get rid of racy n_hdlc.tbuf TTY: n_hdlc, fix lockdep false positive Linux 4.4.53 scsi: lpfc: Correct WQ creation for pagesize MIPS: IP22: Fix build error due to binutils 2.25 uselessnes. MIPS: IP22: Reformat inline assembler code to modern standards. powerpc/xmon: Fix data-breakpoint dmaengine: ipu: Make sure the interrupt routine checks all interrupts. bcma: use (get|put)_device when probing/removing device driver md linear: fix a race between linear_add() and linear_congested() rtc: sun6i: Switch to the external oscillator rtc: sun6i: Add some locking NFSv4: fix getacl ERANGE for some ACL buffer sizes NFSv4: fix getacl head length estimation NFSv4: Fix memory and state leak in _nfs4_open_and_get_state nfsd: special case truncates some more nfsd: minor nfsd_setattr cleanup rtlwifi: rtl8192c-common: Fix "BUG: KASAN: rtlwifi: Fix alignment issues gfs2: Add missing rcu locking for glock lookup rdma_cm: fail iwarp accepts w/o connection params RDMA/core: Fix incorrect structure packing for booleans Drivers: hv: util: Backup: Fix a rescind processing issue Drivers: hv: util: Fcopy: Fix a rescind processing issue Drivers: hv: util: kvp: Fix a rescind processing issue hv: init percpu_list in hv_synic_alloc() hv: allocate synic pages for all present CPUs usb: gadget: udc: fsl: Add missing complete function. usb: host: xhci: plat: check hcc_params after add hcd usb: musb: da8xx: Remove CPPI 3.0 quirk and methods w1: ds2490: USB transfer buffers need to be DMAable w1: don't leak refcount on slave attach failure in w1_attach_slave_device() can: usb_8dev: Fix memory leak of priv->cmd_msg_buffer iio: pressure: mpl3115: do not rely on structure field ordering iio: pressure: mpl115: do not rely on structure field ordering arm/arm64: KVM: Enforce unconditional flush to PoC when mapping to stage-2 fuse: add missing FR_FORCE crypto: testmgr - Pad aes_ccm_enc_tv_template vector ath9k: use correct OTP register offsets for the AR9340 and AR9550 ath9k: fix race condition in enabling/disabling IRQs ath5k: drop bogus warning on drv_set_key with unsupported cipher target: Fix multi-session dynamic se_node_acl double free OOPs target: Obtain se_node_acl->acl_kref during get_initiator_node_acl samples/seccomp: fix 64-bit comparison macros ext4: return EROFS if device is r/o and journal replay is needed ext4: preserve the needs_recovery flag when the journal is aborted ext4: fix inline data error paths ext4: fix data corruption in data=journal mode ext4: trim allocation requests to group size ext4: do not polute the extents cache while shifting extents ext4: Include forgotten start block on fallocate insert range loop: fix LO_FLAGS_PARTSCAN hang block/loop: fix race between I/O and set_status jbd2: don't leak modified metadata buffers on an aborted journal Fix: Disable sys_membarrier when nohz_full is enabled sd: get disk reference in sd_check_events() scsi: use 'scsi_device_from_queue()' for scsi_dh scsi: aacraid: Reorder Adapter status check scsi: storvsc: properly set residual data length on errors scsi: storvsc: properly handle SRB_ERROR when sense message is present scsi: storvsc: use tagged SRB requests if supported by the device dm stats: fix a leaked s->histogram_boundaries array dm cache: fix corruption seen when using cache > 2TB ipc/shm: Fix shmat mmap nil-page protection mm: do not access page->mapping directly on page_endio mm: vmpressure: fix sending wrong events on underflow mm/page_alloc: fix nodes for reclaim in fast path iommu/vt-d: Tylersburg isoch identity map check is done too late. iommu/vt-d: Fix some macros that are incorrectly specified in intel-iommu regulator: Fix regulator_summary for deviceless consumers staging: rtl: fix possible NULL pointer dereference ALSA: hda - Fix micmute hotkey problem for a lenovo AIO machine ALSA: hda - Add subwoofer support for Dell Inspiron 17 7000 Gaming ALSA: seq: Fix link corruption by event error handling ALSA: ctxfi: Fallback DMA mask to 32bit ALSA: timer: Reject user params with too small ticks ALSA: hda - fix Lewisburg audio issue ALSA: hda/realtek - Cannot adjust speaker's volume on a Dell AIO ARM: dts: at91: Enable DMA on sama5d2_xplained console ARM: dts: at91: Enable DMA on sama5d4_xplained console ARM: at91: define LPDDR types media: fix dm1105.c build error uvcvideo: Fix a wrong macro am437x-vpfe: always assign bpp variable MIPS: Handle microMIPS jumps in the same way as MIPS32/MIPS64 jumps MIPS: Calculate microMIPS ra properly when unwinding the stack MIPS: Fix is_jump_ins() handling of 16b microMIPS instructions MIPS: Fix get_frame_info() handling of microMIPS function size MIPS: Prevent unaligned accesses during stack unwinding MIPS: Clear ISA bit correctly in get_frame_info() MIPS: Lantiq: Keep ethernet enabled during boot MIPS: OCTEON: Fix copy_from_user fault handling for large buffers MIPS: BCM47XX: Fix button inversion for Asus WL-500W MIPS: Fix special case in 64 bit IP checksumming. samples: move mic/mpssd example code from Documentation Linux 4.4.52 kvm: vmx: ensure VMCS is current while enabling PML Revert "usb: chipidea: imx: enable CI_HDRC_SET_NON_ZERO_TTHA" rtlwifi: rtl_usb: Fix for URB leaking when doing ifconfig up/down block: fix double-free in the failure path of cgwb_bdi_init() goldfish: Sanitize the broken interrupt handler x86/platform/goldfish: Prevent unconditional loading USB: serial: ark3116: fix register-accessor error handling USB: serial: opticon: fix CTS retrieval at open USB: serial: spcp8x5: fix modem-status handling USB: serial: ftdi_sio: fix line-status over-reporting USB: serial: ftdi_sio: fix extreme low-latency setting USB: serial: ftdi_sio: fix modem-status error handling USB: serial: cp210x: add new IDs for GE Bx50v3 boards USB: serial: mos7840: fix another NULL-deref at open tty: serial: msm: Fix module autoload net: socket: fix recvmmsg not returning error from sock_error ip: fix IP_CHECKSUM handling irda: Fix lockdep annotations in hashbin_delete(). dccp: fix freeing skb too early for IPV6_RECVPKTINFO packet: Do not call fanout_release from atomic contexts packet: fix races in fanout_add() net/llc: avoid BUG_ON() in skb_orphan() blk-mq: really fix plug list flushing for nomerge queues rtc: interface: ignore expired timers when enqueuing new timers rtlwifi: rtl_usb: Fix missing entry in USB driver's private data Linux 4.4.51 mmc: core: fix multi-bit bus width without high-speed mode bcache: Make gc wakeup sane, remove set_task_state() ntb_transport: Pick an unused queue NTB: ntb_transport: fix debugfs_remove_recursive printk: use rcuidle console tracepoint ARM: 8658/1: uaccess: fix zeroing of 64-bit get_user() futex: Move futex_init() to core_initcall drm/dp/mst: fix kernel oops when turning off secondary monitor drm/radeon: Use mode h/vdisplay fields to hide out of bounds HW cursor Input: elan_i2c - add ELAN0605 to the ACPI table Fix missing sanity check in /dev/sg scsi: don't BUG_ON() empty DMA transfers fuse: fix use after free issue in fuse_dev_do_read() siano: make it work again with CONFIG_VMAP_STACK vfs: fix uninitialized flags in splice_to_pipe() Linux 4.4.50 l2tp: do not use udp_ioctl() ping: fix a null pointer dereference packet: round up linear to header len net: introduce device min_header_len sit: fix a double free on error path sctp: avoid BUG_ON on sctp_wait_for_sndbuf mlx4: Invoke softirqs after napi_reschedule macvtap: read vnet_hdr_size once tun: read vnet_hdr_sz once tcp: avoid infinite loop in tcp_splice_read() ipv6: tcp: add a missing tcp_v6_restore_cb() ip6_gre: fix ip6gre_err() invalid reads netlabel: out of bound access in cipso_v4_validate() ipv4: keep skb->dst around in presence of IP options net: use a work queue to defer net_disable_timestamp() work tcp: fix 0 divide in __tcp_select_window() ipv6: pointer math error in ip6_tnl_parse_tlv_enc_lim() ipv6: fix ip6_tnl_parse_tlv_enc_lim() can: Fix kernel panic at security_sock_rcv_skb Conflicts: drivers/scsi/sd.c drivers/usb/gadget/function/f_fs.c drivers/usb/host/xhci-plat.c CRs-Fixed: 2023471 Change-Id: I396051a8de30271af77b3890d4b19787faa1c31e Signed-off-by: Blagovest Kolenichev <bkolenichev@codeaurora.org>
523 lines
19 KiB
C
523 lines
19 KiB
C
#ifndef _SCSI_SCSI_DEVICE_H
|
|
#define _SCSI_SCSI_DEVICE_H
|
|
|
|
#include <linux/list.h>
|
|
#include <linux/spinlock.h>
|
|
#include <linux/workqueue.h>
|
|
#include <linux/blkdev.h>
|
|
#include <scsi/scsi.h>
|
|
#include <linux/atomic.h>
|
|
|
|
struct device;
|
|
struct request_queue;
|
|
struct scsi_cmnd;
|
|
struct scsi_lun;
|
|
struct scsi_sense_hdr;
|
|
|
|
struct scsi_mode_data {
|
|
__u32 length;
|
|
__u16 block_descriptor_length;
|
|
__u8 medium_type;
|
|
__u8 device_specific;
|
|
__u8 header_length;
|
|
__u8 longlba:1;
|
|
};
|
|
|
|
/*
|
|
* sdev state: If you alter this, you also need to alter scsi_sysfs.c
|
|
* (for the ascii descriptions) and the state model enforcer:
|
|
* scsi_lib:scsi_device_set_state().
|
|
*/
|
|
enum scsi_device_state {
|
|
SDEV_CREATED = 1, /* device created but not added to sysfs
|
|
* Only internal commands allowed (for inq) */
|
|
SDEV_RUNNING, /* device properly configured
|
|
* All commands allowed */
|
|
SDEV_CANCEL, /* beginning to delete device
|
|
* Only error handler commands allowed */
|
|
SDEV_DEL, /* device deleted
|
|
* no commands allowed */
|
|
SDEV_QUIESCE, /* Device quiescent. No block commands
|
|
* will be accepted, only specials (which
|
|
* originate in the mid-layer) */
|
|
SDEV_OFFLINE, /* Device offlined (by error handling or
|
|
* user request */
|
|
SDEV_TRANSPORT_OFFLINE, /* Offlined by transport class error handler */
|
|
SDEV_BLOCK, /* Device blocked by scsi lld. No
|
|
* scsi commands from user or midlayer
|
|
* should be issued to the scsi
|
|
* lld. */
|
|
SDEV_CREATED_BLOCK, /* same as above but for created devices */
|
|
};
|
|
|
|
enum scsi_device_event {
|
|
SDEV_EVT_MEDIA_CHANGE = 1, /* media has changed */
|
|
SDEV_EVT_INQUIRY_CHANGE_REPORTED, /* 3F 03 UA reported */
|
|
SDEV_EVT_CAPACITY_CHANGE_REPORTED, /* 2A 09 UA reported */
|
|
SDEV_EVT_SOFT_THRESHOLD_REACHED_REPORTED, /* 38 07 UA reported */
|
|
SDEV_EVT_MODE_PARAMETER_CHANGE_REPORTED, /* 2A 01 UA reported */
|
|
SDEV_EVT_LUN_CHANGE_REPORTED, /* 3F 0E UA reported */
|
|
SDEV_EVT_ALUA_STATE_CHANGE_REPORTED, /* 2A 06 UA reported */
|
|
|
|
SDEV_EVT_FIRST = SDEV_EVT_MEDIA_CHANGE,
|
|
SDEV_EVT_LAST = SDEV_EVT_ALUA_STATE_CHANGE_REPORTED,
|
|
|
|
SDEV_EVT_MAXBITS = SDEV_EVT_LAST + 1
|
|
};
|
|
|
|
struct scsi_event {
|
|
enum scsi_device_event evt_type;
|
|
struct list_head node;
|
|
|
|
/* put union of data structures, for non-simple event types,
|
|
* here
|
|
*/
|
|
};
|
|
|
|
struct scsi_device {
|
|
struct Scsi_Host *host;
|
|
struct request_queue *request_queue;
|
|
|
|
/* the next two are protected by the host->host_lock */
|
|
struct list_head siblings; /* list of all devices on this host */
|
|
struct list_head same_target_siblings; /* just the devices sharing same target id */
|
|
|
|
atomic_t device_busy; /* commands actually active on LLDD */
|
|
atomic_t device_blocked; /* Device returned QUEUE_FULL. */
|
|
|
|
spinlock_t list_lock;
|
|
struct list_head cmd_list; /* queue of in use SCSI Command structures */
|
|
struct list_head starved_entry;
|
|
struct scsi_cmnd *current_cmnd; /* currently active command */
|
|
unsigned short queue_depth; /* How deep of a queue we want */
|
|
unsigned short max_queue_depth; /* max queue depth */
|
|
unsigned short last_queue_full_depth; /* These two are used by */
|
|
unsigned short last_queue_full_count; /* scsi_track_queue_full() */
|
|
unsigned long last_queue_full_time; /* last queue full time */
|
|
unsigned long queue_ramp_up_period; /* ramp up period in jiffies */
|
|
#define SCSI_DEFAULT_RAMP_UP_PERIOD (120 * HZ)
|
|
|
|
unsigned long last_queue_ramp_up; /* last queue ramp up time */
|
|
|
|
unsigned int id, channel;
|
|
u64 lun;
|
|
unsigned int manufacturer; /* Manufacturer of device, for using
|
|
* vendor-specific cmd's */
|
|
unsigned sector_size; /* size in bytes */
|
|
|
|
void *hostdata; /* available to low-level driver */
|
|
char type;
|
|
char scsi_level;
|
|
char inq_periph_qual; /* PQ from INQUIRY data */
|
|
unsigned char inquiry_len; /* valid bytes in 'inquiry' */
|
|
unsigned char * inquiry; /* INQUIRY response data */
|
|
const char * vendor; /* [back_compat] point into 'inquiry' ... */
|
|
const char * model; /* ... after scan; point to static string */
|
|
const char * rev; /* ... "nullnullnullnull" before scan */
|
|
|
|
#define SCSI_VPD_PG_LEN 255
|
|
int vpd_pg83_len;
|
|
unsigned char *vpd_pg83;
|
|
int vpd_pg80_len;
|
|
unsigned char *vpd_pg80;
|
|
unsigned char current_tag; /* current tag */
|
|
struct scsi_target *sdev_target; /* used only for single_lun */
|
|
|
|
unsigned int sdev_bflags; /* black/white flags as also found in
|
|
* scsi_devinfo.[hc]. For now used only to
|
|
* pass settings from slave_alloc to scsi
|
|
* core. */
|
|
unsigned int eh_timeout; /* Error handling timeout */
|
|
unsigned removable:1;
|
|
unsigned changed:1; /* Data invalid due to media change */
|
|
unsigned busy:1; /* Used to prevent races */
|
|
unsigned lockable:1; /* Able to prevent media removal */
|
|
unsigned locked:1; /* Media removal disabled */
|
|
unsigned borken:1; /* Tell the Seagate driver to be
|
|
* painfully slow on this device */
|
|
unsigned disconnect:1; /* can disconnect */
|
|
unsigned soft_reset:1; /* Uses soft reset option */
|
|
unsigned sdtr:1; /* Device supports SDTR messages */
|
|
unsigned wdtr:1; /* Device supports WDTR messages */
|
|
unsigned ppr:1; /* Device supports PPR messages */
|
|
unsigned tagged_supported:1; /* Supports SCSI-II tagged queuing */
|
|
unsigned simple_tags:1; /* simple queue tag messages are enabled */
|
|
unsigned was_reset:1; /* There was a bus reset on the bus for
|
|
* this device */
|
|
unsigned expecting_cc_ua:1; /* Expecting a CHECK_CONDITION/UNIT_ATTN
|
|
* because we did a bus reset. */
|
|
unsigned use_10_for_rw:1; /* first try 10-byte read / write */
|
|
unsigned use_10_for_ms:1; /* first try 10-byte mode sense/select */
|
|
unsigned no_report_opcodes:1; /* no REPORT SUPPORTED OPERATION CODES */
|
|
unsigned no_write_same:1; /* no WRITE SAME command */
|
|
unsigned use_16_for_rw:1; /* Use read/write(16) over read/write(10) */
|
|
unsigned skip_ms_page_8:1; /* do not use MODE SENSE page 0x08 */
|
|
unsigned skip_ms_page_3f:1; /* do not use MODE SENSE page 0x3f */
|
|
unsigned skip_vpd_pages:1; /* do not read VPD pages */
|
|
unsigned try_vpd_pages:1; /* attempt to read VPD pages */
|
|
unsigned use_192_bytes_for_3f:1; /* ask for 192 bytes from page 0x3f */
|
|
unsigned no_start_on_add:1; /* do not issue start on add */
|
|
unsigned allow_restart:1; /* issue START_UNIT in error handler */
|
|
unsigned manage_start_stop:1; /* Let HLD (sd) manage start/stop */
|
|
unsigned start_stop_pwr_cond:1; /* Set power cond. in START_STOP_UNIT */
|
|
unsigned no_uld_attach:1; /* disable connecting to upper level drivers */
|
|
unsigned select_no_atn:1;
|
|
unsigned fix_capacity:1; /* READ_CAPACITY is too high by 1 */
|
|
unsigned guess_capacity:1; /* READ_CAPACITY might be too high by 1 */
|
|
unsigned retry_hwerror:1; /* Retry HARDWARE_ERROR */
|
|
unsigned last_sector_bug:1; /* do not use multisector accesses on
|
|
SD_LAST_BUGGY_SECTORS */
|
|
unsigned no_read_disc_info:1; /* Avoid READ_DISC_INFO cmds */
|
|
unsigned no_read_capacity_16:1; /* Avoid READ_CAPACITY_16 cmds */
|
|
unsigned try_rc_10_first:1; /* Try READ_CAPACACITY_10 first */
|
|
unsigned is_visible:1; /* is the device visible in sysfs */
|
|
unsigned wce_default_on:1; /* Cache is ON by default */
|
|
unsigned no_dif:1; /* T10 PI (DIF) should be disabled */
|
|
unsigned broken_fua:1; /* Don't set FUA bit */
|
|
unsigned lun_in_cdb:1; /* Store LUN bits in CDB[1] */
|
|
unsigned use_rpm_auto:1; /* Enable runtime PM auto suspend */
|
|
|
|
#define SCSI_DEFAULT_AUTOSUSPEND_DELAY -1
|
|
int autosuspend_delay;
|
|
|
|
atomic_t disk_events_disable_depth; /* disable depth for disk events */
|
|
|
|
DECLARE_BITMAP(supported_events, SDEV_EVT_MAXBITS); /* supported events */
|
|
DECLARE_BITMAP(pending_events, SDEV_EVT_MAXBITS); /* pending events */
|
|
struct list_head event_list; /* asserted events */
|
|
struct work_struct event_work;
|
|
|
|
unsigned int max_device_blocked; /* what device_blocked counts down from */
|
|
#define SCSI_DEFAULT_DEVICE_BLOCKED 3
|
|
|
|
atomic_t iorequest_cnt;
|
|
atomic_t iodone_cnt;
|
|
atomic_t ioerr_cnt;
|
|
|
|
struct device sdev_gendev,
|
|
sdev_dev;
|
|
|
|
struct execute_work ew; /* used to get process context on put */
|
|
struct work_struct requeue_work;
|
|
|
|
struct scsi_device_handler *handler;
|
|
void *handler_data;
|
|
|
|
enum scsi_device_state sdev_state;
|
|
unsigned long sdev_data[0];
|
|
} __attribute__((aligned(sizeof(unsigned long))));
|
|
|
|
#define to_scsi_device(d) \
|
|
container_of(d, struct scsi_device, sdev_gendev)
|
|
#define class_to_sdev(d) \
|
|
container_of(d, struct scsi_device, sdev_dev)
|
|
#define transport_class_to_sdev(class_dev) \
|
|
to_scsi_device(class_dev->parent)
|
|
|
|
#define sdev_dbg(sdev, fmt, a...) \
|
|
dev_dbg(&(sdev)->sdev_gendev, fmt, ##a)
|
|
|
|
/*
|
|
* like scmd_printk, but the device name is passed in
|
|
* as a string pointer
|
|
*/
|
|
__printf(4, 5) void
|
|
sdev_prefix_printk(const char *, const struct scsi_device *, const char *,
|
|
const char *, ...);
|
|
|
|
#define sdev_printk(l, sdev, fmt, a...) \
|
|
sdev_prefix_printk(l, sdev, NULL, fmt, ##a)
|
|
|
|
__printf(3, 4) void
|
|
scmd_printk(const char *, const struct scsi_cmnd *, const char *, ...);
|
|
|
|
#define scmd_dbg(scmd, fmt, a...) \
|
|
do { \
|
|
if ((scmd)->request->rq_disk) \
|
|
sdev_dbg((scmd)->device, "[%s] " fmt, \
|
|
(scmd)->request->rq_disk->disk_name, ##a);\
|
|
else \
|
|
sdev_dbg((scmd)->device, fmt, ##a); \
|
|
} while (0)
|
|
|
|
enum scsi_target_state {
|
|
STARGET_CREATED = 1,
|
|
STARGET_RUNNING,
|
|
STARGET_REMOVE,
|
|
STARGET_DEL,
|
|
};
|
|
|
|
/*
|
|
* scsi_target: representation of a scsi target, for now, this is only
|
|
* used for single_lun devices. If no one has active IO to the target,
|
|
* starget_sdev_user is NULL, else it points to the active sdev.
|
|
*/
|
|
struct scsi_target {
|
|
struct scsi_device *starget_sdev_user;
|
|
struct list_head siblings;
|
|
struct list_head devices;
|
|
struct device dev;
|
|
struct kref reap_ref; /* last put renders target invisible */
|
|
unsigned int channel;
|
|
unsigned int id; /* target id ... replace
|
|
* scsi_device.id eventually */
|
|
unsigned int create:1; /* signal that it needs to be added */
|
|
unsigned int single_lun:1; /* Indicates we should only
|
|
* allow I/O to one of the luns
|
|
* for the device at a time. */
|
|
unsigned int pdt_1f_for_no_lun:1; /* PDT = 0x1f
|
|
* means no lun present. */
|
|
unsigned int no_report_luns:1; /* Don't use
|
|
* REPORT LUNS for scanning. */
|
|
unsigned int expecting_lun_change:1; /* A device has reported
|
|
* a 3F/0E UA, other devices on
|
|
* the same target will also. */
|
|
/* commands actually active on LLD. */
|
|
atomic_t target_busy;
|
|
atomic_t target_blocked;
|
|
|
|
/*
|
|
* LLDs should set this in the slave_alloc host template callout.
|
|
* If set to zero then there is not limit.
|
|
*/
|
|
unsigned int can_queue;
|
|
unsigned int max_target_blocked;
|
|
#define SCSI_DEFAULT_TARGET_BLOCKED 3
|
|
|
|
char scsi_level;
|
|
enum scsi_target_state state;
|
|
void *hostdata; /* available to low-level driver */
|
|
unsigned long starget_data[0]; /* for the transport */
|
|
/* starget_data must be the last element!!!! */
|
|
} __attribute__((aligned(sizeof(unsigned long))));
|
|
|
|
#define to_scsi_target(d) container_of(d, struct scsi_target, dev)
|
|
static inline struct scsi_target *scsi_target(struct scsi_device *sdev)
|
|
{
|
|
return to_scsi_target(sdev->sdev_gendev.parent);
|
|
}
|
|
#define transport_class_to_starget(class_dev) \
|
|
to_scsi_target(class_dev->parent)
|
|
|
|
#define starget_printk(prefix, starget, fmt, a...) \
|
|
dev_printk(prefix, &(starget)->dev, fmt, ##a)
|
|
|
|
extern struct scsi_device *__scsi_add_device(struct Scsi_Host *,
|
|
uint, uint, u64, void *hostdata);
|
|
extern int scsi_add_device(struct Scsi_Host *host, uint channel,
|
|
uint target, u64 lun);
|
|
extern int scsi_register_device_handler(struct scsi_device_handler *scsi_dh);
|
|
extern void scsi_remove_device(struct scsi_device *);
|
|
extern int scsi_unregister_device_handler(struct scsi_device_handler *scsi_dh);
|
|
void scsi_attach_vpd(struct scsi_device *sdev);
|
|
|
|
extern struct scsi_device *scsi_device_from_queue(struct request_queue *q);
|
|
extern int scsi_device_get(struct scsi_device *);
|
|
extern void scsi_device_put(struct scsi_device *);
|
|
extern struct scsi_device *scsi_device_lookup(struct Scsi_Host *,
|
|
uint, uint, u64);
|
|
extern struct scsi_device *__scsi_device_lookup(struct Scsi_Host *,
|
|
uint, uint, u64);
|
|
extern struct scsi_device *scsi_device_lookup_by_target(struct scsi_target *,
|
|
u64);
|
|
extern struct scsi_device *__scsi_device_lookup_by_target(struct scsi_target *,
|
|
u64);
|
|
extern void starget_for_each_device(struct scsi_target *, void *,
|
|
void (*fn)(struct scsi_device *, void *));
|
|
extern void __starget_for_each_device(struct scsi_target *, void *,
|
|
void (*fn)(struct scsi_device *,
|
|
void *));
|
|
|
|
/* only exposed to implement shost_for_each_device */
|
|
extern struct scsi_device *__scsi_iterate_devices(struct Scsi_Host *,
|
|
struct scsi_device *);
|
|
|
|
/**
|
|
* shost_for_each_device - iterate over all devices of a host
|
|
* @sdev: the &struct scsi_device to use as a cursor
|
|
* @shost: the &struct scsi_host to iterate over
|
|
*
|
|
* Iterator that returns each device attached to @shost. This loop
|
|
* takes a reference on each device and releases it at the end. If
|
|
* you break out of the loop, you must call scsi_device_put(sdev).
|
|
*/
|
|
#define shost_for_each_device(sdev, shost) \
|
|
for ((sdev) = __scsi_iterate_devices((shost), NULL); \
|
|
(sdev); \
|
|
(sdev) = __scsi_iterate_devices((shost), (sdev)))
|
|
|
|
/**
|
|
* __shost_for_each_device - iterate over all devices of a host (UNLOCKED)
|
|
* @sdev: the &struct scsi_device to use as a cursor
|
|
* @shost: the &struct scsi_host to iterate over
|
|
*
|
|
* Iterator that returns each device attached to @shost. It does _not_
|
|
* take a reference on the scsi_device, so the whole loop must be
|
|
* protected by shost->host_lock.
|
|
*
|
|
* Note: The only reason to use this is because you need to access the
|
|
* device list in interrupt context. Otherwise you really want to use
|
|
* shost_for_each_device instead.
|
|
*/
|
|
#define __shost_for_each_device(sdev, shost) \
|
|
list_for_each_entry((sdev), &((shost)->__devices), siblings)
|
|
|
|
extern int scsi_change_queue_depth(struct scsi_device *, int);
|
|
extern int scsi_track_queue_full(struct scsi_device *, int);
|
|
|
|
extern int scsi_set_medium_removal(struct scsi_device *, char);
|
|
|
|
extern int scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,
|
|
unsigned char *buffer, int len, int timeout,
|
|
int retries, struct scsi_mode_data *data,
|
|
struct scsi_sense_hdr *);
|
|
extern int scsi_mode_select(struct scsi_device *sdev, int pf, int sp,
|
|
int modepage, unsigned char *buffer, int len,
|
|
int timeout, int retries,
|
|
struct scsi_mode_data *data,
|
|
struct scsi_sense_hdr *);
|
|
extern int scsi_test_unit_ready(struct scsi_device *sdev, int timeout,
|
|
int retries, struct scsi_sense_hdr *sshdr);
|
|
extern int scsi_get_vpd_page(struct scsi_device *, u8 page, unsigned char *buf,
|
|
int buf_len);
|
|
extern int scsi_report_opcode(struct scsi_device *sdev, unsigned char *buffer,
|
|
unsigned int len, unsigned char opcode);
|
|
extern int scsi_device_set_state(struct scsi_device *sdev,
|
|
enum scsi_device_state state);
|
|
extern struct scsi_event *sdev_evt_alloc(enum scsi_device_event evt_type,
|
|
gfp_t gfpflags);
|
|
extern void sdev_evt_send(struct scsi_device *sdev, struct scsi_event *evt);
|
|
extern void sdev_evt_send_simple(struct scsi_device *sdev,
|
|
enum scsi_device_event evt_type, gfp_t gfpflags);
|
|
extern int scsi_device_quiesce(struct scsi_device *sdev);
|
|
extern void scsi_device_resume(struct scsi_device *sdev);
|
|
extern void scsi_target_quiesce(struct scsi_target *);
|
|
extern void scsi_target_resume(struct scsi_target *);
|
|
extern void scsi_scan_target(struct device *parent, unsigned int channel,
|
|
unsigned int id, u64 lun, int rescan);
|
|
extern void scsi_target_reap(struct scsi_target *);
|
|
extern void scsi_target_block(struct device *);
|
|
extern void scsi_target_unblock(struct device *, enum scsi_device_state);
|
|
extern void scsi_remove_target(struct device *);
|
|
extern const char *scsi_device_state_name(enum scsi_device_state);
|
|
extern int scsi_is_sdev_device(const struct device *);
|
|
extern int scsi_is_target_device(const struct device *);
|
|
extern int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
|
|
int data_direction, void *buffer, unsigned bufflen,
|
|
unsigned char *sense, int timeout, int retries,
|
|
u64 flags, int *resid);
|
|
extern int scsi_execute_req_flags(struct scsi_device *sdev,
|
|
const unsigned char *cmd, int data_direction, void *buffer,
|
|
unsigned bufflen, struct scsi_sense_hdr *sshdr, int timeout,
|
|
int retries, int *resid, u64 flags);
|
|
static inline int scsi_execute_req(struct scsi_device *sdev,
|
|
const unsigned char *cmd, int data_direction, void *buffer,
|
|
unsigned bufflen, struct scsi_sense_hdr *sshdr, int timeout,
|
|
int retries, int *resid)
|
|
{
|
|
return scsi_execute_req_flags(sdev, cmd, data_direction, buffer,
|
|
bufflen, sshdr, timeout, retries, resid, 0);
|
|
}
|
|
extern void sdev_disable_disk_events(struct scsi_device *sdev);
|
|
extern void sdev_enable_disk_events(struct scsi_device *sdev);
|
|
|
|
#ifdef CONFIG_PM
|
|
extern int scsi_autopm_get_device(struct scsi_device *);
|
|
extern void scsi_autopm_put_device(struct scsi_device *);
|
|
#else
|
|
static inline int scsi_autopm_get_device(struct scsi_device *d) { return 0; }
|
|
static inline void scsi_autopm_put_device(struct scsi_device *d) {}
|
|
#endif /* CONFIG_PM */
|
|
|
|
static inline int __must_check scsi_device_reprobe(struct scsi_device *sdev)
|
|
{
|
|
return device_reprobe(&sdev->sdev_gendev);
|
|
}
|
|
|
|
static inline unsigned int sdev_channel(struct scsi_device *sdev)
|
|
{
|
|
return sdev->channel;
|
|
}
|
|
|
|
static inline unsigned int sdev_id(struct scsi_device *sdev)
|
|
{
|
|
return sdev->id;
|
|
}
|
|
|
|
#define scmd_id(scmd) sdev_id((scmd)->device)
|
|
#define scmd_channel(scmd) sdev_channel((scmd)->device)
|
|
|
|
/*
|
|
* checks for positions of the SCSI state machine
|
|
*/
|
|
static inline int scsi_device_online(struct scsi_device *sdev)
|
|
{
|
|
return (sdev->sdev_state != SDEV_OFFLINE &&
|
|
sdev->sdev_state != SDEV_TRANSPORT_OFFLINE &&
|
|
sdev->sdev_state != SDEV_DEL);
|
|
}
|
|
static inline int scsi_device_blocked(struct scsi_device *sdev)
|
|
{
|
|
return sdev->sdev_state == SDEV_BLOCK ||
|
|
sdev->sdev_state == SDEV_CREATED_BLOCK;
|
|
}
|
|
static inline int scsi_device_created(struct scsi_device *sdev)
|
|
{
|
|
return sdev->sdev_state == SDEV_CREATED ||
|
|
sdev->sdev_state == SDEV_CREATED_BLOCK;
|
|
}
|
|
|
|
/* accessor functions for the SCSI parameters */
|
|
static inline int scsi_device_sync(struct scsi_device *sdev)
|
|
{
|
|
return sdev->sdtr;
|
|
}
|
|
static inline int scsi_device_wide(struct scsi_device *sdev)
|
|
{
|
|
return sdev->wdtr;
|
|
}
|
|
static inline int scsi_device_dt(struct scsi_device *sdev)
|
|
{
|
|
return sdev->ppr;
|
|
}
|
|
static inline int scsi_device_dt_only(struct scsi_device *sdev)
|
|
{
|
|
if (sdev->inquiry_len < 57)
|
|
return 0;
|
|
return (sdev->inquiry[56] & 0x0c) == 0x04;
|
|
}
|
|
static inline int scsi_device_ius(struct scsi_device *sdev)
|
|
{
|
|
if (sdev->inquiry_len < 57)
|
|
return 0;
|
|
return sdev->inquiry[56] & 0x01;
|
|
}
|
|
static inline int scsi_device_qas(struct scsi_device *sdev)
|
|
{
|
|
if (sdev->inquiry_len < 57)
|
|
return 0;
|
|
return sdev->inquiry[56] & 0x02;
|
|
}
|
|
static inline int scsi_device_enclosure(struct scsi_device *sdev)
|
|
{
|
|
return sdev->inquiry ? (sdev->inquiry[6] & (1<<6)) : 1;
|
|
}
|
|
|
|
static inline int scsi_device_protection(struct scsi_device *sdev)
|
|
{
|
|
if (sdev->no_dif)
|
|
return 0;
|
|
|
|
return sdev->scsi_level > SCSI_2 && sdev->inquiry[5] & (1<<0);
|
|
}
|
|
|
|
static inline int scsi_device_tpgs(struct scsi_device *sdev)
|
|
{
|
|
return sdev->inquiry ? (sdev->inquiry[5] >> 4) & 0x3 : 0;
|
|
}
|
|
|
|
#define MODULE_ALIAS_SCSI_DEVICE(type) \
|
|
MODULE_ALIAS("scsi:t-" __stringify(type) "*")
|
|
#define SCSI_DEVICE_MODALIAS_FMT "scsi:t-0x%02x"
|
|
|
|
#endif /* _SCSI_SCSI_DEVICE_H */
|