Skip to content

Commit 477558d

Browse files
committed
Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Pull more SCSI updates from James Bottomley: "This is the final round of mostly small fixes and performance improvements to our initial submit. The main regression fix is the ia64 simscsi build failure which was missed in the serial number elimination conversion" * tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: (24 commits) scsi: ia64: simscsi: use request tag instead of serial_number scsi: aacraid: Fix performance issue on logical drives scsi: lpfc: Fix error codes in lpfc_sli4_pci_mem_setup() scsi: libiscsi: Hold back_lock when calling iscsi_complete_task scsi: hisi_sas: Change SERDES_CFG init value to increase reliability of HiLink scsi: hisi_sas: Send HARD RESET to clear the previous affiliation of STP target port scsi: hisi_sas: Set PHY linkrate when disconnected scsi: hisi_sas: print PHY RX errors count for later revision of v3 hw scsi: hisi_sas: Fix a timeout race of driver internal and SMP IO scsi: hisi_sas: Change return variable type in phy_up_v3_hw() scsi: qla2xxx: check for kstrtol() failure scsi: lpfc: fix 32-bit format string warning scsi: lpfc: fix unused variable warning scsi: target: tcmu: Switch to bitmap_zalloc() scsi: libiscsi: fall back to sendmsg for slab pages scsi: qla2xxx: avoid printf format warning scsi: lpfc: resolve static checker warning in lpfc_sli4_hba_unset scsi: lpfc: Correct __lpfc_sli_issue_iocb_s4 lockdep check scsi: ufs: hisi: fix ufs_hba_variant_ops passing scsi: qla2xxx: Fix panic in qla_dfs_tgt_counters_show ...
2 parents 11efae3 + 52eaa79 commit 477558d

22 files changed

+210
-80
lines changed

arch/ia64/hp/sim/simscsi.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ simscsi_interrupt (unsigned long val)
105105
atomic_dec(&num_reqs);
106106
queue[rd].sc = NULL;
107107
if (DBG)
108-
printk("simscsi_interrupt: done with %ld\n", sc->serial_number);
108+
printk("simscsi_interrupt: done with %u\n",
109+
sc->request->tag);
109110
(*sc->scsi_done)(sc);
110111
rd = (rd + 1) % SIMSCSI_REQ_QUEUE_LEN;
111112
}
@@ -214,8 +215,8 @@ simscsi_queuecommand_lck (struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *)
214215
register long sp asm ("sp");
215216

216217
if (DBG)
217-
printk("simscsi_queuecommand: target=%d,cmnd=%u,sc=%lu,sp=%lx,done=%p\n",
218-
target_id, sc->cmnd[0], sc->serial_number, sp, done);
218+
printk("simscsi_queuecommand: target=%d,cmnd=%u,sc=%u,sp=%lx,done=%p\n",
219+
target_id, sc->cmnd[0], sc->request->tag, sp, done);
219220
#endif
220221

221222
sc->result = DID_BAD_TARGET << 16;

drivers/scsi/aacraid/linit.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -413,13 +413,16 @@ static int aac_slave_configure(struct scsi_device *sdev)
413413
if (chn < AAC_MAX_BUSES && tid < AAC_MAX_TARGETS && aac->sa_firmware) {
414414
devtype = aac->hba_map[chn][tid].devtype;
415415

416-
if (devtype == AAC_DEVTYPE_NATIVE_RAW)
416+
if (devtype == AAC_DEVTYPE_NATIVE_RAW) {
417417
depth = aac->hba_map[chn][tid].qd_limit;
418-
else if (devtype == AAC_DEVTYPE_ARC_RAW)
418+
set_timeout = 1;
419+
goto common_config;
420+
}
421+
if (devtype == AAC_DEVTYPE_ARC_RAW) {
419422
set_qd_dev_type = true;
420-
421-
set_timeout = 1;
422-
goto common_config;
423+
set_timeout = 1;
424+
goto common_config;
425+
}
423426
}
424427

425428
if (aac->jbod && (sdev->type == TYPE_DISK))

drivers/scsi/hisi_sas/hisi_sas.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/dmapool.h>
1919
#include <linux/iopoll.h>
2020
#include <linux/lcm.h>
21+
#include <linux/libata.h>
2122
#include <linux/mfd/syscon.h>
2223
#include <linux/module.h>
2324
#include <linux/of_address.h>
@@ -94,6 +95,11 @@ enum {
9495
PORT_TYPE_SATA = (1U << 0),
9596
};
9697

98+
enum dev_status {
99+
HISI_SAS_DEV_INIT,
100+
HISI_SAS_DEV_NORMAL,
101+
};
102+
97103
enum {
98104
HISI_SAS_INT_ABT_CMD = 0,
99105
HISI_SAS_INT_ABT_DEV = 1,
@@ -161,6 +167,7 @@ struct hisi_sas_phy {
161167
u8 in_reset;
162168
u8 reserved[2];
163169
u32 phy_type;
170+
u32 code_violation_err_count;
164171
enum sas_linkrate minimum_linkrate;
165172
enum sas_linkrate maximum_linkrate;
166173
};
@@ -194,6 +201,7 @@ struct hisi_sas_device {
194201
struct hisi_sas_dq *dq;
195202
struct list_head list;
196203
enum sas_device_type dev_type;
204+
enum dev_status dev_status;
197205
int device_id;
198206
int sata_idx;
199207
spinlock_t lock; /* For protecting slots */

drivers/scsi/hisi_sas/hisi_sas_main.c

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
#include "hisi_sas.h"
13+
#include "../libsas/sas_internal.h"
1314
#define DRV_NAME "hisi_sas"
1415

1516
#define DEV_IS_GONE(dev) \
@@ -707,6 +708,7 @@ static struct hisi_sas_device *hisi_sas_alloc_dev(struct domain_device *device)
707708

708709
hisi_hba->devices[i].device_id = i;
709710
sas_dev = &hisi_hba->devices[i];
711+
sas_dev->dev_status = HISI_SAS_DEV_INIT;
710712
sas_dev->dev_type = device->dev_type;
711713
sas_dev->hisi_hba = hisi_hba;
712714
sas_dev->sas_device = device;
@@ -731,6 +733,8 @@ static int hisi_sas_init_device(struct domain_device *device)
731733
struct hisi_sas_tmf_task tmf_task;
732734
int retry = HISI_SAS_SRST_ATA_DISK_CNT;
733735
struct hisi_hba *hisi_hba = dev_to_hisi_hba(device);
736+
struct device *dev = hisi_hba->dev;
737+
struct sas_phy *local_phy;
734738

735739
switch (device->dev_type) {
736740
case SAS_END_DEVICE:
@@ -746,6 +750,31 @@ static int hisi_sas_init_device(struct domain_device *device)
746750
case SAS_SATA_PM:
747751
case SAS_SATA_PM_PORT:
748752
case SAS_SATA_PENDING:
753+
/*
754+
* send HARD RESET to clear previous affiliation of
755+
* STP target port
756+
*/
757+
local_phy = sas_get_local_phy(device);
758+
if (!scsi_is_sas_phy_local(local_phy)) {
759+
unsigned long deadline = ata_deadline(jiffies, 20000);
760+
struct sata_device *sata_dev = &device->sata_dev;
761+
struct ata_host *ata_host = sata_dev->ata_host;
762+
struct ata_port_operations *ops = ata_host->ops;
763+
struct ata_port *ap = sata_dev->ap;
764+
struct ata_link *link;
765+
unsigned int classes;
766+
767+
ata_for_each_link(link, ap, EDGE)
768+
rc = ops->hardreset(link, &classes,
769+
deadline);
770+
}
771+
sas_put_local_phy(local_phy);
772+
if (rc) {
773+
dev_warn(dev, "SATA disk hardreset fail: 0x%x\n",
774+
rc);
775+
return rc;
776+
}
777+
749778
while (retry-- > 0) {
750779
rc = hisi_sas_softreset_ata_disk(device);
751780
if (!rc)
@@ -808,6 +837,7 @@ static int hisi_sas_dev_found(struct domain_device *device)
808837
rc = hisi_sas_init_device(device);
809838
if (rc)
810839
goto err_out;
840+
sas_dev->dev_status = HISI_SAS_DEV_NORMAL;
811841
return 0;
812842

813843
err_out:
@@ -980,7 +1010,8 @@ static void hisi_sas_do_release_task(struct hisi_hba *hisi_hba, struct sas_task
9801010
spin_lock_irqsave(&task->task_state_lock, flags);
9811011
task->task_state_flags &=
9821012
~(SAS_TASK_STATE_PENDING | SAS_TASK_AT_INITIATOR);
983-
task->task_state_flags |= SAS_TASK_STATE_DONE;
1013+
if (!slot->is_internal && task->task_proto != SAS_PROTOCOL_SMP)
1014+
task->task_state_flags |= SAS_TASK_STATE_DONE;
9841015
spin_unlock_irqrestore(&task->task_state_lock, flags);
9851016
}
9861017

@@ -1713,20 +1744,23 @@ static int hisi_sas_clear_aca(struct domain_device *device, u8 *lun)
17131744
static int hisi_sas_debug_I_T_nexus_reset(struct domain_device *device)
17141745
{
17151746
struct sas_phy *local_phy = sas_get_local_phy(device);
1716-
int rc, reset_type = (device->dev_type == SAS_SATA_DEV ||
1717-
(device->tproto & SAS_PROTOCOL_STP)) ? 0 : 1;
1747+
struct hisi_sas_device *sas_dev = device->lldd_dev;
17181748
struct hisi_hba *hisi_hba = dev_to_hisi_hba(device);
17191749
struct sas_ha_struct *sas_ha = &hisi_hba->sha;
17201750
struct asd_sas_phy *sas_phy = sas_ha->sas_phy[local_phy->number];
17211751
struct hisi_sas_phy *phy = container_of(sas_phy,
17221752
struct hisi_sas_phy, sas_phy);
17231753
DECLARE_COMPLETION_ONSTACK(phyreset);
1754+
int rc, reset_type;
17241755

17251756
if (scsi_is_sas_phy_local(local_phy)) {
17261757
phy->in_reset = 1;
17271758
phy->reset_completion = &phyreset;
17281759
}
17291760

1761+
reset_type = (sas_dev->dev_status == HISI_SAS_DEV_INIT ||
1762+
!dev_is_sata(device)) ? 1 : 0;
1763+
17301764
rc = sas_phy_reset(local_phy, reset_type);
17311765
sas_put_local_phy(local_phy);
17321766

@@ -1742,8 +1776,13 @@ static int hisi_sas_debug_I_T_nexus_reset(struct domain_device *device)
17421776
/* report PHY down if timed out */
17431777
if (!ret)
17441778
hisi_sas_phy_down(hisi_hba, sas_phy->id, 0);
1745-
} else
1779+
} else if (sas_dev->dev_status != HISI_SAS_DEV_INIT) {
1780+
/*
1781+
* If in init state, we rely on caller to wait for link to be
1782+
* ready; otherwise, delay.
1783+
*/
17461784
msleep(2000);
1785+
}
17471786

17481787
return rc;
17491788
}
@@ -2125,9 +2164,18 @@ static int hisi_sas_write_gpio(struct sas_ha_struct *sha, u8 reg_type,
21252164

21262165
static void hisi_sas_phy_disconnected(struct hisi_sas_phy *phy)
21272166
{
2167+
struct asd_sas_phy *sas_phy = &phy->sas_phy;
2168+
struct sas_phy *sphy = sas_phy->phy;
2169+
struct sas_phy_data *d = sphy->hostdata;
2170+
21282171
phy->phy_attached = 0;
21292172
phy->phy_type = 0;
21302173
phy->port = NULL;
2174+
2175+
if (d->enable)
2176+
sphy->negotiated_linkrate = SAS_LINK_RATE_UNKNOWN;
2177+
else
2178+
sphy->negotiated_linkrate = SAS_PHY_DISABLED;
21312179
}
21322180

21332181
void hisi_sas_phy_down(struct hisi_hba *hisi_hba, int phy_no, int rdy)
@@ -2253,6 +2301,7 @@ int hisi_sas_alloc(struct hisi_hba *hisi_hba)
22532301
for (i = 0; i < HISI_SAS_MAX_DEVICES; i++) {
22542302
hisi_hba->devices[i].dev_type = SAS_PHY_UNUSED;
22552303
hisi_hba->devices[i].device_id = i;
2304+
hisi_hba->devices[i].dev_status = HISI_SAS_DEV_INIT;
22562305
}
22572306

22582307
for (i = 0; i < hisi_hba->queue_count; i++) {

drivers/scsi/hisi_sas/hisi_sas_v2_hw.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,7 @@ hisi_sas_device *alloc_dev_quirk_v2_hw(struct domain_device *device)
868868

869869
hisi_hba->devices[i].device_id = i;
870870
sas_dev = &hisi_hba->devices[i];
871+
sas_dev->dev_status = HISI_SAS_DEV_INIT;
871872
sas_dev->dev_type = device->dev_type;
872873
sas_dev->hisi_hba = hisi_hba;
873874
sas_dev->sas_device = device;

drivers/scsi/hisi_sas/hisi_sas_v3_hw.c

Lines changed: 63 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@
129129
#define PHY_CTRL_RESET_MSK (0x1 << PHY_CTRL_RESET_OFF)
130130
#define CMD_HDR_PIR_OFF 8
131131
#define CMD_HDR_PIR_MSK (0x1 << CMD_HDR_PIR_OFF)
132+
#define SERDES_CFG (PORT_BASE + 0x1c)
132133
#define SL_CFG (PORT_BASE + 0x84)
133134
#define AIP_LIMIT (PORT_BASE + 0x90)
134135
#define SL_CONTROL (PORT_BASE + 0x94)
@@ -181,6 +182,8 @@
181182
#define CHL_INT1_DMAC_RX_AXI_RD_ERR_OFF 22
182183
#define CHL_INT2 (PORT_BASE + 0x1bc)
183184
#define CHL_INT2_SL_IDAF_TOUT_CONF_OFF 0
185+
#define CHL_INT2_RX_DISP_ERR_OFF 28
186+
#define CHL_INT2_RX_CODE_ERR_OFF 29
184187
#define CHL_INT2_RX_INVLD_DW_OFF 30
185188
#define CHL_INT2_STP_LINK_TIMEOUT_OFF 31
186189
#define CHL_INT0_MSK (PORT_BASE + 0x1c0)
@@ -523,6 +526,7 @@ static void init_reg_v3_hw(struct hisi_hba *hisi_hba)
523526
}
524527
hisi_sas_phy_write32(hisi_hba, i, PROG_PHY_LINK_RATE,
525528
prog_phy_link_rate);
529+
hisi_sas_phy_write32(hisi_hba, i, SERDES_CFG, 0xffc00);
526530
hisi_sas_phy_write32(hisi_hba, i, SAS_RX_TRAIN_TIMER, 0x13e80);
527531
hisi_sas_phy_write32(hisi_hba, i, CHL_INT0, 0xffffffff);
528532
hisi_sas_phy_write32(hisi_hba, i, CHL_INT1, 0xffffffff);
@@ -544,6 +548,8 @@ static void init_reg_v3_hw(struct hisi_hba *hisi_hba)
544548
hisi_sas_phy_write32(hisi_hba, i, STP_LINK_TIMER, 0x7f7a120);
545549
hisi_sas_phy_write32(hisi_hba, i, CON_CFG_DRIVER, 0x2a0a01);
546550
hisi_sas_phy_write32(hisi_hba, i, SAS_SSP_CON_TIMER_CFG, 0x32);
551+
hisi_sas_phy_write32(hisi_hba, i, SAS_EC_INT_COAL_TIME,
552+
0x30f4240);
547553
/* used for 12G negotiate */
548554
hisi_sas_phy_write32(hisi_hba, i, COARSETUNE_TIME, 0x1e);
549555
hisi_sas_phy_write32(hisi_hba, i, AIP_LIMIT, 0x2ffff);
@@ -1344,7 +1350,8 @@ static void prep_abort_v3_hw(struct hisi_hba *hisi_hba,
13441350

13451351
static irqreturn_t phy_up_v3_hw(int phy_no, struct hisi_hba *hisi_hba)
13461352
{
1347-
int i, res;
1353+
int i;
1354+
irqreturn_t res;
13481355
u32 context, port_id, link_rate;
13491356
struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no];
13501357
struct asd_sas_phy *sas_phy = &phy->sas_phy;
@@ -1575,13 +1582,49 @@ static void handle_chl_int1_v3_hw(struct hisi_hba *hisi_hba, int phy_no)
15751582
hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT1, irq_value);
15761583
}
15771584

1585+
static void phy_get_events_v3_hw(struct hisi_hba *hisi_hba, int phy_no)
1586+
{
1587+
struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no];
1588+
struct asd_sas_phy *sas_phy = &phy->sas_phy;
1589+
struct sas_phy *sphy = sas_phy->phy;
1590+
unsigned long flags;
1591+
u32 reg_value;
1592+
1593+
spin_lock_irqsave(&phy->lock, flags);
1594+
1595+
/* loss dword sync */
1596+
reg_value = hisi_sas_phy_read32(hisi_hba, phy_no, ERR_CNT_DWS_LOST);
1597+
sphy->loss_of_dword_sync_count += reg_value;
1598+
1599+
/* phy reset problem */
1600+
reg_value = hisi_sas_phy_read32(hisi_hba, phy_no, ERR_CNT_RESET_PROB);
1601+
sphy->phy_reset_problem_count += reg_value;
1602+
1603+
/* invalid dword */
1604+
reg_value = hisi_sas_phy_read32(hisi_hba, phy_no, ERR_CNT_INVLD_DW);
1605+
sphy->invalid_dword_count += reg_value;
1606+
1607+
/* disparity err */
1608+
reg_value = hisi_sas_phy_read32(hisi_hba, phy_no, ERR_CNT_DISP_ERR);
1609+
sphy->running_disparity_error_count += reg_value;
1610+
1611+
/* code violation error */
1612+
reg_value = hisi_sas_phy_read32(hisi_hba, phy_no, ERR_CNT_CODE_ERR);
1613+
phy->code_violation_err_count += reg_value;
1614+
1615+
spin_unlock_irqrestore(&phy->lock, flags);
1616+
}
1617+
15781618
static void handle_chl_int2_v3_hw(struct hisi_hba *hisi_hba, int phy_no)
15791619
{
15801620
u32 irq_msk = hisi_sas_phy_read32(hisi_hba, phy_no, CHL_INT2_MSK);
15811621
u32 irq_value = hisi_sas_phy_read32(hisi_hba, phy_no, CHL_INT2);
15821622
struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no];
15831623
struct pci_dev *pci_dev = hisi_hba->pci_dev;
15841624
struct device *dev = hisi_hba->dev;
1625+
static const u32 msk = BIT(CHL_INT2_RX_DISP_ERR_OFF) |
1626+
BIT(CHL_INT2_RX_CODE_ERR_OFF) |
1627+
BIT(CHL_INT2_RX_INVLD_DW_OFF);
15851628

15861629
irq_value &= ~irq_msk;
15871630
if (!irq_value)
@@ -1602,6 +1645,25 @@ static void handle_chl_int2_v3_hw(struct hisi_hba *hisi_hba, int phy_no)
16021645
hisi_sas_notify_phy_event(phy, HISI_PHYE_LINK_RESET);
16031646
}
16041647

1648+
if (pci_dev->revision > 0x20 && (irq_value & msk)) {
1649+
struct asd_sas_phy *sas_phy = &phy->sas_phy;
1650+
struct sas_phy *sphy = sas_phy->phy;
1651+
1652+
phy_get_events_v3_hw(hisi_hba, phy_no);
1653+
1654+
if (irq_value & BIT(CHL_INT2_RX_INVLD_DW_OFF))
1655+
dev_info(dev, "phy%d invalid dword cnt: %u\n", phy_no,
1656+
sphy->invalid_dword_count);
1657+
1658+
if (irq_value & BIT(CHL_INT2_RX_CODE_ERR_OFF))
1659+
dev_info(dev, "phy%d code violation cnt: %u\n", phy_no,
1660+
phy->code_violation_err_count);
1661+
1662+
if (irq_value & BIT(CHL_INT2_RX_DISP_ERR_OFF))
1663+
dev_info(dev, "phy%d disparity error cnt: %u\n", phy_no,
1664+
sphy->running_disparity_error_count);
1665+
}
1666+
16051667
if ((irq_value & BIT(CHL_INT2_RX_INVLD_DW_OFF)) &&
16061668
(pci_dev->revision == 0x20)) {
16071669
u32 reg_value;
@@ -2230,31 +2292,6 @@ static u32 get_phys_state_v3_hw(struct hisi_hba *hisi_hba)
22302292
return hisi_sas_read32(hisi_hba, PHY_STATE);
22312293
}
22322294

2233-
static void phy_get_events_v3_hw(struct hisi_hba *hisi_hba, int phy_no)
2234-
{
2235-
struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no];
2236-
struct asd_sas_phy *sas_phy = &phy->sas_phy;
2237-
struct sas_phy *sphy = sas_phy->phy;
2238-
u32 reg_value;
2239-
2240-
/* loss dword sync */
2241-
reg_value = hisi_sas_phy_read32(hisi_hba, phy_no, ERR_CNT_DWS_LOST);
2242-
sphy->loss_of_dword_sync_count += reg_value;
2243-
2244-
/* phy reset problem */
2245-
reg_value = hisi_sas_phy_read32(hisi_hba, phy_no, ERR_CNT_RESET_PROB);
2246-
sphy->phy_reset_problem_count += reg_value;
2247-
2248-
/* invalid dword */
2249-
reg_value = hisi_sas_phy_read32(hisi_hba, phy_no, ERR_CNT_INVLD_DW);
2250-
sphy->invalid_dword_count += reg_value;
2251-
2252-
/* disparity err */
2253-
reg_value = hisi_sas_phy_read32(hisi_hba, phy_no, ERR_CNT_DISP_ERR);
2254-
sphy->running_disparity_error_count += reg_value;
2255-
2256-
}
2257-
22582295
static int disable_host_v3_hw(struct hisi_hba *hisi_hba)
22592296
{
22602297
struct device *dev = hisi_hba->dev;

0 commit comments

Comments
 (0)