提交 78a6f06e 编写于 作者: D Dan Williams

isci: unify isci_remote_device and scic_sds_remote_device

Remove the distinction between these two implementations and unify on
isci_remote_device (local instances named idev).
Reported-by: NChristoph Hellwig <hch@lst.de>
Signed-off-by: NDan Williams <dan.j.williams@intel.com>
上级 ffe191c9
......@@ -272,7 +272,7 @@ static void scic_sds_controller_sdma_completion(struct scic_sds_controller *scic
{
u32 index;
struct isci_request *ireq;
struct scic_sds_remote_device *device;
struct isci_remote_device *idev;
index = SCU_GET_COMPLETION_INDEX(completion_entry);
......@@ -289,9 +289,9 @@ static void scic_sds_controller_sdma_completion(struct scic_sds_controller *scic
case SCU_CONTEXT_COMMAND_REQUEST_TYPE_DUMP_RNC:
case SCU_CONTEXT_COMMAND_REQUEST_TYPE_OTHER_RNC:
case SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_RNC:
device = scic->device_table[index];
idev = scic->device_table[index];
dev_warn(scic_to_dev(scic), "%s: %x for device %p\n",
__func__, completion_entry, device);
__func__, completion_entry, idev);
/* @todo For a port RNC operation we need to fail the
* device
*/
......@@ -312,7 +312,7 @@ static void scic_sds_controller_unsolicited_frame(struct scic_sds_controller *sc
struct isci_host *ihost = scic_to_ihost(scic);
struct scu_unsolicited_frame_header *frame_header;
struct isci_phy *iphy;
struct scic_sds_remote_device *device;
struct isci_remote_device *idev;
enum sci_status result = SCI_FAILURE;
......@@ -348,12 +348,12 @@ static void scic_sds_controller_unsolicited_frame(struct scic_sds_controller *sc
result = scic_sds_phy_frame_handler(iphy, frame_index);
} else {
if (index < scic->remote_node_entries)
device = scic->device_table[index];
idev = scic->device_table[index];
else
device = NULL;
idev = NULL;
if (device != NULL)
result = scic_sds_remote_device_frame_handler(device, frame_index);
if (idev != NULL)
result = scic_sds_remote_device_frame_handler(idev, frame_index);
else
scic_sds_controller_release_frame(scic, frame_index);
}
......@@ -370,7 +370,7 @@ static void scic_sds_controller_event_completion(struct scic_sds_controller *sci
u32 completion_entry)
{
struct isci_host *ihost = scic_to_ihost(scic);
struct scic_sds_remote_device *device;
struct isci_remote_device *idev;
struct isci_request *ireq;
struct isci_phy *iphy;
u32 index;
......@@ -426,9 +426,9 @@ static void scic_sds_controller_event_completion(struct scic_sds_controller *sci
break;
case SCU_EVENT_SPECIFIC_IT_NEXUS_TIMEOUT:
device = scic->device_table[index];
if (device != NULL)
scic_sds_remote_device_event_handler(device, completion_entry);
idev = scic->device_table[index];
if (idev != NULL)
scic_sds_remote_device_event_handler(idev, completion_entry);
else
dev_warn(scic_to_dev(scic),
"%s: SCIC Controller 0x%p received "
......@@ -460,10 +460,10 @@ static void scic_sds_controller_event_completion(struct scic_sds_controller *sci
case SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX:
case SCU_EVENT_TYPE_RNC_OPS_MISC:
if (index < scic->remote_node_entries) {
device = scic->device_table[index];
idev = scic->device_table[index];
if (device != NULL)
scic_sds_remote_device_event_handler(device, completion_entry);
if (idev != NULL)
scic_sds_remote_device_event_handler(idev, completion_entry);
} else
dev_err(scic_to_dev(scic),
"%s: SCIC Controller 0x%p received event 0x%x "
......@@ -2549,13 +2549,13 @@ static bool scic_sds_controller_has_remote_devices_stopping(
* object that the remote device has stopped.
*/
void scic_sds_controller_remote_device_stopped(struct scic_sds_controller *scic,
struct scic_sds_remote_device *sci_dev)
struct isci_remote_device *idev)
{
if (scic->sm.current_state_id != SCIC_STOPPING) {
dev_dbg(scic_to_dev(scic),
"SCIC Controller 0x%p remote device stopped event "
"from device 0x%p in unexpected state %d\n",
scic, sci_dev,
scic, idev,
scic->sm.current_state_id);
return;
}
......@@ -2622,18 +2622,18 @@ struct isci_request *scic_request_by_tag(struct scic_sds_controller *scic, u16 i
*/
enum sci_status scic_sds_controller_allocate_remote_node_context(
struct scic_sds_controller *scic,
struct scic_sds_remote_device *sci_dev,
struct isci_remote_device *idev,
u16 *node_id)
{
u16 node_index;
u32 remote_node_count = scic_sds_remote_device_node_count(sci_dev);
u32 remote_node_count = scic_sds_remote_device_node_count(idev);
node_index = scic_sds_remote_node_table_allocate_remote_node(
&scic->available_remote_nodes, remote_node_count
);
if (node_index != SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX) {
scic->device_table[node_index] = sci_dev;
scic->device_table[node_index] = idev;
*node_id = node_index;
......@@ -2654,12 +2654,12 @@ enum sci_status scic_sds_controller_allocate_remote_node_context(
*/
void scic_sds_controller_free_remote_node_context(
struct scic_sds_controller *scic,
struct scic_sds_remote_device *sci_dev,
struct isci_remote_device *idev,
u16 node_id)
{
u32 remote_node_count = scic_sds_remote_device_node_count(sci_dev);
u32 remote_node_count = scic_sds_remote_device_node_count(idev);
if (scic->device_table[node_id] == sci_dev) {
if (scic->device_table[node_id] == idev) {
scic->device_table[node_id] = NULL;
scic_sds_remote_node_table_release_remote_node_index(
......@@ -2798,7 +2798,7 @@ enum sci_status isci_free_tag(struct isci_host *ihost, u16 io_tag)
* user desires to be utilized for this request.
*/
enum sci_status scic_controller_start_io(struct scic_sds_controller *scic,
struct scic_sds_remote_device *rdev,
struct isci_remote_device *idev,
struct isci_request *ireq)
{
enum sci_status status;
......@@ -2808,7 +2808,7 @@ enum sci_status scic_controller_start_io(struct scic_sds_controller *scic,
return SCI_FAILURE_INVALID_STATE;
}
status = scic_sds_remote_device_start_io(scic, rdev, ireq);
status = scic_sds_remote_device_start_io(scic, idev, ireq);
if (status != SCI_SUCCESS)
return status;
......@@ -2835,7 +2835,7 @@ enum sci_status scic_controller_start_io(struct scic_sds_controller *scic,
*/
enum sci_status scic_controller_terminate_request(
struct scic_sds_controller *scic,
struct scic_sds_remote_device *rdev,
struct isci_remote_device *idev,
struct isci_request *ireq)
{
enum sci_status status;
......@@ -2873,7 +2873,7 @@ enum sci_status scic_controller_terminate_request(
*/
enum sci_status scic_controller_complete_io(
struct scic_sds_controller *scic,
struct scic_sds_remote_device *rdev,
struct isci_remote_device *idev,
struct isci_request *ireq)
{
enum sci_status status;
......@@ -2884,7 +2884,7 @@ enum sci_status scic_controller_complete_io(
/* XXX: Implement this function */
return SCI_FAILURE;
case SCIC_READY:
status = scic_sds_remote_device_complete_io(scic, rdev, ireq);
status = scic_sds_remote_device_complete_io(scic, idev, ireq);
if (status != SCI_SUCCESS)
return status;
......@@ -2923,7 +2923,7 @@ enum sci_status scic_controller_continue_io(struct isci_request *ireq)
*/
enum sci_task_status scic_controller_start_task(
struct scic_sds_controller *scic,
struct scic_sds_remote_device *rdev,
struct isci_remote_device *idev,
struct isci_request *ireq)
{
enum sci_status status;
......@@ -2936,7 +2936,7 @@ enum sci_task_status scic_controller_start_task(
return SCI_TASK_FAILURE_INVALID_STATE;
}
status = scic_sds_remote_device_start_task(scic, rdev, ireq);
status = scic_sds_remote_device_start_task(scic, idev, ireq);
switch (status) {
case SCI_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS:
set_bit(IREQ_ACTIVE, &ireq->flags);
......
......@@ -163,7 +163,7 @@ struct scic_sds_controller {
* objects that need to handle device completion notifications from the
* hardware. The table is RNi based.
*/
struct scic_sds_remote_device *device_table[SCI_MAX_REMOTE_DEVICES];
struct isci_remote_device *device_table[SCI_MAX_REMOTE_DEVICES];
/**
* This field is the free RNi data structure
......@@ -488,12 +488,12 @@ static inline struct isci_host *scic_to_ihost(struct scic_sds_controller *scic)
#define ISCI_TAG_TCI(tag) ((tag) & (SCI_MAX_IO_REQUESTS-1))
/* expander attached sata devices require 3 rnc slots */
static inline int scic_sds_remote_device_node_count(struct scic_sds_remote_device *sci_dev)
static inline int scic_sds_remote_device_node_count(struct isci_remote_device *idev)
{
struct domain_device *dev = sci_dev_to_domain(sci_dev);
struct domain_device *dev = idev->domain_dev;
if ((dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) &&
!sci_dev->is_direct_attached)
!idev->is_direct_attached)
return SCU_STP_REMOTE_NODE_COUNT;
return SCU_SSP_REMOTE_NODE_COUNT;
}
......@@ -541,11 +541,8 @@ static inline struct device *sciport_to_dev(struct isci_port *iport)
return &iport->isci_host->pdev->dev;
}
static inline struct device *scirdev_to_dev(struct scic_sds_remote_device *sci_dev)
static inline struct device *scirdev_to_dev(struct isci_remote_device *idev)
{
struct isci_remote_device *idev =
container_of(sci_dev, typeof(*idev), sci);
if (!idev || !idev->isci_port || !idev->isci_port->isci_host)
return NULL;
......@@ -589,11 +586,11 @@ void scic_sds_controller_copy_sata_response(void *response_buffer,
void *frame_header,
void *frame_buffer);
enum sci_status scic_sds_controller_allocate_remote_node_context(struct scic_sds_controller *scic,
struct scic_sds_remote_device *sci_dev,
struct isci_remote_device *idev,
u16 *node_id);
void scic_sds_controller_free_remote_node_context(
struct scic_sds_controller *scic,
struct scic_sds_remote_device *sci_dev,
struct isci_remote_device *idev,
u16 node_id);
union scu_remote_node_context *scic_sds_controller_get_remote_node_context_buffer(
struct scic_sds_controller *scic,
......@@ -622,7 +619,7 @@ void scic_sds_controller_link_down(
void scic_sds_controller_remote_device_stopped(
struct scic_sds_controller *scic,
struct scic_sds_remote_device *sci_dev);
struct isci_remote_device *idev);
void scic_sds_controller_copy_task_context(
struct scic_sds_controller *scic,
......@@ -662,22 +659,22 @@ void scic_controller_disable_interrupts(
enum sci_status scic_controller_start_io(
struct scic_sds_controller *scic,
struct scic_sds_remote_device *remote_device,
struct isci_remote_device *idev,
struct isci_request *ireq);
enum sci_task_status scic_controller_start_task(
struct scic_sds_controller *scic,
struct scic_sds_remote_device *remote_device,
struct isci_remote_device *idev,
struct isci_request *ireq);
enum sci_status scic_controller_terminate_request(
struct scic_sds_controller *scic,
struct scic_sds_remote_device *remote_device,
struct isci_remote_device *idev,
struct isci_request *ireq);
enum sci_status scic_controller_complete_io(
struct scic_sds_controller *scic,
struct scic_sds_remote_device *remote_device,
struct isci_remote_device *idev,
struct isci_request *ireq);
void scic_sds_port_configuration_agent_construct(
......
......@@ -1541,7 +1541,7 @@ enum sci_status scic_sds_port_link_down(struct isci_port *iport,
}
enum sci_status scic_sds_port_start_io(struct isci_port *iport,
struct scic_sds_remote_device *sci_dev,
struct isci_remote_device *idev,
struct isci_request *ireq)
{
enum scic_sds_port_states state;
......@@ -1561,7 +1561,7 @@ enum sci_status scic_sds_port_start_io(struct isci_port *iport,
}
enum sci_status scic_sds_port_complete_io(struct isci_port *iport,
struct scic_sds_remote_device *sci_dev,
struct isci_remote_device *idev,
struct isci_request *ireq)
{
enum scic_sds_port_states state;
......
......@@ -283,15 +283,15 @@ enum sci_status scic_sds_port_link_down(struct isci_port *iport,
struct isci_phy *iphy);
struct isci_request;
struct scic_sds_remote_device;
struct isci_remote_device;
enum sci_status scic_sds_port_start_io(
struct isci_port *iport,
struct scic_sds_remote_device *sci_dev,
struct isci_remote_device *idev,
struct isci_request *ireq);
enum sci_status scic_sds_port_complete_io(
struct isci_port *iport,
struct scic_sds_remote_device *sci_dev,
struct isci_remote_device *idev,
struct isci_request *ireq);
enum sas_linkrate scic_sds_port_get_max_allowed_speed(
......
此差异已折叠。
......@@ -70,65 +70,14 @@ enum scic_remote_device_not_ready_reason_code {
SCIC_REMOTE_DEVICE_NOT_READY_REASON_CODE_MAX
};
struct scic_sds_remote_device {
/**
* This field contains the information for the base remote device state
* machine.
*/
struct sci_base_state_machine sm;
/**
* This field is the programmed device port width. This value is
* written to the RCN data structure to tell the SCU how many open
* connections this device can have.
*/
u32 device_port_width;
/**
* This field is the programmed connection rate for this remote device. It is
* used to program the TC with the maximum allowed connection rate.
*/
enum sas_linkrate connection_rate;
/**
* This filed is assinged the value of true if the device is directly
* attached to the port.
*/
bool is_direct_attached;
/**
* This filed contains a pointer back to the port to which this device
* is assigned.
*/
struct isci_port *owning_port;
/**
* This field contains the SCU silicon remote node context specific
* information.
*/
struct scic_sds_remote_node_context rnc;
/**
* This field contains the stated request count for the remote device. The
* device can not reach the SCI_DEV_STOPPED until all
* requests are complete and the rnc_posted value is false.
*/
u32 started_request_count;
/**
* This field contains a pointer to the working request object. It is only
* used only for SATA requests since the unsolicited frames we get from the
* hardware have no Tag value to look up the io request object.
*/
struct isci_request *working_request;
/**
* This field contains the reason for the remote device going not_ready. It is
* assigned in the state handlers and used in the state transition.
*/
u32 not_ready_reason;
};
/**
* isci_remote_device - isci representation of a sas expander / end point
* @device_port_width: hw setting for number of simultaneous connections
* @connection_rate: per-taskcontext connection rate for this device
* @working_request: SATA requests have no tag we for unaccelerated
* protocols we need a method to associate unsolicited
* frames with a pending request
*/
struct isci_remote_device {
#define IDEV_START_PENDING 0
#define IDEV_STOP_PENDING 1
......@@ -143,7 +92,16 @@ struct isci_remote_device {
struct domain_device *domain_dev;
struct list_head node;
struct list_head reqs_in_process;
struct scic_sds_remote_device sci;
struct sci_base_state_machine sm;
u32 device_port_width;
enum sas_linkrate connection_rate;
bool is_direct_attached;
struct isci_port *owning_port;
struct scic_sds_remote_node_context rnc;
/* XXX unify with device reference counting and delete */
u32 started_request_count;
struct isci_request *working_request;
u32 not_ready_reason;
};
#define ISCI_REMOTE_DEVICE_START_TIMEOUT 5000
......@@ -191,7 +149,7 @@ void isci_device_clear_reset_pending(struct isci_host *ihost,
* successfully stopped.
*/
enum sci_status scic_remote_device_stop(
struct scic_sds_remote_device *remote_device,
struct isci_remote_device *idev,
u32 timeout);
/**
......@@ -207,7 +165,7 @@ enum sci_status scic_remote_device_stop(
* started.
*/
enum sci_status scic_remote_device_reset(
struct scic_sds_remote_device *remote_device);
struct isci_remote_device *idev);
/**
* scic_remote_device_reset_complete() - This method informs the device object
......@@ -220,7 +178,7 @@ enum sci_status scic_remote_device_reset(
* is resuming operation.
*/
enum sci_status scic_remote_device_reset_complete(
struct scic_sds_remote_device *remote_device);
struct isci_remote_device *idev);
#define scic_remote_device_is_atapi(device_handle) false
......@@ -335,27 +293,15 @@ enum scic_sds_remote_device_states {
SCI_DEV_FINAL,
};
static inline struct scic_sds_remote_device *rnc_to_dev(struct scic_sds_remote_node_context *rnc)
static inline struct isci_remote_device *rnc_to_dev(struct scic_sds_remote_node_context *rnc)
{
struct scic_sds_remote_device *sci_dev;
struct isci_remote_device *idev;
sci_dev = container_of(rnc, typeof(*sci_dev), rnc);
return sci_dev;
}
static inline struct isci_remote_device *sci_dev_to_idev(struct scic_sds_remote_device *sci_dev)
{
struct isci_remote_device *idev = container_of(sci_dev, typeof(*idev), sci);
idev = container_of(rnc, typeof(*idev), rnc);
return idev;
}
static inline struct domain_device *sci_dev_to_domain(struct scic_sds_remote_device *sci_dev)
{
return sci_dev_to_idev(sci_dev)->domain_dev;
}
static inline bool dev_is_expander(struct domain_device *dev)
{
return dev->dev_type == EDGE_DEV || dev->dev_type == FANOUT_DEV;
......@@ -366,8 +312,8 @@ static inline bool dev_is_expander(struct domain_device *dev)
*
* This macro incrments the request count for this device
*/
#define scic_sds_remote_device_increment_request_count(sci_dev) \
((sci_dev)->started_request_count++)
#define scic_sds_remote_device_increment_request_count(idev) \
((idev)->started_request_count++)
/**
* scic_sds_remote_device_decrement_request_count() -
......@@ -375,44 +321,44 @@ static inline bool dev_is_expander(struct domain_device *dev)
* This macro decrements the request count for this device. This count will
* never decrment past 0.
*/
#define scic_sds_remote_device_decrement_request_count(sci_dev) \
((sci_dev)->started_request_count > 0 ? \
(sci_dev)->started_request_count-- : 0)
#define scic_sds_remote_device_decrement_request_count(idev) \
((idev)->started_request_count > 0 ? \
(idev)->started_request_count-- : 0)
/**
* scic_sds_remote_device_get_request_count() -
*
* This is a helper macro to return the current device request count.
*/
#define scic_sds_remote_device_get_request_count(sci_dev) \
((sci_dev)->started_request_count)
#define scic_sds_remote_device_get_request_count(idev) \
((idev)->started_request_count)
/**
* scic_sds_remote_device_get_controller() -
*
* This macro returns the controller object that contains this device object
*/
#define scic_sds_remote_device_get_controller(sci_dev) \
scic_sds_port_get_controller(scic_sds_remote_device_get_port(sci_dev))
#define scic_sds_remote_device_get_controller(idev) \
scic_sds_port_get_controller(scic_sds_remote_device_get_port(idev))
/**
* scic_sds_remote_device_get_port() -
*
* This macro returns the owning port of this device
*/
#define scic_sds_remote_device_get_port(sci_dev) \
((sci_dev)->owning_port)
#define scic_sds_remote_device_get_port(idev) \
((idev)->owning_port)
/**
* scic_sds_remote_device_get_controller_peg() -
*
* This macro returns the controllers protocol engine group
*/
#define scic_sds_remote_device_get_controller_peg(sci_dev) \
#define scic_sds_remote_device_get_controller_peg(idev) \
(\
scic_sds_controller_get_protocol_engine_group(\
scic_sds_port_get_controller(\
scic_sds_remote_device_get_port(sci_dev) \
scic_sds_remote_device_get_port(idev) \
) \
) \
)
......@@ -422,8 +368,8 @@ static inline bool dev_is_expander(struct domain_device *dev)
*
* This macro returns the remote node index for this device object
*/
#define scic_sds_remote_device_get_index(sci_dev) \
((sci_dev)->rnc.remote_node_index)
#define scic_sds_remote_device_get_index(idev) \
((idev)->rnc.remote_node_index)
/**
* scic_sds_remote_device_build_command_context() -
......@@ -448,36 +394,36 @@ static inline bool dev_is_expander(struct domain_device *dev)
((device)->working_request = (request))
enum sci_status scic_sds_remote_device_frame_handler(
struct scic_sds_remote_device *sci_dev,
struct isci_remote_device *idev,
u32 frame_index);
enum sci_status scic_sds_remote_device_event_handler(
struct scic_sds_remote_device *sci_dev,
struct isci_remote_device *idev,
u32 event_code);
enum sci_status scic_sds_remote_device_start_io(
struct scic_sds_controller *controller,
struct scic_sds_remote_device *sci_dev,
struct isci_remote_device *idev,
struct isci_request *ireq);
enum sci_status scic_sds_remote_device_start_task(
struct scic_sds_controller *controller,
struct scic_sds_remote_device *sci_dev,
struct isci_remote_device *idev,
struct isci_request *ireq);
enum sci_status scic_sds_remote_device_complete_io(
struct scic_sds_controller *controller,
struct scic_sds_remote_device *sci_dev,
struct isci_remote_device *idev,
struct isci_request *ireq);
enum sci_status scic_sds_remote_device_suspend(
struct scic_sds_remote_device *sci_dev,
struct isci_remote_device *idev,
u32 suspend_type);
void scic_sds_remote_device_post_request(
struct scic_sds_remote_device *sci_dev,
struct isci_remote_device *idev,
u32 request);
#define scic_sds_remote_device_is_atapi(sci_dev) false
#define scic_sds_remote_device_is_atapi(idev) false
#endif /* !defined(_ISCI_REMOTE_DEVICE_H_) */
......@@ -103,22 +103,22 @@ bool scic_sds_remote_node_context_is_ready(
static void scic_sds_remote_node_context_construct_buffer(
struct scic_sds_remote_node_context *sci_rnc)
{
struct scic_sds_remote_device *sci_dev = rnc_to_dev(sci_rnc);
struct domain_device *dev = sci_dev_to_domain(sci_dev);
struct isci_remote_device *idev = rnc_to_dev(sci_rnc);
struct domain_device *dev = idev->domain_dev;
int rni = sci_rnc->remote_node_index;
union scu_remote_node_context *rnc;
struct scic_sds_controller *scic;
__le64 sas_addr;
scic = scic_sds_remote_device_get_controller(sci_dev);
scic = scic_sds_remote_device_get_controller(idev);
rnc = scic_sds_controller_get_remote_node_context_buffer(scic, rni);
memset(rnc, 0, sizeof(union scu_remote_node_context)
* scic_sds_remote_device_node_count(sci_dev));
* scic_sds_remote_device_node_count(idev));
rnc->ssp.remote_node_index = rni;
rnc->ssp.remote_node_port_width = sci_dev->device_port_width;
rnc->ssp.logical_port_index = sci_dev->owning_port->physical_port_index;
rnc->ssp.remote_node_port_width = idev->device_port_width;
rnc->ssp.logical_port_index = idev->owning_port->physical_port_index;
/* sas address is __be64, context ram format is __le64 */
sas_addr = cpu_to_le64(SAS_ADDR(dev->sas_addr));
......@@ -148,7 +148,7 @@ static void scic_sds_remote_node_context_construct_buffer(
rnc->ssp.initial_arbitration_wait_time = 0;
/* Open Address Frame Parameters */
rnc->ssp.oaf_connection_rate = sci_dev->connection_rate;
rnc->ssp.oaf_connection_rate = idev->connection_rate;
rnc->ssp.oaf_features = 0;
rnc->ssp.oaf_source_zone_group = 0;
rnc->ssp.oaf_more_compatibility_features = 0;
......@@ -220,26 +220,26 @@ static void scic_sds_remote_node_context_continue_state_transitions(struct scic_
static void scic_sds_remote_node_context_validate_context_buffer(
struct scic_sds_remote_node_context *sci_rnc)
{
struct scic_sds_remote_device *sci_dev = rnc_to_dev(sci_rnc);
struct domain_device *dev = sci_dev_to_domain(sci_dev);
struct isci_remote_device *idev = rnc_to_dev(sci_rnc);
struct domain_device *dev = idev->domain_dev;
union scu_remote_node_context *rnc_buffer;
rnc_buffer = scic_sds_controller_get_remote_node_context_buffer(
scic_sds_remote_device_get_controller(sci_dev),
scic_sds_remote_device_get_controller(idev),
sci_rnc->remote_node_index
);
rnc_buffer->ssp.is_valid = true;
if (!sci_dev->is_direct_attached &&
if (!idev->is_direct_attached &&
(dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP))) {
scic_sds_remote_device_post_request(sci_dev,
scic_sds_remote_device_post_request(idev,
SCU_CONTEXT_COMMAND_POST_RNC_96);
} else {
scic_sds_remote_device_post_request(sci_dev, SCU_CONTEXT_COMMAND_POST_RNC_32);
scic_sds_remote_device_post_request(idev, SCU_CONTEXT_COMMAND_POST_RNC_32);
if (sci_dev->is_direct_attached) {
scic_sds_port_setup_transports(sci_dev->owning_port,
if (idev->is_direct_attached) {
scic_sds_port_setup_transports(idev->owning_port,
sci_rnc->remote_node_index);
}
}
......@@ -296,11 +296,11 @@ static void scic_sds_remote_node_context_invalidating_state_enter(struct sci_bas
static void scic_sds_remote_node_context_resuming_state_enter(struct sci_base_state_machine *sm)
{
struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), sm);
struct scic_sds_remote_device *sci_dev;
struct isci_remote_device *idev;
struct domain_device *dev;
sci_dev = rnc_to_dev(rnc);
dev = sci_dev_to_domain(sci_dev);
idev = rnc_to_dev(rnc);
dev = idev->domain_dev;
/*
* For direct attached SATA devices we need to clear the TLCR
......@@ -309,11 +309,11 @@ static void scic_sds_remote_node_context_resuming_state_enter(struct sci_base_st
* the STPTLDARNI register with the RNi of the device
*/
if ((dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) &&
sci_dev->is_direct_attached)
scic_sds_port_setup_transports(sci_dev->owning_port,
idev->is_direct_attached)
scic_sds_port_setup_transports(idev->owning_port,
rnc->remote_node_index);
scic_sds_remote_device_post_request(sci_dev, SCU_CONTEXT_COMMAND_POST_RNC_RESUME);
scic_sds_remote_device_post_request(idev, SCU_CONTEXT_COMMAND_POST_RNC_RESUME);
}
static void scic_sds_remote_node_context_ready_state_enter(struct sci_base_state_machine *sm)
......@@ -564,8 +564,8 @@ enum sci_status scic_sds_remote_node_context_resume(struct scic_sds_remote_node_
sci_rnc->user_cookie = cb_p;
return SCI_SUCCESS;
case SCI_RNC_TX_SUSPENDED: {
struct scic_sds_remote_device *sci_dev = rnc_to_dev(sci_rnc);
struct domain_device *dev = sci_dev_to_domain(sci_dev);
struct isci_remote_device *idev = rnc_to_dev(sci_rnc);
struct domain_device *dev = idev->domain_dev;
scic_sds_remote_node_context_setup_to_resume(sci_rnc, cb_fn, cb_p);
......@@ -573,7 +573,7 @@ enum sci_status scic_sds_remote_node_context_resume(struct scic_sds_remote_node_
if (dev->dev_type == SAS_END_DEV || dev_is_expander(dev))
sci_change_state(&sci_rnc->sm, SCI_RNC_RESUMING);
else if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) {
if (sci_dev->is_direct_attached) {
if (idev->is_direct_attached) {
/* @todo Fix this since I am being silly in writing to the STPTLDARNI register. */
sci_change_state(&sci_rnc->sm, SCI_RNC_RESUMING);
} else {
......
......@@ -79,7 +79,7 @@
#define SCI_SOFTWARE_SUSPENSION (1)
struct isci_request;
struct scic_sds_remote_device;
struct isci_remote_device;
struct scic_sds_remote_node_context;
typedef void (*scics_sds_remote_node_context_callback)(void *);
......
......@@ -209,17 +209,17 @@ static void scu_ssp_reqeust_construct_task_context(
struct scu_task_context *task_context)
{
dma_addr_t dma_addr;
struct scic_sds_remote_device *target_device;
struct isci_remote_device *idev;
struct isci_port *iport;
target_device = scic_sds_request_get_device(ireq);
idev = scic_sds_request_get_device(ireq);
iport = scic_sds_request_get_port(ireq);
/* Fill in the TC with the its required data */
task_context->abort = 0;
task_context->priority = 0;
task_context->initiator_request = 1;
task_context->connection_rate = target_device->connection_rate;
task_context->connection_rate = idev->connection_rate;
task_context->protocol_engine_index =
scic_sds_controller_get_protocol_engine_group(controller);
task_context->logical_port_index = scic_sds_port_get_index(iport);
......@@ -227,8 +227,7 @@ static void scu_ssp_reqeust_construct_task_context(
task_context->valid = SCU_TASK_CONTEXT_VALID;
task_context->context_type = SCU_TASK_CONTEXT_TYPE;
task_context->remote_node_index =
scic_sds_remote_device_get_index(ireq->target_device);
task_context->remote_node_index = scic_sds_remote_device_get_index(idev);
task_context->command_code = 0;
task_context->link_layer_control = 0;
......@@ -348,17 +347,17 @@ static void scu_sata_reqeust_construct_task_context(
struct scu_task_context *task_context)
{
dma_addr_t dma_addr;
struct scic_sds_remote_device *target_device;
struct isci_remote_device *idev;
struct isci_port *iport;
target_device = scic_sds_request_get_device(ireq);
idev = scic_sds_request_get_device(ireq);
iport = scic_sds_request_get_port(ireq);
/* Fill in the TC with the its required data */
task_context->abort = 0;
task_context->priority = SCU_TASK_PRIORITY_NORMAL;
task_context->initiator_request = 1;
task_context->connection_rate = target_device->connection_rate;
task_context->connection_rate = idev->connection_rate;
task_context->protocol_engine_index =
scic_sds_controller_get_protocol_engine_group(controller);
task_context->logical_port_index =
......@@ -367,8 +366,7 @@ static void scu_sata_reqeust_construct_task_context(
task_context->valid = SCU_TASK_CONTEXT_VALID;
task_context->context_type = SCU_TASK_CONTEXT_TYPE;
task_context->remote_node_index =
scic_sds_remote_device_get_index(ireq->target_device);
task_context->remote_node_index = scic_sds_remote_device_get_index(idev);
task_context->command_code = 0;
task_context->link_layer_control = 0;
......@@ -2850,7 +2848,7 @@ static void isci_request_io_request_complete(struct isci_host *isci_host,
static void scic_sds_request_started_state_enter(struct sci_base_state_machine *sm)
{
struct isci_request *ireq = container_of(sm, typeof(*ireq), sm);
struct domain_device *dev = sci_dev_to_domain(ireq->target_device);
struct domain_device *dev = ireq->target_device->domain_dev;
struct sas_task *task;
/* XXX as hch said always creating an internal sas_task for tmf
......@@ -2988,12 +2986,12 @@ static const struct sci_base_state scic_sds_request_state_table[] = {
static void
scic_sds_general_request_construct(struct scic_sds_controller *scic,
struct scic_sds_remote_device *sci_dev,
struct isci_remote_device *idev,
struct isci_request *ireq)
{
sci_init_sm(&ireq->sm, scic_sds_request_state_table, SCI_REQ_INIT);
ireq->target_device = sci_dev;
ireq->target_device = idev;
ireq->protocol = SCIC_NO_PROTOCOL;
ireq->saved_rx_frame_index = SCU_INVALID_FRAME_INDEX;
......@@ -3004,16 +3002,16 @@ scic_sds_general_request_construct(struct scic_sds_controller *scic,
static enum sci_status
scic_io_request_construct(struct scic_sds_controller *scic,
struct scic_sds_remote_device *sci_dev,
struct isci_remote_device *idev,
struct isci_request *ireq)
{
struct domain_device *dev = sci_dev_to_domain(sci_dev);
struct domain_device *dev = idev->domain_dev;
enum sci_status status = SCI_SUCCESS;
/* Build the common part of the request */
scic_sds_general_request_construct(scic, sci_dev, ireq);
scic_sds_general_request_construct(scic, idev, ireq);
if (sci_dev->rnc.remote_node_index == SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX)
if (idev->rnc.remote_node_index == SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX)
return SCI_FAILURE_INVALID_REMOTE_DEVICE;
if (dev->dev_type == SAS_END_DEV)
......@@ -3031,14 +3029,14 @@ scic_io_request_construct(struct scic_sds_controller *scic,
}
enum sci_status scic_task_request_construct(struct scic_sds_controller *scic,
struct scic_sds_remote_device *sci_dev,
struct isci_remote_device *idev,
u16 io_tag, struct isci_request *ireq)
{
struct domain_device *dev = sci_dev_to_domain(sci_dev);
struct domain_device *dev = idev->domain_dev;
enum sci_status status = SCI_SUCCESS;
/* Build the common part of the request */
scic_sds_general_request_construct(scic, sci_dev, ireq);
scic_sds_general_request_construct(scic, idev, ireq);
if (dev->dev_type == SAS_END_DEV ||
dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) {
......@@ -3102,7 +3100,7 @@ scic_io_request_construct_smp(struct device *dev,
struct sas_task *task)
{
struct scatterlist *sg = &task->smp_task.smp_req;
struct scic_sds_remote_device *sci_dev;
struct isci_remote_device *idev;
struct scu_task_context *task_context;
struct isci_port *iport;
struct smp_req *smp_req;
......@@ -3147,7 +3145,7 @@ scic_io_request_construct_smp(struct device *dev,
task_context = ireq->tc;
sci_dev = scic_sds_request_get_device(ireq);
idev = scic_sds_request_get_device(ireq);
iport = scic_sds_request_get_port(ireq);
/*
......@@ -3156,7 +3154,7 @@ scic_io_request_construct_smp(struct device *dev,
*/
task_context->priority = 0;
task_context->initiator_request = 1;
task_context->connection_rate = sci_dev->connection_rate;
task_context->connection_rate = idev->connection_rate;
task_context->protocol_engine_index =
scic_sds_controller_get_protocol_engine_group(scic);
task_context->logical_port_index = scic_sds_port_get_index(iport);
......@@ -3166,7 +3164,7 @@ scic_io_request_construct_smp(struct device *dev,
task_context->context_type = SCU_TASK_CONTEXT_TYPE;
/* 04h */
task_context->remote_node_index = sci_dev->rnc.remote_node_index;
task_context->remote_node_index = idev->rnc.remote_node_index;
task_context->command_code = 0;
task_context->task_type = SCU_TASK_TYPE_SMP_REQUEST;
......@@ -3257,17 +3255,16 @@ static enum sci_status isci_smp_request_build(struct isci_request *ireq)
*/
static enum sci_status isci_io_request_build(struct isci_host *isci_host,
struct isci_request *request,
struct isci_remote_device *isci_device)
struct isci_remote_device *idev)
{
enum sci_status status = SCI_SUCCESS;
struct sas_task *task = isci_request_access_task(request);
struct scic_sds_remote_device *sci_device = &isci_device->sci;
dev_dbg(&isci_host->pdev->dev,
"%s: isci_device = 0x%p; request = %p, "
"%s: idev = 0x%p; request = %p, "
"num_scatter = %d\n",
__func__,
isci_device,
idev,
request,
task->num_scatter);
......@@ -3290,8 +3287,7 @@ static enum sci_status isci_io_request_build(struct isci_host *isci_host,
return SCI_FAILURE_INSUFFICIENT_RESOURCES;
}
status = scic_io_request_construct(&isci_host->sci, sci_device,
request);
status = scic_io_request_construct(&isci_host->sci, idev, request);
if (status != SCI_SUCCESS) {
dev_warn(&isci_host->pdev->dev,
......@@ -3397,14 +3393,14 @@ int isci_request_execute(struct isci_host *ihost, struct isci_remote_device *ide
* ireq->is_task_management_request is false).
*/
status = scic_controller_start_task(&ihost->sci,
&idev->sci,
idev,
ireq);
} else {
status = SCI_FAILURE;
}
} else {
/* send the request, let the core assign the IO TAG. */
status = scic_controller_start_io(&ihost->sci, &idev->sci,
status = scic_controller_start_io(&ihost->sci, idev,
ireq);
}
......
......@@ -146,7 +146,7 @@ struct isci_request {
struct completion *io_request_completion;
struct sci_base_state_machine sm;
struct scic_sds_controller *owning_controller;
struct scic_sds_remote_device *target_device;
struct isci_remote_device *target_device;
u16 io_tag;
enum sci_request_protocol protocol;
u32 scu_status; /* hardware result */
......@@ -501,7 +501,7 @@ void isci_terminate_pending_requests(struct isci_host *ihost,
struct isci_remote_device *idev);
enum sci_status
scic_task_request_construct(struct scic_sds_controller *scic,
struct scic_sds_remote_device *sci_dev,
struct isci_remote_device *idev,
u16 io_tag,
struct isci_request *ireq);
enum sci_status
......
......@@ -257,7 +257,7 @@ static struct isci_request *isci_task_request_build(struct isci_host *ihost,
return NULL;
/* let the core do it's construct. */
status = scic_task_request_construct(&ihost->sci, &idev->sci, tag,
status = scic_task_request_construct(&ihost->sci, idev, tag,
ireq);
if (status != SCI_SUCCESS) {
......@@ -288,12 +288,11 @@ static struct isci_request *isci_task_request_build(struct isci_host *ihost,
}
int isci_task_execute_tmf(struct isci_host *ihost,
struct isci_remote_device *isci_device,
struct isci_remote_device *idev,
struct isci_tmf *tmf, unsigned long timeout_ms)
{
DECLARE_COMPLETION_ONSTACK(completion);
enum sci_task_status status = SCI_TASK_FAILURE;
struct scic_sds_remote_device *sci_device;
struct isci_request *ireq;
int ret = TMF_RESP_FUNC_FAILED;
unsigned long flags;
......@@ -310,34 +309,30 @@ int isci_task_execute_tmf(struct isci_host *ihost,
/* sanity check, return TMF_RESP_FUNC_FAILED
* if the device is not there and ready.
*/
if (!isci_device ||
(!test_bit(IDEV_IO_READY, &isci_device->flags) &&
!test_bit(IDEV_IO_NCQERROR, &isci_device->flags))) {
if (!idev ||
(!test_bit(IDEV_IO_READY, &idev->flags) &&
!test_bit(IDEV_IO_NCQERROR, &idev->flags))) {
dev_dbg(&ihost->pdev->dev,
"%s: isci_device = %p not ready (%#lx)\n",
"%s: idev = %p not ready (%#lx)\n",
__func__,
isci_device, isci_device ? isci_device->flags : 0);
idev, idev ? idev->flags : 0);
goto err_tci;
} else
dev_dbg(&ihost->pdev->dev,
"%s: isci_device = %p\n",
__func__, isci_device);
sci_device = &isci_device->sci;
"%s: idev = %p\n",
__func__, idev);
/* Assign the pointer to the TMF's completion kernel wait structure. */
tmf->complete = &completion;
ireq = isci_task_request_build(ihost, isci_device, tag, tmf);
ireq = isci_task_request_build(ihost, idev, tag, tmf);
if (!ireq)
goto err_tci;
spin_lock_irqsave(&ihost->scic_lock, flags);
/* start the TMF io. */
status = scic_controller_start_task(&ihost->sci,
sci_device,
ireq);
status = scic_controller_start_task(&ihost->sci, idev, ireq);
if (status != SCI_TASK_SUCCESS) {
dev_warn(&ihost->pdev->dev,
......@@ -355,7 +350,7 @@ int isci_task_execute_tmf(struct isci_host *ihost,
isci_request_change_state(ireq, started);
/* add the request to the remote device request list. */
list_add(&ireq->dev_node, &isci_device->reqs_in_process);
list_add(&ireq->dev_node, &idev->reqs_in_process);
spin_unlock_irqrestore(&ihost->scic_lock, flags);
......@@ -370,7 +365,7 @@ int isci_task_execute_tmf(struct isci_host *ihost,
tmf->cb_state_func(isci_tmf_timed_out, tmf, tmf->cb_data);
scic_controller_terminate_request(&ihost->sci,
&isci_device->sci,
idev,
ireq);
spin_unlock_irqrestore(&ihost->scic_lock, flags);
......@@ -520,13 +515,13 @@ static void isci_request_cleanup_completed_loiterer(
* from a thread that can wait. Note that the request is terminated and
* completed (back to the host, if started there).
* @isci_host: This SCU.
* @isci_device: The target.
* @idev: The target.
* @isci_request: The I/O request to be terminated.
*
*/
static void isci_terminate_request_core(
struct isci_host *isci_host,
struct isci_remote_device *isci_device,
struct isci_remote_device *idev,
struct isci_request *isci_request)
{
enum sci_status status = SCI_SUCCESS;
......@@ -540,7 +535,7 @@ static void isci_terminate_request_core(
dev_dbg(&isci_host->pdev->dev,
"%s: device = %p; request = %p\n",
__func__, isci_device, isci_request);
__func__, idev, isci_request);
spin_lock_irqsave(&isci_host->scic_lock, flags);
......@@ -564,7 +559,7 @@ static void isci_terminate_request_core(
needs_cleanup_handling = true;
status = scic_controller_terminate_request(
&isci_host->sci,
&isci_device->sci,
idev,
isci_request);
}
spin_unlock_irqrestore(&isci_host->scic_lock, flags);
......@@ -683,7 +678,7 @@ static void isci_terminate_request_core(
}
if (needs_cleanup_handling)
isci_request_cleanup_completed_loiterer(
isci_host, isci_device, isci_request, task);
isci_host, idev, isci_request, task);
}
}
......@@ -694,7 +689,7 @@ static void isci_terminate_request_core(
* called from a thread that can wait. Note that the requests are all
* terminated and completed (back to the host, if started there).
* @isci_host: This parameter specifies SCU.
* @isci_device: This parameter specifies the target.
* @idev: This parameter specifies the target.
*
*/
void isci_terminate_pending_requests(struct isci_host *ihost,
......@@ -1521,7 +1516,7 @@ static int isci_reset_device(struct isci_host *ihost,
dev_dbg(&ihost->pdev->dev, "%s: idev %p\n", __func__, idev);
spin_lock_irqsave(&ihost->scic_lock, flags);
status = scic_remote_device_reset(&idev->sci);
status = scic_remote_device_reset(idev);
if (status != SCI_SUCCESS) {
spin_unlock_irqrestore(&ihost->scic_lock, flags);
......@@ -1547,7 +1542,7 @@ static int isci_reset_device(struct isci_host *ihost,
/* Since all pending TCs have been cleaned, resume the RNC. */
spin_lock_irqsave(&ihost->scic_lock, flags);
status = scic_remote_device_reset_complete(&idev->sci);
status = scic_remote_device_reset_complete(idev);
spin_unlock_irqrestore(&ihost->scic_lock, flags);
/* If this is a device on an expander, bring the phy back up. */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册