nouveau.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Thomas Gleixner <tglx@linutronix.de>,
	LKML <linux-kernel@vger.kernel.org>
Cc: Jani Nikula <jani.nikula@linux.intel.com>,
	David Airlie <airlied@linux.ie>,
	nouveau@lists.freedesktop.org, intel-gfx@lists.freedesktop.org,
	Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
	Roland Scheidegger <sroland@vmware.com>,
	dri-devel@lists.freedesktop.org,
	virtualization@lists.linux-foundation.org, linux-mm@kvack.org,
	Huang Rui <ray.huang@amd.com>,
	VMware Graphics <linux-graphics-maintainer@vmware.com>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Daniel Vetter <daniel@ffwll.ch>,
	Rodrigo Vivi <rodrigo.vivi@intel.com>,
	spice-devel@lists.freedesktop.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Chris Wilson <chris@chris-wilson.co.uk>,
	Zack Rusin <zackr@vmware.com>, Ben Skeggs <bskeggs@redhat.com>
Subject: Re: [Nouveau] [patch 1/7] drm/ttm: Replace kmap_atomic() usage
Date: Thu, 4 Mar 2021 18:42:13 +0100	[thread overview]
Message-ID: <404173f2-62ff-7953-2ce1-20ac9fde2aed@amd.com> (raw)
In-Reply-To: <20210303132711.340553449@linutronix.de>



Am 03.03.21 um 14:20 schrieb Thomas Gleixner:
> From: Thomas Gleixner <tglx@linutronix.de>
>
> There is no reason to disable pagefaults and preemption as a side effect of
> kmap_atomic_prot().
>
> Use kmap_local_page_prot() instead and document the reasoning for the
> mapping usage with the given pgprot.
>
> Remove the NULL pointer check for the map. These functions return a valid
> address for valid pages and the return was bogus anyway as it would have
> left preemption and pagefaults disabled.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Christian Koenig <christian.koenig@amd.com>
> Cc: Huang Rui <ray.huang@amd.com>
> Cc: David Airlie <airlied@linux.ie>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: dri-devel@lists.freedesktop.org
> ---
>   drivers/gpu/drm/ttm/ttm_bo_util.c |   20 ++++++++++++--------
>   1 file changed, 12 insertions(+), 8 deletions(-)
>
> --- a/drivers/gpu/drm/ttm/ttm_bo_util.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
> @@ -181,13 +181,15 @@ static int ttm_copy_io_ttm_page(struct t
>   		return -ENOMEM;
>   
>   	src = (void *)((unsigned long)src + (page << PAGE_SHIFT));
> -	dst = kmap_atomic_prot(d, prot);
> -	if (!dst)
> -		return -ENOMEM;
> +	/*
> +	 * Ensure that a highmem page is mapped with the correct
> +	 * pgprot. For non highmem the mapping is already there.
> +	 */

I find the comment a bit misleading. Maybe write:

/*
  * Locally map highmem pages with the correct pgprot.
  * Normal memory should already have the correct pgprot in the linear 
mapping.
  */

Apart from that looks good to me.

Regards,
Christian.

> +	dst = kmap_local_page_prot(d, prot);
>   
>   	memcpy_fromio(dst, src, PAGE_SIZE);
>   
> -	kunmap_atomic(dst);
> +	kunmap_local(dst);
>   
>   	return 0;
>   }
> @@ -203,13 +205,15 @@ static int ttm_copy_ttm_io_page(struct t
>   		return -ENOMEM;
>   
>   	dst = (void *)((unsigned long)dst + (page << PAGE_SHIFT));
> -	src = kmap_atomic_prot(s, prot);
> -	if (!src)
> -		return -ENOMEM;
> +	/*
> +	 * Ensure that a highmem page is mapped with the correct
> +	 * pgprot. For non highmem the mapping is already there.
> +	 */
> +	src = kmap_local_page_prot(s, prot);
>   
>   	memcpy_toio(dst, src, PAGE_SIZE);
>   
> -	kunmap_atomic(src);
> +	kunmap_local(src);
>   
>   	return 0;
>   }
>
>

_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau

  reply	other threads:[~2021-03-04 17:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-03 13:20 [Nouveau] [patch 0/7] drm, highmem: Cleanup io/kmap_atomic*() usage Thomas Gleixner
2021-03-03 13:20 ` [Nouveau] [patch 1/7] drm/ttm: Replace kmap_atomic() usage Thomas Gleixner
2021-03-04 17:42   ` Christian König [this message]
2021-03-03 13:20 ` [Nouveau] [patch 2/7] drm/vmgfx: Replace kmap_atomic() Thomas Gleixner
2021-03-04 18:47   ` Zack Rusin
2021-03-05 15:35   ` Roland Scheidegger
2021-03-03 13:20 ` [Nouveau] [patch 3/7] highmem: Remove kmap_atomic_prot() Thomas Gleixner
2021-03-03 13:20 ` [Nouveau] [patch 4/7] drm/qxl: Replace io_mapping_map_atomic_wc() Thomas Gleixner
2021-03-03 13:20 ` [Nouveau] [patch 5/7] drm/nouveau/device: " Thomas Gleixner
2021-03-03 13:20 ` [Nouveau] [patch 6/7] drm/i915: " Thomas Gleixner
2021-03-03 13:20 ` [Nouveau] [patch 7/7] io-mapping: Remove io_mapping_map_atomic_wc() Thomas Gleixner

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=404173f2-62ff-7953-2ce1-20ac9fde2aed@amd.com \
    --to=christian.koenig@amd.com \
    --cc=airlied@linux.ie \
    --cc=akpm@linux-foundation.org \
    --cc=bskeggs@redhat.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=joonas.lahtinen@linux.intel.com \
    --cc=kraxel@redhat.com \
    --cc=linux-graphics-maintainer@vmware.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=nouveau@lists.freedesktop.org \
    --cc=ray.huang@amd.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=spice-devel@lists.freedesktop.org \
    --cc=sroland@vmware.com \
    --cc=tglx@linutronix.de \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=zackr@vmware.com \
    /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 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).