diff options
author | Dave Jiang <dave.jiang@intel.com> | 2011-02-22 18:39:32 -0500 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2011-07-03 06:55:28 -0400 |
commit | f7885c8490717b010115d6413b339702c64d8a3b (patch) | |
tree | 281176f92d4bd8372205002c4feb48c44200c1c1 /drivers | |
parent | b3824292cb93d4e45b87fe76d8774cbde9e43200 (diff) |
isci: Removed special macros that does 64bit address math
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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/scsi/isci/core/sci_util.h | 39 | ||||
-rw-r--r-- | drivers/scsi/isci/core/scic_sds_unsolicited_frame_control.c | 73 |
2 files changed, 39 insertions, 73 deletions
diff --git a/drivers/scsi/isci/core/sci_util.h b/drivers/scsi/isci/core/sci_util.h index 8f2ba35d955f..9748c76df387 100644 --- a/drivers/scsi/isci/core/sci_util.h +++ b/drivers/scsi/isci/core/sci_util.h | |||
@@ -85,45 +85,6 @@ | |||
85 | #define sci_cb_make_physical_address(physical_addr, addr_upper, addr_lower) \ | 85 | #define sci_cb_make_physical_address(physical_addr, addr_upper, addr_lower) \ |
86 | ((physical_addr) = (addr_lower) | ((u64)addr_upper) << 32) | 86 | ((physical_addr) = (addr_lower) | ((u64)addr_upper) << 32) |
87 | 87 | ||
88 | |||
89 | /** | ||
90 | * sci_physical_address_add() - | ||
91 | * | ||
92 | * This macro simply performs addition on an dma_addr_t type. The | ||
93 | * lower u32 value is "clipped" or "wrapped" back through 0. When this occurs | ||
94 | * the upper 32-bits are incremented by 1. | ||
95 | */ | ||
96 | #define sci_physical_address_add(physical_address, value) \ | ||
97 | { \ | ||
98 | u32 lower = lower_32_bits((physical_address)); \ | ||
99 | u32 upper = upper_32_bits((physical_address)); \ | ||
100 | \ | ||
101 | if (lower + (value) < lower) \ | ||
102 | upper += 1; \ | ||
103 | \ | ||
104 | lower += (value); \ | ||
105 | sci_cb_make_physical_address(physical_address, upper, lower); \ | ||
106 | } | ||
107 | |||
108 | /** | ||
109 | * sci_physical_address_subtract() - | ||
110 | * | ||
111 | * This macro simply performs subtraction on an dma_addr_t type. The | ||
112 | * lower u32 value is "clipped" or "wrapped" back through 0. When this occurs | ||
113 | * the upper 32-bits are decremented by 1. | ||
114 | */ | ||
115 | #define sci_physical_address_subtract(physical_address, value) \ | ||
116 | { \ | ||
117 | u32 lower = lower_32_bits((physical_address)); \ | ||
118 | u32 upper = upper_32_bits((physical_address)); \ | ||
119 | \ | ||
120 | if (lower - (value) > lower) \ | ||
121 | upper -= 1; \ | ||
122 | \ | ||
123 | lower -= (value); \ | ||
124 | sci_cb_make_physical_address(physical_address, upper, lower); \ | ||
125 | } | ||
126 | |||
127 | /** | 88 | /** |
128 | * scic_word_copy_with_swap() - Copy the data from source to destination and | 89 | * scic_word_copy_with_swap() - Copy the data from source to destination and |
129 | * swap the bytes during the copy. | 90 | * swap the bytes during the copy. |
diff --git a/drivers/scsi/isci/core/scic_sds_unsolicited_frame_control.c b/drivers/scsi/isci/core/scic_sds_unsolicited_frame_control.c index 7ca2f1709f6d..7274812af507 100644 --- a/drivers/scsi/isci/core/scic_sds_unsolicited_frame_control.c +++ b/drivers/scsi/isci/core/scic_sds_unsolicited_frame_control.c | |||
@@ -109,7 +109,7 @@ void scic_sds_unsolicited_frame_control_set_address_table_count( | |||
109 | static void scic_sds_unsolicited_frame_control_construct_frames( | 109 | static void scic_sds_unsolicited_frame_control_construct_frames( |
110 | struct scic_sds_unsolicited_frame_control *uf_control, | 110 | struct scic_sds_unsolicited_frame_control *uf_control, |
111 | dma_addr_t uf_buffer_phys_address, | 111 | dma_addr_t uf_buffer_phys_address, |
112 | unsigned long uf_buffer_virt_address, | 112 | void *uf_buffer_virt_address, |
113 | u32 unused_uf_header_entries, | 113 | u32 unused_uf_header_entries, |
114 | u32 used_uf_header_entries) | 114 | u32 used_uf_header_entries) |
115 | { | 115 | { |
@@ -118,7 +118,8 @@ static void scic_sds_unsolicited_frame_control_construct_frames( | |||
118 | 118 | ||
119 | /* | 119 | /* |
120 | * Program the unused buffers into the UF address table and the | 120 | * Program the unused buffers into the UF address table and the |
121 | * controller's array of UFs. */ | 121 | * controller's array of UFs. |
122 | */ | ||
122 | for (index = 0; index < unused_uf_header_entries; index++) { | 123 | for (index = 0; index < unused_uf_header_entries; index++) { |
123 | uf = &uf_control->buffers.array[index]; | 124 | uf = &uf_control->buffers.array[index]; |
124 | 125 | ||
@@ -132,7 +133,8 @@ static void scic_sds_unsolicited_frame_control_construct_frames( | |||
132 | 133 | ||
133 | /* | 134 | /* |
134 | * Program the actual used UF buffers into the UF address table and | 135 | * Program the actual used UF buffers into the UF address table and |
135 | * the controller's array of UFs. */ | 136 | * the controller's array of UFs. |
137 | */ | ||
136 | for (index = unused_uf_header_entries; | 138 | for (index = unused_uf_header_entries; |
137 | index < unused_uf_header_entries + used_uf_header_entries; | 139 | index < unused_uf_header_entries + used_uf_header_entries; |
138 | index++) { | 140 | index++) { |
@@ -140,17 +142,17 @@ static void scic_sds_unsolicited_frame_control_construct_frames( | |||
140 | 142 | ||
141 | uf_control->address_table.array[index] = uf_buffer_phys_address; | 143 | uf_control->address_table.array[index] = uf_buffer_phys_address; |
142 | 144 | ||
143 | uf->buffer = (void *)uf_buffer_virt_address; | 145 | uf->buffer = uf_buffer_virt_address; |
144 | uf->header = &uf_control->headers.array[index]; | 146 | uf->header = &uf_control->headers.array[index]; |
145 | uf->state = UNSOLICITED_FRAME_EMPTY; | 147 | uf->state = UNSOLICITED_FRAME_EMPTY; |
146 | 148 | ||
147 | /* | 149 | /* |
148 | * Increment the address of the physical and virtual memory pointers | 150 | * Increment the address of the physical and virtual memory |
149 | * Everything is aligned on 1k boundary with an increment of 1k */ | 151 | * pointers. Everything is aligned on 1k boundary with an |
152 | * increment of 1k. | ||
153 | */ | ||
150 | uf_buffer_virt_address += SCU_UNSOLICITED_FRAME_BUFFER_SIZE; | 154 | uf_buffer_virt_address += SCU_UNSOLICITED_FRAME_BUFFER_SIZE; |
151 | sci_physical_address_add( | 155 | uf_buffer_phys_address += SCU_UNSOLICITED_FRAME_BUFFER_SIZE; |
152 | uf_buffer_phys_address, SCU_UNSOLICITED_FRAME_BUFFER_SIZE | ||
153 | ); | ||
154 | } | 156 | } |
155 | } | 157 | } |
156 | 158 | ||
@@ -177,6 +179,7 @@ void scic_sds_unsolicited_frame_control_construct( | |||
177 | u32 unused_uf_header_bytes; | 179 | u32 unused_uf_header_bytes; |
178 | u32 used_uf_header_bytes; | 180 | u32 used_uf_header_bytes; |
179 | dma_addr_t uf_buffer_phys_address; | 181 | dma_addr_t uf_buffer_phys_address; |
182 | void *uf_buffer_virt_address; | ||
180 | 183 | ||
181 | /* | 184 | /* |
182 | * Prepare all of the memory sizes for the UF headers, UF address | 185 | * Prepare all of the memory sizes for the UF headers, UF address |
@@ -193,9 +196,11 @@ void scic_sds_unsolicited_frame_control_construct( | |||
193 | 196 | ||
194 | /* | 197 | /* |
195 | * The Unsolicited Frame buffers are set at the start of the UF | 198 | * The Unsolicited Frame buffers are set at the start of the UF |
196 | * memory descriptor entry. The headers and address table will be | 199 | * memory descriptor entry. The headers and address table will be |
197 | * placed after the buffers. */ | 200 | * placed after the buffers. |
201 | */ | ||
198 | uf_buffer_phys_address = mde->physical_address; | 202 | uf_buffer_phys_address = mde->physical_address; |
203 | uf_buffer_virt_address = mde->virtual_address; | ||
199 | 204 | ||
200 | /* | 205 | /* |
201 | * Program the location of the UF header table into the SCU. | 206 | * Program the location of the UF header table into the SCU. |
@@ -205,34 +210,34 @@ void scic_sds_unsolicited_frame_control_construct( | |||
205 | * - Program unused header entries to overlap with the last | 210 | * - Program unused header entries to overlap with the last |
206 | * unsolicited frame. The silicon will never DMA to these unused | 211 | * unsolicited frame. The silicon will never DMA to these unused |
207 | * headers, since we program the UF address table pointers to | 212 | * headers, since we program the UF address table pointers to |
208 | * NULL. */ | 213 | * NULL. |
209 | uf_control->headers.physical_address = uf_buffer_phys_address; | 214 | */ |
210 | sci_physical_address_add( | 215 | uf_control->headers.physical_address = |
211 | uf_control->headers.physical_address, used_uf_buffer_bytes); | 216 | uf_buffer_phys_address + |
212 | sci_physical_address_subtract( | 217 | used_uf_buffer_bytes - |
213 | uf_control->headers.physical_address, unused_uf_header_bytes); | 218 | unused_uf_header_bytes; |
214 | uf_control->headers.array | 219 | |
215 | = (struct scu_unsolicited_frame_header *) | 220 | uf_control->headers.array = |
216 | scic_cb_get_virtual_address( | 221 | uf_buffer_virt_address + |
217 | controller, uf_control->headers.physical_address | 222 | used_uf_buffer_bytes - |
218 | ); | 223 | unused_uf_header_bytes; |
219 | 224 | ||
220 | /* | 225 | /* |
221 | * Program the location of the UF address table into the SCU. | 226 | * Program the location of the UF address table into the SCU. |
222 | * Notes: | 227 | * Notes: |
223 | * - The address must align on a 64-bit boundary. Guaranteed to be on 64 | 228 | * - The address must align on a 64-bit boundary. Guaranteed to be on 64 |
224 | * byte boundary already due to above programming headers being on a | 229 | * byte boundary already due to above programming headers being on a |
225 | * 64-bit boundary and headers are on a 64-bytes in size. */ | 230 | * 64-bit boundary and headers are on a 64-bytes in size. |
226 | uf_control->address_table.physical_address = uf_buffer_phys_address; | 231 | */ |
227 | sci_physical_address_add( | 232 | uf_control->address_table.physical_address = |
228 | uf_control->address_table.physical_address, used_uf_buffer_bytes); | 233 | uf_buffer_phys_address + |
229 | sci_physical_address_add( | 234 | used_uf_buffer_bytes + |
230 | uf_control->address_table.physical_address, used_uf_header_bytes); | 235 | used_uf_header_bytes; |
231 | uf_control->address_table.array | 236 | |
232 | = (dma_addr_t *) | 237 | uf_control->address_table.array = |
233 | scic_cb_get_virtual_address( | 238 | uf_buffer_virt_address + |
234 | controller, uf_control->address_table.physical_address | 239 | used_uf_buffer_bytes + |
235 | ); | 240 | used_uf_header_bytes; |
236 | 241 | ||
237 | uf_control->get = 0; | 242 | uf_control->get = 0; |
238 | 243 | ||
@@ -250,7 +255,7 @@ void scic_sds_unsolicited_frame_control_construct( | |||
250 | scic_sds_unsolicited_frame_control_construct_frames( | 255 | scic_sds_unsolicited_frame_control_construct_frames( |
251 | uf_control, | 256 | uf_control, |
252 | uf_buffer_phys_address, | 257 | uf_buffer_phys_address, |
253 | (unsigned long)mde->virtual_address, | 258 | mde->virtual_address, |
254 | unused_uf_header_entries, | 259 | unused_uf_header_entries, |
255 | used_uf_header_entries | 260 | used_uf_header_entries |
256 | ); | 261 | ); |