Skip to content

Commit fe15880

Browse files
Merge patch series "scsi: pm8001: Bug fix and cleanup"
Damien Le Moal <[email protected]> says: The first patch of this series fixes an issue with IRQ setup which prevents the controller from resuming after a system suspend. The following patches are code cleanup without any functional changes. [mkp: The first patch went into v6.6-rc2 and thus this merge constitutes the remaining patches of the series] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin K. Petersen <[email protected]>
2 parents 17d1194 + 80975ad commit fe15880

22 files changed

+298
-355
lines changed

drivers/scsi/lpfc/lpfc_debugfs.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6073,7 +6073,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
60736073
phba->hba_debugfs_root,
60746074
phba,
60756075
&lpfc_debugfs_op_multixripools);
6076-
if (!phba->debug_multixri_pools) {
6076+
if (IS_ERR(phba->debug_multixri_pools)) {
60776077
lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
60786078
"0527 Cannot create debugfs multixripools\n");
60796079
goto debug_failed;
@@ -6085,7 +6085,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
60856085
debugfs_create_file(name, S_IFREG | 0644,
60866086
phba->hba_debugfs_root,
60876087
phba, &lpfc_cgn_buffer_op);
6088-
if (!phba->debug_cgn_buffer) {
6088+
if (IS_ERR(phba->debug_cgn_buffer)) {
60896089
lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
60906090
"6527 Cannot create debugfs "
60916091
"cgn_buffer\n");
@@ -6098,7 +6098,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
60986098
debugfs_create_file(name, S_IFREG | 0644,
60996099
phba->hba_debugfs_root,
61006100
phba, &lpfc_rx_monitor_op);
6101-
if (!phba->debug_rx_monitor) {
6101+
if (IS_ERR(phba->debug_rx_monitor)) {
61026102
lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
61036103
"6528 Cannot create debugfs "
61046104
"rx_monitor\n");
@@ -6111,7 +6111,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
61116111
debugfs_create_file(name, 0644,
61126112
phba->hba_debugfs_root,
61136113
phba, &lpfc_debugfs_ras_log);
6114-
if (!phba->debug_ras_log) {
6114+
if (IS_ERR(phba->debug_ras_log)) {
61156115
lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
61166116
"6148 Cannot create debugfs"
61176117
" ras_log\n");
@@ -6132,7 +6132,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
61326132
debugfs_create_file(name, S_IFREG | 0644,
61336133
phba->hba_debugfs_root,
61346134
phba, &lpfc_debugfs_op_lockstat);
6135-
if (!phba->debug_lockstat) {
6135+
if (IS_ERR(phba->debug_lockstat)) {
61366136
lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
61376137
"4610 Can't create debugfs lockstat\n");
61386138
goto debug_failed;
@@ -6358,7 +6358,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
63586358
debugfs_create_file(name, 0644,
63596359
vport->vport_debugfs_root,
63606360
vport, &lpfc_debugfs_op_scsistat);
6361-
if (!vport->debug_scsistat) {
6361+
if (IS_ERR(vport->debug_scsistat)) {
63626362
lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
63636363
"4611 Cannot create debugfs scsistat\n");
63646364
goto debug_failed;
@@ -6369,7 +6369,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
63696369
debugfs_create_file(name, 0644,
63706370
vport->vport_debugfs_root,
63716371
vport, &lpfc_debugfs_op_ioktime);
6372-
if (!vport->debug_ioktime) {
6372+
if (IS_ERR(vport->debug_ioktime)) {
63736373
lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
63746374
"0815 Cannot create debugfs ioktime\n");
63756375
goto debug_failed;

drivers/scsi/lpfc/lpfc_hbadisc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,12 @@ lpfc_dev_loss_tmo_callbk(struct fc_rport *rport)
199199
/* Only 1 thread can drop the initial node reference. If
200200
* another thread has set NLP_DROPPED, this thread is done.
201201
*/
202-
if (!(ndlp->nlp_flag & NLP_DROPPED)) {
202+
if (!(ndlp->fc4_xpt_flags & NVME_XPT_REGD) &&
203+
!(ndlp->nlp_flag & NLP_DROPPED)) {
203204
ndlp->nlp_flag |= NLP_DROPPED;
204205
spin_unlock_irqrestore(&ndlp->lock, iflags);
205206
lpfc_nlp_put(ndlp);
206-
spin_lock_irqsave(&ndlp->lock, iflags);
207+
return;
207208
}
208209

209210
spin_unlock_irqrestore(&ndlp->lock, iflags);

drivers/scsi/lpfc/lpfc_nvme.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,7 @@ lpfc_nvme_remoteport_delete(struct nvme_fc_remote_port *remoteport)
228228
spin_unlock_irq(&ndlp->lock);
229229

230230
/* On a devloss timeout event, one more put is executed provided the
231-
* NVME and SCSI rport unregister requests are complete. If the vport
232-
* is unloading, this extra put is executed by lpfc_drop_node.
231+
* NVME and SCSI rport unregister requests are complete.
233232
*/
234233
if (!(ndlp->fc4_xpt_flags & fc4_xpt_flags))
235234
lpfc_disc_state_machine(vport, ndlp, NULL, NLP_EVT_DEVICE_RM);
@@ -2567,11 +2566,7 @@ lpfc_nvme_rescan_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
25672566
* nvme_transport perspective. Loss of an rport just means IO cannot
25682567
* be sent and recovery is completely up to the initator.
25692568
* For now, the driver just unbinds the DID and port_role so that
2570-
* no further IO can be issued. Changes are planned for later.
2571-
*
2572-
* Notes - the ndlp reference count is not decremented here since
2573-
* since there is no nvme_transport api for devloss. Node ref count
2574-
* is only adjusted in driver unload.
2569+
* no further IO can be issued.
25752570
*/
25762571
void
25772572
lpfc_nvme_unregister_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
@@ -2646,6 +2641,21 @@ lpfc_nvme_unregister_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
26462641
"6167 NVME unregister failed %d "
26472642
"port_state x%x\n",
26482643
ret, remoteport->port_state);
2644+
2645+
if (vport->load_flag & FC_UNLOADING) {
2646+
/* Only 1 thread can drop the initial node
2647+
* reference. Check if another thread has set
2648+
* NLP_DROPPED.
2649+
*/
2650+
spin_lock_irq(&ndlp->lock);
2651+
if (!(ndlp->nlp_flag & NLP_DROPPED)) {
2652+
ndlp->nlp_flag |= NLP_DROPPED;
2653+
spin_unlock_irq(&ndlp->lock);
2654+
lpfc_nlp_put(ndlp);
2655+
return;
2656+
}
2657+
spin_unlock_irq(&ndlp->lock);
2658+
}
26492659
}
26502660
}
26512661
return;

drivers/scsi/megaraid/megaraid_sas.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2332,7 +2332,7 @@ struct megasas_instance {
23322332
u32 support_morethan256jbod; /* FW support for more than 256 PD/JBOD */
23332333
bool use_seqnum_jbod_fp; /* Added for PD sequence */
23342334
bool smp_affinity_enable;
2335-
spinlock_t crashdump_lock;
2335+
struct mutex crashdump_lock;
23362336

23372337
struct megasas_register_set __iomem *reg_set;
23382338
u32 __iomem *reply_post_host_index_addr[MR_MAX_MSIX_REG_ARRAY];

drivers/scsi/megaraid/megaraid_sas_base.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3271,14 +3271,13 @@ fw_crash_buffer_store(struct device *cdev,
32713271
struct megasas_instance *instance =
32723272
(struct megasas_instance *) shost->hostdata;
32733273
int val = 0;
3274-
unsigned long flags;
32753274

32763275
if (kstrtoint(buf, 0, &val) != 0)
32773276
return -EINVAL;
32783277

3279-
spin_lock_irqsave(&instance->crashdump_lock, flags);
3278+
mutex_lock(&instance->crashdump_lock);
32803279
instance->fw_crash_buffer_offset = val;
3281-
spin_unlock_irqrestore(&instance->crashdump_lock, flags);
3280+
mutex_unlock(&instance->crashdump_lock);
32823281
return strlen(buf);
32833282
}
32843283

@@ -3293,24 +3292,23 @@ fw_crash_buffer_show(struct device *cdev,
32933292
unsigned long dmachunk = CRASH_DMA_BUF_SIZE;
32943293
unsigned long chunk_left_bytes;
32953294
unsigned long src_addr;
3296-
unsigned long flags;
32973295
u32 buff_offset;
32983296

3299-
spin_lock_irqsave(&instance->crashdump_lock, flags);
3297+
mutex_lock(&instance->crashdump_lock);
33003298
buff_offset = instance->fw_crash_buffer_offset;
33013299
if (!instance->crash_dump_buf ||
33023300
!((instance->fw_crash_state == AVAILABLE) ||
33033301
(instance->fw_crash_state == COPYING))) {
33043302
dev_err(&instance->pdev->dev,
33053303
"Firmware crash dump is not available\n");
3306-
spin_unlock_irqrestore(&instance->crashdump_lock, flags);
3304+
mutex_unlock(&instance->crashdump_lock);
33073305
return -EINVAL;
33083306
}
33093307

33103308
if (buff_offset > (instance->fw_crash_buffer_size * dmachunk)) {
33113309
dev_err(&instance->pdev->dev,
33123310
"Firmware crash dump offset is out of range\n");
3313-
spin_unlock_irqrestore(&instance->crashdump_lock, flags);
3311+
mutex_unlock(&instance->crashdump_lock);
33143312
return 0;
33153313
}
33163314

@@ -3322,7 +3320,7 @@ fw_crash_buffer_show(struct device *cdev,
33223320
src_addr = (unsigned long)instance->crash_buf[buff_offset / dmachunk] +
33233321
(buff_offset % dmachunk);
33243322
memcpy(buf, (void *)src_addr, size);
3325-
spin_unlock_irqrestore(&instance->crashdump_lock, flags);
3323+
mutex_unlock(&instance->crashdump_lock);
33263324

33273325
return size;
33283326
}
@@ -3347,7 +3345,6 @@ fw_crash_state_store(struct device *cdev,
33473345
struct megasas_instance *instance =
33483346
(struct megasas_instance *) shost->hostdata;
33493347
int val = 0;
3350-
unsigned long flags;
33513348

33523349
if (kstrtoint(buf, 0, &val) != 0)
33533350
return -EINVAL;
@@ -3361,9 +3358,9 @@ fw_crash_state_store(struct device *cdev,
33613358
instance->fw_crash_state = val;
33623359

33633360
if ((val == COPIED) || (val == COPY_ERROR)) {
3364-
spin_lock_irqsave(&instance->crashdump_lock, flags);
3361+
mutex_lock(&instance->crashdump_lock);
33653362
megasas_free_host_crash_buffer(instance);
3366-
spin_unlock_irqrestore(&instance->crashdump_lock, flags);
3363+
mutex_unlock(&instance->crashdump_lock);
33673364
if (val == COPY_ERROR)
33683365
dev_info(&instance->pdev->dev, "application failed to "
33693366
"copy Firmware crash dump\n");
@@ -7422,7 +7419,7 @@ static inline void megasas_init_ctrl_params(struct megasas_instance *instance)
74227419
init_waitqueue_head(&instance->int_cmd_wait_q);
74237420
init_waitqueue_head(&instance->abort_cmd_wait_q);
74247421

7425-
spin_lock_init(&instance->crashdump_lock);
7422+
mutex_init(&instance->crashdump_lock);
74267423
spin_lock_init(&instance->mfi_pool_lock);
74277424
spin_lock_init(&instance->hba_lock);
74287425
spin_lock_init(&instance->stream_lock);

drivers/scsi/pm8001/pm8001_hwi.c

Lines changed: 17 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,65 +1180,6 @@ void pm8001_chip_iounmap(struct pm8001_hba_info *pm8001_ha)
11801180
}
11811181
}
11821182

1183-
#ifndef PM8001_USE_MSIX
1184-
/**
1185-
* pm8001_chip_intx_interrupt_enable - enable PM8001 chip interrupt
1186-
* @pm8001_ha: our hba card information
1187-
*/
1188-
static void
1189-
pm8001_chip_intx_interrupt_enable(struct pm8001_hba_info *pm8001_ha)
1190-
{
1191-
pm8001_cw32(pm8001_ha, 0, MSGU_ODMR, ODMR_CLEAR_ALL);
1192-
pm8001_cw32(pm8001_ha, 0, MSGU_ODCR, ODCR_CLEAR_ALL);
1193-
}
1194-
1195-
/**
1196-
* pm8001_chip_intx_interrupt_disable - disable PM8001 chip interrupt
1197-
* @pm8001_ha: our hba card information
1198-
*/
1199-
static void
1200-
pm8001_chip_intx_interrupt_disable(struct pm8001_hba_info *pm8001_ha)
1201-
{
1202-
pm8001_cw32(pm8001_ha, 0, MSGU_ODMR, ODMR_MASK_ALL);
1203-
}
1204-
1205-
#else
1206-
1207-
/**
1208-
* pm8001_chip_msix_interrupt_enable - enable PM8001 chip interrupt
1209-
* @pm8001_ha: our hba card information
1210-
* @int_vec_idx: interrupt number to enable
1211-
*/
1212-
static void
1213-
pm8001_chip_msix_interrupt_enable(struct pm8001_hba_info *pm8001_ha,
1214-
u32 int_vec_idx)
1215-
{
1216-
u32 msi_index;
1217-
u32 value;
1218-
msi_index = int_vec_idx * MSIX_TABLE_ELEMENT_SIZE;
1219-
msi_index += MSIX_TABLE_BASE;
1220-
pm8001_cw32(pm8001_ha, 0, msi_index, MSIX_INTERRUPT_ENABLE);
1221-
value = (1 << int_vec_idx);
1222-
pm8001_cw32(pm8001_ha, 0, MSGU_ODCR, value);
1223-
1224-
}
1225-
1226-
/**
1227-
* pm8001_chip_msix_interrupt_disable - disable PM8001 chip interrupt
1228-
* @pm8001_ha: our hba card information
1229-
* @int_vec_idx: interrupt number to disable
1230-
*/
1231-
static void
1232-
pm8001_chip_msix_interrupt_disable(struct pm8001_hba_info *pm8001_ha,
1233-
u32 int_vec_idx)
1234-
{
1235-
u32 msi_index;
1236-
msi_index = int_vec_idx * MSIX_TABLE_ELEMENT_SIZE;
1237-
msi_index += MSIX_TABLE_BASE;
1238-
pm8001_cw32(pm8001_ha, 0, msi_index, MSIX_INTERRUPT_DISABLE);
1239-
}
1240-
#endif
1241-
12421183
/**
12431184
* pm8001_chip_interrupt_enable - enable PM8001 chip interrupt
12441185
* @pm8001_ha: our hba card information
@@ -1247,11 +1188,14 @@ pm8001_chip_msix_interrupt_disable(struct pm8001_hba_info *pm8001_ha,
12471188
static void
12481189
pm8001_chip_interrupt_enable(struct pm8001_hba_info *pm8001_ha, u8 vec)
12491190
{
1250-
#ifdef PM8001_USE_MSIX
1251-
pm8001_chip_msix_interrupt_enable(pm8001_ha, 0);
1252-
#else
1253-
pm8001_chip_intx_interrupt_enable(pm8001_ha);
1254-
#endif
1191+
if (pm8001_ha->use_msix) {
1192+
pm8001_cw32(pm8001_ha, 0, MSIX_TABLE_BASE,
1193+
MSIX_INTERRUPT_ENABLE);
1194+
pm8001_cw32(pm8001_ha, 0, MSGU_ODCR, 1);
1195+
} else {
1196+
pm8001_cw32(pm8001_ha, 0, MSGU_ODMR, ODMR_CLEAR_ALL);
1197+
pm8001_cw32(pm8001_ha, 0, MSGU_ODCR, ODCR_CLEAR_ALL);
1198+
}
12551199
}
12561200

12571201
/**
@@ -1262,11 +1206,11 @@ pm8001_chip_interrupt_enable(struct pm8001_hba_info *pm8001_ha, u8 vec)
12621206
static void
12631207
pm8001_chip_interrupt_disable(struct pm8001_hba_info *pm8001_ha, u8 vec)
12641208
{
1265-
#ifdef PM8001_USE_MSIX
1266-
pm8001_chip_msix_interrupt_disable(pm8001_ha, 0);
1267-
#else
1268-
pm8001_chip_intx_interrupt_disable(pm8001_ha);
1269-
#endif
1209+
if (pm8001_ha->use_msix)
1210+
pm8001_cw32(pm8001_ha, 0, MSIX_TABLE_BASE,
1211+
MSIX_INTERRUPT_DISABLE);
1212+
else
1213+
pm8001_cw32(pm8001_ha, 0, MSGU_ODMR, ODMR_MASK_ALL);
12701214
}
12711215

12721216
/**
@@ -4180,7 +4124,7 @@ pm8001_chip_phy_start_req(struct pm8001_hba_info *pm8001_ha, u8 phy_id)
41804124
payload.sas_identify.dev_type = SAS_END_DEVICE;
41814125
payload.sas_identify.initiator_bits = SAS_PROTOCOL_ALL;
41824126
memcpy(payload.sas_identify.sas_addr,
4183-
pm8001_ha->sas_addr, SAS_ADDR_SIZE);
4127+
&pm8001_ha->phy[phy_id].dev_sas_addr, SAS_ADDR_SIZE);
41844128
payload.sas_identify.phy_id = phy_id;
41854129

41864130
return pm8001_mpi_build_cmd(pm8001_ha, 0, opcode, &payload,
@@ -4309,16 +4253,15 @@ static int pm8001_chip_phy_ctl_req(struct pm8001_hba_info *pm8001_ha,
43094253

43104254
static u32 pm8001_chip_is_our_interrupt(struct pm8001_hba_info *pm8001_ha)
43114255
{
4312-
#ifdef PM8001_USE_MSIX
4313-
return 1;
4314-
#else
43154256
u32 value;
43164257

4258+
if (pm8001_ha->use_msix)
4259+
return 1;
4260+
43174261
value = pm8001_cr32(pm8001_ha, 0, MSGU_ODR);
43184262
if (value)
43194263
return 1;
43204264
return 0;
4321-
#endif
43224265
}
43234266

43244267
/**

0 commit comments

Comments
 (0)