Skip to contentSkip to conversation

Add modules for realtek USB card reader

PATCH Applied [email protected] 6 participants 20 messages Apr 11, 2014 – May 23, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v7 cover Add modules for realtek USB card reader

From: Roger Tseng <[email protected]>

This patchset adds modules to support Realtek USB vendor specific class flash card reader: one base module in MFD subsystem and two host modules in both mmc and memstick subsystems. The architecture is similar to rtsx_pci.

This work is done primarily to replace the staging driver: staging/rts5139, which doesn't utilize mmc nor memstick subsystems. Once the patchset or its revision is applied, we may need Greg's help to remove the staging one.

v2:
1. Fix potential buffer overflow in rtsx_usb_seq_write_register()
2. Remove unnecessary casting and messages
3. Revise coding style and white spaces

v3:
1. Fix MMC detection fail when under xhci
2. Minor change of pm_runtime behavior in rtsx_usb_ms to prevent some rare freeze due to erroneous Memstick card(not MS-Pro)
3. Further revise coding style as suggested in the thread of v2
4. Using managed resources: devm_*
5. Change license from "GPL v2 and later" to "GPL v2"

v4:
1. Remove invocations to deprecated/removed mmc_suspend|resume_host APIs and unnecessary platform device pm routines
2. Support CRC-ignored R1 response for CMD13 in response to commit:
a27fbf2f067b0cd6f172c8b696b9a44c58bfaa7a: mmc: add ignorance case for CMD13 CRC error
3. Remove unnecessary #ifdef CONFIG_PM_RUNTIME

v5:
1. rtsx_usb_ms.c: adding header inclusion, removing unnecessary NULL checking, and add cancel_work_sync in removal handler to wait possible pending works.
(Changes only rtsx_usb_ms. Other files remain the same to v4)

v6:
NOTE:since the v3 of patch 1/3 (rtsx_usb) has been merged, only diffs are submitted and splitted into two.
1. rtsx_usb.c: fix possible race conditions:
rtsx_usb_bulk_transfer_sglist(): del_timer() => del_timer_sync() rtsx_usb_probe(): move setup_timer() before mfd_add_devices() and also
remove unnecessary init_timer()
2. rtsx_usb.c: rtsx_usb_suspend(): add comments to LED turn-off (Changes only rtsx_usb.c. Other files remain the same to v5)

v7:
1. rtsx_usb_sdmmc: remove unnecessary pm usage balancing during removal
2. rtsx_usb_sdmmc: add Acked-by: Ulf Hansson <[email protected]>

Roger Tseng (4):
[v6 fix] mfd/rtsx_usb: fix possible race condition [v6 fix] mfd/rtsx_usb: add comment in rtsx_usb_suspend
mmc: Add realtek USB sdmmc host driver
memstick: Add realtek USB memstick host driver

 drivers/memstick/host/Kconfig       |   10 +
 drivers/memstick/host/Makefile      |    1 +
 drivers/memstick/host/rtsx_usb_ms.c |  839 ++++++++++++++++++++
 drivers/mfd/rtsx_usb.c              |   14 +-
 drivers/mmc/host/Kconfig            |    7 +
 drivers/mmc/host/Makefile           |    1 +
 drivers/mmc/host/rtsx_usb_sdmmc.c   | 1455 +++++++++++++++++++++++++++++++++++
 7 files changed, 2323 insertions(+), 4 deletions(-)
 create mode 100644 drivers/memstick/host/rtsx_usb_ms.c
 create mode 100644 drivers/mmc/host/rtsx_usb_sdmmc.c
Signature · 1 line
1.8.2
#1 lore raw

PATCH v6 1/4 mfd/rtsx_usb: fix possible race condition

From: Roger Tseng <[email protected]>

Fix two possible race condition generated by misuse of del_timer in rtsx_usb_bulk_transfer_sglist() and uninitialized timers before mfd_add_devices in rtsx_usb_probe().

---
 drivers/mfd/rtsx_usb.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/mfd/rtsx_usb.c +4 -4
index b53b9d4..0ca7973 100644
@@ -67,7 +67,7 @@ static int rtsx_usb_bulk_transfer_sglist(struct rtsx_ucr *ucr,
 	ucr->sg_timer.expires = jiffies + msecs_to_jiffies(timeout);
 	add_timer(&ucr->sg_timer);
 	usb_sg_wait(&ucr->current_sg);
-	del_timer(&ucr->sg_timer);
+	del_timer_sync(&ucr->sg_timer);
 
 	if (act_len)
 		*act_len = ucr->current_sg.bytes;
@@ -644,14 +644,14 @@ static int rtsx_usb_probe(struct usb_interface *intf,
 	if (ret)
 		goto out_init_fail;
 
+	/* initialize USB SG transfer timer */
+	setup_timer(&ucr->sg_timer, rtsx_usb_sg_timed_out, (unsigned long) ucr);
+
 	ret = mfd_add_devices(&intf->dev, usb_dev->devnum, rtsx_usb_cells,
 			ARRAY_SIZE(rtsx_usb_cells), NULL, 0, NULL);
 	if (ret)
 		goto out_init_fail;
 
-	/* initialize USB SG transfer timer */
-	init_timer(&ucr->sg_timer);
-	setup_timer(&ucr->sg_timer, rtsx_usb_sg_timed_out, (unsigned long) ucr);
 #ifdef CONFIG_PM
 	intf->needs_remote_wakeup = 1;
 	usb_enable_autosuspend(usb_dev);
Signature · 1 line
1.8.2
Applied
#2 lore raw

Re: [PATCH v7 1/4] [v6 fix] mfd/rtsx_usb: fix possible race condition

Quoted 10 lines

From: Roger Tseng <[email protected]>

Fix two possible race condition generated by misuse of del_timer in rtsx_usb_bulk_transfer_sglist() and uninitialized timers before mfd_add_devices in rtsx_usb_probe().

---
 drivers/mfd/rtsx_usb.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Applied, thanks.

Signature · 8 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
#3 lore raw

PATCH v6 2/4 mfd/rtsx_usb: add comment in rtsx_usb_suspend

In reply to [email protected]

From: Roger Tseng <[email protected]>

Explain why there is no need to have a symmetric LED turn-on in resume handler while calling rtsx_usb_turn_off_led() in suspend handler.

---
 drivers/mfd/rtsx_usb.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/mfd/rtsx_usb.c +6 -0
index 0ca7973..141ea52 100644
@@ -687,9 +687,15 @@ static int rtsx_usb_suspend(struct usb_interface *intf, pm_message_t message)
 	dev_dbg(&intf->dev, "%s called with pm message 0x%04u\n",
 			__func__, message.event);
 
+	/*
+	 * Call to make sure LED is off during suspend to save more power.
+	 * It is NOT a permanent state and could be turned on anytime later.
+	 * Thus no need to call turn_on when resunming.
+	 */
 	mutex_lock(&ucr->dev_mutex);
 	rtsx_usb_turn_off_led(ucr);
 	mutex_unlock(&ucr->dev_mutex);
+
 	return 0;
 }
 
Signature · 1 line
1.8.2
Applied
#4 lore raw

Re: [PATCH v7 2/4] [v6 fix] mfd/rtsx_usb: add comment in rtsx_usb_suspend

Quoted 9 lines · On Fri, 11 Apr 2014, [email protected] wrote:

From: Roger Tseng <[email protected]>

Explain why there is no need to have a symmetric LED turn-on in resume handler while calling rtsx_usb_turn_off_led() in suspend handler.

---
 drivers/mfd/rtsx_usb.c | 6 ++++++
 1 file changed, 6 insertions(+)

Applied, thanks.

Signature · 8 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
#5 lore raw

PATCH v7 3/4 mmc: Add realtek USB sdmmc host driver

In reply to [email protected]

From: Roger Tseng <[email protected]>

Realtek USB SD/MMC host driver provides mmc host support based on the Realtek USB card reader MFD driver.

---
 drivers/mmc/host/Kconfig          |    7 +
 drivers/mmc/host/Makefile         |    1 +
 drivers/mmc/host/rtsx_usb_sdmmc.c | 1455 +++++++++++++++++++++++++++++++++++++
 3 files changed, 1463 insertions(+)
 create mode 100644 drivers/mmc/host/rtsx_usb_sdmmc.c
drivers/mmc/host/Kconfig +7 -0
index 1384f67..1c01df4 100644
@@ -689,3 +689,10 @@ config MMC_REALTEK_PCI
 	help
 	  Say Y here to include driver code to support SD/MMC card interface
 	  of Realtek PCI-E card reader
+
+config MMC_REALTEK_USB
+	tristate "Realtek USB SD/MMC Card Interface Driver"
+	depends on MFD_RTSX_USB
+	help
+	  Say Y here to include driver code to support SD/MMC card interface
+	  of Realtek RTS5129/39 series card reader
drivers/mmc/host/Makefile +1 -0
index 3483b6b..8194317 100644
@@ -53,6 +53,7 @@ obj-$(CONFIG_MMC_USHC)		+= ushc.o
 obj-$(CONFIG_MMC_WMT)		+= wmt-sdmmc.o
 
 obj-$(CONFIG_MMC_REALTEK_PCI)	+= rtsx_pci_sdmmc.o
+obj-$(CONFIG_MMC_REALTEK_USB)	+= rtsx_usb_sdmmc.o
 
 obj-$(CONFIG_MMC_SDHCI_PLTFM)		+= sdhci-pltfm.o
 obj-$(CONFIG_MMC_SDHCI_CNS3XXX)		+= sdhci-cns3xxx.o
drivers/mmc/host/rtsx_usb_sdmmc.c new file +1455 -0

1,455 lines not on this page · raw message

Signature · 1 line
1.8.2
Applied
#6 lore raw

Re: [PATCH v7 3/4] mmc: Add realtek USB sdmmc host driver

Quoted 5 lines

From: Roger Tseng <[email protected]>

Realtek USB SD/MMC host driver provides mmc host support based on the Realtek USB card reader MFD driver.

Quoted 8 lines
---
 drivers/mmc/host/Kconfig          |    7 +
 drivers/mmc/host/Makefile         |    1 +
 drivers/mmc/host/rtsx_usb_sdmmc.c | 1455 +++++++++++++++++++++++++++++++++++++
 3 files changed, 1463 insertions(+)
 create mode 100644 drivers/mmc/host/rtsx_usb_sdmmc.c

Applied, thanks.

Signature · 8 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
#7 lore raw

PATCH v7 4/4 memstick: Add realtek USB memstick host driver

In reply to [email protected]

From: Roger Tseng <[email protected]>

Realtek USB memstick host driver provides memstick host support based on the Realtek USB card reader MFD driver.

---
 drivers/memstick/host/Kconfig       |  10 +
 drivers/memstick/host/Makefile      |   1 +
 drivers/memstick/host/rtsx_usb_ms.c | 839 ++++++++++++++++++++++++++++++++++++
 3 files changed, 850 insertions(+)
 create mode 100644 drivers/memstick/host/rtsx_usb_ms.c
drivers/memstick/host/Kconfig +10 -0
index 1b37cf8..7310e32 100644
@@ -52,3 +52,13 @@ config MEMSTICK_REALTEK_PCI
 
 	  To compile this driver as a module, choose M here: the module will
 	  be called rtsx_pci_ms.
+
+config MEMSTICK_REALTEK_USB
+	tristate "Realtek USB Memstick Card Interface Driver"
+	depends on MFD_RTSX_USB
+	help
+	  Say Y here to include driver code to support Memstick card interface
+	  of Realtek RTS5129/39 series USB card reader
+
+	  To compile this driver as a module, choose M here: the module will
+	  be called rts5139_ms.
drivers/memstick/host/Makefile +1 -0
index af3459d..491c955 100644
@@ -6,3 +6,4 @@ obj-$(CONFIG_MEMSTICK_TIFM_MS)		+= tifm_ms.o
 obj-$(CONFIG_MEMSTICK_JMICRON_38X)	+= jmb38x_ms.o
 obj-$(CONFIG_MEMSTICK_R592)		+= r592.o
 obj-$(CONFIG_MEMSTICK_REALTEK_PCI)	+= rtsx_pci_ms.o
+obj-$(CONFIG_MEMSTICK_REALTEK_USB)	+= rtsx_usb_ms.o
drivers/memstick/host/rtsx_usb_ms.c new file +839 -0

839 lines not on this page · raw message

Signature · 1 line
1.8.2
#8 lore raw

Re: [PATCH v7 4/4] memstick: Add realtek USB memstick host driver

Hi Andrew,

Quoted 5 lines

From: Roger Tseng <[email protected]>

Realtek USB memstick host driver provides memstick host support based on the Realtek USB card reader MFD driver.

Quoted 7 lines
---
 drivers/memstick/host/Kconfig       |  10 +
 drivers/memstick/host/Makefile      |   1 +
 drivers/memstick/host/rtsx_usb_ms.c | 839 ++++++++++++++++++++++++++++++++++++
 3 files changed, 850 insertions(+)
 create mode 100644 drivers/memstick/host/rtsx_usb_ms.c

It seems Max and Alex are less than interested in this patch, so I'm going to apply it anyway. In your last review you mentioned that it looked good to your inexpert eye. Can I apply your Ack to that effect?

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
author
#9 lore raw

Re: [PATCH v7 4/4] memstick: Add realtek USB memstick host driver

Quoted 15 lines · Lee Jones

Hi Andrew,

Quoted 5 lines

From: Roger Tseng <[email protected]>

Realtek USB memstick host driver provides memstick host support based on the Realtek USB card reader MFD driver.

Quoted 7 lines
---
  drivers/memstick/host/Kconfig       |  10 +
  drivers/memstick/host/Makefile      |   1 +
  drivers/memstick/host/rtsx_usb_ms.c | 839 ++++++++++++++++++++++++++++++++++++
  3 files changed, 850 insertions(+)

create mode 100644 drivers/memstick/host/rtsx_usb_ms.c

Quoted 4 lines

It seems Max and Alex are less than interested in this patch, so I'm going to apply it anyway. In your last review you mentioned that it looked good to your inexpert eye. Can I apply your Ack to that effect?

Hi Andrew,

Would you confirm the Ack for Lee?

Best regards,
Roger Tseng

#10 lore raw

Re: [PATCH v7 4/4] memstick: Add realtek USB memstick host driver

In reply to Lee Jones
Quoted 4 lines · Lee Jones

It seems Max and Alex are less than interested in this patch, so I'm going to apply it anyway. In your last review you mentioned that it looked good to your inexpert eye. Can I apply your Ack to that effect?

Just apply it... He said it was ok.

These two new drivers are not beautiful works of art but they're not horrible.

Roger and the Realtek devs have been very responsive so I imagine they'll fix which ever bugs show up. Let's move on with this.

regards,
dan carpenter

Applied
#11 lore raw

Re: [PATCH v7 4/4] memstick: Add realtek USB memstick host driver

In reply to [email protected]
Quoted 5 lines

From: Roger Tseng <[email protected]>

Realtek USB memstick host driver provides memstick host support based on the Realtek USB card reader MFD driver.

Quoted 7 lines
---
 drivers/memstick/host/Kconfig       |  10 +
 drivers/memstick/host/Makefile      |   1 +
 drivers/memstick/host/rtsx_usb_ms.c | 839 ++++++++++++++++++++++++++++++++++++
 3 files changed, 850 insertions(+)
 create mode 100644 drivers/memstick/host/rtsx_usb_ms.c

Applied, thanks.

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
author
#12 lore raw

Re: [PATCH v7 4/4] memstick: Add realtek USB memstick host driver

Quoted 13 lines · Lee Jones
Quoted 5 lines

From: Roger Tseng <[email protected]>

Realtek USB memstick host driver provides memstick host support based on the Realtek USB card reader MFD driver.

Quoted 7 lines
---
  drivers/memstick/host/Kconfig       |  10 +
  drivers/memstick/host/Makefile      |   1 +
  drivers/memstick/host/rtsx_usb_ms.c | 839 ++++++++++++++++++++++++++++++++++++
  3 files changed, 850 insertions(+)

create mode 100644 drivers/memstick/host/rtsx_usb_ms.c

Quoted 2 lines

Applied, thanks.

Greg,

Since all patches have been applied and the device is now supported by the new driver, would you remove the former staging one at drivers/staging/rts5139? Similar removal had been done for our PCIE devices in:

commit cd2112220b6b0a35fa12ba988a0dd837515dfaf8

Author: Greg Kroah-Hartman <[email protected]>
Date:   Fri Oct 26 09:03:21 2012 -0700

Staging: remove rts_pstor driver

Best regards,
Roger Tseng

#13 lore raw

Re: [PATCH v7 4/4] memstick: Add realtek USB memstick host driver

Quoted 23 lines · Roger
Quoted 13 lines · Lee Jones
Quoted 5 lines

From: Roger Tseng <[email protected]>

Realtek USB memstick host driver provides memstick host support based on the Realtek USB card reader MFD driver.

Quoted 7 lines
---
  drivers/memstick/host/Kconfig       |  10 +
  drivers/memstick/host/Makefile      |   1 +
  drivers/memstick/host/rtsx_usb_ms.c | 839 ++++++++++++++++++++++++++++++++++++
  3 files changed, 850 insertions(+)

create mode 100644 drivers/memstick/host/rtsx_usb_ms.c

Quoted 2 lines

Applied, thanks.

Greg,

Since all patches have been applied and the device is now supported by the new driver, would you remove the former staging one at drivers/staging/rts5139? Similar removal had been done for our PCIE devices in:

Quoted 6 lines

commit cd2112220b6b0a35fa12ba988a0dd837515dfaf8

Author: Greg Kroah-Hartman <[email protected]>
Date:   Fri Oct 26 09:03:21 2012 -0700

Staging: remove rts_pstor driver

Now removed, thanks.

greg k-h

#14 lore raw
In reply to [email protected]
Quoted 9 lines · On Fri, 2014-04-11 at 14:53 +0800, [email protected] wrote:

From: Roger Tseng <[email protected]>

This patchset adds modules to support Realtek USB vendor specific class flash card reader: one base module in MFD subsystem and two host modules in both mmc and memstick subsystems. The architecture is similar to rtsx_pci.

This work is done primarily to replace the staging driver: staging/rts5139, which doesn't utilize mmc nor memstick subsystems. Once the patchset or its revision is applied, we may need Greg's help to remove the staging one.

Looks good to me.

Regards
Oliver

#15 lore raw
Quoted 11 lines
Quoted 9 lines

From: Roger Tseng <[email protected]>

This patchset adds modules to support Realtek USB vendor specific class flash card reader: one base module in MFD subsystem and two host modules in both mmc and memstick subsystems. The architecture is similar to rtsx_pci.

This work is done primarily to replace the staging driver: staging/rts5139, which doesn't utilize mmc nor memstick subsystems. Once the patchset or its revision is applied, we may need Greg's help to remove the staging one.

Looks good to me.

Is that an Ack?

Quoted 4 lines

Regards
Oliver

Signature · 8 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Acked-by
#16 lore raw
Quoted 6 lines · Lee Jones
Quoted 6 lines
Quoted 6 lines

From: Roger Tseng <[email protected]>

This patchset adds modules to support Realtek USB vendor specific class flash card reader: one base module in MFD subsystem and two host modules in both mmc and memstick subsystems. The architecture is similar to rtsx_pci.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

This work is done primarily to replace the staging driver: staging/rts5139, which doesn't utilize mmc nor memstick subsystems. Once the patchset or its revision is applied, we may need Greg's help to remove the staging one.

Looks good to me.

Is that an Ack?

Sorry
Oliver

author
#17 lore raw
Quoted 11 lines · Oliver Neukum
Quoted 10 lines · Lee Jones
Quoted 10 lines
Quoted 9 lines

From: Roger Tseng <[email protected]>

This patchset adds modules to support Realtek USB vendor specific class flash card reader: one base module in MFD subsystem and two host modules in both mmc and memstick subsystems. The architecture is similar to rtsx_pci.

This work is done primarily to replace the staging driver: staging/rts5139, which doesn't utilize mmc nor memstick subsystems. Once the patchset or its revision is applied, we may need Greg's help to remove the staging one.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Looks good to me.

Is that an Ack?

Sorry
Oliver

Lee,

Would you apply all of these patches?

Best regards,
Roger Tseng

#18 lore raw
Quoted 24 lines · Roger
Quoted 23 lines · Oliver Neukum
Quoted 20 lines · Lee Jones
Quoted 9 lines
Quoted 9 lines

From: Roger Tseng <[email protected]>

This patchset adds modules to support Realtek USB vendor specific class flash
card reader: one base module in MFD subsystem and two host modules in both mmc
and memstick subsystems. The architecture is similar to rtsx_pci.

Quoted 8 lines
Quoted 5 lines

This work is done primarily to replace the staging driver:
staging/rts5139,
which doesn't utilize mmc nor memstick subsystems. Once the patchset or its
revision is applied, we may need Greg's help to remove the staging one.

Looks good to me.

Is that an Ack?

Quoted 8 lines
Quoted 5 lines

Sorry
Oliver

Lee,

Would you apply all of these patches?

I have sent a pull request to Chris, containing the patch with the new mmc driver. The rest I am fine with if Lee can take though the mfd tree.

Kind regards
Ulf Hansson

Quoted 4 lines

Best regards,
Roger Tseng

#19 lore raw
In reply to Roger
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 11 lines
Quoted 9 lines

From: Roger Tseng <[email protected]>

This patchset adds modules to support Realtek USB vendor specific class flash card reader: one base module in MFD subsystem and two host modules in both mmc and memstick subsystems. The architecture is similar to rtsx_pci.

This work is done primarily to replace the staging driver: staging/rts5139, which doesn't utilize mmc nor memstick subsystems. Once the patchset or its revision is applied, we may need Greg's help to remove the staging one.

Looks good to me.

Is that an Ack?

Quoted 8 lines
Quoted 5 lines

Sorry
Oliver

Lee,

Would you apply all of these patches?

In time. I'm still catching up after the merge-window.

Signature · 8 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel