Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1200656
| From | Michal Nazarewicz <mina86@mina86.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] CMA: Don't return a valid cma for non-cma dev |
| Date | 2015-08-05 13:20 +0200 |
| Message-ID | <pU4TL-85f-17@gated-at.bofh.it> (permalink) |
| References | (4 earlier) <pSk6C-Yx-21@gated-at.bofh.it> <pSmBu-4qd-21@gated-at.bofh.it> <pU31E-5mp-3@gated-at.bofh.it> <pU47o-6U1-21@gated-at.bofh.it> <pU4qJ-7hH-15@gated-at.bofh.it> |
| Organization | http://mina86.com/ |
> On Wed, Aug 05, 2015 at 12:28:03PM +0200, Michal Nazarewicz wrote:
>> If you need several CMA areas to allocate from, create multiple struct
>> devices.
On Wed, Aug 05 2015, Feng Tang wrote:
> I've made a quick patch, which works ok on our multiple cma heap cases.
> ---
> diff --git a/drivers/staging/android/ion/ion_cma_heap.c b/drivers/staging/android/ion/ion_cma_heap.c
> index f4211f1..ee9c5d1 100644
> --- a/drivers/staging/android/ion/ion_cma_heap.c
> +++ b/drivers/staging/android/ion/ion_cma_heap.c
> @@ -29,6 +29,7 @@
> struct ion_cma_heap {
> struct ion_heap heap;
> struct device *dev;
> + struct device default_dma_dev;
I’m unfamiliar with ION code so cannot comment in great detail, butwhy
do you need dev and default_dma_dev fields? Just make dev a non-pointer
and use that.
> };
>
> #define to_cma_heap(x) container_of(x, struct ion_cma_heap, heap)
> @@ -180,9 +181,14 @@ struct ion_heap *ion_cma_heap_create(struct ion_platform_heap *data)
> return ERR_PTR(-ENOMEM);
>
> cma_heap->heap.ops = &ion_cma_ops;
> - /* get device from private heaps data, later it will be
> - * used to make the link with reserved CMA memory */
> - cma_heap->dev = data->priv;
> +
> + cma_heap->dev = &cma_heap->default_dma_dev;
> + cma_heap->dev->coherent_dma_mask = DMA_BIT_MASK(32);
> + cma_heap->dev->dma_mask = &dev->coherent_dma_mask;
> +
> + /* data->priv contains a pointer to struct cma */
> + dev_set_cma_area(cma_heap->dev, data->priv);
In the previous code, data->priv seemed to be struct device*, but in
this code it is used as struct cma*.
> +
> cma_heap->heap.type = ION_HEAP_TYPE_DMA;
> return &cma_heap->heap;
> }
But yeah, in general, from CMA’s point of view, this looks good.
--
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michał “mina86” Nazarewicz (o o)
ooo +--<mpn@google.com>--<xmpp:mina86@jabber.org>--ooO--(_)--Ooo--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: [PATCH] CMA: Don't return a valid cma for non-cma dev Feng Tang <feng.tang@intel.com> - 2015-08-05 11:20 +0200
Re: [PATCH] CMA: Don't return a valid cma for non-cma dev Michal Nazarewicz <mina86@mina86.com> - 2015-08-05 12:30 +0200
Re: [PATCH] CMA: Don't return a valid cma for non-cma dev Feng Tang <feng.tang@intel.com> - 2015-08-05 12:40 +0200
Re: [PATCH] CMA: Don't return a valid cma for non-cma dev Feng Tang <feng.tang@intel.com> - 2015-08-05 12:50 +0200
Re: [PATCH] CMA: Don't return a valid cma for non-cma dev Michal Nazarewicz <mina86@mina86.com> - 2015-08-05 13:20 +0200
Re: [PATCH] CMA: Don't return a valid cma for non-cma dev Feng Tang <feng.tang@intel.com> - 2015-08-05 15:20 +0200
csiph-web