From patchwork Wed Apr 22 11:40:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 185689 Delivered-To: patch@linaro.org Received: by 2002:a92:3d9a:0:0:0:0:0 with SMTP id k26csp649047ilf; Wed, 22 Apr 2020 04:41:16 -0700 (PDT) X-Google-Smtp-Source: APiQypK8N6GY2jdoRBp/zn4rkehTQ7kotOviOCKvdS3GSoTHybQsfT/iw8yy8lUCSnoiTwHsJcJh X-Received: by 2002:a17:90b:2385:: with SMTP id mr5mr10968460pjb.172.1587555676811; Wed, 22 Apr 2020 04:41:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587555676; cv=none; d=google.com; s=arc-20160816; b=XOkI3Jux6HlVpSohdq6ZG4rKgSPu1UI26t6AK057tQyMrONnDW0T7TflIlqEkr5xst 4rlcW9x5VPYVfLrr0G8JGsLjpkCTgI21qe+WWJpnlS+hqQh1cbWxhfeh3CcptN1F4Mxf n9vAmeE5D2lHQfYbeBkhvNqu2+y6iXgh7DQKwBa10OVS6bPd1fKMg7f/sJhIAsalHsxI GUOKtyU2ImxLUTYLM+tDRLZ1vL/IqPEmQLDl2/H+v8jvWSHFf2Yeg1omgSskFy6EQVzV kgLnuufuWbb8nPY+sZrYn+yG0OjRizl/lvP1KCAkvpgvE0KG/TE+BRwfZ80D3Js9M2Tc VMFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:cms-type:in-reply-to:message-id:date :subject:to:from:dkim-signature:dkim-filter:delivered-to; bh=h5VpcktvKhffdUrZdDe/dqvvj7cCYwwqbUYb3x6ZqQI=; b=ICUc/kdRra7XlhfcoFZupfA9KzlzsNkDw7M+Ta8cuPcOn3kBDR6RIo/Y59FFLM9zMZ AAh+qm6plrK2mM+kww/UlQ5rxhDuVK2wEiV1g/no5jVBftmautJ0utMA92UAL1L2oqIt PceGtb8QVG5EeMAoOcH/0uWCnJYvwoQEHmQPhrr/S2/A18YnQyVhrYgtutBwXaPwt1WD Dq6QlefPZFG0EYM5YeeW9zecEaeZ5HNbMOrIXDKNcnNvseWOi0n9YlLxnYav0YF+nyiJ X+1lj+KjObh9PV/BW0EmiuPXPw+H8YQQKqSUI/fKLAT9RhFq+kINE5FDtBI6JcU63pty 0fVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=eJBDy+WA; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [2610:10:20:722:a800:ff:fe36:1795]) by mx.google.com with ESMTPS id a14si4000381pjv.31.2020.04.22.04.41.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Apr 2020 04:41:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) client-ip=2610:10:20:722:a800:ff:fe36:1795; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=eJBDy+WA; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A8D416E41F; Wed, 22 Apr 2020 11:41:13 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by gabe.freedesktop.org (Postfix) with ESMTPS id 35C396E41F for ; Wed, 22 Apr 2020 11:41:12 +0000 (UTC) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200422114111euoutp02bd217d3b393ba7e961d72d4573db207e~IIXjGk5vX3198031980euoutp02W for ; Wed, 22 Apr 2020 11:41:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200422114111euoutp02bd217d3b393ba7e961d72d4573db207e~IIXjGk5vX3198031980euoutp02W DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1587555671; bh=jySS9kmEQ6ZJogXBh5srjxo4f8GGmavoMRc37EuQxhE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eJBDy+WAGeUuhHxNHSpnu0z+PWhuy3JFN0lI62hQJC8mdd/AZWyVTmFwQhVgK9h6Y DxkGKsnm/x9GZZNFh21OTy1L/5vQAG+DZINoL5ain8gmrnIDF9ndv3OjHFr/8UIx1C yUgDsRhH+HmRQv/UPAfwGu+5loUSxk+LBsXvYPKw= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200422114110eucas1p2e0fd93fb3efef7553644ac5646bb74c1~IIXivXvGR0670106701eucas1p2r; Wed, 22 Apr 2020 11:41:10 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 30.A0.60698.65D20AE5; Wed, 22 Apr 2020 12:41:10 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200422114110eucas1p2ef6b94864d6ad44af66855a9cb003a96~IIXiY5T9Q1480914809eucas1p2L; Wed, 22 Apr 2020 11:41:10 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200422114110eusmtrp29f0e076f47320fb56d076bb7585f124a~IIXiYOID33169431694eusmtrp26; Wed, 22 Apr 2020 11:41:10 +0000 (GMT) X-AuditID: cbfec7f5-a29ff7000001ed1a-16-5ea02d568b51 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 14.6C.08375.65D20AE5; Wed, 22 Apr 2020 12:41:10 +0100 (BST) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200422114110eusmtip293bb2ff4707d1546c39d676132259cf1~IIXh8eWIH2390223902eusmtip2j; Wed, 22 Apr 2020 11:41:09 +0000 (GMT) From: Marek Szyprowski To: dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH v2 2/3] drm/exynos: gem: rework scatter-list contiguity check on prime import Date: Wed, 22 Apr 2020 13:40:59 +0200 Message-Id: <20200422114059.29477-1-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <4cfed490-e45c-e559-bfa3-c616e3c00029@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrEIsWRmVeSWpSXmKPExsWy7djPc7phugviDG49NLS4te4cq8XGGetZ La58fc9mMen+BBaLGef3MVmsPXKX3WLG5JdsDuwe97uPM3n0bVnF6PF5k1wAcxSXTUpqTmZZ apG+XQJXxstVW5kK/gtV/P37gq2BcQJ/FyMnh4SAicScG0uZuxi5OIQEVjBKTHz5kxHC+cIo 8W3XdhYI5zOjxIVV51hhWj4cfMAEkVjOKNG64i8bXMudz9vBqtgEDCW63naxgdgiAm4STYdn soIUMQtcB5r7YxF7FyMHh7BAvMSiNe4gNSwCqhKL5q9kAwnzCthKHHiQA7FMXmL1h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hxglOJiVRHg3 PJwXJ8SbklhZlVqUH19UmpNafIjRFOikicxSosn5wNjJK4k3NDU0t7A0NDc2NzazUBLn7RA4 GCMkkJ5YkpqdmlqQWgTTx8TBKdXAGCF6k2GyB/PtegOnKYfqekLnrtfv/PQnMmyvrtDZNTna 7TdEHqTM+tncISy3x4VjRZD7b7N3BgmpfycJdn0JWJW++dX+ioYLqgxn/Sy8f62dlyP6NKXu 98N7XCV5yw5oTTwvd+OKXf4STvk7P8s9nT6eeJ0wbd7WI/WcIdx1Iuf220jmid+6q8RSnJFo qMVcVJwIANyT+/tlAgAA X-CMS-MailID: 20200422114110eucas1p2ef6b94864d6ad44af66855a9cb003a96 X-Msg-Generator: CA X-RootMTR: 20200422114110eucas1p2ef6b94864d6ad44af66855a9cb003a96 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200422114110eucas1p2ef6b94864d6ad44af66855a9cb003a96 References: <4cfed490-e45c-e559-bfa3-c616e3c00029@samsung.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrzej Hajda , Bartlomiej Zolnierkiewicz , Seung-Woo Kim , Marek Szyprowski MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Explicitly check if the imported buffer has been mapped as contiguous in the DMA address space, what is required by all Exynos DRM CRTC drivers. While touching this, set buffer flags depending on the availability of the IOMMU. Signed-off-by: Marek Szyprowski --- v2: - reworked a check for sgt->nents - added a comment about a scatter-list contiguity check - removed additional 'return ERR_PTR(-EINVAL)' accidentaly left after debugging --- drivers/gpu/drm/exynos/exynos_drm_gem.c | 42 ++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 11 deletions(-) -- 1.9.1 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c b/drivers/gpu/drm/exynos/exynos_drm_gem.c index 40514d3..f136efb 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_gem.c +++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c @@ -458,6 +458,29 @@ struct drm_gem_object * int npages; int ret; + if (sgt->nents < 1) + return ERR_PTR(-EINVAL); + + /* + * Check if the provided buffer has been mapped as contiguous + * into DMA address space. + */ + if (sgt->nents > 1) { + 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) { + if (!sg_dma_len(s)) + break; + if (sg_dma_address(s) != next_addr) { + DRM_ERROR("buffer chunks must be mapped contiguously"); + return ERR_PTR(-EINVAL); + } + next_addr = sg_dma_address(s) + sg_dma_len(s); + } + } + exynos_gem = exynos_drm_gem_init(dev, attach->dmabuf->size); if (IS_ERR(exynos_gem)) { ret = PTR_ERR(exynos_gem); @@ -480,18 +503,15 @@ struct drm_gem_object * exynos_gem->sgt = sgt; - if (sgt->nents == 1) { - /* always physically continuous memory if sgt->nents is 1. */ - exynos_gem->flags |= EXYNOS_BO_CONTIG; - } else { - /* - * this case could be CONTIG or NONCONTIG type but for now - * sets NONCONTIG. - * TODO. we have to find a way that exporter can notify - * the type of its own buffer to importer. - */ + /* + * Buffer has been mapped as contiguous into DMA address space, + * but if there is IOMMU, it can be either CONTIG or NONCONTIG. + * We assume a simplified logic below: + */ + if (is_drm_iommu_supported(dev)) exynos_gem->flags |= EXYNOS_BO_NONCONTIG; - } + else + exynos_gem->flags |= EXYNOS_BO_CONTIG; return &exynos_gem->base;