diff options
author | Ulf Hansson <ulf.hansson@linaro.org> | 2019-02-13 14:03:30 -0500 |
---|---|---|
committer | Ulf Hansson <ulf.hansson@linaro.org> | 2019-02-25 11:20:21 -0500 |
commit | eae343c290f78916b254972e85e0b419e55618f1 (patch) | |
tree | 06535e95538295dfe00d90ddae50adb8a371a728 /drivers/mmc | |
parent | 9d2d24302e615e984034d2f60a4da739de6bd637 (diff) |
mmc: core: Convert mmc_align_data_size() into an SDIO specific function
The only user of mmc_align_data_size() is sdio_align_size(), which is
called from SDIO func drivers to let them distinguish, how to optimally
allocate data buffers.
Let's move mmc_align_data_size() close to the SDIO code as to make it
static, rename it to _sdio_align_size() and simplify its definition, all
with the purpose of clarifying that this is SDIO specific.
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Diffstat (limited to 'drivers/mmc')
-rw-r--r-- | drivers/mmc/core/core.c | 27 | ||||
-rw-r--r-- | drivers/mmc/core/sdio_io.c | 29 | ||||
-rw-r--r-- | drivers/mmc/core/sdio_ops.h | 1 |
3 files changed, 21 insertions, 36 deletions
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 659eb32c0246..b45aaa904107 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c | |||
@@ -757,33 +757,6 @@ void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card) | |||
757 | } | 757 | } |
758 | EXPORT_SYMBOL(mmc_set_data_timeout); | 758 | EXPORT_SYMBOL(mmc_set_data_timeout); |
759 | 759 | ||
760 | /** | ||
761 | * mmc_align_data_size - pads a transfer size to a more optimal value | ||
762 | * @card: the MMC card associated with the data transfer | ||
763 | * @sz: original transfer size | ||
764 | * | ||
765 | * Pads the original data size with a number of extra bytes in | ||
766 | * order to avoid controller bugs and/or performance hits | ||
767 | * (e.g. some controllers revert to PIO for certain sizes). | ||
768 | * | ||
769 | * Returns the improved size, which might be unmodified. | ||
770 | * | ||
771 | * Note that this function is only relevant when issuing a | ||
772 | * single scatter gather entry. | ||
773 | */ | ||
774 | unsigned int mmc_align_data_size(struct mmc_card *card, unsigned int sz) | ||
775 | { | ||
776 | /* | ||
777 | * FIXME: We don't have a system for the controller to tell | ||
778 | * the core about its problems yet, so for now we just 32-bit | ||
779 | * align the size. | ||
780 | */ | ||
781 | sz = ((sz + 3) / 4) * 4; | ||
782 | |||
783 | return sz; | ||
784 | } | ||
785 | EXPORT_SYMBOL(mmc_align_data_size); | ||
786 | |||
787 | /* | 760 | /* |
788 | * Allow claiming an already claimed host if the context is the same or there is | 761 | * Allow claiming an already claimed host if the context is the same or there is |
789 | * no context but the task is the same. | 762 | * no context but the task is the same. |
diff --git a/drivers/mmc/core/sdio_io.c b/drivers/mmc/core/sdio_io.c index d40744bbafa9..3f67fbbe0d75 100644 --- a/drivers/mmc/core/sdio_io.c +++ b/drivers/mmc/core/sdio_io.c | |||
@@ -10,6 +10,7 @@ | |||
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <linux/export.h> | 12 | #include <linux/export.h> |
13 | #include <linux/kernel.h> | ||
13 | #include <linux/mmc/host.h> | 14 | #include <linux/mmc/host.h> |
14 | #include <linux/mmc/card.h> | 15 | #include <linux/mmc/card.h> |
15 | #include <linux/mmc/sdio.h> | 16 | #include <linux/mmc/sdio.h> |
@@ -203,6 +204,21 @@ static inline unsigned int sdio_max_byte_size(struct sdio_func *func) | |||
203 | return min(mval, 512u); /* maximum size for byte mode */ | 204 | return min(mval, 512u); /* maximum size for byte mode */ |
204 | } | 205 | } |
205 | 206 | ||
207 | /* | ||
208 | * This is legacy code, which needs to be re-worked some day. Basically we need | ||
209 | * to take into account the properties of the host, as to enable the SDIO func | ||
210 | * driver layer to allocate optimal buffers. | ||
211 | */ | ||
212 | static inline unsigned int _sdio_align_size(unsigned int sz) | ||
213 | { | ||
214 | /* | ||
215 | * FIXME: We don't have a system for the controller to tell | ||
216 | * the core about its problems yet, so for now we just 32-bit | ||
217 | * align the size. | ||
218 | */ | ||
219 | return ALIGN(sz, 4); | ||
220 | } | ||
221 | |||
206 | /** | 222 | /** |
207 | * sdio_align_size - pads a transfer size to a more optimal value | 223 | * sdio_align_size - pads a transfer size to a more optimal value |
208 | * @func: SDIO function | 224 | * @func: SDIO function |
@@ -230,7 +246,7 @@ unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz) | |||
230 | * wants to increase the size up to a point where it | 246 | * wants to increase the size up to a point where it |
231 | * might need more than one block. | 247 | * might need more than one block. |
232 | */ | 248 | */ |
233 | sz = mmc_align_data_size(func->card, sz); | 249 | sz = _sdio_align_size(sz); |
234 | 250 | ||
235 | /* | 251 | /* |
236 | * If we can still do this with just a byte transfer, then | 252 | * If we can still do this with just a byte transfer, then |
@@ -252,7 +268,7 @@ unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz) | |||
252 | */ | 268 | */ |
253 | blk_sz = ((sz + func->cur_blksize - 1) / | 269 | blk_sz = ((sz + func->cur_blksize - 1) / |
254 | func->cur_blksize) * func->cur_blksize; | 270 | func->cur_blksize) * func->cur_blksize; |
255 | blk_sz = mmc_align_data_size(func->card, blk_sz); | 271 | blk_sz = _sdio_align_size(blk_sz); |
256 | 272 | ||
257 | /* | 273 | /* |
258 | * This value is only good if it is still just | 274 | * This value is only good if it is still just |
@@ -265,8 +281,7 @@ unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz) | |||
265 | * We failed to do one request, but at least try to | 281 | * We failed to do one request, but at least try to |
266 | * pad the remainder properly. | 282 | * pad the remainder properly. |
267 | */ | 283 | */ |
268 | byte_sz = mmc_align_data_size(func->card, | 284 | byte_sz = _sdio_align_size(sz % func->cur_blksize); |
269 | sz % func->cur_blksize); | ||
270 | if (byte_sz <= sdio_max_byte_size(func)) { | 285 | if (byte_sz <= sdio_max_byte_size(func)) { |
271 | blk_sz = sz / func->cur_blksize; | 286 | blk_sz = sz / func->cur_blksize; |
272 | return blk_sz * func->cur_blksize + byte_sz; | 287 | return blk_sz * func->cur_blksize + byte_sz; |
@@ -276,16 +291,14 @@ unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz) | |||
276 | * We need multiple requests, so first check that the | 291 | * We need multiple requests, so first check that the |
277 | * controller can handle the chunk size; | 292 | * controller can handle the chunk size; |
278 | */ | 293 | */ |
279 | chunk_sz = mmc_align_data_size(func->card, | 294 | chunk_sz = _sdio_align_size(sdio_max_byte_size(func)); |
280 | sdio_max_byte_size(func)); | ||
281 | if (chunk_sz == sdio_max_byte_size(func)) { | 295 | if (chunk_sz == sdio_max_byte_size(func)) { |
282 | /* | 296 | /* |
283 | * Fix up the size of the remainder (if any) | 297 | * Fix up the size of the remainder (if any) |
284 | */ | 298 | */ |
285 | byte_sz = orig_sz % chunk_sz; | 299 | byte_sz = orig_sz % chunk_sz; |
286 | if (byte_sz) { | 300 | if (byte_sz) { |
287 | byte_sz = mmc_align_data_size(func->card, | 301 | byte_sz = _sdio_align_size(byte_sz); |
288 | byte_sz); | ||
289 | } | 302 | } |
290 | 303 | ||
291 | return (orig_sz / chunk_sz) * chunk_sz + byte_sz; | 304 | return (orig_sz / chunk_sz) * chunk_sz + byte_sz; |
diff --git a/drivers/mmc/core/sdio_ops.h b/drivers/mmc/core/sdio_ops.h index 96945cafbf0b..1f6d0447ea0f 100644 --- a/drivers/mmc/core/sdio_ops.h +++ b/drivers/mmc/core/sdio_ops.h | |||
@@ -25,7 +25,6 @@ int mmc_io_rw_direct(struct mmc_card *card, int write, unsigned fn, | |||
25 | int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn, | 25 | int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn, |
26 | unsigned addr, int incr_addr, u8 *buf, unsigned blocks, unsigned blksz); | 26 | unsigned addr, int incr_addr, u8 *buf, unsigned blocks, unsigned blksz); |
27 | int sdio_reset(struct mmc_host *host); | 27 | int sdio_reset(struct mmc_host *host); |
28 | unsigned int mmc_align_data_size(struct mmc_card *card, unsigned int sz); | ||
29 | void sdio_irq_work(struct work_struct *work); | 28 | void sdio_irq_work(struct work_struct *work); |
30 | 29 | ||
31 | static inline bool sdio_is_io_busy(u32 opcode, u32 arg) | 30 | static inline bool sdio_is_io_busy(u32 opcode, u32 arg) |