mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v4] mfd:rtsx: do retry when DMA transfer error
@ 2017-04-26  2:46 steven_feng
  2017-04-26  3:05 ` 冯伟linux
  2017-05-22 10:14 ` Lee Jones
  0 siblings, 2 replies; 5+ messages in thread
From: steven_feng @ 2017-04-26  2:46 UTC (permalink / raw)
  To: lee.jones; +Cc: linux-kernel, Steven Feng

From: Steven Feng <steven_feng@realsil.com.cn>

The request should be resent when DMA transfer error occurred.
For rts5227, the clock rate needs to be reduced when error occurred.

Signed-off-by: Steven Feng <steven_feng@realsil.com.cn>
---
 drivers/mfd/rtsx_pcr.c       | 18 ++++++++++++++++--
 include/linux/mfd/rtsx_pci.h |  5 +++++
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/rtsx_pcr.c b/drivers/mfd/rtsx_pcr.c
index 98029ee..8e21fd6 100644
--- a/drivers/mfd/rtsx_pcr.c
+++ b/drivers/mfd/rtsx_pcr.c
@@ -30,6 +30,7 @@
 #include <linux/platform_device.h>
 #include <linux/mfd/core.h>
 #include <linux/mfd/rtsx_pci.h>
+#include <linux/mmc/card.h>
 #include <asm/unaligned.h>
 
 #include "rtsx_pcr.h"
@@ -452,8 +453,12 @@ int rtsx_pci_dma_transfer(struct rtsx_pcr *pcr, struct scatterlist *sglist,
 	}
 
 	spin_lock_irqsave(&pcr->lock, flags);
-	if (pcr->trans_result == TRANS_RESULT_FAIL)
-		err = -EINVAL;
+	if (pcr->trans_result == TRANS_RESULT_FAIL) {
+		err = -EILSEQ;
+		if (pcr->dma_error_count < RTS_MAX_TIMES_FREQ_REDUCTION)
+			pcr->dma_error_count++;
+	}
+
 	else if (pcr->trans_result == TRANS_NO_DEVICE)
 		err = -ENODEV;
 	spin_unlock_irqrestore(&pcr->lock, flags);
@@ -659,6 +664,14 @@ int rtsx_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock,
 	if (err < 0)
 		return err;
 
+	/* Reduce MMC card clock by 20MHz each time a DMA transfer error occurs
+	 */
+	if (card_clock == UHS_SDR104_MAX_DTR &&
+		pcr->dma_error_count &&
+		PCI_PID(pcr) == RTS5227_DEVICE_ID)
+		card_clock = UHS_SDR104_MAX_DTR -
+			(pcr->dma_error_count * 20000000);
+
 	card_clock /= 1000000;
 	pcr_dbg(pcr, "Switch card clock to %dMHz\n", card_clock);
 
@@ -894,6 +907,7 @@ static irqreturn_t rtsx_pci_isr(int irq, void *dev_id)
 			pcr->card_removed |= SD_EXIST;
 			pcr->card_inserted &= ~SD_EXIST;
 		}
+		pcr->dma_error_count = 0;
 	}
 
 	if (int_reg & MS_INT) {
diff --git a/include/linux/mfd/rtsx_pci.h b/include/linux/mfd/rtsx_pci.h
index 7eb7cba..116816f 100644
--- a/include/linux/mfd/rtsx_pci.h
+++ b/include/linux/mfd/rtsx_pci.h
@@ -850,6 +850,9 @@
 
 #define rtsx_pci_init_cmd(pcr)		((pcr)->ci = 0)
 
+#define RTS5227_DEVICE_ID		0x5227
+#define RTS_MAX_TIMES_FREQ_REDUCTION	8
+
 struct rtsx_pcr;
 
 struct pcr_handle {
@@ -957,6 +960,8 @@ struct rtsx_pcr {
 
 	int				num_slots;
 	struct rtsx_slot		*slots;
+
+	u8				dma_error_count;
 };
 
 #define CHK_PCI_PID(pcr, pid)		((pcr)->pci->device == (pid))
-- 
1.9.1

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

* Re: [PATCH v4] mfd:rtsx: do retry when DMA transfer error
  2017-04-26  2:46 [PATCH v4] mfd:rtsx: do retry when DMA transfer error steven_feng
@ 2017-04-26  3:05 ` 冯伟linux
  2017-04-26  8:51   ` Lee Jones
  2017-05-22 10:14 ` Lee Jones
  1 sibling, 1 reply; 5+ messages in thread
From: 冯伟linux @ 2017-04-26  3:05 UTC (permalink / raw)
  To: lee.jones; +Cc: linux-kernel

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

Hi lee.jones:
    I have just now resented the patch V4, please review it.


steven feng
Realsil Microelectronics CO. LTD.
Mobile:181-6899-0403  Ext:57594

On 2017年04月26日 10:47, 冯伟linux wrote:
> From: Steven Feng <steven_feng@realsil.com.cn>
>
> The request should be resent when DMA transfer error occurred.
> For rts5227, the clock rate needs to be reduced when error occurred.
>
> Signed-off-by: Steven Feng <steven_feng@realsil.com.cn>
> ---
>  drivers/mfd/rtsx_pcr.c       | 18 ++++++++++++++++--
>  include/linux/mfd/rtsx_pci.h |  5 +++++
>  2 files changed, 21 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mfd/rtsx_pcr.c b/drivers/mfd/rtsx_pcr.c
> index 98029ee..8e21fd6 100644
> --- a/drivers/mfd/rtsx_pcr.c
> +++ b/drivers/mfd/rtsx_pcr.c
> @@ -30,6 +30,7 @@
>  #include <linux/platform_device.h>
>  #include <linux/mfd/core.h>
>  #include <linux/mfd/rtsx_pci.h>
> +#include <linux/mmc/card.h>
>  #include <asm/unaligned.h>
>  
>  #include "rtsx_pcr.h"
> @@ -452,8 +453,12 @@ int rtsx_pci_dma_transfer(struct rtsx_pcr *pcr, struct scatterlist *sglist,
>  	}
>  
>  	spin_lock_irqsave(&pcr->lock, flags);
> -	if (pcr->trans_result == TRANS_RESULT_FAIL)
> -		err = -EINVAL;
> +	if (pcr->trans_result == TRANS_RESULT_FAIL) {
> +		err = -EILSEQ;
> +		if (pcr->dma_error_count < RTS_MAX_TIMES_FREQ_REDUCTION)
> +			pcr->dma_error_count++;
> +	}
> +
>  	else if (pcr->trans_result == TRANS_NO_DEVICE)
>  		err = -ENODEV;
>  	spin_unlock_irqrestore(&pcr->lock, flags);
> @@ -659,6 +664,14 @@ int rtsx_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock,
>  	if (err < 0)
>  		return err;
>  
> +	/* Reduce MMC card clock by 20MHz each time a DMA transfer error occurs
> +	 */
> +	if (card_clock == UHS_SDR104_MAX_DTR &&
> +		pcr->dma_error_count &&
> +		PCI_PID(pcr) == RTS5227_DEVICE_ID)
> +		card_clock = UHS_SDR104_MAX_DTR -
> +			(pcr->dma_error_count * 20000000);
> +
>  	card_clock /= 1000000;
>  	pcr_dbg(pcr, "Switch card clock to %dMHz\n", card_clock);
>  
> @@ -894,6 +907,7 @@ static irqreturn_t rtsx_pci_isr(int irq, void *dev_id)
>  			pcr->card_removed |= SD_EXIST;
>  			pcr->card_inserted &= ~SD_EXIST;
>  		}
> +		pcr->dma_error_count = 0;
>  	}
>  
>  	if (int_reg & MS_INT) {
> diff --git a/include/linux/mfd/rtsx_pci.h b/include/linux/mfd/rtsx_pci.h
> index 7eb7cba..116816f 100644
> --- a/include/linux/mfd/rtsx_pci.h
> +++ b/include/linux/mfd/rtsx_pci.h
> @@ -850,6 +850,9 @@
>  
>  #define rtsx_pci_init_cmd(pcr)		((pcr)->ci = 0)
>  
> +#define RTS5227_DEVICE_ID		0x5227
> +#define RTS_MAX_TIMES_FREQ_REDUCTION	8
> +
>  struct rtsx_pcr;
>  
>  struct pcr_handle {
> @@ -957,6 +960,8 @@ struct rtsx_pcr {
>  
>  	int				num_slots;
>  	struct rtsx_slot		*slots;
> +
> +	u8				dma_error_count;
>  };
>  
>  #define CHK_PCI_PID(pcr, pid)		((pcr)->pci->device == (pid))


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: steven_feng.vcf --]
[-- Type: text/x-vcard; name="steven_feng.vcf", Size: 184 bytes --]

begin:vcard
fn;quoted-printable:=E5=86=AF=E4=BC=9F
n;quoted-printable:;=E5=86=AF=E4=BC=9F
email;internet:steven_feng@realsil.com.cn
tel;cell:18168990403
version:2.1
end:vcard


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

* Re: [PATCH v4] mfd:rtsx: do retry when DMA transfer error
  2017-04-26  3:05 ` 冯伟linux
@ 2017-04-26  8:51   ` Lee Jones
  0 siblings, 0 replies; 5+ messages in thread
From: Lee Jones @ 2017-04-26  8:51 UTC (permalink / raw)
  To: 冯伟linux; +Cc: linux-kernel

On Wed, 26 Apr 2017, 冯伟linux wrote:

> Hi lee.jones:
>     I have just now resented the patch V4, please review it.

Please don't sent chaser emails.

Especially demanding ones sent within hours/minutes of the patch.

> steven feng
> Realsil Microelectronics CO. LTD.
> Mobile:181-6899-0403  Ext:57594
> 
> On 2017年04月26日 10:47, 冯伟linux wrote:
> > From: Steven Feng <steven_feng@realsil.com.cn>
> >
> > The request should be resent when DMA transfer error occurred.
> > For rts5227, the clock rate needs to be reduced when error occurred.
> >
> > Signed-off-by: Steven Feng <steven_feng@realsil.com.cn>
> > ---
> >  drivers/mfd/rtsx_pcr.c       | 18 ++++++++++++++++--
> >  include/linux/mfd/rtsx_pci.h |  5 +++++
> >  2 files changed, 21 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/mfd/rtsx_pcr.c b/drivers/mfd/rtsx_pcr.c
> > index 98029ee..8e21fd6 100644
> > --- a/drivers/mfd/rtsx_pcr.c
> > +++ b/drivers/mfd/rtsx_pcr.c
> > @@ -30,6 +30,7 @@
> >  #include <linux/platform_device.h>
> >  #include <linux/mfd/core.h>
> >  #include <linux/mfd/rtsx_pci.h>
> > +#include <linux/mmc/card.h>
> >  #include <asm/unaligned.h>
> >  
> >  #include "rtsx_pcr.h"
> > @@ -452,8 +453,12 @@ int rtsx_pci_dma_transfer(struct rtsx_pcr *pcr, struct scatterlist *sglist,
> >  	}
> >  
> >  	spin_lock_irqsave(&pcr->lock, flags);
> > -	if (pcr->trans_result == TRANS_RESULT_FAIL)
> > -		err = -EINVAL;
> > +	if (pcr->trans_result == TRANS_RESULT_FAIL) {
> > +		err = -EILSEQ;
> > +		if (pcr->dma_error_count < RTS_MAX_TIMES_FREQ_REDUCTION)
> > +			pcr->dma_error_count++;
> > +	}
> > +
> >  	else if (pcr->trans_result == TRANS_NO_DEVICE)
> >  		err = -ENODEV;
> >  	spin_unlock_irqrestore(&pcr->lock, flags);
> > @@ -659,6 +664,14 @@ int rtsx_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock,
> >  	if (err < 0)
> >  		return err;
> >  
> > +	/* Reduce MMC card clock by 20MHz each time a DMA transfer error occurs
> > +	 */
> > +	if (card_clock == UHS_SDR104_MAX_DTR &&
> > +		pcr->dma_error_count &&
> > +		PCI_PID(pcr) == RTS5227_DEVICE_ID)
> > +		card_clock = UHS_SDR104_MAX_DTR -
> > +			(pcr->dma_error_count * 20000000);
> > +
> >  	card_clock /= 1000000;
> >  	pcr_dbg(pcr, "Switch card clock to %dMHz\n", card_clock);
> >  
> > @@ -894,6 +907,7 @@ static irqreturn_t rtsx_pci_isr(int irq, void *dev_id)
> >  			pcr->card_removed |= SD_EXIST;
> >  			pcr->card_inserted &= ~SD_EXIST;
> >  		}
> > +		pcr->dma_error_count = 0;
> >  	}
> >  
> >  	if (int_reg & MS_INT) {
> > diff --git a/include/linux/mfd/rtsx_pci.h b/include/linux/mfd/rtsx_pci.h
> > index 7eb7cba..116816f 100644
> > --- a/include/linux/mfd/rtsx_pci.h
> > +++ b/include/linux/mfd/rtsx_pci.h
> > @@ -850,6 +850,9 @@
> >  
> >  #define rtsx_pci_init_cmd(pcr)		((pcr)->ci = 0)
> >  
> > +#define RTS5227_DEVICE_ID		0x5227
> > +#define RTS_MAX_TIMES_FREQ_REDUCTION	8
> > +
> >  struct rtsx_pcr;
> >  
> >  struct pcr_handle {
> > @@ -957,6 +960,8 @@ struct rtsx_pcr {
> >  
> >  	int				num_slots;
> >  	struct rtsx_slot		*slots;
> > +
> > +	u8				dma_error_count;
> >  };
> >  
> >  #define CHK_PCI_PID(pcr, pid)		((pcr)->pci->device == (pid))
> 

> begin:vcard
> fn;quoted-printable:=E5=86=AF=E4=BC=9F
> n;quoted-printable:;=E5=86=AF=E4=BC=9F
> email;internet:steven_feng@realsil.com.cn
> tel;cell:18168990403
> version:2.1
> end:vcard
> 


-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH v4] mfd:rtsx: do retry when DMA transfer error
  2017-04-26  2:46 [PATCH v4] mfd:rtsx: do retry when DMA transfer error steven_feng
  2017-04-26  3:05 ` 冯伟linux
@ 2017-05-22 10:14 ` Lee Jones
  1 sibling, 0 replies; 5+ messages in thread
From: Lee Jones @ 2017-05-22 10:14 UTC (permalink / raw)
  To: steven_feng; +Cc: linux-kernel

On Wed, 26 Apr 2017, steven_feng@realsil.com.cn wrote:

> From: Steven Feng <steven_feng@realsil.com.cn>
> 
> The request should be resent when DMA transfer error occurred.
> For rts5227, the clock rate needs to be reduced when error occurred.
> 
> Signed-off-by: Steven Feng <steven_feng@realsil.com.cn>
> ---
>  drivers/mfd/rtsx_pcr.c       | 18 ++++++++++++++++--
>  include/linux/mfd/rtsx_pci.h |  5 +++++
>  2 files changed, 21 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mfd/rtsx_pcr.c b/drivers/mfd/rtsx_pcr.c
> index 98029ee..8e21fd6 100644
> --- a/drivers/mfd/rtsx_pcr.c
> +++ b/drivers/mfd/rtsx_pcr.c
> @@ -30,6 +30,7 @@
>  #include <linux/platform_device.h>
>  #include <linux/mfd/core.h>
>  #include <linux/mfd/rtsx_pci.h>
> +#include <linux/mmc/card.h>
>  #include <asm/unaligned.h>
>  
>  #include "rtsx_pcr.h"
> @@ -452,8 +453,12 @@ int rtsx_pci_dma_transfer(struct rtsx_pcr *pcr, struct scatterlist *sglist,
>  	}
>  
>  	spin_lock_irqsave(&pcr->lock, flags);
> -	if (pcr->trans_result == TRANS_RESULT_FAIL)
> -		err = -EINVAL;
> +	if (pcr->trans_result == TRANS_RESULT_FAIL) {
> +		err = -EILSEQ;
> +		if (pcr->dma_error_count < RTS_MAX_TIMES_FREQ_REDUCTION)
> +			pcr->dma_error_count++;
> +	}
> +
>  	else if (pcr->trans_result == TRANS_NO_DEVICE)
>  		err = -ENODEV;
>  	spin_unlock_irqrestore(&pcr->lock, flags);
> @@ -659,6 +664,14 @@ int rtsx_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock,
>  	if (err < 0)
>  		return err;
>  
> +	/* Reduce MMC card clock by 20MHz each time a DMA transfer error occurs
> +	 */

This is not a correctly formatted multi-line comment in the kernel.

Reword and make it a single line comment.

> +	if (card_clock == UHS_SDR104_MAX_DTR &&
> +		pcr->dma_error_count &&
> +		PCI_PID(pcr) == RTS5227_DEVICE_ID)

It would be nicer if these aligned after the '('.

> +		card_clock = UHS_SDR104_MAX_DTR -
> +			(pcr->dma_error_count * 20000000);
>  
>  	card_clock /= 1000000;
>  	pcr_dbg(pcr, "Switch card clock to %dMHz\n", card_clock);
>  
> @@ -894,6 +907,7 @@ static irqreturn_t rtsx_pci_isr(int irq, void *dev_id)
>  			pcr->card_removed |= SD_EXIST;
>  			pcr->card_inserted &= ~SD_EXIST;
>  		}
> +		pcr->dma_error_count = 0;
>  	}
>  
>  	if (int_reg & MS_INT) {
> diff --git a/include/linux/mfd/rtsx_pci.h b/include/linux/mfd/rtsx_pci.h
> index 7eb7cba..116816f 100644
> --- a/include/linux/mfd/rtsx_pci.h
> +++ b/include/linux/mfd/rtsx_pci.h
> @@ -850,6 +850,9 @@
>  
>  #define rtsx_pci_init_cmd(pcr)		((pcr)->ci = 0)
>  
> +#define RTS5227_DEVICE_ID		0x5227
> +#define RTS_MAX_TIMES_FREQ_REDUCTION	8
> +
>  struct rtsx_pcr;
>  
>  struct pcr_handle {
> @@ -957,6 +960,8 @@ struct rtsx_pcr {
>  
>  	int				num_slots;
>  	struct rtsx_slot		*slots;
> +
> +	u8				dma_error_count;
>  };
>  
>  #define CHK_PCI_PID(pcr, pid)		((pcr)->pci->device == (pid))

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* [PATCH v4] mfd:rtsx: do retry when DMA transfer error
@ 2017-04-10  9:29 steven_feng
  0 siblings, 0 replies; 5+ messages in thread
From: steven_feng @ 2017-04-10  9:29 UTC (permalink / raw)
  To: lee.jones; +Cc: linux-kernel, Steven Feng

From: Steven Feng <steven_feng@realsil.com.cn>

The request should be resent when DMA transfer error occurred.
For rts5227, the clock rate needs to be reduced when error occurred.

Signed-off-by: Steven Feng <steven_feng@realsil.com.cn>
---
 drivers/mfd/rtsx_pcr.c       | 18 ++++++++++++++++--
 include/linux/mfd/rtsx_pci.h |  5 +++++
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/rtsx_pcr.c b/drivers/mfd/rtsx_pcr.c
index 98029ee..8e21fd6 100644
--- a/drivers/mfd/rtsx_pcr.c
+++ b/drivers/mfd/rtsx_pcr.c
@@ -30,6 +30,7 @@
 #include <linux/platform_device.h>
 #include <linux/mfd/core.h>
 #include <linux/mfd/rtsx_pci.h>
+#include <linux/mmc/card.h>
 #include <asm/unaligned.h>
 
 #include "rtsx_pcr.h"
@@ -452,8 +453,12 @@ int rtsx_pci_dma_transfer(struct rtsx_pcr *pcr, struct scatterlist *sglist,
 	}
 
 	spin_lock_irqsave(&pcr->lock, flags);
-	if (pcr->trans_result == TRANS_RESULT_FAIL)
-		err = -EINVAL;
+	if (pcr->trans_result == TRANS_RESULT_FAIL) {
+		err = -EILSEQ;
+		if (pcr->dma_error_count < RTS_MAX_TIMES_FREQ_REDUCTION)
+			pcr->dma_error_count++;
+	}
+
 	else if (pcr->trans_result == TRANS_NO_DEVICE)
 		err = -ENODEV;
 	spin_unlock_irqrestore(&pcr->lock, flags);
@@ -659,6 +664,14 @@ int rtsx_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock,
 	if (err < 0)
 		return err;
 
+	/* Reduce MMC card clock by 20MHz each time a DMA transfer error occurs
+	 */
+	if (card_clock == UHS_SDR104_MAX_DTR &&
+		pcr->dma_error_count &&
+		PCI_PID(pcr) == RTS5227_DEVICE_ID)
+		card_clock = UHS_SDR104_MAX_DTR -
+			(pcr->dma_error_count * 20000000);
+
 	card_clock /= 1000000;
 	pcr_dbg(pcr, "Switch card clock to %dMHz\n", card_clock);
 
@@ -894,6 +907,7 @@ static irqreturn_t rtsx_pci_isr(int irq, void *dev_id)
 			pcr->card_removed |= SD_EXIST;
 			pcr->card_inserted &= ~SD_EXIST;
 		}
+		pcr->dma_error_count = 0;
 	}
 
 	if (int_reg & MS_INT) {
diff --git a/include/linux/mfd/rtsx_pci.h b/include/linux/mfd/rtsx_pci.h
index 7eb7cba..116816f 100644
--- a/include/linux/mfd/rtsx_pci.h
+++ b/include/linux/mfd/rtsx_pci.h
@@ -850,6 +850,9 @@
 
 #define rtsx_pci_init_cmd(pcr)		((pcr)->ci = 0)
 
+#define RTS5227_DEVICE_ID		0x5227
+#define RTS_MAX_TIMES_FREQ_REDUCTION	8
+
 struct rtsx_pcr;
 
 struct pcr_handle {
@@ -957,6 +960,8 @@ struct rtsx_pcr {
 
 	int				num_slots;
 	struct rtsx_slot		*slots;
+
+	u8				dma_error_count;
 };
 
 #define CHK_PCI_PID(pcr, pid)		((pcr)->pci->device == (pid))
-- 
1.9.1

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

end of thread, other threads:[~2017-05-22 10:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-26  2:46 [PATCH v4] mfd:rtsx: do retry when DMA transfer error steven_feng
2017-04-26  3:05 ` 冯伟linux
2017-04-26  8:51   ` Lee Jones
2017-05-22 10:14 ` Lee Jones
  -- strict thread matches above, loose matches on Subject: below --
2017-04-10  9:29 steven_feng

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

all inboxes | Powered by JetHome®