From patchwork Tue Dec 3 16:32:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 11271605 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ED3E9159A for ; Tue, 3 Dec 2019 16:32:12 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D62AE20675 for ; Tue, 3 Dec 2019 16:32:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D62AE20675 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3CAB56E9EA; Tue, 3 Dec 2019 16:32:09 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7E0E26E9EA for ; Tue, 3 Dec 2019 16:32:08 +0000 (UTC) Received: by mail-wm1-x344.google.com with SMTP id f129so4242314wmf.2 for ; Tue, 03 Dec 2019 08:32:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9+5X8T1e9hRpXIXFZg1NPo8MjmX2IuYdom9kAI//J+o=; b=XbO2dLD9VibDLDez/yi49140rrnxsCAtgtEgpYUriHo0EyUtbOkL8N1Ou61IG7Jwf0 XvGHSuCAs5AS71MGebzRh6Hb09FgKvLFCKgjwKSdu8nTWVVOeikQzoldrl6+OP+u9BfY vQxJwJpqx9qaDFNy76ReprRXIHb11nRDYSKwVV6iDp8B/TeRW6iQGK/VR09h3vktr/bm LOjABiKeFcpLkam+WFlhXDntDoRo15fBRKD1hqyy/Zc4t5KN2OpsCOwvj3zb9gUSSZRv Yn7he7mED7GnRlX/kFyjj2pBy86RpDegIEqxsaRFbTt/phc2Wo19964OMYFdU0tmbpW+ VHZw== X-Gm-Message-State: APjAAAUGr7g/otW2H4eny88cTXj7dXyhZVJFHO1lgY7pDhb7Q7Xppfh5 IPzgLNxDilbuQCjqVwgBQY8= X-Google-Smtp-Source: APXvYqzOOcKTaW7GhzPsuaxOQCcVpGuf35zh5toqs1OS7u7PG84TbcFn+UpOIoBmykGNDW6kwGp2zg== X-Received: by 2002:a1c:3803:: with SMTP id f3mr29839022wma.134.1575390727042; Tue, 03 Dec 2019 08:32:07 -0800 (PST) Received: from localhost (pD9E518ED.dip0.t-ipconnect.de. [217.229.24.237]) by smtp.gmail.com with ESMTPSA id l17sm3559762wme.45.2019.12.03.08.32.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2019 08:32:06 -0800 (PST) From: Thierry Reding To: Thierry Reding Subject: [PATCH 2/3] drm/cma-helper: Use sgt_dma_contiguous() helper Date: Tue, 3 Dec 2019 17:32:02 +0100 Message-Id: <20191203163203.1486837-2-thierry.reding@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191203163203.1486837-1-thierry.reding@gmail.com> References: <20191203163203.1486837-1-thierry.reding@gmail.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9+5X8T1e9hRpXIXFZg1NPo8MjmX2IuYdom9kAI//J+o=; b=hNKazjUsDMTafj6NH2ZsTDB75Dvo/1uUIYIEBgWNqDG673w8LZtv9LEAwiZf03eBPA qwbZC0C3pYALrzSP4kWPEVaFwGyMSAFfg7QKaTgQkzMKMvMQvYnL3IYVBv5aO+uaTF8x eyE6UhCauBAn+dLdc6eIr5s2age6Y+Dy6o1ENABd2o7n6U49sYLINPWnlAMPkbHCRIVs p76/r9NIwJgsttgohB9COBN54M7wjPrIggT+0fJISLAiQ8IoEgT/Rpb62xz17kyr2YZ3 ferp/EGxYz9yNnHybORwwWJkXNeNRXOd780s2HfJDGQdwSkexSg4lgg5uVDgI2IBUPrz ASfQ== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Thierry Reding Functionality to count the number of contiguous DMA chunks in an SG table has been added to the scatterlist library. Use this functionality to replace an open-coded version in the GEM/CMA helpers. Signed-off-by: Thierry Reding Reviewed-by: Daniel Vetter --- drivers/gpu/drm/drm_gem_cma_helper.c | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c b/drivers/gpu/drm/drm_gem_cma_helper.c index 12e98fb28229..5bbae9654cc6 100644 --- a/drivers/gpu/drm/drm_gem_cma_helper.c +++ b/drivers/gpu/drm/drm_gem_cma_helper.c @@ -471,26 +471,8 @@ drm_gem_cma_prime_import_sg_table(struct drm_device *dev, { struct drm_gem_cma_object *cma_obj; - if (sgt->nents != 1) { - /* check if the entries in the sg_table are contiguous */ - dma_addr_t next_addr = sg_dma_address(sgt->sgl); - struct scatterlist *s; - unsigned int i; - - for_each_sg(sgt->sgl, s, sgt->nents, i) { - /* - * sg_dma_address(s) is only valid for entries - * that have sg_dma_len(s) != 0 - */ - if (!sg_dma_len(s)) - continue; - - if (sg_dma_address(s) != next_addr) - return ERR_PTR(-EINVAL); - - next_addr = sg_dma_address(s) + sg_dma_len(s); - } - } + if (!sgt_dma_contiguous(sgt)) + return ERR_PTR(-EINVAL); /* Create a CMA GEM buffer. */ cma_obj = __drm_gem_cma_create(dev, attach->dmabuf->size);