Skip to content

Commit

Permalink
isci: Removed special macros that does 64bit address math
Browse files Browse the repository at this point in the history
These macros are not necessary. We can do 64bit math directly.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
  • Loading branch information
Dave Jiang authored and Dan Williams committed Jul 3, 2011
1 parent b382429 commit f7885c8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 73 deletions.
39 changes: 0 additions & 39 deletions drivers/scsi/isci/core/sci_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,45 +85,6 @@
#define sci_cb_make_physical_address(physical_addr, addr_upper, addr_lower) \
((physical_addr) = (addr_lower) | ((u64)addr_upper) << 32)


/**
* sci_physical_address_add() -
*
* This macro simply performs addition on an dma_addr_t type. The
* lower u32 value is "clipped" or "wrapped" back through 0. When this occurs
* the upper 32-bits are incremented by 1.
*/
#define sci_physical_address_add(physical_address, value) \
{ \
u32 lower = lower_32_bits((physical_address)); \
u32 upper = upper_32_bits((physical_address)); \
\
if (lower + (value) < lower) \
upper += 1; \
\
lower += (value); \
sci_cb_make_physical_address(physical_address, upper, lower); \
}

/**
* sci_physical_address_subtract() -
*
* This macro simply performs subtraction on an dma_addr_t type. The
* lower u32 value is "clipped" or "wrapped" back through 0. When this occurs
* the upper 32-bits are decremented by 1.
*/
#define sci_physical_address_subtract(physical_address, value) \
{ \
u32 lower = lower_32_bits((physical_address)); \
u32 upper = upper_32_bits((physical_address)); \
\
if (lower - (value) > lower) \
upper -= 1; \
\
lower -= (value); \
sci_cb_make_physical_address(physical_address, upper, lower); \
}

/**
* scic_word_copy_with_swap() - Copy the data from source to destination and
* swap the bytes during the copy.
Expand Down
73 changes: 39 additions & 34 deletions drivers/scsi/isci/core/scic_sds_unsolicited_frame_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void scic_sds_unsolicited_frame_control_set_address_table_count(
static void scic_sds_unsolicited_frame_control_construct_frames(
struct scic_sds_unsolicited_frame_control *uf_control,
dma_addr_t uf_buffer_phys_address,
unsigned long uf_buffer_virt_address,
void *uf_buffer_virt_address,
u32 unused_uf_header_entries,
u32 used_uf_header_entries)
{
Expand All @@ -118,7 +118,8 @@ static void scic_sds_unsolicited_frame_control_construct_frames(

/*
* Program the unused buffers into the UF address table and the
* controller's array of UFs. */
* controller's array of UFs.
*/
for (index = 0; index < unused_uf_header_entries; index++) {
uf = &uf_control->buffers.array[index];

Expand All @@ -132,25 +133,26 @@ static void scic_sds_unsolicited_frame_control_construct_frames(

/*
* Program the actual used UF buffers into the UF address table and
* the controller's array of UFs. */
* 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 = (void *)uf_buffer_virt_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 */
* 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;
sci_physical_address_add(
uf_buffer_phys_address, SCU_UNSOLICITED_FRAME_BUFFER_SIZE
);
uf_buffer_phys_address += SCU_UNSOLICITED_FRAME_BUFFER_SIZE;
}
}

Expand All @@ -177,6 +179,7 @@ void scic_sds_unsolicited_frame_control_construct(
u32 unused_uf_header_bytes;
u32 used_uf_header_bytes;
dma_addr_t uf_buffer_phys_address;
void *uf_buffer_virt_address;

/*
* Prepare all of the memory sizes for the UF headers, UF address
Expand All @@ -193,9 +196,11 @@ void scic_sds_unsolicited_frame_control_construct(

/*
* 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. */
* memory descriptor entry. The headers and address table will be
* placed after the buffers.
*/
uf_buffer_phys_address = mde->physical_address;
uf_buffer_virt_address = mde->virtual_address;

/*
* Program the location of the UF header table into the SCU.
Expand All @@ -205,34 +210,34 @@ void scic_sds_unsolicited_frame_control_construct(
* - Program unused header entries to overlap with the last
* unsolicited frame. The silicon will never DMA to these unused
* headers, since we program the UF address table pointers to
* NULL. */
uf_control->headers.physical_address = uf_buffer_phys_address;
sci_physical_address_add(
uf_control->headers.physical_address, used_uf_buffer_bytes);
sci_physical_address_subtract(
uf_control->headers.physical_address, unused_uf_header_bytes);
uf_control->headers.array
= (struct scu_unsolicited_frame_header *)
scic_cb_get_virtual_address(
controller, uf_control->headers.physical_address
);
* 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;

/*
* Program the location of the UF address table into the SCU.
* Notes:
* - The address must align on a 64-bit boundary. Guaranteed to be on 64
* 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;
sci_physical_address_add(
uf_control->address_table.physical_address, used_uf_buffer_bytes);
sci_physical_address_add(
uf_control->address_table.physical_address, used_uf_header_bytes);
uf_control->address_table.array
= (dma_addr_t *)
scic_cb_get_virtual_address(
controller, uf_control->address_table.physical_address
);
* 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->get = 0;

Expand All @@ -250,7 +255,7 @@ void scic_sds_unsolicited_frame_control_construct(
scic_sds_unsolicited_frame_control_construct_frames(
uf_control,
uf_buffer_phys_address,
(unsigned long)mde->virtual_address,
mde->virtual_address,
unused_uf_header_entries,
used_uf_header_entries
);
Expand Down

0 comments on commit f7885c8

Please sign in to comment.