On Mon, Mar 11, 2013 at 11:21:05AM +0200, Terje Bergström wrote: > On 11.03.2013 09:18, Thierry Reding wrote: > > This sound a bit over-engineered at this point in time. DRM is currently > > the only user. Is anybody working on any non-DRM drivers that would use > > this? > > Well, this contains beginning of that: > > http://nv-tegra.nvidia.com/gitweb/?p=linux-2.6.git;a=blob;f=drivers/media/video/tegra_v4l2_camera.c;h=644d0be5380367aca4c826c49724c03aad08387c;hb=l4t/l4t-r16-r2 > > I don't want to give these guys any excuse not to port it over to host1x > code base. :-) I was aware of that driver but I didn't realize it had been available publicly. It's great to see this, though, and one more argument in favour of not binding the host1x_bo too tightly to DRM/GEM. > > So how about the following proposal, which I think might satisfy both of > > us: > > > > struct host1x_bo; > > > > struct host1x_bo_ops { > > struct host1x_bo *(*get)(struct host1x_bo *bo); > > void (*put)(struct host1x_bo *bo); > > dma_addr_t (*pin)(struct host1x_bo *bo, struct sg_table **sgt); > > ... > > }; > > > > struct host1x_bo *host1x_bo_get(struct host1x_bo *bo); > > void host1x_bo_put(struct host1x_bo *bo); > > dma_addr_t host1x_bo_pin(struct host1x_bo *bo, struct sg_table **sgt); > > ... > > > > struct host1x_bo { > > const struct host1x_bo_ops *ops; > > ... > > }; > > > > struct tegra_drm_bo { > > struct host1x_bo base; > > ... > > }; > > > > That way you can get rid of the host1x_memmgr_create_handle() helper and > > instead embed host1x_bo into driver-/framework-specific structures with > > the necessary initialization. > > This would make sense. We'll get back when we have enough of > implementation done to understand it all. One consequence is that we > cannot use drm_gem_cma_create() anymore. We'll have to introduce a > function that does the same as drm_gem_cma_create(), but it takes a > pre-allocated drm_gem_cma_object pointer. That way we can allocate the > struct, and use DRM CMA just to initialize the drm_gem_cma_object. I certainly think that introducing a drm_gem_cma_object_init() function shouldn't pose a problem. If you do, make sure to update the existing drm_gem_cma_create() to use it. Having both lets users have the choice to use drm_gem_cma_create() if they don't need to embed it, or drm_gem_cma_object_init() otherwise. > Other way would be just taking a copy of DRM CMA helper, but I'd like to > defer that to the next step when we implement IOMMU aware allocator. I'm not sure I understand what you're saying, but if you add a function as discussed above this shouldn't be necessary. > > It also allows you to interact directly with the objects instead of > > having to go through the memmgr API. The memory manager doesn't really > > exist anymore so keeping the name in the API is only confusing. Your > > current proposal deals with memory handles directly already so it's > > really just making the naming more consistent. > > The memmgr APIs are currently just a shortcut wrapper to the ops, so in > that sense the memmgr does not really exist. I think it might still make > sense to keep static inline wrappers for calling the ops within, but we > could rename them to host1x_bo_somethingandother. Then it'd follow the > pattern we are using for the hw ops in the latest set. Yes, that's exactly what I had in mind in the above proposal. They could be inline, but it's probably also okay if they're not. They aren't meant to be used very frequently so the extra function call shouldn't matter much. It might be easier to do add some additional checks if they aren't inlined. I'm fine either way. Thierry
Attachment:
pgp9GfHmYcdlM.pgp
Description: PGP signature
_______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/dri-devel