From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759975AbdACRPI (ORCPT ); Tue, 3 Jan 2017 12:15:08 -0500 Received: from mail-wm0-f49.google.com ([74.125.82.49]:37423 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759870AbdACROJ (ORCPT ); Tue, 3 Jan 2017 12:14:09 -0500 Date: Tue, 3 Jan 2017 17:17:27 +0000 From: Lee Jones To: steven_feng@realsil.com.cn Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH] mfd:rtsx: do retry when dma transfer error Message-ID: <20170103171727.GP2977@dell> References: <1481271814-31820-1-git-send-email-steven_feng@realsil.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1481271814-31820-1-git-send-email-steven_feng@realsil.com.cn> User-Agent: Mutt/1.6.2 (2016-07-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 09 Dec 2016, steven_feng@realsil.com.cn wrote: > From: steven_feng > > 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 > --- > 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 > #include > #include > +#include > #include > > #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