linux-tegra.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Zhang <markz-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
To: Terje Bergstrom <tbergstrom-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Cc: Thierry Reding
	<thierry.reding-RM9K5IK7kjKj5M59NBduVrNAH6kLmebB@public.gmane.org>,
	"linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Stephen Warren <swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Subject: Re: Binding together tegradrm & nvhost
Date: Tue, 21 Aug 2012 14:12:08 +0800	[thread overview]
Message-ID: <1345529528.31608.165.camel@markz-desktop> (raw)
In-Reply-To: <50331F32.4040903-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>

On Tue, 2012-08-21 at 13:40 +0800, Terje Bergstrom wrote:
> On 21.08.2012 07:57, Mark Zhang wrote:
> > On Mon, 2012-08-20 at 21:01 +0800, Terje Bergstrom wrote:
> >> I propose that we create a virtual device for this.
> > This has been discussed several times. Indeed, we need a virtual device
> > for drm driver. The problem is, where do we define it? It's not a good
> > idea define it in dt, we all agreed with that before. Also it's not good
> > to define it in the code...
> > So, do you have any further proposal about this?
> 
> Let's see what Thierry came up with once he gets the code up. It seems
> he solved this somehow.
> 
> > I know little about host1x hardware. I wanna know does host1x have the
> > functionality to enum it's children? If this is true, do we still need
> > to define these host1x child devices in the dt? Will the 2 dc devices be
> > enumed and created during host1x's probe?
> 
> No, host1x doesn't have any probing functionality. Everything must be
> known by software beforehand.
> 
> The dc devices can be created in host1x probe the same time as the rest.
> I checked exynos driver and it seems to create the subdevices/drivers at
> drm load callback. I don't know if it matters whether it's done in load
> or probe phase.
> 

OK, thank you. In current version, all devices are created by
"of_platform_populate" in board init function. So if we still need to
define devices in dt, what's the benefit that we put these device
creation works into host1x's probe function? I don't see any difference
although create device in host1x probe() sounds more reasonable...

> > Hm... I think in last conference we agreed that nvhost driver will not
> > have it's device file, so this kind of ioctl's are going to routed to
> > tegra drm driver, then drm driver passes these ioctl's to nvhost driver.
> > Right?
> 
> Yes, nvhost will export in-kernel API so that tegradrm can call nvhost
> to implement the functionality. tegradrm will handle all ioctl related
> infra, and nvhost will handle the hardware interaction.
> 
> nvhost has in our own kernel variant also ioctl API, but that won't
> exist in upstream version.
> 

Got it.

> > I'm still not very clear about this part. So let me try to explain this.
> > Correct me if I'm wrong.
> > [Userspace]
> > Cause dma-buf has not explicit userspace apis, so we consider GEM.
> > Userspace programs call GEM interfaces to create/close/flink/mmap the
> > buffers.
> > Besides, by using GEM PRIME's handle to fd ioctl, userspace program is
> > able to convert a GEM handle to a dma-buf fd. This FD can be passed to
> > kernel driver so that the drivers gain the opportunity to access the
> > buffer.
> 
> Yes, correct. We can (naively) consider GEM being the API towards user
> space, and dma-buf as the kernel side implementation. We can consider if
> we need to implement GEM flink(), though. Please see below why.
> 
> > [Kernel]
> > DRM driver handles GEM buffer creation. Shmfs or CMA can be used as
> > backing storage. Right now CMA buffer allocation is wrapped by dma
> > mapping apis and shmfs has it's individual APIs.
> > DRM driver should export this buffer as dma-buf after GEM buffer is
> > created. Otherwise, drm prime can't get fd from this gem buffer handle
> > later.
> 
> We can just allocate memory with dma mapping API and use IOMMU for
> handling the mapping to hardware and dma-buf for mapping to user and
> kernel space. I don't think we need shmfs.
> 

Agree. Shmfs is not mandatory, DMA mapping API + IOMMU works. Even
without IOMMU, CMA works either.

> > Currently I'm still confused with these problems:
> > 1. Userspace program is able to get a dma-buf fd for a specific GEM
> > buffer. Is this a unique fd? I mean, can I pass this fd from one process
> > to another, then other processes can access the same buffer? If the
> > answer is yes, does this mean we don't need GEM's "flink" functionality?
> > If the answer is no, GEM's "flink" makes sense. 
> 
> User space process can send the fd to another process via a unix socket,
> and the other process can import the fd to gain access to the same
> memory. This is more secure thank flink, which (if I understand
> correctly) allows anybody with knowledge about the name to access the
> buffer.
> 
> > 2. How to sync buffer operations between these different frameworks? For
> > example, GEM has it's own buffer read/write/mmap interfaces, while
> > dma-buf has either. So if the userspace program does something on the
> > buffer via GEM apis, while a kernel driver is operating the same buffer
> > via dma-buf interfaces, what should we do? Because GEM and dma-buf are
> > different frameworks, where shall we setup a sync mechanism?
> 
> User space must take care that it does not access the buffer if it has
> given the buffer to hw. We can't enforce it, though, but we can give an
> API to help. The API relies on fences, which map to sync points in hardware.
> 
> When user space sends an operation to host1x client, it will be given a
> fence, which maps to a pair of sync point register number and value. The
> operation will ask host1x client to signal the fence via host1x (=sync
> point increment). We will give IOCTL's to user space so that it can
> check if buffer is safe to reuse, and operation to wait for the fence.
> 
> For dc, I haven't checked what kinds of operations on buffers there will
> be. We'll probably need dc to allocate a fence from nvhost (=sync point
> increment max), and increment sync point when an event has completed.
> This way we can pass the fence to user space, and let user space wait
> for it. This way user space will know when a buffer that was passed to
> dc is free to be reused.
> 

OK. So we have fence to sync all operations on a specific buffer. So
this also means we should add fence support on GEM and dma-buf
implementation both, right?

> In Linaro's mm-sig there is discussion on generalizing this
> synchronization mechanism.
> 
> Terje

  parent reply	other threads:[~2012-08-21  6:12 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-20 13:01 Binding together tegradrm & nvhost Terje Bergström
     [not found] ` <50323513.3090606-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-08-20 13:18   ` Thierry Reding
     [not found]     ` <20120820131800.GA13785-RM9K5IK7kjIQXX3q8xo1gnVAuStQJXxyR5q1nwbD4aMs9pC9oP6+/A@public.gmane.org>
2012-08-20 13:33       ` Terje Bergström
2012-08-21  3:50       ` Dennis Gilmore
2012-08-21  5:39       ` Mark Zhang
2012-08-21  5:42         ` Thierry Reding
     [not found]           ` <20120821054256.GA5325-RM9K5IK7kjIQXX3q8xo1gnVAuStQJXxyR5q1nwbD4aMs9pC9oP6+/A@public.gmane.org>
2012-08-21  6:16             ` Mark Zhang
2012-08-21  6:21               ` Thierry Reding
2012-08-21 14:57               ` Thierry Reding
     [not found]                 ` <20120821145709.GA701-RM9K5IK7kjIQXX3q8xo1gnVAuStQJXxyR5q1nwbD4aMs9pC9oP6+/A@public.gmane.org>
2012-08-22  2:29                   ` Mark Zhang
2012-08-22  8:42                   ` Terje Bergström
     [not found]                     ` <50349B58.4000809-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-08-22 10:33                       ` Thierry Reding
     [not found]                         ` <20120822103309.GB31448-RM9K5IK7kjIQXX3q8xo1gnVAuStQJXxyR5q1nwbD4aMs9pC9oP6+/A@public.gmane.org>
2012-08-22 11:42                           ` Terje Bergström
2012-08-21  4:57   ` Mark Zhang
2012-08-21  5:40     ` Terje Bergström
     [not found]       ` <50331F32.4040903-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-08-21  6:12         ` Mark Zhang [this message]
2012-08-21  6:35           ` Terje Bergström
     [not found]             ` <50332C22.7090009-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-08-21  7:12               ` Mark Zhang
2012-08-21 21:57               ` Stephen Warren
     [not found]                 ` <50340445.6010908-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-08-22  5:54                   ` Thierry Reding
2012-08-21 21:53   ` Stephen Warren
     [not found]     ` <50340343.1050206-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-08-22  6:49       ` Thierry Reding

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=1345529528.31608.165.camel@markz-desktop \
    --to=markz-ddmlm1+adcrqt0dzr+alfa@public.gmane.org \
    --cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
    --cc=tbergstrom-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
    --cc=thierry.reding-RM9K5IK7kjKj5M59NBduVrNAH6kLmebB@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 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).