aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdmund Nadolski <edmund.nadolski@intel.com>2011-05-19 23:00:51 -0400
committerDan Williams <dan.j.williams@intel.com>2011-07-03 07:04:49 -0400
commitac0eeb4f774261d1da21a68169f7ddd4f6c082fc (patch)
tree28953f87b323fdc73f00642115910aab619e0150
parent5553ba2be0f3e3741e1a885a33d2b89921f9fd48 (diff)
isci: convert port config agent timer to sci_timer
Signed-off-by: Edmund Nadolski <edmund.nadolski@intel.com> [squashed collateral cleanups] Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r--drivers/scsi/isci/host.c2
-rw-r--r--drivers/scsi/isci/host.h11
-rw-r--r--drivers/scsi/isci/port_config.c117
3 files changed, 53 insertions, 77 deletions
diff --git a/drivers/scsi/isci/host.c b/drivers/scsi/isci/host.c
index a3269b6fa225..468357ffc771 100644
--- a/drivers/scsi/isci/host.c
+++ b/drivers/scsi/isci/host.c
@@ -1366,6 +1366,8 @@ void isci_host_deinit(struct isci_host *ihost)
1366 del_timer_sync(&sci_port->timer.timer); 1366 del_timer_sync(&sci_port->timer.timer);
1367 } 1367 }
1368 1368
1369 del_timer_sync(&ihost->sci.port_agent.timer.timer);
1370
1369 isci_timer_list_destroy(ihost); 1371 isci_timer_list_destroy(ihost);
1370} 1372}
1371 1373
diff --git a/drivers/scsi/isci/host.h b/drivers/scsi/isci/host.h
index 784e1355e8ec..deb0ee031f27 100644
--- a/drivers/scsi/isci/host.h
+++ b/drivers/scsi/isci/host.h
@@ -122,7 +122,7 @@ struct scic_sds_port_configuration_agent {
122 bool timer_pending; 122 bool timer_pending;
123 port_config_fn link_up_handler; 123 port_config_fn link_up_handler;
124 port_config_fn link_down_handler; 124 port_config_fn link_down_handler;
125 void *timer; 125 struct sci_timer timer;
126}; 126};
127 127
128/** 128/**
@@ -569,15 +569,6 @@ static inline struct isci_host *scic_to_ihost(struct scic_sds_controller *scic)
569 } 569 }
570 570
571/** 571/**
572 * scic_sds_controller_get_port_configuration_agent() -
573 *
574 * This is a helper macro to get the port configuration agent from the
575 * controller object.
576 */
577#define scic_sds_controller_get_port_configuration_agent(controller) \
578 (&(controller)->port_agent)
579
580/**
581 * scic_sds_controller_get_protocol_engine_group() - 572 * scic_sds_controller_get_protocol_engine_group() -
582 * 573 *
583 * This macro returns the protocol engine group for this controller object. 574 * This macro returns the protocol engine group for this controller object.
diff --git a/drivers/scsi/isci/port_config.c b/drivers/scsi/isci/port_config.c
index ca76f493c30d..1cde7b9165f4 100644
--- a/drivers/scsi/isci/port_config.c
+++ b/drivers/scsi/isci/port_config.c
@@ -328,21 +328,25 @@ static enum sci_status scic_sds_mpc_agent_validate_phy_configuration(
328 return scic_sds_port_configuration_agent_validate_ports(controller, port_agent); 328 return scic_sds_port_configuration_agent_validate_ports(controller, port_agent);
329} 329}
330 330
331/** 331static void mpc_agent_timeout(unsigned long data)
332 *
333 *
334 * This timer routine is used to allow the SCI User to rediscover or change
335 * device objects before a new series of link up notifications because a link
336 * down has allowed a better port configuration.
337 */
338static void scic_sds_mpc_agent_timeout_handler(void *object)
339{ 332{
340 u8 index; 333 u8 index;
341 struct scic_sds_controller *scic = object; 334 struct sci_timer *tmr = (struct sci_timer *)data;
342 struct isci_host *ihost = scic_to_ihost(scic); 335 struct scic_sds_port_configuration_agent *port_agent;
343 struct scic_sds_port_configuration_agent *port_agent = &scic->port_agent; 336 struct scic_sds_controller *scic;
337 struct isci_host *ihost;
338 unsigned long flags;
344 u16 configure_phy_mask; 339 u16 configure_phy_mask;
345 340
341 port_agent = container_of(tmr, typeof(*port_agent), timer);
342 scic = container_of(port_agent, typeof(*scic), port_agent);
343 ihost = scic_to_ihost(scic);
344
345 spin_lock_irqsave(&ihost->scic_lock, flags);
346
347 if (tmr->cancel)
348 goto done;
349
346 port_agent->timer_pending = false; 350 port_agent->timer_pending = false;
347 351
348 /* Find the mask of phys that are reported read but as yet unconfigured into a port */ 352 /* Find the mask of phys that are reported read but as yet unconfigured into a port */
@@ -357,6 +361,9 @@ static void scic_sds_mpc_agent_timeout_handler(void *object)
357 sci_phy); 361 sci_phy);
358 } 362 }
359 } 363 }
364
365done:
366 spin_unlock_irqrestore(&ihost->scic_lock, flags);
360} 367}
361 368
362/** 369/**
@@ -441,8 +448,8 @@ static void scic_sds_mpc_agent_link_down(
441 !port_agent->timer_pending) { 448 !port_agent->timer_pending) {
442 port_agent->timer_pending = true; 449 port_agent->timer_pending = true;
443 450
444 isci_timer_start(port_agent->timer, 451 sci_mod_timer(&port_agent->timer,
445 SCIC_SDS_MPC_RECONFIGURATION_TIMEOUT); 452 SCIC_SDS_MPC_RECONFIGURATION_TIMEOUT);
446 } 453 }
447 454
448 scic_sds_port_link_down(sci_port, sci_phy); 455 scic_sds_port_link_down(sci_port, sci_phy);
@@ -500,31 +507,6 @@ static enum sci_status scic_sds_apc_agent_validate_phy_configuration(
500 507
501/** 508/**
502 * 509 *
503 * @controller: This is the controller that to which the port agent is assigned.
504 * @port_agent: This is the port agent that is requesting the timer start
505 * operation.
506 * @phy: This is the phy that has caused the timer operation to be scheduled.
507 *
508 * This routine will restart the automatic port configuration timeout timer for
509 * the next time period. This could be caused by either a link down event or a
510 * link up event where we can not yet tell to which port a phy belongs.
511 */
512static inline void scic_sds_apc_agent_start_timer(
513 struct scic_sds_controller *scic,
514 struct scic_sds_port_configuration_agent *port_agent,
515 struct scic_sds_phy *sci_phy,
516 u32 timeout)
517{
518 if (port_agent->timer_pending)
519 isci_timer_stop(port_agent->timer);
520
521 port_agent->timer_pending = true;
522
523 isci_timer_start(port_agent->timer, timeout);
524}
525
526/**
527 *
528 * @controller: This is the controller object that receives the link up 510 * @controller: This is the controller object that receives the link up
529 * notification. 511 * notification.
530 * @phy: This is the phy object which has gone link up. 512 * @phy: This is the phy object which has gone link up.
@@ -635,9 +617,17 @@ static void scic_sds_apc_agent_configure_ports(
635 break; 617 break;
636 618
637 case SCIC_SDS_APC_START_TIMER: 619 case SCIC_SDS_APC_START_TIMER:
638 scic_sds_apc_agent_start_timer( 620 /*
639 controller, port_agent, phy, SCIC_SDS_APC_WAIT_LINK_UP_NOTIFICATION 621 * This can occur for either a link down event, or a link
640 ); 622 * up event where we cannot yet tell the port to which a
623 * phy belongs.
624 */
625 if (port_agent->timer_pending)
626 sci_del_timer(&port_agent->timer);
627
628 port_agent->timer_pending = true;
629 sci_mod_timer(&port_agent->timer,
630 SCIC_SDS_APC_WAIT_LINK_UP_NOTIFICATION);
641 break; 631 break;
642 632
643 case SCIC_SDS_APC_SKIP_PHY: 633 case SCIC_SDS_APC_SKIP_PHY:
@@ -719,15 +709,24 @@ static void scic_sds_apc_agent_link_down(
719} 709}
720 710
721/* configure the phys into ports when the timer fires */ 711/* configure the phys into ports when the timer fires */
722static void scic_sds_apc_agent_timeout_handler(void *object) 712static void apc_agent_timeout(unsigned long data)
723{ 713{
724 u32 index; 714 u32 index;
715 struct sci_timer *tmr = (struct sci_timer *)data;
725 struct scic_sds_port_configuration_agent *port_agent; 716 struct scic_sds_port_configuration_agent *port_agent;
726 struct scic_sds_controller *scic = object; 717 struct scic_sds_controller *scic;
727 struct isci_host *ihost = scic_to_ihost(scic); 718 struct isci_host *ihost;
719 unsigned long flags;
728 u16 configure_phy_mask; 720 u16 configure_phy_mask;
729 721
730 port_agent = scic_sds_controller_get_port_configuration_agent(scic); 722 port_agent = container_of(tmr, typeof(*port_agent), timer);
723 scic = container_of(port_agent, typeof(*scic), port_agent);
724 ihost = scic_to_ihost(scic);
725
726 spin_lock_irqsave(&ihost->scic_lock, flags);
727
728 if (tmr->cancel)
729 goto done;
731 730
732 port_agent->timer_pending = false; 731 port_agent->timer_pending = false;
733 732
@@ -743,6 +742,9 @@ static void scic_sds_apc_agent_timeout_handler(void *object)
743 scic_sds_apc_agent_configure_ports(scic, port_agent, 742 scic_sds_apc_agent_configure_ports(scic, port_agent,
744 &ihost->phys[index].sci, false); 743 &ihost->phys[index].sci, false);
745 } 744 }
745
746done:
747 spin_unlock_irqrestore(&ihost->scic_lock, flags);
746} 748}
747 749
748/* 750/*
@@ -769,7 +771,6 @@ void scic_sds_port_configuration_agent_construct(
769 port_agent->link_down_handler = NULL; 771 port_agent->link_down_handler = NULL;
770 772
771 port_agent->timer_pending = false; 773 port_agent->timer_pending = false;
772 port_agent->timer = NULL;
773 774
774 for (index = 0; index < SCI_MAX_PORTS; index++) { 775 for (index = 0; index < SCI_MAX_PORTS; index++) {
775 port_agent->phy_valid_port_range[index].min_index = 0; 776 port_agent->phy_valid_port_range[index].min_index = 0;
@@ -781,9 +782,8 @@ enum sci_status scic_sds_port_configuration_agent_initialize(
781 struct scic_sds_controller *scic, 782 struct scic_sds_controller *scic,
782 struct scic_sds_port_configuration_agent *port_agent) 783 struct scic_sds_port_configuration_agent *port_agent)
783{ 784{
784 enum sci_status status = SCI_SUCCESS; 785 enum sci_status status;
785 enum scic_port_configuration_mode mode; 786 enum scic_port_configuration_mode mode;
786 struct isci_host *ihost = scic_to_ihost(scic);
787 787
788 mode = scic->oem_parameters.sds1.controller.mode_type; 788 mode = scic->oem_parameters.sds1.controller.mode_type;
789 789
@@ -794,10 +794,7 @@ enum sci_status scic_sds_port_configuration_agent_initialize(
794 port_agent->link_up_handler = scic_sds_mpc_agent_link_up; 794 port_agent->link_up_handler = scic_sds_mpc_agent_link_up;
795 port_agent->link_down_handler = scic_sds_mpc_agent_link_down; 795 port_agent->link_down_handler = scic_sds_mpc_agent_link_down;
796 796
797 port_agent->timer = isci_timer_create( 797 sci_init_timer(&port_agent->timer, mpc_agent_timeout);
798 ihost,
799 scic,
800 scic_sds_mpc_agent_timeout_handler);
801 } else { 798 } else {
802 status = scic_sds_apc_agent_validate_phy_configuration( 799 status = scic_sds_apc_agent_validate_phy_configuration(
803 scic, port_agent); 800 scic, port_agent);
@@ -805,21 +802,7 @@ enum sci_status scic_sds_port_configuration_agent_initialize(
805 port_agent->link_up_handler = scic_sds_apc_agent_link_up; 802 port_agent->link_up_handler = scic_sds_apc_agent_link_up;
806 port_agent->link_down_handler = scic_sds_apc_agent_link_down; 803 port_agent->link_down_handler = scic_sds_apc_agent_link_down;
807 804
808 port_agent->timer = isci_timer_create( 805 sci_init_timer(&port_agent->timer, apc_agent_timeout);
809 ihost,
810 scic,
811 scic_sds_apc_agent_timeout_handler);
812 }
813
814 /* Make sure we have actually gotten a timer */
815 if ((status == SCI_SUCCESS) && (port_agent->timer == NULL)) {
816 dev_err(scic_to_dev(scic),
817 "%s: Controller 0x%p automatic port configuration "
818 "agent could not get timer.\n",
819 __func__,
820 scic);
821
822 status = SCI_FAILURE;
823 } 806 }
824 807
825 return status; 808 return status;