Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
isci: kill 'get/set' macros
Most of these simple dereference macros are longer than their open coded
equivalent.  Deleting enum sci_controller_mode is thrown in for good
measure.

Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
  • Loading branch information
djbw committed Jul 3, 2011
1 parent 89a7301 commit 34a9915
Show file tree
Hide file tree
Showing 15 changed files with 188 additions and 478 deletions.
8 changes: 3 additions & 5 deletions drivers/scsi/isci/host.c
Expand Up @@ -2627,7 +2627,7 @@ enum sci_status sci_controller_start_io(struct isci_host *ihost,
return status;

set_bit(IREQ_ACTIVE, &ireq->flags);
sci_controller_post_request(ihost, sci_request_get_post_context(ireq));
sci_controller_post_request(ihost, ireq->post_context);
return SCI_SUCCESS;
}

Expand Down Expand Up @@ -2707,7 +2707,7 @@ enum sci_status sci_controller_continue_io(struct isci_request *ireq)
}

set_bit(IREQ_ACTIVE, &ireq->flags);
sci_controller_post_request(ihost, sci_request_get_post_context(ireq));
sci_controller_post_request(ihost, ireq->post_context);
return SCI_SUCCESS;
}

Expand Down Expand Up @@ -2747,9 +2747,7 @@ enum sci_task_status sci_controller_start_task(struct isci_host *ihost,
return SCI_SUCCESS;
case SCI_SUCCESS:
set_bit(IREQ_ACTIVE, &ireq->flags);

sci_controller_post_request(ihost,
sci_request_get_post_context(ireq));
sci_controller_post_request(ihost, ireq->post_context);
break;
default:
break;
Expand Down
20 changes: 3 additions & 17 deletions drivers/scsi/isci/host.h
Expand Up @@ -172,6 +172,7 @@ struct isci_host {
/* XXX kill */
bool phy_startup_timer_pending;
u32 next_phy_to_start;
/* XXX convert to unsigned long and use bitops */
u8 invalid_phy_mask;

/* TODO attempt dynamic interrupt coalescing scheme */
Expand Down Expand Up @@ -359,13 +360,8 @@ static inline struct isci_host *dev_to_ihost(struct domain_device *dev)
return dev->port->ha->lldd_ha;
}

/**
* sci_controller_get_protocol_engine_group() -
*
* This macro returns the protocol engine group for this controller object.
* Presently we only support protocol engine group 0 so just return that
*/
#define sci_controller_get_protocol_engine_group(controller) 0
/* we always use protocol engine group zero */
#define ISCI_PEG 0

/* see sci_controller_io_tag_allocate|free for how seq and tci are built */
#define ISCI_TAG(seq, tci) (((u16) (seq)) << 12 | tci)
Expand All @@ -385,16 +381,6 @@ static inline int sci_remote_device_node_count(struct isci_remote_device *idev)
return SCU_SSP_REMOTE_NODE_COUNT;
}

/**
* sci_controller_set_invalid_phy() -
*
* This macro will set the bit in the invalid phy mask for this controller
* object. This is used to control messages reported for invalid link up
* notifications.
*/
#define sci_controller_set_invalid_phy(controller, phy) \
((controller)->invalid_phy_mask |= (1 << (phy)->phy_index))

/**
* sci_controller_clear_invalid_phy() -
*
Expand Down
5 changes: 0 additions & 5 deletions drivers/scsi/isci/isci.h
Expand Up @@ -73,11 +73,6 @@

#define SCI_CONTROLLER_INVALID_IO_TAG 0xFFFF

enum sci_controller_mode {
SCI_MODE_SPEED,
SCI_MODE_SIZE /* deprecated */
};

#define SCI_MAX_PHYS (4UL)
#define SCI_MAX_PORTS SCI_MAX_PHYS
#define SCI_MAX_SMP_PHYS (384) /* not silicon constrained */
Expand Down
33 changes: 16 additions & 17 deletions drivers/scsi/isci/phy.c
Expand Up @@ -265,10 +265,11 @@ static void phy_sata_timeout(unsigned long data)
* port (i.e. it's contained in the dummy port). !NULL All other
* values indicate a handle/pointer to the port containing the phy.
*/
struct isci_port *phy_get_non_dummy_port(
struct isci_phy *iphy)
struct isci_port *phy_get_non_dummy_port(struct isci_phy *iphy)
{
if (sci_port_get_index(iphy->owning_port) == SCIC_SDS_DUMMY_PORT)
struct isci_port *iport = iphy->owning_port;

if (iport->physical_port_index == SCIC_SDS_DUMMY_PORT)
return NULL;

return iphy->owning_port;
Expand Down Expand Up @@ -858,10 +859,9 @@ enum sci_status sci_phy_frame_handler(struct isci_phy *iphy, u32 frame_index)
struct dev_to_host_fis *frame_header;
u32 *fis_frame_data;

result = sci_unsolicited_frame_control_get_header(
&(sci_phy_get_controller(iphy)->uf_control),
frame_index,
(void **)&frame_header);
result = sci_unsolicited_frame_control_get_header(&ihost->uf_control,
frame_index,
(void **)&frame_header);

if (result != SCI_SUCCESS)
return result;
Expand Down Expand Up @@ -1090,6 +1090,8 @@ static void scu_link_layer_tx_hard_reset(
static void sci_phy_stopped_state_enter(struct sci_base_state_machine *sm)
{
struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
struct isci_port *iport = iphy->owning_port;
struct isci_host *ihost = iport->owning_controller;

/*
* @todo We need to get to the controller to place this PE in a
Expand All @@ -1100,14 +1102,14 @@ static void sci_phy_stopped_state_enter(struct sci_base_state_machine *sm)
scu_link_layer_stop_protocol_engine(iphy);

if (iphy->sm.previous_state_id != SCI_PHY_INITIAL)
sci_controller_link_down(sci_phy_get_controller(iphy),
phy_get_non_dummy_port(iphy),
iphy);
sci_controller_link_down(ihost, phy_get_non_dummy_port(iphy), iphy);
}

static void sci_phy_starting_state_enter(struct sci_base_state_machine *sm)
{
struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
struct isci_port *iport = iphy->owning_port;
struct isci_host *ihost = iport->owning_controller;

scu_link_layer_stop_protocol_engine(iphy);
scu_link_layer_start_oob(iphy);
Expand All @@ -1117,21 +1119,18 @@ static void sci_phy_starting_state_enter(struct sci_base_state_machine *sm)
iphy->bcn_received_while_port_unassigned = false;

if (iphy->sm.previous_state_id == SCI_PHY_READY)
sci_controller_link_down(sci_phy_get_controller(iphy),
phy_get_non_dummy_port(iphy),
iphy);
sci_controller_link_down(ihost, phy_get_non_dummy_port(iphy), iphy);

sci_change_state(&iphy->sm, SCI_PHY_SUB_INITIAL);
}

static void sci_phy_ready_state_enter(struct sci_base_state_machine *sm)
{
struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
struct isci_port *iport = iphy->owning_port;
struct isci_host *ihost = iport->owning_controller;

sci_controller_link_up(sci_phy_get_controller(iphy),
phy_get_non_dummy_port(iphy),
iphy);

sci_controller_link_up(ihost, phy_get_non_dummy_port(iphy), iphy);
}

static void sci_phy_ready_state_exit(struct sci_base_state_machine *sm)
Expand Down
17 changes: 0 additions & 17 deletions drivers/scsi/isci/phy.h
Expand Up @@ -440,23 +440,6 @@ enum sci_phy_states {
SCI_PHY_FINAL,
};

/**
* sci_phy_get_index() -
*
* This macro returns the phy index for the specified phy
*/
#define sci_phy_get_index(phy) \
((phy)->phy_index)

/**
* sci_phy_get_controller() - This macro returns the controller for this
* phy
*
*
*/
#define sci_phy_get_controller(phy) \
(sci_port_get_controller((phy)->owning_port))

void sci_phy_construct(
struct isci_phy *iphy,
struct isci_port *iport,
Expand Down
4 changes: 2 additions & 2 deletions drivers/scsi/isci/port.c
Expand Up @@ -654,7 +654,7 @@ static void sci_port_activate_phy(struct isci_port *iport, struct isci_phy *iphy
void sci_port_deactivate_phy(struct isci_port *iport, struct isci_phy *iphy,
bool do_notify_user)
{
struct isci_host *ihost = sci_port_get_controller(iport);
struct isci_host *ihost = iport->owning_controller;

iport->active_phy_mask &= ~(1 << iphy->phy_index);

Expand All @@ -678,7 +678,7 @@ static void sci_port_invalid_link_up(struct isci_port *iport, struct isci_phy *i
* invalid link.
*/
if ((ihost->invalid_phy_mask & (1 << iphy->phy_index)) == 0) {
sci_controller_set_invalid_phy(ihost, iphy);
ihost->invalid_phy_mask |= 1 << iphy->phy_index;
dev_warn(&ihost->pdev->dev, "Invalid link up!\n");
}
}
Expand Down
17 changes: 0 additions & 17 deletions drivers/scsi/isci/port.h
Expand Up @@ -210,23 +210,6 @@ enum sci_port_states {

};

/**
* sci_port_get_controller() -
*
* Helper macro to get the owning controller of this port
*/
#define sci_port_get_controller(this_port) \
((this_port)->owning_controller)

/**
* sci_port_get_index() -
*
* This macro returns the physical port index for this port object
*/
#define sci_port_get_index(this_port) \
((this_port)->physical_port_index)


static inline void sci_port_decrement_request_count(struct isci_port *iport)
{
if (WARN_ONCE(iport->started_request_count == 0,
Expand Down
14 changes: 6 additions & 8 deletions drivers/scsi/isci/port_config.c
Expand Up @@ -367,10 +367,10 @@ static void sci_mpc_agent_link_up(struct isci_host *ihost,
if (!iport)
return;

port_agent->phy_ready_mask |= (1 << sci_phy_get_index(iphy));
port_agent->phy_ready_mask |= (1 << iphy->phy_index);
sci_port_link_up(iport, iphy);
if ((iport->active_phy_mask & (1 << sci_phy_get_index(iphy))))
port_agent->phy_configured_mask |= (1 << sci_phy_get_index(iphy));
if ((iport->active_phy_mask & (1 << iphy->phy_index)))
port_agent->phy_configured_mask |= (1 << iphy->phy_index);
}

/**
Expand Down Expand Up @@ -404,10 +404,8 @@ static void sci_mpc_agent_link_down(
* rebuilding the port with the phys that remain in the ready
* state.
*/
port_agent->phy_ready_mask &=
~(1 << sci_phy_get_index(iphy));
port_agent->phy_configured_mask &=
~(1 << sci_phy_get_index(iphy));
port_agent->phy_ready_mask &= ~(1 << iphy->phy_index);
port_agent->phy_configured_mask &= ~(1 << iphy->phy_index);

/*
* Check to see if there are more phys waiting to be
Expand Down Expand Up @@ -643,7 +641,7 @@ static void sci_apc_agent_link_down(
struct isci_port *iport,
struct isci_phy *iphy)
{
port_agent->phy_ready_mask &= ~(1 << sci_phy_get_index(iphy));
port_agent->phy_ready_mask &= ~(1 << iphy->phy_index);

if (!iport)
return;
Expand Down
43 changes: 17 additions & 26 deletions drivers/scsi/isci/remote_device.c
Expand Up @@ -456,7 +456,7 @@ static void sci_remote_device_start_request(struct isci_remote_device *idev,
sci_port_complete_io(iport, idev, ireq);
else {
kref_get(&idev->kref);
sci_remote_device_increment_request_count(idev);
idev->started_request_count++;
}
}

Expand Down Expand Up @@ -636,7 +636,7 @@ enum sci_status sci_remote_device_complete_io(struct isci_host *ihost,
* status of "DEVICE_RESET_REQUIRED", instead of "INVALID STATE".
*/
sci_change_state(sm, SCI_STP_DEV_AWAIT_RESET);
} else if (sci_remote_device_get_request_count(idev) == 0)
} else if (idev->started_request_count == 0)
sci_change_state(sm, SCI_STP_DEV_IDLE);
break;
case SCI_SMP_DEV_CMD:
Expand All @@ -650,10 +650,10 @@ enum sci_status sci_remote_device_complete_io(struct isci_host *ihost,
if (status != SCI_SUCCESS)
break;

if (sci_remote_device_get_request_count(idev) == 0)
if (idev->started_request_count == 0)
sci_remote_node_context_destruct(&idev->rnc,
rnc_destruct_done,
idev);
rnc_destruct_done,
idev);
break;
}

Expand Down Expand Up @@ -761,26 +761,17 @@ enum sci_status sci_remote_device_start_task(struct isci_host *ihost,
return status;
}

/**
*
* @sci_dev:
* @request:
*
* This method takes the request and bulids an appropriate SCU context for the
* request and then requests the controller to post the request. none
*/
void sci_remote_device_post_request(
struct isci_remote_device *idev,
u32 request)
void sci_remote_device_post_request(struct isci_remote_device *idev, u32 request)
{
struct isci_port *iport = idev->owning_port;
u32 context;

context = sci_remote_device_build_command_context(idev, request);
context = request |
(ISCI_PEG << SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) |
(iport->physical_port_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT) |
idev->rnc.remote_node_index;

sci_controller_post_request(
sci_remote_device_get_controller(idev),
context
);
sci_controller_post_request(iport->owning_controller, context);
}

/* called once the remote node context has transisitioned to a
Expand Down Expand Up @@ -893,7 +884,7 @@ static void sci_remote_device_stopped_state_enter(struct sci_base_state_machine
static void sci_remote_device_starting_state_enter(struct sci_base_state_machine *sm)
{
struct isci_remote_device *idev = container_of(sm, typeof(*idev), sm);
struct isci_host *ihost = sci_remote_device_get_controller(idev);
struct isci_host *ihost = idev->owning_port->owning_controller;

isci_remote_device_not_ready(ihost, idev,
SCIC_REMOTE_DEVICE_NOT_READY_START_REQUESTED);
Expand Down Expand Up @@ -961,7 +952,7 @@ static void sci_stp_remote_device_ready_idle_substate_enter(struct sci_base_stat
static void sci_stp_remote_device_ready_cmd_substate_enter(struct sci_base_state_machine *sm)
{
struct isci_remote_device *idev = container_of(sm, typeof(*idev), sm);
struct isci_host *ihost = sci_remote_device_get_controller(idev);
struct isci_host *ihost = idev->owning_port->owning_controller;

BUG_ON(idev->working_request == NULL);

Expand All @@ -972,7 +963,7 @@ static void sci_stp_remote_device_ready_cmd_substate_enter(struct sci_base_state
static void sci_stp_remote_device_ready_ncq_error_substate_enter(struct sci_base_state_machine *sm)
{
struct isci_remote_device *idev = container_of(sm, typeof(*idev), sm);
struct isci_host *ihost = sci_remote_device_get_controller(idev);
struct isci_host *ihost = idev->owning_port->owning_controller;

if (idev->not_ready_reason == SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED)
isci_remote_device_not_ready(ihost, idev,
Expand All @@ -982,15 +973,15 @@ static void sci_stp_remote_device_ready_ncq_error_substate_enter(struct sci_base
static void sci_smp_remote_device_ready_idle_substate_enter(struct sci_base_state_machine *sm)
{
struct isci_remote_device *idev = container_of(sm, typeof(*idev), sm);
struct isci_host *ihost = sci_remote_device_get_controller(idev);
struct isci_host *ihost = idev->owning_port->owning_controller;

isci_remote_device_ready(ihost, idev);
}

static void sci_smp_remote_device_ready_cmd_substate_enter(struct sci_base_state_machine *sm)
{
struct isci_remote_device *idev = container_of(sm, typeof(*idev), sm);
struct isci_host *ihost = sci_remote_device_get_controller(idev);
struct isci_host *ihost = idev->owning_port->owning_controller;

BUG_ON(idev->working_request == NULL);

Expand Down

0 comments on commit 34a9915

Please sign in to comment.