Skip to content

Commit b2bbf43

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/drzeus/mmc
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/drzeus/mmc: au1xmmc: raise segment size limit. mmc_block: use proper sg iterators mmc: properly iterate over sg list in debug check mmc_test: Revert "mmc_test: test oversized sg lists" sdhci: check correct return value sdhci: disable DMA for req, not completely sdhci: handle bug in JMB38x for sizes < 4 bytes
2 parents 561b35b + e491d23 commit b2bbf43

7 files changed

Lines changed: 40 additions & 95 deletions

File tree

‎drivers/mmc/card/block.c‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
213213
struct mmc_blk_data *md = mq->data;
214214
struct mmc_card *card = md->queue.card;
215215
struct mmc_blk_request brq;
216-
int ret = 1, sg_pos, data_size;
216+
int ret = 1, data_size, i;
217+
struct scatterlist *sg;
217218

218219
mmc_claim_host(card->host);
219220

@@ -267,18 +268,22 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
267268

268269
mmc_queue_bounce_pre(mq);
269270

271+
/*
272+
* Adjust the sg list so it is the same size as the
273+
* request.
274+
*/
270275
if (brq.data.blocks !=
271276
(req->nr_sectors >> (md->block_bits - 9))) {
272277
data_size = brq.data.blocks * brq.data.blksz;
273-
for (sg_pos = 0; sg_pos < brq.data.sg_len; sg_pos++) {
274-
data_size -= mq->sg[sg_pos].length;
278+
for_each_sg(brq.data.sg, sg, brq.data.sg_len, i) {
279+
data_size -= sg->length;
275280
if (data_size <= 0) {
276-
mq->sg[sg_pos].length += data_size;
277-
sg_pos++;
281+
sg->length += data_size;
282+
i++;
278283
break;
279284
}
280285
}
281-
brq.data.sg_len = sg_pos;
286+
brq.data.sg_len = i;
282287
}
283288

284289
mmc_wait_for_req(card->host, &brq.mrq);

‎drivers/mmc/card/mmc_test.c‎

Lines changed: 3 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -388,16 +388,14 @@ static int mmc_test_transfer(struct mmc_test_card *test,
388388
int ret, i;
389389
unsigned long flags;
390390

391-
BUG_ON(blocks * blksz > BUFFER_SIZE);
392-
393391
if (write) {
394392
for (i = 0;i < blocks * blksz;i++)
395393
test->scratch[i] = i;
396394
} else {
397-
memset(test->scratch, 0, blocks * blksz);
395+
memset(test->scratch, 0, BUFFER_SIZE);
398396
}
399397
local_irq_save(flags);
400-
sg_copy_from_buffer(sg, sg_len, test->scratch, blocks * blksz);
398+
sg_copy_from_buffer(sg, sg_len, test->scratch, BUFFER_SIZE);
401399
local_irq_restore(flags);
402400

403401
ret = mmc_test_set_blksize(test, blksz);
@@ -444,7 +442,7 @@ static int mmc_test_transfer(struct mmc_test_card *test,
444442
}
445443
} else {
446444
local_irq_save(flags);
447-
sg_copy_to_buffer(sg, sg_len, test->scratch, blocks * blksz);
445+
sg_copy_to_buffer(sg, sg_len, test->scratch, BUFFER_SIZE);
448446
local_irq_restore(flags);
449447
for (i = 0;i < blocks * blksz;i++) {
450448
if (test->scratch[i] != (u8)i)
@@ -805,69 +803,6 @@ static int mmc_test_multi_xfersize_read(struct mmc_test_card *test)
805803
return 0;
806804
}
807805

808-
static int mmc_test_bigsg_write(struct mmc_test_card *test)
809-
{
810-
int ret;
811-
unsigned int size;
812-
struct scatterlist sg;
813-
814-
if (test->card->host->max_blk_count == 1)
815-
return RESULT_UNSUP_HOST;
816-
817-
size = PAGE_SIZE * 2;
818-
size = min(size, test->card->host->max_req_size);
819-
size = min(size, test->card->host->max_seg_size);
820-
size = min(size, test->card->host->max_blk_count * 512);
821-
822-
memset(test->buffer, 0, BUFFER_SIZE);
823-
824-
if (size < 1024)
825-
return RESULT_UNSUP_HOST;
826-
827-
sg_init_table(&sg, 1);
828-
sg_init_one(&sg, test->buffer, BUFFER_SIZE);
829-
830-
ret = mmc_test_transfer(test, &sg, 1, 0, size/512, 512, 1);
831-
if (ret)
832-
return ret;
833-
834-
return 0;
835-
}
836-
837-
static int mmc_test_bigsg_read(struct mmc_test_card *test)
838-
{
839-
int ret, i;
840-
unsigned int size;
841-
struct scatterlist sg;
842-
843-
if (test->card->host->max_blk_count == 1)
844-
return RESULT_UNSUP_HOST;
845-
846-
size = PAGE_SIZE * 2;
847-
size = min(size, test->card->host->max_req_size);
848-
size = min(size, test->card->host->max_seg_size);
849-
size = min(size, test->card->host->max_blk_count * 512);
850-
851-
if (size < 1024)
852-
return RESULT_UNSUP_HOST;
853-
854-
memset(test->buffer, 0xCD, BUFFER_SIZE);
855-
856-
sg_init_table(&sg, 1);
857-
sg_init_one(&sg, test->buffer, BUFFER_SIZE);
858-
ret = mmc_test_transfer(test, &sg, 1, 0, size/512, 512, 0);
859-
if (ret)
860-
return ret;
861-
862-
/* mmc_test_transfer() doesn't check for read overflows */
863-
for (i = size;i < BUFFER_SIZE;i++) {
864-
if (test->buffer[i] != 0xCD)
865-
return RESULT_FAIL;
866-
}
867-
868-
return 0;
869-
}
870-
871806
#ifdef CONFIG_HIGHMEM
872807

873808
static int mmc_test_write_high(struct mmc_test_card *test)
@@ -1071,20 +1006,6 @@ static const struct mmc_test_case mmc_test_cases[] = {
10711006
.run = mmc_test_multi_xfersize_read,
10721007
},
10731008

1074-
{
1075-
.name = "Over-sized SG list write",
1076-
.prepare = mmc_test_prepare_write,
1077-
.run = mmc_test_bigsg_write,
1078-
.cleanup = mmc_test_cleanup,
1079-
},
1080-
1081-
{
1082-
.name = "Over-sized SG list read",
1083-
.prepare = mmc_test_prepare_read,
1084-
.run = mmc_test_bigsg_read,
1085-
.cleanup = mmc_test_cleanup,
1086-
},
1087-
10881009
#ifdef CONFIG_HIGHMEM
10891010

10901011
{

‎drivers/mmc/core/core.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
121121
{
122122
#ifdef CONFIG_MMC_DEBUG
123123
unsigned int i, sz;
124+
struct scatterlist *sg;
124125
#endif
125126

126127
pr_debug("%s: starting CMD%u arg %08x flags %08x\n",
@@ -156,8 +157,8 @@ mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
156157

157158
#ifdef CONFIG_MMC_DEBUG
158159
sz = 0;
159-
for (i = 0;i < mrq->data->sg_len;i++)
160-
sz += mrq->data->sg[i].length;
160+
for_each_sg(mrq->data->sg, sg, mrq->data->sg_len, i)
161+
sz += sg->length;
161162
BUG_ON(sz != mrq->data->blocks * mrq->data->blksz);
162163
#endif
163164

‎drivers/mmc/host/au1xmmc.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,13 @@
6161

6262
/* Hardware definitions */
6363
#define AU1XMMC_DESCRIPTOR_COUNT 1
64-
#define AU1XMMC_DESCRIPTOR_SIZE 2048
64+
65+
/* max DMA seg size: 64KB on Au1100, 4MB on Au1200 */
66+
#ifdef CONFIG_SOC_AU1100
67+
#define AU1XMMC_DESCRIPTOR_SIZE 0x0000ffff
68+
#else /* Au1200 */
69+
#define AU1XMMC_DESCRIPTOR_SIZE 0x003fffff
70+
#endif
6571

6672
#define AU1XMMC_OCR (MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_29_30 | \
6773
MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 | \

‎drivers/mmc/host/sdhci-pci.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ static int jmicron_probe(struct sdhci_pci_chip *chip)
143143
chip->quirks |= SDHCI_QUIRK_32BIT_DMA_ADDR |
144144
SDHCI_QUIRK_32BIT_DMA_SIZE |
145145
SDHCI_QUIRK_32BIT_ADMA_SIZE |
146-
SDHCI_QUIRK_RESET_AFTER_REQUEST;
146+
SDHCI_QUIRK_RESET_AFTER_REQUEST |
147+
SDHCI_QUIRK_BROKEN_SMALL_PIO;
147148
}
148149

149150
/*

‎drivers/mmc/host/sdhci.c‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,15 @@ static void sdhci_transfer_pio(struct sdhci_host *host)
278278
else
279279
mask = SDHCI_SPACE_AVAILABLE;
280280

281+
/*
282+
* Some controllers (JMicron JMB38x) mess up the buffer bits
283+
* for transfers < 4 bytes. As long as it is just one block,
284+
* we can ignore the bits.
285+
*/
286+
if ((host->quirks & SDHCI_QUIRK_BROKEN_SMALL_PIO) &&
287+
(host->data->blocks == 1))
288+
mask = ~0;
289+
281290
while (readl(host->ioaddr + SDHCI_PRESENT_STATE) & mask) {
282291
if (host->data->flags & MMC_DATA_READ)
283292
sdhci_read_block_pio(host);
@@ -439,7 +448,7 @@ static int sdhci_adma_table_pre(struct sdhci_host *host,
439448

440449
host->adma_addr = dma_map_single(mmc_dev(host->mmc),
441450
host->adma_desc, (128 * 2 + 1) * 4, DMA_TO_DEVICE);
442-
if (dma_mapping_error(mmc_dev(host->mmc), host->align_addr))
451+
if (dma_mapping_error(mmc_dev(host->mmc), host->adma_addr))
443452
goto unmap_entries;
444453
BUG_ON(host->adma_addr & 0x3);
445454

@@ -645,7 +654,7 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data)
645654
* us an invalid request.
646655
*/
647656
WARN_ON(1);
648-
host->flags &= ~SDHCI_USE_DMA;
657+
host->flags &= ~SDHCI_REQ_USE_DMA;
649658
} else {
650659
writel(host->adma_addr,
651660
host->ioaddr + SDHCI_ADMA_ADDRESS);
@@ -664,7 +673,7 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data)
664673
* us an invalid request.
665674
*/
666675
WARN_ON(1);
667-
host->flags &= ~SDHCI_USE_DMA;
676+
host->flags &= ~SDHCI_REQ_USE_DMA;
668677
} else {
669678
WARN_ON(sg_cnt != 1);
670679
writel(sg_dma_address(data->sg),

‎drivers/mmc/host/sdhci.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ struct sdhci_host {
206206
#define SDHCI_QUIRK_NO_SIMULT_VDD_AND_POWER (1<<11)
207207
/* Controller provides an incorrect timeout value for transfers */
208208
#define SDHCI_QUIRK_BROKEN_TIMEOUT_VAL (1<<12)
209+
/* Controller has an issue with buffer bits for small transfers */
210+
#define SDHCI_QUIRK_BROKEN_SMALL_PIO (1<<13)
209211

210212
int irq; /* Device IRQ */
211213
void __iomem * ioaddr; /* Mapped address */

0 commit comments

Comments
 (0)