pm80xx : Updates for the driver version 0.1.39.
Subsystems (2)
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.
Deepak Ukey (4):
pm80xx : Support for char device.
pm80xx : IOCTL functionality for GPIO.
pm80xx : IOCTL functionality for SGPIO.
pm80xx : sysfs attribute for non fatal dump.
Peter Chang (2):
pm80xx : Increase request sg length. pm80xx : Cleanup initialization loading fail path.
Vikram Auradkar (1):
pm80xx : Deal with kexec reboots.
Viswas G (4):
pm80xx : sysfs attribute for number of phys.
pm80xx : IOCTL functionality to get phy profile.
pm80xx : Introduce read and write length for IOCTL payload structure. pm80xx : IOCTL functionality for TWI device.
yuuzheng (1):
pm80xx : Free the tag when mpi_set_phy_profile_resp is received.
drivers/scsi/Kconfig | 7 + drivers/scsi/pm8001/pm8001_ctl.c | 665 +++++++++++++++++++++++++++++++++++++- drivers/scsi/pm8001/pm8001_ctl.h | 185 +++++++++++ drivers/scsi/pm8001/pm8001_defs.h | 5 +- drivers/scsi/pm8001/pm8001_hwi.c | 303 +++++++++++++++-- drivers/scsi/pm8001/pm8001_hwi.h | 18 ++ drivers/scsi/pm8001/pm8001_init.c | 104 ++++-- drivers/scsi/pm8001/pm8001_sas.c | 37 +++ drivers/scsi/pm8001/pm8001_sas.h | 72 ++++- drivers/scsi/pm8001/pm80xx_hwi.c | 390 +++++++++++++++++++++- drivers/scsi/pm8001/pm80xx_hwi.h | 55 ++++ 11 files changed, 1779 insertions(+), 62 deletions(-)
Signature · 1 line
2.16.3
PATCH 1/12 pm80xx : Increase request sg length.
From: Peter Chang <[email protected]>
Increasing the per-request size maximum (max_sectors_kb) runs into the per-device dma scatter gather list limit (max_segments) for users of the io vector system calls (eg, readv and writev). This is because the kernel combines io vectors into dma segments when possible, but it doesn't work for our user because the vectors in the buffer cache get scrambled.
This change bumps the advertised max scatter gather length to 528 to cover 2M w/ x86's 4k pages and some extra for the user checksum. It trims the size of some of the tables we don't care about and exposes all of the command slots upstream to the scsi layer.
--- drivers/scsi/Kconfig | 7 +++++++ drivers/scsi/pm8001/pm8001_defs.h | 5 +++-- drivers/scsi/pm8001/pm8001_init.c | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-)
drivers/scsi/Kconfig +7 -0
@@ -1504,6 +1504,13 @@ config SCSI_PM8001 This driver supports PMC-Sierra PCIE SAS/SATA 8x6G SPC 8001 chip based host adapters. +config SCSI_PM8001_MAX_DMA_SG + int "max segments per request" + depends on SCSI_PM8001 + default 128 + help + Allow for larger requests bound by MAX_ORDER of the ccb table. + config SCSI_BFA_FC tristate "Brocade BFA Fibre Channel Support" depends on PCI && SCSI
drivers/scsi/pm8001/pm8001_defs.h +3 -2
@@ -75,7 +75,7 @@ enum port_type { };/* driver compile-time configuration */ -#define PM8001_MAX_CCB 512/* max ccbs supported */ +#define PM8001_MAX_CCB 256/* max ccbs supported */ #define PM8001_MPI_QUEUE 1024/* maximum mpi queue entries */ #define PM8001_MAX_INB_NUM 1#define PM8001_MAX_OUTB_NUM 1
@@ -99,7 +99,8 @@ enum port_type {#define OB (CI + PM8001_MAX_SPCV_INB_NUM)#define PI (OB + PM8001_MAX_SPCV_OUTB_NUM)#define USI_MAX_MEMCNT (PI + PM8001_MAX_SPCV_OUTB_NUM) -#define PM8001_MAX_DMA_SG SG_ALL +#define CONFIG_SCSI_PM8001_MAX_DMA_SG 528 +#define PM8001_MAX_DMA_SG CONFIG_SCSI_PM8001_MAX_DMA_SGenum memory_region_num {AAP1 =0x0 ,/* application acceleration processor */ IOP ,/* IO processor */
drivers/scsi/pm8001/pm8001_init.c +1 -1
@@ -95,7 +95,7 @@ static struct scsi_host_template pm8001_sht = { .bios_param = sas_bios_param, .can_queue = 1, .this_id = -1, - .sg_tablesize = SG_ALL, + .sg_tablesize = PM8001_MAX_DMA_SG, .max_sectors = SCSI_DEFAULT_MAX_SECTORS, .eh_device_reset_handler = sas_eh_device_reset_handler, .eh_target_reset_handler = sas_eh_target_reset_handler,
Signature · 1 line
2.16.3
kbuild test robot
build botRe: [PATCH 01/12] pm80xx : Increase request sg length.
Thank you for the patch! Perhaps something to improve:
Hi Deepak,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on mkp-scsi/for-next]
[cannot apply to scsi/for-next v5.5-rc3 next-20191219]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Deepak-Ukey/pm80xx-Updates-for-the-driver-version-0-1-39/20191225-181036 base: https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next config: xtensa-allyesconfig (attached as .config) compiler: xtensa-linux-gcc (GCC) 7.5.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.5.0 make.cross ARCH=xtensa
If you fix the issue, kindly add following tag
All warnings (new ones prefixed by >>):
In file included from drivers/scsi/pm8001/pm8001_sas.h:58:0,
from drivers/scsi/pm8001/pm8001_init.c:42:
>> drivers/scsi/pm8001/pm8001_defs.h:102:0: warning: "CONFIG_SCSI_PM8001_MAX_DMA_SG" redefined
#define CONFIG_SCSI_PM8001_MAX_DMA_SG 528 In file included from include/linux/kconfig.h:5:0,
from <command-line>:0:
./include/generated/autoconf.h:9320:0: note: this is the location of the previous definition
#define CONFIG_SCSI_PM8001_MAX_DMA_SG 128vim +/CONFIG_SCSI_PM8001_MAX_DMA_SG +102 drivers/scsi/pm8001/pm8001_defs.h
95
96 #define USI_MAX_MEMCNT_BASE 5
97 #define IB (USI_MAX_MEMCNT_BASE + 1)
98 #define CI (IB + PM8001_MAX_SPCV_INB_NUM)
99 #define OB (CI + PM8001_MAX_SPCV_INB_NUM)
100 #define PI (OB + PM8001_MAX_SPCV_OUTB_NUM)
101 #define USI_MAX_MEMCNT (PI + PM8001_MAX_SPCV_OUTB_NUM)
> 102 #define CONFIG_SCSI_PM8001_MAX_DMA_SG 528 103 #define PM8001_MAX_DMA_SG CONFIG_SCSI_PM8001_MAX_DMA_SG
104 enum memory_region_num {
105 AAP1 = 0x0, /* application acceleration processor */
106 IOP, /* IO processor */
107 NVMD, /* NVM device */
108 DEV_MEM, /* memory for devices */
109 CCB_MEM, /* memory for command control block */
110 FW_FLASH, /* memory for fw flash update */
111 FORENSIC_MEM /* memory for fw forensic data */
112 };
113 #define PM8001_EVENT_LOG_SIZE (128 * 1024)
114
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation
PATCH 2/12 pm80xx : Deal with kexec reboots.
In reply to Deepak UkeyFrom: Vikram Auradkar <[email protected]>
A kexec reboot causes the controller fw to assert. This assertion shows up in two ways, the controller doesn't show up as ready and an interrupt is waiting as soon as the handler is registered. To resolve this added below fix:
-split the interrupt handling setup into two parts, setup and
request.
-If the controller ready register indicates not-ready, but that the
not readiness is only on the IOC units we can still try a reset to bring the system back to the pre-reboot state.
--- drivers/scsi/pm8001/pm8001_init.c | 48 +++++++++++++++++++++++++++++++++++---- drivers/scsi/pm8001/pm80xx_hwi.c | 15 ++++++++---- 2 files changed, 54 insertions(+), 9 deletions(-)
drivers/scsi/pm8001/pm8001_init.c +43 -5
@@ -248,6 +248,9 @@ static irqreturn_t pm8001_interrupt_handler_intx(int irq, void *dev_id)return ret; } +static u32 pm8001_setup_irq (struct pm8001_hba_info *pm8001_ha); +static u32 pm8001_request_irq (struct pm8001_hba_info *pm8001_ha); +/** * pm8001_alloc - initiate our hba structure and 6 DMAs area. * @pm8001_ha:our hba structure.
@@ -890,9 +893,7 @@ static int pm8001_configure_phy_settings(struct pm8001_hba_info *pm8001_ha)*/ static u32 pm8001_setup_msix (struct pm8001_hba_info *pm8001_ha) { -u32 i =0 , j =0 ;u32 number_of_intr; -int flag =0 ;int rc;/* SPCv controllers supports 64 msi-x */
@@ -900,11 +901,11 @@ static u32 pm8001_setup_msix(struct pm8001_hba_info *pm8001_ha) number_of_intr =1 ; }else { number_of_intr =PM8001_MAX_MSIX_VEC ; - flag &= ~IRQF_SHARED ; } rc =pci_alloc_irq_vectors (pm8001_ha->pdev, number_of_intr, number_of_intr,PCI_IRQ_MSIX ); + number_of_intr = rc;if (rc <0 )return rc; pm8001_ha->number_of_intr = number_of_intr;
@@ -912,8 +913,22 @@ static u32 pm8001_setup_msix(struct pm8001_hba_info *pm8001_ha)PM8001_INIT_DBG (pm8001_ha,pm8001_printk ("pci_alloc_irq_vectors request ret:%d no of intr %d\n" , rc, pm8001_ha->number_of_intr)); +return 0 ; +} + +static u32 pm8001_request_msix (struct pm8001_hba_info *pm8001_ha) +{ +u32 i =0 , j =0 ; +int flag =0 , rc =0 ; -for (i =0 ; i < number_of_intr; i++) { +if (pm8001_ha->chip_id != chip_8001) + flag &= ~IRQF_SHARED ; + +PM8001_INIT_DBG (pm8001_ha, +pm8001_printk ("pci_enable_msix request number of intr %d\n" , + pm8001_ha->number_of_intr)); + +for (i =0 ; i < pm8001_ha->number_of_intr; i++) {snprintf (pm8001_ha->intr_drvname[i],sizeof (pm8001_ha->intr_drvname[0 ]),"%s-%d" , pm8001_ha->name, i);
@@ -938,6 +953,21 @@ static u32 pm8001_setup_msix(struct pm8001_hba_info *pm8001_ha) }#endif +static u32 pm8001_setup_irq (struct pm8001_hba_info *pm8001_ha) +{ +struct pci_dev *pdev; + + pdev = pm8001_ha->pdev; + +#ifdef PM8001_USE_MSIX +if (pci_find_capability (pdev,PCI_CAP_ID_MSIX )) +return pm8001_setup_msix (pm8001_ha); +PM8001_INIT_DBG (pm8001_ha, +pm8001_printk ("MSIX not supported!!!\n" )); +#endif +return 0 ; +} +/** * pm8001_request_irq - register interrupt * @chip_info: our ha struct.
@@ -951,7 +981,7 @@ static u32 pm8001_request_irq(struct pm8001_hba_info *pm8001_ha)#ifdef PM8001_USE_MSIX if (pdev->msix_cap &&pci_msi_enabled ()) -return pm8001_setup_msix (pm8001_ha); +return pm8001_request_msix (pm8001_ha);else {PM8001_INIT_DBG (pm8001_ha,pm8001_printk ("MSIX not supported!!!\n" ));
@@ -1033,6 +1063,13 @@ static int pm8001_pci_probe(struct pci_dev *pdev, rc = -ENOMEM ; goto err_out_free; } +/* Setup Interrupt */ + rc =pm8001_setup_irq (pm8001_ha); +if (rc) { +PM8001_FAIL_DBG (pm8001_ha,pm8001_printk ( +"pm8001_setup_irq failed [ret: %d]\n" , rc)); + goto err_out_shost; + }list_add_tail (&pm8001_ha->list, &hba_list);PM8001_CHIP_DISP ->chip_soft_rst (pm8001_ha); rc =PM8001_CHIP_DISP ->chip_init (pm8001_ha);
@@ -1045,6 +1082,7 @@ static int pm8001_pci_probe(struct pci_dev *pdev, rc =scsi_add_host (shost, &pdev->dev);if (rc) goto err_out_ha_free; +/* Request Interrupt */ rc =pm8001_request_irq (pm8001_ha);if (rc) { PM8001_FAIL_DBG(pm8001_ha, pm8001_printk(
drivers/scsi/pm8001/pm80xx_hwi.c +11 -4
@@ -1438,11 +1438,18 @@ pm80xx_chip_soft_rst(struct pm8001_hba_info *pm8001_ha)if (!pm8001_ha->controller_fatal_error) {/* Check if MPI is in ready state to reset */ if (mpi_uninit_check (pm8001_ha) !=0 ) { - regval =pm8001_cr32 (pm8001_ha,0 ,MSGU_SCRATCH_PAD_1 ); +u32 r0 =pm8001_cr32 (pm8001_ha,0 ,MSGU_SCRATCH_PAD_0 ); +u32 r1 =pm8001_cr32 (pm8001_ha,0 ,MSGU_SCRATCH_PAD_1 ); +u32 r2 =pm8001_cr32 (pm8001_ha,0 ,MSGU_SCRATCH_PAD_2 ); +u32 r3 =pm8001_cr32 (pm8001_ha,0 ,MSGU_SCRATCH_PAD_3 );PM8001_FAIL_DBG (pm8001_ha,pm8001_printk ( -"MPI state is not ready scratch1 :0x%x\n" , - regval)); -return -1 ; +"MPI state is not ready scratch: %x:%x:%x:%x\n" , + r0, r1, r2, r3)); +/* if things aren't ready but the bootloader is ok then +* try the reset anyway. +*/ +if (r1 &SCRATCH_PAD1_BOOTSTATE_MASK ) +return -1 ; } }/* checked for reset register normal state; 0x0 */
Signature · 1 line
2.16.3
Jinpu Wang
maintainerRe: [PATCH 02/12] pm80xx : Deal with kexec reboots.
Quoted 13 lines · Deepak Ukey
From: Vikram Auradkar <[email protected]>
A kexec reboot causes the controller fw to assert. This assertion shows up in two ways, the controller doesn't show up as ready and an interrupt is waiting as soon as the handler is registered. To resolve this added below fix:
(quoted diff) +0
-2-split the interrupt handling setup into two parts, setup and request. -If the controller ready register indicates not-ready, but that the not readiness is only on the IOC units we can still try a reset to bring the system back to the pre-reboot state.
Quoted 8 lines
Signed-off-by Vikram Auradkar <[email protected]>Signed-off-by Deepak Ukey <[email protected]>Signed-off-by Viswas G <[email protected]>Signed-off-by Vishakha Channapattan <[email protected]>Signed-off-by Bhavesh Jashnani <[email protected]>Signed-off-by Radha Ramachandran <[email protected]>Signed-off-by Akshat Jain <[email protected]>Signed-off-by Yu Zheng <[email protected]>
The patch looks fine, Acked-by: Jack Wang <[email protected]>
ps: the signed-off-by chain was surprisingly long for such simple patch, do they all contribute to the patch?
Quoted 149 lines
--- drivers/scsi/pm8001/pm8001_init.c | 48 +++++++++++++++++++++++++++++++++++---- drivers/scsi/pm8001/pm80xx_hwi.c | 15 ++++++++---- 2 files changed, 54 insertions(+), 9 deletions(-)drivers/scsi/pm8001/pm8001_init.c +43
-5@@ -248,6 +248,9 @@ static irqreturn_t pm8001_interrupt_handler_intx(int irq, void *dev_id)return ret; } +static u32 pm8001_setup_irq (struct pm8001_hba_info *pm8001_ha); +static u32 pm8001_request_irq (struct pm8001_hba_info *pm8001_ha); +/** * pm8001_alloc - initiate our hba structure and 6 DMAs area. * @pm8001_ha:our hba structure. @@ -890,9 +893,7 @@ static int pm8001_configure_phy_settings(struct pm8001_hba_info *pm8001_ha)*/ static u32 pm8001_setup_msix (struct pm8001_hba_info *pm8001_ha) { -u32 i =0 , j =0 ;u32 number_of_intr; -int flag =0 ;int rc;/* SPCv controllers supports 64 msi-x */ @@ -900,11 +901,11 @@ static u32 pm8001_setup_msix(struct pm8001_hba_info *pm8001_ha) number_of_intr =1 ; }else { number_of_intr =PM8001_MAX_MSIX_VEC ; - flag &= ~IRQF_SHARED ; } rc =pci_alloc_irq_vectors (pm8001_ha->pdev, number_of_intr, number_of_intr,PCI_IRQ_MSIX ); + number_of_intr = rc;if (rc <0 )return rc; pm8001_ha->number_of_intr = number_of_intr;@@ -912,8 +913,22 @@ static u32 pm8001_setup_msix(struct pm8001_hba_info *pm8001_ha)PM8001_INIT_DBG (pm8001_ha,pm8001_printk ("pci_alloc_irq_vectors request ret:%d no of intr %d\n" , rc, pm8001_ha->number_of_intr)); +return 0 ; +} + +static u32 pm8001_request_msix (struct pm8001_hba_info *pm8001_ha) +{ +u32 i =0 , j =0 ; +int flag =0 , rc =0 ; -for (i =0 ; i < number_of_intr; i++) { +if (pm8001_ha->chip_id != chip_8001) + flag &= ~IRQF_SHARED ; + +PM8001_INIT_DBG (pm8001_ha, +pm8001_printk ("pci_enable_msix request number of intr %d\n" , + pm8001_ha->number_of_intr)); + +for (i =0 ; i < pm8001_ha->number_of_intr; i++) {snprintf (pm8001_ha->intr_drvname[i],sizeof (pm8001_ha->intr_drvname[0 ]),"%s-%d" , pm8001_ha->name, i);@@ -938,6 +953,21 @@ static u32 pm8001_setup_msix(struct pm8001_hba_info *pm8001_ha) }#endif +static u32 pm8001_setup_irq (struct pm8001_hba_info *pm8001_ha) +{ +struct pci_dev *pdev; + + pdev = pm8001_ha->pdev; + +#ifdef PM8001_USE_MSIX +if (pci_find_capability (pdev,PCI_CAP_ID_MSIX )) +return pm8001_setup_msix (pm8001_ha); +PM8001_INIT_DBG (pm8001_ha, +pm8001_printk ("MSIX not supported!!!\n" )); +#endif +return 0 ; +} +/** * pm8001_request_irq - register interrupt * @chip_info: our ha struct. @@ -951,7 +981,7 @@ static u32 pm8001_request_irq(struct pm8001_hba_info *pm8001_ha)#ifdef PM8001_USE_MSIX if (pdev->msix_cap &&pci_msi_enabled ()) -return pm8001_setup_msix (pm8001_ha); +return pm8001_request_msix (pm8001_ha);else {PM8001_INIT_DBG (pm8001_ha,pm8001_printk ("MSIX not supported!!!\n" ));@@ -1033,6 +1063,13 @@ static int pm8001_pci_probe(struct pci_dev *pdev, rc = -ENOMEM ; goto err_out_free; } +/* Setup Interrupt */ + rc =pm8001_setup_irq (pm8001_ha); +if (rc) { +PM8001_FAIL_DBG (pm8001_ha,pm8001_printk ( +"pm8001_setup_irq failed [ret: %d]\n" , rc)); + goto err_out_shost; + }list_add_tail (&pm8001_ha->list, &hba_list);PM8001_CHIP_DISP ->chip_soft_rst (pm8001_ha); rc =PM8001_CHIP_DISP ->chip_init (pm8001_ha);@@ -1045,6 +1082,7 @@ static int pm8001_pci_probe(struct pci_dev *pdev, rc =scsi_add_host (shost, &pdev->dev);if (rc) goto err_out_ha_free; +/* Request Interrupt */ rc =pm8001_request_irq (pm8001_ha);if (rc) { PM8001_FAIL_DBG(pm8001_ha, pm8001_printk(drivers/scsi/pm8001/pm80xx_hwi.c +11
-5@@ -1438,11 +1438,18 @@ pm80xx_chip_soft_rst(struct pm8001_hba_info *pm8001_ha)if (!pm8001_ha->controller_fatal_error) {/* Check if MPI is in ready state to reset */ if (mpi_uninit_check (pm8001_ha) !=0 ) { - regval =pm8001_cr32 (pm8001_ha,0 ,MSGU_SCRATCH_PAD_1 ); +u32 r0 =pm8001_cr32 (pm8001_ha,0 ,MSGU_SCRATCH_PAD_0 ); +u32 r1 =pm8001_cr32 (pm8001_ha,0 ,MSGU_SCRATCH_PAD_1 ); +u32 r2 =pm8001_cr32 (pm8001_ha,0 ,MSGU_SCRATCH_PAD_2 ); +u32 r3 =pm8001_cr32 (pm8001_ha,0 ,MSGU_SCRATCH_PAD_3 );PM8001_FAIL_DBG (pm8001_ha,pm8001_printk ( -"MPI state is not ready scratch1 :0x%x\n" , - regval)); -return -1 ; +"MPI state is not ready scratch: %x:%x:%x:%x\n" , + r0, r1, r2, r3)); +/* if things aren't ready but the bootloader is ok then +* try the reset anyway. +*/ +if (r1 &SCRATCH_PAD1_BOOTSTATE_MASK ) +return -1 ; } }/* checked for reset register normal state; 0x0 */ --2.16.3
PATCH 3/12 pm80xx : Free the tag when mpi_set_phy_profile_resp is received.
In reply to Deepak UkeyFrom: yuuzheng <[email protected]>
In pm80xx driver, the command mpi_set_phy_profile_req is sent by host during boot to configure the phy profile such as analog setting page, rate control page. However, the tag is not freed when its response is received. As a result, 16 tags are missing for each HBA after boot. When NCQ is enabled with queue depth 16, it needs at least, 15 * 16 = 240 tags for each HBA to achieve the best performance. In current pm80xx driver with setting CCB_MAX = 256, the total number of tags in each HBA is 255 for data IO. Hence, without returning those tags to the pool after boot, some device will finally be forced to non-ncq mode by ATA layer due to excessive errors (i.e. LLDD cannot allocate tag for queued task).
--- drivers/scsi/pm8001/pm80xx_hwi.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/scsi/pm8001/pm80xx_hwi.c +7 -3
@@ -3715,28 +3715,32 @@ static int mpi_flash_op_ext_resp(struct pm8001_hba_info *pm8001_ha, void *piomb)static int mpi_set_phy_profile_resp (struct pm8001_hba_info *pm8001_ha,void *piomb) { +u32 tag;u8 page_code; +int rc =0 ;struct set_phy_profile_resp *pPayload = (struct set_phy_profile_resp *)(piomb +4 );u32 ppc_phyid =le32_to_cpu (pPayload->ppc_phyid);u32 status =le32_to_cpu (pPayload->status); + tag =le32_to_cpu (pPayload->tag); page_code = (u8)((ppc_phyid &0xFF00 ) >>8 );if (status) {/* status is FAILED */ PM8001_FAIL_DBG (pm8001_ha,pm8001_printk ("PhyProfile command failed with status " "0x%08X \n" , status)); -return -1 ; + rc =-1 ; }else {if (page_code !=SAS_PHY_ANALOG_SETTINGS_PAGE ) {PM8001_FAIL_DBG (pm8001_ha,pm8001_printk ("Invalid page code 0x%X\n" , page_code)); -return -1 ; + rc =-1 ; } } -return 0 ; +pm8001_tag_free (pm8001_ha, tag); +return rc; }/**
Signature · 1 line
2.16.3
Re: [PATCH 03/12] pm80xx : Free the tag when mpi_set_phy_profile_resp is received.
Quoted 15 lines · Deepak Ukey
From: yuuzheng <[email protected]>
In pm80xx driver, the command
mpi_set_phy_profile_reqis sent by host during boot to configure the phy profile such as analog setting page, rate control page. However, the tag is not freed when its response is received. As a result, 16 tags are missing for each HBA after boot. When NCQ is enabled with queue depth 16, it needs at least, 15 * 16 = 240 tags for each HBA to achieve the best performance. In current pm80xx driver with settingCCB_MAX= 256, the total number of tags in each HBA is 255 for data IO. Hence, without returning those tags to the pool after boot, some device will finally be forced to non-ncq mode by ATA layer due to excessive errors (i.e. LLDD cannot allocate tag for queued task).
Quoted 7 lines
Signed-off-by yuuzheng <[email protected]>Signed-off-by Deepak Ukey <[email protected]>Signed-off-by Viswas G <[email protected]>Signed-off-by Vishakha Channapattan <[email protected]>Signed-off-by Bhavesh Jashnani <[email protected]>Signed-off-by Radha Ramachandran <[email protected]>Signed-off-by Akshat Jain <[email protected]>
The patch looks fine.
Quoted 47 lines
--- drivers/scsi/pm8001/pm80xx_hwi.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)drivers/scsi/pm8001/pm80xx_hwi.c +7
-4@@ -3715,28 +3715,32 @@ static int mpi_flash_op_ext_resp(struct pm8001_hba_info *pm8001_ha, void *piomb)static int mpi_set_phy_profile_resp (struct pm8001_hba_info *pm8001_ha,void *piomb) { +u32 tag;u8 page_code; +int rc =0 ;struct set_phy_profile_resp *pPayload = (struct set_phy_profile_resp *)(piomb +4 );u32 ppc_phyid =le32_to_cpu (pPayload->ppc_phyid);u32 status =le32_to_cpu (pPayload->status); + tag =le32_to_cpu (pPayload->tag); page_code = (u8)((ppc_phyid &0xFF00 ) >>8 );if (status) {/* status is FAILED */ PM8001_FAIL_DBG (pm8001_ha,pm8001_printk ("PhyProfile command failed with status " "0x%08X \n" , status)); -return -1 ; + rc =-1 ; }else {if (page_code !=SAS_PHY_ANALOG_SETTINGS_PAGE ) {PM8001_FAIL_DBG (pm8001_ha,pm8001_printk ("Invalid page code 0x%X\n" , page_code)); -return -1 ; + rc =-1 ; } } -return 0 ; +pm8001_tag_free (pm8001_ha, tag); +return rc; }/** -- 2.16.3
PATCH 4/12 pm80xx : Cleanup initialization loading fail path.
In reply to Deepak UkeyFrom: Peter Chang <[email protected]>
1)Move the instance tracking down after we think the instance is good to go. avoids having a use-after free.
2)There are goto targets for trying to cleanup if the hw fails to initialize, but there's some overlap depending on who thinks they own the sub-structures.
--- drivers/scsi/pm8001/pm8001_init.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
drivers/scsi/pm8001/pm8001_init.c +11 -6
@@ -1016,6 +1016,7 @@ static int pm8001_pci_probe(struct pci_dev *pdev,struct pm8001_hba_info *pm8001_ha;struct Scsi_Host *shost =NULL ;const struct pm8001_chip_info *chip; +struct sas_ha_struct *sha;dev_printk (KERN_INFO , &pdev->dev,"pm80xx: driver version %s\n" ,DRV_VERSION );
@@ -1044,12 +1045,12 @@ static int pm8001_pci_probe(struct pci_dev *pdev, goto err_out_regions; } chip = &pm8001_chips[ent->driver_data]; -SHOST_TO_SAS_HA (shost) = -kzalloc (sizeof (struct sas_ha_struct ),GFP_KERNEL ); -if (!SHOST_TO_SAS_HA (shost)) { + sha =kzalloc (sizeof (struct sas_ha_struct ),GFP_KERNEL ); +if (!sha) { rc = -ENOMEM ; goto err_out_free_host; } +SHOST_TO_SAS_HA (shost) = sha; rc =pm8001_prep_sas_ha_init (shost, chip);if (rc) {
@@ -1070,7 +1071,7 @@ static int pm8001_pci_probe(struct pci_dev *pdev, "pm8001_setup_irq failed [ret: %d]\n", rc)); goto err_out_shost; } -list_add_tail (&pm8001_ha->list, &hba_list); +PM8001_CHIP_DISP ->chip_soft_rst (pm8001_ha); rc =PM8001_CHIP_DISP ->chip_init (pm8001_ha);if (rc) {
@@ -1105,8 +1106,12 @@ static int pm8001_pci_probe(struct pci_dev *pdev,pm8001_post_sas_ha_init (shost, chip); rc =sas_register_ha (SHOST_TO_SAS_HA (shost)); -if (rc) +if (rc) { +PM8001_FAIL_DBG (pm8001_ha,pm8001_printk ( +"sas_register_ha failed [ret: %d]\n" , rc)); goto err_out_shost; + } +list_add_tail (&pm8001_ha->list, &hba_list);scsi_scan_host (pm8001_ha->shost); pm8001_ha->flags =PM8001F_RUN_TIME ;return 0 ;
@@ -1116,7 +1121,7 @@ static int pm8001_pci_probe(struct pci_dev *pdev, err_out_ha_free:pm8001_free (pm8001_ha); err_out_free: -kfree (SHOST_TO_SAS_HA (shost)); +kfree (sha); err_out_free_host:scsi_host_put (shost); err_out_regions:
Signature · 1 line
2.16.3
Re: [PATCH 04/12] pm80xx : Cleanup initialization loading fail path.
Quoted 9 lines · Deepak Ukey
From: Peter Chang <[email protected]>
1)Move the instance tracking down after we think the instance is good to go. avoids having a use-after free.
2)There are goto targets for trying to cleanup if the hw fails to initialize, but there's some overlap depending on who thinks they own the sub-structures.
Quoted 8 lines
Signed-off-by Peter Chang <[email protected]>Signed-off-by Deepak Ukey <[email protected]>Signed-off-by Viswas G <[email protected]>Signed-off-by Vishakha Channapattan <[email protected]>Signed-off-by Bhavesh Jashnani <[email protected]>Signed-off-by Radha Ramachandran <[email protected]>Signed-off-by Akshat Jain <[email protected]>Signed-off-by Yu Zheng <[email protected]>
The patch looks fine,
Quoted 67 lines
--- drivers/scsi/pm8001/pm8001_init.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)drivers/scsi/pm8001/pm8001_init.c +11
-7@@ -1016,6 +1016,7 @@ static int pm8001_pci_probe(struct pci_dev *pdev,struct pm8001_hba_info *pm8001_ha;struct Scsi_Host *shost =NULL ;const struct pm8001_chip_info *chip; +struct sas_ha_struct *sha;dev_printk (KERN_INFO , &pdev->dev,"pm80xx: driver version %s\n" ,DRV_VERSION );@@ -1044,12 +1045,12 @@ static int pm8001_pci_probe(struct pci_dev *pdev, goto err_out_regions; } chip = &pm8001_chips[ent->driver_data]; -SHOST_TO_SAS_HA (shost) = -kzalloc (sizeof (struct sas_ha_struct ),GFP_KERNEL ); -if (!SHOST_TO_SAS_HA (shost)) { + sha =kzalloc (sizeof (struct sas_ha_struct ),GFP_KERNEL ); +if (!sha) { rc = -ENOMEM ; goto err_out_free_host; } +SHOST_TO_SAS_HA (shost) = sha; rc =pm8001_prep_sas_ha_init (shost, chip);if (rc) {@@ -1070,7 +1071,7 @@ static int pm8001_pci_probe(struct pci_dev *pdev, "pm8001_setup_irq failed [ret: %d]\n", rc)); goto err_out_shost; } -list_add_tail (&pm8001_ha->list, &hba_list); +PM8001_CHIP_DISP ->chip_soft_rst (pm8001_ha); rc =PM8001_CHIP_DISP ->chip_init (pm8001_ha);if (rc) {@@ -1105,8 +1106,12 @@ static int pm8001_pci_probe(struct pci_dev *pdev,pm8001_post_sas_ha_init (shost, chip); rc =sas_register_ha (SHOST_TO_SAS_HA (shost)); -if (rc) +if (rc) { +PM8001_FAIL_DBG (pm8001_ha,pm8001_printk ( +"sas_register_ha failed [ret: %d]\n" , rc)); goto err_out_shost; + } +list_add_tail (&pm8001_ha->list, &hba_list);scsi_scan_host (pm8001_ha->shost); pm8001_ha->flags =PM8001F_RUN_TIME ;return 0 ;@@ -1116,7 +1121,7 @@ static int pm8001_pci_probe(struct pci_dev *pdev, err_out_ha_free:pm8001_free (pm8001_ha); err_out_free: -kfree (SHOST_TO_SAS_HA (shost)); +kfree (sha); err_out_free_host:scsi_host_put (shost); err_out_regions: --2.16.3
PATCH 5/12 pm80xx : Support for char device.
In reply to Deepak UkeyFrom: Deepak Ukey <[email protected]>
Added the support to register char device for pm80xx module and also added the ioctl functionality to get driver info.
--- drivers/scsi/pm8001/pm8001_ctl.c | 148 ++++++++++++++++++++++++++++++++++++++ drivers/scsi/pm8001/pm8001_ctl.h | 33 +++++++++ drivers/scsi/pm8001/pm8001_init.c | 5 ++ drivers/scsi/pm8001/pm8001_sas.h | 6 ++ 4 files changed, 192 insertions(+)
drivers/scsi/pm8001/pm8001_ctl.c +148 -0
@@ -41,6 +41,7 @@#include <linux/slab.h> #include "pm8001_sas.h" #include "pm8001_ctl.h" +int pm80xx_major =-1 ;/* scsi host attributes */
@@ -845,3 +846,150 @@ struct device_attribute *pm8001_host_attrs[] = { NULL, }; +/* +* pm8001_open - open the configuration file +* @inode: inode being opened +* @file: file handle attached +* +* Called when the configuration device is opened. Does the needed +* set up on the handle and then returns +* +*/ +static int pm8001_open (struct inode *inode,struct file *file) +{ +struct pm8001_hba_info *pm8001_ha; +unsigned int minor_number =iminor (inode); +int err = -ENODEV ; + +list_for_each_entry (pm8001_ha, &hba_list, list) { +if (pm8001_ha->id == minor_number) { + file->private_data = pm8001_ha; + err =0 ; +break ; + } + } + +return err; +} + +/** +* pm8001_close - close the configuration file +* @inode: inode being opened +* @file: file handle attached +* +* Called when the configuration device is closed. Does the needed +* set up on the handle and then returns +* +*/ +static int pm8001_close (struct inode *inode,struct file *file) +{ +return 0 ; +} + +static long pm8001_info_ioctl (struct pm8001_hba_info *pm8001_ha, +unsigned long arg) +{ +u32 ret =0 ; +struct ioctl_info_buffer info_buf; + +strcpy (info_buf.information.sz_name,DRV_NAME ); + + info_buf.information.usmajor_revision =DRV_MAJOR ; + info_buf.information.usminor_revision =DRV_MINOR ; + info_buf.information.usbuild_revision =DRV_BUILD ; +if (pm8001_ha->chip_id == chip_8001) { + info_buf.information.maxoutstandingIO = + pm8001_ha->main_cfg_tbl.pm8001_tbl.max_out_io; + info_buf.information.maxdevices = + (pm8001_ha->main_cfg_tbl.pm8001_tbl.max_sgl >>16 ) & +0xFFFF ; + }else { + info_buf.information.maxoutstandingIO = + pm8001_ha->main_cfg_tbl.pm80xx_tbl.max_out_io; + info_buf.information.maxdevices = + (pm8001_ha->main_cfg_tbl.pm80xx_tbl.max_sgl >>16 ) & +0xFFFF ; + } + info_buf.header.return_code =ADPT_IOCTL_CALL_SUCCESS ; + +if (copy_to_user ((void *)arg, (void *)&info_buf, +sizeof (struct ioctl_info_buffer ))) { + ret =ADPT_IOCTL_CALL_FAILED ; + } +return ret; +} + +/** +* pm8001_ioctl - pm8001 configuration request +* @inode: inode of device +* @file: file handle +* @cmd: ioctl command code +* @arg: argument +* +* Handles a configuration ioctl. +* +*/ +static long pm8001_ioctl (struct file *file, +unsigned int cmd,unsigned long arg) +{ +u32 ret = -EACCES ; +struct pm8001_hba_info *pm8001_ha; +struct ioctl_header header; + + pm8001_ha = file->private_data; + +switch (cmd) { +case ADPT_IOCTL_INFO : + ret =pm8001_info_ioctl (pm8001_ha, arg); +break ; +default : + ret =ADPT_IOCTL_CALL_INVALID_CODE ; + } + +if (ret ==0 ) +return ret; + header.return_code = ret; + ret = -EACCES ; +if (copy_to_user ((void *)arg, (void *)&header, +sizeof (struct ioctl_header ))) { +PM8001_FAIL_DBG (pm8001_ha, +pm8001_printk ("copy_to_user failed\n" )); + } +return ret; +} + +static const struct file_operations pm8001_fops = { + .owner =THIS_MODULE , + .open = pm8001_open, + .release = pm8001_close, + .unlocked_ioctl = pm8001_ioctl, +}; + +/** +* pm8001_setup_chrdev - register char device +* Return value: +* 0 in case of success, otherwise non-zero value +*/ +int pm8001_setup_chrdev (void ) +{ + pm80xx_major =register_chrdev (0 ,DRV_NAME , &pm8001_fops); +if (pm80xx_major <0 ) { +pr_warn ("pm8001: unable to register %s device.\n" , +DRV_NAME ); +return pm80xx_major; + } +return 0 ; +} + +/** +* pm8001_release_chrdev - unregisters per-adapter management interface +* Return value: +* none +*/ +void pm8001_release_chrdev (void ) +{ +if (pm80xx_major >-1 ) { +unregister_chrdev (pm80xx_major,DRV_NAME ); + pm80xx_major =-1 ; + } +}
drivers/scsi/pm8001/pm8001_ctl.h +33 -0
@@ -59,5 +59,38 @@#define SYSFS_OFFSET 1024#define PM80XX_IB_OB_QUEUE_SIZE (32 * 1024)#define PM8001_IB_OB_QUEUE_SIZE (16 * 1024) + +#define ADPT_IOCTL_CALL_SUCCESS 0x00 +#define ADPT_IOCTL_CALL_FAILED 0x01 +#define ADPT_IOCTL_CALL_INVALID_CODE 0x03 + +struct ioctl_header { +u32 io_controller_num; +u32 length; +u32 return_code; +u32 timeout; +u16 direction; +}; + +struct ioctl_drv_info { +u8 sz_name[64 ]; +u16 usmajor_revision; +u16 usminor_revision; +u16 usbuild_revision; +u16 reserved0; +u32 maxdevices; +u32 maxoutstandingIO; +u32 reserved[16 ]; +}; + +struct ioctl_info_buffer { +struct ioctl_header header; +struct ioctl_drv_info information; +}; + +#define ADPT_IOCTL_INFO _IOR(ADPT_MAGIC_NUMBER, 0, struct ioctl_info_buffer *) + +#define ADPT_MAGIC_NUMBER 'm' +#endif /* PM8001_CTL_H_INCLUDED */
drivers/scsi/pm8001/pm8001_init.c +5 -0
@@ -1421,6 +1421,9 @@ static int __init pm8001_init(void) pm8001_stt =sas_domain_attach_transport (&pm8001_transport_ops);if (!pm8001_stt) goto err_wq; + rc =pm8001_setup_chrdev (); +if (rc) + goto err_ctl; rc =pci_register_driver (&pm8001_pci_driver);if (rc) goto err_tp;
@@ -1428,6 +1431,8 @@ static int __init pm8001_init(void) err_tp:sas_release_transport (pm8001_stt); +err_ctl: +pm8001_release_chrdev (); err_wq:destroy_workqueue (pm8001_wq); err:
drivers/scsi/pm8001/pm8001_sas.h +6 -0
@@ -59,6 +59,9 @@#define DRV_NAME "pm80xx"#define DRV_VERSION "0.1.39" +#define DRV_MAJOR 1 +#define DRV_MINOR 3 +#define DRV_BUILD 0#define PM8001_FAIL_LOGGING 0x01/* Error message logging */ #define PM8001_INIT_LOGGING 0x02/* driver init logging */ #define PM8001_DISC_LOGGING 0x04/* discovery layer logging */
@@ -745,6 +748,9 @@ ssize_t pm8001_get_gsm_dump(struct device *cdev, u32, char *buf);/* ctl shared API */ extern struct device_attribute *pm8001_host_attrs[]; +int pm8001_setup_chrdev (void ); +void pm8001_release_chrdev (void ); + static inline void pm8001_ccb_task_free_done(struct pm8001_hba_info *pm8001_ha, struct sas_task *task, struct pm8001_ccb_info *ccb,
Signature · 1 line
2.16.3
Jinpu Wang
maintainerRe: [PATCH 05/12] pm80xx : Support for char device.
Quoted 5 lines · Deepak Ukey
From: Deepak Ukey <[email protected]>
Added the support to register char device for pm80xx module and also added the ioctl functionality to get driver info.
Please describe why do you need a char device, also the use case for this get driver info functionality.
Quoted 8 lines
Signed-off-by Deepak Ukey <[email protected]>Signed-off-by Viswas G <[email protected]>Signed-off-by Vishakha Channapattan <[email protected]>Signed-off-by Bhavesh Jashnani <[email protected]>Signed-off-by Radha Ramachandran <[email protected]>Signed-off-by Akshat Jain <[email protected]>Signed-off-by Yu Zheng <[email protected]>
PATCH 6/12 pm80xx : sysfs attribute for number of phys.
In reply to Deepak UkeyFrom: Viswas G <[email protected]>
Added sysfs attribute to show number of phys.
--- drivers/scsi/pm8001/pm8001_ctl.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/scsi/pm8001/pm8001_ctl.c +20 -0
@@ -89,6 +89,25 @@ static ssize_t controller_fatal_error_show(struct device *cdev, }static DEVICE_ATTR_RO (controller_fatal_error); +/** +* pm8001_ctl_num_phys_show - Number of phys +* @cdev:pointer to embedded class device +* @buf:the buffer returned +* A sysfs 'read-only' shost attribute. +*/ +static ssize_t num_phys_show (struct device *cdev, +struct device_attribute *attr,char *buf) +{ +int ret; +struct Scsi_Host *shost =class_to_shost (cdev); +struct sas_ha_struct *sha =SHOST_TO_SAS_HA (shost); +struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; + + ret =sprintf (buf,"%d" , pm8001_ha->chip->n_phy); +return ret; +} +static DEVICE_ATTR_RO (num_phys); +/** * pm8001_ctl_fw_version_show - firmware version * @cdev: pointer to embedded class device
@@ -825,6 +844,7 @@ static DEVICE_ATTR(update_fw, S_IRUGO|S_IWUSR|S_IWGRP,struct device_attribute *pm8001_host_attrs[] = { &dev_attr_interface_rev, &dev_attr_controller_fatal_error, + &dev_attr_num_phys, &dev_attr_fw_version, &dev_attr_update_fw, &dev_attr_aap_log,
Signature · 1 line
2.16.3
Jinpu Wang
maintainerRe: [PATCH 06/12] pm80xx : sysfs attribute for number of phys.
Quoted 22 lines · Deepak Ukey
From: Viswas G <[email protected]>
Added sysfs attribute to show number of phys.
Signed-off-by Deepak Ukey <[email protected]>Signed-off-by Viswas G <[email protected]>Signed-off-by Vishakha Channapattan <[email protected]>Signed-off-by Bhavesh Jashnani <[email protected]>Signed-off-by Radha Ramachandran <[email protected]>Signed-off-by Akshat Jain <[email protected]>Signed-off-by Yu Zheng <[email protected]>--- drivers/scsi/pm8001/pm8001_ctl.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)drivers/scsi/pm8001/pm8001_ctl.c +0
-0@@ -89,6 +89,25 @@ static ssize_t controller_fatal_error_show(struct device *cdev, }
drivers/scsi/pm8001/pm8001_ctl.c static ssize_t controller_fatal_error_show(struct device *cdev, · line 99
Quoted 10 lines
drivers/scsi/pm8001/pm8001_ctl.c +8
-0static DEVICE_ATTR_RO (controller_fatal_error); +/** +* pm8001_ctl_num_phys_show - Number of phys +* @cdev:pointer to embedded class device +* @buf:the buffer returned +* A sysfs 'read-only' shost attribute. +*/ +static ssize_t num_phys_show (struct device *cdev, +struct device_attribute *attr,char *buf)
please use pm8001_ctl_num_phys_show as function name, so it follows same conversion as other functions.
Better also rename controller_fatal_error too.
Thanks
Quoted 25 lines
drivers/scsi/pm8001/pm8001_ctl.c +12
-1+{ +int ret; +struct Scsi_Host *shost =class_to_shost (cdev); +struct sas_ha_struct *sha =SHOST_TO_SAS_HA (shost); +struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; + + ret =sprintf (buf,"%d" , pm8001_ha->chip->n_phy); +return ret; +} +static DEVICE_ATTR_RO (num_phys); +/** * pm8001_ctl_fw_version_show - firmware version * @cdev: pointer to embedded class device @@ -825,6 +844,7 @@ static DEVICE_ATTR(update_fw, S_IRUGO|S_IWUSR|S_IWGRP,struct device_attribute *pm8001_host_attrs[] = { &dev_attr_interface_rev, &dev_attr_controller_fatal_error, + &dev_attr_num_phys, &dev_attr_fw_version, &dev_attr_update_fw, &dev_attr_aap_log, --2.16.3
Re: [PATCH 06/12] pm80xx : sysfs attribute for number of phys.
Quoted 25 lines · Jinpu Wang
Quoted 24 lines · Deepak Ukey
From: Viswas G <[email protected]>
Added sysfs attribute to show number of phys.
Signed-off-by Deepak Ukey <[email protected]>Signed-off-by Viswas G <[email protected]>Signed-off-by Vishakha Channapattan <[email protected]>Signed-off-by Bhavesh Jashnani <[email protected]>Signed-off-by Radha Ramachandran <[email protected]>Signed-off-by Akshat Jain <[email protected]>Signed-off-by Yu Zheng <[email protected]>--- drivers/scsi/pm8001/pm8001_ctl.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)drivers/scsi/pm8001/pm8001_ctl.c +0
-0@@ -89,6 +89,25 @@ static ssize_t controller_fatal_error_show(struct device *cdev, }static DEVICE_ATTR_RO (controller_fatal_error);
Quoted 11 lines
drivers/scsi/pm8001/pm8001_ctl.c static ssize_t controller_fatal_error_show(struct device *cdev, · line 99
Quoted 8 lines
drivers/scsi/pm8001/pm8001_ctl.c +8
-0+/** +* pm8001_ctl_num_phys_show - Number of phys +* @cdev:pointer to embedded class device +* @buf:the buffer returned +* A sysfs 'read-only' shost attribute. +*/ +static ssize_t num_phys_show (struct device *cdev, +struct device_attribute *attr,char *buf)please use
pm8001_ctl_num_phys_showas function name, so it follows same conversion as other functions.
Better also renamecontroller_fatal_errortoo.
If you don't mind me saying, this info is already available in sysfs for any libsas or even SAS host (using scsi_transport_sas.c), like this:
john@ubuntu:/sys/class/sas_phy$ ls phy-0:0 phy-0:0:12 phy-0:0:17 phy-0:0:21 phy-0:0:4 phy-0:0:9 phy-0:5 phy-0:0:0 phy-0:0:13 phy-0:0:18 phy-0:0:22 phy-0:0:5 phy-0:1 phy-0:6 phy-0:0:1 phy-0:0:14 phy-0:0:19 phy-0:0:23 phy-0:0:6 phy-0:2 phy-0:7 phy-0:0:10 phy-0:0:15 phy-0:0:2 phy-0:0:24 phy-0:0:7 phy-0:3 phy-0:0:11 phy-0:0:16 phy-0:0:20 phy-0:0:3 phy-0:0:8 phy-0:4
Any phy-X:Y is a root phy, and X denotes the host index and Y is the phy index.
Quoted 29 lines
Thanks
Quoted 23 lines
drivers/scsi/pm8001/pm8001_ctl.c +12
-1+{ +int ret; +struct Scsi_Host *shost =class_to_shost (cdev); +struct sas_ha_struct *sha =SHOST_TO_SAS_HA (shost); +struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; + + ret =sprintf (buf,"%d" , pm8001_ha->chip->n_phy); +return ret; +} +static DEVICE_ATTR_RO (num_phys); +/** * pm8001_ctl_fw_version_show - firmware version * @cdev: pointer to embedded class device @@ -825,6 +844,7 @@ static DEVICE_ATTR(update_fw, S_IRUGO|S_IWUSR|S_IWGRP,struct device_attribute *pm8001_host_attrs[] = { &dev_attr_interface_rev, &dev_attr_controller_fatal_error, + &dev_attr_num_phys, &dev_attr_fw_version, &dev_attr_update_fw, &dev_attr_aap_log, --Quoted 2 lines
2.16.3
.
RE: [PATCH 06/12] pm80xx : sysfs attribute for number of phys.
Thanks John Garry. The intention here is to get the total number of phys for the controller through sysfs and it is used by the management utility as well.
Regards,
Viswas G
-----Original Message-----
From: John Garry <[email protected]>
Sent: Thursday, January 2, 2020 6:03 PM
To: Jinpu Wang <[email protected]>; Deepak Ukey - I31172 <[email protected]>
Cc: Linux SCSI Mailinglist <[email protected]>; Vasanthalakshmi Tharmarajan - I30664 <[email protected]>; Viswas G - I30667 <[email protected]>; Jack Wang <[email protected]>; Martin K. Petersen <[email protected]>; [email protected]; [email protected]; Vikram Auradkar <[email protected]>; [email protected]; [email protected]; Radha Ramachandran <[email protected]>; [email protected]
Subject: Re: [PATCH 06/12] pm80xx : sysfs attribute for number of phys.
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Quoted 26 lines · Jinpu Wang
Quoted 25 lines · Deepak Ukey
From: Viswas G <mailto:[email protected]>
Added sysfs attribute to show number of phys.
Signed-off-by Deepak Ukey <mailto:[email protected]>Signed-off-by Viswas G <mailto:[email protected]>Signed-off-by Vishakha Channapattan <mailto:[email protected]>Signed-off-by Bhavesh Jashnani <mailto:[email protected]>Signed-off-by Radha Ramachandran <mailto:[email protected]>Signed-off-by Akshat Jain <mailto:[email protected]>Signed-off-by Yu Zheng <mailto:[email protected]>--- drivers/scsi/pm8001/pm8001_ctl.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)drivers/scsi/pm8001/pm8001_ctl.c +0
-0@@ -89,6 +89,25 @@ static ssize_t controller_fatal_error_show(struct device *cdev, }static DEVICE_ATTR_RO (controller_fatal_error);
Quoted 11 lines
drivers/scsi/pm8001/pm8001_ctl.c static ssize_t controller_fatal_error_show(struct device *cdev, · line 99
Quoted 8 lines
drivers/scsi/pm8001/pm8001_ctl.c +8
-0+/** +* pm8001_ctl_num_phys_show - Number of phys +* @cdev:pointer to embedded class device +* @buf:the buffer returned +* A sysfs 'read-only' shost attribute. +*/ +static ssize_t num_phys_show (struct device *cdev, +struct device_attribute *attr,char *buf)please use
pm8001_ctl_num_phys_showas function name, so it follows same conversion as other functions.
Better also renamecontroller_fatal_errortoo.
If you don't mind me saying, this info is already available in sysfs for any libsas or even SAS host (using scsi_transport_sas.c), like this:
john@ubuntu:/sys/class/sas_phy$ ls phy-0:0 phy-0:0:12 phy-0:0:17 phy-0:0:21 phy-0:0:4 phy-0:0:9 phy-0:5 phy-0:0:0 phy-0:0:13 phy-0:0:18 phy-0:0:22 phy-0:0:5 phy-0:1 phy-0:6 phy-0:0:1 phy-0:0:14 phy-0:0:19 phy-0:0:23 phy-0:0:6 phy-0:2 phy-0:7 phy-0:0:10 phy-0:0:15 phy-0:0:2 phy-0:0:24 phy-0:0:7 phy-0:3 phy-0:0:11 phy-0:0:16 phy-0:0:20 phy-0:0:3 phy-0:0:8 phy-0:4
Any phy-X:Y is a root phy, and X denotes the host index and Y is the phy index.
Quoted 29 lines
Thanks
Quoted 19 lines
drivers/scsi/pm8001/pm8001_ctl.c +11
-0+{ +int ret; +struct Scsi_Host *shost =class_to_shost (cdev); +struct sas_ha_struct *sha =SHOST_TO_SAS_HA (shost); +struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; + + ret =sprintf (buf,"%d" , pm8001_ha->chip->n_phy); +return ret; +} +static DEVICE_ATTR_RO (num_phys); +/** * pm8001_ctl_fw_version_show - firmware version * @cdev: pointer to embedded class device @@ -825,6 +844,7 @@ static DEVICE_ATTR(update_fw, S_IRUGO|S_IWUSR|S_IWGRP,
structdevice_attribute*pm8001_host_attrs[] = {
&dev_attr_interface_rev,&dev_attr_controller_fatal_error,
+&dev_attr_num_phys,Quoted 6 lines
&dev_attr_fw_version, &dev_attr_update_fw, &dev_attr_aap_log,--
2.16.3.
RE: [PATCH 06/12] pm80xx : sysfs attribute for number of phys.
Hi Jinpu,
please use pm8001_ctl_num_phys_show as function name, so it follows
Quoted 2 lines
same conversion as other functions.
Better also renamecontroller_fatal_errortoo.
If I tried to keep the function name as pm8001_ctl_num_phys_show as other function follows then checkpatch.pl gives the below warning.
------
WARNING: Consider renaming function(s) 'pm8001_ctl_num_phys_show' to 'num_phys_show' #37: FILE: drivers/scsi/pm8001/pm8001_ctl.c:108:
+}
total: 0 errors, 1 warnings, 32 lines checked
-------
That’s the only reason I have changes the function name. For making the other function with same naming convention, I will change the function name of all other function like num_phys_show' and we will submit this patch in our upcoming patch set.
Regards,
Deepak
-----Original Message-----
From: Viswas G - I30667
Sent: Thursday, January 2, 2020 10:09 PM
To: John Garry <[email protected]>; Jinpu Wang <[email protected]>; Deepak Ukey - I31172 <[email protected]>
Cc: Linux SCSI Mailinglist <[email protected]>; Vasanthalakshmi Tharmarajan - I30664 <[email protected]>; Jack Wang <[email protected]>; Martin K. Petersen <[email protected]>; [email protected]; [email protected]; Vikram Auradkar <[email protected]>; [email protected]; [email protected]; Radha Ramachandran <[email protected]>; [email protected]
Subject: RE: [PATCH 06/12] pm80xx : sysfs attribute for number of phys.
Thanks John Garry. The intention here is to get the total number of phys for the controller through sysfs and it is used by the management utility as well.
Regards,
Viswas G
-----Original Message-----
From: John Garry <[email protected]>
Sent: Thursday, January 2, 2020 6:03 PM
To: Jinpu Wang <[email protected]>; Deepak Ukey - I31172 <[email protected]>
Cc: Linux SCSI Mailinglist <[email protected]>; Vasanthalakshmi Tharmarajan - I30664 <[email protected]>; Viswas G - I30667 <[email protected]>; Jack Wang <[email protected]>; Martin K. Petersen <[email protected]>; [email protected]; [email protected]; Vikram Auradkar <[email protected]>; [email protected]; [email protected]; Radha Ramachandran <[email protected]>; [email protected]
Subject: Re: [PATCH 06/12] pm80xx : sysfs attribute for number of phys.
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Quoted 26 lines · Jinpu Wang
Quoted 25 lines · Deepak Ukey
From: Viswas G <mailto:[email protected]>
Added sysfs attribute to show number of phys.
Signed-off-by Deepak Ukey <mailto:[email protected]>Signed-off-by Viswas G <mailto:[email protected]>Signed-off-by Vishakha Channapattan <mailto:[email protected]>Signed-off-by Bhavesh Jashnani <mailto:[email protected]>Signed-off-by Radha Ramachandran <mailto:[email protected]>Signed-off-by Akshat Jain <mailto:[email protected]>Signed-off-by Yu Zheng <mailto:[email protected]>--- drivers/scsi/pm8001/pm8001_ctl.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)drivers/scsi/pm8001/pm8001_ctl.c +0
-0@@ -89,6 +89,25 @@ static ssize_t controller_fatal_error_show(struct device *cdev, }static DEVICE_ATTR_RO (controller_fatal_error);
Quoted 11 lines
drivers/scsi/pm8001/pm8001_ctl.c static ssize_t controller_fatal_error_show(struct device *cdev, · line 99
Quoted 8 lines
drivers/scsi/pm8001/pm8001_ctl.c +8
-0+/** +* pm8001_ctl_num_phys_show - Number of phys +* @cdev:pointer to embedded class device +* @buf:the buffer returned +* A sysfs 'read-only' shost attribute. +*/ +static ssize_t num_phys_show (struct device *cdev, +struct device_attribute *attr,char *buf)please use
pm8001_ctl_num_phys_showas function name, so it follows same conversion as other functions.
Better also renamecontroller_fatal_errortoo.
If you don't mind me saying, this info is already available in sysfs for any libsas or even SAS host (using scsi_transport_sas.c), like this:
john@ubuntu:/sys/class/sas_phy$ ls phy-0:0 phy-0:0:12 phy-0:0:17 phy-0:0:21 phy-0:0:4 phy-0:0:9 phy-0:5 phy-0:0:0 phy-0:0:13 phy-0:0:18 phy-0:0:22 phy-0:0:5 phy-0:1 phy-0:6 phy-0:0:1 phy-0:0:14 phy-0:0:19 phy-0:0:23 phy-0:0:6 phy-0:2 phy-0:7 phy-0:0:10 phy-0:0:15 phy-0:0:2 phy-0:0:24 phy-0:0:7 phy-0:3 phy-0:0:11 phy-0:0:16 phy-0:0:20 phy-0:0:3 phy-0:0:8 phy-0:4
Any phy-X:Y is a root phy, and X denotes the host index and Y is the phy index.
Quoted 29 lines
Thanks
Quoted 19 lines
drivers/scsi/pm8001/pm8001_ctl.c +11
-0+{ +int ret; +struct Scsi_Host *shost =class_to_shost (cdev); +struct sas_ha_struct *sha =SHOST_TO_SAS_HA (shost); +struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; + + ret =sprintf (buf,"%d" , pm8001_ha->chip->n_phy); +return ret; +} +static DEVICE_ATTR_RO (num_phys); +/** * pm8001_ctl_fw_version_show - firmware version * @cdev: pointer to embedded class device @@ -825,6 +844,7 @@ static DEVICE_ATTR(update_fw, S_IRUGO|S_IWUSR|S_IWGRP,
structdevice_attribute*pm8001_host_attrs[] = {
&dev_attr_interface_rev,&dev_attr_controller_fatal_error,
+&dev_attr_num_phys,Quoted 6 lines
&dev_attr_fw_version, &dev_attr_update_fw, &dev_attr_aap_log,--
2.16.3.
Jinpu Wang
maintainerRe: [PATCH 06/12] pm80xx : sysfs attribute for number of phys.
Quoted 14 lines · On Mon, Jan 13, 2020 at 10:26 AM <[email protected]> wrote:
Hi Jinpu,
please use
pm8001_ctl_num_phys_showas function name, so it followsQuoted 2 lines
same conversion as other functions.
Better also renamecontroller_fatal_errortoo.If I tried to keep the function name as
pm8001_ctl_num_phys_showas other function follows then checkpatch.pl gives the below warning.------
WARNING: Consider renaming function(s) 'pm8001_ctl_num_phys_show' to 'num_phys_show' #37: FILE:drivers/scsi/pm8001/pm8001_ctl.c:108:
+}
Quoted 7 lines
total: 0 errors, 1 warnings, 32 lines checked
-------That’s the only reason I have changes the function name. For making the other function with same naming convention, I will change the function name of all other function like
num_phys_show' and we will submit this patch in our upcoming patch set.Regards,
Deepak
Thanks for checking, then we can do it later.
PS: please avoid top-posting.
PATCH 7/12 pm80xx : IOCTL functionality to get phy profile.
In reply to Deepak UkeyFrom: Viswas G <[email protected]>
Added the ioctl functionality to collect phy status and phy error.
--- drivers/scsi/pm8001/pm8001_ctl.c | 145 +++++++++++++++++++++++++++++++++++++++ drivers/scsi/pm8001/pm8001_ctl.h | 35 +++++++++- drivers/scsi/pm8001/pm8001_sas.h | 9 +++ drivers/scsi/pm8001/pm80xx_hwi.c | 82 ++++++++++++++++++++++ drivers/scsi/pm8001/pm80xx_hwi.h | 2 + 5 files changed, 272 insertions(+), 1 deletion(-)
drivers/scsi/pm8001/pm8001_ctl.c +145 -0
@@ -41,6 +41,8 @@#include <linux/slab.h> #include "pm8001_sas.h" #include "pm8001_ctl.h" +#include "pm80xx_hwi.h" +int pm80xx_major =-1 ;/* scsi host attributes */
@@ -939,6 +941,143 @@ static long pm8001_info_ioctl(struct pm8001_hba_info *pm8001_ha,return ret; } +static int pm8001_ioctl_get_phy_profile (struct pm8001_hba_info *pm8001_ha, +unsigned long arg) +{ +struct phy_profile phy_prof[MAX_NUM_PHYS ]; +int nphys; +DECLARE_COMPLETION_ONSTACK (completion); +unsigned long timeout =msecs_to_jiffies (2000 ); +u32 ret =0 , i; +int page_code =SAS_PHY_GENERAL_STATUS_PAGE ; + +if (pm8001_ha->pdev->device ==0x8001 || + pm8001_ha->pdev->device ==0x8081 ) { +return ADPT_IOCTL_CALL_INVALID_DEVICE ; + } + +if (copy_from_user (&phy_prof[0 ], (struct phy_profile *)arg, +sizeof (struct phy_profile ))) { +PM8001_FAIL_DBG (pm8001_ha, +pm8001_printk ("copy_from_user failed\n" )); +return ADPT_IOCTL_CALL_FAILED ; + } + +mutex_lock (&pm8001_ha->ioctl_mutex); + nphys = phy_prof[0 ].phy_id; +if (nphys ==-1 ) { +for (i =0 ; i < pm8001_ha->chip->n_phy; i++) { + pm8001_ha->ioctl_completion = &completion; + ret =PM8001_CHIP_DISP ->get_phy_profile_req (pm8001_ha, + i, page_code); +if (ret !=0 ) { +PM8001_FAIL_DBG (pm8001_ha,pm8001_printk ( +"Get phy profile request failed\n" )); + ret =ADPT_IOCTL_CALL_FAILED ; + goto exit; + } + timeout =wait_for_completion_timeout (&completion, + timeout); +if (timeout ==0 ) { + ret =ADPT_IOCTL_CALL_FAILED ; + goto exit; + } +memcpy ((void *)&phy_prof[i], + (void *)&pm8001_ha->phy_profile_resp, +sizeof (struct phy_profile )); + } + +if (copy_to_user ((void *)arg, (void *)&phy_prof, +sizeof (struct phy_profile ) * (i))) { +PM8001_FAIL_DBG (pm8001_ha, +pm8001_printk ("copy_to_user failed\n" )); + ret =ADPT_IOCTL_CALL_FAILED ; + } + }else { + pm8001_ha->ioctl_completion = &completion; + ret =PM8001_CHIP_DISP ->get_phy_profile_req (pm8001_ha, + nphys, page_code); +if (ret !=0 ) { +PM8001_FAIL_DBG (pm8001_ha,pm8001_printk ( +"Get phy profile request failed\n" )); + ret =ADPT_IOCTL_CALL_FAILED ; + goto exit; + } + timeout =wait_for_completion_timeout (&completion, + timeout); +if (timeout ==0 ) { + ret =ADPT_IOCTL_CALL_FAILED ; + goto exit; + } + +if (copy_to_user ((void *)arg, + (void *)&pm8001_ha->phy_profile_resp, +sizeof (struct phy_profile ))) { +PM8001_FAIL_DBG (pm8001_ha, +pm8001_printk ("copy_to_user failed\n" )); + ret =ADPT_IOCTL_CALL_FAILED ; + } + } +exit: +spin_lock_irq (&pm8001_ha->ioctl_lock); + pm8001_ha->ioctl_completion =NULL ; +spin_unlock_irq (&pm8001_ha->ioctl_lock); +mutex_unlock (&pm8001_ha->ioctl_mutex); +return ret; +} + +static int pm8001_ioctl_get_phy_err (struct pm8001_hba_info *pm8001_ha, +unsigned long arg) +{ +struct phy_errcnt phy_err[MAX_NUM_PHYS ]; +DECLARE_COMPLETION_ONSTACK (completion); +unsigned long timeout =msecs_to_jiffies (2000 ); +u32 ret =0 , i; +int page_code =SAS_PHY_ERR_COUNTERS_PAGE ; +/*6H card does not support phyerr*/ +if (pm8001_ha->pdev->device ==0x8001 || + pm8001_ha->pdev->device ==0x8081 ) { +return ADPT_IOCTL_CALL_INVALID_DEVICE ; + } + +mutex_lock (&pm8001_ha->ioctl_mutex); + +for (i =0 ; i < pm8001_ha->chip->n_phy; i++) { + pm8001_ha->ioctl_completion = &completion; + ret =PM8001_CHIP_DISP ->get_phy_profile_req (pm8001_ha, + i, page_code); +if (ret !=0 ) { +PM8001_FAIL_DBG (pm8001_ha,pm8001_printk ( +"Get phy profile request failed\n" )); + ret =ADPT_IOCTL_CALL_FAILED ; + goto exit; + } + timeout =wait_for_completion_timeout (&completion, + timeout); +if (timeout ==0 ) { + ret =ADPT_IOCTL_CALL_FAILED ; + goto exit; + } +memcpy ((void *)&phy_err[i], + (void *)&pm8001_ha->phy_profile_resp, +sizeof (struct phy_errcnt )); + } + +if (copy_to_user ((void *)arg, (void *)&phy_err, +sizeof (struct phy_errcnt ) * (i))) { +PM8001_FAIL_DBG (pm8001_ha, +pm8001_printk ("copy_to_user failed\n" )); + ret =ADPT_IOCTL_CALL_FAILED ; + } + +exit: +spin_lock_irq (&pm8001_ha->ioctl_lock); + pm8001_ha->ioctl_completion =NULL ; +spin_unlock_irq (&pm8001_ha->ioctl_lock); +mutex_unlock (&pm8001_ha->ioctl_mutex); +return ret; +} +/** * pm8001_ioctl - pm8001 configuration request * @inode: inode of device
@@ -962,6 +1101,12 @@ static long pm8001_ioctl(struct file *file,case ADPT_IOCTL_INFO : ret =pm8001_info_ioctl (pm8001_ha, arg);break ; +case ADPT_IOCTL_GET_PHY_PROFILE : + ret =pm8001_ioctl_get_phy_profile (pm8001_ha, arg); +return ret; +case ADPT_IOCTL_GET_PHY_ERR_CNT : + ret =pm8001_ioctl_get_phy_err (pm8001_ha, arg); +break ;default : ret =ADPT_IOCTL_CALL_INVALID_CODE ; }
drivers/scsi/pm8001/pm8001_ctl.h +34 -1
@@ -63,6 +63,9 @@#define ADPT_IOCTL_CALL_SUCCESS 0x00#define ADPT_IOCTL_CALL_FAILED 0x01#define ADPT_IOCTL_CALL_INVALID_CODE 0x03 +#define ADPT_IOCTL_CALL_INVALID_DEVICE 0x04 + +#define MAX_NUM_PHYS 16struct ioctl_header {u32 io_controller_num;
@@ -88,8 +91,38 @@ struct ioctl_info_buffer { struct ioctl_drv_info information; }; -#define ADPT_IOCTL_INFO _IOR(ADPT_MAGIC_NUMBER, 0, struct ioctl_info_buffer *) +struct phy_profile { +char phy_id; +unsigned int phys: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; + +struct phy_errcnt { +unsigned int InvalidDword; +unsigned int runningDisparityError; +unsigned int codeViolation; +unsigned int LossOfSyncDW; +unsigned int phyResetProblem; +unsigned int inboundCRCError; +}; +struct phy_prof_resp { +union { +struct phy_profile status; +struct phy_errcnt errcnt; + } phy; +}; + +#define ADPT_IOCTL_INFO _IOR(ADPT_MAGIC_NUMBER, 0, struct ioctl_info_buffer *) +#define ADPT_IOCTL_GET_PHY_PROFILE _IOWR(ADPT_MAGIC_NUMBER, 8, \ + struct phy_profile*) +#define ADPT_IOCTL_GET_PHY_ERR_CNT _IOWR(ADPT_MAGIC_NUMBER, 9, \ + struct phy_err*)#define ADPT_MAGIC_NUMBER 'm'#endif /* PM8001_CTL_H_INCLUDED */
drivers/scsi/pm8001/pm8001_sas.h +9 -0
@@ -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"
@@ -246,6 +247,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 pm8001_chip_info {
@@ -560,6 +563,12 @@ struct pm8001_hba_info {bool controller_fatal_error;const struct firmware *fw_image;struct isr_param irq_vector[PM8001_MAX_MSIX_VEC ]; +spinlock_t ioctl_lock; +struct mutex ioctl_mutex; +struct completion *ioctl_completion; +struct timer_list ioctl_timer; +u32 ioctl_timer_expired; +struct phy_prof_resp phy_profile_resp;u32 reset_in_progress; };
drivers/scsi/pm8001/pm80xx_hwi.c +82 -0
101 lines not on this page · raw message
drivers/scsi/pm8001/pm80xx_hwi.h +2 -0
@@ -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
Jinpu Wang
maintainerRe: [PATCH 07/12] pm80xx : IOCTL functionality to get phy profile.
Quoted 4 lines · Deepak Ukey
From: Viswas G <[email protected]>
Added the ioctl functionality to collect phy status and phy error.
Please split it to 2 patches, one for phy status and one for phy error
Thanks
RE: [PATCH 07/12] pm80xx : IOCTL functionality to get phy profile.
Thanks Jinpu Wang . We will address this in the v2 patch set.
Regards,
Viswas G
-----Original Message-----
From: Jinpu Wang <[email protected]>
Sent: Thursday, January 2, 2020 5:41 PM
To: Deepak Ukey - I31172 <[email protected]>
Cc: Linux SCSI Mailinglist <[email protected]>; Vasanthalakshmi Tharmarajan - I30664 <[email protected]>; Viswas G - I30667 <[email protected]>; Jack Wang <[email protected]>; Martin K. Petersen <[email protected]>; [email protected]; [email protected]; Vikram Auradkar <[email protected]>; [email protected]; [email protected]; Radha Ramachandran <[email protected]>; [email protected]
Subject: Re: [PATCH 07/12] pm80xx : IOCTL functionality to get phy profile.
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Quoted 4 lines · Deepak Ukey
From: Viswas G <[email protected]>
Added the ioctl functionality to collect phy status and phy error.
Please split it to 2 patches, one for phy status and one for phy error
Thanks
PATCH 8/12 pm80xx : IOCTL functionality for GPIO.
In reply to Deepak UkeyFrom: Deepak Ukey <[email protected]>
Added IOCTL functionality for GPIO.
The SPCv controller provides 24 GPIO signals. The first 12 signals [11:0] and the last 4 signals [23:20] are for customer use. Eight signals [19:12] are reserved for the SPCv controller firmware. Whenever the host performs GPIO setup or a read/write operation using the GPIO command the host needs to make sure that it does not disturb the GPIO configuration for the bits [19:12]. Each signal can be configured either as an input or as an output. When configured as an output, the host can use the GPIO Command to set the desired level. GPIO inputs can also be configured so that the SPCv controller sends the GPIO Event notification when specific GPIO events occur.
Different GPIO features implemented:
1) GPIO Pin Setup
2) GPIO Event Setup
3) GPIO Read
4) GPIO Write
--- drivers/scsi/pm8001/pm8001_ctl.c | 95 ++++++++++++++++++++++++++++++++++ drivers/scsi/pm8001/pm8001_ctl.h | 24 +++++++++ drivers/scsi/pm8001/pm8001_init.c | 6 +++ drivers/scsi/pm8001/pm8001_sas.h | 17 ++++++ drivers/scsi/pm8001/pm80xx_hwi.c | 106 ++++++++++++++++++++++++++++++++++++++ drivers/scsi/pm8001/pm80xx_hwi.h | 49 ++++++++++++++++++ 6 files changed, 297 insertions(+)
drivers/scsi/pm8001/pm8001_ctl.c +95 -0
@@ -39,6 +39,7 @@*/ #include <linux/firmware.h> #include <linux/slab.h> +#include <linux/poll.h> #include "pm8001_sas.h" #include "pm8001_ctl.h" #include "pm80xx_hwi.h"
@@ -941,6 +942,73 @@ static long pm8001_info_ioctl(struct pm8001_hba_info *pm8001_ha,return ret; } +static long pm8001_gpio_ioctl (struct pm8001_hba_info *pm8001_ha, +unsigned long arg) +{ +struct gpio_buffer buffer; +struct pm8001_gpio *payload; +struct gpio_ioctl_resp *gpio_resp; +DECLARE_COMPLETION_ONSTACK (completion); +unsigned long timeout; +u32 ret =0 , operation; + +if (pm8001_ha->pdev->subsystem_vendor ==PCI_VENDOR_ID_ADAPTEC2 ) +return ADPT_IOCTL_CALL_INVALID_DEVICE ; + +if (copy_from_user (&buffer, (struct gpio_buffer *)arg, +sizeof (struct gpio_buffer ))) { + ret =ADPT_IOCTL_CALL_FAILED ; + } +mutex_lock (&pm8001_ha->ioctl_mutex); + pm8001_ha->ioctl_completion = &completion; + payload = &buffer.gpio_payload; + operation = payload->operation; + ret =PM8001_CHIP_DISP ->gpio_req (pm8001_ha, payload); +if (ret !=0 ) { + ret =ADPT_IOCTL_CALL_FAILED ; + goto exit; + } + + timeout = (unsigned long )buffer.header.timeout *1000 ; +if (timeout <2000 ) + timeout =2000 ; + + timeout =wait_for_completion_timeout (&completion, +msecs_to_jiffies (timeout)); +if (timeout ==0 ) { + ret =ADPT_IOCTL_CALL_TIMEOUT ; + goto exit; + } + gpio_resp = &pm8001_ha->gpio_resp; + buffer.header.return_code =ADPT_IOCTL_CALL_SUCCESS ; + +if (operation ==GPIO_READ ) { + payload->rd_wr_val = gpio_resp->gpio_rd_val; + payload->input_enable = gpio_resp->gpio_in_enabled; + payload->pinsetup1 = gpio_resp->gpio_pinsetup1; + payload->pinsetup2 = gpio_resp->gpio_pinsetup2; + payload->event_level = gpio_resp->gpio_evt_change; + payload->event_rising_edge = gpio_resp->gpio_evt_rise; + payload->event_falling_edge = gpio_resp->gpio_evt_fall; + +if (copy_to_user ((void *)arg, (void *)&buffer, +sizeof (struct gpio_buffer ))) { + ret =ADPT_IOCTL_CALL_FAILED ; + } + }else { +if (copy_to_user ((void *)arg, (void *)&buffer.header, +sizeof (struct ioctl_header ))) { + ret =ADPT_IOCTL_CALL_FAILED ; + } + } +exit: +spin_lock_irq (&pm8001_ha->ioctl_lock); + pm8001_ha->ioctl_completion =NULL ; +spin_unlock_irq (&pm8001_ha->ioctl_lock); +mutex_unlock (&pm8001_ha->ioctl_mutex); +return ret; +} +static int pm8001_ioctl_get_phy_profile (struct pm8001_hba_info *pm8001_ha,unsigned long arg) {
@@ -1101,6 +1169,9 @@ static long pm8001_ioctl(struct file *file,case ADPT_IOCTL_INFO : ret =pm8001_info_ioctl (pm8001_ha, arg);break ; +case ADPT_IOCTL_GPIO : + ret =pm8001_gpio_ioctl (pm8001_ha, arg); +break ;case ADPT_IOCTL_GET_PHY_PROFILE : ret =pm8001_ioctl_get_phy_profile (pm8001_ha, arg);return ret;
@@ -1123,11 +1194,35 @@ static long pm8001_ioctl(struct file *file,return ret; } +/** +*pm8001_poll - pm8001 poll request function +*@file: file handle +*@wait: poll table to wait +*Handles a poll request. +*/ +__poll_t pm8001_poll (struct file *file,poll_table *wait) +{ +struct pm8001_hba_info *pm8001_ha; +__poll_t mask =0 ; + + pm8001_ha = file->private_data; + +poll_wait (file, &pm8001_ha->pollq, wait); + +if (pm8001_ha->gpio_event_occurred ==1 ) { + pm8001_ha->gpio_event_occurred =0 ; + mask |=POLLIN |POLLRDNORM ; + } + +return mask; +} +static const struct file_operations pm8001_fops = { .owner =THIS_MODULE , .open = pm8001_open, .release = pm8001_close, .unlocked_ioctl = pm8001_ioctl, + .poll = pm8001_poll, };/**
drivers/scsi/pm8001/pm8001_ctl.h +24 -0
@@ -64,6 +64,7 @@#define ADPT_IOCTL_CALL_FAILED 0x01#define ADPT_IOCTL_CALL_INVALID_CODE 0x03#define ADPT_IOCTL_CALL_INVALID_DEVICE 0x04 +#define ADPT_IOCTL_CALL_TIMEOUT 0x08#define MAX_NUM_PHYS 16
@@ -86,11 +87,33 @@ struct ioctl_drv_info {u32 reserved[16 ]; }; +#define GPIO_READ 0 +#define GPIO_WRITE 1 +#define GPIO_PINSETUP 2 +#define GPIO_EVENTSETUP 3 + +struct pm8001_gpio { +u32 operation; +u32 mask; +u32 rd_wr_val; +u32 input_enable; +u32 pinsetup1; +u32 pinsetup2; +u32 event_level; +u32 event_rising_edge; +u32 event_falling_edge; +}; +struct ioctl_info_buffer {struct ioctl_header header;struct ioctl_drv_info information; }; +struct gpio_buffer { +struct ioctl_header header; +struct pm8001_gpio gpio_payload; +}; +struct phy_profile {char phy_id;unsigned int phys:4 ;
@@ -119,6 +142,7 @@ struct phy_prof_resp { };#define ADPT_IOCTL_INFO _IOR(ADPT_MAGIC_NUMBER, 0, struct ioctl_info_buffer *) +#define ADPT_IOCTL_GPIO _IOWR(ADPT_MAGIC_NUMBER, 1, struct gpio_buffer *)#define ADPT_IOCTL_GET_PHY_PROFILE _IOWR(ADPT_MAGIC_NUMBER, 8, \ struct phy_profile*)#define ADPT_IOCTL_GET_PHY_ERR_CNT _IOWR(ADPT_MAGIC_NUMBER, 9, \
drivers/scsi/pm8001/pm8001_init.c +6 -0
@@ -498,6 +498,12 @@ static struct pm8001_hba_info *pm8001_pci_alloc(struct pci_dev *pdev,else pm8001_ha->iomb_size =IOMB_SIZE_SPC ; +mutex_init (&pm8001_ha->ioctl_mutex); + pm8001_ha->ioctl_completion =NULL ; +init_waitqueue_head (&pm8001_ha->pollq); + pm8001_ha->gpio_event_occurred =0 ; +spin_lock_init (&pm8001_ha->ioctl_lock); +#ifdef PM8001_USE_TASKLET /* Tasklet for non msi-x interrupt handler */ if ((!pdev->msix_cap || !pci_msi_enabled())
drivers/scsi/pm8001/pm8001_sas.h +17 -0
@@ -132,6 +132,18 @@ extern const struct pm8001_dispatch pm8001_80xx_dispatch;struct pm8001_hba_info ;struct pm8001_ccb_info ;struct pm8001_device ; + +struct gpio_ioctl_resp { +u32 tag; +u32 gpio_rd_val; +u32 gpio_in_enabled; +u32 gpio_pinsetup1; +u32 gpio_pinsetup2; +u32 gpio_evt_change; +u32 gpio_evt_rise; +u32 gpio_evt_fall; +}; +/* define task management IU */ struct pm8001_tmf_task {u8 tmf;
@@ -247,6 +259,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 (*gpio_req)(struct pm8001_hba_info *pm8001_ha, +struct pm8001_gpio *gpio_payload);int (*get_phy_profile_req)(struct pm8001_hba_info *pm8001_ha,int phy,int page); };
@@ -562,6 +576,9 @@ struct pm8001_hba_info {u32 smp_exp_mode;bool controller_fatal_error;const struct firmware *fw_image; +struct gpio_ioctl_resp gpio_resp; +u32 gpio_event_occurred; +wait_queue_head_t pollq;struct isr_param irq_vector[PM8001_MAX_MSIX_VEC ];spinlock_t ioctl_lock;struct mutex ioctl_mutex;
drivers/scsi/pm8001/pm80xx_hwi.c +106 -0
133 lines not on this page · raw message
drivers/scsi/pm8001/pm80xx_hwi.h +49 -0
55 lines not on this page · raw message
Signature · 1 line
2.16.3
Jinpu Wang
maintainerRe: [PATCH 08/12] pm80xx : IOCTL functionality for GPIO.
Quoted 12 lines · Deepak Ukey
From: Deepak Ukey <[email protected]>
Added IOCTL functionality for GPIO.
The SPCv controller provides 24 GPIO signals. The first 12 signals [11:0] and the last 4 signals [23:20] are for customer use. Eight signals [19:12] are reserved for the SPCv controller firmware. Whenever the host performs GPIO setup or a read/write operation using the GPIO command the host needs to make sure that it does not disturb the GPIO configuration for the bits [19:12]. Each signal can be configured either as an input or as an output. When configured as an output, the host can use the GPIO Command to
Quoted 9 lines
set the desired level. GPIO inputs can also be configured so that the SPCv controller sends the GPIO Event notification when specific GPIO events occur.
Different GPIO features implemented:
1) GPIO Pin Setup
2) GPIO Event Setup
3) GPIO Read
4) GPIO Write
I think you can also implement lldd_write_gpio callback, so smp_utils can also control gpio, right?
Jinpu Wang
maintainerRe: [PATCH 08/12] pm80xx : IOCTL functionality for GPIO.
Quoted 24 lines · Jinpu Wang
Quoted 12 lines · Deepak Ukey
From: Deepak Ukey <[email protected]>
Added IOCTL functionality for GPIO.
The SPCv controller provides 24 GPIO signals. The first 12 signals [11:0] and the last 4 signals [23:20] are for customer use. Eight signals [19:12] are reserved for the SPCv controller firmware. Whenever the host performs GPIO setup or a read/write operation using the GPIO command the host needs to make sure that it does not disturb the GPIO configuration for the bits [19:12]. Each signal can be configured either as an input or as an output. When configured as an output, the host can use the GPIO Command toQuoted 9 lines
set the desired level. GPIO inputs can also be configured so that the SPCv controller sends the GPIO Event notification when specific GPIO events occur.
Different GPIO features implemented:
1) GPIO Pin Setup
2) GPIO Event Setup
3) GPIO Read
4) GPIO Write
Quoted 2 lines
I think you can also implement
lldd_write_gpiocallback, sosmp_utilscan also control gpio, right?
This comment should go to SGPIO, patch09
PATCH 9/12 pm80xx : IOCTL functionality for SGPIO.
In reply to Deepak UkeyFrom: Deepak Ukey <[email protected]>
Added the IOCTL functionality for SGPIO.
--- drivers/scsi/pm8001/pm8001_ctl.c | 73 ++++++++++++++++ drivers/scsi/pm8001/pm8001_ctl.h | 72 ++++++++++++++++ drivers/scsi/pm8001/pm8001_hwi.c | 172 +++++++++++++++++++++++++++++++++++++- drivers/scsi/pm8001/pm8001_hwi.h | 17 ++++ drivers/scsi/pm8001/pm8001_init.c | 3 + drivers/scsi/pm8001/pm8001_sas.c | 37 ++++++++ drivers/scsi/pm8001/pm8001_sas.h | 20 +++++ drivers/scsi/pm8001/pm80xx_hwi.c | 6 ++ drivers/scsi/pm8001/pm80xx_hwi.h | 3 + 9 files changed, 402 insertions(+), 1 deletion(-)
drivers/scsi/pm8001/pm8001_ctl.c +73 -0
@@ -1009,6 +1009,76 @@ static long pm8001_gpio_ioctl(struct pm8001_hba_info *pm8001_ha,return ret; } +static long pm8001_sgpio_ioctl (struct pm8001_hba_info *pm8001_ha, +unsigned long arg) +{ +struct sgpio_buffer buffer; +struct read_write_req_resp *req = &buffer.sgpio_req; +struct sgpio_req payload; +struct sgpio_ioctl_resp *sgpio_resp; +DECLARE_COMPLETION_ONSTACK (completion); +unsigned long timeout; +u32 ret =0 , i; + +if (copy_from_user (&buffer, (struct sgpio_buffer *)arg, +sizeof (struct sgpio_buffer ))) { +return ADPT_IOCTL_CALL_FAILED ; + } +mutex_lock (&pm8001_ha->ioctl_mutex); + pm8001_ha->ioctl_completion = &completion; + + payload.func_reg_index =cpu_to_le32 ((req->register_index <<24 ) | + (req->register_type <<16 ) | (req->function <<8 ) | +SMP_FRAME_REQ ); + payload.count = req->register_count; + +if (req->function ==WRITE_SGPIO_REGISTER ) { +if (req->register_count >MAX_SGPIO_REQ_PAYLOAD ) { + ret =ADPT_IOCTL_CALL_FAILED ; + goto exit; + } +for (i =0 ; i < req->register_count; i++) + payload.value[i] = req->read_write_data[i]; + } + + ret =PM8001_CHIP_DISP ->sgpio_req (pm8001_ha, &payload); +if (ret !=0 ) { + ret =ADPT_IOCTL_CALL_FAILED ; + goto exit; + } +if (timeout <2000 ) + timeout =2000 ; + + timeout =wait_for_completion_timeout (&completion, +msecs_to_jiffies (timeout)); +if (timeout ==0 ) { + ret =ADPT_IOCTL_CALL_TIMEOUT ; + goto exit; + } + + sgpio_resp = &pm8001_ha->sgpio_resp; + req->frame_type = sgpio_resp->func_result &0xff ; + req->function = (sgpio_resp->func_result >>8 ) &0xff ; + req->function_result = (sgpio_resp->func_result >>16 ) &0xff ; +if (req->function ==READ_SGPIO_REGISTER ) { +for (i =0 ; i < req->register_count; i++) + req->read_write_data[i] = sgpio_resp->value[i]; + } + ret =ADPT_IOCTL_CALL_SUCCESS ; +exit: +spin_lock_irq (&pm8001_ha->ioctl_lock); + pm8001_ha->ioctl_completion =NULL ; +spin_unlock_irq (&pm8001_ha->ioctl_lock); + buffer.header.return_code = ret; +if (copy_to_user ((void *)arg, (void *)&buffer, +sizeof (struct sgpio_buffer ))) { + ret =ADPT_IOCTL_CALL_FAILED ; + } +mutex_unlock (&pm8001_ha->ioctl_mutex); + +return ret; +} +static int pm8001_ioctl_get_phy_profile (struct pm8001_hba_info *pm8001_ha,unsigned long arg) {
@@ -1172,6 +1242,9 @@ static long pm8001_ioctl(struct file *file,case ADPT_IOCTL_GPIO : ret =pm8001_gpio_ioctl (pm8001_ha, arg);break ; +case ADPT_IOCTL_SGPIO : + ret =pm8001_sgpio_ioctl (pm8001_ha, arg); +break ;case ADPT_IOCTL_GET_PHY_PROFILE : ret =pm8001_ioctl_get_phy_profile (pm8001_ha, arg);return ret;
drivers/scsi/pm8001/pm8001_ctl.h +72 -0
96 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_hwi.c +171 -1
206 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_hwi.h +17 -0
@@ -82,6 +82,7 @@#define OPC_INB_GET_DEVICE_STATE 43/* 0x02B */ #define OPC_INB_SET_DEV_INFO 44/* 0x02C */ #define OPC_INB_SAS_RE_INITIALIZE 45/* 0x02D */ +#define OPC_INB_SGPIO_REG 46/* 0x02E */ /* for Response Opcode of IOMB */ #define OPC_OUB_ECHO 1/* 0x001 */
@@ -120,6 +121,7 @@#define OPC_OUB_GET_DEVICE_STATE 39/* 0x027 */ #define OPC_OUB_SET_DEV_INFO 40/* 0x028 */ #define OPC_OUB_SAS_RE_INITIALIZE 41/* 0x029 */ +#define OPC_OUB_SGPIO_RESP 2094/* 0x82E */ /* for phy start*/ #define SPINHOLD_DISABLE (0x00 << 14)
@@ -697,6 +699,18 @@ struct set_dev_state_resp {u32 reserved[11 ]; } __attribute__((packed, aligned(4))); +struct sgpio_reg_req { +__le32 tag; +__le32 func_reg_index; +__le32 count; +__le32 value[12 ]; +} __packed__aligned(4) ; + +struct sgpio_reg_resp { +__le32 tag; +__le32 func_result; +__le32 value[13 ]; +} __packed__aligned(4) ;#define NDS_BITS 0x0F#define PDS_BITS 0xF0
@@ -922,6 +936,9 @@ struct set_dev_state_resp {#define MAIN_HDA_FLAGS_OFFSET 0x84/* DWORD 0x21 */ #define MAIN_ANALOG_SETUP_OFFSET 0x88/* DWORD 0x22 */ +/*FATAL ERROR INTERRUPT bit definition*/ +#define MAIN_CFG_SGPIO_ENABLE (0x1 << 2) +/* Gereral Status Table offset - byte offset */ #define GST_GSTLEN_MPIS_OFFSET 0x00#define GST_IQ_FREEZE_STATE0_OFFSET 0x04
drivers/scsi/pm8001/pm8001_init.c +3 -0
@@ -122,6 +122,7 @@ static struct sas_domain_function_template pm8001_transport_ops = { .lldd_I_T_nexus_reset = pm8001_I_T_nexus_reset, .lldd_lu_reset = pm8001_lu_reset, .lldd_query_task = pm8001_query_task, + .lldd_write_gpio = pm8001_write_sgpio, };/**
@@ -1110,6 +1111,8 @@ static int pm8001_pci_probe(struct pci_dev *pdev,if (pm8001_configure_phy_settings (pm8001_ha)) goto err_out_shost; +pm8001_setup_sgpio (pm8001_ha); +pm8001_post_sas_ha_init (shost, chip); rc =sas_register_ha (SHOST_TO_SAS_HA (shost));if (rc) {
drivers/scsi/pm8001/pm8001_sas.c +37 -0
@@ -1361,3 +1361,40 @@ int pm8001_clear_task_set(struct domain_device *dev, u8 *lun)return pm8001_issue_ssp_tmf (dev, lun, &tmf_task); } +int pm8001_write_sgpio (struct sas_ha_struct *sas_ha,u8 reg_type, +u8 reg_index,u8 reg_count,u8 *write_data) +{ +struct pm8001_hba_info *pm8001_ha = sas_ha->lldd_ha; +struct sgpio_req payload; +u32 ret =0 , i, j, value; + +PM8001_MSG_DBG (pm8001_ha,pm8001_printk ( +"reg_type=%x, reg_index:%x, reg_count:%x\n" , + reg_type, reg_index, reg_count)); + +mutex_lock (&pm8001_ha->ioctl_mutex); + + payload.func_reg_index =cpu_to_le32 ((reg_index <<24 ) | + (reg_type <<16 ) | (WRITE_SGPIO_REGISTER <<8 ) | +SMP_FRAME_REQ ); + + payload.count = reg_count; + +for (i =0 ; i < reg_count; i++) { + value =0 ; +for (j =0 ; j <4 ; j++) { + value |= (u32)(*write_data) << (24 -(j*8 )); + write_data++; + } + payload.value[i] = value; +PM8001_MSG_DBG (pm8001_ha,pm8001_printk ( +"payload value: %x\n" , payload.value[i])); + } + + ret =PM8001_CHIP_DISP ->sgpio_req (pm8001_ha, &payload); +if (ret !=0 ) + ret =-1 ; + +mutex_unlock (&pm8001_ha->ioctl_mutex); +return ret; +}
drivers/scsi/pm8001/pm8001_sas.h +20 -0
@@ -144,6 +144,17 @@ struct gpio_ioctl_resp {u32 gpio_evt_fall; }; +struct sgpio_req { +u32 func_reg_index; +u32 count; +u32 value[MAX_SGPIO_REQ_PAYLOAD ]; +}; + +struct sgpio_ioctl_resp { +u32 func_result; +u32 value[MAX_SGPIO_RESP_PAYLOAD ]; +}; +/* define task management IU */ struct pm8001_tmf_task {u8 tmf;
@@ -261,6 +272,8 @@ struct pm8001_dispatch {int (*sas_re_init_req)(struct pm8001_hba_info *pm8001_ha);int (*gpio_req)(struct pm8001_hba_info *pm8001_ha,struct pm8001_gpio *gpio_payload); +int (*sgpio_req)(struct pm8001_hba_info *pm8001_ha, +struct sgpio_req *sgpio_payload);int (*get_phy_profile_req)(struct pm8001_hba_info *pm8001_ha,int phy,int page); };
@@ -585,6 +598,7 @@ struct pm8001_hba_info {struct completion *ioctl_completion;struct timer_list ioctl_timer;u32 ioctl_timer_expired; +struct sgpio_ioctl_resp sgpio_resp;struct phy_prof_resp phy_profile_resp;u32 reset_in_progress; };
@@ -698,6 +712,8 @@ int pm8001_lu_reset(struct domain_device *dev, u8 *lun);int pm8001_I_T_nexus_reset (struct domain_device *dev);int pm8001_I_T_nexus_event_handler (struct domain_device *dev);int pm8001_query_task (struct sas_task *task); +int pm8001_write_sgpio (struct sas_ha_struct *sas_ha,u8 reg_type, +u8 reg_index,u8 reg_count,u8 *write_data); void pm8001_open_reject_retry( struct pm8001_hba_info *pm8001_ha, struct sas_task *task_to_close,
@@ -733,6 +749,8 @@ int pm8001_chip_abort_task(struct pm8001_hba_info *pm8001_ha,struct pm8001_device *pm8001_dev, u8 flag, u32 task_tag, u32 cmd_tag);int pm8001_chip_dereg_dev_req (struct pm8001_hba_info *pm8001_ha,u32 device_id); +int pm8001_chip_sgpio_req (struct pm8001_hba_info *pm8001_ha, +struct sgpio_req *sgpio_payload);void pm8001_chip_make_sg (struct scatterlist *scatter,int nr,void *prd);void pm8001_work_fn (struct work_struct *work); int pm8001_handle_event(struct pm8001_hba_info *pm8001_ha,
@@ -754,6 +772,7 @@ int pm8001_mpi_fw_flash_update_resp(struct pm8001_hba_info *pm8001_ha, void *piomb);int pm8001_mpi_general_event (struct pm8001_hba_info *pm8001_ha ,void *piomb);int pm8001_mpi_task_abort_resp (struct pm8001_hba_info *pm8001_ha,void *piomb); +int pm8001_sgpio_resp (struct pm8001_hba_info *pm8001_ha,void *piomb);struct sas_task *pm8001_alloc_task (void );void pm8001_task_done (struct sas_task *task);void pm8001_free_task (struct sas_task *task);
@@ -761,6 +780,7 @@ void pm8001_tag_free(struct pm8001_hba_info *pm8001_ha, u32 tag);struct pm8001_device *pm8001_find_dev (struct pm8001_hba_info *pm8001_ha,u32 device_id);int pm80xx_set_thermal_config (struct pm8001_hba_info *pm8001_ha); +int pm8001_setup_sgpio (struct pm8001_hba_info *pm8001_ha);int pm8001_bar4_shift (struct pm8001_hba_info *pm8001_ha,u32 shiftValue); void pm8001_set_phy_profile(struct pm8001_hba_info *pm8001_ha,
drivers/scsi/pm8001/pm80xx_hwi.c +6 -0
@@ -4100,6 +4100,11 @@ static void process_one_iomb(struct pm8001_hba_info *pm8001_ha, void *piomb) "OPC_OUB_SSP_COALESCED_COMP_RESP opcode:%x\n", opc));ssp_coalesced_comp_resp (pm8001_ha, piomb);break ; +case OPC_OUB_SGPIO_RESP : +PM8001_MSG_DBG (pm8001_ha,pm8001_printk ( +"OPC_OUB_SGPIO RESPONSE opcode: %x\n" , opc)); +pm8001_sgpio_resp (pm8001_ha, piomb); +break ;default :PM8001_DEVIO_DBG (pm8001_ha,pm8001_printk ("Unknown outbound Queue IOMB OPC = 0x%x\n" , opc));
@@ -5170,5 +5175,6 @@ const struct pm8001_dispatch pm8001_80xx_dispatch = { .fw_flash_update_req = pm8001_chip_fw_flash_update_req, .set_dev_state_req = pm8001_chip_set_dev_state_req, .gpio_req = pm80xx_chip_gpio_req, + .sgpio_req = pm8001_chip_sgpio_req, .get_phy_profile_req = pm8001_chip_get_phy_profile, };
drivers/scsi/pm8001/pm80xx_hwi.h +3 -0
@@ -1509,6 +1509,9 @@ typedef struct SASProtocolTimerConfig SASProtocolTimerConfig_t;#define MAIN_MPI_ILA_RELEASE_TYPE 0xA4/* DWORD 0x29 */ #define MAIN_MPI_INACTIVE_FW_VERSION 0XB0/* DWORD 0x2C */ +/*FATAL ERROR INTERRUPT bit definition*/ +#define MAIN_CFG_SGPIO_ENABLE (0x1 << 2) +/* Gereral Status Table offset - byte offset */ #define GST_GSTLEN_MPIS_OFFSET 0x00#define GST_IQ_FREEZE_STATE0_OFFSET 0x04
Signature · 1 line
2.16.3
Re: [PATCH 09/12] pm80xx : IOCTL functionality for SGPIO.
Hi Deepak,
The 0day bot reported an issue with this patch with Clang, would you mind taking a look at it? The full report is attached at the bottom, I've added a comment inline before it though.
Quoted 58 lines · Deepak Ukey
From: Deepak Ukey <[email protected]>
Added the IOCTL functionality for SGPIO.
Signed-off-by Deepak Ukey <[email protected]>Signed-off-by Viswas G <[email protected]>Signed-off-by Vishakha Channapattan <[email protected]>Signed-off-by Bhavesh Jashnani <[email protected]>Signed-off-by Radha Ramachandran <[email protected]>Signed-off-by Akshat Jain <[email protected]>Signed-off-by Yu Zheng <[email protected]>--- drivers/scsi/pm8001/pm8001_ctl.c | 73 ++++++++++++++++ drivers/scsi/pm8001/pm8001_ctl.h | 72 ++++++++++++++++ drivers/scsi/pm8001/pm8001_hwi.c | 172 +++++++++++++++++++++++++++++++++++++- drivers/scsi/pm8001/pm8001_hwi.h | 17 ++++ drivers/scsi/pm8001/pm8001_init.c | 3 + drivers/scsi/pm8001/pm8001_sas.c | 37 ++++++++ drivers/scsi/pm8001/pm8001_sas.h | 20 +++++ drivers/scsi/pm8001/pm80xx_hwi.c | 6 ++ drivers/scsi/pm8001/pm80xx_hwi.h | 3 + 9 files changed, 402 insertions(+), 1 deletion(-)drivers/scsi/pm8001/pm8001_ctl.c +27
-0@@ -1009,6 +1009,76 @@ static long pm8001_gpio_ioctl(struct pm8001_hba_info *pm8001_ha,return ret; } +static long pm8001_sgpio_ioctl (struct pm8001_hba_info *pm8001_ha, +unsigned long arg) +{ +struct sgpio_buffer buffer; +struct read_write_req_resp *req = &buffer.sgpio_req; +struct sgpio_req payload; +struct sgpio_ioctl_resp *sgpio_resp; +DECLARE_COMPLETION_ONSTACK (completion); +unsigned long timeout; +u32 ret =0 , i; + +if (copy_from_user (&buffer, (struct sgpio_buffer *)arg, +sizeof (struct sgpio_buffer ))) { +return ADPT_IOCTL_CALL_FAILED ; + } +mutex_lock (&pm8001_ha->ioctl_mutex); + pm8001_ha->ioctl_completion = &completion; + + payload.func_reg_index =cpu_to_le32 ((req->register_index <<24 ) | + (req->register_type <<16 ) | (req->function <<8 ) | +SMP_FRAME_REQ ); + payload.count = req->register_count; + +if (req->function ==WRITE_SGPIO_REGISTER ) { +if (req->register_count >MAX_SGPIO_REQ_PAYLOAD ) { + ret =ADPT_IOCTL_CALL_FAILED ; + goto exit;
drivers/scsi/pm8001/pm8001_ctl.c static long pm8001_gpio_ioctl(struct pm8001_hba_info *pm8001_ha, · line 1048
Quoted 10 lines
drivers/scsi/pm8001/pm8001_ctl.c +10
-0+ } +for (i =0 ; i < req->register_count; i++) + payload.value[i] = req->read_write_data[i]; + } + + ret =PM8001_CHIP_DISP ->sgpio_req (pm8001_ha, &payload); +if (ret !=0 ) { + ret =ADPT_IOCTL_CALL_FAILED ; + goto exit; + }
timeout is uninitialized here; could this if statement be removed and have the msecs_to_jiffies just hardcode the 2000?
Quoted 46 lines
drivers/scsi/pm8001/pm8001_ctl.c +36
-0+if (timeout <2000 ) + timeout =2000 ; + + timeout =wait_for_completion_timeout (&completion, +msecs_to_jiffies (timeout)); +if (timeout ==0 ) { + ret =ADPT_IOCTL_CALL_TIMEOUT ; + goto exit; + } + + sgpio_resp = &pm8001_ha->sgpio_resp; + req->frame_type = sgpio_resp->func_result &0xff ; + req->function = (sgpio_resp->func_result >>8 ) &0xff ; + req->function_result = (sgpio_resp->func_result >>16 ) &0xff ; +if (req->function ==READ_SGPIO_REGISTER ) { +for (i =0 ; i < req->register_count; i++) + req->read_write_data[i] = sgpio_resp->value[i]; + } + ret =ADPT_IOCTL_CALL_SUCCESS ; +exit: +spin_lock_irq (&pm8001_ha->ioctl_lock); + pm8001_ha->ioctl_completion =NULL ; +spin_unlock_irq (&pm8001_ha->ioctl_lock); + buffer.header.return_code = ret; +if (copy_to_user ((void *)arg, (void *)&buffer, +sizeof (struct sgpio_buffer ))) { + ret =ADPT_IOCTL_CALL_FAILED ; + } +mutex_unlock (&pm8001_ha->ioctl_mutex); + +return ret; +} +static int pm8001_ioctl_get_phy_profile (struct pm8001_hba_info *pm8001_ha,unsigned long arg) {@@ -1172,6 +1242,9 @@ static long pm8001_ioctl(struct file *file,case ADPT_IOCTL_GPIO : ret =pm8001_gpio_ioctl (pm8001_ha, arg);break ; +case ADPT_IOCTL_SGPIO : + ret =pm8001_sgpio_ioctl (pm8001_ha, arg); +break ;case ADPT_IOCTL_GET_PHY_PROFILE : ret =pm8001_ioctl_get_phy_profile (pm8001_ha, arg);return ret;
Quoted 121 lines · kbuild test robot
CC: [email protected]
In-Reply-To: <[email protected]>
References: <[email protected]>
TO: Deepak Ukey <[email protected]>
CC: [email protected]
CC: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]Hi Deepak,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on mkp-scsi/for-next]
[cannot apply to scsi/for-next v5.5-rc3 next-20191220]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]url: https://github.com/0day-ci/linux/commits/Deepak-Ukey/pm80xx-Updates-for-the-driver-version-0-1-39/20191225-181036 base: https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next config: x86_64-allyesconfig (attached as .config) compiler: clang version 10.0.0 (git://gitmirror/llvm_project 9a77c2095439ba41bd8f6f35931b94075b2fd45b) reproduce: # save the attached .config to linux build tree make ARCH=x86_64If you fix the issue, kindly add following tag
Reported-by kbuild test robot <[email protected]>All warnings (new ones prefixed by >>):
In file included from drivers/scsi/pm8001/pm8001_ctl.c:43: In file included from drivers/scsi/pm8001/pm8001_sas.h:58: drivers/scsi/pm8001/pm8001_defs.h:102:9: warning: 'CONFIG_SCSI_PM8001_MAX_DMA_SG' macro redefined [-Wmacro-redefined] #define CONFIG_SCSI_PM8001_MAX_DMA_SG 528 ^ ./include/generated/autoconf.h:10861:9: note: previous definition is here #define CONFIG_SCSI_PM8001_MAX_DMA_SG 128 ^Quoted 1 line
Quoted 1 line
drivers/scsi/pm8001/pm8001_ctl.c:1049:6: warning: variable 'timeout' is uninitialized when used here [-Wuninitialized]if (timeout < 2000) ^~~~~~~ drivers/scsi/pm8001/pm8001_ctl.c:1020:23: note: initialize the variable 'timeout' to silence this warning unsigned long timeout; ^ = 02 warnings generated.
vim +/timeout +1049
drivers/scsi/pm8001/pm8001_ctl.c1011
1012 static long pm8001_sgpio_ioctl(structpm8001_hba_info*pm8001_ha,
1013 unsigned long arg)
1014 {
1015 structsgpio_bufferbuffer;
1016 structread_write_req_resp*req = &buffer.sgpio_req;
1017 structsgpio_reqpayload;
1018 structsgpio_ioctl_resp*sgpio_resp;
1019DECLARE_COMPLETION_ONSTACK(completion);
1020 unsigned long timeout;
1021 u32 ret = 0, i;
1022
1023 if (copy_from_user(&buffer, (structsgpio_buffer*)arg,
1024sizeof(struct sgpio_buffer))) {
1025 returnADPT_IOCTL_CALL_FAILED;
1026 }
1027mutex_lock(&pm8001_ha->ioctl_mutex);
1028pm8001_ha->ioctl_completion= &completion;
1029
1030 payload.func_reg_index = cpu_to_le32((req->register_index << 24) |
1031 (req->register_type<< 16) | (req->function<< 8) |
1032SMP_FRAME_REQ);
1033 payload.count =req->register_count;
1034
1035 if (req->function==WRITE_SGPIO_REGISTER) {
1036 if (req->register_count>MAX_SGPIO_REQ_PAYLOAD) {
1037 ret =ADPT_IOCTL_CALL_FAILED;
1038 goto exit;
1039 }
1040 for (i = 0; i <req->register_count; i++)
1041 payload.value[i] = req->read_write_data[i];
1042 }
1043
1044 ret =PM8001_CHIP_DISP->sgpio_req(pm8001_ha, &payload);
1045 if (ret != 0) {
1046 ret =ADPT_IOCTL_CALL_FAILED;
1047 goto exit;
1048 }Quoted 1 line
1049 if (timeout < 2000)
1050 timeout = 2000;
1051
1052 timeout = wait_for_completion_timeout(&completion,
1053msecs_to_jiffies(timeout));
1054 if (timeout == 0) {
1055 ret =ADPT_IOCTL_CALL_TIMEOUT;
1056 goto exit;
1057 }
1058
1059sgpio_resp=&pm8001_ha->sgpio_resp;
1060req->frame_type=sgpio_resp->func_result&0xff;
1061req->function= (sgpio_resp->func_result>> 8) &0xff;
1062req->function_result= (sgpio_resp->func_result>> 16) &0xff;
1063 if (req->function==READ_SGPIO_REGISTER) {
1064 for (i = 0; i <req->register_count; i++)
1065 req->read_write_data[i] = sgpio_resp->value[i];
1066 }
1067 ret =ADPT_IOCTL_CALL_SUCCESS;
1068 exit:
1069spin_lock_irq(&pm8001_ha->ioctl_lock);
1070pm8001_ha->ioctl_completion= NULL;
1071spin_unlock_irq(&pm8001_ha->ioctl_lock);
1072 buffer.header.return_code = ret;
1073 if (copy_to_user((void *)arg, (void *)&buffer,
1074sizeof(struct sgpio_buffer))) {
1075 ret =ADPT_IOCTL_CALL_FAILED;
1076 }
1077mutex_unlock(&pm8001_ha->ioctl_mutex);
1078
1079 return ret;
1080 }
1081
Quoted 3 lines
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/[email protected] Intel Corporation
Cheers,
Nathan
Jinpu Wang
maintainerRe: [PATCH 09/12] pm80xx : IOCTL functionality for SGPIO.
In reply to Deepak UkeyQuoted 5 lines · Deepak Ukey
From: Deepak Ukey <[email protected]>
Added the IOCTL functionality for SGPIO.
Please extends your commit message, what's the use case, please fix the warnings Nathan reported.
Thanks
PATCH 10/12 pm80xx : sysfs attribute for non fatal dump.
In reply to Deepak UkeyFrom: Deepak Ukey <[email protected]>
Added the functionality to collect non fatal dump.
--- drivers/scsi/pm8001/pm8001_ctl.c | 45 +++++++++++++ drivers/scsi/pm8001/pm8001_init.c | 1 + drivers/scsi/pm8001/pm8001_sas.h | 4 ++ drivers/scsi/pm8001/pm80xx_hwi.c | 130 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 180 insertions(+)
drivers/scsi/pm8001/pm8001_ctl.c +45 -0
@@ -577,6 +577,49 @@ static ssize_t pm8001_ctl_fatal_log_show(struct device *cdev, static DEVICE_ATTR(fatal_log, S_IRUGO, pm8001_ctl_fatal_log_show, NULL); +/** +** non_fatal_log_show - non fatal error logging +** @cdev:pointer to embedded class device +** @buf: the buffer returned +** +** A sysfs 'read-only' shost attribute. +**/ +static ssize_t non_fatal_log_show (struct device *cdev, +struct device_attribute *attr,char *buf) +{ +u32 count; + + count =pm80xx_get_non_fatal_dump (cdev, attr, buf); +return count; +} +static DEVICE_ATTR_RO (non_fatal_log); + +static ssize_t non_fatal_count_show (struct device *cdev, +struct device_attribute *attr,char *buf) +{ +struct Scsi_Host *shost =class_to_shost (cdev); +struct sas_ha_struct *sha =SHOST_TO_SAS_HA (shost); +struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; + +return snprintf (buf,PAGE_SIZE ,"%08x" , + pm8001_ha->non_fatal_count); +} + +static ssize_t non_fatal_count_store (struct device *cdev, +struct device_attribute *attr,const char *buf,size_t count) +{ +struct Scsi_Host *shost =class_to_shost (cdev); +struct sas_ha_struct *sha =SHOST_TO_SAS_HA (shost); +struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; +int val =0 ; + +if (kstrtoint (buf,16 , &val) !=0 ) +return -EINVAL ; + + pm8001_ha->non_fatal_count = val; +return strlen (buf); +} +static DEVICE_ATTR_RW (non_fatal_count);/** ** pm8001_ctl_gsm_log_show - gsm dump collection
@@ -853,6 +896,8 @@ struct device_attribute *pm8001_host_attrs[] = { &dev_attr_aap_log, &dev_attr_iop_log, &dev_attr_fatal_log, + &dev_attr_non_fatal_log, + &dev_attr_non_fatal_count, &dev_attr_gsm_log, &dev_attr_max_out_io, &dev_attr_max_devices,
drivers/scsi/pm8001/pm8001_init.c +1 -0
@@ -484,6 +484,7 @@ static struct pm8001_hba_info *pm8001_pci_alloc(struct pci_dev *pdev, pm8001_ha->shost = shost; pm8001_ha->id = pm8001_id++; pm8001_ha->logging_level = logging_level; + pm8001_ha->non_fatal_count =0 ;if (link_rate >=1 && link_rate <=15 ) pm8001_ha->link_rate = (link_rate <<8 );else {
drivers/scsi/pm8001/pm8001_sas.h +4 -0
@@ -601,6 +601,8 @@ struct pm8001_hba_info {struct sgpio_ioctl_resp sgpio_resp;struct phy_prof_resp phy_profile_resp;u32 reset_in_progress; +u32 non_fatal_count; +u32 non_fatal_read_length; };struct pm8001_work {
@@ -790,6 +792,8 @@ void pm8001_set_phy_profile_single(struct pm8001_hba_info *pm8001_ha,int pm80xx_bar4_shift (struct pm8001_hba_info *pm8001_ha,u32 shiftValue);ssize_t pm80xx_get_fatal_dump (struct device *cdev,struct device_attribute *attr,char *buf); +ssize_t pm80xx_get_non_fatal_dump (struct device *cdev, +struct device_attribute *attr,char *buf);ssize_t pm8001_get_gsm_dump (struct device *cdev,u32 ,char *buf);/* ctl shared API */ extern struct device_attribute *pm8001_host_attrs[];
drivers/scsi/pm8001/pm80xx_hwi.c +130 -0
136 lines not on this page · raw message
Signature · 1 line
2.16.3
Jinpu Wang
maintainerRe: [PATCH 10/12] pm80xx : sysfs attribute for non fatal dump.
Quoted 4 lines · Deepak Ukey
From: Deepak Ukey <[email protected]>
Added the functionality to collect non fatal dump.
Please extend the commit message, what the use case, how to use it.
Quoted 29 lines
Signed-off-by Deepak Ukey <[email protected]>Signed-off-by Viswas G <[email protected]>Signed-off-by Vishakha Channapattan <[email protected]>Signed-off-by Bhavesh Jashnani <[email protected]>Signed-off-by Radha Ramachandran <[email protected]>Signed-off-by Akshat Jain <[email protected]>Signed-off-by Yu Zheng <[email protected]>--- drivers/scsi/pm8001/pm8001_ctl.c | 45 +++++++++++++ drivers/scsi/pm8001/pm8001_init.c | 1 + drivers/scsi/pm8001/pm8001_sas.h | 4 ++ drivers/scsi/pm8001/pm80xx_hwi.c | 130 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 180 insertions(+)drivers/scsi/pm8001/pm8001_ctl.c +6
-0@@ -577,6 +577,49 @@ static ssize_t pm8001_ctl_fatal_log_show(struct device *cdev, static DEVICE_ATTR(fatal_log, S_IRUGO, pm8001_ctl_fatal_log_show, NULL); +/** +** non_fatal_log_show - non fatal error logging +** @cdev:pointer to embedded class device +** @buf: the buffer returned +** +** A sysfs 'read-only' shost attribute.
drivers/scsi/pm8001/pm8001_ctl.c static ssize_t pm8001_ctl_fatal_log_show(struct device *cdev, · line 595
Quoted 10 lines
drivers/scsi/pm8001/pm8001_ctl.c +10
-0+**/ +static ssize_t non_fatal_log_show (struct device *cdev, +struct device_attribute *attr,char *buf) +{ +u32 count; + + count =pm80xx_get_non_fatal_dump (cdev, attr, buf); +return count; +} +static DEVICE_ATTR_RO (non_fatal_log);
I would suggest to use pm8001_ctl_non_fatal_log_show as function name, or convert remove
the prefix for other functions, it's annoying to have different naming convention.
Quoted 217 lines
drivers/scsi/pm8001/pm8001_ctl.c +29
-0+ +static ssize_t non_fatal_count_show (struct device *cdev, +struct device_attribute *attr,char *buf) +{ +struct Scsi_Host *shost =class_to_shost (cdev); +struct sas_ha_struct *sha =SHOST_TO_SAS_HA (shost); +struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; + +return snprintf (buf,PAGE_SIZE ,"%08x" , + pm8001_ha->non_fatal_count); +} + +static ssize_t non_fatal_count_store (struct device *cdev, +struct device_attribute *attr,const char *buf,size_t count) +{ +struct Scsi_Host *shost =class_to_shost (cdev); +struct sas_ha_struct *sha =SHOST_TO_SAS_HA (shost); +struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; +int val =0 ; + +if (kstrtoint (buf,16 , &val) !=0 ) +return -EINVAL ; + + pm8001_ha->non_fatal_count = val; +return strlen (buf); +} +static DEVICE_ATTR_RW (non_fatal_count);/** ** pm8001_ctl_gsm_log_show - gsm dump collection @@ -853,6 +896,8 @@ struct device_attribute *pm8001_host_attrs[] = { &dev_attr_aap_log, &dev_attr_iop_log, &dev_attr_fatal_log, + &dev_attr_non_fatal_log, + &dev_attr_non_fatal_count, &dev_attr_gsm_log, &dev_attr_max_out_io, &dev_attr_max_devices,drivers/scsi/pm8001/pm8001_init.c +1
-0@@ -484,6 +484,7 @@ static struct pm8001_hba_info *pm8001_pci_alloc(struct pci_dev *pdev, pm8001_ha->shost = shost; pm8001_ha->id = pm8001_id++; pm8001_ha->logging_level = logging_level; + pm8001_ha->non_fatal_count =0 ;if (link_rate >=1 && link_rate <=15 ) pm8001_ha->link_rate = (link_rate <<8 );else {drivers/scsi/pm8001/pm8001_sas.h +4
-0@@ -601,6 +601,8 @@ struct pm8001_hba_info {struct sgpio_ioctl_resp sgpio_resp;struct phy_prof_resp phy_profile_resp;u32 reset_in_progress; +u32 non_fatal_count; +u32 non_fatal_read_length; };struct pm8001_work {@@ -790,6 +792,8 @@ void pm8001_set_phy_profile_single(struct pm8001_hba_info *pm8001_ha,int pm80xx_bar4_shift (struct pm8001_hba_info *pm8001_ha,u32 shiftValue);ssize_t pm80xx_get_fatal_dump (struct device *cdev,struct device_attribute *attr,char *buf); +ssize_t pm80xx_get_non_fatal_dump (struct device *cdev, +struct device_attribute *attr,char *buf);ssize_t pm8001_get_gsm_dump (struct device *cdev,u32 ,char *buf);/* ctl shared API */ extern struct device_attribute *pm8001_host_attrs[];drivers/scsi/pm8001/pm80xx_hwi.c +130
-1@@ -393,6 +393,136 @@ ssize_t pm80xx_get_fatal_dump(struct device *cdev, (char *)buf; } +/* pm80xx_get_non_fatal_dump - dump the nonfatal data from the dma +* location by the firmware. +*/ +ssize_t pm80xx_get_non_fatal_dump (struct device *cdev, +struct device_attribute *attr,char *buf) +{ +struct Scsi_Host *shost =class_to_shost (cdev); +struct sas_ha_struct *sha =SHOST_TO_SAS_HA (shost); +struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; +void __iomem *nonfatal_table_address = pm8001_ha->fatal_tbl_addr; +u32 accum_len =0 ; +u32 total_len =0 ; +u32 reg_val =0 ; +u32 *temp =NULL ; +u32 index =0 ; +u32 output_length; +unsigned long start =0 ; +char *buf_copy = buf; + + temp = (u32 *)pm8001_ha->memoryMap.region[FORENSIC_MEM ].virt_ptr; +if (++pm8001_ha->non_fatal_count ==1 ) { +if (pm8001_ha->chip_id == chip_8001) { +snprintf (pm8001_ha->forensic_info.data_buf.direct_data, +PAGE_SIZE ,"Not supported for SPC controller" ); +return 0 ; + } +PM8001_IO_DBG (pm8001_ha, +pm8001_printk ("forensic_info TYPE_NON_FATAL...\n" )); +/* +* Step 1: Write the host buffer parameters in the MPI Fatal and +* Non-Fatal Error Dump Capture Table.This is the buffer +* where debug data will be DMAed to. +*/ +pm8001_mw32 (nonfatal_table_address, +MPI_FATAL_EDUMP_TABLE_LO_OFFSET , + pm8001_ha->memoryMap.region[FORENSIC_MEM ].phys_addr_lo); + +pm8001_mw32 (nonfatal_table_address, +MPI_FATAL_EDUMP_TABLE_HI_OFFSET , + pm8001_ha->memoryMap.region[FORENSIC_MEM ].phys_addr_hi); + +pm8001_mw32 (nonfatal_table_address, +MPI_FATAL_EDUMP_TABLE_LENGTH ,SYSFS_OFFSET ); + +/* Optionally, set the DUMPCTRL bit to 1 if the host +* keeps sending active I/Os while capturing the non-fatal +* debug data. Otherwise, leave this bit set to zero +*/ +pm8001_mw32 (nonfatal_table_address, +MPI_FATAL_EDUMP_TABLE_HANDSHAKE ,MPI_FATAL_EDUMP_HANDSHAKE_RDY ); + +/* +* Step 2: Clear Accumulative Length of Debug Data Transferred +* [ACCDDLEN] field in the MPI Fatal and Non-Fatal Error Dump +* Capture Table to zero. +*/ +pm8001_mw32 (nonfatal_table_address, +MPI_FATAL_EDUMP_TABLE_ACCUM_LEN ,0 ); + +/* initiallize previous accumulated length to 0 */ + pm8001_ha->forensic_preserved_accumulated_transfer =0 ; + pm8001_ha->non_fatal_read_length =0 ; + } + + total_len =pm8001_mr32 (nonfatal_table_address, +MPI_FATAL_EDUMP_TABLE_TOTAL_LEN ); +/* +* Step 3:Clear Fatal/Non-Fatal Debug Data Transfer Status [FDDTSTAT] +* field and then request that the SPCv controller transfer the debug +* data by setting bit 7 of the Inbound Doorbell Set Register. +*/ +pm8001_mw32 (nonfatal_table_address,MPI_FATAL_EDUMP_TABLE_STATUS ,0 ); +pm8001_cw32 (pm8001_ha,0 ,MSGU_IBDB_SET , + SPCv_MSGU_CFG_TABLE_NONFATAL_DUMP); + +/* +* Step 4.1: Read back the Inbound Doorbell Set Register (by polling for +* 2 seconds) until register bit 7 is cleared. +* This step only indicates the request is accepted by the controller. +*/ + start = jiffies + (2 *HZ );/* 2 sec */ +do { + reg_val =pm8001_cr32 (pm8001_ha,0 ,MSGU_IBDB_SET ) & + SPCv_MSGU_CFG_TABLE_NONFATAL_DUMP; + }while ((reg_val !=0 ) &&time_before (jiffies, start)); + +/* Step 4.2: To check the completion of the transfer, poll the Fatal/Non +* Fatal Debug Data Transfer Status [FDDTSTAT] field for 2 seconds in +* the MPI Fatal and Non-Fatal Error Dump Capture Table. +*/ + start = jiffies + (2 *HZ );/* 2 sec */ +do { + reg_val =pm8001_mr32 (nonfatal_table_address, +MPI_FATAL_EDUMP_TABLE_STATUS ); + }while ((!reg_val) &&time_before (jiffies, start)); + +if ((reg_val ==0x00 ) || + (reg_val ==MPI_FATAL_EDUMP_TABLE_STAT_DMA_FAILED ) || + (reg_val >MPI_FATAL_EDUMP_TABLE_STAT_NF_SUCCESS_DONE )) { + pm8001_ha->non_fatal_read_length =0 ; + buf_copy +=snprintf (buf_copy,PAGE_SIZE ,"%08x " ,0xFFFFFFFF ); + pm8001_ha->non_fatal_count =0 ; +return (buf_copy - buf); + }else if (reg_val == +MPI_FATAL_EDUMP_TABLE_STAT_NF_SUCCESS_MORE_DATA ) { + buf_copy +=snprintf (buf_copy,PAGE_SIZE ,"%08x " ,2 ); + }else if ((reg_val ==MPI_FATAL_EDUMP_TABLE_STAT_NF_SUCCESS_DONE ) || + (pm8001_ha->non_fatal_read_length >= total_len)) { + pm8001_ha->non_fatal_read_length =0 ; + buf_copy +=snprintf (buf_copy,PAGE_SIZE ,"%08x " ,4 ); + pm8001_ha->non_fatal_count =0 ; + } + accum_len =pm8001_mr32 (nonfatal_table_address, +MPI_FATAL_EDUMP_TABLE_ACCUM_LEN ); + output_length = accum_len - + pm8001_ha->forensic_preserved_accumulated_transfer; + +for (index =0 ; index < output_length/4 ; index++) + buf_copy +=snprintf (buf_copy,PAGE_SIZE , +"%08x " , *(temp+index)); + + pm8001_ha->non_fatal_read_length += output_length; + +/* store current accumulated length to use in next iteration as +* the previous accumulated length +*/ + pm8001_ha->forensic_preserved_accumulated_transfer = accum_len; +return (buf_copy - buf); +} +/** * read_main_config_table - read the configure table and save it. * @pm8001_ha: our hba card information -- 2.16.3
PATCH 11/12 pm80xx : Introduce read and write length for IOCTL payload structure.
In reply to Deepak UkeyFrom: Viswas G <[email protected]>
Removed the common length and introduce read and write length for IOCTL payload structure.
--- drivers/scsi/pm8001/pm8001_ctl.c | 6 +++--- drivers/scsi/pm8001/pm8001_hwi.c | 22 +++++++++++----------- drivers/scsi/pm8001/pm8001_init.c | 12 ++++++------ drivers/scsi/pm8001/pm8001_sas.h | 3 ++- 4 files changed, 22 insertions(+), 21 deletions(-)
drivers/scsi/pm8001/pm8001_ctl.c +3 -3
@@ -486,7 +486,7 @@ static ssize_t pm8001_ctl_bios_version_show(struct device *cdev, pm8001_ha->nvmd_completion = &completion; payload.minor_function =7 ; payload.offset =0 ; - payload.length =4096 ; + payload.rd_length =4096 ; payload.func_specific =kzalloc (4096 ,GFP_KERNEL );if (!payload.func_specific)return -ENOMEM ;
@@ -697,7 +697,7 @@ static int pm8001_set_nvmd(struct pm8001_hba_info *pm8001_ha) payload = (struct pm8001_ioctl_payload *)ioctlbuffer;memcpy ((u8 *)&payload->func_specific, (u8 *)pm8001_ha->fw_image->data, pm8001_ha->fw_image->size); - payload->length = pm8001_ha->fw_image->size; + payload->wr_length = pm8001_ha->fw_image->size; payload->id =0 ; payload->minor_function =0x1 ; pm8001_ha->nvmd_completion = &completion;
@@ -743,7 +743,7 @@ static int pm8001_update_flash(struct pm8001_hba_info *pm8001_ha) IOCTL_BUF_SIZE);for (loopNumber =0 ; loopNumber < loopcount; loopNumber++) { payload = (struct pm8001_ioctl_payload *)ioctlbuffer; - payload->length =1024 *16 ; + payload->wr_length =1024 *16 ; payload->id =0 ; fwControl = (struct fw_control_info *)&payload->func_specific;
drivers/scsi/pm8001/pm8001_hwi.c +11 -11
@@ -4841,7 +4841,7 @@ int pm8001_chip_get_nvmd_req(struct pm8001_hba_info *pm8001_ha,if (!fw_control_context)return -ENOMEM ; fw_control_context->usrAddr = (u8 *)ioctl_payload->func_specific; - fw_control_context->len = ioctl_payload->length; + fw_control_context->len = ioctl_payload->rd_length; circularQ = &pm8001_ha->inbnd_q_tbl[0 ];memset (&nvmd_req,0 ,sizeof (nvmd_req)); rc =pm8001_tag_alloc (pm8001_ha, &tag);
@@ -4862,7 +4862,7 @@ int pm8001_chip_get_nvmd_req(struct pm8001_hba_info *pm8001_ha, nvmd_req.len_ir_vpdd =cpu_to_le32 (IPMode | twi_addr <<16 | twi_page_size <<8 |TWI_DEVICE ); - nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->length); + nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->rd_length); nvmd_req.resp_addr_hi =cpu_to_le32 (pm8001_ha->memoryMap.region[NVMD ].phys_addr_hi); nvmd_req.resp_addr_lo =
@@ -4871,7 +4871,7 @@ int pm8001_chip_get_nvmd_req(struct pm8001_hba_info *pm8001_ha, }case C_SEEPROM : { nvmd_req.len_ir_vpdd =cpu_to_le32 (IPMode |C_SEEPROM ); - nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->length); + nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->rd_length); nvmd_req.resp_addr_hi =cpu_to_le32 (pm8001_ha->memoryMap.region[NVMD ].phys_addr_hi); nvmd_req.resp_addr_lo =
@@ -4880,7 +4880,7 @@ int pm8001_chip_get_nvmd_req(struct pm8001_hba_info *pm8001_ha, }case VPD_FLASH : { nvmd_req.len_ir_vpdd =cpu_to_le32 (IPMode |VPD_FLASH ); - nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->length); + nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->rd_length); nvmd_req.resp_addr_hi =cpu_to_le32 (pm8001_ha->memoryMap.region[NVMD ].phys_addr_hi); nvmd_req.resp_addr_lo =
@@ -4889,7 +4889,7 @@ int pm8001_chip_get_nvmd_req(struct pm8001_hba_info *pm8001_ha, }case EXPAN_ROM : { nvmd_req.len_ir_vpdd =cpu_to_le32 (IPMode |EXPAN_ROM ); - nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->length); + nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->rd_length); nvmd_req.resp_addr_hi =cpu_to_le32 (pm8001_ha->memoryMap.region[NVMD ].phys_addr_hi); nvmd_req.resp_addr_lo =
@@ -4898,7 +4898,7 @@ int pm8001_chip_get_nvmd_req(struct pm8001_hba_info *pm8001_ha, }case IOP_RDUMP : { nvmd_req.len_ir_vpdd =cpu_to_le32 (IPMode |IOP_RDUMP ); - nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->length); + nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->rd_length); nvmd_req.vpd_offset =cpu_to_le32 (ioctl_payload->offset); nvmd_req.resp_addr_hi =cpu_to_le32 (pm8001_ha->memoryMap.region[NVMD ].phys_addr_hi);
@@ -4938,7 +4938,7 @@ int pm8001_chip_set_nvmd_req(struct pm8001_hba_info *pm8001_ha, circularQ = &pm8001_ha->inbnd_q_tbl[0 ];memcpy (pm8001_ha->memoryMap.region[NVMD ].virt_ptr, &ioctl_payload->func_specific, - ioctl_payload->length); + ioctl_payload->wr_length);memset (&nvmd_req,0 ,sizeof (nvmd_req)); rc =pm8001_tag_alloc (pm8001_ha, &tag);if (rc) {
@@ -4957,7 +4957,7 @@ int pm8001_chip_set_nvmd_req(struct pm8001_hba_info *pm8001_ha, nvmd_req.reserved[0 ] =cpu_to_le32 (0xFEDCBA98 ); nvmd_req.len_ir_vpdd =cpu_to_le32 (IPMode | twi_addr <<16 | twi_page_size <<8 |TWI_DEVICE ); - nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->length); + nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->wr_length); nvmd_req.resp_addr_hi =cpu_to_le32 (pm8001_ha->memoryMap.region[NVMD ].phys_addr_hi); nvmd_req.resp_addr_lo =
@@ -4966,7 +4966,7 @@ int pm8001_chip_set_nvmd_req(struct pm8001_hba_info *pm8001_ha, }case C_SEEPROM : nvmd_req.len_ir_vpdd =cpu_to_le32 (IPMode |C_SEEPROM ); - nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->length); + nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->wr_length); nvmd_req.reserved[0 ] =cpu_to_le32 (0xFEDCBA98 ); nvmd_req.resp_addr_hi =cpu_to_le32 (pm8001_ha->memoryMap.region[NVMD ].phys_addr_hi);
@@ -4975,7 +4975,7 @@ int pm8001_chip_set_nvmd_req(struct pm8001_hba_info *pm8001_ha,break ;case VPD_FLASH : nvmd_req.len_ir_vpdd =cpu_to_le32 (IPMode |VPD_FLASH ); - nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->length); + nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->wr_length); nvmd_req.reserved[0 ] =cpu_to_le32 (0xFEDCBA98 ); nvmd_req.resp_addr_hi =cpu_to_le32 (pm8001_ha->memoryMap.region[NVMD ].phys_addr_hi);
@@ -4984,7 +4984,7 @@ int pm8001_chip_set_nvmd_req(struct pm8001_hba_info *pm8001_ha,break ;case EXPAN_ROM : nvmd_req.len_ir_vpdd =cpu_to_le32 (IPMode |EXPAN_ROM ); - nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->length); + nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->wr_length); nvmd_req.reserved[0 ] =cpu_to_le32 (0xFEDCBA98 ); nvmd_req.resp_addr_hi =cpu_to_le32 (pm8001_ha->memoryMap.region[NVMD ].phys_addr_hi);
drivers/scsi/pm8001/pm8001_init.c +6 -6
@@ -643,22 +643,22 @@ static void pm8001_init_sas_add(struct pm8001_hba_info *pm8001_ha)if (pm8001_ha->chip_id == chip_8001) {if (deviceid ==0x8081 || deviceid ==0x0042 ) { payload.minor_function =4 ; - payload.length =4096 ; + payload.rd_length =4096 ; }else { payload.minor_function =0 ; - payload.length =128 ; + payload.rd_length =128 ; } }else if ((pm8001_ha->chip_id == chip_8070 || pm8001_ha->chip_id == chip_8072) && pm8001_ha->pdev->subsystem_vendor ==PCI_VENDOR_ID_ATTO ) { payload.minor_function =4 ; - payload.length =4096 ; + payload.rd_length =4096 ; }else { payload.minor_function =1 ; - payload.length =4096 ; + payload.rd_length =4096 ; } payload.offset =0 ; - payload.func_specific =kzalloc (payload.length,GFP_KERNEL ); + payload.func_specific =kzalloc (payload.rd_length,GFP_KERNEL );if (!payload.func_specific) {PM8001_INIT_DBG (pm8001_ha,pm8001_printk ("mem alloc fail\n" ));return ;
@@ -728,7 +728,7 @@ static int pm8001_get_phy_settings_info(struct pm8001_hba_info *pm8001_ha)/* SAS ADDRESS read from flash / EEPROM */ payload.minor_function =6 ; payload.offset =0 ; - payload.length =4096 ; + payload.rd_length =4096 ; payload.func_specific =kzalloc (4096 ,GFP_KERNEL );if (!payload.func_specific)return -ENOMEM ;
drivers/scsi/pm8001/pm8001_sas.h +2 -1
@@ -164,10 +164,11 @@ struct pm8001_ioctl_payload {u32 signature;u16 major_function;u16 minor_function; -u16 length;u16 status;u16 offset;u16 id; +u32 wr_length; +u32 rd_length;u8 *func_specific; };
Signature · 1 line
2.16.3
Re: [PATCH 11/12] pm80xx : Introduce read and write length for IOCTL payload structure.
Quoted 6 lines · Deepak Ukey
From: Viswas G <[email protected]>
Removed the common length and introduce read and write length for IOCTL payload structure.
Quoted 7 lines
Signed-off-by Deepak Ukey <[email protected]>Signed-off-by Viswas G <[email protected]>Signed-off-by Vishakha Channapattan <[email protected]>Signed-off-by Bhavesh Jashnani <[email protected]>Signed-off-by Radha Ramachandran <[email protected]>Signed-off-by Akshat Jain <[email protected]>Signed-off-by Yu Zheng <[email protected]>
Looks fine to me.
Quoted 202 lines
--- drivers/scsi/pm8001/pm8001_ctl.c | 6 +++--- drivers/scsi/pm8001/pm8001_hwi.c | 22 +++++++++++----------- drivers/scsi/pm8001/pm8001_init.c | 12 ++++++------ drivers/scsi/pm8001/pm8001_sas.h | 3 ++- 4 files changed, 22 insertions(+), 21 deletions(-)drivers/scsi/pm8001/pm8001_ctl.c +3
-3@@ -486,7 +486,7 @@ static ssize_t pm8001_ctl_bios_version_show(struct device *cdev, pm8001_ha->nvmd_completion = &completion; payload.minor_function =7 ; payload.offset =0 ; - payload.length =4096 ; + payload.rd_length =4096 ; payload.func_specific =kzalloc (4096 ,GFP_KERNEL );if (!payload.func_specific)return -ENOMEM ;@@ -697,7 +697,7 @@ static int pm8001_set_nvmd(struct pm8001_hba_info *pm8001_ha) payload = (struct pm8001_ioctl_payload *)ioctlbuffer;memcpy ((u8 *)&payload->func_specific, (u8 *)pm8001_ha->fw_image->data, pm8001_ha->fw_image->size); - payload->length = pm8001_ha->fw_image->size; + payload->wr_length = pm8001_ha->fw_image->size; payload->id =0 ; payload->minor_function =0x1 ; pm8001_ha->nvmd_completion = &completion;@@ -743,7 +743,7 @@ static int pm8001_update_flash(struct pm8001_hba_info *pm8001_ha) IOCTL_BUF_SIZE);for (loopNumber =0 ; loopNumber < loopcount; loopNumber++) { payload = (struct pm8001_ioctl_payload *)ioctlbuffer; - payload->length =1024 *16 ; + payload->wr_length =1024 *16 ; payload->id =0 ; fwControl = (struct fw_control_info *)&payload->func_specific;drivers/scsi/pm8001/pm8001_hwi.c +11
-11@@ -4841,7 +4841,7 @@ int pm8001_chip_get_nvmd_req(struct pm8001_hba_info *pm8001_ha,if (!fw_control_context)return -ENOMEM ; fw_control_context->usrAddr = (u8 *)ioctl_payload->func_specific; - fw_control_context->len = ioctl_payload->length; + fw_control_context->len = ioctl_payload->rd_length; circularQ = &pm8001_ha->inbnd_q_tbl[0 ];memset (&nvmd_req,0 ,sizeof (nvmd_req)); rc =pm8001_tag_alloc (pm8001_ha, &tag);@@ -4862,7 +4862,7 @@ int pm8001_chip_get_nvmd_req(struct pm8001_hba_info *pm8001_ha, nvmd_req.len_ir_vpdd =cpu_to_le32 (IPMode | twi_addr <<16 | twi_page_size <<8 |TWI_DEVICE ); - nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->length); + nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->rd_length); nvmd_req.resp_addr_hi =cpu_to_le32 (pm8001_ha->memoryMap.region[NVMD ].phys_addr_hi); nvmd_req.resp_addr_lo =@@ -4871,7 +4871,7 @@ int pm8001_chip_get_nvmd_req(struct pm8001_hba_info *pm8001_ha, }case C_SEEPROM : { nvmd_req.len_ir_vpdd =cpu_to_le32 (IPMode |C_SEEPROM ); - nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->length); + nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->rd_length); nvmd_req.resp_addr_hi =cpu_to_le32 (pm8001_ha->memoryMap.region[NVMD ].phys_addr_hi); nvmd_req.resp_addr_lo =@@ -4880,7 +4880,7 @@ int pm8001_chip_get_nvmd_req(struct pm8001_hba_info *pm8001_ha, }case VPD_FLASH : { nvmd_req.len_ir_vpdd =cpu_to_le32 (IPMode |VPD_FLASH ); - nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->length); + nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->rd_length); nvmd_req.resp_addr_hi =cpu_to_le32 (pm8001_ha->memoryMap.region[NVMD ].phys_addr_hi); nvmd_req.resp_addr_lo =@@ -4889,7 +4889,7 @@ int pm8001_chip_get_nvmd_req(struct pm8001_hba_info *pm8001_ha, }case EXPAN_ROM : { nvmd_req.len_ir_vpdd =cpu_to_le32 (IPMode |EXPAN_ROM ); - nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->length); + nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->rd_length); nvmd_req.resp_addr_hi =cpu_to_le32 (pm8001_ha->memoryMap.region[NVMD ].phys_addr_hi); nvmd_req.resp_addr_lo =@@ -4898,7 +4898,7 @@ int pm8001_chip_get_nvmd_req(struct pm8001_hba_info *pm8001_ha, }case IOP_RDUMP : { nvmd_req.len_ir_vpdd =cpu_to_le32 (IPMode |IOP_RDUMP ); - nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->length); + nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->rd_length); nvmd_req.vpd_offset =cpu_to_le32 (ioctl_payload->offset); nvmd_req.resp_addr_hi =cpu_to_le32 (pm8001_ha->memoryMap.region[NVMD ].phys_addr_hi);@@ -4938,7 +4938,7 @@ int pm8001_chip_set_nvmd_req(struct pm8001_hba_info *pm8001_ha, circularQ = &pm8001_ha->inbnd_q_tbl[0 ];memcpy (pm8001_ha->memoryMap.region[NVMD ].virt_ptr, &ioctl_payload->func_specific, - ioctl_payload->length); + ioctl_payload->wr_length);memset (&nvmd_req,0 ,sizeof (nvmd_req)); rc =pm8001_tag_alloc (pm8001_ha, &tag);if (rc) {@@ -4957,7 +4957,7 @@ int pm8001_chip_set_nvmd_req(struct pm8001_hba_info *pm8001_ha, nvmd_req.reserved[0 ] =cpu_to_le32 (0xFEDCBA98 ); nvmd_req.len_ir_vpdd =cpu_to_le32 (IPMode | twi_addr <<16 | twi_page_size <<8 |TWI_DEVICE ); - nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->length); + nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->wr_length); nvmd_req.resp_addr_hi =cpu_to_le32 (pm8001_ha->memoryMap.region[NVMD ].phys_addr_hi); nvmd_req.resp_addr_lo =@@ -4966,7 +4966,7 @@ int pm8001_chip_set_nvmd_req(struct pm8001_hba_info *pm8001_ha, }case C_SEEPROM : nvmd_req.len_ir_vpdd =cpu_to_le32 (IPMode |C_SEEPROM ); - nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->length); + nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->wr_length); nvmd_req.reserved[0 ] =cpu_to_le32 (0xFEDCBA98 ); nvmd_req.resp_addr_hi =cpu_to_le32 (pm8001_ha->memoryMap.region[NVMD ].phys_addr_hi);@@ -4975,7 +4975,7 @@ int pm8001_chip_set_nvmd_req(struct pm8001_hba_info *pm8001_ha,break ;case VPD_FLASH : nvmd_req.len_ir_vpdd =cpu_to_le32 (IPMode |VPD_FLASH ); - nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->length); + nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->wr_length); nvmd_req.reserved[0 ] =cpu_to_le32 (0xFEDCBA98 ); nvmd_req.resp_addr_hi =cpu_to_le32 (pm8001_ha->memoryMap.region[NVMD ].phys_addr_hi);@@ -4984,7 +4984,7 @@ int pm8001_chip_set_nvmd_req(struct pm8001_hba_info *pm8001_ha,break ;case EXPAN_ROM : nvmd_req.len_ir_vpdd =cpu_to_le32 (IPMode |EXPAN_ROM ); - nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->length); + nvmd_req.resp_len =cpu_to_le32 (ioctl_payload->wr_length); nvmd_req.reserved[0 ] =cpu_to_le32 (0xFEDCBA98 ); nvmd_req.resp_addr_hi =cpu_to_le32 (pm8001_ha->memoryMap.region[NVMD ].phys_addr_hi);drivers/scsi/pm8001/pm8001_init.c +6
-6@@ -643,22 +643,22 @@ static void pm8001_init_sas_add(struct pm8001_hba_info *pm8001_ha)if (pm8001_ha->chip_id == chip_8001) {if (deviceid ==0x8081 || deviceid ==0x0042 ) { payload.minor_function =4 ; - payload.length =4096 ; + payload.rd_length =4096 ; }else { payload.minor_function =0 ; - payload.length =128 ; + payload.rd_length =128 ; } }else if ((pm8001_ha->chip_id == chip_8070 || pm8001_ha->chip_id == chip_8072) && pm8001_ha->pdev->subsystem_vendor ==PCI_VENDOR_ID_ATTO ) { payload.minor_function =4 ; - payload.length =4096 ; + payload.rd_length =4096 ; }else { payload.minor_function =1 ; - payload.length =4096 ; + payload.rd_length =4096 ; } payload.offset =0 ; - payload.func_specific =kzalloc (payload.length,GFP_KERNEL ); + payload.func_specific =kzalloc (payload.rd_length,GFP_KERNEL );if (!payload.func_specific) {PM8001_INIT_DBG (pm8001_ha,pm8001_printk ("mem alloc fail\n" ));return ;@@ -728,7 +728,7 @@ static int pm8001_get_phy_settings_info(struct pm8001_hba_info *pm8001_ha)/* SAS ADDRESS read from flash / EEPROM */ payload.minor_function =6 ; payload.offset =0 ; - payload.length =4096 ; + payload.rd_length =4096 ; payload.func_specific =kzalloc (4096 ,GFP_KERNEL );if (!payload.func_specific)return -ENOMEM ;drivers/scsi/pm8001/pm8001_sas.h +2
-2@@ -164,10 +164,11 @@ struct pm8001_ioctl_payload {u32 signature;u16 major_function;u16 minor_function; -u16 length;u16 status;u16 offset;u16 id; +u32 wr_length; +u32 rd_length;u8 *func_specific; }; --2.16.3
PATCH 12/12 pm80xx : IOCTL functionality for TWI device.
In reply to Deepak UkeyFrom: Viswas G <[email protected]>
Added the IOCTL functionality for TWI device.
--- drivers/scsi/pm8001/pm8001_ctl.c | 133 ++++++++++++++++++++++++++++++++++++++ drivers/scsi/pm8001/pm8001_ctl.h | 23 +++++++ drivers/scsi/pm8001/pm8001_hwi.c | 113 ++++++++++++++++++++++++++------ drivers/scsi/pm8001/pm8001_hwi.h | 1 + drivers/scsi/pm8001/pm8001_init.c | 10 +++ drivers/scsi/pm8001/pm8001_sas.h | 13 ++++ drivers/scsi/pm8001/pm80xx_hwi.c | 41 ++++++++++++ drivers/scsi/pm8001/pm80xx_hwi.h | 1 + 8 files changed, 314 insertions(+), 21 deletions(-)
drivers/scsi/pm8001/pm8001_ctl.c +133 -0
@@ -1124,6 +1124,126 @@ static long pm8001_sgpio_ioctl(struct pm8001_hba_info *pm8001_ha,return ret; } +static int icotl_twi_wr_request (int twi_wr, +struct pm8001_hba_info *pm8001_ha,unsigned long arg) +{ +int ret =0 ; +unsigned char *buf; +int bus; +int addr; +bool addr_mode_7bit = true; +int rd_size =0 ; +int wr_size =0 ; +int offset =0 ; +bool direct_addr = true; +struct twi_ioctl_payload *twi_ioctl; + + twi_ioctl =kmalloc (sizeof (struct twi_ioctl_payload ),GFP_KERNEL ); +if (!twi_ioctl) { +PM8001_FAIL_DBG (pm8001_ha, +pm8001_printk ("Failed to allocate ioctl\n" )); +return -ENOMEM ; + } + ret =copy_from_user (twi_ioctl, (u8 *)arg,sizeof (*twi_ioctl)); +if (ret) { +PM8001_FAIL_DBG (pm8001_ha, +pm8001_printk ("Failed to get ioctl args\n" )); +return -EIO ; + } + + bus = twi_ioctl->bus; + addr = twi_ioctl->addr; + +switch (twi_wr) { +case TW_WRITE : + wr_size = twi_ioctl->wr_size; +/* first 1K read/write is not possible, +* from 2k we have customer specific seeprom +*/ + offset = twi_ioctl->offset; +if (wr_size >48 ) + direct_addr = false; + buf =kzalloc (wr_size,GFP_KERNEL ); + +if (buf ==NULL ) { +PM8001_FAIL_DBG (pm8001_ha, +pm8001_printk ("No Memory for write\n" )); +return -ENOMEM ; + } + ret =copy_from_user (buf, (u8 *)twi_ioctl->buf, wr_size); +if (!ret) { + ret =pm80xx_twi_wr_request (pm8001_ha, bus, addr, + addr_mode_7bit, rd_size, wr_size, offset, + direct_addr, buf); + }else { +PM8001_FAIL_DBG (pm8001_ha,pm8001_printk + ("Failed to get data from buffer\n" )); +return -EIO ; + } +kfree (buf); +break ; +case TW_READ : + rd_size = twi_ioctl->rd_size; + offset = twi_ioctl->offset; +if (rd_size >48 ) + direct_addr = false; + buf =kzalloc (rd_size,GFP_KERNEL ); +if (buf ==NULL ) { +PM8001_FAIL_DBG (pm8001_ha, +pm8001_printk ("No Memory for read\n" )); +return -ENOMEM ; + } + ret =pm80xx_twi_wr_request (pm8001_ha, bus, addr, + addr_mode_7bit, rd_size, wr_size, offset, + direct_addr, buf); +if (!ret) { + ret =copy_to_user ((u8 *)twi_ioctl->buf, buf, rd_size); +kfree (buf); + }else { +PM8001_FAIL_DBG (pm8001_ha,pm8001_printk + ("pm80xx_twi_wr_request failed !!!\n" )); +return -EIO ; + } +break ; +case TW_WRITE_READ : + rd_size = twi_ioctl->rd_size; + wr_size = twi_ioctl->wr_size; + offset = twi_ioctl->offset; +if (wr_size >48 || rd_size >48 ) + direct_addr = false; + buf =kzalloc (max_t (int, wr_size, rd_size),GFP_KERNEL ); +if (buf ==NULL ) { +PM8001_FAIL_DBG (pm8001_ha, +pm8001_printk ("No Memory for read\n" )); +return -ENOMEM ; + } + ret =copy_from_user (buf, (u8 *)twi_ioctl->buf, wr_size); +if (!ret) { + ret =pm80xx_twi_wr_request (pm8001_ha, bus, addr, + addr_mode_7bit, rd_size, wr_size, offset, + direct_addr, buf); +if (!ret) + ret =copy_to_user ((u8 *)twi_ioctl->buf, + buf, rd_size); +else { +PM8001_FAIL_DBG (pm8001_ha,pm8001_printk + ("Failed to copy data to read buffer\n" )); + ret = -EIO ; + } + }else { +PM8001_FAIL_DBG (pm8001_ha,pm8001_printk + ("Failed to get data from write buffer\n" )); +return -ENOMEM ; + } +break ; +default : +PM8001_FAIL_DBG (pm8001_ha,pm8001_printk + ("Invalid twi operation\n" )); +return -EINVAL ; + } +return ret; +} +static int pm8001_ioctl_get_phy_profile (struct pm8001_hba_info *pm8001_ha,unsigned long arg) {
@@ -1277,6 +1397,7 @@ static long pm8001_ioctl(struct file *file,u32 ret = -EACCES ;struct pm8001_hba_info *pm8001_ha;struct ioctl_header header; +u8 twi_wr =0 ; pm8001_ha = file->private_data;
@@ -1296,6 +1417,18 @@ static long pm8001_ioctl(struct file *file,case ADPT_IOCTL_GET_PHY_ERR_CNT : ret =pm8001_ioctl_get_phy_err (pm8001_ha, arg);break ; +case ADPT_IOCTL_TWI_WRITE : + twi_wr =0x01 ; + ret =icotl_twi_wr_request (twi_wr, pm8001_ha, arg); +return ret; +case ADPT_IOCTL_TWI_READ : + twi_wr =0x02 ; + ret =icotl_twi_wr_request (twi_wr, pm8001_ha, arg); +return ret; +case ADPT_IOCTL_TWI_WRITE_READ : + twi_wr =0x03 ; + ret =icotl_twi_wr_request (twi_wr, pm8001_ha, arg); +return ret;default : ret =ADPT_IOCTL_CALL_INVALID_CODE ; }
drivers/scsi/pm8001/pm8001_ctl.h +23 -0
@@ -101,6 +101,26 @@#define SGPIO_CMD_ERROR_WRONG_FRAME_REG_TYPE_REG_INDEX 0x1D#define SGPIO_CMD_ERROR_WRONG_ALL_HEADER_PARAMS 0x9D +#define TWI_SEEPROM_BUS_NUMBER 0 +#define TWI_SEEPROM_DEV_ADDR 0xa0 +#define TWI_SEEPROM_READ_SIZE 1024 +#define TWI_SEEPROM_WRITE_SIZE 1024 + +#define TW_IOCTL_STATUS_SUCCESS 0 +#define TW_IOCTL_STATUS_FAILURE 1 +#define TW_IOCTL_STATUS_WRONG_ADDR 0xA + +struct twi_ioctl_payload { +u32 bus; +u32 addr; +u32 rd_size; +u32 wr_size; +u32 offset; +u8 addr_mode; +u8 *buf; +u32 status; +}; +struct ioctl_header {u32 io_controller_num;u32 length;
@@ -219,6 +239,9 @@ struct phy_prof_resp { struct phy_profile*)#define ADPT_IOCTL_GET_PHY_ERR_CNT _IOWR(ADPT_MAGIC_NUMBER, 9, \ struct phy_err*) +#define ADPT_IOCTL_TWI_READ _IOR('m', 10, char *) +#define ADPT_IOCTL_TWI_WRITE _IOW('m', 11, char *) +#define ADPT_IOCTL_TWI_WRITE_READ _IOWR('m', 12, char *)#define ADPT_MAGIC_NUMBER 'm'#endif /* PM8001_CTL_H_INCLUDED */
drivers/scsi/pm8001/pm8001_hwi.c +92 -21
160 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_hwi.h +1 -0
@@ -634,6 +634,7 @@ struct set_nvm_data_req {__le32 resp_addr_hi;__le32 resp_len;u32 reserved1; +__le32 tr_dl; } __attribute__((packed, aligned(4)));
drivers/scsi/pm8001/pm8001_init.c +10 -0
@@ -55,6 +55,14 @@ MODULE_PARM_DESC(link_rate, "Enable link rate.\n"" 4: Link rate 6.0G\n" " 8: Link rate 12.0G\n"); +static ulong twi_address =0xa0 ; +module_param (twi_address, ulong,0644 ); +MODULE_PARM_DESC (twi_address,"set the address of twi device." ); + +static ulong twi_page_size; +module_param (twi_page_size, ulong,0644 ); +MODULE_PARM_DESC (twi_page_size,"set the page size of twi device." ); +static struct scsi_transport_template *pm8001_stt;/**
@@ -484,6 +492,8 @@ static struct pm8001_hba_info *pm8001_pci_alloc(struct pci_dev *pdev, pm8001_ha->shost = shost; pm8001_ha->id = pm8001_id++; pm8001_ha->logging_level = logging_level; + pm8001_ha->twi_address = twi_address; + pm8001_ha->twi_page_size = twi_page_size; pm8001_ha->non_fatal_count =0 ;if (link_rate >=1 && link_rate <=15 ) pm8001_ha->link_rate = (link_rate <<8 );
drivers/scsi/pm8001/pm8001_sas.h +13 -0
@@ -169,6 +169,9 @@ struct pm8001_ioctl_payload {u16 id;u32 wr_length;u32 rd_length; +bool twi_direct_addr; +u8 bus; +u8 twi_addr;u8 *func_specific; };
@@ -586,6 +589,8 @@ struct pm8001_hba_info {#endif u32 logging_level;u32 link_rate; +u32 twi_address; +u32 twi_page_size;u32 fw_status;u32 smp_exp_mode;bool controller_fatal_error;
@@ -650,6 +655,11 @@ struct pm8001_fw_image_header {#define DS_IN_ERROR 0x04#define DS_NON_OPERATIONAL 0x07 +#define TR_MASK 0x60000000 +#define TW_WRITE 0x01 +#define TW_READ 0x02 +#define TW_WRITE_READ 0x03 +/** * brief param structure for firmware flash update. */
@@ -796,6 +806,9 @@ ssize_t pm80xx_get_fatal_dump(struct device *cdev,ssize_t pm80xx_get_non_fatal_dump (struct device *cdev,struct device_attribute *attr,char *buf);ssize_t pm8001_get_gsm_dump (struct device *cdev,u32 ,char *buf); +int pm80xx_twi_wr_request (struct pm8001_hba_info *pm8001_ha,int bus,int addr, +bool addr_mode_7bit,int rd_size,int wr_size, +int offset,bool direct_addr,unsigned char *buf);/* ctl shared API */ extern struct device_attribute *pm8001_host_attrs[];
drivers/scsi/pm8001/pm80xx_hwi.c +41 -0
47 lines not on this page · raw message
drivers/scsi/pm8001/pm80xx_hwi.h +1 -0
@@ -966,6 +966,7 @@ struct set_nvm_data_req {__le32 resp_addr_hi;__le32 resp_len;u32 reserved1[17 ]; +__le32 tr_dl; } __attribute__((packed, aligned(4)));/**
Signature · 1 line
2.16.3
Jinpu Wang
maintainerRe: [PATCH 12/12] pm80xx : IOCTL functionality for TWI device.
Quoted 5 lines · Deepak Ukey
From: Viswas G <[email protected]>
Added the IOCTL functionality for TWI device.
Please extend the commit message, what's the new functionality, what's the use case.
Thanks
RE: [PATCH 12/12] pm80xx : IOCTL functionality for TWI device.
Thanks Jinpu Wang . We will address this in the v2 patch set.
Regards,
Viswas G
-----Original Message-----
From: Jinpu Wang <[email protected]>
Sent: Thursday, January 2, 2020 5:51 PM
To: Deepak Ukey - I31172 <[email protected]>
Cc: Linux SCSI Mailinglist <[email protected]>; Vasanthalakshmi Tharmarajan - I30664 <[email protected]>; Viswas G - I30667 <[email protected]>; Jack Wang <[email protected]>; Martin K. Petersen <[email protected]>; [email protected]; [email protected]; Vikram Auradkar <[email protected]>; [email protected]; [email protected]; Radha Ramachandran <[email protected]>; [email protected]
Subject: Re: [PATCH 12/12] pm80xx : IOCTL functionality for TWI device.
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Quoted 5 lines · Deepak Ukey
From: Viswas G <[email protected]>
Added the IOCTL functionality for TWI device.
Please extend the commit message, what's the new functionality, what's the use case.
Thanks