be2iscsi: Move freeing of resources to stop_conn
PATCH 2/4 be2iscsi: Move freeing of resources to stop_conn
We need to hold on to ep resources untill invalidate and
close connection are completed
Signed-off-by Jayamohan Kallickal <[email protected]>
--- drivers/scsi/be2iscsi/be_iscsi.c | 23 ++++++++++------------- drivers/scsi/be2iscsi/be_main.c | 31 ++++++++++--------------------- drivers/scsi/be2iscsi/be_mgmt.h | 1 + 3 files changed, 21 insertions(+), 34 deletions(-)
drivers/scsi/be2iscsi/be_iscsi.c +10 -13
@@ -460,14 +460,12 @@ static void beiscsi_put_cid(struct beiscsi_hba *phba, unsigned short cid)* beiscsi_free_ep - free endpoint * @ep: pointer to iscsi endpoint structure */ -static void beiscsi_free_ep (struct iscsi_endpoint *ep) +static void beiscsi_free_ep (struct beiscsi_endpoint *beiscsi_ep) { -struct beiscsi_endpoint *beiscsi_ep = ep->dd_data;struct beiscsi_hba *phba = beiscsi_ep->phba;beiscsi_put_cid (phba, beiscsi_ep->ep_cid); beiscsi_ep->phba =NULL ; -iscsi_destroy_endpoint (ep); }/**
@@ -498,7 +496,7 @@ beiscsi_ep_connect(struct Scsi_Host *shost, struct sockaddr *dst_addr,if (phba->state) { ret = -EBUSY ; -SE_DEBUG (DBG_LVL_1 ,"The Adapet state is Not UP \n" ); +SE_DEBUG (DBG_LVL_1 ,"The Adapter state is Not UP \n" );return ERR_PTR (ret); }
@@ -510,9 +508,10 @@ beiscsi_ep_connect(struct Scsi_Host *shost, struct sockaddr *dst_addr, beiscsi_ep = ep->dd_data; beiscsi_ep->phba = phba; + beiscsi_ep->openiscsi_ep = ep;if (beiscsi_open_conn (ep,NULL , dst_addr, non_blocking)) { -SE_DEBUG (DBG_LVL_1 ,"Failed in allocate iscsi cid\n" ); +SE_DEBUG (DBG_LVL_1 ,"Failed in beiscsi_open_conn \n" ); ret = -ENOMEM ; goto free_ep; }
@@ -520,7 +519,7 @@ beiscsi_ep_connect(struct Scsi_Host *shost, struct sockaddr *dst_addr,return ep; free_ep: -beiscsi_free_ep (ep); +beiscsi_free_ep (beiscsi_ep);return ERR_PTR (ret); }
@@ -547,15 +546,14 @@ int beiscsi_ep_poll(struct iscsi_endpoint *ep, int timeout_ms)* @ep: The iscsi endpoint * @flag: The type of connection closure */ -static int beiscsi_close_conn (struct iscsi_endpoint *ep,int flag) +static int beiscsi_close_conn (struct beiscsi_endpoint *beiscsi_ep,int flag) {int ret =0 ; -struct beiscsi_endpoint *beiscsi_ep = ep->dd_data;struct beiscsi_hba *phba = beiscsi_ep->phba;if (MGMT_STATUS_SUCCESS !=mgmt_upload_connection (phba, beiscsi_ep->ep_cid, -CONNECTION_UPLOAD_GRACEFUL )) { + flag)) {SE_DEBUG (DBG_LVL_8 ,"upload failed for cid 0x%x" , beiscsi_ep->ep_cid); ret =-1 ;
@@ -575,19 +573,15 @@ void beiscsi_ep_disconnect(struct iscsi_endpoint *ep)struct beiscsi_conn *beiscsi_conn;struct beiscsi_endpoint *beiscsi_ep;struct beiscsi_hba *phba; -int flag =0 ; beiscsi_ep = ep->dd_data; phba = beiscsi_ep->phba; -SE_DEBUG (DBG_LVL_8 ,"In beiscsi_ep_disconnect\n" );if (beiscsi_ep->conn) { beiscsi_conn = beiscsi_ep->conn;iscsi_suspend_queue (beiscsi_conn->conn); -beiscsi_close_conn (ep, flag); } -beiscsi_free_ep (ep); }/**
@@ -637,6 +631,9 @@ void beiscsi_conn_stop(struct iscsi_cls_conn *cls_conn, int flag)"mgmt_invalidate_connection Failed for cid=%d \n" , beiscsi_ep->ep_cid); } +beiscsi_close_conn (beiscsi_ep,CONNECTION_UPLOAD_GRACEFUL ); +beiscsi_free_ep (beiscsi_ep); +iscsi_destroy_endpoint (beiscsi_ep->openiscsi_ep);beiscsi_unbind_conn_to_cid (phba, beiscsi_ep->ep_cid);iscsi_conn_stop (cls_conn, flag); }
drivers/scsi/be2iscsi/be_main.c +10 -21
@@ -1434,6 +1434,8 @@ static unsigned int beiscsi_process_cq(struct be_eq_obj *pbe_eq)unsigned int tot_nump =0 ;struct beiscsi_conn *beiscsi_conn;struct sgl_handle *psgl_handle =NULL ; +struct beiscsi_endpoint *beiscsi_ep; +struct iscsi_endpoint *ep;struct beiscsi_hba *phba; cq = pbe_eq->cq;
@@ -1449,28 +1451,15 @@ static unsigned int beiscsi_process_cq(struct be_eq_obj *pbe_eq) dw[offsetof(struct amap_sol_cqe_ring , icd_index) / 32] & SOL_ICD_INDEX_MASK) >> 6)]; - beiscsi_conn = phba->conn_table[psgl_handle->cid]; -if (!beiscsi_conn || !beiscsi_conn->ep) { -shost_printk (KERN_WARNING , phba->shost, -"Connection table empty for cid = %d\n" , - psgl_handle->cid); -return 0 ; - } - + ep = phba->ep_array[psgl_handle->cid]; }else { - beiscsi_conn = phba->conn_table[(u32) ((sol-> - dw[offsetof(struct amap_sol_cqe , cid) /32 ] & -SOL_CID_MASK ) >>6 ) - + ep = phba->ep_array[(u32) ((sol-> + dw[offsetof(struct amap_sol_cqe , cid) /32 ] & +SOL_CID_MASK ) >>6 ) - phba->fw_config.iscsi_cid_start]; -if (!beiscsi_conn || !beiscsi_conn->ep) { -shost_printk (KERN_WARNING , phba->shost, -"Connection table empty for cid = %d\n" , - (u32)(sol->dw[offsetof(struct amap_sol_cqe , - cid) /32 ] &SOL_CID_MASK ) >>6 ); -return 0 ; - } } - + beiscsi_ep = ep->dd_data; + beiscsi_conn = beiscsi_ep->conn;if (num_processed >=32 ) {hwi_ring_cq_db (phba, cq->id, num_processed,0 ,0 );
@@ -3044,7 +3033,7 @@ static int hba_setup_cid_tbls(struct beiscsi_hba *phba) {int i, new_cid; - phba->cid_array =kmalloc (sizeof (void *) * phba->params.cxns_per_ctrl, + phba->cid_array =kzalloc (sizeof (void *) * phba->params.cxns_per_ctrl,GFP_KERNEL );if (!phba->cid_array) { shost_printk(KERN_ERR, phba->shost,
@@ -3052,7 +3041,7 @@ static int hba_setup_cid_tbls(struct beiscsi_hba *phba) "hba_setup_cid_tbls\n");return -ENOMEM ; } - phba->ep_array =kmalloc (sizeof (struct iscsi_endpoint *) * + phba->ep_array =kzalloc (sizeof (struct iscsi_endpoint *) * phba->params.cxns_per_ctrl *2 ,GFP_KERNEL );if (!phba->ep_array) { shost_printk(KERN_ERR, phba->shost,
drivers/scsi/be2iscsi/be_mgmt.h +1 -0
@@ -231,6 +231,7 @@ struct beiscsi_endpoint {struct beiscsi_hba *phba;struct beiscsi_sess *sess;struct beiscsi_conn *conn; +struct iscsi_endpoint *openiscsi_ep;unsigned short ip_type;char dst6_addr[ISCSI_ADDRESS_BUF_LEN ];unsigned long dst_addr;
Signature · 1 line
1.6.4
PATCH 2/5 pm8001: enhance error handle for IO patch
Enhance error handle for IO patch, when the port is down ,fast return phy down for task.
Quoted 1 line
From
7a47413727945fe9dc5c9b443b28795f0e658c18Mon Sep 17 00:00:00 2001
From: Jack Wang <[email protected]>
Date: Wed, 18 Nov 2009 15:27:46 +0800
Subject: [PATCH 2/4] enhance error handle for IO
Signed-off-by Jack Wang <[email protected]>
--- drivers/scsi/pm8001/pm8001_hwi.c | 29 ++++++++++++++++++++++++++--- drivers/scsi/pm8001/pm8001_init.c | 7 ++++++- drivers/scsi/pm8001/pm8001_sas.c | 36 +++++++++++++++++++++++++++++++++++- drivers/scsi/pm8001/pm8001_sas.h | 4 ++++ 4 files changed, 71 insertions(+), 5 deletions(-)
drivers/scsi/pm8001/pm8001_hwi.c +26 -3
@@ -2906,13 +2906,17 @@ hw_event_sas_phy_up(struct pm8001_hba_info *pm8001_ha, void *piomb)le32_to_cpu (pPayload->lr_evt_status_phyid_portid);u8 link_rate = (u8)((lr_evt_status_phyid_portid &0xF0000000 ) >>28 ); +u8 port_id = (u8)(lr_evt_status_phyid_portid &0x0000000F );u8 phy_id = (u8)((lr_evt_status_phyid_portid &0x000000F0 ) >>4 ); +u32 npip_portstate =le32_to_cpu (pPayload->npip_portstate); +u8 portstate = (u8)(npip_portstate &0x0000000F ); +struct pm8001_port *port = &pm8001_ha->port[port_id];struct sas_ha_struct *sas_ha = pm8001_ha->sas;struct pm8001_phy *phy = &pm8001_ha->phy[phy_id];unsigned long flags;u8 deviceType = pPayload->sas_identify.dev_type; - + port->port_state = portstate;PM8001_MSG_DBG (pm8001_ha,pm8001_printk ("HW_EVENT_SAS_PHY_UP \n" ));
@@ -2925,16 +2929,19 @@ hw_event_sas_phy_up(struct pm8001_hba_info *pm8001_ha, void *piomb)PM8001_MSG_DBG (pm8001_ha,pm8001_printk ("end device.\n" ));pm8001_chip_phy_ctl_req (pm8001_ha, phy_id,PHY_NOTIFY_ENABLE_SPINUP ); + port->port_attached =1 ;get_lrate_mode (phy, link_rate);break ;case SAS_EDGE_EXPANDER_DEVICE :PM8001_MSG_DBG (pm8001_ha,pm8001_printk ("expander device.\n" )); + port->port_attached =1 ;get_lrate_mode (phy, link_rate);break ;case SAS_FANOUT_EXPANDER_DEVICE :PM8001_MSG_DBG (pm8001_ha,pm8001_printk ("fanout expander device.\n" )); + port->port_attached =1 ;get_lrate_mode (phy, link_rate);break ;default :
@@ -2976,11 +2983,17 @@ hw_event_sata_phy_up(struct pm8001_hba_info *pm8001_ha, void *piomb)le32_to_cpu (pPayload->lr_evt_status_phyid_portid);u8 link_rate = (u8)((lr_evt_status_phyid_portid &0xF0000000 ) >>28 ); +u8 port_id = (u8)(lr_evt_status_phyid_portid &0x0000000F );u8 phy_id = (u8)((lr_evt_status_phyid_portid &0x000000F0 ) >>4 ); +u32 npip_portstate =le32_to_cpu (pPayload->npip_portstate); +u8 portstate = (u8)(npip_portstate &0x0000000F ); +struct pm8001_port *port = &pm8001_ha->port[port_id];struct sas_ha_struct *sas_ha = pm8001_ha->sas;struct pm8001_phy *phy = &pm8001_ha->phy[phy_id];unsigned long flags; + port->port_state = portstate; + port->port_attached =1 ;get_lrate_mode (phy, link_rate); phy->phy_type |=PORT_TYPE_SATA ; phy->phy_attached =1 ;
@@ -3014,7 +3027,13 @@ hw_event_phy_down(struct pm8001_hba_info *pm8001_ha, void *piomb) (u8)((lr_evt_status_phyid_portid &0x000000F0 ) >>4 );u32 npip_portstate =le32_to_cpu (pPayload->npip_portstate);u8 portstate = (u8)(npip_portstate &0x0000000F ); - +struct pm8001_port *port = &pm8001_ha->port[port_id]; +struct pm8001_phy *phy = &pm8001_ha->phy[phy_id]; + port->port_state = portstate; + phy->phy_type =0 ; + phy->identify.device_type =0 ; + phy->phy_attached =0 ; +memset (&phy->dev_sas_addr,0 ,SAS_ADDR_SIZE );switch (portstate) {case PORT_VALID :break ;
@@ -3023,26 +3042,30 @@ hw_event_phy_down(struct pm8001_hba_info *pm8001_ha, void *piomb) pm8001_printk(" PortInvalid portID %d \n", port_id));PM8001_MSG_DBG (pm8001_ha,pm8001_printk (" Last phy Down and port invalid\n" )); + port->port_attached =0 ;pm8001_hw_event_ack_req (pm8001_ha,0 ,HW_EVENT_PHY_DOWN , port_id, phy_id,0 ,0 );break ;case PORT_IN_RESET :PM8001_MSG_DBG (pm8001_ha, -pm8001_printk (" PortInReset portID %d \n" , port_id)); +pm8001_printk (" Port In Reset portID %d \n" , port_id));break ;case PORT_NOT_ESTABLISHED :PM8001_MSG_DBG (pm8001_ha,pm8001_printk (" phy Down and PORT_NOT_ESTABLISHED\n" )); + port->port_attached =0 ;break ;case PORT_LOSTCOMM :PM8001_MSG_DBG (pm8001_ha,pm8001_printk (" phy Down and PORT_LOSTCOMM\n" ));PM8001_MSG_DBG (pm8001_ha,pm8001_printk (" Last phy Down and port invalid\n" )); + port->port_attached =0 ;pm8001_hw_event_ack_req (pm8001_ha,0 ,HW_EVENT_PHY_DOWN , port_id, phy_id,0 ,0 );break ;default : + port->port_attached =0 ;PM8001_MSG_DBG (pm8001_ha,pm8001_printk (" phy Down and(default) = %x\n" , portstate));
drivers/scsi/pm8001/pm8001_init.c +6 -1
@@ -200,8 +200,13 @@ static int __devinit pm8001_alloc(struct pm8001_hba_info *pm8001_ha) {int i;spin_lock_init (&pm8001_ha->lock); -for (i =0 ; i < pm8001_ha->chip->n_phy; i++) +for (i =0 ; i < pm8001_ha->chip->n_phy; i++) {pm8001_phy_init (pm8001_ha, i); + pm8001_ha->port[i].wide_port_phymap =0 ; + pm8001_ha->port[i].port_attached =0 ; + pm8001_ha->port[i].port_state =0 ; +INIT_LIST_HEAD (&pm8001_ha->port[i].list); + } pm8001_ha->tags =kzalloc (PM8001_MAX_CCB ,GFP_KERNEL );if (!pm8001_ha->tags)
drivers/scsi/pm8001/pm8001_sas.c +35 -1
@@ -346,11 +346,12 @@ static int pm8001_task_exec(struct sas_task *task, const int num,struct domain_device *dev = task->dev;struct pm8001_hba_info *pm8001_ha;struct pm8001_device *pm8001_dev; +struct pm8001_port *port =NULL ;struct sas_task *t = task;struct pm8001_ccb_info *ccb;u32 tag =0xdeadbeef , rc, n_elem =0 ;u32 n = num; -unsigned long flags =0 ; +unsigned long flags =0 , flags_libsas =0 ;if (!dev->port) {struct task_status_struct *tsm = &t->task_status;
@@ -379,6 +380,39 @@ static int pm8001_task_exec(struct sas_task *task, const int num, rc =SAS_PHY_DOWN ; goto out_done; } +if (dev->port->id >= pm8001_ha->chip->n_phy) + port = &pm8001_ha->port[dev->port->id - + pm8001_ha->chip->n_phy]; +else + port = &pm8001_ha->port[dev->port->id]; +if (port && !port->port_attached) { +if (sas_protocol_ata (t->task_proto)) { +struct task_status_struct *ts = &t->task_status; + ts->resp =SAS_TASK_UNDELIVERED ; + ts->stat =SAS_PHY_DOWN ; + +spin_unlock_irqrestore (&pm8001_ha->lock, flags); +spin_unlock_irqrestore (dev->sata_dev.ap->lock, + flags_libsas); + t->task_done (t); +spin_lock_irqsave (dev->sata_dev.ap->lock, + flags_libsas); +spin_lock_irqsave (&pm8001_ha->lock, flags); +if (n >1 ) + t =list_entry (t->list.next, + struct sas_task, list); +continue ; + }else { +struct task_status_struct *ts = &t->task_status; + ts->resp =SAS_TASK_UNDELIVERED ; + ts->stat =SAS_PHY_DOWN ; + t->task_done (t); +if (n >1 ) + t =list_entry (t->list.next, + struct sas_task, list); +continue ; + } + } rc =pm8001_tag_alloc (pm8001_ha, &tag);if (rc) goto err_out;
drivers/scsi/pm8001/pm8001_sas.h +4 -0
@@ -164,6 +164,10 @@ struct pm8001_chip_info {struct pm8001_port {struct asd_sas_port sas_port; +u8 port_attached; +u8 wide_port_phymap; +u8 port_state; +struct list_head list; };struct pm8001_phy {
Signature · 1 line
1.6.5.1.1367.gcd48