Skip to content

Commit 031b814

Browse files
committed
Merge tag 'mmc-v4.14-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc
Pull MMC fixes from Ulf Hansson: "MMC core: - Fix driver strength selection when selecting hs400es - Delete bounce buffer handling: This change fixes a problem related to how bounce buffers are being allocated. However, instead of trying to fix that, let's just remove the mmc bounce buffer code altogether, as it has practically no use. MMC host: - meson-gx: A couple of fixes related to clock/phase/tuning - sdhci-xenon: Fix clock resource by adding an optional bus clock" * tag 'mmc-v4.14-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc: mmc: sdhci-xenon: Fix clock resource by adding an optional bus clock mmc: meson-gx: include tx phase in the tuning process mmc: meson-gx: fix rx phase reset mmc: meson-gx: make sure the clock is rounded down mmc: Delete bounce buffer handling mmc: core: add driver strength selection when selecting hs400es
2 parents 1c86f2e + bb16ea1 commit 031b814

File tree

11 files changed

+81
-162
lines changed

11 files changed

+81
-162
lines changed

Documentation/devicetree/bindings/mmc/marvell,xenon-sdhci.txt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ Required Properties:
1616

1717
- clocks:
1818
Array of clocks required for SDHC.
19-
Require at least input clock for Xenon IP core.
19+
Require at least input clock for Xenon IP core. For Armada AP806 and
20+
CP110, the AXI clock is also mandatory.
2021

2122
- clock-names:
2223
Array of names corresponding to clocks property.
2324
The input clock for Xenon IP core should be named as "core".
25+
The input clock for the AXI bus must be named as "axi".
2426

2527
- reg:
2628
* For "marvell,armada-3700-sdhci", two register areas.
@@ -106,8 +108,8 @@ Example:
106108
compatible = "marvell,armada-ap806-sdhci";
107109
reg = <0xaa0000 0x1000>;
108110
interrupts = <GIC_SPI 13 IRQ_TYPE_LEVEL_HIGH>
109-
clocks = <&emmc_clk>;
110-
clock-names = "core";
111+
clocks = <&emmc_clk>,<&axi_clk>;
112+
clock-names = "core", "axi";
111113
bus-width = <4>;
112114
marvell,xenon-phy-slow-mode;
113115
marvell,xenon-tun-count = <11>;
@@ -126,8 +128,8 @@ Example:
126128
interrupts = <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>
127129
vqmmc-supply = <&sd_vqmmc_regulator>;
128130
vmmc-supply = <&sd_vmmc_regulator>;
129-
clocks = <&sdclk>;
130-
clock-names = "core";
131+
clocks = <&sdclk>, <&axi_clk>;
132+
clock-names = "core", "axi";
131133
bus-width = <4>;
132134
marvell,xenon-tun-count = <9>;
133135
};

drivers/mmc/core/block.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,8 +1634,6 @@ static void mmc_blk_data_prep(struct mmc_queue *mq, struct mmc_queue_req *mqrq,
16341634
}
16351635

16361636
mqrq->areq.mrq = &brq->mrq;
1637-
1638-
mmc_queue_bounce_pre(mqrq);
16391637
}
16401638

16411639
static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq,
@@ -1829,7 +1827,6 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req)
18291827
brq = &mq_rq->brq;
18301828
old_req = mmc_queue_req_to_req(mq_rq);
18311829
type = rq_data_dir(old_req) == READ ? MMC_BLK_READ : MMC_BLK_WRITE;
1832-
mmc_queue_bounce_post(mq_rq);
18331830

18341831
switch (status) {
18351832
case MMC_BLK_SUCCESS:

drivers/mmc/core/mmc.c

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,6 +1286,23 @@ int mmc_hs400_to_hs200(struct mmc_card *card)
12861286
return err;
12871287
}
12881288

1289+
static void mmc_select_driver_type(struct mmc_card *card)
1290+
{
1291+
int card_drv_type, drive_strength, drv_type;
1292+
1293+
card_drv_type = card->ext_csd.raw_driver_strength |
1294+
mmc_driver_type_mask(0);
1295+
1296+
drive_strength = mmc_select_drive_strength(card,
1297+
card->ext_csd.hs200_max_dtr,
1298+
card_drv_type, &drv_type);
1299+
1300+
card->drive_strength = drive_strength;
1301+
1302+
if (drv_type)
1303+
mmc_set_driver_type(card->host, drv_type);
1304+
}
1305+
12891306
static int mmc_select_hs400es(struct mmc_card *card)
12901307
{
12911308
struct mmc_host *host = card->host;
@@ -1341,6 +1358,8 @@ static int mmc_select_hs400es(struct mmc_card *card)
13411358
goto out_err;
13421359
}
13431360

1361+
mmc_select_driver_type(card);
1362+
13441363
/* Switch card to HS400 */
13451364
val = EXT_CSD_TIMING_HS400 |
13461365
card->drive_strength << EXT_CSD_DRV_STR_SHIFT;
@@ -1374,23 +1393,6 @@ static int mmc_select_hs400es(struct mmc_card *card)
13741393
return err;
13751394
}
13761395

1377-
static void mmc_select_driver_type(struct mmc_card *card)
1378-
{
1379-
int card_drv_type, drive_strength, drv_type;
1380-
1381-
card_drv_type = card->ext_csd.raw_driver_strength |
1382-
mmc_driver_type_mask(0);
1383-
1384-
drive_strength = mmc_select_drive_strength(card,
1385-
card->ext_csd.hs200_max_dtr,
1386-
card_drv_type, &drv_type);
1387-
1388-
card->drive_strength = drive_strength;
1389-
1390-
if (drv_type)
1391-
mmc_set_driver_type(card->host, drv_type);
1392-
}
1393-
13941396
/*
13951397
* For device supporting HS200 mode, the following sequence
13961398
* should be done before executing the tuning process.

drivers/mmc/core/queue.c

Lines changed: 9 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
#include "core.h"
2424
#include "card.h"
2525

26-
#define MMC_QUEUE_BOUNCESZ 65536
27-
2826
/*
2927
* Prepare a MMC request. This just filters out odd stuff.
3028
*/
@@ -150,26 +148,6 @@ static void mmc_queue_setup_discard(struct request_queue *q,
150148
queue_flag_set_unlocked(QUEUE_FLAG_SECERASE, q);
151149
}
152150

153-
static unsigned int mmc_queue_calc_bouncesz(struct mmc_host *host)
154-
{
155-
unsigned int bouncesz = MMC_QUEUE_BOUNCESZ;
156-
157-
if (host->max_segs != 1 || (host->caps & MMC_CAP_NO_BOUNCE_BUFF))
158-
return 0;
159-
160-
if (bouncesz > host->max_req_size)
161-
bouncesz = host->max_req_size;
162-
if (bouncesz > host->max_seg_size)
163-
bouncesz = host->max_seg_size;
164-
if (bouncesz > host->max_blk_count * 512)
165-
bouncesz = host->max_blk_count * 512;
166-
167-
if (bouncesz <= 512)
168-
return 0;
169-
170-
return bouncesz;
171-
}
172-
173151
/**
174152
* mmc_init_request() - initialize the MMC-specific per-request data
175153
* @q: the request queue
@@ -184,26 +162,9 @@ static int mmc_init_request(struct request_queue *q, struct request *req,
184162
struct mmc_card *card = mq->card;
185163
struct mmc_host *host = card->host;
186164

187-
if (card->bouncesz) {
188-
mq_rq->bounce_buf = kmalloc(card->bouncesz, gfp);
189-
if (!mq_rq->bounce_buf)
190-
return -ENOMEM;
191-
if (card->bouncesz > 512) {
192-
mq_rq->sg = mmc_alloc_sg(1, gfp);
193-
if (!mq_rq->sg)
194-
return -ENOMEM;
195-
mq_rq->bounce_sg = mmc_alloc_sg(card->bouncesz / 512,
196-
gfp);
197-
if (!mq_rq->bounce_sg)
198-
return -ENOMEM;
199-
}
200-
} else {
201-
mq_rq->bounce_buf = NULL;
202-
mq_rq->bounce_sg = NULL;
203-
mq_rq->sg = mmc_alloc_sg(host->max_segs, gfp);
204-
if (!mq_rq->sg)
205-
return -ENOMEM;
206-
}
165+
mq_rq->sg = mmc_alloc_sg(host->max_segs, gfp);
166+
if (!mq_rq->sg)
167+
return -ENOMEM;
207168

208169
return 0;
209170
}
@@ -212,13 +173,6 @@ static void mmc_exit_request(struct request_queue *q, struct request *req)
212173
{
213174
struct mmc_queue_req *mq_rq = req_to_mmc_queue_req(req);
214175

215-
/* It is OK to kfree(NULL) so this will be smooth */
216-
kfree(mq_rq->bounce_sg);
217-
mq_rq->bounce_sg = NULL;
218-
219-
kfree(mq_rq->bounce_buf);
220-
mq_rq->bounce_buf = NULL;
221-
222176
kfree(mq_rq->sg);
223177
mq_rq->sg = NULL;
224178
}
@@ -242,12 +196,6 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card,
242196
if (mmc_dev(host)->dma_mask && *mmc_dev(host)->dma_mask)
243197
limit = (u64)dma_max_pfn(mmc_dev(host)) << PAGE_SHIFT;
244198

245-
/*
246-
* mmc_init_request() depends on card->bouncesz so it must be calculated
247-
* before blk_init_allocated_queue() starts allocating requests.
248-
*/
249-
card->bouncesz = mmc_queue_calc_bouncesz(host);
250-
251199
mq->card = card;
252200
mq->queue = blk_alloc_queue(GFP_KERNEL);
253201
if (!mq->queue)
@@ -271,17 +219,11 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card,
271219
if (mmc_can_erase(card))
272220
mmc_queue_setup_discard(mq->queue, card);
273221

274-
if (card->bouncesz) {
275-
blk_queue_max_hw_sectors(mq->queue, card->bouncesz / 512);
276-
blk_queue_max_segments(mq->queue, card->bouncesz / 512);
277-
blk_queue_max_segment_size(mq->queue, card->bouncesz);
278-
} else {
279-
blk_queue_bounce_limit(mq->queue, limit);
280-
blk_queue_max_hw_sectors(mq->queue,
281-
min(host->max_blk_count, host->max_req_size / 512));
282-
blk_queue_max_segments(mq->queue, host->max_segs);
283-
blk_queue_max_segment_size(mq->queue, host->max_seg_size);
284-
}
222+
blk_queue_bounce_limit(mq->queue, limit);
223+
blk_queue_max_hw_sectors(mq->queue,
224+
min(host->max_blk_count, host->max_req_size / 512));
225+
blk_queue_max_segments(mq->queue, host->max_segs);
226+
blk_queue_max_segment_size(mq->queue, host->max_seg_size);
285227

286228
sema_init(&mq->thread_sem, 1);
287229

@@ -370,56 +312,7 @@ void mmc_queue_resume(struct mmc_queue *mq)
370312
*/
371313
unsigned int mmc_queue_map_sg(struct mmc_queue *mq, struct mmc_queue_req *mqrq)
372314
{
373-
unsigned int sg_len;
374-
size_t buflen;
375-
struct scatterlist *sg;
376315
struct request *req = mmc_queue_req_to_req(mqrq);
377-
int i;
378-
379-
if (!mqrq->bounce_buf)
380-
return blk_rq_map_sg(mq->queue, req, mqrq->sg);
381-
382-
sg_len = blk_rq_map_sg(mq->queue, req, mqrq->bounce_sg);
383-
384-
mqrq->bounce_sg_len = sg_len;
385-
386-
buflen = 0;
387-
for_each_sg(mqrq->bounce_sg, sg, sg_len, i)
388-
buflen += sg->length;
389-
390-
sg_init_one(mqrq->sg, mqrq->bounce_buf, buflen);
391-
392-
return 1;
393-
}
394-
395-
/*
396-
* If writing, bounce the data to the buffer before the request
397-
* is sent to the host driver
398-
*/
399-
void mmc_queue_bounce_pre(struct mmc_queue_req *mqrq)
400-
{
401-
if (!mqrq->bounce_buf)
402-
return;
403-
404-
if (rq_data_dir(mmc_queue_req_to_req(mqrq)) != WRITE)
405-
return;
406-
407-
sg_copy_to_buffer(mqrq->bounce_sg, mqrq->bounce_sg_len,
408-
mqrq->bounce_buf, mqrq->sg[0].length);
409-
}
410-
411-
/*
412-
* If reading, bounce the data from the buffer after the request
413-
* has been handled by the host driver
414-
*/
415-
void mmc_queue_bounce_post(struct mmc_queue_req *mqrq)
416-
{
417-
if (!mqrq->bounce_buf)
418-
return;
419-
420-
if (rq_data_dir(mmc_queue_req_to_req(mqrq)) != READ)
421-
return;
422316

423-
sg_copy_from_buffer(mqrq->bounce_sg, mqrq->bounce_sg_len,
424-
mqrq->bounce_buf, mqrq->sg[0].length);
317+
return blk_rq_map_sg(mq->queue, req, mqrq->sg);
425318
}

drivers/mmc/core/queue.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ enum mmc_drv_op {
4949
struct mmc_queue_req {
5050
struct mmc_blk_request brq;
5151
struct scatterlist *sg;
52-
char *bounce_buf;
53-
struct scatterlist *bounce_sg;
54-
unsigned int bounce_sg_len;
5552
struct mmc_async_req areq;
5653
enum mmc_drv_op drv_op;
5754
int drv_op_result;
@@ -81,11 +78,8 @@ extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *,
8178
extern void mmc_cleanup_queue(struct mmc_queue *);
8279
extern void mmc_queue_suspend(struct mmc_queue *);
8380
extern void mmc_queue_resume(struct mmc_queue *);
84-
8581
extern unsigned int mmc_queue_map_sg(struct mmc_queue *,
8682
struct mmc_queue_req *);
87-
extern void mmc_queue_bounce_pre(struct mmc_queue_req *);
88-
extern void mmc_queue_bounce_post(struct mmc_queue_req *);
8983

9084
extern int mmc_access_rpmb(struct mmc_queue *);
9185

drivers/mmc/host/cavium.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,7 @@ int cvm_mmc_of_slot_probe(struct device *dev, struct cvm_mmc_host *host)
10381038
*/
10391039
mmc->caps |= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED |
10401040
MMC_CAP_ERASE | MMC_CAP_CMD23 | MMC_CAP_POWER_OFF_CARD |
1041-
MMC_CAP_3_3V_DDR | MMC_CAP_NO_BOUNCE_BUFF;
1041+
MMC_CAP_3_3V_DDR;
10421042

10431043
if (host->use_sg)
10441044
mmc->max_segs = 16;

drivers/mmc/host/meson-gx-mmc.c

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -531,8 +531,7 @@ static int meson_mmc_clk_init(struct meson_host *host)
531531
div->shift = __ffs(CLK_DIV_MASK);
532532
div->width = __builtin_popcountl(CLK_DIV_MASK);
533533
div->hw.init = &init;
534-
div->flags = (CLK_DIVIDER_ONE_BASED |
535-
CLK_DIVIDER_ROUND_CLOSEST);
534+
div->flags = CLK_DIVIDER_ONE_BASED;
536535

537536
clk = devm_clk_register(host->dev, &div->hw);
538537
if (WARN_ON(IS_ERR(clk)))
@@ -717,6 +716,22 @@ static int meson_mmc_clk_phase_tuning(struct mmc_host *mmc, u32 opcode,
717716
static int meson_mmc_execute_tuning(struct mmc_host *mmc, u32 opcode)
718717
{
719718
struct meson_host *host = mmc_priv(mmc);
719+
int ret;
720+
721+
/*
722+
* If this is the initial tuning, try to get a sane Rx starting
723+
* phase before doing the actual tuning.
724+
*/
725+
if (!mmc->doing_retune) {
726+
ret = meson_mmc_clk_phase_tuning(mmc, opcode, host->rx_clk);
727+
728+
if (ret)
729+
return ret;
730+
}
731+
732+
ret = meson_mmc_clk_phase_tuning(mmc, opcode, host->tx_clk);
733+
if (ret)
734+
return ret;
720735

721736
return meson_mmc_clk_phase_tuning(mmc, opcode, host->rx_clk);
722737
}
@@ -746,6 +761,11 @@ static void meson_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
746761
case MMC_POWER_UP:
747762
if (!IS_ERR(mmc->supply.vmmc))
748763
mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, ios->vdd);
764+
765+
/* Reset phases */
766+
clk_set_phase(host->rx_clk, 0);
767+
clk_set_phase(host->tx_clk, 270);
768+
749769
break;
750770

751771
case MMC_POWER_ON:
@@ -759,8 +779,6 @@ static void meson_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
759779
host->vqmmc_enabled = true;
760780
}
761781

762-
/* Reset rx phase */
763-
clk_set_phase(host->rx_clk, 0);
764782
break;
765783
}
766784

drivers/mmc/host/pxamci.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -702,11 +702,7 @@ static int pxamci_probe(struct platform_device *pdev)
702702

703703
pxamci_init_ocr(host);
704704

705-
/*
706-
* This architecture used to disable bounce buffers through its
707-
* defconfig, now it is done at runtime as a host property.
708-
*/
709-
mmc->caps = MMC_CAP_NO_BOUNCE_BUFF;
705+
mmc->caps = 0;
710706
host->cmdat = 0;
711707
if (!cpu_is_pxa25x()) {
712708
mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ;

0 commit comments

Comments
 (0)