All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lucas Stach <l.stach@pengutronix.de>
To: Alexandre Courbot <gnurou@gmail.com>
Cc: Russell King - ARM Linux <linux@arm.linux.org.uk>,
	"nouveau@lists.freedesktop.org" <nouveau@lists.freedesktop.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>,
	Alexandre Courbot <acourbot@nvidia.com>,
	Ben Skeggs <bskeggs@redhat.com>,
	Maarten Lankhorst <maarten.lankhorst@canonical.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [Nouveau] [PATCH v2 2/3] drm/ttm: introduce dma cache sync helpers
Date: Tue, 24 Jun 2014 15:58:15 +0200	[thread overview]
Message-ID: <1403618295.4230.13.camel@weser.hi.pengutronix.de> (raw)
In-Reply-To: <CAAVeFuLcC30BdWierY8Bg0vBmfNCaB=Qs34h790jGB=BRYvGAg@mail.gmail.com>

Am Dienstag, den 24.06.2014, 22:52 +0900 schrieb Alexandre Courbot:
> On Tue, Jun 24, 2014 at 10:25 PM, Lucas Stach <l.stach@pengutronix.de> wrote:
> > Am Dienstag, den 24.06.2014, 14:27 +0200 schrieb Maarten Lankhorst:
> >> op 24-06-14 14:23, Alexandre Courbot schreef:
> >> > On Tue, Jun 24, 2014 at 7:55 PM, Alexandre Courbot <acourbot@nvidia.com> wrote:
> >> >> On 06/24/2014 07:33 PM, Alexandre Courbot wrote:
> >> >>> On 06/24/2014 07:02 PM, Russell King - ARM Linux wrote:
> >> >>>> On Tue, Jun 24, 2014 at 06:54:26PM +0900, Alexandre Courbot wrote:
> >> >>>>> From: Lucas Stach <dev@lynxeye.de>
> >> >>>>>
> >> >>>>> On architectures for which access to GPU memory is non-coherent,
> >> >>>>> caches need to be flushed and invalidated explicitly at the
> >> >>>>> appropriate places. Introduce two small helpers to make things
> >> >>>>> easy for TTM-based drivers.
> >> >>>>
> >> >>>> Have you run this with DMA API debugging enabled?  I suspect you haven't,
> >> >>>> and I recommend that you do.
> >> >>>
> >> >>> # cat /sys/kernel/debug/dma-api/error_count
> >> >>> 162621
> >> >>>
> >> >>> (╯°□°)╯︵ ┻━┻)
> >> >>
> >> >> *puts table back on its feet*
> >> >>
> >> >> So, yeah - TTM memory is not allocated using the DMA API, hence we cannot
> >> >> use the DMA API to sync it. Thanks Russell for pointing it out.
> >> >>
> >> >> The only alternative I see here is to flush the CPU caches when syncing for
> >> >> the device, and invalidate them for the other direction. Of course if the
> >> >> device has caches on its side as well the opposite operation must also be
> >> >> done for it. Guess the only way is to handle it all by ourselves here. :/
> >> > ... and it really sucks. Basically if we cannot use the DMA API here
> >> > we will lose the convenience of having a portable API that does just
> >> > the right thing for the underlying platform. Without it we would have
> >> > to duplicate arm_iommu_sync_single_for_cpu/device() and we would only
> >> > have support for ARM.
> >> >
> >> > The usage of the DMA API that we are doing might be illegal, but in
> >> > essence it does exactly what we need - at least for ARM. What are the
> >> > alternatives?
> >> Convert TTM to use the dma api? :-)
> >
> > Actually TTM already has a page alloc backend using the DMA API. It's
> > just not used for the standard case right now.
> 
> Indeed, and Nouveau even already makes use of it if CONFIG_SWIOTLB is
> set apparently.
> 
> > I would argue that we should just use this page allocator (which has the
> > side effect of getting pages from CMA if available -> you are actually
> > free to change the caching) and do away with the other allocator in the
> > ARM case.
> 
> Mm? Does it mean that CMA memory is not mapped into lowmem? That would
> certainly help in the present case, but I wonder how useful it will be
> once the iommu support is in place. Will also need to consider
> performance of such coherent memory for e.g. user-space mappings.
> 
> Anyway, I will experiment a bit with this tomorrow, thanks!

CMA memory is reserved before the lowmem section mapping is set up. It
is then mapped with individual 4k pages before giving it back to the
buddy allocator.
This means CMA pages in use by the kernel are mapped into lowmem, but
they are actually unmapped from lowmem once you allocate them as DMA
memory.

Regards,
Lucas

-- 
Pengutronix e.K.             | Lucas Stach                 |
Industrial Linux Solutions   | http://www.pengutronix.de/  |


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Lucas Stach <l.stach@pengutronix.de>
To: Alexandre Courbot <gnurou@gmail.com>
Cc: Maarten Lankhorst <maarten.lankhorst@canonical.com>,
	Alexandre Courbot <acourbot@nvidia.com>,
	Russell King - ARM Linux <linux@arm.linux.org.uk>,
	"nouveau@lists.freedesktop.org" <nouveau@lists.freedesktop.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	Ben Skeggs <bskeggs@redhat.com>,
	"linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [Nouveau] [PATCH v2 2/3] drm/ttm: introduce dma cache sync helpers
Date: Tue, 24 Jun 2014 15:58:15 +0200	[thread overview]
Message-ID: <1403618295.4230.13.camel@weser.hi.pengutronix.de> (raw)
In-Reply-To: <CAAVeFuLcC30BdWierY8Bg0vBmfNCaB=Qs34h790jGB=BRYvGAg@mail.gmail.com>

Am Dienstag, den 24.06.2014, 22:52 +0900 schrieb Alexandre Courbot:
> On Tue, Jun 24, 2014 at 10:25 PM, Lucas Stach <l.stach@pengutronix.de> wrote:
> > Am Dienstag, den 24.06.2014, 14:27 +0200 schrieb Maarten Lankhorst:
> >> op 24-06-14 14:23, Alexandre Courbot schreef:
> >> > On Tue, Jun 24, 2014 at 7:55 PM, Alexandre Courbot <acourbot@nvidia.com> wrote:
> >> >> On 06/24/2014 07:33 PM, Alexandre Courbot wrote:
> >> >>> On 06/24/2014 07:02 PM, Russell King - ARM Linux wrote:
> >> >>>> On Tue, Jun 24, 2014 at 06:54:26PM +0900, Alexandre Courbot wrote:
> >> >>>>> From: Lucas Stach <dev@lynxeye.de>
> >> >>>>>
> >> >>>>> On architectures for which access to GPU memory is non-coherent,
> >> >>>>> caches need to be flushed and invalidated explicitly at the
> >> >>>>> appropriate places. Introduce two small helpers to make things
> >> >>>>> easy for TTM-based drivers.
> >> >>>>
> >> >>>> Have you run this with DMA API debugging enabled?  I suspect you haven't,
> >> >>>> and I recommend that you do.
> >> >>>
> >> >>> # cat /sys/kernel/debug/dma-api/error_count
> >> >>> 162621
> >> >>>
> >> >>> (╯°□°)╯︵ ┻━┻)
> >> >>
> >> >> *puts table back on its feet*
> >> >>
> >> >> So, yeah - TTM memory is not allocated using the DMA API, hence we cannot
> >> >> use the DMA API to sync it. Thanks Russell for pointing it out.
> >> >>
> >> >> The only alternative I see here is to flush the CPU caches when syncing for
> >> >> the device, and invalidate them for the other direction. Of course if the
> >> >> device has caches on its side as well the opposite operation must also be
> >> >> done for it. Guess the only way is to handle it all by ourselves here. :/
> >> > ... and it really sucks. Basically if we cannot use the DMA API here
> >> > we will lose the convenience of having a portable API that does just
> >> > the right thing for the underlying platform. Without it we would have
> >> > to duplicate arm_iommu_sync_single_for_cpu/device() and we would only
> >> > have support for ARM.
> >> >
> >> > The usage of the DMA API that we are doing might be illegal, but in
> >> > essence it does exactly what we need - at least for ARM. What are the
> >> > alternatives?
> >> Convert TTM to use the dma api? :-)
> >
> > Actually TTM already has a page alloc backend using the DMA API. It's
> > just not used for the standard case right now.
> 
> Indeed, and Nouveau even already makes use of it if CONFIG_SWIOTLB is
> set apparently.
> 
> > I would argue that we should just use this page allocator (which has the
> > side effect of getting pages from CMA if available -> you are actually
> > free to change the caching) and do away with the other allocator in the
> > ARM case.
> 
> Mm? Does it mean that CMA memory is not mapped into lowmem? That would
> certainly help in the present case, but I wonder how useful it will be
> once the iommu support is in place. Will also need to consider
> performance of such coherent memory for e.g. user-space mappings.
> 
> Anyway, I will experiment a bit with this tomorrow, thanks!

CMA memory is reserved before the lowmem section mapping is set up. It
is then mapped with individual 4k pages before giving it back to the
buddy allocator.
This means CMA pages in use by the kernel are mapped into lowmem, but
they are actually unmapped from lowmem once you allocate them as DMA
memory.

Regards,
Lucas

-- 
Pengutronix e.K.             | Lucas Stach                 |
Industrial Linux Solutions   | http://www.pengutronix.de/  |


WARNING: multiple messages have this Message-ID (diff)
From: l.stach@pengutronix.de (Lucas Stach)
To: linux-arm-kernel@lists.infradead.org
Subject: [Nouveau] [PATCH v2 2/3] drm/ttm: introduce dma cache sync helpers
Date: Tue, 24 Jun 2014 15:58:15 +0200	[thread overview]
Message-ID: <1403618295.4230.13.camel@weser.hi.pengutronix.de> (raw)
In-Reply-To: <CAAVeFuLcC30BdWierY8Bg0vBmfNCaB=Qs34h790jGB=BRYvGAg@mail.gmail.com>

Am Dienstag, den 24.06.2014, 22:52 +0900 schrieb Alexandre Courbot:
> On Tue, Jun 24, 2014 at 10:25 PM, Lucas Stach <l.stach@pengutronix.de> wrote:
> > Am Dienstag, den 24.06.2014, 14:27 +0200 schrieb Maarten Lankhorst:
> >> op 24-06-14 14:23, Alexandre Courbot schreef:
> >> > On Tue, Jun 24, 2014 at 7:55 PM, Alexandre Courbot <acourbot@nvidia.com> wrote:
> >> >> On 06/24/2014 07:33 PM, Alexandre Courbot wrote:
> >> >>> On 06/24/2014 07:02 PM, Russell King - ARM Linux wrote:
> >> >>>> On Tue, Jun 24, 2014 at 06:54:26PM +0900, Alexandre Courbot wrote:
> >> >>>>> From: Lucas Stach <dev@lynxeye.de>
> >> >>>>>
> >> >>>>> On architectures for which access to GPU memory is non-coherent,
> >> >>>>> caches need to be flushed and invalidated explicitly at the
> >> >>>>> appropriate places. Introduce two small helpers to make things
> >> >>>>> easy for TTM-based drivers.
> >> >>>>
> >> >>>> Have you run this with DMA API debugging enabled?  I suspect you haven't,
> >> >>>> and I recommend that you do.
> >> >>>
> >> >>> # cat /sys/kernel/debug/dma-api/error_count
> >> >>> 162621
> >> >>>
> >> >>> (??????? ???)
> >> >>
> >> >> *puts table back on its feet*
> >> >>
> >> >> So, yeah - TTM memory is not allocated using the DMA API, hence we cannot
> >> >> use the DMA API to sync it. Thanks Russell for pointing it out.
> >> >>
> >> >> The only alternative I see here is to flush the CPU caches when syncing for
> >> >> the device, and invalidate them for the other direction. Of course if the
> >> >> device has caches on its side as well the opposite operation must also be
> >> >> done for it. Guess the only way is to handle it all by ourselves here. :/
> >> > ... and it really sucks. Basically if we cannot use the DMA API here
> >> > we will lose the convenience of having a portable API that does just
> >> > the right thing for the underlying platform. Without it we would have
> >> > to duplicate arm_iommu_sync_single_for_cpu/device() and we would only
> >> > have support for ARM.
> >> >
> >> > The usage of the DMA API that we are doing might be illegal, but in
> >> > essence it does exactly what we need - at least for ARM. What are the
> >> > alternatives?
> >> Convert TTM to use the dma api? :-)
> >
> > Actually TTM already has a page alloc backend using the DMA API. It's
> > just not used for the standard case right now.
> 
> Indeed, and Nouveau even already makes use of it if CONFIG_SWIOTLB is
> set apparently.
> 
> > I would argue that we should just use this page allocator (which has the
> > side effect of getting pages from CMA if available -> you are actually
> > free to change the caching) and do away with the other allocator in the
> > ARM case.
> 
> Mm? Does it mean that CMA memory is not mapped into lowmem? That would
> certainly help in the present case, but I wonder how useful it will be
> once the iommu support is in place. Will also need to consider
> performance of such coherent memory for e.g. user-space mappings.
> 
> Anyway, I will experiment a bit with this tomorrow, thanks!

CMA memory is reserved before the lowmem section mapping is set up. It
is then mapped with individual 4k pages before giving it back to the
buddy allocator.
This means CMA pages in use by the kernel are mapped into lowmem, but
they are actually unmapped from lowmem once you allocate them as DMA
memory.

Regards,
Lucas

-- 
Pengutronix e.K.             | Lucas Stach                 |
Industrial Linux Solutions   | http://www.pengutronix.de/  |

  reply	other threads:[~2014-06-24 13:58 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-24  9:54 [PATCH v2 0/3] drm/ttm: nouveau: memory coherency for ARM Alexandre Courbot
2014-06-24  9:54 ` Alexandre Courbot
2014-06-24  9:54 ` Alexandre Courbot
2014-06-24  9:54 ` [PATCH v2 1/3] drm/ttm: recognize ARM arch in ioprot handler Alexandre Courbot
2014-06-24  9:54   ` Alexandre Courbot
2014-06-24  9:54   ` Alexandre Courbot
     [not found] ` <1403603667-11302-1-git-send-email-acourbot-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2014-06-24  9:54   ` [PATCH v2 2/3] drm/ttm: introduce dma cache sync helpers Alexandre Courbot
2014-06-24  9:54     ` Alexandre Courbot
2014-06-24  9:54     ` Alexandre Courbot
2014-06-24 10:02     ` Russell King - ARM Linux
2014-06-24 10:02       ` Russell King - ARM Linux
2014-06-24 10:02       ` Russell King - ARM Linux
2014-06-24 10:33       ` Alexandre Courbot
2014-06-24 10:33         ` Alexandre Courbot
2014-06-24 10:33         ` Alexandre Courbot
     [not found]         ` <53A953E6.2030503-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2014-06-24 10:55           ` Alexandre Courbot
2014-06-24 10:55             ` Alexandre Courbot
2014-06-24 10:55             ` Alexandre Courbot
     [not found]             ` <53A95910.20104-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2014-06-24 12:23               ` Alexandre Courbot
2014-06-24 12:23                 ` Alexandre Courbot
2014-06-24 12:23                 ` Alexandre Courbot
2014-06-24 12:27                 ` [Nouveau] " Maarten Lankhorst
2014-06-24 12:27                   ` Maarten Lankhorst
2014-06-24 12:27                   ` Maarten Lankhorst
2014-06-24 13:25                   ` Lucas Stach
2014-06-24 13:25                     ` Lucas Stach
2014-06-24 13:25                     ` Lucas Stach
     [not found]                     ` <1403616338.4230.8.camel-WzVe3FnzCwFR6QfukMTsflXZhhPuCNm+@public.gmane.org>
2014-06-24 13:52                       ` Alexandre Courbot
2014-06-24 13:52                         ` [Nouveau] " Alexandre Courbot
2014-06-24 13:52                         ` Alexandre Courbot
2014-06-24 13:58                         ` Lucas Stach [this message]
2014-06-24 13:58                           ` Lucas Stach
2014-06-24 13:58                           ` Lucas Stach
     [not found]                           ` <1403618295.4230.13.camel-WzVe3FnzCwFR6QfukMTsflXZhhPuCNm+@public.gmane.org>
2014-06-24 14:03                             ` Alexandre Courbot
2014-06-24 14:03                               ` [Nouveau] " Alexandre Courbot
2014-06-24 14:03                               ` Alexandre Courbot
2014-06-26 14:50                             ` Alexandre Courbot
2014-06-26 14:50                               ` Alexandre Courbot
2014-06-26 14:50                               ` Alexandre Courbot
2014-06-25  4:00                       ` Stéphane Marchesin
2014-06-25  4:00                         ` [Nouveau] " Stéphane Marchesin
2014-06-25  4:00                         ` Stéphane Marchesin
     [not found]                         ` <CACP_E+KECMyusuZd6hpzthL-RpfUOJpWh0EABf1DGAeaXc00aA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-06-26 14:53                           ` Alexandre Courbot
2014-06-26 14:53                             ` [Nouveau] " Alexandre Courbot
2014-06-26 14:53                             ` Alexandre Courbot
     [not found]                             ` <CAAVeFuLU04rk1DWMhVJV=ktVCpq4js38p1ipCr1jh1x72b=GZw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-06-26 16:10                               ` Russell King - ARM Linux
2014-06-26 16:10                                 ` [Nouveau] " Russell King - ARM Linux
2014-06-26 16:10                                 ` Russell King - ARM Linux
     [not found]                                 ` <20140626161055.GX32514-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2014-06-26 23:17                                   ` Alexandre Courbot
2014-06-26 23:17                                     ` [Nouveau] " Alexandre Courbot
2014-06-26 23:17                                     ` Alexandre Courbot
2014-06-27 12:08                                     ` Rob Clark
2014-06-27 12:08                                       ` Rob Clark
2014-06-27 12:08                                       ` Rob Clark
2014-06-24 13:09                 ` Russell King - ARM Linux
2014-06-24 13:09                   ` Russell King - ARM Linux
2014-06-24 13:09                   ` Russell King - ARM Linux
     [not found]                   ` <20140624130930.GN32514-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2014-06-24 13:25                     ` Alexandre Courbot
2014-06-24 13:25                       ` Alexandre Courbot
2014-06-24 13:25                       ` Alexandre Courbot
2014-06-24  9:54 ` [PATCH v2 3/3] drm/nouveau: hook up cache sync functions Alexandre Courbot
2014-06-24  9:54   ` Alexandre Courbot
2014-06-24  9:54   ` Alexandre Courbot

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=1403618295.4230.13.camel@weser.hi.pengutronix.de \
    --to=l.stach@pengutronix.de \
    --cc=acourbot@nvidia.com \
    --cc=bskeggs@redhat.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gnurou@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=maarten.lankhorst@canonical.com \
    --cc=nouveau@lists.freedesktop.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.