Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1960894pxk; Tue, 1 Sep 2020 11:56:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcJfibHGdRiBP9d3w5Hq3YlCGmv/GzW766qUcc2SkeM3UzMEhaSw4nN9zc1nPC0/D3c3ff X-Received: by 2002:a50:fe0a:: with SMTP id f10mr2998800edt.264.1598986606158; Tue, 01 Sep 2020 11:56:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598986606; cv=none; d=google.com; s=arc-20160816; b=QsBlaid0dgSFH5rth5qrzbhXpbLlIcY5lB1rd85yCO7P/AqZLapWX+hHSauWEA903M ZPxxnOdeGQplfxmQRcMwNHtf5vM7G9vwJfQN6m2IDrUV+sGOVG3Ee99JGoi09z3C6ThG RIHUhPRZmAluO2C0tIKf5y5W4Db92+wRGMGJBFX11usyWRmeNGuwN++c2SqFEZrKi/k2 Rz/pE16aTp/copjqunJsjP4bl/HRIJVkwsI8OTZcfQxtlFKIXZ7S+7GO+T/eSBFNZ6q+ hEe+WvHn4GBOzC509s5w+xD9hJFTA4jw6bAW0P/ZPXI8gcPR5byizaN78T5jMSU8XhXx WB4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=DYCtCs6CmVoXAlJPYOEeTb0/5yAQXdC1A6FJl9+QCgw=; b=RrKRP6px4xsJ5ElW2h8hr1YlbIvoQlD4FbjYspZCa3l0piFWq3oqfFsthgcVTkdqG8 ZL7zj/T1lAyHuqWBPQi/Gcjmp9BUIyw3GQXm8CG1mMADc0ZfxW/+W7wFfRmBJ2FXNmGZ rpg7XexdUrL+ib+eonFqoKsiJFPFRdFeysZvW3Y/VX6zhjF05DlGHaLjTiNLRI7zX+W+ Wy27vQy7ckr/W2iZbKoaVvEx+/opkm34TM8haCT2r6u/p0yJizmgY31fpQwmWMupznY/ 8Dke4qnQkukUoc3PYo2y9QocJRMNeE25xlkJ9JjQNZPOuPkhbIECSKm9zV/2SCDdlBg/ nvQA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h1si1094144edt.387.2020.09.01.11.56.23; Tue, 01 Sep 2020 11:56:46 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732148AbgIASzM (ORCPT + 99 others); Tue, 1 Sep 2020 14:55:12 -0400 Received: from foss.arm.com ([217.140.110.172]:48404 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732114AbgIASzA (ORCPT ); Tue, 1 Sep 2020 14:55:00 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2C3121FB; Tue, 1 Sep 2020 11:55:00 -0700 (PDT) Received: from [10.57.40.122] (unknown [10.57.40.122]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 168583F71F; Tue, 1 Sep 2020 11:54:56 -0700 (PDT) Subject: Re: [PATCH v9 11/32] drm: mediatek: use common helper for extracting pages array To: Marek Szyprowski , dri-devel@lists.freedesktop.org, iommu@lists.linux-foundation.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org Cc: Christoph Hellwig , Bartlomiej Zolnierkiewicz , linux-arm-kernel@lists.infradead.org, David Airlie , Daniel Vetter , Matthias Brugger , Chun-Kuang Hu , Philipp Zabel , linux-mediatek@lists.infradead.org References: <20200826063316.23486-1-m.szyprowski@samsung.com> <20200826063316.23486-12-m.szyprowski@samsung.com> From: Robin Murphy Message-ID: <30f20ad6-783b-89c3-17b5-30c6a2587d23@arm.com> Date: Tue, 1 Sep 2020 19:54:55 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200826063316.23486-12-m.szyprowski@samsung.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-08-26 07:32, Marek Szyprowski wrote: > Use common helper for converting a sg_table object into struct > page pointer array. Reviewed-by: Robin Murphy Side note: is mtk_drm_gem_prime_vmap() missing a call to sg_free_table(sgt) before its kfree(sgt)? > Signed-off-by: Marek Szyprowski > --- > drivers/gpu/drm/mediatek/mtk_drm_gem.c | 9 ++------- > 1 file changed, 2 insertions(+), 7 deletions(-) > > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_gem.c b/drivers/gpu/drm/mediatek/mtk_drm_gem.c > index 3654ec732029..0583e557ad37 100644 > --- a/drivers/gpu/drm/mediatek/mtk_drm_gem.c > +++ b/drivers/gpu/drm/mediatek/mtk_drm_gem.c > @@ -233,9 +233,7 @@ void *mtk_drm_gem_prime_vmap(struct drm_gem_object *obj) > { > struct mtk_drm_gem_obj *mtk_gem = to_mtk_gem_obj(obj); > struct sg_table *sgt; > - struct sg_page_iter iter; > unsigned int npages; > - unsigned int i = 0; > > if (mtk_gem->kvaddr) > return mtk_gem->kvaddr; > @@ -249,11 +247,8 @@ void *mtk_drm_gem_prime_vmap(struct drm_gem_object *obj) > if (!mtk_gem->pages) > goto out; > > - for_each_sg_page(sgt->sgl, &iter, sgt->orig_nents, 0) { > - mtk_gem->pages[i++] = sg_page_iter_page(&iter); > - if (i > npages) > - break; > - } > + drm_prime_sg_to_page_addr_arrays(sgt, mtk_gem->pages, NULL, npages); > + > mtk_gem->kvaddr = vmap(mtk_gem->pages, npages, VM_MAP, > pgprot_writecombine(PAGE_KERNEL)); > >