Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp24864img; Thu, 21 Mar 2019 13:12:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqzKqDKeo1Fw/0xX87WHBXYwTtz4LWjSJsCCKfRW+syorr9/mCp1rsj3UX40IPMcXdH80HVk X-Received: by 2002:aa7:8ac8:: with SMTP id b8mr5021886pfd.87.1553199162107; Thu, 21 Mar 2019 13:12:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553199162; cv=none; d=google.com; s=arc-20160816; b=l29xzGZE8x6LTScMitUXbkqa3jATlXdNrKrLkkhj2kpauaFuTzHdb/uC1IKipMWejq Kt0TCy5BYdImYlAcCgHVCTyFt8muKnHSg6ft2x44QRf9l76nyjUZ3g95HJk4Oo7V7xov 8zG0mdjRoehXfeoAzuTBQJpcx54F8BXm/W0B7Lyf3C7XUrj29i8NGi0/QHOHrN+PM5Qk oae5PQosdkpseX2CxCOjV6C0YaKvuDgibSBvZY6HWrvXvGLinhc4VOIP8IuBKDpGatkc WESUSeJzGSLED6hOtPBLbC9q+SQM4qXsjkIVMkCwhXrNXw80vNvj0D2507H2qFX+dWuN 0djw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=9P5W3/unLbHiwQeefxsCF7KUs13ROq2ZhWkA041EwJE=; b=OKkEOUVEJ2idVl1M2xMWUmo1Q/1Ek7vaxuPfe+AqifizfSt8r0J1EIyN7XeTjLW2sk Vi8FNJlE3kWsIyhqfIBc0SLGesZCYyBIRsvfd50K8m77/gH5ebGm13380UHIQaAjnNaO VOJ9rgrH9DjGICt25eX2+8fpa1zbBkS9SGARlo/YYbNCrCWrKp+ViJdY0emThBX5f3Lt nqA0BTN/UWIy8ihGUiE261OL+7ch6Da4Uv4ZJX1XuappOidIKRnbe8R6n7mkj9SfxONG uoE1hD4xZuHQb1rC+INGDhWFYpTd7pedfb+OKcTgVfCChYywarmPJv+WMNT7vzSOAHr2 jCQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jwB0sJL7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a5si4894467pgq.384.2019.03.21.13.12.26; Thu, 21 Mar 2019 13:12:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jwB0sJL7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728803AbfCUULP (ORCPT + 99 others); Thu, 21 Mar 2019 16:11:15 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:33547 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728138AbfCUULO (ORCPT ); Thu, 21 Mar 2019 16:11:14 -0400 Received: by mail-wr1-f66.google.com with SMTP id q1so8101379wrp.0 for ; Thu, 21 Mar 2019 13:11:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9P5W3/unLbHiwQeefxsCF7KUs13ROq2ZhWkA041EwJE=; b=jwB0sJL7xU271oin4iKuHvx+pUnTN27Tx2/TiWyOnC0sdez0Wb4+426dnFtOd3gQ8B O90cFHLJrgLpLfI84K+bBjyMLJcYPu7a1TklbxiMfV13ezkTMXdbiKnHFyTHofix4wO6 +MNz5SAoGBlynr/h0U1F7wXIIuT0VKYo8xn/8VmmAMvS9UeOsL0KqRow9Pb6+vYQu+AO ay/neaYZ10/m+G8YSlSQrDMOVAhvQ3PF5/GaQ7xeHLEUlytYYXMMllkknxmq8osuju6C Bq8wNqSWY07+1iRFbIks8e52eOnyb5LTAjLj1i1Gzj4wPg0spF4yJo5xGnMFG3n4+mRm 7Z1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9P5W3/unLbHiwQeefxsCF7KUs13ROq2ZhWkA041EwJE=; b=aJj884kTCPiXy4BuC2sn7ZQgnBCtSxLPX1FNfrvLt1go0Ev6KA1jqQXS8a2Ls9VwME CSPcaEX9yAnQsk6IemJQjia9eEuRyk8RtZqh3TlFD4hiw+TXaeiX4HBLPT4XDpTpsj3M enYGiao2MA9aeLJXhBEcXn48CcW0vtKt7IrOR1KyvIwcaPkJ/66bwAoH8utW3zMpTIdT WTraLtkvgQIpJWNWWbWlm6EDpJ9uYz2l1X1G1FzaSPDQiz+3z9E9e7sEkTzFMacNbOT3 e5MHX5BrwFvkAU841wBMvX9r14ByDYtsTv/zIIQBBAV/6W3gHD3QRDdKsLgFTTQjJqKD +2AQ== X-Gm-Message-State: APjAAAXh+b2rfHt4i99N+B7pG/+YJugwoHra9pQ5o8dMRP6F3OXPCBYS ll7x/STO8DrmResu0vEgkG8OgEhDhIo92wruEnf9mg== X-Received: by 2002:a5d:6682:: with SMTP id l2mr3696549wru.33.1553199072988; Thu, 21 Mar 2019 13:11:12 -0700 (PDT) MIME-Version: 1.0 References: <1551819273-640-1-git-send-email-john.stultz@linaro.org> <1551819273-640-3-git-send-email-john.stultz@linaro.org> <20190319142604.f6puq3ugxrcxsrjs@DESKTOP-E1NTVVP.localdomain> In-Reply-To: <20190319142604.f6puq3ugxrcxsrjs@DESKTOP-E1NTVVP.localdomain> From: John Stultz Date: Thu, 21 Mar 2019 13:11:02 -0700 Message-ID: Subject: Re: [RFC][PATCH 2/5 v2] dma-buf: heaps: Add heap helpers To: Brian Starkey Cc: lkml , Laura Abbott , Benjamin Gaignard , Greg KH , Sumit Semwal , Liam Mark , "Andrew F . Davis" , Chenbo Feng , Alistair Strachan , "dri-devel@lists.freedesktop.org" , nd Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 19, 2019 at 7:26 AM Brian Starkey wrote: > > Hi John, > > On Tue, Mar 05, 2019 at 12:54:30PM -0800, John Stultz wrote: > > ... > > > + > > +void dma_heap_buffer_destroy(struct dma_heap_buffer *heap_buffer) > > +{ > > + struct heap_helper_buffer *buffer = to_helper_buffer(heap_buffer); > > + > > + if (buffer->kmap_cnt > 0) { > > + pr_warn_once("%s: buffer still mapped in the kernel\n", > > + __func__); > > Could be worth something louder like a full WARN. > > > + vunmap(buffer->vaddr); > > + } > > + > > + buffer->free(buffer); > > +} > > + > > ... > > > + > > +static void *dma_heap_dma_buf_kmap(struct dma_buf *dmabuf, > > + unsigned long offset) > > +{ > > + struct dma_heap_buffer *heap_buffer = dmabuf->priv; > > + struct heap_helper_buffer *buffer = to_helper_buffer(heap_buffer); > > + > > + return buffer->vaddr + offset * PAGE_SIZE; > > I think it'd be good to check for NULL vaddr and return NULL in that > case. Less chance of an invalid pointer being accidentally used then. Thanks so much for the feedback! I've added these two suggestions in! -john