Skip to content

Commit efc2da9

Browse files
committed
Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Pull SCSI fixes from James Bottomley: "Seven fixes, all in drivers. The hpsa three are the most extensive and the most problematic: it's a packed structure misalignment that oopses on ia64 but looks like it would also oops on quite a few non-x86 architectures. The pm80xx is a regression and the rest are bug fixes for patches in the misc tree" * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: scsi: scsi_transport_srp: Don't block target in SRP_PORT_LOST state scsi: target: iscsi: Fix zero tag inside a trace event scsi: pm80xx: Fix chip initialization failure scsi: ufs: core: Fix wrong Task Tag used in task management request UPIUs scsi: ufs: core: Fix task management request completion timeout scsi: hpsa: Add an assert to prevent __packed reintroduction scsi: hpsa: Fix boot on ia64 (atomic_t alignment) scsi: hpsa: Use __packed on individual structs, not header-wide
2 parents 95c7b07 + 5cd0f6f commit efc2da9

File tree

5 files changed

+65
-57
lines changed

5 files changed

+65
-57
lines changed

drivers/scsi/hpsa_cmd.h

Lines changed: 45 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
#ifndef HPSA_CMD_H
2121
#define HPSA_CMD_H
2222

23+
#include <linux/compiler.h>
24+
25+
#include <linux/build_bug.h> /* static_assert */
26+
#include <linux/stddef.h> /* offsetof */
27+
2328
/* general boundary defintions */
2429
#define SENSEINFOBYTES 32 /* may vary between hbas */
2530
#define SG_ENTRIES_IN_CMD 32 /* Max SG entries excluding chain blocks */
@@ -200,12 +205,10 @@ union u64bit {
200205
MAX_EXT_TARGETS + 1) /* + 1 is for the controller itself */
201206

202207
/* SCSI-3 Commands */
203-
#pragma pack(1)
204-
205208
#define HPSA_INQUIRY 0x12
206209
struct InquiryData {
207210
u8 data_byte[36];
208-
};
211+
} __packed;
209212

210213
#define HPSA_REPORT_LOG 0xc2 /* Report Logical LUNs */
211214
#define HPSA_REPORT_PHYS 0xc3 /* Report Physical LUNs */
@@ -221,7 +224,7 @@ struct raid_map_disk_data {
221224
u8 xor_mult[2]; /**< XOR multipliers for this position,
222225
* valid for data disks only */
223226
u8 reserved[2];
224-
};
227+
} __packed;
225228

226229
struct raid_map_data {
227230
__le32 structure_size; /* Size of entire structure in bytes */
@@ -247,14 +250,14 @@ struct raid_map_data {
247250
__le16 dekindex; /* Data encryption key index. */
248251
u8 reserved[16];
249252
struct raid_map_disk_data data[RAID_MAP_MAX_ENTRIES];
250-
};
253+
} __packed;
251254

252255
struct ReportLUNdata {
253256
u8 LUNListLength[4];
254257
u8 extended_response_flag;
255258
u8 reserved[3];
256259
u8 LUN[HPSA_MAX_LUN][8];
257-
};
260+
} __packed;
258261

259262
struct ext_report_lun_entry {
260263
u8 lunid[8];
@@ -269,20 +272,20 @@ struct ext_report_lun_entry {
269272
u8 lun_count; /* multi-lun device, how many luns */
270273
u8 redundant_paths;
271274
u32 ioaccel_handle; /* ioaccel1 only uses lower 16 bits */
272-
};
275+
} __packed;
273276

274277
struct ReportExtendedLUNdata {
275278
u8 LUNListLength[4];
276279
u8 extended_response_flag;
277280
u8 reserved[3];
278281
struct ext_report_lun_entry LUN[HPSA_MAX_PHYS_LUN];
279-
};
282+
} __packed;
280283

281284
struct SenseSubsystem_info {
282285
u8 reserved[36];
283286
u8 portname[8];
284287
u8 reserved1[1108];
285-
};
288+
} __packed;
286289

287290
/* BMIC commands */
288291
#define BMIC_READ 0x26
@@ -317,36 +320,36 @@ union SCSI3Addr {
317320
u8 Targ:6;
318321
u8 Mode:2; /* b10 */
319322
} LogUnit;
320-
};
323+
} __packed;
321324

322325
struct PhysDevAddr {
323326
u32 TargetId:24;
324327
u32 Bus:6;
325328
u32 Mode:2;
326329
/* 2 level target device addr */
327330
union SCSI3Addr Target[2];
328-
};
331+
} __packed;
329332

330333
struct LogDevAddr {
331334
u32 VolId:30;
332335
u32 Mode:2;
333336
u8 reserved[4];
334-
};
337+
} __packed;
335338

336339
union LUNAddr {
337340
u8 LunAddrBytes[8];
338341
union SCSI3Addr SCSI3Lun[4];
339342
struct PhysDevAddr PhysDev;
340343
struct LogDevAddr LogDev;
341-
};
344+
} __packed;
342345

343346
struct CommandListHeader {
344347
u8 ReplyQueue;
345348
u8 SGList;
346349
__le16 SGTotal;
347350
__le64 tag;
348351
union LUNAddr LUN;
349-
};
352+
} __packed;
350353

351354
struct RequestBlock {
352355
u8 CDBLen;
@@ -365,18 +368,18 @@ struct RequestBlock {
365368
#define GET_DIR(tad) (((tad) >> 6) & 0x03)
366369
u16 Timeout;
367370
u8 CDB[16];
368-
};
371+
} __packed;
369372

370373
struct ErrDescriptor {
371374
__le64 Addr;
372375
__le32 Len;
373-
};
376+
} __packed;
374377

375378
struct SGDescriptor {
376379
__le64 Addr;
377380
__le32 Len;
378381
__le32 Ext;
379-
};
382+
} __packed;
380383

381384
union MoreErrInfo {
382385
struct {
@@ -390,15 +393,16 @@ union MoreErrInfo {
390393
u8 offense_num; /* byte # of offense 0-base */
391394
u32 offense_value;
392395
} Invalid_Cmd;
393-
};
396+
} __packed;
397+
394398
struct ErrorInfo {
395399
u8 ScsiStatus;
396400
u8 SenseLen;
397401
u16 CommandStatus;
398402
u32 ResidualCnt;
399403
union MoreErrInfo MoreErrInfo;
400404
u8 SenseInfo[SENSEINFOBYTES];
401-
};
405+
} __packed;
402406
/* Command types */
403407
#define CMD_IOCTL_PEND 0x01
404408
#define CMD_SCSI 0x03
@@ -453,6 +457,15 @@ struct CommandList {
453457
atomic_t refcount; /* Must be last to avoid memset in hpsa_cmd_init() */
454458
} __aligned(COMMANDLIST_ALIGNMENT);
455459

460+
/*
461+
* Make sure our embedded atomic variable is aligned. Otherwise we break atomic
462+
* operations on architectures that don't support unaligned atomics like IA64.
463+
*
464+
* The assert guards against reintroductin against unwanted __packed to
465+
* the struct CommandList.
466+
*/
467+
static_assert(offsetof(struct CommandList, refcount) % __alignof__(atomic_t) == 0);
468+
456469
/* Max S/G elements in I/O accelerator command */
457470
#define IOACCEL1_MAXSGENTRIES 24
458471
#define IOACCEL2_MAXSGENTRIES 28
@@ -489,7 +502,7 @@ struct io_accel1_cmd {
489502
__le64 host_addr; /* 0x70 - 0x77 */
490503
u8 CISS_LUN[8]; /* 0x78 - 0x7F */
491504
struct SGDescriptor SG[IOACCEL1_MAXSGENTRIES];
492-
} __aligned(IOACCEL1_COMMANDLIST_ALIGNMENT);
505+
} __packed __aligned(IOACCEL1_COMMANDLIST_ALIGNMENT);
493506

494507
#define IOACCEL1_FUNCTION_SCSIIO 0x00
495508
#define IOACCEL1_SGLOFFSET 32
@@ -519,7 +532,7 @@ struct ioaccel2_sg_element {
519532
u8 chain_indicator;
520533
#define IOACCEL2_CHAIN 0x80
521534
#define IOACCEL2_LAST_SG 0x40
522-
};
535+
} __packed;
523536

524537
/*
525538
* SCSI Response Format structure for IO Accelerator Mode 2
@@ -559,7 +572,7 @@ struct io_accel2_scsi_response {
559572
u8 sense_data_len; /* sense/response data length */
560573
u8 resid_cnt[4]; /* residual count */
561574
u8 sense_data_buff[32]; /* sense/response data buffer */
562-
};
575+
} __packed;
563576

564577
/*
565578
* Structure for I/O accelerator (mode 2 or m2) commands.
@@ -592,7 +605,7 @@ struct io_accel2_cmd {
592605
__le32 tweak_upper; /* Encryption tweak, upper 4 bytes */
593606
struct ioaccel2_sg_element sg[IOACCEL2_MAXSGENTRIES];
594607
struct io_accel2_scsi_response error_data;
595-
} __aligned(IOACCEL2_COMMANDLIST_ALIGNMENT);
608+
} __packed __aligned(IOACCEL2_COMMANDLIST_ALIGNMENT);
596609

597610
/*
598611
* defines for Mode 2 command struct
@@ -618,15 +631,15 @@ struct hpsa_tmf_struct {
618631
__le64 abort_tag; /* cciss tag of SCSI cmd or TMF to abort */
619632
__le64 error_ptr; /* Error Pointer */
620633
__le32 error_len; /* Error Length */
621-
} __aligned(IOACCEL2_COMMANDLIST_ALIGNMENT);
634+
} __packed __aligned(IOACCEL2_COMMANDLIST_ALIGNMENT);
622635

623636
/* Configuration Table Structure */
624637
struct HostWrite {
625638
__le32 TransportRequest;
626639
__le32 command_pool_addr_hi;
627640
__le32 CoalIntDelay;
628641
__le32 CoalIntCount;
629-
};
642+
} __packed;
630643

631644
#define SIMPLE_MODE 0x02
632645
#define PERFORMANT_MODE 0x04
@@ -675,7 +688,7 @@ struct CfgTable {
675688
#define HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_STATE_CHANGE (1 << 30)
676689
#define HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_CONFIG_CHANGE (1 << 31)
677690
__le32 clear_event_notify;
678-
};
691+
} __packed;
679692

680693
#define NUM_BLOCKFETCH_ENTRIES 8
681694
struct TransTable_struct {
@@ -686,14 +699,14 @@ struct TransTable_struct {
686699
__le32 RepQCtrAddrHigh32;
687700
#define MAX_REPLY_QUEUES 64
688701
struct vals32 RepQAddr[MAX_REPLY_QUEUES];
689-
};
702+
} __packed;
690703

691704
struct hpsa_pci_info {
692705
unsigned char bus;
693706
unsigned char dev_fn;
694707
unsigned short domain;
695708
u32 board_id;
696-
};
709+
} __packed;
697710

698711
struct bmic_identify_controller {
699712
u8 configured_logical_drive_count; /* offset 0 */
@@ -702,7 +715,7 @@ struct bmic_identify_controller {
702715
u8 pad2[136];
703716
u8 controller_mode; /* offset 292 */
704717
u8 pad3[32];
705-
};
718+
} __packed;
706719

707720

708721
struct bmic_identify_physical_device {
@@ -845,7 +858,7 @@ struct bmic_identify_physical_device {
845858
u8 max_link_rate[256];
846859
u8 neg_phys_link_rate[256];
847860
u8 box_conn_name[8];
848-
} __attribute((aligned(512)));
861+
} __packed __attribute((aligned(512)));
849862

850863
struct bmic_sense_subsystem_info {
851864
u8 primary_slot_number;
@@ -858,7 +871,7 @@ struct bmic_sense_subsystem_info {
858871
u8 secondary_array_serial_number[32];
859872
u8 secondary_cache_serial_number[32];
860873
u8 pad[332];
861-
};
874+
} __packed;
862875

863876
struct bmic_sense_storage_box_params {
864877
u8 reserved[36];
@@ -870,7 +883,6 @@ struct bmic_sense_storage_box_params {
870883
u8 reserver_3[84];
871884
u8 phys_connector[2];
872885
u8 reserved_4[296];
873-
};
886+
} __packed;
874887

875-
#pragma pack()
876888
#endif /* HPSA_CMD_H */

drivers/scsi/pm8001/pm8001_hwi.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ static void init_default_table_values(struct pm8001_hba_info *pm8001_ha)
223223
PM8001_EVENT_LOG_SIZE;
224224
pm8001_ha->main_cfg_tbl.pm8001_tbl.iop_event_log_option = 0x01;
225225
pm8001_ha->main_cfg_tbl.pm8001_tbl.fatal_err_interrupt = 0x01;
226-
for (i = 0; i < PM8001_MAX_INB_NUM; i++) {
226+
for (i = 0; i < pm8001_ha->max_q_num; i++) {
227227
pm8001_ha->inbnd_q_tbl[i].element_pri_size_cnt =
228228
PM8001_MPI_QUEUE | (pm8001_ha->iomb_size << 16) | (0x00<<30);
229229
pm8001_ha->inbnd_q_tbl[i].upper_base_addr =
@@ -249,7 +249,7 @@ static void init_default_table_values(struct pm8001_hba_info *pm8001_ha)
249249
pm8001_ha->inbnd_q_tbl[i].producer_idx = 0;
250250
pm8001_ha->inbnd_q_tbl[i].consumer_index = 0;
251251
}
252-
for (i = 0; i < PM8001_MAX_OUTB_NUM; i++) {
252+
for (i = 0; i < pm8001_ha->max_q_num; i++) {
253253
pm8001_ha->outbnd_q_tbl[i].element_size_cnt =
254254
PM8001_MPI_QUEUE | (pm8001_ha->iomb_size << 16) | (0x01<<30);
255255
pm8001_ha->outbnd_q_tbl[i].upper_base_addr =
@@ -671,9 +671,9 @@ static int pm8001_chip_init(struct pm8001_hba_info *pm8001_ha)
671671
read_outbnd_queue_table(pm8001_ha);
672672
/* update main config table ,inbound table and outbound table */
673673
update_main_config_table(pm8001_ha);
674-
for (i = 0; i < PM8001_MAX_INB_NUM; i++)
674+
for (i = 0; i < pm8001_ha->max_q_num; i++)
675675
update_inbnd_queue_table(pm8001_ha, i);
676-
for (i = 0; i < PM8001_MAX_OUTB_NUM; i++)
676+
for (i = 0; i < pm8001_ha->max_q_num; i++)
677677
update_outbnd_queue_table(pm8001_ha, i);
678678
/* 8081 controller donot require these operations */
679679
if (deviceid != 0x8081 && deviceid != 0x0042) {

drivers/scsi/scsi_transport_srp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ int srp_reconnect_rport(struct srp_rport *rport)
541541
res = mutex_lock_interruptible(&rport->mutex);
542542
if (res)
543543
goto out;
544-
if (rport->state != SRP_RPORT_FAIL_FAST)
544+
if (rport->state != SRP_RPORT_FAIL_FAST && rport->state != SRP_RPORT_LOST)
545545
/*
546546
* sdev state must be SDEV_TRANSPORT_OFFLINE, transition
547547
* to SDEV_BLOCK is illegal. Calling scsi_target_unblock()

0 commit comments

Comments
 (0)