Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 254550
b: refs/heads/master
c: ac668c6
h: refs/heads/master
v: v3
  • Loading branch information
Dan Williams committed Jul 3, 2011
1 parent 2b5f977 commit e20e951
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 232 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9b917987fd16d0687afe550a02f68099419f5d43
refs/heads/master: ac668c69709c7d927015c5cf3d9e87bf4eaaf57d
75 changes: 51 additions & 24 deletions trunk/drivers/scsi/isci/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <linux/circ_buf.h>
#include <linux/device.h>
#include <scsi/sas.h>
#include "host.h"
Expand Down Expand Up @@ -1054,6 +1055,33 @@ static void phy_startup_timeout(unsigned long data)
spin_unlock_irqrestore(&ihost->scic_lock, flags);
}

static void isci_tci_free(struct isci_host *ihost, u16 tci)
{
u16 tail = ihost->tci_tail & (SCI_MAX_IO_REQUESTS-1);

ihost->tci_pool[tail] = tci;
ihost->tci_tail = tail + 1;
}

static u16 isci_tci_alloc(struct isci_host *ihost)
{
u16 head = ihost->tci_head & (SCI_MAX_IO_REQUESTS-1);
u16 tci = ihost->tci_pool[head];

ihost->tci_head = head + 1;
return tci;
}

static u16 isci_tci_active(struct isci_host *ihost)
{
return CIRC_CNT(ihost->tci_head, ihost->tci_tail, SCI_MAX_IO_REQUESTS);
}

static u16 isci_tci_space(struct isci_host *ihost)
{
return CIRC_SPACE(ihost->tci_head, ihost->tci_tail, SCI_MAX_IO_REQUESTS);
}

static enum sci_status scic_controller_start(struct scic_sds_controller *scic,
u32 timeout)
{
Expand All @@ -1069,9 +1097,11 @@ static enum sci_status scic_controller_start(struct scic_sds_controller *scic,
}

/* Build the TCi free pool */
sci_pool_initialize(scic->tci_pool);
BUILD_BUG_ON(SCI_MAX_IO_REQUESTS > 1 << sizeof(ihost->tci_pool[0]) * 8);
ihost->tci_head = 0;
ihost->tci_tail = 0;
for (index = 0; index < scic->task_context_entries; index++)
sci_pool_put(scic->tci_pool, index);
isci_tci_free(ihost, index);

/* Build the RNi free pool */
scic_sds_remote_node_table_initialize(
Expand Down Expand Up @@ -3063,18 +3093,17 @@ enum sci_task_status scic_controller_start_task(
* currently available tags to be allocated. All return other values indicate a
* legitimate tag.
*/
u16 scic_controller_allocate_io_tag(
struct scic_sds_controller *scic)
u16 scic_controller_allocate_io_tag(struct scic_sds_controller *scic)
{
u16 task_context;
u16 sequence_count;

if (!sci_pool_empty(scic->tci_pool)) {
sci_pool_get(scic->tci_pool, task_context);
struct isci_host *ihost = scic_to_ihost(scic);
u16 tci;
u16 seq;

sequence_count = scic->io_request_sequence[task_context];
if (isci_tci_space(ihost)) {
tci = isci_tci_alloc(ihost);
seq = scic->io_request_sequence[tci];

return scic_sds_io_tag_construct(sequence_count, task_context);
return scic_sds_io_tag_construct(seq, tci);
}

return SCI_CONTROLLER_INVALID_IO_TAG;
Expand Down Expand Up @@ -3105,10 +3134,10 @@ u16 scic_controller_allocate_io_tag(
* tags. SCI_FAILURE_INVALID_IO_TAG This value is returned if the supplied tag
* is not a valid IO tag value.
*/
enum sci_status scic_controller_free_io_tag(
struct scic_sds_controller *scic,
u16 io_tag)
enum sci_status scic_controller_free_io_tag(struct scic_sds_controller *scic,
u16 io_tag)
{
struct isci_host *ihost = scic_to_ihost(scic);
u16 sequence;
u16 index;

Expand All @@ -3117,18 +3146,16 @@ enum sci_status scic_controller_free_io_tag(
sequence = scic_sds_io_tag_get_sequence(io_tag);
index = scic_sds_io_tag_get_index(io_tag);

if (!sci_pool_full(scic->tci_pool)) {
if (sequence == scic->io_request_sequence[index]) {
scic_sds_io_sequence_increment(
scic->io_request_sequence[index]);
/* prevent tail from passing head */
if (isci_tci_active(ihost) == 0)
return SCI_FAILURE_INVALID_IO_TAG;

sci_pool_put(scic->tci_pool, index);
if (sequence == scic->io_request_sequence[index]) {
scic_sds_io_sequence_increment(scic->io_request_sequence[index]);

return SCI_SUCCESS;
}
}
isci_tci_free(ihost, index);

return SCI_SUCCESS;
}
return SCI_FAILURE_INVALID_IO_TAG;
}


12 changes: 4 additions & 8 deletions trunk/drivers/scsi/isci/host.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@

#include "remote_device.h"
#include "phy.h"
#include "pool.h"
#include "isci.h"
#include "remote_node_table.h"
#include "registers.h"
Expand Down Expand Up @@ -179,11 +178,6 @@ struct scic_sds_controller {
*/
struct scic_remote_node_table available_remote_nodes;

/**
* This field is the TCi pool used to manage the task context index.
*/
SCI_POOL_CREATE(tci_pool, u16, SCI_MAX_IO_REQUESTS);

/**
* This filed is the struct scic_power_control data used to controll when direct
* attached devices can consume power.
Expand Down Expand Up @@ -310,6 +304,10 @@ struct scic_sds_controller {

struct isci_host {
struct scic_sds_controller sci;
u16 tci_head;
u16 tci_tail;
u16 tci_pool[SCI_MAX_IO_REQUESTS];

union scic_oem_parameters oem_parameters;

int id; /* unique within a given pci device */
Expand Down Expand Up @@ -423,8 +421,6 @@ enum scic_sds_controller_states {
SCIC_FAILED,
};



/**
* struct isci_pci_info - This class represents the pci function containing the
* controllers. Depending on PCI SKU, there could be up to 2 controllers in
Expand Down
1 change: 1 addition & 0 deletions trunk/drivers/scsi/isci/isci.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ static inline void check_sizes(void)
BUILD_BUG_ON_NOT_POWER_OF_2(SCU_MAX_UNSOLICITED_FRAMES);
BUILD_BUG_ON_NOT_POWER_OF_2(SCU_MAX_COMPLETION_QUEUE_ENTRIES);
BUILD_BUG_ON(SCU_MAX_UNSOLICITED_FRAMES > SCU_ABSOLUTE_MAX_UNSOLICITED_FRAMES);
BUILD_BUG_ON_NOT_POWER_OF_2(SCI_MAX_IO_REQUESTS);
}

/**
Expand Down
199 changes: 0 additions & 199 deletions trunk/drivers/scsi/isci/pool.h

This file was deleted.

0 comments on commit e20e951

Please sign in to comment.