Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4088887pxb; Tue, 26 Jan 2021 12:05:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQveY5nLg6UaObMxXujySOyW32RrknKDvYmnp9/5JCWGVl+TxtBBgTbKgAE1UOopnlpyms X-Received: by 2002:a17:906:48cb:: with SMTP id d11mr4553622ejt.334.1611691523430; Tue, 26 Jan 2021 12:05:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611691523; cv=none; d=google.com; s=arc-20160816; b=dDvf/d4BGTlLWkL5T1zB0HsYdnSTdHHOca8QBYChldSC83sso4B4+yLWx7Xn3wyxri CLNW7denYIHWm0+H0DfyoYbsTdVnnfg60ux6nz0HPeQ3vRWkHqalGj6gTvxh6Na9+2v7 phznkSwR5UopTuzrXciABoFwsJTuaBL32kXpD/rVvM6YeyGdJ8PuNPfM5Jb1zHAL2nf4 /8VZCvcVJiT8RYGWmraCA2jgzjFku3KazvJL7NlXb8Ih6cQCoG/LHCdkHy06tHip7Zpu ZMPQhL4K6/bKQRiE972qz5OxuUzWPR+UtHgzRTDd5ITdOwAszADvtAHBdgMvgzyFAgE7 /AEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=W32USTVMA4Na4R83P1ldiQToO8MF00oSxMXfGmTH1mg=; b=YZJuduzh+NsUmOXBuNMQpVCLioRs0BdUA3bWukfure/XcPl9xxDs5WDsDekHEtLn+H THgdKhNTvlSFd1daqjmnibfRFt7rxH54FR6E3N+Z3pf/nBatbDmbORN3NyE3U8BHD8w4 8BqZiRw67SPwin8HMCVwxd3nAxpTnfD2MmPPv4APoEYAXSF+l0Bm8jpcTARFqpO1JSk0 QfYsTa8HZNN8pb+FuU6TjlzKUjgI1TFtq4T+/Z/75n459322srWj2fwkalZNYWNZ7WPX ohQZfDXcbu9bmJclGQQFa/TIN9x/LcgTY2YIaZJ660XLaU6sQeVjXUtStfbNZIxTgR/H 2PfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iGGad8Zv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id c1si6974771eds.18.2021.01.26.12.04.56; Tue, 26 Jan 2021 12:05:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iGGad8Zv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S2392394AbhAZRhW (ORCPT + 99 others); Tue, 26 Jan 2021 12:37:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389616AbhAZHqG (ORCPT ); Tue, 26 Jan 2021 02:46:06 -0500 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 101C7C061351 for ; Mon, 25 Jan 2021 23:33:11 -0800 (PST) Received: by mail-lf1-x12c.google.com with SMTP id h7so21475179lfc.6 for ; Mon, 25 Jan 2021 23:33:10 -0800 (PST) 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=W32USTVMA4Na4R83P1ldiQToO8MF00oSxMXfGmTH1mg=; b=iGGad8ZvGGCQxu9TMHL9veAeJhvUmkKrwjjKMwaNwfuM6xAnAIXUTRwKpHFa4HSTRx KeLwL2AaM4YYKmMFkxUUIAjBjJ1lXLdFg7bTMbgQpY3t2/F7y1zx/+8I+17UEvgsQf9U hb4wGQznDB3Has2Qt7crmDWfW3NkLi3VoHXXcZ3yOj8xzStYt3rajuw/v+hhfch2WAuP UX/D0jb+Hgzg4/WnIvILyeVnI04EY8zOR1i7wnNHkbtvHlgmSZzrpLWh5Ziab6y5ZUoS W8Wfi5503gqbWmfVrzYR7xOw37OYR258L7zhQPidFOK0I8WFj04u7Wv3BRwwDvqSdUqN zl9Q== 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=W32USTVMA4Na4R83P1ldiQToO8MF00oSxMXfGmTH1mg=; b=L24T1neDOIhKZOPTGBcPZEiw3PVYG0xuNTKjifpMd8kCy04jJt6xPef/iAVV64jFDb yas7OOdlK+nsuc98+BSWfT2alhcO1l3rdY+6V6OZjrw1pU2yh3KcdWuGhobvg8gHiMIG p+k3qXkFraNx1mWGiuv4HSmnfgE5uLpZiZ5aSjuJEwjq8SXSA2jdMv+haTg7oTAatHaC nyH/j8wbHJ+J85MAf47iGHYzt8w5ZKwCVYn0ZCsj/OUkD5hgBGxHSvrv480TPXBdQwTa KjQZt0T+eT1PBuxec1DfGl0YoEX2Q2Kym+ep+EdnBLDnVDlD0iQcp1QYxfRJBT8+T3wR iRBg== X-Gm-Message-State: AOAM532yLxcwQFQMz92aBrXXCOBOCa7ZUQAxnARLhEQFtxcoe4prN4K/ 1tosoAdxeYbJEf0/9DVlQamEyN3btBlSa25JVlftaQ== X-Received: by 2002:a19:48d0:: with SMTP id v199mr2093711lfa.535.1611646389475; Mon, 25 Jan 2021 23:33:09 -0800 (PST) MIME-Version: 1.0 References: <20210121175502.274391-1-minchan@kernel.org> <20210121175502.274391-5-minchan@kernel.org> In-Reply-To: <20210121175502.274391-5-minchan@kernel.org> From: John Stultz Date: Mon, 25 Jan 2021 23:32:57 -0800 Message-ID: Subject: Re: [PATCH v4 4/4] dma-buf: heaps: add chunk heap to dmabuf heaps To: Minchan Kim Cc: Andrew Morton , linux-mm , LKML , Hyesoo Yu , david@redhat.com, Michal Hocko , Suren Baghdasaryan , KyongHo Cho , John Dias , Hridya Valsaraju , Sumit Semwal , linux-media , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Christoph Hellwig , Rob Herring , "moderated list:DMA BUFFER SHARING FRAMEWORK" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 21, 2021 at 9:55 AM Minchan Kim wrote: Hey Minchan, Thanks for sending this out! I'm still working through testing with this patch set, so I may have some more feedback tomorrow, but a few quick items I did hit below. > + > +#define CHUNK_PREFIX "chunk-" > + > +static int register_chunk_heap(struct chunk_heap *chunk_heap_info) > +{ > + struct dma_heap_export_info exp_info; > + const char *name = cma_get_name(chunk_heap_info->cma); > + size_t len = strlen(CHUNK_PREFIX) + strlen(name) + 1; > + char *buf = kmalloc(len, GFP_KERNEL); > + > + if (!buf) > + return -ENOMEM; > + > + sprintf(buf, CHUNK_PREFIX"%s", cma_get_name(chunk_heap_info->cma)); > + buf[len] = '\0'; > + > + exp_info.name = buf; > + exp_info.name = cma_get_name(chunk_heap_info->cma); I think you intended to delete this line, as it's overwriting your prefixed name. > + exp_info.ops = &chunk_heap_ops; > + exp_info.priv = chunk_heap_info; > + > + chunk_heap_info->heap = dma_heap_add(&exp_info); > + if (IS_ERR(chunk_heap_info->heap)) { > + kfree(buf); > + return PTR_ERR(chunk_heap_info->heap); > + } > + > + return 0; > +} > + > +static int __init chunk_heap_init(void) > +{ > + unsigned int i; > + > + for (i = 0; i < chunk_heap_count; i++) > + register_chunk_heap(&chunk_heaps[i]); > + > + return 0; > +} > +module_init(chunk_heap_init); > + > +#ifdef CONFIG_OF_EARLY_FLATTREE > + > +static int __init dmabuf_chunk_heap_area_init(struct reserved_mem *rmem) > +{ > + int ret; > + struct cma *cma; > + struct chunk_heap *chunk_heap_info; > + const __be32 *chunk_order; > + > + phys_addr_t align = PAGE_SIZE << max(MAX_ORDER - 1, pageblock_order); > + phys_addr_t mask = align - 1; > + > + if ((rmem->base & mask) || (rmem->size & mask)) { > + pr_err("Incorrect alignment for CMA region\n"); > + return -EINVAL; Passing this check can be tough if you're using dynamically assigned rmem, so it might be helpful for debugging to print the base/size/mask values? thanks -john