dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: j.glisse@gmail.com
Cc: thellstrom@vmware.com, Jerome Glisse <jglisse@redhat.com>,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 13/14] drm/ttm: isolate dma data from ttm_tt V3
Date: Tue, 15 Nov 2011 16:07:46 -0500	[thread overview]
Message-ID: <20111115210746.GA17200@phenom.dumpdata.com> (raw)
In-Reply-To: <1321051669-16675-14-git-send-email-j.glisse@gmail.com>

On Fri, Nov 11, 2011 at 05:47:48PM -0500, j.glisse@gmail.com wrote:
> From: Jerome Glisse <jglisse@redhat.com>
> 
> Move dma data to a superset ttm_dma_tt structure which herit

inherit

> from ttm_tt. This allow driver that don't use dma functionalities
> to not have to waste memory for it.
> 
> V2 Rebase on top of no memory account changes (where/when is my
>    delorean when i need it ?)
> V3 Make sure page list is initialized empty
> 
> Signed-off-by: Jerome Glisse <jglisse@redhat.com>
> Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
.. snip..

> +void ttm_tt_fini(struct ttm_tt *ttm)
> +{
> +	drm_free_large(ttm->pages);
> +	ttm->pages = NULL;
> +}
> +EXPORT_SYMBOL(ttm_tt_fini);
> +
> +int ttm_dma_tt_init(struct ttm_dma_tt *ttm_dma, struct ttm_bo_device *bdev,
> +		unsigned long size, uint32_t page_flags,
> +		struct page *dummy_read_page)
> +{
> +	struct ttm_tt *ttm = &ttm_dma->ttm;
> +
> +	ttm->bdev = bdev;
> +	ttm->glob = bdev->glob;
> +	ttm->num_pages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
> +	ttm->caching_state = tt_cached;
> +	ttm->page_flags = page_flags;
> +	ttm->dummy_read_page = dummy_read_page;
> +	ttm->state = tt_unpopulated;
> +
> +	INIT_LIST_HEAD(&ttm_dma->pages_list);
> +	ttm_dma_tt_alloc_page_directory(ttm_dma);
> +	if (!ttm->pages || !ttm_dma->dma_address) {
> +		ttm_tt_destroy(ttm);
> +		printk(KERN_ERR TTM_PFX "Failed allocating page table\n");
> +		return -ENOMEM;
> +	}
> +	return 0;
> +}
> +EXPORT_SYMBOL(ttm_dma_tt_init);

EXPORT_SYMBOL_GPL ?

> +
> +void ttm_dma_tt_fini(struct ttm_dma_tt *ttm_dma)
> +{
> +	struct ttm_tt *ttm = &ttm_dma->ttm;
> +
> +	drm_free_large(ttm->pages);
> +	ttm->pages = NULL;
> +	drm_free_large(ttm_dma->dma_address);
> +	ttm_dma->dma_address = NULL;
> +}
> +EXPORT_SYMBOL(ttm_dma_tt_fini);
> +

EXPORT_SYMBOL_GPL?


>  void ttm_tt_unbind(struct ttm_tt *ttm)
>  {
>  	int ret;
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c
> index 3986d74..1e2c0fb 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c
> @@ -168,6 +168,7 @@ static void vmw_ttm_destroy(struct ttm_tt *ttm)
>  {
>  	struct vmw_ttm_tt *vmw_be = container_of(ttm, struct vmw_ttm_tt, ttm);
>  
> +	ttm_tt_fini(ttm);
>  	kfree(vmw_be);
>  }
>  
> @@ -191,6 +192,7 @@ struct ttm_tt *vmw_ttm_tt_create(struct ttm_bo_device *bdev,
>  	vmw_be->dev_priv = container_of(bdev, struct vmw_private, bdev);
>  
>  	if (ttm_tt_init(&vmw_be->ttm, bdev, size, page_flags, dummy_read_page)) {
> +		kfree(vmw_be);
>  		return NULL;
>  	}
>  
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index beef9ab..89caa48 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -104,7 +104,6 @@ enum ttm_caching_state {
>   * @caching_state: The current caching state of the pages.
>   * @state: The current binding state of the pages.
>   * @dma_address: The DMA (bus) addresses of the pages (if TTM_PAGE_FLAG_DMA32)
> - * @alloc_list: used by some page allocation backend
>   *
>   * This is a structure holding the pages, caching- and aperture binding
>   * status for a buffer object that isn't backed by fixed (VRAM / AGP)
> @@ -127,8 +126,23 @@ struct ttm_tt {
>  		tt_unbound,
>  		tt_unpopulated,
>  	} state;
> +};
> +
> +/**
> + * struct ttm_dma_tt
> + *
> + * @ttm: Base ttm_tt struct.
> + * @dma_address: The DMA (bus) addresses of the pages (if TTM_PAGE_FLAG_DMA32)

Not anymore (the TTM_PAGE_FLAG_DMA32 comment).

> + * @pages_list: used by some page allocation backend
> + *
> + * This is a structure holding the pages, caching- and aperture binding
> + * status for a buffer object that isn't backed by fixed (VRAM / AGP)
> + * memory.
> + */
> +struct ttm_dma_tt {
> +	struct ttm_tt ttm;
>  	dma_addr_t *dma_address;
> -	struct list_head alloc_list;
> +	struct list_head pages_list;
>  };
>  
>  #define TTM_MEMTYPE_FLAG_FIXED         (1 << 0)	/* Fixed (on-card) PCI memory */
> @@ -595,6 +609,19 @@ ttm_flag_masked(uint32_t *old, uint32_t new, uint32_t mask)
>  extern int ttm_tt_init(struct ttm_tt *ttm, struct ttm_bo_device *bdev,
>  			unsigned long size, uint32_t page_flags,
>  			struct page *dummy_read_page);
> +extern int ttm_dma_tt_init(struct ttm_dma_tt *ttm_dma, struct ttm_bo_device *bdev,
> +			   unsigned long size, uint32_t page_flags,
> +			   struct page *dummy_read_page);
> +
> +/**
> + * ttm_tt_fini
> + *
> + * @ttm: The struct ttm_tt.
> + *
> + * Free memory of ttm_tt structu

structure
> + */
> +extern void ttm_tt_fini(struct ttm_tt *ttm);
> +extern void ttm_dma_tt_fini(struct ttm_dma_tt *ttm_dma);


.. snip..
>   * Initialize pool allocator.
>   */
>  int ttm_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages);
> @@ -107,8 +78,8 @@ void ttm_dma_page_alloc_fini(void);
>   */
>  extern int ttm_dma_page_alloc_debugfs(struct seq_file *m, void *data);
>  
> -int ttm_dma_populate(struct ttm_tt *ttm, struct device *dev);
> -extern void ttm_dma_unpopulate(struct ttm_tt *ttm, struct device *dev);
> +int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev);
> +extern void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev);
>  
>  #else
>  static inline int ttm_dma_page_alloc_init(struct ttm_mem_global *glob,

You are missing changes to the static implementations in case CONFIG_SWIOTLB is not set.

> -- 
> 1.7.7.1

  reply	other threads:[~2011-11-15 21:07 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-11 22:47 ttm: merge ttm_backend & ttm_tt, introduce ttm dma allocator V5 j.glisse
2011-11-11 22:47 ` [PATCH 01/14] swiotlb: Expose swiotlb_nr_tlb function to modules j.glisse
2011-11-11 22:47 ` [PATCH 02/14] drm/ttm: remove userspace backed ttm object support j.glisse
2011-11-11 22:47 ` [PATCH 03/14] drm/ttm: remove split btw highmen and lowmem page j.glisse
2011-11-11 22:47 ` [PATCH 04/14] drm/ttm: remove unused backend flags field j.glisse
2011-11-11 22:47 ` [PATCH 05/14] drm/ttm: use ttm put pages function to properly restore cache attribute j.glisse
2011-11-11 22:47 ` [PATCH 06/14] drm/ttm: test for dma_address array allocation failure j.glisse
2011-11-11 22:47 ` [PATCH 07/14] drm/ttm: page allocation use page array instead of list j.glisse
2011-11-11 22:47 ` [PATCH 08/14] drm/ttm: merge ttm_backend and ttm_tt V5 j.glisse
2011-11-11 22:47 ` [PATCH 09/14] drm/ttm: introduce callback for ttm_tt populate & unpopulate V4 j.glisse
2011-11-11 22:47 ` [PATCH 10/14] drm/ttm: provide dma aware ttm page pool code V8 j.glisse
2011-11-16 15:50   ` Konrad Rzeszutek Wilk
2011-11-16 16:04     ` Jerome Glisse
2011-11-11 22:47 ` [PATCH 11/14] drm/radeon/kms: enable the ttm dma pool if swiotlb is on V3 j.glisse
2011-11-16 15:46   ` Konrad Rzeszutek Wilk
2011-11-16 16:05     ` Jerome Glisse
2011-11-11 22:47 ` [PATCH 12/14] drm/nouveau: enable the ttm dma pool when swiotlb is active V3 j.glisse
2011-11-11 22:47 ` [PATCH 13/14] drm/ttm: isolate dma data from ttm_tt V3 j.glisse
2011-11-15 21:07   ` Konrad Rzeszutek Wilk [this message]
2011-11-15 21:47     ` Jerome Glisse
2011-11-16  0:35     ` Jerome Glisse
2011-11-16 17:21       ` Konrad Rzeszutek Wilk
2011-11-11 22:47 ` [PATCH 14/14] drm/ttm: simplify memory accounting for ttm user j.glisse
2011-11-14 14:49 ` ttm: merge ttm_backend & ttm_tt, introduce ttm dma allocator V5 Thomas Hellstrom
2011-11-14 16:02   ` Jerome Glisse
2011-11-14 16:06     ` Thomas Hellstrom
2011-11-14 18:54       ` Jerome Glisse
2011-11-14 19:25         ` Thomas Hellstrom
2011-11-16 15:15         ` Konrad Rzeszutek Wilk
2011-11-16 15:31           ` Jerome Glisse
2011-11-16 15:53             ` Konrad Rzeszutek Wilk

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=20111115210746.GA17200@phenom.dumpdata.com \
    --to=konrad.wilk@oracle.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=j.glisse@gmail.com \
    --cc=jglisse@redhat.com \
    --cc=thellstrom@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