* [PATCH] mfd:rtsx: do retry when dma transfer error
@ 2016-12-09 8:23 steven_feng
2017-01-03 17:17 ` Lee Jones
0 siblings, 1 reply; 3+ messages in thread
From: steven_feng @ 2016-12-09 8:23 UTC (permalink / raw)
To: lee.jones; +Cc: linux-kernel, steven_feng
From: steven_feng <steven_feng@realsil.com.cn>
the request should be reissued when dma transfer error.
for rts5227, the clock freq need to step reduce when error occurred.
Signed-off-by: steven_feng <steven_feng@realsil.com.cn>
---
drivers/mfd/rtsx_pcr.c | 15 +++++++++++++--
include/linux/mfd/rtsx_pci.h | 2 ++
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/drivers/mfd/rtsx_pcr.c b/drivers/mfd/rtsx_pcr.c
index 98029ee..1684e61 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 < 8)
+ pcr->dma_error_count++;
+ }
+
else if (pcr->trans_result == TRANS_NO_DEVICE)
err = -ENODEV;
spin_unlock_irqrestore(&pcr->lock, flags);
@@ -659,6 +664,11 @@ int rtsx_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock,
if (err < 0)
return err;
+ if (card_clock == UHS_SDR104_MAX_DTR &&
+ pcr->dma_error_count && PCI_PID(pcr) == 0x5227)
+ 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 +904,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..1d65f4e 100644
--- a/include/linux/mfd/rtsx_pci.h
+++ b/include/linux/mfd/rtsx_pci.h
@@ -957,6 +957,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 related [flat|nested] 3+ messages in thread
* Re: [PATCH] mfd:rtsx: do retry when dma transfer error
2016-12-09 8:23 [PATCH] mfd:rtsx: do retry when dma transfer error steven_feng
@ 2017-01-03 17:17 ` Lee Jones
2017-01-04 9:48 ` 冯伟linux
0 siblings, 1 reply; 3+ messages in thread
From: Lee Jones @ 2017-01-03 17:17 UTC (permalink / raw)
To: steven_feng; +Cc: linux-kernel
On Fri, 09 Dec 2016, steven_feng@realsil.com.cn wrote:
> From: steven_feng <steven_feng@realsil.com.cn>
>
> the request should be reissued when dma transfer error.
> for rts5227, the clock freq need to step reduce when error occurred.
>
> Signed-off-by: steven_feng <steven_feng@realsil.com.cn>
> ---
> drivers/mfd/rtsx_pcr.c | 15 +++++++++++++--
> include/linux/mfd/rtsx_pci.h | 2 ++
> 2 files changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mfd/rtsx_pcr.c b/drivers/mfd/rtsx_pcr.c
> index 98029ee..1684e61 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;
This seems strange. What is the reason for using this error?
> + if (pcr->dma_error_count < 8)
Why 8?
> + pcr->dma_error_count++;
> + }
> +
> else if (pcr->trans_result == TRANS_NO_DEVICE)
> err = -ENODEV;
> spin_unlock_irqrestore(&pcr->lock, flags);
> @@ -659,6 +664,11 @@ int rtsx_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock,
> if (err < 0)
> return err;
>
> + if (card_clock == UHS_SDR104_MAX_DTR &&
> + pcr->dma_error_count && PCI_PID(pcr) == 0x5227)
Tabbing is off here.
What does 0x5227 mean? No magic numbers. Please define it.
> + card_clock = UHS_SDR104_MAX_DTR -
> + pcr->dma_error_count * 20000000;
What does this do?
Looks like you need a comment to describe what you're trying to
achieve.
> card_clock /= 1000000;
> pcr_dbg(pcr, "Switch card clock to %dMHz\n", card_clock);
>
> @@ -894,6 +904,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..1d65f4e 100644
> --- a/include/linux/mfd/rtsx_pci.h
> +++ b/include/linux/mfd/rtsx_pci.h
> @@ -957,6 +957,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] 3+ messages in thread
* Re: [PATCH] mfd:rtsx: do retry when dma transfer error
2017-01-03 17:17 ` Lee Jones
@ 2017-01-04 9:48 ` 冯伟linux
0 siblings, 0 replies; 3+ messages in thread
From: 冯伟linux @ 2017-01-04 9:48 UTC (permalink / raw)
To: Lee Jones; +Cc: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 3635 bytes --]
> This seems strange. What is the reason for using this error?
>
>> + if (pcr->dma_error_count < 8)
> Why 8?
dma_error_count record the number of dma transfer error,
card clock decreased by 20MHz *dma_error_count, when setting card clock
again.
while dma_error_count == 8, the clock had reduced from 208MHz to 40MHz
The frequency is low enough, if transfer error still occurs, card reset
is needed.
> What does 0x5227 mean? No magic numbers. Please define it.
>
>> + card_clock = UHS_SDR104_MAX_DTR -
>> + pcr->dma_error_count * 20000000;
> What does this do?
0x5227 is the rts5227's device ID, which is a pcie card reader.
card clock need to decreased by 20MHz * dma_error_count,
because of dma transfer error occured at current frequency.
> Looks like you need a comment to describe what you're trying to
> achieve.
add it at patch v2
steven feng
Realsil Microelectronics CO. LTD.
Mobile:181-6899-0403 Ext:57594
在 2017年01月04日 01:13, Lee Jones 写道:
> On Fri, 09 Dec 2016, steven_feng@realsil.com.cn wrote:
>
>> From: steven_feng <steven_feng@realsil.com.cn>
>>
>> the request should be reissued when dma transfer error.
>> for rts5227, the clock freq need to step reduce when error occurred.
>>
>> Signed-off-by: steven_feng <steven_feng@realsil.com.cn>
>> ---
>> drivers/mfd/rtsx_pcr.c | 15 +++++++++++++--
>> include/linux/mfd/rtsx_pci.h | 2 ++
>> 2 files changed, 15 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/mfd/rtsx_pcr.c b/drivers/mfd/rtsx_pcr.c
>> index 98029ee..1684e61 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;
> This seems strange. What is the reason for using this error?
>
>> + if (pcr->dma_error_count < 8)
> Why 8?
>
>> + pcr->dma_error_count++;
>> + }
>> +
>> else if (pcr->trans_result == TRANS_NO_DEVICE)
>> err = -ENODEV;
>> spin_unlock_irqrestore(&pcr->lock, flags);
>> @@ -659,6 +664,11 @@ int rtsx_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock,
>> if (err < 0)
>> return err;
>>
>> + if (card_clock == UHS_SDR104_MAX_DTR &&
>> + pcr->dma_error_count && PCI_PID(pcr) == 0x5227)
> Tabbing is off here.
>
> What does 0x5227 mean? No magic numbers. Please define it.
>
>> + card_clock = UHS_SDR104_MAX_DTR -
>> + pcr->dma_error_count * 20000000;
> What does this do?
>
> Looks like you need a comment to describe what you're trying to
> achieve.
>
>> card_clock /= 1000000;
>> pcr_dbg(pcr, "Switch card clock to %dMHz\n", card_clock);
>>
>> @@ -894,6 +904,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..1d65f4e 100644
>> --- a/include/linux/mfd/rtsx_pci.h
>> +++ b/include/linux/mfd/rtsx_pci.h
>> @@ -957,6 +957,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] 3+ messages in thread
end of thread, other threads:[~2017-01-04 9:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-09 8:23 [PATCH] mfd:rtsx: do retry when dma transfer error steven_feng
2017-01-03 17:17 ` Lee Jones
2017-01-04 9:48 ` 冯伟linux
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).