Re: [PATCH 03/14] mmc: sdhci: correct the DMA setting for IOMMU

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 15/11/19 1:07 PM, haibo.chen@xxxxxxx wrote:
> From: Haibo Chen <haibo.chen@xxxxxxx>
> 
> The default max segment size of IOMMU is 64KB, which exceed the ADMA
> limitation if ADMA only support max to 65535, 64KB - 1Byte. IOMMU will
> optimize the segments it received, merge the little segment into one
> big segment. If we use the default IOMMU config, then ADMA will get
> some segments which it's size is 64KB. Then ADMA error will shows up.
> 
> Signed-off-by: Haibo Chen <haibo.chen@xxxxxxx>
> ---
>  drivers/mmc/host/sdhci.c | 16 ++++++++++++++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index 1436cc9c5f82..3a8093de26c7 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -3743,6 +3743,7 @@ static inline bool sdhci_can_64bit_dma(struct sdhci_host *host)
>  int sdhci_setup_host(struct sdhci_host *host)
>  {
>  	struct mmc_host *mmc;
> +	struct device *dev;
>  	u32 max_current_caps;
>  	unsigned int ocr_avail;
>  	unsigned int override_timeout_clk;
> @@ -3754,6 +3755,7 @@ int sdhci_setup_host(struct sdhci_host *host)
>  		return -EINVAL;
>  
>  	mmc = host->mmc;
> +	dev = mmc_dev(mmc);
>  
>  	/*
>  	 * If there are external regulators, get them. Note this must be done
> @@ -4224,10 +4226,20 @@ int sdhci_setup_host(struct sdhci_host *host)
>  	 * be larger than 64 KiB though.
>  	 */
>  	if (host->flags & SDHCI_USE_ADMA) {
> -		if (host->quirks & SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC)
> +		if (host->quirks & SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC) {
>  			mmc->max_seg_size = 65535;
> -		else
> +
> +			/*
> +			 * send the ADMA limitation to IOMMU. In default,
> +			 * the max segment size of IOMMU is 64KB, this exceed
> +			 * the ADMA max segment limitation, which is 65535.
> +			 */
> +			dev->dma_parms = devm_kzalloc(dev,
> +					sizeof(*dev->dma_parms), GFP_KERNEL);
> +			dma_set_max_seg_size(dev, SZ_64K - 1);

Doesn't mmc_setup_queue() already do this?

> +		} else {
>  			mmc->max_seg_size = 65536;
> +		}
>  	} else {
>  		mmc->max_seg_size = mmc->max_req_size;
>  	}
> 




[Index of Archives]     [Linux Memonry Technology]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux