Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp912661rdb; Fri, 1 Dec 2023 01:47:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IHlwm7xjt6iApM8NFG5HpS+vSv11AX80QppGJKbS9n13oOvy4cA3LWTAQb0Elndd0VaVH1k X-Received: by 2002:a05:6e02:792:b0:35c:611c:c2a4 with SMTP id q18-20020a056e02079200b0035c611cc2a4mr24948769ils.24.1701424059015; Fri, 01 Dec 2023 01:47:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701424058; cv=none; d=google.com; s=arc-20160816; b=r3TNxxvAX/ET7gvxPzxDWmvok7pnKwzMcU9v37lYTf2b3CQzZQ83BZWS5TOsx299m2 hxeTMrR4BPmbYnOYxo20zVNicuTgB/wIa0POGhjwdKfE0aBR5UDfJxO5IDhXwzThOOm2 UBevOezNHJ2KH78HWhGDHH4LyvhRnv85dk5Xe1cT7ofh2E4OX+LZv6ieoiSRCbAoAUu4 FtuIbXB8glSyv4o57CoRjyvcMFeua6zrN1PXqa9IfQ+GAgKD3RGLh2r0N+J0zAsplmWA aVGV5LLQa3+qbpce0/giVC/U9IFlVAMmiHBNOEFsaPX5os8IeViI5ElBnW8T9dyDCqNE zUKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:autocrypt :from:references:cc:to:content-language:subject:user-agent :mime-version:date:message-id:dkim-signature; bh=4BbyvAGvhh+6Pb2VBUqbRWe/SgLKCJhyAKnPND5uhCc=; fh=SLY62hvWHM05fOu6G3NnCddKoBhppOxjpMSaIq9DQuI=; b=0iS0pn9GSfkCVhP73RbHwkfTVV4Ucs6zyZ5/rzzeG796uyUXaSKv1mZrjH5qrjXthx sMLOFXQtOyG9OunDMyaPaXAn3afvGLjDswxWsd7f5ClFTNBURMa1jr92VBCljpqi9KJp br1Lc7hd6HcrDDxegRl0iFENFvGE1gRbkrOpYalYQ/zLhueIRqzDfCNk0E2/MQuyuLhI m+qZLVtwbjHcLOgX0iif2dgHbvUKE83sZ6qFvr+fOPClr+Ty8TYNyElTCaJPv5IGSk0U HTfQUsT8pBB3DXfe+WOpX5CTEo9IX3KqtblQvWdug3YMk/lTSrTT1WISizLSdYdF87wg 51DQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=gr3CtMky; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id h193-20020a636cca000000b005c6259da615si3045884pgc.271.2023.12.01.01.47.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 01:47:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=gr3CtMky; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 8D1448080EF7; Fri, 1 Dec 2023 01:47:36 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378052AbjLAJrR (ORCPT + 99 others); Fri, 1 Dec 2023 04:47:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377899AbjLAJrQ (ORCPT ); Fri, 1 Dec 2023 04:47:16 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 608F010F9 for ; Fri, 1 Dec 2023 01:47:21 -0800 (PST) Received: from [192.168.88.20] (91-158-149-209.elisa-laajakaista.fi [91.158.149.209]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 49864D52; Fri, 1 Dec 2023 10:46:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1701424001; bh=sGOmHRHvL/BapzPSylBybPfKNcDvouT8hH1hH24PyM4=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=gr3CtMkyrGL7o9zgsbQ3lwkknSwAp3epPFPSXcOP+mnUJtg+4EELjakpYNxFMWUpt +944LXKeNi3Zg508ZHtStsM1A3wHkvRLEL4J/wjGTJDpMa3lOLJel6dQEZl+36Q3On i1ALqPFVCTLyzvfUVW43SoWYTefPIbVd2+M5KsZA= Message-ID: <0c2e0f85-0a35-43b2-ba78-4aebbaa2b379@ideasonboard.com> Date: Fri, 1 Dec 2023 11:47:15 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] drm: omapdrm: Improve check for contiguous buffers Content-Language: en-US To: Andrew Davis , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20231113205501.616927-1-afd@ti.com> From: Tomi Valkeinen Autocrypt: addr=tomi.valkeinen@ideasonboard.com; keydata= xsFNBE6ms0cBEACyizowecZqXfMZtnBniOieTuFdErHAUyxVgtmr0f5ZfIi9Z4l+uUN4Zdw2 wCEZjx3o0Z34diXBaMRJ3rAk9yB90UJAnLtb8A97Oq64DskLF81GCYB2P1i0qrG7UjpASgCA Ru0lVvxsWyIwSfoYoLrazbT1wkWRs8YBkkXQFfL7Mn3ZMoGPcpfwYH9O7bV1N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eaVGHiR4TnNFiT3otD5UpYQI7S suYxoTdHrrrBzdlKe5rUWpzoZkVK6p0s9OIvGzLT0lrb0HC9iNDWT3JgpYDnk4Z2mFi6tTbq xKMtpVFRA6FjviGDRsfkfoURZI51nf2RSAk/A8BEDDZ7lgJHskYoklSpwyrXhkp9FHGMaYII m9EKuUTX9JPDG2FTthCBrdsgWYPdJQvM+zscq09vFMQ9Fykbx5N8z/oFEUy3ACyPqW2oyfvU CH5WDpWBG0s5BALp1gBJPytIAd/pY/5ZdNoi0Cx3+Z7jaBFEyYJdWy1hGddpkgnMjyOfLI7B CFrdecTZbR5upjNSDvQ7RG85SnpYJTIin+SAUazAeA2nS6gTZzumgtdw8XmVXZwdBfF+ICof 92UkbYcYNbzWO/GHgsNT1WnM4sa9lwCSWH8Fw1o/3bX1VVPEsnESOfxkNdu+gAF5S6+I6n3a ueeIlwJl5CpT5l8RpoZXEOVtXYn8zzOJ7oGZYINRV9Pf8qKGLf3Dft7zKBP832I3PQjeok7F yjt+9S+KgSFSHP3Pa4E7lsSdWhSlHYNdG/czhoUkSCN09C0rEK93wxACx3vtxPLjXu6RptBw 3dRq7n+mQChEB1am0BueV1JZaBboIL0AGlSJkm23kw== In-Reply-To: <20231113205501.616927-1-afd@ti.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 01 Dec 2023 01:47:36 -0800 (PST) On 13/11/2023 22:55, Andrew Davis wrote: > While a scatter-gather table having only 1 entry does imply it is > contiguous, it is a logic error to assume the inverse. Tables can have > more than 1 entry and still be contiguous. Use a proper check here. > > Signed-off-by: Andrew Davis > --- Thanks, I'll pick this up. Tomi > Changes from v2: > - Double check that these multi-segment SGTs are handled correctly elsewhere in the driver > - Rebase on v6.7-rc1 > > Changes from v1: > - Sent correct version of patch :) > > drivers/gpu/drm/omapdrm/omap_gem.c | 14 ++++++++++---- > 1 file changed, 10 insertions(+), 4 deletions(-) > > diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c > index c48fa531ca321..3421e8389222a 100644 > --- a/drivers/gpu/drm/omapdrm/omap_gem.c > +++ b/drivers/gpu/drm/omapdrm/omap_gem.c > @@ -48,7 +48,7 @@ struct omap_gem_object { > * OMAP_BO_MEM_DMA_API flag set) > * > * - buffers imported from dmabuf (with the OMAP_BO_MEM_DMABUF flag set) > - * if they are physically contiguous (when sgt->orig_nents == 1) > + * if they are physically contiguous > * > * - buffers mapped through the TILER when pin_cnt is not zero, in which > * case the DMA address points to the TILER aperture > @@ -148,12 +148,18 @@ u64 omap_gem_mmap_offset(struct drm_gem_object *obj) > return drm_vma_node_offset_addr(&obj->vma_node); > } > > +static bool omap_gem_sgt_is_contiguous(struct sg_table *sgt, size_t size) > +{ > + return !(drm_prime_get_contiguous_size(sgt) < size); > +} > + > static bool omap_gem_is_contiguous(struct omap_gem_object *omap_obj) > { > if (omap_obj->flags & OMAP_BO_MEM_DMA_API) > return true; > > - if ((omap_obj->flags & OMAP_BO_MEM_DMABUF) && omap_obj->sgt->nents == 1) > + if ((omap_obj->flags & OMAP_BO_MEM_DMABUF) && > + omap_gem_sgt_is_contiguous(omap_obj->sgt, omap_obj->base.size)) > return true; > > return false; > @@ -1385,7 +1391,7 @@ struct drm_gem_object *omap_gem_new_dmabuf(struct drm_device *dev, size_t size, > union omap_gem_size gsize; > > /* Without a DMM only physically contiguous buffers can be supported. */ > - if (sgt->orig_nents != 1 && !priv->has_dmm) > + if (!omap_gem_sgt_is_contiguous(sgt, size) && !priv->has_dmm) > return ERR_PTR(-EINVAL); > > gsize.bytes = PAGE_ALIGN(size); > @@ -1399,7 +1405,7 @@ struct drm_gem_object *omap_gem_new_dmabuf(struct drm_device *dev, size_t size, > > omap_obj->sgt = sgt; > > - if (sgt->orig_nents == 1) { > + if (omap_gem_sgt_is_contiguous(sgt, size)) { > omap_obj->dma_addr = sg_dma_address(sgt->sgl); > } else { > /* Create pages list from sgt */