Return-path: Received: from mx08-00178001.pphosted.com ([91.207.212.93]:34287 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753067AbcKUQlb (ORCPT ); Mon, 21 Nov 2016 11:41:31 -0500 From: Hugues FRUCHET To: Hans Verkuil , "linux-media@vger.kernel.org" CC: "kernel@stlinux.com" , Benjamin Gaignard , Jean Christophe TROTIN Date: Mon, 21 Nov 2016 17:41:26 +0100 Subject: Re: [PATCH v2 06/10] [media] st-delta: add contiguous memory allocator Message-ID: <63d8c335-4a3d-b406-b5a7-0a8741b741f3@st.com> References: <1479468336-26199-1-git-send-email-hugues.fruchet@st.com> <1479468336-26199-7-git-send-email-hugues.fruchet@st.com> <41a23991-114e-de14-5c90-0996abb3777e@xs4all.nl> In-Reply-To: <41a23991-114e-de14-5c90-0996abb3777e@xs4all.nl> Content-Language: en-US Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org List-ID: Hi Hans, Thanks for review, I will change the commit message to "[media] st-delta: add memory allocator helper functions" and add commit messages. BR, Hugues. On 11/21/2016 02:46 PM, Hans Verkuil wrote: > This needs a proper commit message since it is not clear who will use this. > > I'm not sure I would call it a 'contiguous memory allocator': this are > really > just helper functions, if I understand it correctly. > > 'contiguous memory allocator' is also what 'CMA' stands for, so that's > confusing. > > Note: you have empty commit messages for other patches in this series as > well, > please always provide a valid commit message! > > Regards, > > Hans > > On 18/11/16 12:25, Hugues Fruchet wrote: >> Signed-off-by: Hugues Fruchet >> --- >> drivers/media/platform/sti/delta/Makefile | 2 +- >> drivers/media/platform/sti/delta/delta-mem.c | 51 ++++++++++++++++++++++++++++ >> drivers/media/platform/sti/delta/delta-mem.h | 14 ++++++++ >> drivers/media/platform/sti/delta/delta.h | 8 +++++ >> 4 files changed, 74 insertions(+), 1 deletion(-) >> create mode 100644 drivers/media/platform/sti/delta/delta-mem.c >> create mode 100644 drivers/media/platform/sti/delta/delta-mem.h >> >> diff --git a/drivers/media/platform/sti/delta/Makefile b/drivers/media/platform/sti/delta/Makefile >> index 07ba7ad..cbfb1b5 100644 >> --- a/drivers/media/platform/sti/delta/Makefile >> +++ b/drivers/media/platform/sti/delta/Makefile >> @@ -1,2 +1,2 @@ >> obj-$(CONFIG_VIDEO_STI_DELTA) := st-delta.o >> -st-delta-y := delta-v4l2.o >> +st-delta-y := delta-v4l2.o delta-mem.o >> diff --git a/drivers/media/platform/sti/delta/delta-mem.c b/drivers/media/platform/sti/delta/delta-mem.c >> new file mode 100644 >> index 0000000..d7b53d3 >> --- /dev/null >> +++ b/drivers/media/platform/sti/delta/delta-mem.c >> @@ -0,0 +1,51 @@ >> +/* >> + * Copyright (C) STMicroelectronics SA 2015 >> + * Author: Hugues Fruchet for STMicroelectronics. >> + * License terms: GNU General Public License (GPL), version 2 >> + */ >> + >> +#include "delta.h" >> +#include "delta-mem.h" >> + >> +int hw_alloc(struct delta_ctx *ctx, u32 size, const char *name, >> + struct delta_buf *buf) >> +{ >> + struct delta_dev *delta = ctx->dev; >> + dma_addr_t dma_addr; >> + void *addr; >> + unsigned long attrs = DMA_ATTR_WRITE_COMBINE; >> + >> + addr = dma_alloc_attrs(delta->dev, size, &dma_addr, >> + GFP_KERNEL | __GFP_NOWARN, attrs); >> + if (!addr) { >> + dev_err(delta->dev, >> + "%s hw_alloc:dma_alloc_coherent failed for %s (size=%d)\n", >> + ctx->name, name, size); >> + ctx->sys_errors++; >> + return -ENOMEM; >> + } >> + >> + buf->size = size; >> + buf->paddr = dma_addr; >> + buf->vaddr = addr; >> + buf->name = name; >> + buf->attrs = attrs; >> + >> + dev_dbg(delta->dev, >> + "%s allocate %d bytes of HW memory @(virt=0x%p, phy=0x%pad): %s\n", >> + ctx->name, size, buf->vaddr, &buf->paddr, buf->name); >> + >> + return 0; >> +} >> + >> +void hw_free(struct delta_ctx *ctx, struct delta_buf *buf) >> +{ >> + struct delta_dev *delta = ctx->dev; >> + >> + dev_dbg(delta->dev, >> + "%s free %d bytes of HW memory @(virt=0x%p, phy=0x%pad): %s\n", >> + ctx->name, buf->size, buf->vaddr, &buf->paddr, buf->name); >> + >> + dma_free_attrs(delta->dev, buf->size, >> + buf->vaddr, buf->paddr, buf->attrs); >> +} >> diff --git a/drivers/media/platform/sti/delta/delta-mem.h b/drivers/media/platform/sti/delta/delta-mem.h >> new file mode 100644 >> index 0000000..f8ca109 >> --- /dev/null >> +++ b/drivers/media/platform/sti/delta/delta-mem.h >> @@ -0,0 +1,14 @@ >> +/* >> + * Copyright (C) STMicroelectronics SA 2015 >> + * Author: Hugues Fruchet for STMicroelectronics. >> + * License terms: GNU General Public License (GPL), version 2 >> + */ >> + >> +#ifndef DELTA_MEM_H >> +#define DELTA_MEM_H >> + >> +int hw_alloc(struct delta_ctx *ctx, u32 size, const char *name, >> + struct delta_buf *buf); >> +void hw_free(struct delta_ctx *ctx, struct delta_buf *buf); >> + >> +#endif /* DELTA_MEM_H */ >> diff --git a/drivers/media/platform/sti/delta/delta.h b/drivers/media/platform/sti/delta/delta.h >> index 6b48460..d31cb9a 100644 >> --- a/drivers/media/platform/sti/delta/delta.h >> +++ b/drivers/media/platform/sti/delta/delta.h >> @@ -191,6 +191,14 @@ struct delta_dts { >> u64 val; >> }; >> >> +struct delta_buf { >> + u32 size; >> + void *vaddr; >> + dma_addr_t paddr; >> + const char *name; >> + unsigned long attrs; >> +}; >> + >> struct delta_ctx; >> >> /* >>