diff options
author | Kashyap, Desai <kashyap.desai@lsi.com> | 2009-05-29 07:22:37 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2009-06-09 18:43:06 -0400 |
commit | 2f187862e579f1f5e883188cab6bd867cb60387f (patch) | |
tree | 85785a2e0e176da653323f1a8cf133f7e9e86ca6 /drivers/message/fusion/mptsas.c | |
parent | eedf92b99806aeff18dc21c9dfb28999ce374413 (diff) |
[SCSI] mpt fusion: Code Cleanup patch
Resending patch considering Grants G's code review.
Main goal to submit this patch is code cleaup.
1. Better driver debug prints and code indentation.
2. fault_reset_work_lock is not used anywhere. driver is using taskmgmt_lock
instead of fault_reset_work_lock.
3. setting pci_set_drvdata properly.
4. Ingore config request when IOC is in reset state.( ioc_reset_in_progress
is set).
5. Init/clear managment frame proprely.(INITIALIZE_MGMT_STATUS and
CLEAR_MGMT_STATUS)
Signed-off-by: Kashyap Desai <kadesai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/message/fusion/mptsas.c')
-rw-r--r-- | drivers/message/fusion/mptsas.c | 94 |
1 files changed, 62 insertions, 32 deletions
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c index 6aa91268afe9..da22141152d7 100644 --- a/drivers/message/fusion/mptsas.c +++ b/drivers/message/fusion/mptsas.c | |||
@@ -724,8 +724,8 @@ mptsas_setup_wide_ports(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info) | |||
724 | * Forming a port | 724 | * Forming a port |
725 | */ | 725 | */ |
726 | if (!port_details) { | 726 | if (!port_details) { |
727 | port_details = kzalloc(sizeof(*port_details), | 727 | port_details = kzalloc(sizeof(struct |
728 | GFP_KERNEL); | 728 | mptsas_portinfo_details), GFP_KERNEL); |
729 | if (!port_details) | 729 | if (!port_details) |
730 | goto out; | 730 | goto out; |
731 | port_details->num_phys = 1; | 731 | port_details->num_phys = 1; |
@@ -952,7 +952,7 @@ mptsas_target_reset_queue(MPT_ADAPTER *ioc, | |||
952 | 952 | ||
953 | vtarget->deleted = 1; /* block IO */ | 953 | vtarget->deleted = 1; /* block IO */ |
954 | 954 | ||
955 | target_reset_list = kzalloc(sizeof(*target_reset_list), | 955 | target_reset_list = kzalloc(sizeof(struct mptsas_target_reset_event), |
956 | GFP_ATOMIC); | 956 | GFP_ATOMIC); |
957 | if (!target_reset_list) { | 957 | if (!target_reset_list) { |
958 | dfailprintk(ioc, printk(MYIOC_s_WARN_FMT | 958 | dfailprintk(ioc, printk(MYIOC_s_WARN_FMT |
@@ -1791,8 +1791,13 @@ static int mptsas_mgmt_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *req, | |||
1791 | memcpy(ioc->sas_mgmt.reply, reply, | 1791 | memcpy(ioc->sas_mgmt.reply, reply, |
1792 | min(ioc->reply_sz, 4 * reply->u.reply.MsgLength)); | 1792 | min(ioc->reply_sz, 4 * reply->u.reply.MsgLength)); |
1793 | } | 1793 | } |
1794 | complete(&ioc->sas_mgmt.done); | 1794 | |
1795 | return 1; | 1795 | if (ioc->sas_mgmt.status & MPT_MGMT_STATUS_PENDING) { |
1796 | ioc->sas_mgmt.status &= ~MPT_MGMT_STATUS_PENDING; | ||
1797 | complete(&ioc->sas_mgmt.done); | ||
1798 | return 1; | ||
1799 | } | ||
1800 | return 0; | ||
1796 | } | 1801 | } |
1797 | 1802 | ||
1798 | static int mptsas_phy_reset(struct sas_phy *phy, int hard_reset) | 1803 | static int mptsas_phy_reset(struct sas_phy *phy, int hard_reset) |
@@ -1831,6 +1836,7 @@ static int mptsas_phy_reset(struct sas_phy *phy, int hard_reset) | |||
1831 | MPI_SAS_OP_PHY_HARD_RESET : MPI_SAS_OP_PHY_LINK_RESET; | 1836 | MPI_SAS_OP_PHY_HARD_RESET : MPI_SAS_OP_PHY_LINK_RESET; |
1832 | req->PhyNum = phy->identify.phy_identifier; | 1837 | req->PhyNum = phy->identify.phy_identifier; |
1833 | 1838 | ||
1839 | INITIALIZE_MGMT_STATUS(ioc->sas_mgmt.status) | ||
1834 | mpt_put_msg_frame(mptsasMgmtCtx, ioc, mf); | 1840 | mpt_put_msg_frame(mptsasMgmtCtx, ioc, mf); |
1835 | 1841 | ||
1836 | timeleft = wait_for_completion_timeout(&ioc->sas_mgmt.done, | 1842 | timeleft = wait_for_completion_timeout(&ioc->sas_mgmt.done, |
@@ -1862,6 +1868,7 @@ static int mptsas_phy_reset(struct sas_phy *phy, int hard_reset) | |||
1862 | error = 0; | 1868 | error = 0; |
1863 | 1869 | ||
1864 | out_unlock: | 1870 | out_unlock: |
1871 | CLEAR_MGMT_STATUS(ioc->sas_mgmt.status) | ||
1865 | mutex_unlock(&ioc->sas_mgmt.mutex); | 1872 | mutex_unlock(&ioc->sas_mgmt.mutex); |
1866 | out: | 1873 | out: |
1867 | return error; | 1874 | return error; |
@@ -1999,10 +2006,15 @@ static int mptsas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, | |||
1999 | if (!dma_addr_out) | 2006 | if (!dma_addr_out) |
2000 | goto put_mf; | 2007 | goto put_mf; |
2001 | ioc->add_sge(psge, flagsLength, dma_addr_out); | 2008 | ioc->add_sge(psge, flagsLength, dma_addr_out); |
2002 | psge += (sizeof(u32) + sizeof(dma_addr_t)); | 2009 | psge += ioc->SGE_size; |
2003 | 2010 | ||
2004 | /* response */ | 2011 | /* response */ |
2005 | flagsLength = MPT_SGE_FLAGS_SSIMPLE_READ; | 2012 | flagsLength = MPI_SGE_FLAGS_SIMPLE_ELEMENT | |
2013 | MPI_SGE_FLAGS_SYSTEM_ADDRESS | | ||
2014 | MPI_SGE_FLAGS_IOC_TO_HOST | | ||
2015 | MPI_SGE_FLAGS_END_OF_BUFFER; | ||
2016 | |||
2017 | flagsLength = flagsLength << MPI_SGE_FLAGS_SHIFT; | ||
2006 | flagsLength |= rsp->data_len + 4; | 2018 | flagsLength |= rsp->data_len + 4; |
2007 | dma_addr_in = pci_map_single(ioc->pcidev, bio_data(rsp->bio), | 2019 | dma_addr_in = pci_map_single(ioc->pcidev, bio_data(rsp->bio), |
2008 | rsp->data_len, PCI_DMA_BIDIRECTIONAL); | 2020 | rsp->data_len, PCI_DMA_BIDIRECTIONAL); |
@@ -2010,6 +2022,7 @@ static int mptsas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, | |||
2010 | goto unmap; | 2022 | goto unmap; |
2011 | ioc->add_sge(psge, flagsLength, dma_addr_in); | 2023 | ioc->add_sge(psge, flagsLength, dma_addr_in); |
2012 | 2024 | ||
2025 | INITIALIZE_MGMT_STATUS(ioc->sas_mgmt.status) | ||
2013 | mpt_put_msg_frame(mptsasMgmtCtx, ioc, mf); | 2026 | mpt_put_msg_frame(mptsasMgmtCtx, ioc, mf); |
2014 | 2027 | ||
2015 | timeleft = wait_for_completion_timeout(&ioc->sas_mgmt.done, 10 * HZ); | 2028 | timeleft = wait_for_completion_timeout(&ioc->sas_mgmt.done, 10 * HZ); |
@@ -2031,7 +2044,8 @@ static int mptsas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, | |||
2031 | req->data_len = 0; | 2044 | req->data_len = 0; |
2032 | rsp->data_len -= smprep->ResponseDataLength; | 2045 | rsp->data_len -= smprep->ResponseDataLength; |
2033 | } else { | 2046 | } else { |
2034 | printk(MYIOC_s_ERR_FMT "%s: smp passthru reply failed to be returned\n", | 2047 | printk(MYIOC_s_ERR_FMT |
2048 | "%s: smp passthru reply failed to be returned\n", | ||
2035 | ioc->name, __func__); | 2049 | ioc->name, __func__); |
2036 | ret = -ENXIO; | 2050 | ret = -ENXIO; |
2037 | } | 2051 | } |
@@ -2046,6 +2060,7 @@ put_mf: | |||
2046 | if (mf) | 2060 | if (mf) |
2047 | mpt_free_msg_frame(ioc, mf); | 2061 | mpt_free_msg_frame(ioc, mf); |
2048 | out_unlock: | 2062 | out_unlock: |
2063 | CLEAR_MGMT_STATUS(ioc->sas_mgmt.status) | ||
2049 | mutex_unlock(&ioc->sas_mgmt.mutex); | 2064 | mutex_unlock(&ioc->sas_mgmt.mutex); |
2050 | out: | 2065 | out: |
2051 | return ret; | 2066 | return ret; |
@@ -2109,7 +2124,7 @@ mptsas_sas_io_unit_pg0(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info) | |||
2109 | 2124 | ||
2110 | port_info->num_phys = buffer->NumPhys; | 2125 | port_info->num_phys = buffer->NumPhys; |
2111 | port_info->phy_info = kcalloc(port_info->num_phys, | 2126 | port_info->phy_info = kcalloc(port_info->num_phys, |
2112 | sizeof(*port_info->phy_info),GFP_KERNEL); | 2127 | sizeof(struct mptsas_phyinfo), GFP_KERNEL); |
2113 | if (!port_info->phy_info) { | 2128 | if (!port_info->phy_info) { |
2114 | error = -ENOMEM; | 2129 | error = -ENOMEM; |
2115 | goto out_free_consistent; | 2130 | goto out_free_consistent; |
@@ -2271,10 +2286,6 @@ mptsas_sas_device_pg0(MPT_ADAPTER *ioc, struct mptsas_devinfo *device_info, | |||
2271 | __le64 sas_address; | 2286 | __le64 sas_address; |
2272 | int error=0; | 2287 | int error=0; |
2273 | 2288 | ||
2274 | if (ioc->sas_discovery_runtime && | ||
2275 | mptsas_is_end_device(device_info)) | ||
2276 | goto out; | ||
2277 | |||
2278 | hdr.PageVersion = MPI_SASDEVICE0_PAGEVERSION; | 2289 | hdr.PageVersion = MPI_SASDEVICE0_PAGEVERSION; |
2279 | hdr.ExtPageLength = 0; | 2290 | hdr.ExtPageLength = 0; |
2280 | hdr.PageNumber = 0; | 2291 | hdr.PageNumber = 0; |
@@ -2315,6 +2326,7 @@ mptsas_sas_device_pg0(MPT_ADAPTER *ioc, struct mptsas_devinfo *device_info, | |||
2315 | 2326 | ||
2316 | mptsas_print_device_pg0(ioc, buffer); | 2327 | mptsas_print_device_pg0(ioc, buffer); |
2317 | 2328 | ||
2329 | memset(device_info, 0, sizeof(struct mptsas_devinfo)); | ||
2318 | device_info->handle = le16_to_cpu(buffer->DevHandle); | 2330 | device_info->handle = le16_to_cpu(buffer->DevHandle); |
2319 | device_info->handle_parent = le16_to_cpu(buffer->ParentDevHandle); | 2331 | device_info->handle_parent = le16_to_cpu(buffer->ParentDevHandle); |
2320 | device_info->handle_enclosure = | 2332 | device_info->handle_enclosure = |
@@ -2346,7 +2358,9 @@ mptsas_sas_expander_pg0(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info, | |||
2346 | SasExpanderPage0_t *buffer; | 2358 | SasExpanderPage0_t *buffer; |
2347 | dma_addr_t dma_handle; | 2359 | dma_addr_t dma_handle; |
2348 | int i, error; | 2360 | int i, error; |
2361 | __le64 sas_address; | ||
2349 | 2362 | ||
2363 | memset(port_info, 0, sizeof(struct mptsas_portinfo)); | ||
2350 | hdr.PageVersion = MPI_SASEXPANDER0_PAGEVERSION; | 2364 | hdr.PageVersion = MPI_SASEXPANDER0_PAGEVERSION; |
2351 | hdr.ExtPageLength = 0; | 2365 | hdr.ExtPageLength = 0; |
2352 | hdr.PageNumber = 0; | 2366 | hdr.PageNumber = 0; |
@@ -2392,18 +2406,23 @@ mptsas_sas_expander_pg0(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info, | |||
2392 | } | 2406 | } |
2393 | 2407 | ||
2394 | /* save config data */ | 2408 | /* save config data */ |
2395 | port_info->num_phys = buffer->NumPhys; | 2409 | port_info->num_phys = (buffer->NumPhys) ? buffer->NumPhys : 1; |
2396 | port_info->phy_info = kcalloc(port_info->num_phys, | 2410 | port_info->phy_info = kcalloc(port_info->num_phys, |
2397 | sizeof(*port_info->phy_info),GFP_KERNEL); | 2411 | sizeof(struct mptsas_phyinfo), GFP_KERNEL); |
2398 | if (!port_info->phy_info) { | 2412 | if (!port_info->phy_info) { |
2399 | error = -ENOMEM; | 2413 | error = -ENOMEM; |
2400 | goto out_free_consistent; | 2414 | goto out_free_consistent; |
2401 | } | 2415 | } |
2402 | 2416 | ||
2417 | memcpy(&sas_address, &buffer->SASAddress, sizeof(__le64)); | ||
2403 | for (i = 0; i < port_info->num_phys; i++) { | 2418 | for (i = 0; i < port_info->num_phys; i++) { |
2404 | port_info->phy_info[i].portinfo = port_info; | 2419 | port_info->phy_info[i].portinfo = port_info; |
2405 | port_info->phy_info[i].handle = | 2420 | port_info->phy_info[i].handle = |
2406 | le16_to_cpu(buffer->DevHandle); | 2421 | le16_to_cpu(buffer->DevHandle); |
2422 | port_info->phy_info[i].identify.sas_address = | ||
2423 | le64_to_cpu(sas_address); | ||
2424 | port_info->phy_info[i].identify.handle_parent = | ||
2425 | le16_to_cpu(buffer->ParentDevHandle); | ||
2407 | } | 2426 | } |
2408 | 2427 | ||
2409 | out_free_consistent: | 2428 | out_free_consistent: |
@@ -2423,11 +2442,7 @@ mptsas_sas_expander_pg1(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, | |||
2423 | dma_addr_t dma_handle; | 2442 | dma_addr_t dma_handle; |
2424 | int error=0; | 2443 | int error=0; |
2425 | 2444 | ||
2426 | if (ioc->sas_discovery_runtime && | 2445 | hdr.PageVersion = MPI_SASEXPANDER1_PAGEVERSION; |
2427 | mptsas_is_end_device(&phy_info->attached)) | ||
2428 | goto out; | ||
2429 | |||
2430 | hdr.PageVersion = MPI_SASEXPANDER0_PAGEVERSION; | ||
2431 | hdr.ExtPageLength = 0; | 2446 | hdr.ExtPageLength = 0; |
2432 | hdr.PageNumber = 1; | 2447 | hdr.PageNumber = 1; |
2433 | hdr.Reserved1 = 0; | 2448 | hdr.Reserved1 = 0; |
@@ -2462,6 +2477,12 @@ mptsas_sas_expander_pg1(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, | |||
2462 | cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT; | 2477 | cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT; |
2463 | 2478 | ||
2464 | error = mpt_config(ioc, &cfg); | 2479 | error = mpt_config(ioc, &cfg); |
2480 | |||
2481 | if (error == MPI_IOCSTATUS_CONFIG_INVALID_PAGE) { | ||
2482 | error = -ENODEV; | ||
2483 | goto out; | ||
2484 | } | ||
2485 | |||
2465 | if (error) | 2486 | if (error) |
2466 | goto out_free_consistent; | 2487 | goto out_free_consistent; |
2467 | 2488 | ||
@@ -2681,16 +2702,21 @@ static int mptsas_probe_one_phy(struct device *dev, | |||
2681 | goto out; | 2702 | goto out; |
2682 | } | 2703 | } |
2683 | mptsas_set_port(ioc, phy_info, port); | 2704 | mptsas_set_port(ioc, phy_info, port); |
2684 | dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT | 2705 | devtprintk(ioc, dev_printk(KERN_DEBUG, &port->dev, |
2685 | "sas_port_alloc: port=%p dev=%p port_id=%d\n", | 2706 | MYIOC_s_FMT "add port %d, sas_addr (0x%llx)\n", |
2686 | ioc->name, port, dev, port->port_identifier)); | 2707 | ioc->name, port->port_identifier, |
2708 | (unsigned long long)phy_info-> | ||
2709 | attached.sas_address)); | ||
2687 | } | 2710 | } |
2688 | dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_port_add_phy: phy_id=%d\n", | 2711 | dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
2689 | ioc->name, phy_info->phy_id)); | 2712 | "sas_port_add_phy: phy_id=%d\n", |
2713 | ioc->name, phy_info->phy_id)); | ||
2690 | sas_port_add_phy(port, phy_info->phy); | 2714 | sas_port_add_phy(port, phy_info->phy); |
2691 | phy_info->sas_port_add_phy = 0; | 2715 | phy_info->sas_port_add_phy = 0; |
2716 | devtprintk(ioc, dev_printk(KERN_DEBUG, &phy_info->phy->dev, | ||
2717 | MYIOC_s_FMT "add phy %d, phy-obj (0x%p)\n", ioc->name, | ||
2718 | phy_info->phy_id, phy_info->phy)); | ||
2692 | } | 2719 | } |
2693 | |||
2694 | if (!mptsas_get_rphy(phy_info) && port && !port->rphy) { | 2720 | if (!mptsas_get_rphy(phy_info) && port && !port->rphy) { |
2695 | 2721 | ||
2696 | struct sas_rphy *rphy; | 2722 | struct sas_rphy *rphy; |
@@ -2703,9 +2729,10 @@ static int mptsas_probe_one_phy(struct device *dev, | |||
2703 | * the adding/removing of devices that occur | 2729 | * the adding/removing of devices that occur |
2704 | * after start of day. | 2730 | * after start of day. |
2705 | */ | 2731 | */ |
2706 | if (ioc->sas_discovery_runtime && | 2732 | if (mptsas_is_end_device(&phy_info->attached) && |
2707 | mptsas_is_end_device(&phy_info->attached)) | 2733 | phy_info->attached.handle_parent) { |
2708 | goto out; | 2734 | goto out; |
2735 | } | ||
2709 | 2736 | ||
2710 | mptsas_parse_device_info(&identify, &phy_info->attached); | 2737 | mptsas_parse_device_info(&identify, &phy_info->attached); |
2711 | if (scsi_is_host_device(parent)) { | 2738 | if (scsi_is_host_device(parent)) { |
@@ -3420,9 +3447,12 @@ mptsas_probe_devices(MPT_ADAPTER *ioc) | |||
3420 | } | 3447 | } |
3421 | } | 3448 | } |
3422 | 3449 | ||
3423 | /* | 3450 | /** |
3424 | * Start of day discovery | 3451 | * mptsas_scan_sas_topology - |
3425 | */ | 3452 | * @ioc: Pointer to MPT_ADAPTER structure |
3453 | * @sas_address: | ||
3454 | * | ||
3455 | **/ | ||
3426 | static void | 3456 | static void |
3427 | mptsas_scan_sas_topology(MPT_ADAPTER *ioc) | 3457 | mptsas_scan_sas_topology(MPT_ADAPTER *ioc) |
3428 | { | 3458 | { |