public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] mmc: rtsx: add check before sending request
@ 2015-01-14  3:09 micky_ching
  2015-01-14  3:09 ` [PATCH 1/2] mmc: rtsx: finish request if no card exist micky_ching
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: micky_ching @ 2015-01-14  3:09 UTC (permalink / raw)
  To: chris, ulf.hansson, sameo
  Cc: gregkh, dan.carpenter, devel, linux-kernel, linux-mmc, rogerable,
	wei_wang, Micky Ching

From: Micky Ching <micky_ching@realsil.com.cn>

Add check before sending request can make request return faster.
- finish request if no card exist
  This can make request finish faster, especial for some sdio card,
  when card removed, there still a lot of command pending,
  if we check card exist and stop request, the card will disappear
  faster in user space.

- check sg_count before long data xfer
  modify sg_count type unsigned -> int, because dma_map_sg() return
  int, and this value can be negative to indicate some error occurs.

Micky Ching (2):
  mmc: rtsx: finish request if no card exist
  mmc: rtsx: check sg_count before long data xfer

 drivers/mmc/host/rtsx_pci_sdmmc.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

-- 
1.9.1


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

* [PATCH 1/2] mmc: rtsx: finish request if no card exist
  2015-01-14  3:09 [PATCH 0/2] mmc: rtsx: add check before sending request micky_ching
@ 2015-01-14  3:09 ` micky_ching
  2015-01-14  3:09 ` [PATCH 2/2] mmc: rtsx: check sg_count before long data xfer micky_ching
  2015-01-21 12:59 ` [PATCH 0/2] mmc: rtsx: add check before sending request Ulf Hansson
  2 siblings, 0 replies; 4+ messages in thread
From: micky_ching @ 2015-01-14  3:09 UTC (permalink / raw)
  To: chris, ulf.hansson, sameo
  Cc: gregkh, dan.carpenter, devel, linux-kernel, linux-mmc, rogerable,
	wei_wang, Micky Ching

From: Micky Ching <micky_ching@realsil.com.cn>

Return error-code directly if no card exist, this can
make card remove faster.

Signed-off-by: Micky Ching <micky_ching@realsil.com.cn>
---
 drivers/mmc/host/rtsx_pci_sdmmc.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c b/drivers/mmc/host/rtsx_pci_sdmmc.c
index 26c6a7c..b435806 100644
--- a/drivers/mmc/host/rtsx_pci_sdmmc.c
+++ b/drivers/mmc/host/rtsx_pci_sdmmc.c
@@ -100,6 +100,11 @@ static void sd_print_debug_regs(struct realtek_pci_sdmmc *host)
 #define sd_print_debug_regs(host)
 #endif /* DEBUG */
 
+static inline int sd_get_cd_int(struct realtek_pci_sdmmc *host)
+{
+	return rtsx_pci_readl(host->pcr, RTSX_BIPR) & SD_EXIST;
+}
+
 static void sd_cmd_set_sd_cmd(struct rtsx_pcr *pcr, struct mmc_command *cmd)
 {
 	rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_CMD0, 0xFF,
@@ -798,7 +803,7 @@ static void sd_request(struct work_struct *work)
 	unsigned int data_size = 0;
 	int err;
 
-	if (host->eject) {
+	if (host->eject || !sd_get_cd_int(host)) {
 		cmd->error = -ENOMEDIUM;
 		goto finish;
 	}
@@ -1116,7 +1121,7 @@ static int sdmmc_get_cd(struct mmc_host *mmc)
 	u32 val;
 
 	if (host->eject)
-		return -ENOMEDIUM;
+		return cd;
 
 	mutex_lock(&pcr->pcr_mutex);
 
-- 
1.9.1


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

* [PATCH 2/2] mmc: rtsx: check sg_count before long data xfer
  2015-01-14  3:09 [PATCH 0/2] mmc: rtsx: add check before sending request micky_ching
  2015-01-14  3:09 ` [PATCH 1/2] mmc: rtsx: finish request if no card exist micky_ching
@ 2015-01-14  3:09 ` micky_ching
  2015-01-21 12:59 ` [PATCH 0/2] mmc: rtsx: add check before sending request Ulf Hansson
  2 siblings, 0 replies; 4+ messages in thread
From: micky_ching @ 2015-01-14  3:09 UTC (permalink / raw)
  To: chris, ulf.hansson, sameo
  Cc: gregkh, dan.carpenter, devel, linux-kernel, linux-mmc, rogerable,
	wei_wang, Micky Ching

From: Micky Ching <micky_ching@realsil.com.cn>

Check sg_count before sending long data xfer.
Because dma_map_sg() return int, and sg_count may be negative,
so using int instead of unsigned.

Signed-off-by: Micky Ching <micky_ching@realsil.com.cn>
---
 drivers/mmc/host/rtsx_pci_sdmmc.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c b/drivers/mmc/host/rtsx_pci_sdmmc.c
index b435806..1d3d6c4 100644
--- a/drivers/mmc/host/rtsx_pci_sdmmc.c
+++ b/drivers/mmc/host/rtsx_pci_sdmmc.c
@@ -54,9 +54,9 @@ struct realtek_pci_sdmmc {
 #define SDMMC_POWER_ON		1
 #define SDMMC_POWER_OFF		0
 
-	unsigned int		sg_count;
+	int			sg_count;
 	s32			cookie;
-	unsigned int		cookie_sg_count;
+	int			cookie_sg_count;
 	bool			using_cookie;
 };
 
@@ -557,6 +557,13 @@ static int sd_rw_multi(struct realtek_pci_sdmmc *host, struct mmc_request *mrq)
 {
 	struct mmc_data *data = mrq->data;
 
+	if (host->sg_count < 0) {
+		data->error = host->sg_count;
+		dev_dbg(sdmmc_dev(host), "%s: sg_count = %d is invalid\n",
+			__func__, host->sg_count);
+		return data->error;
+	}
+
 	if (data->flags & MMC_DATA_READ)
 		return sd_read_long_data(host, mrq);
 
-- 
1.9.1


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

* Re: [PATCH 0/2] mmc: rtsx: add check before sending request
  2015-01-14  3:09 [PATCH 0/2] mmc: rtsx: add check before sending request micky_ching
  2015-01-14  3:09 ` [PATCH 1/2] mmc: rtsx: finish request if no card exist micky_ching
  2015-01-14  3:09 ` [PATCH 2/2] mmc: rtsx: check sg_count before long data xfer micky_ching
@ 2015-01-21 12:59 ` Ulf Hansson
  2 siblings, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2015-01-21 12:59 UTC (permalink / raw)
  To: micky
  Cc: Chris Ball, Samuel Ortiz, Greg Kroah-Hartman, Dan Carpenter,
	driverdev-devel@linuxdriverproject.org,
	linux-kernel@vger.kernel.org, linux-mmc, Roger, Wei WANG

On 14 January 2015 at 04:09,  <micky_ching@realsil.com.cn> wrote:
> From: Micky Ching <micky_ching@realsil.com.cn>
>
> Add check before sending request can make request return faster.
> - finish request if no card exist
>   This can make request finish faster, especial for some sdio card,
>   when card removed, there still a lot of command pending,
>   if we check card exist and stop request, the card will disappear
>   faster in user space.
>
> - check sg_count before long data xfer
>   modify sg_count type unsigned -> int, because dma_map_sg() return
>   int, and this value can be negative to indicate some error occurs.
>
> Micky Ching (2):
>   mmc: rtsx: finish request if no card exist
>   mmc: rtsx: check sg_count before long data xfer
>
>  drivers/mmc/host/rtsx_pci_sdmmc.c | 20 ++++++++++++++++----
>  1 file changed, 16 insertions(+), 4 deletions(-)
>
> --
> 1.9.1
>

Thanks! Applied for next.

Kind regards
Uffe

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

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

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-14  3:09 [PATCH 0/2] mmc: rtsx: add check before sending request micky_ching
2015-01-14  3:09 ` [PATCH 1/2] mmc: rtsx: finish request if no card exist micky_ching
2015-01-14  3:09 ` [PATCH 2/2] mmc: rtsx: check sg_count before long data xfer micky_ching
2015-01-21 12:59 ` [PATCH 0/2] mmc: rtsx: add check before sending request Ulf Hansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox