Skip to content

Commit a893858

Browse files
committed
Merge tag 'mmc-v6.10-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc
Pull MMC fixes from Ulf Hansson: - moxart-mmc: Revert "mmc: moxart-mmc: Use sg_miter for PIO" - sdhci: Do not invert write-protect twice - sdhci: Do not lock spinlock around mmc_gpio_get_ro() - sdhci-pci/sdhci-pci-o2micro: Return proper error codes - sdhci-brcmstb: Fix support for erase/trim/discard * tag 'mmc-v6.10-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc: mmc: sdhci: Do not lock spinlock around mmc_gpio_get_ro() mmc: sdhci: Do not invert write-protect twice Revert "mmc: moxart-mmc: Use sg_miter for PIO" mmc: sdhci-brcmstb: check R1_STATUS for erase/trim/discard mmc: sdhci-pci-o2micro: Convert PCIBIOS_* return codes to errnos mmc: sdhci-pci: Convert PCIBIOS_* return codes to errnos
2 parents de0a9f4 + ab069ce commit a893858

File tree

5 files changed

+90
-69
lines changed

5 files changed

+90
-69
lines changed

drivers/mmc/host/moxart-mmc.c

Lines changed: 43 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,12 @@ struct moxart_host {
131131
struct dma_async_tx_descriptor *tx_desc;
132132
struct mmc_host *mmc;
133133
struct mmc_request *mrq;
134+
struct scatterlist *cur_sg;
134135
struct completion dma_complete;
135136
struct completion pio_complete;
136137

137-
struct sg_mapping_iter sg_miter;
138+
u32 num_sg;
139+
u32 data_remain;
138140
u32 data_len;
139141
u32 fifo_width;
140142
u32 timeout;
@@ -146,6 +148,35 @@ struct moxart_host {
146148
bool is_removed;
147149
};
148150

151+
static inline void moxart_init_sg(struct moxart_host *host,
152+
struct mmc_data *data)
153+
{
154+
host->cur_sg = data->sg;
155+
host->num_sg = data->sg_len;
156+
host->data_remain = host->cur_sg->length;
157+
158+
if (host->data_remain > host->data_len)
159+
host->data_remain = host->data_len;
160+
}
161+
162+
static inline int moxart_next_sg(struct moxart_host *host)
163+
{
164+
int remain;
165+
struct mmc_data *data = host->mrq->cmd->data;
166+
167+
host->cur_sg++;
168+
host->num_sg--;
169+
170+
if (host->num_sg > 0) {
171+
host->data_remain = host->cur_sg->length;
172+
remain = host->data_len - data->bytes_xfered;
173+
if (remain > 0 && remain < host->data_remain)
174+
host->data_remain = remain;
175+
}
176+
177+
return host->num_sg;
178+
}
179+
149180
static int moxart_wait_for_status(struct moxart_host *host,
150181
u32 mask, u32 *status)
151182
{
@@ -278,29 +309,14 @@ static void moxart_transfer_dma(struct mmc_data *data, struct moxart_host *host)
278309

279310
static void moxart_transfer_pio(struct moxart_host *host)
280311
{
281-
struct sg_mapping_iter *sgm = &host->sg_miter;
282312
struct mmc_data *data = host->mrq->cmd->data;
283313
u32 *sgp, len = 0, remain, status;
284314

285315
if (host->data_len == data->bytes_xfered)
286316
return;
287317

288-
/*
289-
* By updating sgm->consumes this will get a proper pointer into the
290-
* buffer at any time.
291-
*/
292-
if (!sg_miter_next(sgm)) {
293-
/* This shold not happen */
294-
dev_err(mmc_dev(host->mmc), "ran out of scatterlist prematurely\n");
295-
data->error = -EINVAL;
296-
complete(&host->pio_complete);
297-
return;
298-
}
299-
sgp = sgm->addr;
300-
remain = sgm->length;
301-
if (remain > host->data_len)
302-
remain = host->data_len;
303-
sgm->consumed = 0;
318+
sgp = sg_virt(host->cur_sg);
319+
remain = host->data_remain;
304320

305321
if (data->flags & MMC_DATA_WRITE) {
306322
while (remain > 0) {
@@ -315,7 +331,6 @@ static void moxart_transfer_pio(struct moxart_host *host)
315331
sgp++;
316332
len += 4;
317333
}
318-
sgm->consumed += len;
319334
remain -= len;
320335
}
321336

@@ -332,22 +347,22 @@ static void moxart_transfer_pio(struct moxart_host *host)
332347
sgp++;
333348
len += 4;
334349
}
335-
sgm->consumed += len;
336350
remain -= len;
337351
}
338352
}
339353

340-
data->bytes_xfered += sgm->consumed;
341-
if (host->data_len == data->bytes_xfered) {
354+
data->bytes_xfered += host->data_remain - remain;
355+
host->data_remain = remain;
356+
357+
if (host->data_len != data->bytes_xfered)
358+
moxart_next_sg(host);
359+
else
342360
complete(&host->pio_complete);
343-
return;
344-
}
345361
}
346362

347363
static void moxart_prepare_data(struct moxart_host *host)
348364
{
349365
struct mmc_data *data = host->mrq->cmd->data;
350-
unsigned int flags = SG_MITER_ATOMIC; /* Used from IRQ */
351366
u32 datactrl;
352367
int blksz_bits;
353368

@@ -358,19 +373,15 @@ static void moxart_prepare_data(struct moxart_host *host)
358373
blksz_bits = ffs(data->blksz) - 1;
359374
BUG_ON(1 << blksz_bits != data->blksz);
360375

376+
moxart_init_sg(host, data);
377+
361378
datactrl = DCR_DATA_EN | (blksz_bits & DCR_BLK_SIZE);
362379

363-
if (data->flags & MMC_DATA_WRITE) {
364-
flags |= SG_MITER_FROM_SG;
380+
if (data->flags & MMC_DATA_WRITE)
365381
datactrl |= DCR_DATA_WRITE;
366-
} else {
367-
flags |= SG_MITER_TO_SG;
368-
}
369382

370383
if (moxart_use_dma(host))
371384
datactrl |= DCR_DMA_EN;
372-
else
373-
sg_miter_start(&host->sg_miter, data->sg, data->sg_len, flags);
374385

375386
writel(DCR_DATA_FIFO_RESET, host->base + REG_DATA_CONTROL);
376387
writel(MASK_DATA | FIFO_URUN | FIFO_ORUN, host->base + REG_CLEAR);
@@ -443,9 +454,6 @@ static void moxart_request(struct mmc_host *mmc, struct mmc_request *mrq)
443454
}
444455

445456
request_done:
446-
if (!moxart_use_dma(host))
447-
sg_miter_stop(&host->sg_miter);
448-
449457
spin_unlock_irqrestore(&host->lock, flags);
450458
mmc_request_done(host->mmc, mrq);
451459
}

drivers/mmc/host/sdhci-brcmstb.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#define BRCMSTB_MATCH_FLAGS_NO_64BIT BIT(0)
2525
#define BRCMSTB_MATCH_FLAGS_BROKEN_TIMEOUT BIT(1)
2626
#define BRCMSTB_MATCH_FLAGS_HAS_CLOCK_GATE BIT(2)
27+
#define BRCMSTB_MATCH_FLAGS_USE_CARD_BUSY BIT(4)
2728

2829
#define BRCMSTB_PRIV_FLAGS_HAS_CQE BIT(0)
2930
#define BRCMSTB_PRIV_FLAGS_GATE_CLOCK BIT(1)
@@ -384,6 +385,9 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
384385
if (match_priv->flags & BRCMSTB_MATCH_FLAGS_BROKEN_TIMEOUT)
385386
host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
386387

388+
if (!(match_priv->flags & BRCMSTB_MATCH_FLAGS_USE_CARD_BUSY))
389+
host->mmc_host_ops.card_busy = NULL;
390+
387391
/* Change the base clock frequency if the DT property exists */
388392
if (device_property_read_u32(&pdev->dev, "clock-frequency",
389393
&priv->base_freq_hz) != 0)

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,7 @@ static int jmicron_pmos(struct sdhci_pci_chip *chip, int on)
13261326

13271327
ret = pci_read_config_byte(chip->pdev, 0xAE, &scratch);
13281328
if (ret)
1329-
return ret;
1329+
goto fail;
13301330

13311331
/*
13321332
* Turn PMOS on [bit 0], set over current detection to 2.4 V
@@ -1337,7 +1337,10 @@ static int jmicron_pmos(struct sdhci_pci_chip *chip, int on)
13371337
else
13381338
scratch &= ~0x47;
13391339

1340-
return pci_write_config_byte(chip->pdev, 0xAE, scratch);
1340+
ret = pci_write_config_byte(chip->pdev, 0xAE, scratch);
1341+
1342+
fail:
1343+
return pcibios_err_to_errno(ret);
13411344
}
13421345

13431346
static int jmicron_probe(struct sdhci_pci_chip *chip)
@@ -2202,7 +2205,7 @@ static int sdhci_pci_probe(struct pci_dev *pdev,
22022205

22032206
ret = pci_read_config_byte(pdev, PCI_SLOT_INFO, &slots);
22042207
if (ret)
2205-
return ret;
2208+
return pcibios_err_to_errno(ret);
22062209

22072210
slots = PCI_SLOT_INFO_SLOTS(slots) + 1;
22082211
dev_dbg(&pdev->dev, "found %d slot(s)\n", slots);
@@ -2211,7 +2214,7 @@ static int sdhci_pci_probe(struct pci_dev *pdev,
22112214

22122215
ret = pci_read_config_byte(pdev, PCI_SLOT_INFO, &first_bar);
22132216
if (ret)
2214-
return ret;
2217+
return pcibios_err_to_errno(ret);
22152218

22162219
first_bar &= PCI_SLOT_INFO_FIRST_BAR_MASK;
22172220

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

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
823823
ret = pci_read_config_byte(chip->pdev,
824824
O2_SD_LOCK_WP, &scratch);
825825
if (ret)
826-
return ret;
826+
goto read_fail;
827827
scratch &= 0x7f;
828828
pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch);
829829

@@ -834,7 +834,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
834834
ret = pci_read_config_byte(chip->pdev,
835835
O2_SD_CLKREQ, &scratch);
836836
if (ret)
837-
return ret;
837+
goto read_fail;
838838
scratch |= 0x20;
839839
pci_write_config_byte(chip->pdev, O2_SD_CLKREQ, scratch);
840840

@@ -843,7 +843,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
843843
*/
844844
ret = pci_read_config_byte(chip->pdev, O2_SD_CAPS, &scratch);
845845
if (ret)
846-
return ret;
846+
goto read_fail;
847847
scratch |= 0x01;
848848
pci_write_config_byte(chip->pdev, O2_SD_CAPS, scratch);
849849
pci_write_config_byte(chip->pdev, O2_SD_CAPS, 0x73);
@@ -856,15 +856,15 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
856856
ret = pci_read_config_byte(chip->pdev,
857857
O2_SD_INF_MOD, &scratch);
858858
if (ret)
859-
return ret;
859+
goto read_fail;
860860
scratch |= 0x08;
861861
pci_write_config_byte(chip->pdev, O2_SD_INF_MOD, scratch);
862862

863863
/* Lock WP */
864864
ret = pci_read_config_byte(chip->pdev,
865865
O2_SD_LOCK_WP, &scratch);
866866
if (ret)
867-
return ret;
867+
goto read_fail;
868868
scratch |= 0x80;
869869
pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch);
870870
break;
@@ -875,7 +875,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
875875
ret = pci_read_config_byte(chip->pdev,
876876
O2_SD_LOCK_WP, &scratch);
877877
if (ret)
878-
return ret;
878+
goto read_fail;
879879

880880
scratch &= 0x7f;
881881
pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch);
@@ -886,7 +886,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
886886
O2_SD_FUNC_REG0,
887887
&scratch_32);
888888
if (ret)
889-
return ret;
889+
goto read_fail;
890890
scratch_32 = ((scratch_32 & 0xFF000000) >> 24);
891891

892892
/* Check Whether subId is 0x11 or 0x12 */
@@ -898,7 +898,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
898898
O2_SD_FUNC_REG4,
899899
&scratch_32);
900900
if (ret)
901-
return ret;
901+
goto read_fail;
902902

903903
/* Enable Base Clk setting change */
904904
scratch_32 |= O2_SD_FREG4_ENABLE_CLK_SET;
@@ -921,7 +921,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
921921
ret = pci_read_config_dword(chip->pdev,
922922
O2_SD_CLK_SETTING, &scratch_32);
923923
if (ret)
924-
return ret;
924+
goto read_fail;
925925

926926
scratch_32 &= ~(0xFF00);
927927
scratch_32 |= 0x07E0C800;
@@ -931,14 +931,14 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
931931
ret = pci_read_config_dword(chip->pdev,
932932
O2_SD_CLKREQ, &scratch_32);
933933
if (ret)
934-
return ret;
934+
goto read_fail;
935935
scratch_32 |= 0x3;
936936
pci_write_config_dword(chip->pdev, O2_SD_CLKREQ, scratch_32);
937937

938938
ret = pci_read_config_dword(chip->pdev,
939939
O2_SD_PLL_SETTING, &scratch_32);
940940
if (ret)
941-
return ret;
941+
goto read_fail;
942942

943943
scratch_32 &= ~(0x1F3F070E);
944944
scratch_32 |= 0x18270106;
@@ -949,7 +949,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
949949
ret = pci_read_config_dword(chip->pdev,
950950
O2_SD_CAP_REG2, &scratch_32);
951951
if (ret)
952-
return ret;
952+
goto read_fail;
953953
scratch_32 &= ~(0xE0);
954954
pci_write_config_dword(chip->pdev,
955955
O2_SD_CAP_REG2, scratch_32);
@@ -961,7 +961,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
961961
ret = pci_read_config_byte(chip->pdev,
962962
O2_SD_LOCK_WP, &scratch);
963963
if (ret)
964-
return ret;
964+
goto read_fail;
965965
scratch |= 0x80;
966966
pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch);
967967
break;
@@ -971,15 +971,15 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
971971
ret = pci_read_config_byte(chip->pdev,
972972
O2_SD_LOCK_WP, &scratch);
973973
if (ret)
974-
return ret;
974+
goto read_fail;
975975

976976
scratch &= 0x7f;
977977
pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch);
978978

979979
ret = pci_read_config_dword(chip->pdev,
980980
O2_SD_PLL_SETTING, &scratch_32);
981981
if (ret)
982-
return ret;
982+
goto read_fail;
983983

984984
if ((scratch_32 & 0xff000000) == 0x01000000) {
985985
scratch_32 &= 0x0000FFFF;
@@ -998,7 +998,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
998998
O2_SD_FUNC_REG4,
999999
&scratch_32);
10001000
if (ret)
1001-
return ret;
1001+
goto read_fail;
10021002
scratch_32 |= (1 << 22);
10031003
pci_write_config_dword(chip->pdev,
10041004
O2_SD_FUNC_REG4, scratch_32);
@@ -1017,7 +1017,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
10171017
ret = pci_read_config_byte(chip->pdev,
10181018
O2_SD_LOCK_WP, &scratch);
10191019
if (ret)
1020-
return ret;
1020+
goto read_fail;
10211021
scratch |= 0x80;
10221022
pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch);
10231023
break;
@@ -1028,7 +1028,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
10281028
/* UnLock WP */
10291029
ret = pci_read_config_byte(chip->pdev, O2_SD_LOCK_WP, &scratch);
10301030
if (ret)
1031-
return ret;
1031+
goto read_fail;
10321032
scratch &= 0x7f;
10331033
pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch);
10341034

@@ -1057,13 +1057,16 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
10571057
/* Lock WP */
10581058
ret = pci_read_config_byte(chip->pdev, O2_SD_LOCK_WP, &scratch);
10591059
if (ret)
1060-
return ret;
1060+
goto read_fail;
10611061
scratch |= 0x80;
10621062
pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch);
10631063
break;
10641064
}
10651065

10661066
return 0;
1067+
1068+
read_fail:
1069+
return pcibios_err_to_errno(ret);
10671070
}
10681071

10691072
#ifdef CONFIG_PM_SLEEP

0 commit comments

Comments
 (0)