Skip to contentSkip to conversation

pm80xx : Updates for the driver version 0.1.39.

PATCH Superseded Deepak Ukey 4 participants 10 messages Aug 4, 2020 – Aug 6, 2020

Subsystems (2)

v6 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v6 cover pm80xx : Updates for the driver version 0.1.39.

From: Deepak Ukey <[email protected]>

This patch set includes some bug fixes and features for pm80xx driver.

Changes from V5:
For "Support for get phy profile functionality."
-Added fix for xtensa warning reported by kerenl test robot.
-Corrected the phy_status structure parameter.

Viswas G (2):
pm80xx : Support for get phy profile functionality. pm80xx : Staggered spin up support.

 drivers/scsi/pm8001/pm8001_ctl.h  |  33 ++++++
 drivers/scsi/pm8001/pm8001_defs.h |   3 +
 drivers/scsi/pm8001/pm8001_hwi.c  |  14 ++-
 drivers/scsi/pm8001/pm8001_init.c |  55 +++++++++-
 drivers/scsi/pm8001/pm8001_sas.c  |  36 ++++++-
 drivers/scsi/pm8001/pm8001_sas.h  |  18 ++++
 drivers/scsi/pm8001/pm80xx_hwi.c  | 213 ++++++++++++++++++++++++++++++++++----
 drivers/scsi/pm8001/pm80xx_hwi.h  |   2 +
 8 files changed, 349 insertions(+), 25 deletions(-)
Signature · 1 line
2.16.3
#1 lore raw

PATCH v6 1/2 pm80xx : Support for get phy profile functionality.

From: Viswas G <[email protected]>

Added the support to get the phy profile which gives information about the phy states, port and errors on phy.

---
 drivers/scsi/pm8001/pm8001_ctl.h  | 33 +++++++++++++++
 drivers/scsi/pm8001/pm8001_init.c |  2 +
 drivers/scsi/pm8001/pm8001_sas.h  |  5 +++
 drivers/scsi/pm8001/pm80xx_hwi.c  | 88 ++++++++++++++++++++++++++++++++++++++-
 drivers/scsi/pm8001/pm80xx_hwi.h  |  2 +
 5 files changed, 128 insertions(+), 2 deletions(-)
drivers/scsi/pm8001/pm8001_ctl.h +33 -0
index d0d43a250b9e..f7aadaf5c6aa 100644
@@ -41,6 +41,39 @@
 #ifndef PM8001_CTL_H_INCLUDED
 #define PM8001_CTL_H_INCLUDED
 
+#ifdef __LITTLE_ENDIAN_BITFIELD
+struct phy_status {
+	char		phy_id;
+	unsigned int	phy_state:4;
+	unsigned int	nlr:4;
+	unsigned int	plr:4;
+	unsigned int	reserved1:12;
+	unsigned char	port_id;
+	unsigned int	prts:4;
+	unsigned int	reserved2:20;
+} __packed;
+#else
+struct phy_status {
+	char		phy_id;
+	unsigned int	reserved1:12;
+	unsigned int	plr:4;
+	unsigned int	nlr:4;
+	unsigned int	phy_state:4;
+	unsigned char	port_id;
+	unsigned int	reserved2:20;
+	unsigned int	prts:4;
+} __packed;
+#endif
+
+struct phy_errcnt {
+	unsigned int	InvalidDword;
+	unsigned int	runningDisparityError;
+	unsigned int	codeViolation;
+	unsigned int	LossOfSyncDW;
+	unsigned int	phyResetProblem;
+	unsigned int	inboundCRCError;
+};
+
 #define IOCTL_BUF_SIZE		4096
 #define HEADER_LEN			28
 #define SIZE_OFFSET			16
drivers/scsi/pm8001/pm8001_init.c +2 -0
index 9e99262a2b9d..ff65d6cf6d31 100644
@@ -398,6 +398,8 @@ static int pm8001_alloc(struct pm8001_hba_info *pm8001_ha,
 		pm8001_ha->ccb_info[i].task = NULL;
 		pm8001_ha->ccb_info[i].ccb_tag = 0xffffffff;
 		pm8001_ha->ccb_info[i].device = NULL;
+		pm8001_ha->ccb_info[i].completion = NULL;
+		pm8001_ha->ccb_info[i].resp_buf = NULL;
 		++pm8001_ha->tags_num;
 	}
 	pm8001_ha->flags = PM8001F_INIT_TIME;
drivers/scsi/pm8001/pm8001_sas.h +5 -0
index ae7ba9b3c4bc..488af79dec47 100644
@@ -56,6 +56,7 @@
 #include <scsi/sas_ata.h>
 #include <linux/atomic.h>
 #include "pm8001_defs.h"
+#include "pm8001_ctl.h"
 
 #define DRV_NAME		"pm80xx"
 #define DRV_VERSION		"0.1.39"
@@ -244,6 +245,8 @@ struct pm8001_dispatch {
 	int (*sas_diag_execute_req)(struct pm8001_hba_info *pm8001_ha,
 		u32 state);
 	int (*sas_re_init_req)(struct pm8001_hba_info *pm8001_ha);
+	int (*get_phy_profile_req)(struct pm8001_hba_info *pm8001_ha,
+		int phy, int page, struct completion *comp, void *buf);
 };
 
 struct pm8001_chip_info {
@@ -318,6 +321,8 @@ struct pm8001_ccb_info {
 	struct pm8001_prd	buf_prd[PM8001_MAX_DMA_SG];
 	struct fw_control_ex	*fw_control_context;
 	u8			open_retry;
+	struct completion	*completion;
+	void			*resp_buf;
 };
 
 struct mpi_mem {
drivers/scsi/pm8001/pm80xx_hwi.c +86 -2

112 lines not on this page · raw message

drivers/scsi/pm8001/pm80xx_hwi.h +2 -0
index 701951a0f715..b5119c5479da 100644
@@ -175,7 +175,9 @@
 #define PHY_STOP_ERR_DEVICE_ATTACHED	0x1046
 
 /* phy_profile */
+#define SAS_PHY_ERR_COUNTERS_PAGE	0x01
 #define SAS_PHY_ANALOG_SETTINGS_PAGE	0x04
+#define SAS_PHY_GENERAL_STATUS_PAGE	0x05
 #define PHY_DWORD_LENGTH		0xC
 
 /* Thermal related */
Signature · 1 line
2.16.3
maintainer Acked-by on v6 1/2
#2 lore raw

Re: [PATCH V6 1/2] pm80xx : Support for get phy profile functionality.

Quoted 10 lines · Deepak Ukey

From: Viswas G <[email protected]>

Added the support to get the phy profile which gives information about the phy states, port and errors on phy.

Thanks!

Quoted 232 lines
---
 drivers/scsi/pm8001/pm8001_ctl.h  | 33 +++++++++++++++
 drivers/scsi/pm8001/pm8001_init.c |  2 +
 drivers/scsi/pm8001/pm8001_sas.h  |  5 +++
 drivers/scsi/pm8001/pm80xx_hwi.c  | 88 ++++++++++++++++++++++++++++++++++++++-
 drivers/scsi/pm8001/pm80xx_hwi.h  |  2 +
 5 files changed, 128 insertions(+), 2 deletions(-)
drivers/scsi/pm8001/pm8001_ctl.h +33 -0
index d0d43a250b9e..f7aadaf5c6aa 100644
@@ -41,6 +41,39 @@
 #ifndef PM8001_CTL_H_INCLUDED
 #define PM8001_CTL_H_INCLUDED
 
+#ifdef __LITTLE_ENDIAN_BITFIELD
+struct phy_status {
+       char            phy_id;
+       unsigned int    phy_state:4;
+       unsigned int    nlr:4;
+       unsigned int    plr:4;
+       unsigned int    reserved1:12;
+       unsigned char   port_id;
+       unsigned int    prts:4;
+       unsigned int    reserved2:20;
+} __packed;
+#else
+struct phy_status {
+       char            phy_id;
+       unsigned int    reserved1:12;
+       unsigned int    plr:4;
+       unsigned int    nlr:4;
+       unsigned int    phy_state:4;
+       unsigned char   port_id;
+       unsigned int    reserved2:20;
+       unsigned int    prts:4;
+} __packed;
+#endif
+
+struct phy_errcnt {
+       unsigned int    InvalidDword;
+       unsigned int    runningDisparityError;
+       unsigned int    codeViolation;
+       unsigned int    LossOfSyncDW;
+       unsigned int    phyResetProblem;
+       unsigned int    inboundCRCError;
+};
+
 #define IOCTL_BUF_SIZE         4096
 #define HEADER_LEN                     28
 #define SIZE_OFFSET                    16
drivers/scsi/pm8001/pm8001_init.c +2 -0
index 9e99262a2b9d..ff65d6cf6d31 100644
@@ -398,6 +398,8 @@ static int pm8001_alloc(struct pm8001_hba_info *pm8001_ha,
                pm8001_ha->ccb_info[i].task = NULL;
                pm8001_ha->ccb_info[i].ccb_tag = 0xffffffff;
                pm8001_ha->ccb_info[i].device = NULL;
+               pm8001_ha->ccb_info[i].completion = NULL;
+               pm8001_ha->ccb_info[i].resp_buf = NULL;
                ++pm8001_ha->tags_num;
        }
        pm8001_ha->flags = PM8001F_INIT_TIME;
drivers/scsi/pm8001/pm8001_sas.h +5 -0
index ae7ba9b3c4bc..488af79dec47 100644
@@ -56,6 +56,7 @@
 #include <scsi/sas_ata.h>
 #include <linux/atomic.h>
 #include "pm8001_defs.h"
+#include "pm8001_ctl.h"
 
 #define DRV_NAME               "pm80xx"
 #define DRV_VERSION            "0.1.39"
@@ -244,6 +245,8 @@ struct pm8001_dispatch {
        int (*sas_diag_execute_req)(struct pm8001_hba_info *pm8001_ha,
                u32 state);
        int (*sas_re_init_req)(struct pm8001_hba_info *pm8001_ha);
+       int (*get_phy_profile_req)(struct pm8001_hba_info *pm8001_ha,
+               int phy, int page, struct completion *comp, void *buf);
 };
 
 struct pm8001_chip_info {
@@ -318,6 +321,8 @@ struct pm8001_ccb_info {
        struct pm8001_prd       buf_prd[PM8001_MAX_DMA_SG];
        struct fw_control_ex    *fw_control_context;
        u8                      open_retry;
+       struct completion       *completion;
+       void                    *resp_buf;
 };
 
 struct mpi_mem {
drivers/scsi/pm8001/pm80xx_hwi.c +86 -2
index 4d205ebaee87..baccb082e65f 100644
@@ -3792,7 +3792,6 @@ static int mpi_set_controller_config_resp(struct pm8001_hba_info *pm8001_ha,
        PM8001_MSG_DBG(pm8001_ha, pm8001_printk(
                        "SET CONTROLLER RESP: status 0x%x qlfr_pgcd 0x%x\n",
                        status, err_qlfr_pgcd));
-
        return 0;
 }
 
@@ -3818,9 +3817,63 @@ static int mpi_get_controller_config_resp(struct pm8001_hba_info *pm8001_ha,
 static int mpi_get_phy_profile_resp(struct pm8001_hba_info *pm8001_ha,
                        void *piomb)
 {
+       u32 tag, page_code;
+       struct phy_status *phy_status, *phy_stat;
+       struct phy_errcnt *phy_err, *phy_err_cnt;
+       struct pm8001_ccb_info *ccb;
+       struct get_phy_profile_resp *pPayload =
+               (struct get_phy_profile_resp *)(piomb + 4);
+       u32 status = le32_to_cpu(pPayload->status);
+
+       page_code = (u8)((pPayload->ppc_phyid & 0xFF00) >> 8);
+
        PM8001_MSG_DBG(pm8001_ha,
-                       pm8001_printk(" pm80xx_addition_functionality\n"));
+               pm8001_printk(" pm80xx_addition_functionality\n"));
+       if (status) {
+               /* status is FAILED */
+               PM8001_FAIL_DBG(pm8001_ha, pm8001_printk(
+                       "mpiGetPhyProfileReq failed  with status 0x%08x\n",
+                       status));
+       }
 
+       tag = le32_to_cpu(pPayload->tag);
+       ccb = &pm8001_ha->ccb_info[tag];
+       if (ccb->completion != NULL) {
+               if (status) {
+                       /* signal fail status */
+                       memset(&ccb->resp_buf, 0xff, sizeof(ccb->resp_buf));
+               } else if (page_code == SAS_PHY_GENERAL_STATUS_PAGE) {
+                       phy_status = (struct phy_status *)ccb->resp_buf;
+                       phy_stat =
+                       (struct phy_status *)pPayload->ppc_specific_rsp;
+                       phy_status->phy_id =
+                               le32_to_cpu((__force __le32)phy_stat->phy_id);
+                       phy_status->phy_state =
+                               le32_to_cpu((__force __le32)phy_stat->phy_state);
+                       phy_status->plr =
+                               le32_to_cpu((__force __le32)phy_stat->plr);
+                       phy_status->nlr =
+                               le32_to_cpu((__force __le32)phy_stat->nlr);
+                       phy_status->port_id =
+                               le32_to_cpu((__force __le32)phy_stat->port_id);
+                       phy_status->prts =
+                               le32_to_cpu((__force __le32)phy_stat->prts);
+               } else if (page_code == SAS_PHY_ERR_COUNTERS_PAGE) {
+                       phy_err = (struct phy_errcnt *)ccb->resp_buf;
+                       phy_err_cnt =
+                       (struct phy_errcnt *)pPayload->ppc_specific_rsp;
+                       phy_err->InvalidDword =
+                       le32_to_cpu((__force __le32)phy_err_cnt->InvalidDword);
+                       phy_err->runningDisparityError = le32_to_cpu
+                       ((__force __le32)phy_err_cnt->runningDisparityError);
+                       phy_err->LossOfSyncDW = le32_to_cpu
+                       ((__force __le32)phy_err_cnt->LossOfSyncDW);
+                       phy_err->phyResetProblem = le32_to_cpu
+                       ((__force __le32)phy_err_cnt->phyResetProblem);
+               }
+               complete(ccb->completion);
+       }
+       pm8001_tag_free(pm8001_ha, tag);
        return 0;
 }
 
@@ -5013,6 +5066,36 @@ pm80xx_chip_isr(struct pm8001_hba_info *pm8001_ha, u8 vec)
        return IRQ_HANDLED;
 }
 
+static int pm8001_chip_get_phy_profile(struct pm8001_hba_info *pm8001_ha,
+       int phy_id, int page_code, struct completion *comp, void *buf)
+{
+       u32 tag;
+       struct get_phy_profile_req payload;
+       struct inbound_queue_table *circularQ;
+       struct pm8001_ccb_info *ccb;
+       int rc, ppc_phyid;
+       u32 opc = OPC_INB_GET_PHY_PROFILE;
+
+       memset(&payload, 0, sizeof(payload));
+
+       rc = pm8001_tag_alloc(pm8001_ha, &tag);
+       if (rc)
+               PM8001_FAIL_DBG(pm8001_ha, pm8001_printk("Invalid tag\n"));
+
+       ccb = &pm8001_ha->ccb_info[tag];
+       ccb->completion = comp;
+       ccb->resp_buf = buf;
+       circularQ = &pm8001_ha->inbnd_q_tbl[0];
+
+       payload.tag = cpu_to_le32(tag);
+       ppc_phyid = (page_code & 0xFF)  << 8 | (phy_id & 0xFF);
+       payload.ppc_phyid = cpu_to_le32(ppc_phyid);
+
+       pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload,
+                       sizeof(payload), 0);
+       return rc;
+}
+
 void mpi_set_phy_profile_req(struct pm8001_hba_info *pm8001_ha,
        u32 operation, u32 phyid, u32 length, u32 *buf)
 {
@@ -5113,4 +5196,5 @@ const struct pm8001_dispatch pm8001_80xx_dispatch = {
        .set_nvmd_req           = pm8001_chip_set_nvmd_req,
        .fw_flash_update_req    = pm8001_chip_fw_flash_update_req,
        .set_dev_state_req      = pm8001_chip_set_dev_state_req,
+       .get_phy_profile_req    = pm8001_chip_get_phy_profile,
 };
drivers/scsi/pm8001/pm80xx_hwi.h +2 -1
index 701951a0f715..b5119c5479da 100644
@@ -175,7 +175,9 @@
 #define PHY_STOP_ERR_DEVICE_ATTACHED   0x1046
 
 /* phy_profile */
+#define SAS_PHY_ERR_COUNTERS_PAGE      0x01
 #define SAS_PHY_ANALOG_SETTINGS_PAGE   0x04
+#define SAS_PHY_GENERAL_STATUS_PAGE    0x05
 #define PHY_DWORD_LENGTH               0xC
 
 /* Thermal related */
--

2.16.3

#3 lore raw

PATCH v6 2/2 pm80xx : Staggered spin up support.

In reply to Deepak Ukey

From: Viswas G <[email protected]>

As a part of drive discovery, driver will initaite the drive spin up. If all drives do spin up together, it will result in large power consumption. To reduce the power consumption, driver provide an option to make a small group of drives (say 3 or 4 drives together) to do the spin up. The delay between two spin up group and no of drives to spin up (group) can be programmed by the customer in seeprom and driver will use it to control the spinup.

---
 drivers/scsi/pm8001/pm8001_defs.h |   3 +
 drivers/scsi/pm8001/pm8001_hwi.c  |  14 ++++-
 drivers/scsi/pm8001/pm8001_init.c |  53 +++++++++++++++-
 drivers/scsi/pm8001/pm8001_sas.c  |  36 ++++++++++-
 drivers/scsi/pm8001/pm8001_sas.h  |  13 ++++
 drivers/scsi/pm8001/pm80xx_hwi.c  | 125 +++++++++++++++++++++++++++++++++-----
 6 files changed, 221 insertions(+), 23 deletions(-)
drivers/scsi/pm8001/pm8001_defs.h +3 -0
index 1c7f15fd69ce..fd700ce5e80c 100644
@@ -101,6 +101,9 @@ enum port_type {
 #define USI_MAX_MEMCNT		(PI + PM8001_MAX_SPCV_OUTB_NUM)
 #define	CONFIG_SCSI_PM8001_MAX_DMA_SG	528
 #define PM8001_MAX_DMA_SG	CONFIG_SCSI_PM8001_MAX_DMA_SG
+#define SPINUP_DELAY_OFFSET		0x890 /* 0x890 - delay */
+#define SPINUP_GROUP_OFFSET		0x892 /* 0x892 - group */
+#define PM80XX_MAX_SPINUP_DELAY	10000 /* 10000 ms */
 enum memory_region_num {
 	AAP1 = 0x0, /* application acceleration processor */
 	IOP,	    /* IO processor */
drivers/scsi/pm8001/pm8001_hwi.c +12 -2
index fb9848e1d481..6378c8e8d6b2 100644
@@ -3237,7 +3237,7 @@ int pm8001_mpi_local_phy_ctl(struct pm8001_hba_info *pm8001_ha, void *piomb)
 		(struct local_phy_ctl_resp *)(piomb + 4);
 	u32 status = le32_to_cpu(pPayload->status);
 	u32 phy_id = le32_to_cpu(pPayload->phyop_phyid) & ID_BITS;
-	u32 phy_op = le32_to_cpu(pPayload->phyop_phyid) & OP_BITS;
+	u32 phy_op = (le32_to_cpu(pPayload->phyop_phyid) & OP_BITS) >> 8;
 	tag = le32_to_cpu(pPayload->tag);
 	if (status != 0) {
 		PM8001_MSG_DBG(pm8001_ha,
@@ -3248,6 +3248,13 @@ int pm8001_mpi_local_phy_ctl(struct pm8001_hba_info *pm8001_ha, void *piomb)
 			pm8001_printk("%x phy execute %x phy op success!\n",
 			phy_id, phy_op));
 		pm8001_ha->phy[phy_id].reset_success = true;
+		if (phy_op == PHY_NOTIFY_ENABLE_SPINUP &&
+			!pm8001_ha->reset_in_progress){
+			/* Notify the sas layer to discover
+			 * the the whole sas domain
+			 */
+			pm8001_bytes_dmaed(pm8001_ha, phy_id);
+		}
 	}
 	if (pm8001_ha->phy[phy_id].enable_completion) {
 		complete(pm8001_ha->phy[phy_id].enable_completion);
@@ -3643,7 +3650,10 @@ int pm8001_mpi_reg_resp(struct pm8001_hba_info *pm8001_ha, void *piomb)
 			pm8001_printk("DEVREG_FAILURE_DEVICE_TYPE_NOT_SUPPORTED\n"));
 		break;
 	}
-	complete(pm8001_dev->dcompletion);
+	if (pm8001_dev->dcompletion) {
+		complete(pm8001_dev->dcompletion);
+		pm8001_dev->dcompletion = NULL;
+	}
 	ccb->task = NULL;
 	ccb->ccb_tag = 0xFFFFFFFF;
 	pm8001_tag_free(pm8001_ha, htag);
drivers/scsi/pm8001/pm8001_init.c +50 -3

89 lines not on this page · raw message

drivers/scsi/pm8001/pm8001_sas.c +34 -2
index b7cbc312843e..cf1c5e68953b 100644
@@ -265,14 +265,39 @@ int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
 void pm8001_scan_start(struct Scsi_Host *shost)
 {
 	int i;
+	unsigned long lock_flags;
 	struct pm8001_hba_info *pm8001_ha;
 	struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
+	DECLARE_COMPLETION(comp);
 	pm8001_ha = sha->lldd_ha;
 	/* SAS_RE_INITIALIZATION not available in SPCv/ve */
 	if (pm8001_ha->chip_id == chip_8001)
 		PM8001_CHIP_DISP->sas_re_init_req(pm8001_ha);
-	for (i = 0; i < pm8001_ha->chip->n_phy; ++i)
-		PM8001_CHIP_DISP->phy_start_req(pm8001_ha, i);
+
+	if (pm8001_ha->pdev->device == 0x8001 ||
+		pm8001_ha->pdev->device == 0x8081 ||
+		(pm8001_ha->spinup_interval != 0)) {
+		for (i = 0; i < pm8001_ha->chip->n_phy; ++i)
+			PM8001_CHIP_DISP->phy_start_req(pm8001_ha, i);
+	} else {
+		for (i = 0; i < pm8001_ha->chip->n_phy; ++i) {
+			spin_lock_irqsave(&pm8001_ha->lock, lock_flags);
+			pm8001_ha->phy_started = i;
+			pm8001_ha->scan_completion = &comp;
+			pm8001_ha->phystart_timedout = 1;
+			spin_unlock_irqrestore(&pm8001_ha->lock, lock_flags);
+			PM8001_CHIP_DISP->phy_start_req(pm8001_ha, i);
+			wait_for_completion_timeout(&comp,
+				msecs_to_jiffies(500));
+			if (pm8001_ha->phystart_timedout)
+				PM8001_MSG_DBG(pm8001_ha, pm8001_printk(
+				"Timeout happened for phyid = %d\n", i));
+		}
+		spin_lock_irqsave(&pm8001_ha->lock, lock_flags);
+		pm8001_ha->phy_started = -1;
+		pm8001_ha->scan_completion = NULL;
+		spin_unlock_irqrestore(&pm8001_ha->lock, lock_flags);
+	}
 }
 
 int pm8001_scan_finished(struct Scsi_Host *shost, unsigned long time)
@@ -662,6 +687,13 @@ static int pm8001_dev_found_notify(struct domain_device *dev)
 			flag = 1; /* directly sata */
 		}
 	} /*register this device to HBA*/
+
+	if (pm8001_ha->phy_started == pm8001_device->attached_phy) {
+		if (pm8001_ha->scan_completion != NULL) {
+			pm8001_ha->phystart_timedout = 0;
+			complete(pm8001_ha->scan_completion);
+		}
+	}
 	PM8001_DISC_DBG(pm8001_ha, pm8001_printk("Found device\n"));
 	PM8001_CHIP_DISP->reg_dev_req(pm8001_ha, pm8001_device, flag);
 	spin_unlock_irqrestore(&pm8001_ha->lock, flags);
drivers/scsi/pm8001/pm8001_sas.h +13 -0
index 488af79dec47..d2d73cba7f41 100644
@@ -261,6 +261,7 @@ struct pm8001_port {
 	u8			port_attached;
 	u16			wide_port_phymap;
 	u8			port_state;
+	u8			port_id;
 	struct list_head	list;
 };
 
@@ -566,6 +567,17 @@ struct pm8001_hba_info {
 	u32			reset_in_progress;
 	u32			non_fatal_count;
 	u32			non_fatal_read_length;
+	bool			staggered_spinup;
+	struct completion	*scan_completion;
+	u32			phy_started;
+	u16			phystart_timedout;
+	int			spinup_group;
+	int			spinup_interval;
+	int			phy_up[PM8001_MAX_PHYS];
+	struct timer_list	spinup_timer;
+	int			phy_head;
+	int			phy_tail;
+	spinlock_t		phy_q_lock;
 };
 
 struct pm8001_work {
@@ -684,6 +696,7 @@ void pm8001_open_reject_retry(
 int pm8001_mem_alloc(struct pci_dev *pdev, void **virt_addr,
 	dma_addr_t *pphys_addr, u32 *pphys_addr_hi, u32 *pphys_addr_lo,
 	u32 mem_size, u32 align);
+void pm8001_spinup_timedout(struct timer_list *t);
 
 void pm8001_chip_iounmap(struct pm8001_hba_info *pm8001_ha);
 int pm8001_mpi_build_cmd(struct pm8001_hba_info *pm8001_ha,
drivers/scsi/pm8001/pm80xx_hwi.c +109 -16

201 lines not on this page · raw message

Signature · 1 line
2.16.3
#4 lore raw

Re: [PATCH V6 2/2] pm80xx : Staggered spin up support.

As mentioned before - this should be a libsas or transport class policy, and not a module parameter hack in one driver.

#5 lore raw

RE: [PATCH V6 2/2] pm80xx : Staggered spin up support.

Hi Christoph,

Yes, It is better to be implemented in libsas. Since the out of box pm80xx driver has this support, we would like to push this for the time being. We will see how this can be moved to libsas.

Regards,
Deepak

-----Original Message-----
From: Christoph Hellwig [mailto:[email protected]]
Sent: Tuesday, August 4, 2020 11:33 AM
To: Deepak Ukey - I31172 <[email protected]>
Cc: [email protected]; Vasanthalakshmi Tharmarajan - I30664 <[email protected]>; Viswas G - I30667 <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH V6 2/2] pm80xx : Staggered spin up support.

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

As mentioned before - this should be a libsas or transport class policy, and not a module parameter hack in one driver.

#6 lore raw

Re: [PATCH V6 2/2] pm80xx : Staggered spin up support.

Quoted 4 lines · On 04/08/2020 07:33, [email protected] wrote:

Hi Christoph,

Yes, It is better to be implemented in libsas. Since the out of box pm80xx driver has this support, we would like to push this for the time being. We will see how this can be moved to libsas.

Other libsas users may like this feature. And libsas does already support SATA spin-up hold events - as does pm8001 - but there's not really much to that in libsas.

Question: why have a module param to enable this feature? Why not solely rely on the seeprom spin-up interval, whereby a value of 0 means no staggered spin-up?

thanks

Quoted 15 lines

Regards,
Deepak

-----Original Message-----
From: Christoph Hellwig [mailto:[email protected]]
Sent: Tuesday, August 4, 2020 11:33 AM
To: Deepak Ukey - I31172 <[email protected]>
Cc: [email protected]; Vasanthalakshmi Tharmarajan - I30664 <[email protected]>; Viswas G - I30667 <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH V6 2/2] pm80xx : Staggered spin up support.

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

As mentioned before - this should be a libsas or transport class policy, and not a module parameter hack in one driver. .

#7 lore raw

RE: [PATCH V6 2/2] pm80xx : Staggered spin up support.

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Quoted 4 lines · On 04/08/2020 07:33, [email protected] wrote:

Hi Christoph,

Yes, It is better to be implemented in libsas. Since the out of box pm80xx driver has this support, we would like to push this for the time being. We will see how this can be moved to libsas.

Other libsas users may like this feature. And libsas does already support SATA spin-up hold events - as does pm8001 - but there's not really much to that in libsas.

Question: why have a module param to enable this feature? Why not solely rely on the seeprom spin-up interval, whereby a value of 0 means no staggered spin-up?
- Setting spin-up interval may increase the time for device discovery. Customer who has a valid spin up interval - configured can still turn of this using module parameter. Or else, they have to reflash the seeprom.

Thanks
Deepak

Quoted 19 lines

-----Original Message-----
From: Christoph Hellwig [mailto:[email protected]]
Sent: Tuesday, August 4, 2020 11:33 AM
To: Deepak Ukey - I31172 <[email protected]>
Cc: [email protected]; Vasanthalakshmi Tharmarajan - I30664 <[email protected]>; Viswas G - I30667 <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH V6 2/2] pm80xx : Staggered spin up support.

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

As mentioned before - this should be a libsas or transport class policy, and not a module parameter hack in one driver. .

#8 lore raw

Re: [PATCH V6 2/2] pm80xx : Staggered spin up support.

Quoted 11 lines · On 04/08/2020 10:51, [email protected] wrote:

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Quoted 4 lines · On 04/08/2020 07:33,[email protected] wrote:

Hi Christoph,

Yes, It is better to be implemented in libsas. Since the out of box pm80xx driver has this support, we would like to push this for the time being. We will see how this can be moved to libsas.

Other libsas users may like this feature. And libsas does already support SATA spin-up hold events - as does pm8001 - but there's not really much to that in libsas.

Question: why have a module param to enable this feature? Why not solely rely on the seeprom spin-up interval, whereby a value of 0 means no staggered spin-up?
- Setting spin-up interval may increase the time for device discovery. Customer who has a valid spin up interval

Please use standard mailing list practices in replying.

- configured can still turn of this using module parameter. Or
else, they have to reflash the seeprom.

So another knob to control the driver. Anyway I think that it would be good for libsas to support this feature to benefit all users.

All the tunables from the LLDD can be fed to libsas, and libsas just needs to do what you do in pm8001_spinup_timedout() to callback to the LLDD to enable the SPINUP.

BTW, out of interest, what is this change for:

drivers/scsi/pm8001/pm8001_sas.c int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func, · line 271

Quoted 7 lines
  void pm8001_scan_start(struct Scsi_Host *shost)
  {
  	int i;
drivers/scsi/pm8001/pm8001_sas.c +2 -0
+	unsigned long lock_flags;
  	struct pm8001_hba_info *pm8001_ha;
  	struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
+	DECLARE_COMPLETION(comp);

note: this should be the _ONSTACK() variant, and is it safe to even reuse in the loop, below?

Quoted 23 lines
  	pm8001_ha = sha->lldd_ha;
  	/* SAS_RE_INITIALIZATION not available in SPCv/ve */
  	if (pm8001_ha->chip_id == chip_8001)
  		PM8001_CHIP_DISP->sas_re_init_req(pm8001_ha);
drivers/scsi/pm8001/pm8001_sas.c +16 -2
-	for (i = 0; i < pm8001_ha->chip->n_phy; ++i)
-		PM8001_CHIP_DISP->phy_start_req(pm8001_ha, i);
+
+	if (pm8001_ha->pdev->device == 0x8001 ||
+		pm8001_ha->pdev->device == 0x8081 ||
+		(pm8001_ha->spinup_interval != 0)) {
+		for (i = 0; i < pm8001_ha->chip->n_phy; ++i)
+			PM8001_CHIP_DISP->phy_start_req(pm8001_ha, i);
+	} else {
+		for (i = 0; i < pm8001_ha->chip->n_phy; ++i) {
+			spin_lock_irqsave(&pm8001_ha->lock, lock_flags);
+			pm8001_ha->phy_started = i;
+			pm8001_ha->scan_completion = &comp;
+			pm8001_ha->phystart_timedout = 1;
+			spin_unlock_irqrestore(&pm8001_ha->lock, lock_flags);
+			PM8001_CHIP_DISP->phy_start_req(pm8001_ha, i);
+			wait_for_completion_timeout(&comp,
+				msecs_to_jiffies(500));

drivers/scsi/pm8001/pm8001_sas.c int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func, · line 301

Quoted 10 lines
drivers/scsi/pm8001/pm8001_sas.c +9 -0
+			if (pm8001_ha->phystart_timedout)
+				PM8001_MSG_DBG(pm8001_ha, pm8001_printk(
+				"Timeout happened for phyid = %d\n", i));
+		}
+		spin_lock_irqsave(&pm8001_ha->lock, lock_flags);
+		pm8001_ha->phy_started = -1;
+		pm8001_ha->scan_completion = NULL;
+		spin_unlock_irqrestore(&pm8001_ha->lock, lock_flags);
+	}
  }

Thanks,
John

#9 lore raw

RE: [PATCH V6 2/2] pm80xx : Staggered spin up support.

Quoted 104 lines

-----Original Message-----
From: John Garry [mailto:[email protected]]
Sent: Wednesday, August 5, 2020 9:56 PM
To: Deepak Ukey - I31172 <[email protected]>; [email protected]
Cc: [email protected]; Vasanthalakshmi Tharmarajan - I30664 <[email protected]>; Viswas G - I30667 <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH V6 2/2] pm80xx : Staggered spin up support.

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Quoted 7 lines · On 04/08/2020 10:51, [email protected] wrote:

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Quoted 3 lines · On 04/08/2020 07:33,[email protected] wrote:

Hi Christoph,

Yes, It is better to be implemented in libsas. Since the out of box pm80xx

driver has this support, we would like to push this for the time being. We will see how this can be moved to libsas.

Quoted 2 lines
Quoted 1 line

Other libsas users may like this feature. And libsas does already support SATA

spin-up hold events - as does pm8001 - but there's not really much to that in libsas.

Quoted 2 lines

Question: why have a module param to enable this feature? Why not solely

rely on the seeprom spin-up interval, whereby a value of 0 means no staggered spin-up?

Quoted 2 lines

- Setting spin-up interval may increase the time for device discovery. Customer who has a valid spin up interval

Please use standard mailing list practices in replying.

- configured can still turn of this using module parameter. Or else, they have
to reflash the seeprom.

So another knob to control the driver. Anyway I think that it would be good for libsas to support this feature to benefit all users.

All the tunables from the LLDD can be fed to libsas, and libsas just needs to do what you do in pm8001_spinup_timedout() to callback to the LLDD to enable the SPINUP.

BTW, out of interest, what is this change for:

drivers/scsi/pm8001/pm8001_sas.c int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func, · line 271

Quoted 7 lines
  void pm8001_scan_start(struct Scsi_Host *shost)
  {
     int i;
drivers/scsi/pm8001/pm8001_sas.c +2 -0
+    unsigned long lock_flags;
     struct pm8001_hba_info *pm8001_ha;
     struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
+    DECLARE_COMPLETION(comp);

note: this should be the _ONSTACK() variant, and is it safe to even reuse in the
loop, below?
Thank you John for pointing this out. We will change this to ‘DECLARE_COMPLETION_ONSTACK’ and submit the updated patch. “
phy start” request is sequential and driver submit the new phy_start request after completing the current request. So I think it is safe to use that in a loop. Please share you thought.

Quoted 23 lines
     pm8001_ha = sha->lldd_ha;
     /* SAS_RE_INITIALIZATION not available in SPCv/ve */
     if (pm8001_ha->chip_id == chip_8001)
             PM8001_CHIP_DISP->sas_re_init_req(pm8001_ha);
drivers/scsi/pm8001/pm8001_sas.c +16 -2
-    for (i = 0; i < pm8001_ha->chip->n_phy; ++i)
-            PM8001_CHIP_DISP->phy_start_req(pm8001_ha, i);
+
+    if (pm8001_ha->pdev->device == 0x8001 ||
+            pm8001_ha->pdev->device == 0x8081 ||
+            (pm8001_ha->spinup_interval != 0)) {
+            for (i = 0; i < pm8001_ha->chip->n_phy; ++i)
+                    PM8001_CHIP_DISP->phy_start_req(pm8001_ha, i);
+    } else {
+            for (i = 0; i < pm8001_ha->chip->n_phy; ++i) {
+                    spin_lock_irqsave(&pm8001_ha->lock, lock_flags);
+                    pm8001_ha->phy_started = i;
+                    pm8001_ha->scan_completion = &comp;
+                    pm8001_ha->phystart_timedout = 1;
+                    spin_unlock_irqrestore(&pm8001_ha->lock, lock_flags);
+                    PM8001_CHIP_DISP->phy_start_req(pm8001_ha, i);
+                    wait_for_completion_timeout(&comp,
+                            msecs_to_jiffies(500));

drivers/scsi/pm8001/pm8001_sas.c int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func, · line 301

Quoted 10 lines
drivers/scsi/pm8001/pm8001_sas.c +9 -0
+                    if (pm8001_ha->phystart_timedout)
+                            PM8001_MSG_DBG(pm8001_ha, pm8001_printk(
+                            "Timeout happened for phyid = %d\n", i));
+            }
+            spin_lock_irqsave(&pm8001_ha->lock, lock_flags);
+            pm8001_ha->phy_started = -1;
+            pm8001_ha->scan_completion = NULL;
+            spin_unlock_irqrestore(&pm8001_ha->lock, lock_flags);
+    }
  }

Thanks,
John