From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965750AbcAURjH (ORCPT ); Thu, 21 Jan 2016 12:39:07 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35396 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965590AbcAURjE (ORCPT ); Thu, 21 Jan 2016 12:39:04 -0500 Subject: Re: [PATCH] staging: android: ion: Set the length of the DMA sg entries in buffer To: "Jon Medhurst (Tixy)" , Greg Kroah-Hartman , =?UTF-8?Q?Arve_Hj=c3=b8nnev=c3=a5g?= , Riley Andrews References: <1453377467.2858.14.camel@linaro.org> Cc: Liviu Dudau , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org From: Laura Abbott Message-ID: <56A117B6.7050503@redhat.com> Date: Thu, 21 Jan 2016 09:39:02 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: <1453377467.2858.14.camel@linaro.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/21/2016 03:57 AM, Jon Medhurst (Tixy) wrote: > From: Liviu Dudau > > ion_buffer_create() will allocate a buffer and then create a DMA > mapping for it, but it forgot to set the length of the page entries. > > Signed-off-by: Liviu Dudau > Signed-off-by: Jon Medhurst > --- > drivers/staging/android/ion/ion.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c > index e237e9f..df56021 100644 > --- a/drivers/staging/android/ion/ion.c > +++ b/drivers/staging/android/ion/ion.c > @@ -251,8 +251,10 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap, > * memory coming from the heaps is ready for dma, ie if it has a > * cached mapping that mapping has been invalidated > */ > - for_each_sg(buffer->sg_table->sgl, sg, buffer->sg_table->nents, i) > + for_each_sg(buffer->sg_table->sgl, sg, buffer->sg_table->nents, i) { > sg_dma_address(sg) = sg_phys(sg); > + sg_dma_len(sg) = sg->length; > + } > mutex_lock(&dev->buffer_lock); > ion_buffer_add(dev, buffer); > mutex_unlock(&dev->buffer_lock); > So Ion is really doing it wrong by setting the sg_dma_address manually as the comment above notes. Ion has moved away from sg_dma_len though (see 06e0dcaeb4fd72a010a1f5ad0c03abd8e0a58ef9). This isn't technically a mapping as well. What's broken by not having sg_dma_len set? Thanks, Laura