All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: Bug#757733: RTS2557 SD card reader does not work
       [not found] <20140810225012.3425.19201.reportbug@t4.home.phihag.de>
@ 2014-08-10 23:58 ` Ben Hutchings
  2014-08-11  1:10   ` Philipp Hagemeister
  0 siblings, 1 reply; 5+ messages in thread
From: Ben Hutchings @ 2014-08-10 23:58 UTC (permalink / raw)
  To: Wei WANG; +Cc: Philipp Hagemeister, 757733, LKML

[-- Attachment #1: Type: text/plain, Size: 1560 bytes --]

On Mon, 2014-08-11 at 00:50 +0200, Philipp Hagemeister wrote:
> Package: src:linux
> Version: 3.16-1~exp1
> Severity: normal
> 
> Dear Maintainer,
> 
> I have a Lenovo Thinkpad T440s with an included SD card reader for which
> /dev/mmc* devices do not show up. It seems to be an RTS 2557:
> 
> $ lspci -v | grep RTS
> 02:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. RTS5227 PCI
> Express Card Reader (rev 01)
> 
> With linux-image-3.14-2-amd64 (unstable) as well as 3.16-trunk-
> amd64(experimental), there are no /dev/mmc* devices (or in fact, any new
> devices) after inserting an SD card (which works fine on another reader). dmesg
> shows this error:
> 
> $ dmesg  | grep rtsx_pci
> [    0.881602] rtsx_pci 0000:02:00.0: irq 57 for MSI/MSI-X
> [    0.881619] rtsx_pci 0000:02:00.0: rtsx_pci_acquire_irq: pcr->msi_en = 1,
> pci->irq = 57
> [    0.980400] rtsx_pci: probe of 0000:02:00.0 failed with error -110
> 
> This error shows up at boot time. There are no new dmesg (or syslog) outputs
> upon inserting the SD card.

A web search shows some similar reports (e.g.
<https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1329566>,
<http://askubuntu.com/questions/473848/ubuntu-14-04-realtek-semiconductor-co-ltd-rts5227-pci-express-card-reader-isn>).
But in that last one, it turns out that the out-of-tree driver does
work.

Is there anything Philipp can do (e.g. debugging options) to help get
this fixed?

Ben.

-- 
Ben Hutchings
Humans are not rational beings; they are rationalising beings.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Bug#757733: RTS2557 SD card reader does not work
  2014-08-10 23:58 ` Bug#757733: RTS2557 SD card reader does not work Ben Hutchings
@ 2014-08-11  1:10   ` Philipp Hagemeister
  2014-08-11  6:45     ` 答复: " 王炜
  0 siblings, 1 reply; 5+ messages in thread
From: Philipp Hagemeister @ 2014-08-11  1:10 UTC (permalink / raw)
  To: Ben Hutchings, Wei WANG; +Cc: 757733, LKML


[-- Attachment #1.1: Type: text/plain, Size: 601 bytes --]

> A web search shows some similar reports (e.g.
> <https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1329566>,
>
<http://askubuntu.com/questions/473848/ubuntu-14-04-realtek-semiconductor-co-ltd-rts5227-pci-express-card-reader-isn>).
> But in that last one, it turns out that the out-of-tree driver does
> work.

Indeed, that is a workaround - download from
http://www.realtek.com.tw/downloads/downloadsView.aspx?Langid=1&PNid=15&PFid=25&Level=4&Conn=3&DownTypeID=3&GetDown=false
, apply the attached patch, remove all rtsx_* modules, and insert the
new rts2557 module into the kernel.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: rts5229.patch --]
[-- Type: text/x-patch; name="rts5229.patch", Size: 1881 bytes --]

commit 31eeecabfabe62c9667464f2144cbbd57c370b6f
Author: Philipp Hagemeister <phihag@phihag.de>
Date:   Mon Aug 11 03:03:56 2014 +0200

    Rename rts2559 to rts2557 and remove outdated macros

diff --git a/Makefile b/Makefile
index 6536bd4..7815096 100644
--- a/Makefile
+++ b/Makefile
@@ -22,7 +22,7 @@
 # Makefile for the PCI-Express Card Reader drivers.
 #
 
-TARGET_MODULE := rts5229
+TARGET_MODULE := rts5227
 
 EXTRA_CFLAGS := -Idrivers/scsi 
 
diff --git a/rtsx.c b/rtsx.c
index 7fd7a92..8ba9e19 100644
--- a/rtsx.c
+++ b/rtsx.c
@@ -263,7 +263,6 @@ static struct scsi_host_template rtsx_host_template = {
 	
 	.name =				CR_DRIVER_NAME,
 	.proc_name =			CR_DRIVER_NAME,
-	.proc_info =			proc_info,
 	.info =				host_info,
 
 	
@@ -911,7 +910,7 @@ static void rtsx_init_options(struct rtsx_chip *chip)
 	chip->support_mmc = 1;
 }
 
-static int __devinit rtsx_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
+static int rtsx_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
 {
 	struct Scsi_Host *host;
 	struct rtsx_dev *dev;
@@ -1066,7 +1065,7 @@ errout:
 }
 
 
-static void __devexit rtsx_remove(struct pci_dev *pci)
+static void rtsx_remove(struct pci_dev *pci)
 {
 	struct rtsx_dev *dev = (struct rtsx_dev *)pci_get_drvdata(pci);
 
@@ -1092,7 +1091,7 @@ static struct pci_driver driver = {
 	.name = CR_DRIVER_NAME,
 	.id_table = rts5229_ids,
 	.probe = rtsx_probe,
-	.remove = __devexit_p(rtsx_remove),
+	.remove = rtsx_remove,
 #ifdef CONFIG_PM
 	.suspend = rtsx_suspend,
 	.resume = rtsx_resume,
diff --git a/rtsx.h b/rtsx.h
index 3a1bb2f..98b26c4 100644
--- a/rtsx.h
+++ b/rtsx.h
@@ -52,7 +52,7 @@
 #include "trace.h"
 #include "general.h"
 
-#define CR_DRIVER_NAME		"rts5229"
+#define CR_DRIVER_NAME		"rts5227"
 
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 14)

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* 答复: Bug#757733: RTS2557 SD card reader does not work
  2014-08-11  1:10   ` Philipp Hagemeister
@ 2014-08-11  6:45     ` 王炜
  2015-01-11  0:09       ` Johannes Schauer
  0 siblings, 1 reply; 5+ messages in thread
From: 王炜 @ 2014-08-11  6:45 UTC (permalink / raw)
  To: Philipp Hagemeister, Ben Hutchings; +Cc: 757733, LKML

[-- Attachment #1: Type: text/plain, Size: 1026 bytes --]


> -----邮件原件-----
> 发件人: Philipp Hagemeister [mailto:phihag@phihag.de]
> 发送时间: 2014年8月11日 9:10
> 收件人: Ben Hutchings; 王炜
> 抄送: 757733@bugs.debian.org; LKML
> 主题: Re: Bug#757733: RTS2557 SD card reader does not work
> 
> > A web search shows some similar reports (e.g.
> > <https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1329566>,
> >
> <http://askubuntu.com/questions/473848/ubuntu-14-04-realtek-semiconducto
> r-co-ltd-rts5227-pci-express-card-reader-isn>).
> > But in that last one, it turns out that the out-of-tree driver does
> > work.
> 
> Indeed, that is a workaround - download from
> http://www.realtek.com.tw/downloads/downloadsView.aspx?Langid=1&PNid=
> 15&PFid=25&Level=4&Conn=3&DownTypeID=3&GetDown=false
> , apply the attached patch, remove all rtsx_* modules, and insert the new
> rts2557 module into the kernel.


Hi Philipp & Ben:

Would you please try this patch. If it does work, we will submit it to upstream kernel.

BR,
Wei

[-- Attachment #2: 0001-mfd-rtsx-fix-rts5227-suspend-resume-setting.patch --]
[-- Type: application/octet-stream, Size: 3681 bytes --]

From b2c90217392ecdf05bc98f73cce41c2008f9b0df Mon Sep 17 00:00:00 2001
From: Micky Ching <micky_ching@realsil.com.cn>
Date: Mon, 11 Aug 2014 14:12:42 +0800
Subject: [PATCH] mfd: rtsx: fix rts5227 suspend/resume setting

Signed-off-by: Micky Ching <micky_ching@realsil.com.cn>
---
 drivers/mfd/rts5227.c        |   13 +++++++++++++
 drivers/mfd/rtsx_pcr.c       |   16 ++++++++++++----
 include/linux/mfd/rtsx_pci.h |   18 ++++++++++++++++++
 3 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/drivers/mfd/rts5227.c b/drivers/mfd/rts5227.c
index 9c8eec8..65f236b 100644
--- a/drivers/mfd/rts5227.c
+++ b/drivers/mfd/rts5227.c
@@ -128,8 +128,21 @@ static int rts5227_extra_init_hw(struct rtsx_pcr *pcr)
 	return rtsx_pci_send_cmd(pcr, 100);
 }
 
+static int rts5227_reset_first(struct rtsx_pcr *pcr)
+{
+	/* init aspm */
+	if (rtsx_pci_update_cfg_byte(pcr, LCTLR, 0xFC, 0))
+		pcr_err(pcr, "update LCTLR failed\n");
+	/* reset PM before send buffer cmd */
+	if (rtsx_pci_write_register(pcr, PM_CTRL3, 0x10, 0x00))
+		pcr_err(pcr, "set PM_CTRL3 failed\n");
+
+	return 0;
+}
+
 static int rts5227_optimize_phy(struct rtsx_pcr *pcr)
 {
+	rts5227_reset_first(pcr);
 	/* Optimize RX sensitivity */
 	return rtsx_pci_write_phy_register(pcr, 0x00, 0xBA42);
 }
diff --git a/drivers/mfd/rtsx_pcr.c b/drivers/mfd/rtsx_pcr.c
index 1d15735..a61739e 100644
--- a/drivers/mfd/rtsx_pcr.c
+++ b/drivers/mfd/rtsx_pcr.c
@@ -952,16 +952,20 @@ static int rtsx_pci_init_hw(struct rtsx_pcr *pcr)
 
 	/* Power on SSC */
 	err = rtsx_pci_write_register(pcr, FPDCTL, SSC_POWER_DOWN, 0);
-	if (err < 0)
+	if (err < 0) {
+		pcr_err(pcr, "power on ssc\n");
 		return err;
+	}
 
 	/* Wait SSC power stable */
 	udelay(200);
 
 	if (pcr->ops->optimize_phy) {
 		err = pcr->ops->optimize_phy(pcr);
-		if (err < 0)
+		if (err < 0) {
+			pcr_err(pcr, "optimize phy\n");
 			return err;
+		}
 	}
 
 	rtsx_pci_init_cmd(pcr);
@@ -1003,8 +1007,10 @@ static int rtsx_pci_init_hw(struct rtsx_pcr *pcr)
 	rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, NFTS_TX_CTRL, 0x02, 0);
 
 	err = rtsx_pci_send_cmd(pcr, 100);
-	if (err < 0)
+	if (err < 0) {
+		pcr_err(pcr, "send init hw cmd\n");
 		return err;
+	}
 
 	rtsx_pci_write_config_byte(pcr, LCTLR, 0);
 
@@ -1015,8 +1021,10 @@ static int rtsx_pci_init_hw(struct rtsx_pcr *pcr)
 
 	if (pcr->ops->extra_init_hw) {
 		err = pcr->ops->extra_init_hw(pcr);
-		if (err < 0)
+		if (err < 0) {
+			pcr_err(pcr, "init extra hw\n");
 			return err;
+		}
 	}
 
 	/* No CD interrupt if probing driver with card inserted.
diff --git a/include/linux/mfd/rtsx_pci.h b/include/linux/mfd/rtsx_pci.h
index 0ce7721..a294951 100644
--- a/include/linux/mfd/rtsx_pci.h
+++ b/include/linux/mfd/rtsx_pci.h
@@ -915,6 +915,11 @@ struct rtsx_pcr {
 	struct rtsx_slot		*slots;
 };
 
+#define pcr_err(pcr, fmt, arg...)			\
+	dev_err(&(pcr)->pci->dev, "%s error: " fmt, __func__, ##arg)
+#define pcr_dbg(pcr, fmt, arg...)			\
+	dev_dbg(&(pcr)->pci->dev, "%s: " fmt, __func__, ##arg)
+
 #define CHK_PCI_PID(pcr, pid)		((pcr)->pci->device == (pid))
 #define PCI_VID(pcr)			((pcr)->pci->vendor)
 #define PCI_PID(pcr)			((pcr)->pci->device)
@@ -961,4 +966,17 @@ static inline u8 *rtsx_pci_get_cmd_data(struct rtsx_pcr *pcr)
 	return (u8 *)(pcr->host_cmds_ptr);
 }
 
+static inline int rtsx_pci_update_cfg_byte(struct rtsx_pcr *pcr, int addr,
+		u8 mask, u8 append)
+{
+	int err;
+	u8 val;
+
+	err = pci_read_config_byte(pcr->pci, addr, &val);
+	if (err)
+		return err;
+	err = pci_write_config_byte(pcr->pci, addr, (val & mask) | append);
+	return err;
+}
+
 #endif
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: Bug#757733: RTS2557 SD card reader does not work
  2014-08-11  6:45     ` 答复: " 王炜
@ 2015-01-11  0:09       ` Johannes Schauer
  2015-01-12  8:11         ` Johannes Schauer
  0 siblings, 1 reply; 5+ messages in thread
From: Johannes Schauer @ 2015-01-11  0:09 UTC (permalink / raw)
  To: wei_wang, phihag, ben; +Cc: 757733, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1010 bytes --]

Hi,

On Mon, 11 Aug 2014 06:45:24 +0000 <wei_wang@realsil.com.cn> wrote:
> Would you please try this patch. If it does work, we will submit it to upstream kernel.

I own a Lenovo Thinkpad T440s as well just as the original bug submitter
(Philipp) and that patch by Wei does not fix the problem for me (I applied it
to a 3.18 tree).

What does work is to follow Philipp's instructions to patch the out-of-tree
driver from realtek.com.tw. That module then gives me my SD card as /dev/sdbX.

Weirdly, my SD card reader used to work (but presented the SD card as
/dev/mmcblk0pX). I do not know why it stopped working though as I didn't reboot
my laptop for several months. Running an older kernel version (3.14 for
example) does not fix the problem. Maybe it is related to other parts of my
(Debian testing) OS. I'll see if I can find a Debian unstable snapshot that
restores the behaviour I observed last year and try to bisect to find the
source of the regression.

Thanks!

cheers, josch

[-- Attachment #2: signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAABCAAGBQJUsb8vAAoJEPLLpcePvYPhRDkP/3nq8SNabMVdXr6WQuE7SRV2
4ZehJ3IAM6uXIg9n4e8JCmWrWYrmwnOlz1O0vatXjyFgbizx2wUludiYMXUjblhS
aHlxSOxa7fgN3ILGRCKPBUauE/BmT/N4kRXVBNKC9FgRjaiARuViq8gIZ+++aNdL
rLnOiokvRQjdB2g9A7SMyMJXctR+SaCPHxQQLtgIUiDCCt6+lk8HCf91vVLHLSoo
GU3wW83ClKz43d2voWjpr1jrEF5bI4lYGM5CEp++IFgRYz031knWGS5o4m+90k0b
Ub0cmDrpSuZ9hQ3YUlGqlA54CNeRyDZtItUDMCeWee1hcqx/nwt5UWuzlmFa94+M
b9o637Xhd15apimEwwSbtpGU41Jh5p1OS85kdkDqPxDFvlq0ipHDNBVl8yjRtRFY
3PBELzrQdSS+QAXUaZh9hlWZ5dGYNtrmHUbVZhk6QSdAjIydawaTGdzTaMcYd7Fe
DpVx7C0EvImurIFNR5F2ubD6wlILpmJleZYQuGD6HD+nD/J+GoRRroHccvgNtAfh
x8Nxi8v9RNe4XTg75xKQVcTMB68tfpFmLwdVmC+z4jz7UjbyeNQKaAKol9szXn3v
t14asRbLZtvQHcOCV/UZ+bppzas86I/8TimDmDeQw29RC4H7fcHMEMnOYlDVEkG3
G6OiswJuL7fLKTbUXWYz
=sFMM
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Bug#757733: RTS2557 SD card reader does not work
  2015-01-11  0:09       ` Johannes Schauer
@ 2015-01-12  8:11         ` Johannes Schauer
  0 siblings, 0 replies; 5+ messages in thread
From: Johannes Schauer @ 2015-01-12  8:11 UTC (permalink / raw)
  To: wei_wang, phihag, ben; +Cc: 757733, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 3413 bytes --]

Hi,

On Sun, 11 Jan 2015 01:09:19 +0100 Johannes Schauer <j.schauer@email.de> wrote:
> Weirdly, my SD card reader used to work (but presented the SD card as
> /dev/mmcblk0pX). I do not know why it stopped working though as I didn't reboot
> my laptop for several months. Running an older kernel version (3.14 for
> example) does not fix the problem. Maybe it is related to other parts of my
> (Debian testing) OS. I'll see if I can find a Debian unstable snapshot that
> restores the behaviour I observed last year and try to bisect to find the
> source of the regression.

I spent the past two days trying to reproduce the problem and I'm unable to get
reliable results. Let me explain what I did.

 - December 20 I took a snapshot of my system (but without rebooting) at this
   time my T440s SD card reader worked fine and showed up as /dev/mmcblk0*
 - January 10 (three weeks later) I did a big `apt-get upgrade/dist-upgrade` to
   update all the packages to their Jessie or Sid versions, respectively and
   rebooted. The card reader didn't show up anymore. Nothing on dmesg when I
   inserted my sdcard which would before show me the new registered partitions
 - I put a Debian Sid debootstrap from January 1 2014 on a USB stick and booted
   that. Same thing, no SD card.
 - I put a Debian Sid debootstrap from January 1 2013 on a USB stick and booted
   that. Same thing, no SD card.
 - In the hopes that at least the snapshot from December 20 would work and
   somehow allow me to find out which package upgrade broke my system, I put
   this back on my harddisk and booted it. The SD card reader worked and was
   available as /dev/mmcblk0*
 - I upgraded step by step important packages like linux-image-amd64,
   initramfs, udev, while rebooting after every step. The system kept working.
 - I added /usr /bin /sbin /var /etc /boot and /lib to a git on my / so that I
   would always be able to quickly roll back everything and did `apt-get
   upgrade/dist-upgrade` for the rest of my system and rebooted. Everything
   kept working
 - So at this point I executed the same upgrade path which before made a system
   that was working not working but in this case the SD card reader kept
   working. I had no explanation as I didn't do anything different.
 - I put the prior non-working snapshot of my system from January 10 back which
   had all the upgrades already done. And surprise: this time it worked! The
   exact same hard disk image which before leads to my MMC card reader not
   showing up worked fine this time.
 - I installed Debian Jessie (with the daily installer from [1]) on a USB stick
   and booted that. My card reader keeps working
 - I put put a Debian Sid debootstrap from January 1 2014 on a USB stick and
   booted that (this wasn't working before, see above). This time it worked and
   I was able to mount my SD card.

What do you make from this?

Apparently there are situations where, with the exact same root file system (My
January 20 full snapshot and the January 1 2014 Debian Sid debootstrap) it at
some point did not work but then worked again.

How can this happen?

What else can I try?

Right now everything works and I'm not able to make it not-working again.
Thoughts?

cheers, josch

[1] http://cdimage.debian.org/cdimage/daily-builds/daily/arch-latest/amd64/iso-cd/debian-testing-amd64-netinst.iso

[-- Attachment #2: signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAABCAAGBQJUs4GlAAoJEPLLpcePvYPh1hcP/0Ba9nO9jDwgDm6xincrTajM
FYHF3sQKmIz3DibbMvoBQA3YePHy0PhZgbNUroNMI7OPefe7vQipvcFtFCYxXfsG
+bvLQ+FW4saHk0+1mHw27ozx211jXWW/g1xPejsaVBdlunCIM8bclCjUcJ0tXiPZ
Xd1ECbm8S32uPAhxd+SpWuLq/+EM/oy3x20fiOPW8QJ4Ik6Tt/T+vqY1ZMnmDlU9
VkjpXYZbIUCc26L923o69cDofIRdUUwbZU/OedR1uBD/N6RZe9LcV625pfuPPQB6
t5pdbIR00EwhF14G+JyIcXIpe2qCRneGLztN4jw8Y+nBxM1jltpzVF4qb3pLfXur
isrbCOYQ6JAcO/t735WF0aZaRzcsXaEiFnu/Tb92iZ6Y46o2fO3UvfLBQ7QGPTAr
vfT6vBmCapdccpqA/N7ueTs50UbrM/exX/id8kmo9mU1liVoI64AdArnH16iU5zw
Sn4QlwpIbDeBjV8oh9w05P/r9VjYmuH70eecjBGtAVhuND/dJBW/W34O16XvT+Li
d/n+zwfuLjHPq2bBHtAuNkUMI/B3wCrjNgM86KGB2FSfb2JcpvhWxM62AJ0MkmMQ
vzeTI60gV/ui/1pg9u/AZvhanttyI1G98cXBjbupb+n7U9nt0dHpIgDqmjdU1fTZ
jp4QdMpTisSBSKntrlqp
=gs15
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-01-12  8:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20140810225012.3425.19201.reportbug@t4.home.phihag.de>
2014-08-10 23:58 ` Bug#757733: RTS2557 SD card reader does not work Ben Hutchings
2014-08-11  1:10   ` Philipp Hagemeister
2014-08-11  6:45     ` 答复: " 王炜
2015-01-11  0:09       ` Johannes Schauer
2015-01-12  8:11         ` Johannes Schauer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.