All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Szyprowski <m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
To: Hiroshi Doyu <hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Cc: linaro-mm-sig-cunTk1MwBs8s++Sfvej+rw@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 4/4] ARM: dma-mapping: Skip cache maint for invalid page
Date: Tue, 28 Aug 2012 23:58:48 +0200	[thread overview]
Message-ID: <503D3F18.7070507@samsung.com> (raw)
In-Reply-To: <1346154232-13299-4-git-send-email-hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>

Hello,

On 8/28/2012 1:43 PM, Hiroshi Doyu wrote:

> Skip cache maint for invalid page but warn it.
>
> Signed-off-by: Hiroshi Doyu <hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> ---
>   arch/arm/mm/dma-mapping.c |    9 +++++++++
>   1 files changed, 9 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
> index 2621282..0368702 100644
> --- a/arch/arm/mm/dma-mapping.c
> +++ b/arch/arm/mm/dma-mapping.c
> @@ -1589,6 +1589,9 @@ static void arm_iommu_unmap_page(struct device *dev, dma_addr_t handle,
>   	if (!iova)
>   		return;
>
> +	if (WARN_ON(!pfn_valid(page_to_pfn(page))))
> +		return;
> +
>   	if (!dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))
>   		__dma_page_dev_to_cpu(page, offset, size, dir);
>
> @@ -1607,6 +1610,9 @@ static void arm_iommu_sync_single_for_cpu(struct device *dev,
>   	if (!iova)
>   		return;
>
> +	if (WARN_ON(!pfn_valid(page_to_pfn(page))))
> +		return;
> +
>   	__dma_page_dev_to_cpu(page, offset, size, dir);
>   }
>
> @@ -1621,6 +1627,9 @@ static void arm_iommu_sync_single_for_device(struct device *dev,
>   	if (!iova)
>   		return;
>
> +	if (WARN_ON(!pfn_valid(page_to_pfn(page))))
> +		return;
> +
>   	__dma_page_cpu_to_dev(page, offset, size, dir);
>   }

I really wonder what has happened in your system that you require
such paranoid checks. All of the above functions are called on the
scatter-list which has been first passed to dma_map_sg(). IMHO it
makes much more sense to add a pfn_valid() check in dma_map_sg()
and return error if the provided scatter list is not valid instead
of these WARN_ONs.

Best regards
-- 
Marek Szyprowski
Samsung Poland R&D Center

WARNING: multiple messages have this Message-ID (diff)
From: m.szyprowski@samsung.com (Marek Szyprowski)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/4] ARM: dma-mapping: Skip cache maint for invalid page
Date: Tue, 28 Aug 2012 23:58:48 +0200	[thread overview]
Message-ID: <503D3F18.7070507@samsung.com> (raw)
In-Reply-To: <1346154232-13299-4-git-send-email-hdoyu@nvidia.com>

Hello,

On 8/28/2012 1:43 PM, Hiroshi Doyu wrote:

> Skip cache maint for invalid page but warn it.
>
> Signed-off-by: Hiroshi Doyu <hdoyu@nvidia.com>
> ---
>   arch/arm/mm/dma-mapping.c |    9 +++++++++
>   1 files changed, 9 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
> index 2621282..0368702 100644
> --- a/arch/arm/mm/dma-mapping.c
> +++ b/arch/arm/mm/dma-mapping.c
> @@ -1589,6 +1589,9 @@ static void arm_iommu_unmap_page(struct device *dev, dma_addr_t handle,
>   	if (!iova)
>   		return;
>
> +	if (WARN_ON(!pfn_valid(page_to_pfn(page))))
> +		return;
> +
>   	if (!dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))
>   		__dma_page_dev_to_cpu(page, offset, size, dir);
>
> @@ -1607,6 +1610,9 @@ static void arm_iommu_sync_single_for_cpu(struct device *dev,
>   	if (!iova)
>   		return;
>
> +	if (WARN_ON(!pfn_valid(page_to_pfn(page))))
> +		return;
> +
>   	__dma_page_dev_to_cpu(page, offset, size, dir);
>   }
>
> @@ -1621,6 +1627,9 @@ static void arm_iommu_sync_single_for_device(struct device *dev,
>   	if (!iova)
>   		return;
>
> +	if (WARN_ON(!pfn_valid(page_to_pfn(page))))
> +		return;
> +
>   	__dma_page_cpu_to_dev(page, offset, size, dir);
>   }

I really wonder what has happened in your system that you require
such paranoid checks. All of the above functions are called on the
scatter-list which has been first passed to dma_map_sg(). IMHO it
makes much more sense to add a pfn_valid() check in dma_map_sg()
and return error if the provided scatter list is not valid instead
of these WARN_ONs.

Best regards
-- 
Marek Szyprowski
Samsung Poland R&D Center

  parent reply	other threads:[~2012-08-28 21:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-28 11:43 [PATCH 1/4] ARM: dma-mapping: Small logical clean up Hiroshi Doyu
2012-08-28 11:43 ` Hiroshi Doyu
     [not found] ` <1346154232-13299-1-git-send-email-hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-08-28 11:43   ` [PATCH 2/4] ARM: dma-mapping: Remove unsed var at arm_coherent_iommu_unmap_page Hiroshi Doyu
2012-08-28 11:43     ` Hiroshi Doyu
2012-08-28 11:43   ` [PATCH 3/4] ARM: dma-mapping: Refrain noisy console message Hiroshi Doyu
2012-08-28 11:43     ` Hiroshi Doyu
2012-08-28 11:43   ` [PATCH 4/4] ARM: dma-mapping: Skip cache maint for invalid page Hiroshi Doyu
2012-08-28 11:43     ` Hiroshi Doyu
     [not found]     ` <1346154232-13299-4-git-send-email-hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-08-28 21:58       ` Marek Szyprowski [this message]
2012-08-28 21:58         ` Marek Szyprowski
     [not found]         ` <503D3F18.7070507-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2012-08-29  4:49           ` Hiroshi Doyu
2012-08-29  4:49             ` Hiroshi Doyu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=503D3F18.7070507@samsung.com \
    --to=m.szyprowski-sze3o3uu22jbdgjk7y7tuq@public.gmane.org \
    --cc=hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
    --cc=linaro-mm-sig-cunTk1MwBs8s++Sfvej+rw@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.