From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2235EC433DB for ; Tue, 26 Jan 2021 19:24:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A299B22B2C for ; Tue, 26 Jan 2021 19:24:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A299B22B2C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3A31B8D010E; Tue, 26 Jan 2021 14:24:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 354418D00F8; Tue, 26 Jan 2021 14:24:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1CE358D010E; Tue, 26 Jan 2021 14:24:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0053.hostedemail.com [216.40.44.53]) by kanga.kvack.org (Postfix) with ESMTP id 007928D00F8 for ; Tue, 26 Jan 2021 14:24:48 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id B896B1EE6 for ; Tue, 26 Jan 2021 19:24:48 +0000 (UTC) X-FDA: 77748903456.18.legs53_230bd7827590 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id 829DA100ED9CA for ; Tue, 26 Jan 2021 19:24:48 +0000 (UTC) X-HE-Tag: legs53_230bd7827590 X-Filterd-Recvd-Size: 6976 Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by imf03.hostedemail.com (Postfix) with ESMTP for ; Tue, 26 Jan 2021 19:24:47 +0000 (UTC) Received: by mail-pj1-f41.google.com with SMTP id s24so1266365pjp.5 for ; Tue, 26 Jan 2021 11:24:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=PQEAhCm3+TMoHM6fCNFPYeDIJ30oYf/VDFpXx3VbChw=; b=pdxOOP16unQeTfJM+vcSmtoc9otBE7D1QLUGBMbUYwwc34fV0mmt1KNHQcGy+JP0cp 53WCFFjL8QIOoe4118TDseHG68AAfQPg+8uzBDlf7Vk8eIPb8XprP3FU8DM1Fx7jAwJ4 5dqxSza5b9ihAmhyNhw+OIYVCN/olOVqT//FYm+DX+irUbO4Hy7VwOpBEZD81ZgyAHoB IHHnsDCgxxMP0KCAEbhJUDrkzNhPyOaNAGPa4BSQwgPDSLRKZr8VE5N8LUaR6/Zbz3K6 GuKzfXkjki5oS4gGXjjW50XwR7uc+G2V5R93Dzcx3edaVBVeekPcoJzppscpK0pLvETu d8Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=PQEAhCm3+TMoHM6fCNFPYeDIJ30oYf/VDFpXx3VbChw=; b=kYyRo+7R4dvXlW6CpJC2FNBEkHGrSVmN3lK8mdK7vrM1m/vHPEPsckz0pMIm14T1my quNYp2mbVsLMUld4aqkSbMVf596cuZevnNhBYXiZsiVZ/BPuFIjzFzvx75Zbg1O4D6Tf VaDGe3zqsQKX72O+lWFpYL7iJgSx+6c8XLlJt72auLda7ytuN53FzcSYG+jk++EsEnjS uicrrHsBZp+1jmTZs1ay4boyosIgVV6laY8Ktd/R75BQwXqlNZ9g8iCQJvB/87DmZtPL Ri432QCiMbWh0s3/Ys/jyPLJ4k3rWYBeyU+I2I4C6n6m1dl0jnxOoMr9jbWmBykgs0di s1SQ== X-Gm-Message-State: AOAM5307s5Mp4gyfDC4Y1jsNqln3thVPlK5j0ybymxhbfpkMNAnqYCp5 BdS7ttVomKXu4U2BzA046SM= X-Google-Smtp-Source: ABdhPJxdJr9i8PyYeuFQBxPxm7+nZIJNNDk8XULgbT6ihBzMPiuZA67mDinh9JKsG2HkLZaC7sxFnw== X-Received: by 2002:a17:90a:5403:: with SMTP id z3mr1385657pjh.198.1611689087020; Tue, 26 Jan 2021 11:24:47 -0800 (PST) Received: from google.com ([2620:15c:211:201:9dd5:b47b:bb84:dede]) by smtp.gmail.com with ESMTPSA id jx15sm2818337pjb.17.2021.01.26.11.24.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jan 2021 11:24:45 -0800 (PST) Date: Tue, 26 Jan 2021 11:24:43 -0800 From: Minchan Kim To: John Stultz 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" Subject: Re: [PATCH v4 4/4] dma-buf: heaps: add chunk heap to dmabuf heaps Message-ID: References: <20210121175502.274391-1-minchan@kernel.org> <20210121175502.274391-5-minchan@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Jan 25, 2021 at 11:32:57PM -0800, John Stultz wrote: > 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. Hi John, You're right. Will fix it. > > > + 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? Let me fold this into next respin. diff --git a/drivers/dma-buf/heaps/chunk_heap.c b/drivers/dma-buf/heaps/chunk_heap.c index 6fe8e69d108f..cc2ed5341b54 100644 --- a/drivers/dma-buf/heaps/chunk_heap.c +++ b/drivers/dma-buf/heaps/chunk_heap.c @@ -456,7 +456,8 @@ static int __init dmabuf_chunk_heap_area_init(struct reserved_mem *rmem) phys_addr_t mask = align - 1; if ((rmem->base & mask) || (rmem->size & mask)) { - pr_err("Incorrect alignment for CMA region\n"); + pr_err("Incorrect alignment for CMA region: base %pa size %pa mask %pa\n", + rmem->base, rmem->size, mask); return -EINVAL; } Thanks for the review, John!