From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752763AbbHENN2 (ORCPT ); Wed, 5 Aug 2015 09:13:28 -0400 Received: from mga11.intel.com ([192.55.52.93]:53720 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751390AbbHENNZ (ORCPT ); Wed, 5 Aug 2015 09:13:25 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,617,1432623600"; d="scan'208";a="536452240" Date: Wed, 5 Aug 2015 21:22:38 +0800 From: Feng Tang To: Michal Nazarewicz Cc: "linux-kernel@vger.kernel.org" , "m.szyprowski@samsung.com" , "kyungmin.park@samsung.com" , "akpm@linux-foundation.org" , "iamjoonsoo.kim@lge.com" , "john.stultz@linaro.org" Subject: Re: [PATCH] CMA: Don't return a valid cma for non-cma dev Message-ID: <20150805132238.GB8875@shbuild888> References: <1438223828-26140-1-git-send-email-feng.tang@intel.com> <1438311070.4299.1.camel@intel.com> <20150731151816.GA18347@shbuild888> <20150805091917.GA27241@shbuild888> <20150805105558.GA8875@shbuild888> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 05, 2015 at 01:15:50PM +0200, Michal Nazarewicz wrote: > > 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. Good point. I've thought about keeping dev to be back compatible with current code, and only use default_dma_dev when no "dev" is passed in platform data. But from your other comments, it may be not necessary to keep the "dev" > > > }; > > > > #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*. As we are going to use per cma-heap's own "default_dma_dev", the "data->priv" should be a pointer to "struct cma*", which makes more sense, as when a cma heap is created, we'd better provide a "struct cma *" to tell it where to request cma buffer. > > > + > > 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. Thanks! Will try to clean the code and add more comments, then send it out for review. - Feng