Commit 34a99158 authored by Dan Williams's avatar Dan Williams

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: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent 89a7301f
......@@ -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;
}
......@@ -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;
}
......@@ -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;
......
......@@ -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 */
......@@ -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)
......@@ -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() -
*
......
......@@ -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 */
......
......@@ -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;
......@@ -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;
......@@ -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
......@@ -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);
......@@ -1117,9 +1119,7 @@ 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);
}
......@@ -1127,11 +1127,10 @@ static void sci_phy_starting_state_enter(struct sci_base_state_machine *sm)
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)
......
......@@ -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,
......
......@@ -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);
......@@ -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");
}
}
......
......@@ -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,
......
......@@ -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);
}
/**
......@@ -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
......@@ -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;
......
......@@ -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++;
}
}
......@@ -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:
......@@ -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;
}
......@@ -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
......@@ -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);
......@@ -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);
......@@ -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,
......@@ -982,7 +973,7 @@ 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);
}
......@@ -990,7 +981,7 @@ static void sci_smp_remote_device_ready_idle_substate_enter(struct sci_base_stat
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);
......
......@@ -305,91 +305,18 @@ static inline bool dev_is_expander(struct domain_device *dev)
return dev->dev_type == EDGE_DEV || dev->dev_type == FANOUT_DEV;
}
/**
* sci_remote_device_increment_request_count() -
*
* This macro incrments the request count for this device
*/
#define sci_remote_device_increment_request_count(idev) \
((idev)->started_request_count++)
/**
* sci_remote_device_decrement_request_count() -
*
* This macro decrements the request count for this device. This count will
* never decrment past 0.
*/
#define sci_remote_device_decrement_request_count(idev) \
((idev)->started_request_count > 0 ? \
(idev)->started_request_count-- : 0)
/**
* sci_remote_device_get_request_count() -
*
* This is a helper macro to return the current device request count.
*/
#define sci_remote_device_get_request_count(idev) \
((idev)->started_request_count)
/**
* sci_remote_device_get_controller() -
*
* This macro returns the controller object that contains this device object
*/
#define sci_remote_device_get_controller(idev) \
sci_port_get_controller(sci_remote_device_get_port(idev))
/**
* sci_remote_device_get_port() -
*
* This macro returns the owning port of this device
*/
#define sci_remote_device_get_port(idev) \
((idev)->owning_port)
/**
* sci_remote_device_get_controller_peg() -
*
* This macro returns the controllers protocol engine group
*/
#define sci_remote_device_get_controller_peg(idev) \
(\
sci_controller_get_protocol_engine_group(\
sci_port_get_controller(\
sci_remote_device_get_port(idev) \
) \
) \
)
/**
* sci_remote_device_get_index() -
*
* This macro returns the remote node index for this device object
*/
#define sci_remote_device_get_index(idev) \
((idev)->rnc.remote_node_index)
/**
* sci_remote_device_build_command_context() -
*
* This macro builds a remote device context for the SCU post request operation
*/
#define sci_remote_device_build_command_context(device, command) \
((command) \
| (sci_remote_device_get_controller_peg((device)) << SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) \
| ((device)->owning_port->physical_port_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT) \
| (sci_remote_device_get_index((device))) \
)
/**
* sci_remote_device_set_working_request() -
*
* This macro makes the working request assingment for the remote device
* object. To clear the working request use this macro with a NULL request
* object.
*/
#define sci_remote_device_set_working_request(device, request) \
((device)->working_request = (request))
static inline void sci_remote_device_decrement_request_count(struct isci_remote_device *idev)
{
/* XXX delete this voodoo when converting to the top-level device
* reference count
*/
if (WARN_ONCE(idev->started_request_count == 0,
"%s: tried to decrement started_request_count past 0!?",
__func__))
/* pass */;
else
idev->started_request_count--;
}
enum sci_status sci_remote_device_frame_handler(
struct isci_remote_device *idev,
......
......@@ -111,7 +111,7 @@ static void sci_remote_node_context_construct_buffer(struct sci_remote_node_cont
struct isci_host *ihost;
__le64 sas_addr;
ihost = sci_remote_device_get_controller(idev);
ihost = idev->owning_port->owning_controller;
rnc = sci_rnc_by_id(ihost, rni);
memset(rnc, 0, sizeof(union scu_remote_node_context)
......
......@@ -204,9 +204,6 @@ void sci_remote_node_context_construct(struct sci_remote_node_context *rnc,
bool sci_remote_node_context_is_ready(
struct sci_remote_node_context *sci_rnc);
#define sci_remote_node_context_get_remote_node_index(rcn) \
((rnc)->remote_node_index)
enum sci_status sci_remote_node_context_event_handler(struct sci_remote_node_context *sci_rnc,
u32 event_code);
enum sci_status sci_remote_node_context_destruct(struct sci_remote_node_context *sci_rnc,
......
This diff is collapsed.
......@@ -300,58 +300,6 @@ enum sci_base_request_states {
SCI_REQ_FINAL,
};
/**
* sci_request_get_controller() -
*
* This macro will return the controller for this io request object
*/
#define sci_request_get_controller(ireq) \
((ireq)->owning_controller)
/**
* sci_request_get_device() -
*
* This macro will return the device for this io request object
*/
#define sci_request_get_device(ireq) \
((ireq)->target_device)
/**
* sci_request_get_port() -
*
* This macro will return the port for this io request object
*/
#define sci_request_get_port(ireq) \
sci_remote_device_get_port(sci_request_get_device(ireq))
/**
* sci_request_get_post_context() -
*
* This macro returns the constructed post context result for the io request.
*/
#define sci_request_get_post_context(ireq) \
((ireq)->post_context)
/**
* sci_request_get_task_context() -
*
* This is a helper macro to return the os handle for this request object.
*/
#define sci_request_get_task_context(request) \
((request)->task_context_buffer)
/**
* sci_request_set_status() -
*
* This macro will set the scu hardware status and sci request completion
* status for an io request.
*/
#define sci_request_set_status(request, scu_status_code, sci_status_code) \
{ \
(request)->scu_status = (scu_status_code); \
(request)->sci_status = (sci_status_code); \
}
enum sci_status sci_request_start(struct isci_request *ireq);
enum sci_status sci_io_request_terminate(struct isci_request *ireq);
enum sci_status
......@@ -381,27 +329,6 @@ sci_io_request_get_dma_addr(struct isci_request *ireq, void *virt_addr)
return ireq->request_daddr + (requested_addr - base_addr);
}
/**
* This function gets the status of the request object.
* @request: This parameter points to the isci_request object
*
* status of the object as a isci_request_status enum.
*/
static inline enum isci_request_status
isci_request_get_state(struct isci_request *isci_request)
{
BUG_ON(isci_request == NULL);
/*probably a bad sign... */
if (isci_request->status == unallocated)
dev_warn(&isci_request->isci_host->pdev->dev,
"%s: isci_request->status == unallocated\n",
__func__);
return isci_request->status;
}
/**
* isci_request_change_state() - This function sets the status of the request
* object.
......
......@@ -654,7 +654,7 @@ static void isci_terminate_request_core(struct isci_host *ihost,
* needs to be detached and freed here.
*/
spin_lock_irqsave(&isci_request->state_lock, flags);
request_status = isci_request_get_state(isci_request);
request_status = isci_request->status;
if ((isci_request->ttype == io_task) /* TMFs are in their own thread */
&& ((request_status == aborted)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment