Skip to contentSkip to conversation

Add modules to support realtek PCIE card reader

PATCH Superseded [email protected] 1 participant 4 messages Aug 21, 2012 – Aug 23, 2012

Subsystems (2)

v3 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v3 cover Add modules to support realtek PCIE card reader

From: Wei WANG <[email protected]>

1. Fix a bug that DMA out of SW-IOMMU space in Lenovo Thinkpad x121e
2. Tested by Borislav Petkov <[email protected]>

Wei WANG (2):
drivers/mfd: Add realtek pcie card reader driver drivers/mmc: Add realtek pcie sdmmc host driver

 drivers/mfd/Kconfig               |    9 +
 drivers/mfd/Makefile              |    4 +
 drivers/mfd/rts5209.c             |  104 +++
 drivers/mfd/rts5229.c             |  119 ++++
 drivers/mfd/rtsx_pcr.c            | 1286 +++++++++++++++++++++++++++++++++++
 drivers/mfd/rtsx_pcr.h            |   31 +
 drivers/mmc/host/Kconfig          |    7 +
 drivers/mmc/host/Makefile         |    2 +
 drivers/mmc/host/rtsx_pci_sdmmc.c | 1341 +++++++++++++++++++++++++++++++++++++
 include/linux/mfd/rtsx_common.h   |   47 ++
 include/linux/mfd/rtsx_pci.h      |  690 +++++++++++++++++++
 11 files changed, 3640 insertions(+)
 create mode 100644 drivers/mfd/rts5209.c
 create mode 100644 drivers/mfd/rts5229.c
 create mode 100644 drivers/mfd/rtsx_pcr.c
 create mode 100644 drivers/mfd/rtsx_pcr.h
 create mode 100644 drivers/mmc/host/rtsx_pci_sdmmc.c
 create mode 100644 include/linux/mfd/rtsx_common.h
 create mode 100644 include/linux/mfd/rtsx_pci.h
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v3 1/2 drivers/mfd: Add realtek pcie card reader driver

From: Wei WANG <[email protected]>

Realtek PCI-E card reader driver adapts requests from upper-level sdmmc/memstick layer to the real physical card reader.

---
 drivers/mfd/Kconfig             |    9 +
 drivers/mfd/Makefile            |    4 +
 drivers/mfd/rts5209.c           |  104 ++++
 drivers/mfd/rts5229.c           |  119 ++++
 drivers/mfd/rtsx_pcr.c          | 1286 +++++++++++++++++++++++++++++++++++++++
 drivers/mfd/rtsx_pcr.h          |   31 +
 include/linux/mfd/rtsx_common.h |   47 ++
 include/linux/mfd/rtsx_pci.h    |  690 +++++++++++++++++++++
 8 files changed, 2290 insertions(+)
 create mode 100644 drivers/mfd/rts5209.c
 create mode 100644 drivers/mfd/rts5229.c
 create mode 100644 drivers/mfd/rtsx_pcr.c
 create mode 100644 drivers/mfd/rtsx_pcr.h
 create mode 100644 include/linux/mfd/rtsx_common.h
 create mode 100644 include/linux/mfd/rtsx_pci.h
drivers/mfd/Kconfig +9 -0
index d1facef..4c07a34 100644
@@ -63,6 +63,15 @@ config MFD_SM501_GPIO
 	 lines on the SM501. The platform data is used to supply the
 	 base number for the first GPIO line to register.
 
+config MFD_RTSX_PCI
+	tristate "Support for Realtek PCI-E driver-based card reader"
+	depends on PCI
+	help
+	  This supports for Realtek PCI-Express driver-based card reader including
+	  rts5209, rts5229, etc. Realtek driver-based card reader supports access
+	  to many types of memory cards, such as Memory Stick, Memory Stick Pro,
+	  Secure Digital and MultiMediaCard.
+
 config MFD_ASIC3
 	bool "Support for Compaq ASIC3"
 	depends on GENERIC_HARDIRQS && GPIOLIB && ARM
drivers/mfd/Makefile +4 -0
index 79dd22d..e8cdc7b 100644
@@ -9,6 +9,9 @@ obj-$(CONFIG_MFD_88PM805)	+= 88pm805.o 88pm80x.o
 obj-$(CONFIG_MFD_SM501)		+= sm501.o
 obj-$(CONFIG_MFD_ASIC3)		+= asic3.o tmio_core.o
 
+rtsx_pci-objs			:= rtsx_pcr.o rts5209.o rts5229.o
+obj-$(CONFIG_MFD_RTSX_PCI)	+= rtsx_pci.o
+
 obj-$(CONFIG_HTC_EGPIO)		+= htc-egpio.o
 obj-$(CONFIG_HTC_PASIC3)	+= htc-pasic3.o
 obj-$(CONFIG_HTC_I2CPLD)	+= htc-i2cpld.o
@@ -132,3 +135,4 @@ obj-$(CONFIG_MFD_RC5T583)	+= rc5t583.o rc5t583-irq.o
 obj-$(CONFIG_MFD_SEC_CORE)	+= sec-core.o sec-irq.o
 obj-$(CONFIG_MFD_ANATOP)	+= anatop-mfd.o
 obj-$(CONFIG_MFD_LM3533)	+= lm3533-core.o lm3533-ctrlbank.o
+obj-$(CONFIG_MFD_RTSX_PCI)	+= rtsx_pci.o
drivers/mfd/rts5209.c new file +104 -0

104 lines not on this page · raw message

drivers/mfd/rts5229.c new file +119 -0

119 lines not on this page · raw message

drivers/mfd/rtsx_pcr.c new file +1286 -0

1,286 lines not on this page · raw message

drivers/mfd/rtsx_pcr.h new file +31 -0
new file mode 100644
index 0000000..8fbc471
@@ -0,0 +1,31 @@
+/* Driver for Realtek PCI-Express card reader
+ *
+ * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author:
+ *   Wei WANG <[email protected]>
+ *   No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China
+ */
+
+#ifndef __RTSX_PCR_H
+#define __RTSX_PCR_H
+
+#include <linux/mfd/rtsx_pci.h>
+
+extern const struct pcr_ops rts5209_pcr_ops;
+extern const struct pcr_ops rts5229_pcr_ops;
+
+#endif
include/linux/mfd/rtsx_common.h new file +47 -0

47 lines not on this page · raw message

include/linux/mfd/rtsx_pci.h new file +690 -0

690 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#2 lore raw

PATCH v3 2/2 drivers/mmc: Add realtek pcie sdmmc host driver

In reply to [email protected]

From: Wei WANG <[email protected]>

Realtek PCI-E SD/MMC card host driver is used to access SD/MMC card, with the help of Realtek PCI-E card reader MFD driver.

---
 drivers/mmc/host/Kconfig          |    7 +
 drivers/mmc/host/Makefile         |    2 +
 drivers/mmc/host/rtsx_pci_sdmmc.c | 1341 +++++++++++++++++++++++++++++++++++++
 3 files changed, 1350 insertions(+)
 create mode 100644 drivers/mmc/host/rtsx_pci_sdmmc.c
drivers/mmc/host/Kconfig +7 -0
index aa131b3..d6f0c01 100644
@@ -612,3 +612,10 @@ config MMC_USHC
 
 	  Note: These controllers only support SDIO cards and do not
 	  support MMC or SD memory cards.
+
+config MMC_REALTEK_PCI
+	tristate "Realtek PCI-E SD/MMC Card Interface Driver"
+	depends on MFD_RTSX_PCI
+	help
+	  Say Y here to include driver code to support SD/MMC card interface
+	  of Realtek PCI-E driver-based card reader
drivers/mmc/host/Makefile +2 -0
index 8922b06..4679ba3 100644
@@ -45,6 +45,8 @@ obj-$(CONFIG_MMC_JZ4740)	+= jz4740_mmc.o
 obj-$(CONFIG_MMC_VUB300)	+= vub300.o
 obj-$(CONFIG_MMC_USHC)		+= ushc.o
 
+obj-$(CONFIG_MMC_REALTEK_PCI)	+= rtsx_pci_sdmmc.o
+
 obj-$(CONFIG_MMC_SDHCI_PLTFM)		+= sdhci-pltfm.o
 obj-$(CONFIG_MMC_SDHCI_CNS3XXX)		+= sdhci-cns3xxx.o
 obj-$(CONFIG_MMC_SDHCI_ESDHC_IMX)	+= sdhci-esdhc-imx.o
drivers/mmc/host/rtsx_pci_sdmmc.c new file +1341 -0

1,341 lines not on this page · raw message

Signature · 1 line
1.7.9.5
author
#3 lore raw

[drivers/mmc]Issue on DMA out of SW-IOMMU space

In reply to [email protected]

Hi all:

Several days ago I sent out a series of patches to support Realtek SD/MMC reader. Boris helped to give it a test using his Thinkpad x121e, with a built-in Realtek card reader named rts5209. (Hi, Thank you, Boris .. ) And he reported that some error messages, as below shows, would arise when formating a 16G SD UHS-I card using mkfs.ext3.

[ 286.244866] mmc0: new ultra high speed SDR50 SDHC card at address e624
[ 286.277199] mmcblk0: mmc0:e624 SU16G 14.8 GiB
[ 286.318163] mmcblk0:
[ 363.754647] mmcblk0: p1
[ 379.545510] DMA: Out of SW-IOMMU space for 438272 bytes at device
0000:03:00.0
[ 389.578514] DMA: Out of SW-IOMMU space for 380928 bytes at device
0000:03:00.0
[ 399.590953] DMA: Out of SW-IOMMU space for 524288 bytes at device
0000:03:00.0
[ 409.590698] DMA: Out of SW-IOMMU space for 380928 bytes at device
0000:03:00.0
[ 419.589054] DMA: Out of SW-IOMMU space for 380928 bytes at device

0000:03:00.0

That's to say, in some situation dma_map_sg would fail when transferring massive data.
By adding more debug message I found some facts:
1. In Thinkpad x121e, the transfer size in one transfer is often 512KB. (But in my notebook, the largest transfer size I found is 64KB);
2. When dma_map_sg succeeds, the largest sg size in the sglist will not be larger than 256KB;
3. When dma_map_sg fails, the sg number of the sglist is always 2, and the total transfer size is circa 512KB. So I guess that the largest sg size may be larger than 256KB.

Based on the above facts and guess, I asked Boris to help to change mmc->max_seg_size from 512KB to 64KB in Realtek SD/MMC host driver, and everything is OK.

(Hi Boris, you have also tested 256KB later, and the result is still OK, right ?)

So my question comes out.

Quoted 1 line

From our experiment, it seems that mmc host driver must set a proper

value to max_seg_size at first. But I really don't think it's the host driver's responsibility to guess/inquiry the max DMA segment size before declaring it.
The host driver is all along passive to response the request from the upper layer. If the segment is too large to handle, that buffer should be divided into more smaller pieces at first in the upper layer and then pass on to the lower layer, which is our host driver in this case. And I didn't find any host driver in drivers/mmc/host to inquiry the max DMA segment size that this platform can afford before declaring their max_seg_size.

Maybe I missed something , but I still can't find the answer for now. So please help :-)

BR,
wwang