Commit 7c78da31 authored by Dan Williams's avatar Dan Williams

isci: remove 'min memory' infrastructure

The old 'core' had aspirations of running in severely memory constrained
environments like bios option-rom, it's not needed for Linux and gets in
the way of other cleanups (like unifying/reducing the number of structure
members in scic_sds_controller/isci_host).

This also fixes a theoretical bug in that the driver would blindly override
the silicon advertised limits for number of ports, task contexts, and remote
node contexts.
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent dbb0743a
This diff is collapsed.
......@@ -239,18 +239,6 @@ struct scic_sds_controller {
*/
u32 logical_port_entries;
/**
* This field is the minimum number of hardware supported completion queue
* entries and the software requested completion queue entries.
*/
u32 completion_queue_entries;
/**
* This field is the minimum number of hardware supported event entries and
* the software requested event entries.
*/
u32 completion_event_entries;
/**
* This field is the minimum number of devices supported by the hardware and
* the number of devices requested by the software.
......@@ -325,7 +313,6 @@ struct isci_host {
union scic_oem_parameters oem_parameters;
int id; /* unique within a given pci device */
void *core_ctrl_memory;
struct dma_pool *dma_pool;
struct isci_phy phys[SCI_MAX_PHYS];
struct isci_port ports[SCI_MAX_PORTS + 1]; /* includes dummy port */
......
......@@ -78,39 +78,16 @@ enum sci_controller_mode {
SCI_MODE_SIZE /* deprecated */
};
#define SCI_MAX_PHYS (4)
#define SCI_MAX_PHYS (4UL)
#define SCI_MAX_PORTS SCI_MAX_PHYS
#define SCI_MIN_SMP_PHYS (38)
#define SCI_MAX_SMP_PHYS (384) /* not silicon constrained */
#define SCI_MAX_REMOTE_DEVICES (256)
#define SCI_MIN_REMOTE_DEVICES (16)
#define SCI_MAX_IO_REQUESTS (256)
#define SCI_MIN_IO_REQUESTS (1)
#define SCI_MAX_REMOTE_DEVICES (256UL)
#define SCI_MAX_IO_REQUESTS (256UL)
#define SCI_MAX_MSIX_MESSAGES (2)
#define SCI_MAX_SCATTER_GATHER_ELEMENTS 130 /* not silicon constrained */
#define SCI_MIN_SCATTER_GATHER_ELEMENTS 1
#define SCI_MAX_CONTROLLERS 2
#define SCI_MAX_DOMAINS SCI_MAX_PORTS
/* 2 indicates the maximum number of UFs that can occur for a given IO request.
* The hardware handles reception of additional unsolicited frames while all
* UFs are in use, by holding off the transmitting device. This number could
* be theoretically reduced to 1, but 2 provides for more reliable operation.
* During SATA PIO operation, it is possible under some conditions for there to
* be 3 separate FISes received, back to back to back (PIO Setup, Data, D2H
* Register). It is unlikely to have all 3 pending all at once without some of
* them already being processed.
*/
#define SCU_MIN_UNSOLICITED_FRAMES (1)
#define SCU_MIN_CRITICAL_NOTIFICATIONS (24)
#define SCU_MIN_EVENTS (4)
#define SCU_MIN_COMPLETION_QUEUE_SCRATCH (2)
#define SCU_MIN_COMPLETION_QUEUE_ENTRIES (SCU_MIN_CRITICAL_NOTIFICATIONS \
+ SCU_MIN_EVENTS \
+ SCU_MIN_UNSOLICITED_FRAMES \
+ SCI_MIN_IO_REQUESTS \
+ SCU_MIN_COMPLETION_QUEUE_SCRATCH)
#define SCU_MAX_CRITICAL_NOTIFICATIONS (384)
#define SCU_MAX_EVENTS (128)
#define SCU_MAX_UNSOLICITED_FRAMES (128)
......@@ -121,51 +98,6 @@ enum sci_controller_mode {
+ SCI_MAX_IO_REQUESTS \
+ SCU_MAX_COMPLETION_QUEUE_SCRATCH)
#if !defined(ENABLE_MINIMUM_MEMORY_MODE)
#define SCU_UNSOLICITED_FRAME_COUNT SCU_MAX_UNSOLICITED_FRAMES
#define SCU_CRITICAL_NOTIFICATION_COUNT SCU_MAX_CRITICAL_NOTIFICATIONS
#define SCU_EVENT_COUNT SCU_MAX_EVENTS
#define SCU_COMPLETION_QUEUE_SCRATCH SCU_MAX_COMPLETION_QUEUE_SCRATCH
#define SCU_IO_REQUEST_COUNT SCI_MAX_IO_REQUESTS
#define SCU_IO_REQUEST_SGE_COUNT SCI_MAX_SCATTER_GATHER_ELEMENTS
#define SCU_COMPLETION_QUEUE_COUNT SCU_MAX_COMPLETION_QUEUE_ENTRIES
#else
#define SCU_UNSOLICITED_FRAME_COUNT SCU_MIN_UNSOLICITED_FRAMES
#define SCU_CRITICAL_NOTIFICATION_COUNT SCU_MIN_CRITICAL_NOTIFICATIONS
#define SCU_EVENT_COUNT SCU_MIN_EVENTS
#define SCU_COMPLETION_QUEUE_SCRATCH SCU_MIN_COMPLETION_QUEUE_SCRATCH
#define SCU_IO_REQUEST_COUNT SCI_MIN_IO_REQUESTS
#define SCU_IO_REQUEST_SGE_COUNT SCI_MIN_SCATTER_GATHER_ELEMENTS
#define SCU_COMPLETION_QUEUE_COUNT SCU_MIN_COMPLETION_QUEUE_ENTRIES
#endif /* !defined(ENABLE_MINIMUM_MEMORY_OPERATION) */
/**
*
*
* The SCU_COMPLETION_QUEUE_COUNT constant indicates the size of the completion
* queue into which the hardware DMAs 32-bit quantas (completion entries).
*/
/**
*
*
* This queue must be programmed to a power of 2 size (e.g. 32, 64, 1024, etc.).
*/
#if (SCU_COMPLETION_QUEUE_COUNT != 16) && \
(SCU_COMPLETION_QUEUE_COUNT != 32) && \
(SCU_COMPLETION_QUEUE_COUNT != 64) && \
(SCU_COMPLETION_QUEUE_COUNT != 128) && \
(SCU_COMPLETION_QUEUE_COUNT != 256) && \
(SCU_COMPLETION_QUEUE_COUNT != 512) && \
(SCU_COMPLETION_QUEUE_COUNT != 1024)
#error "SCU_COMPLETION_QUEUE_COUNT must be set to a power of 2."
#endif
#if SCU_MIN_UNSOLICITED_FRAMES > SCU_MAX_UNSOLICITED_FRAMES
#error "Invalid configuration of unsolicited frame constants"
#endif /* SCU_MIN_UNSOLICITED_FRAMES > SCU_MAX_UNSOLICITED_FRAMES */
#define SCU_MIN_UF_TABLE_ENTRIES (8)
#define SCU_ABSOLUTE_MAX_UNSOLICITED_FRAMES (4096)
#define SCU_UNSOLICITED_FRAME_BUFFER_SIZE (1024)
#define SCU_INVALID_FRAME_INDEX (0xFFFF)
......@@ -173,14 +105,14 @@ enum sci_controller_mode {
#define SCU_IO_REQUEST_MAX_SGE_SIZE (0x00FFFFFF)
#define SCU_IO_REQUEST_MAX_TRANSFER_LENGTH (0x00FFFFFF)
/*
* Determine the size of the unsolicited frame array including
* unused buffers. */
#if SCU_UNSOLICITED_FRAME_COUNT <= SCU_MIN_UF_TABLE_ENTRIES
#define SCU_UNSOLICITED_FRAME_CONTROL_ARRAY_SIZE SCU_MIN_UF_TABLE_ENTRIES
#else
#define SCU_UNSOLICITED_FRAME_CONTROL_ARRAY_SIZE SCU_MAX_UNSOLICITED_FRAMES
#endif /* SCU_UNSOLICITED_FRAME_COUNT <= SCU_MIN_UF_TABLE_ENTRIES */
static inline void check_sizes(void)
{
BUILD_BUG_ON_NOT_POWER_OF_2(SCU_MAX_EVENTS);
BUILD_BUG_ON(SCU_MAX_UNSOLICITED_FRAMES <= 8);
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);
}
/**
* enum sci_status - This is the general return status enumeration for non-IO,
......
......@@ -213,7 +213,7 @@ struct scic_sds_request {
struct scu_task_context tc ____cacheline_aligned;
/* could be larger with sg chaining */
#define SCU_SGL_SIZE ((SCU_IO_REQUEST_SGE_COUNT + 1) / 2)
#define SCU_SGL_SIZE ((SCI_MAX_SCATTER_GATHER_ELEMENTS + 1) / 2)
struct scu_sgl_element_pair sg_table[SCU_SGL_SIZE] __attribute__ ((aligned(32)));
/*
......
......@@ -57,120 +57,30 @@
#include "unsolicited_frame_control.h"
#include "registers.h"
/**
* This method will program the unsolicited frames (UFs) into the UF address
* table and construct the UF frame structure being modeled in the core. It
* will handle the case where some of the UFs are not being used and thus
* should have entries programmed to zero in the address table.
* @uf_control: This parameter specifies the unsolicted frame control object
* for which to construct the unsolicited frames objects.
* @uf_buffer_phys_address: This parameter specifies the physical address for
* the first unsolicited frame buffer.
* @uf_buffer_virt_address: This parameter specifies the virtual address for
* the first unsolicited frame buffer.
* @unused_uf_header_entries: This parameter specifies the number of unused UF
* headers. This value can be non-zero when there are a non-power of 2
* number of unsolicited frames being supported.
* @used_uf_header_entries: This parameter specifies the number of actually
* utilized UF headers.
*
*/
static void scic_sds_unsolicited_frame_control_construct_frames(
struct scic_sds_unsolicited_frame_control *uf_control,
dma_addr_t uf_buffer_phys_address,
void *uf_buffer_virt_address,
u32 unused_uf_header_entries,
u32 used_uf_header_entries)
{
u32 index;
struct scic_sds_unsolicited_frame *uf;
/*
* Program the unused buffers into the UF address table and the
* controller's array of UFs.
*/
for (index = 0; index < unused_uf_header_entries; index++) {
uf = &uf_control->buffers.array[index];
uf->buffer = NULL;
uf_control->address_table.array[index] = 0;
uf->header = &uf_control->headers.array[index];
uf->state = UNSOLICITED_FRAME_EMPTY;
}
/*
* Program the actual used UF buffers into the UF address table and
* the controller's array of UFs.
*/
for (index = unused_uf_header_entries;
index < unused_uf_header_entries + used_uf_header_entries;
index++) {
uf = &uf_control->buffers.array[index];
uf_control->address_table.array[index] = uf_buffer_phys_address;
uf->buffer = uf_buffer_virt_address;
uf->header = &uf_control->headers.array[index];
uf->state = UNSOLICITED_FRAME_EMPTY;
/*
* Increment the address of the physical and virtual memory
* pointers. Everything is aligned on 1k boundary with an
* increment of 1k.
*/
uf_buffer_virt_address += SCU_UNSOLICITED_FRAME_BUFFER_SIZE;
uf_buffer_phys_address += SCU_UNSOLICITED_FRAME_BUFFER_SIZE;
}
}
int scic_sds_unsolicited_frame_control_construct(struct scic_sds_controller *scic)
{
struct scic_sds_unsolicited_frame_control *uf_control = &scic->uf_control;
u32 unused_uf_header_entries;
u32 used_uf_header_entries;
u32 used_uf_buffer_bytes;
u32 unused_uf_header_bytes;
u32 used_uf_header_bytes;
dma_addr_t uf_buffer_phys_address;
void *uf_buffer_virt_address;
struct scic_sds_unsolicited_frame *uf;
u32 buf_len, header_len, i;
dma_addr_t dma;
size_t size;
/*
* The UF buffer address table size must be programmed to a power
* of 2. Find the first power of 2 that is equal to or greater then
* the number of unsolicited frame buffers to be utilized.
*/
uf_control->address_table.count = SCU_MIN_UF_TABLE_ENTRIES;
while (uf_control->address_table.count < uf_control->buffers.count &&
uf_control->address_table.count < SCU_ABSOLUTE_MAX_UNSOLICITED_FRAMES)
uf_control->address_table.count <<= 1;
void *virt;
/*
* Prepare all of the memory sizes for the UF headers, UF address
* table, and UF buffers themselves.
*/
used_uf_buffer_bytes = uf_control->buffers.count
* SCU_UNSOLICITED_FRAME_BUFFER_SIZE;
unused_uf_header_entries = uf_control->address_table.count
- uf_control->buffers.count;
used_uf_header_entries = uf_control->buffers.count;
unused_uf_header_bytes = unused_uf_header_entries
* sizeof(struct scu_unsolicited_frame_header);
used_uf_header_bytes = used_uf_header_entries
* sizeof(struct scu_unsolicited_frame_header);
size = used_uf_buffer_bytes + used_uf_header_bytes +
uf_control->address_table.count * sizeof(dma_addr_t);
buf_len = SCU_MAX_UNSOLICITED_FRAMES * SCU_UNSOLICITED_FRAME_BUFFER_SIZE;
header_len = SCU_MAX_UNSOLICITED_FRAMES * sizeof(struct scu_unsolicited_frame_header);
size = buf_len + header_len + SCU_MAX_UNSOLICITED_FRAMES * sizeof(dma_addr_t);
/*
* The Unsolicited Frame buffers are set at the start of the UF
* memory descriptor entry. The headers and address table will be
* placed after the buffers.
*/
uf_buffer_virt_address = dmam_alloc_coherent(scic_to_dev(scic), size,
&uf_buffer_phys_address, GFP_KERNEL);
if (!uf_buffer_virt_address)
virt = dmam_alloc_coherent(scic_to_dev(scic), size, &dma, GFP_KERNEL);
if (!virt)
return -ENOMEM;
/*
......@@ -183,15 +93,8 @@ int scic_sds_unsolicited_frame_control_construct(struct scic_sds_controller *sci
* headers, since we program the UF address table pointers to
* NULL.
*/
uf_control->headers.physical_address =
uf_buffer_phys_address +
used_uf_buffer_bytes -
unused_uf_header_bytes;
uf_control->headers.array =
uf_buffer_virt_address +
used_uf_buffer_bytes -
unused_uf_header_bytes;
uf_control->headers.physical_address = dma + buf_len;
uf_control->headers.array = virt + buf_len;
/*
* Program the location of the UF address table into the SCU.
......@@ -200,16 +103,8 @@ int scic_sds_unsolicited_frame_control_construct(struct scic_sds_controller *sci
* byte boundary already due to above programming headers being on a
* 64-bit boundary and headers are on a 64-bytes in size.
*/
uf_control->address_table.physical_address =
uf_buffer_phys_address +
used_uf_buffer_bytes +
used_uf_header_bytes;
uf_control->address_table.array =
uf_buffer_virt_address +
used_uf_buffer_bytes +
used_uf_header_bytes;
uf_control->address_table.physical_address = dma + buf_len + header_len;
uf_control->address_table.array = virt + buf_len + header_len;
uf_control->get = 0;
/*
......@@ -220,16 +115,26 @@ int scic_sds_unsolicited_frame_control_construct(struct scic_sds_controller *sci
* - Aligned on a 1KB boundary. */
/*
* If the user provided less then the maximum amount of memory,
* then be sure that we programm the first entries in the UF
* address table to NULL. */
scic_sds_unsolicited_frame_control_construct_frames(
uf_control,
uf_buffer_phys_address,
uf_buffer_virt_address,
unused_uf_header_entries,
used_uf_header_entries
);
* Program the actual used UF buffers into the UF address table and
* the controller's array of UFs.
*/
for (i = 0; i < SCU_MAX_UNSOLICITED_FRAMES; i++) {
uf = &uf_control->buffers.array[i];
uf_control->address_table.array[i] = dma;
uf->buffer = virt;
uf->header = &uf_control->headers.array[i];
uf->state = UNSOLICITED_FRAME_EMPTY;
/*
* Increment the address of the physical and virtual memory
* pointers. Everything is aligned on 1k boundary with an
* increment of 1k.
*/
virt += SCU_UNSOLICITED_FRAME_BUFFER_SIZE;
dma += SCU_UNSOLICITED_FRAME_BUFFER_SIZE;
}
return 0;
}
......@@ -247,7 +152,7 @@ enum sci_status scic_sds_unsolicited_frame_control_get_header(
u32 frame_index,
void **frame_header)
{
if (frame_index < uf_control->address_table.count) {
if (frame_index < SCU_MAX_UNSOLICITED_FRAMES) {
/*
* Skip the first word in the frame since this is a controll word used
* by the hardware. */
......@@ -272,7 +177,7 @@ enum sci_status scic_sds_unsolicited_frame_control_get_buffer(
u32 frame_index,
void **frame_buffer)
{
if (frame_index < uf_control->address_table.count) {
if (frame_index < SCU_MAX_UNSOLICITED_FRAMES) {
*frame_buffer = uf_control->buffers.array[frame_index].buffer;
return SCI_SUCCESS;
......@@ -298,26 +203,24 @@ bool scic_sds_unsolicited_frame_control_release_frame(
u32 frame_get;
u32 frame_cycle;
frame_get = uf_control->get & (uf_control->address_table.count - 1);
frame_cycle = uf_control->get & uf_control->address_table.count;
frame_get = uf_control->get & (SCU_MAX_UNSOLICITED_FRAMES - 1);
frame_cycle = uf_control->get & SCU_MAX_UNSOLICITED_FRAMES;
/*
* In the event there are NULL entries in the UF table, we need to
* advance the get pointer in order to find out if this frame should
* be released (i.e. update the get pointer). */
while (((lower_32_bits(uf_control->address_table.array[frame_get])
== 0) &&
(upper_32_bits(uf_control->address_table.array[frame_get])
== 0)) &&
(frame_get < uf_control->address_table.count))
while (lower_32_bits(uf_control->address_table.array[frame_get]) == 0 &&
upper_32_bits(uf_control->address_table.array[frame_get]) == 0 &&
frame_get < SCU_MAX_UNSOLICITED_FRAMES)
frame_get++;
/*
* The table has a NULL entry as it's last element. This is
* illegal. */
BUG_ON(frame_get >= uf_control->address_table.count);
BUG_ON(frame_get >= SCU_MAX_UNSOLICITED_FRAMES);
if (frame_index < uf_control->address_table.count) {
if (frame_index < SCU_MAX_UNSOLICITED_FRAMES) {
uf_control->buffers.array[frame_index].state = UNSOLICITED_FRAME_RELEASED;
/*
......@@ -333,9 +236,8 @@ bool scic_sds_unsolicited_frame_control_release_frame(
INCREMENT_QUEUE_GET(
frame_get,
frame_cycle,
uf_control->address_table.count - 1,
uf_control->address_table.count
);
SCU_MAX_UNSOLICITED_FRAMES - 1,
SCU_MAX_UNSOLICITED_FRAMES);
}
uf_control->get =
......
......@@ -144,25 +144,18 @@ struct scic_sds_uf_header_array {
*/
struct scic_sds_uf_buffer_array {
/**
* This field is the minimum number of unsolicited frames supported by the
* hardware and the number of unsolicited frames requested by the software.
*/
u32 count;
/**
* This field is the SCIC_UNSOLICITED_FRAME data its used to manage
* This field is the unsolicited frame data its used to manage
* the data for the unsolicited frame requests. It also represents
* the virtual address location that corresponds to the
* physical_address field.
*/
struct scic_sds_unsolicited_frame array[SCU_UNSOLICITED_FRAME_CONTROL_ARRAY_SIZE];
struct scic_sds_unsolicited_frame array[SCU_MAX_UNSOLICITED_FRAMES];
/**
* This field specifies the physical address location for the UF
* buffer array.
*/
dma_addr_t physical_address;
};
/**
......@@ -173,15 +166,6 @@ struct scic_sds_uf_buffer_array {
* 1KB buffers into which the silicon will DMA unsolicited frames.
*/
struct scic_sds_uf_address_table_array {
/**
* This field specifies the actual programmed size of the
* unsolicited frame buffer address table. The size of the table
* can be larger than the actual number of UF buffers, but it must
* be a power of 2 and the last entry in the table is not allowed
* to be NULL.
*/
u32 count;
/**
* This field represents a virtual pointer that refers to the
* starting address of the UF address table.
......
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