* [PATCH 0/3] memstick: rtsx: finish request faster if no card exist
@ 2015-01-14 2:40 micky_ching
2015-01-14 2:40 ` [PATCH 1/3] memstick: rtsx: dump register using compact format micky_ching
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: micky_ching @ 2015-01-14 2:40 UTC (permalink / raw)
To: devel, linux-kernel
Cc: sameo, maximlevitsky, gregkh, oakad, rogerable, wei_wang,
Micky Ching
From: Micky Ching <micky_ching@realsil.com.cn>
This pathset include some misc coding update.
- dump register using compact format.
This prevent dump a lot of lines register dump when some error occurs.
- finish request if no card exist
check card exist before sending any request, When card removed,
request can returned much faster.
- move suspend/resume to pm ops
Move suspend/resume pm ops instead of driver.suspend/drivers.resume,
we tested in some case if we put it in driver.suspend/drivers.resume,
the function will not called.
Micky Ching (3):
memstick: rtsx: dump register using compact format
memstick: rtsx: finish request if no card exist
memstick: rtsx: move suspend/resume to pm ops
drivers/memstick/host/rtsx_pci_ms.c | 89 ++++++++++++++++++++-----------------
1 file changed, 49 insertions(+), 40 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] memstick: rtsx: dump register using compact format
2015-01-14 2:40 [PATCH 0/3] memstick: rtsx: finish request faster if no card exist micky_ching
@ 2015-01-14 2:40 ` micky_ching
2015-01-14 2:40 ` [PATCH 2/3] memstick: rtsx: finish request if no card exist micky_ching
2015-01-14 2:40 ` [PATCH 3/3] memstick: rtsx: move suspend/resume to pm ops micky_ching
2 siblings, 0 replies; 4+ messages in thread
From: micky_ching @ 2015-01-14 2:40 UTC (permalink / raw)
To: devel, linux-kernel
Cc: sameo, maximlevitsky, gregkh, oakad, rogerable, wei_wang,
Micky Ching
From: Micky Ching <micky_ching@realsil.com.cn>
Using more compact format for dump register when error occurs,
this is useful to read debug log and reduce log length.
Signed-off-by: Micky Ching <micky_ching@realsil.com.cn>
---
drivers/memstick/host/rtsx_pci_ms.c | 37 ++++++++++++++++++++-----------------
1 file changed, 20 insertions(+), 17 deletions(-)
diff --git a/drivers/memstick/host/rtsx_pci_ms.c b/drivers/memstick/host/rtsx_pci_ms.c
index 818fa94..baf94db 100644
--- a/drivers/memstick/host/rtsx_pci_ms.c
+++ b/drivers/memstick/host/rtsx_pci_ms.c
@@ -54,26 +54,29 @@ static inline void ms_clear_error(struct realtek_pci_ms *host)
}
#ifdef DEBUG
+static void dump_reg_range(struct realtek_pci_ms *host, u16 start, u16 end)
+{
+ u16 len = end - start + 1;
+ int i;
+ u8 data[8];
+
+ for (i = 0; i < len; i += 8) {
+ int j;
+ int n = min(8, len - i);
+
+ memset(&data, 0, sizeof(data));
+ for (j = 0; j < n; j++)
+ rtsx_pci_read_register(host->pcr, start + i + j,
+ data + j);
+ dev_dbg(ms_dev(host), "0x%04X(%d): %8ph\n",
+ start + i, n, data);
+ }
+}
static void ms_print_debug_regs(struct realtek_pci_ms *host)
{
- struct rtsx_pcr *pcr = host->pcr;
- u16 i;
- u8 *ptr;
-
- /* Print MS host internal registers */
- rtsx_pci_init_cmd(pcr);
- for (i = 0xFD40; i <= 0xFD44; i++)
- rtsx_pci_add_cmd(pcr, READ_REG_CMD, i, 0, 0);
- for (i = 0xFD52; i <= 0xFD69; i++)
- rtsx_pci_add_cmd(pcr, READ_REG_CMD, i, 0, 0);
- rtsx_pci_send_cmd(pcr, 100);
-
- ptr = rtsx_pci_get_cmd_data(pcr);
- for (i = 0xFD40; i <= 0xFD44; i++)
- dev_dbg(ms_dev(host), "0x%04X: 0x%02x\n", i, *(ptr++));
- for (i = 0xFD52; i <= 0xFD69; i++)
- dev_dbg(ms_dev(host), "0x%04X: 0x%02x\n", i, *(ptr++));
+ dump_reg_range(host, 0xFD40, 0xFD44);
+ dump_reg_range(host, 0xFD52, 0xFD69);
}
#else
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] memstick: rtsx: finish request if no card exist
2015-01-14 2:40 [PATCH 0/3] memstick: rtsx: finish request faster if no card exist micky_ching
2015-01-14 2:40 ` [PATCH 1/3] memstick: rtsx: dump register using compact format micky_ching
@ 2015-01-14 2:40 ` micky_ching
2015-01-14 2:40 ` [PATCH 3/3] memstick: rtsx: move suspend/resume to pm ops micky_ching
2 siblings, 0 replies; 4+ messages in thread
From: micky_ching @ 2015-01-14 2:40 UTC (permalink / raw)
To: devel, linux-kernel
Cc: sameo, maximlevitsky, gregkh, oakad, rogerable, wei_wang,
Micky Ching
From: Micky Ching <micky_ching@realsil.com.cn>
Check card exist before start request, this method can make card remove
faster. If we found the card is not exist, just return error-code,
not sending request can save much time.
Signed-off-by: Micky Ching <micky_ching@realsil.com.cn>
---
drivers/memstick/host/rtsx_pci_ms.c | 27 ++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/drivers/memstick/host/rtsx_pci_ms.c b/drivers/memstick/host/rtsx_pci_ms.c
index baf94db..c9981af 100644
--- a/drivers/memstick/host/rtsx_pci_ms.c
+++ b/drivers/memstick/host/rtsx_pci_ms.c
@@ -85,6 +85,11 @@ static void ms_print_debug_regs(struct realtek_pci_ms *host)
#endif
+static inline int ms_get_cd_int(struct realtek_pci_ms *host)
+{
+ return rtsx_pci_readl(host->pcr, RTSX_BIPR) & MS_EXIST;
+}
+
static int ms_power_on(struct realtek_pci_ms *host)
{
struct rtsx_pcr *pcr = host->pcr;
@@ -409,6 +414,9 @@ static void rtsx_pci_ms_handle_req(struct work_struct *work)
struct memstick_host *msh = host->msh;
int rc;
+ if (host->req)
+ return;
+
mutex_lock(&pcr->pcr_mutex);
rtsx_pci_start_run(pcr);
@@ -419,15 +427,16 @@ static void rtsx_pci_ms_handle_req(struct work_struct *work)
rtsx_pci_write_register(pcr, CARD_SHARE_MODE,
CARD_SHARE_MASK, CARD_SHARE_48_MS);
- if (!host->req) {
- do {
- rc = memstick_next_req(msh, &host->req);
- dev_dbg(ms_dev(host), "next req %d\n", rc);
-
- if (!rc)
- host->req->error = rtsx_pci_ms_issue_cmd(host);
- } while (!rc);
- }
+ while (true) {
+ rc = memstick_next_req(msh, &host->req);
+ dev_dbg(ms_dev(host), "next req %d\n", rc);
+ if (rc)
+ break;
+ if (!ms_get_cd_int(host))
+ host->req->error = -ENOMEDIUM;
+ else
+ host->req->error = rtsx_pci_ms_issue_cmd(host);
+ };
mutex_unlock(&pcr->pcr_mutex);
}
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] memstick: rtsx: move suspend/resume to pm ops
2015-01-14 2:40 [PATCH 0/3] memstick: rtsx: finish request faster if no card exist micky_ching
2015-01-14 2:40 ` [PATCH 1/3] memstick: rtsx: dump register using compact format micky_ching
2015-01-14 2:40 ` [PATCH 2/3] memstick: rtsx: finish request if no card exist micky_ching
@ 2015-01-14 2:40 ` micky_ching
2 siblings, 0 replies; 4+ messages in thread
From: micky_ching @ 2015-01-14 2:40 UTC (permalink / raw)
To: devel, linux-kernel
Cc: sameo, maximlevitsky, gregkh, oakad, rogerable, wei_wang,
Micky Ching
From: Micky Ching <micky_ching@realsil.com.cn>
Move suspend/resume function to pm ops, make it consistence
with rtsx_usb_ms.c driver.
Signed-off-by: Micky Ching <micky_ching@realsil.com.cn>
---
drivers/memstick/host/rtsx_pci_ms.c | 25 +++++++++++--------------
1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/drivers/memstick/host/rtsx_pci_ms.c b/drivers/memstick/host/rtsx_pci_ms.c
index c9981af..475afa8 100644
--- a/drivers/memstick/host/rtsx_pci_ms.c
+++ b/drivers/memstick/host/rtsx_pci_ms.c
@@ -22,6 +22,7 @@
#include <linux/module.h>
#include <linux/highmem.h>
#include <linux/delay.h>
+#include <linux/pm.h>
#include <linux/platform_device.h>
#include <linux/memstick.h>
#include <linux/mfd/rtsx_pci.h>
@@ -514,11 +515,11 @@ static int rtsx_pci_ms_set_param(struct memstick_host *msh,
return 0;
}
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
-static int rtsx_pci_ms_suspend(struct platform_device *pdev, pm_message_t state)
+static int rtsx_pci_ms_suspend(struct device *dev)
{
- struct realtek_pci_ms *host = platform_get_drvdata(pdev);
+ struct realtek_pci_ms *host = dev_get_drvdata(dev);
struct memstick_host *msh = host->msh;
dev_dbg(ms_dev(host), "--> %s\n", __func__);
@@ -527,9 +528,9 @@ static int rtsx_pci_ms_suspend(struct platform_device *pdev, pm_message_t state)
return 0;
}
-static int rtsx_pci_ms_resume(struct platform_device *pdev)
+static int rtsx_pci_ms_resume(struct device *dev)
{
- struct realtek_pci_ms *host = platform_get_drvdata(pdev);
+ struct realtek_pci_ms *host = dev_get_drvdata(dev);
struct memstick_host *msh = host->msh;
dev_dbg(ms_dev(host), "--> %s\n", __func__);
@@ -537,13 +538,7 @@ static int rtsx_pci_ms_resume(struct platform_device *pdev)
memstick_resume_host(msh);
return 0;
}
-
-#else /* CONFIG_PM */
-
-#define rtsx_pci_ms_suspend NULL
-#define rtsx_pci_ms_resume NULL
-
-#endif /* CONFIG_PM */
+#endif /* CONFIG_PM_SLEEP */
static void rtsx_pci_ms_card_event(struct platform_device *pdev)
{
@@ -641,6 +636,9 @@ static int rtsx_pci_ms_drv_remove(struct platform_device *pdev)
return 0;
}
+static SIMPLE_DEV_PM_OPS(rtsx_pci_ms_pm_ops,
+ rtsx_pci_ms_suspend, rtsx_pci_ms_resume);
+
static struct platform_device_id rtsx_pci_ms_ids[] = {
{
.name = DRV_NAME_RTSX_PCI_MS,
@@ -654,10 +652,9 @@ static struct platform_driver rtsx_pci_ms_driver = {
.probe = rtsx_pci_ms_drv_probe,
.remove = rtsx_pci_ms_drv_remove,
.id_table = rtsx_pci_ms_ids,
- .suspend = rtsx_pci_ms_suspend,
- .resume = rtsx_pci_ms_resume,
.driver = {
.name = DRV_NAME_RTSX_PCI_MS,
+ .pm = &rtsx_pci_ms_pm_ops,
},
};
module_platform_driver(rtsx_pci_ms_driver);
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-01-14 2:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-14 2:40 [PATCH 0/3] memstick: rtsx: finish request faster if no card exist micky_ching
2015-01-14 2:40 ` [PATCH 1/3] memstick: rtsx: dump register using compact format micky_ching
2015-01-14 2:40 ` [PATCH 2/3] memstick: rtsx: finish request if no card exist micky_ching
2015-01-14 2:40 ` [PATCH 3/3] memstick: rtsx: move suspend/resume to pm ops micky_ching
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox