From patchwork Wed Aug 26 06:33:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 248356 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:522:0:0:0:0 with SMTP id h2csp4063571ils; Tue, 25 Aug 2020 23:36:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNpz2Q+D2OGamFRWnjRtQQ7bHf3Gfo9hc3dEEn3kpeH/cEx+s0NLDtFlEQPRzrlMducAza X-Received: by 2002:a62:26c2:: with SMTP id m185mr11129836pfm.115.1598423774699; Tue, 25 Aug 2020 23:36:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598423774; cv=none; d=google.com; s=arc-20160816; b=nbKUhEvfriEsTR/37+hbYehaTqx9EuHx7QRCAtI+nfxMOg7g9aEp6xaOa3rjEra2Te wIVQmehpITo6IEKEuFZIE+EzexygN8JFEfZ7eQmMro6JVdeXSVqKTaR3BCnF4YnPmkzy lGDV9Tc59XtGGPmi2SCTNkdVtInjXNJP5/WxHoCzmP7Uya3Tr0h0KiINjjk8stMwhjI+ yRH2VLzPWwFXic76qv5q3mqY6AxMF9/NfsR92h8nNmCAvuuDMdla3hzkLHZsX2ce1P7Y MqDS2VgV0eu5O+8XY6Tanrn7AY0Yb2yeg0MV6kmSff0ZHL1RpVsO1N0XT/I2OgViCUyT V3iQ== 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=ucLstHB0bTmckkDMwO0V35oFAR2Dov7teZ3OBqbUO5g=; b=nnfCU5zn8/G4lQC2bZgQHuSgrs9TBojNTyFgIR79G2YiLVeIPSR3HWh8EN24fyBsjz 6PobStnLybQap3lz5kE8lVTZ79bCL4sY//CkhdCbLUiNGQdV1NNiqGnIF+NR5ideFwUL bFcYfuCIX3uE1023e/BJAQqx9qCvvNMdDRDgLOW6t0bz8tNqtTXQeC25v30nOqqhcQ3V qTD+fbtNyrMHeUbAeNnSK485q2SaNQ71XcatXaZxGKaGZYXQTrNHlW+9EglZ0ruzY+Xw dCQHJl8NfHtUSIfMbBc+HQS0Nt5y5dp8C/NMQrR8MaA11E/OWYNJ2O3by8o/Uyu+jZb1 06fA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=IdY2twB6; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 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. [131.252.210.177]) by mx.google.com with ESMTPS id q4si902412pgf.403.2020.08.25.23.36.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2020 23:36:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=IdY2twB6; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 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 0BE8E6EA16; Wed, 26 Aug 2020 06:35:56 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by gabe.freedesktop.org (Postfix) with ESMTPS id 46D276EA03 for ; Wed, 26 Aug 2020 06:35:43 +0000 (UTC) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200826063541euoutp018f0c00eb80809ebcc88ef7eeb929d102~uveyoI1RD2035120351euoutp01L for ; Wed, 26 Aug 2020 06:35:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200826063541euoutp018f0c00eb80809ebcc88ef7eeb929d102~uveyoI1RD2035120351euoutp01L DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1598423741; bh=M6LUpUR0yeAQpj3I0Hzt+0kX5PVbzJKyJpNcEwtoCPI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IdY2twB6wuYfDlMptUp2KJ7OZNg2ew8kv8Lpp+bsE74SEp4HRl+CrgPzzHQ0Aqd1x aB3WJ0elgVTLaRHGF+7DRWQAPbP6C06Es/B9iwMtB9Hpk4OTSIeXKg/JkeibGk+0UL +JzrQDKwXplco+CM2GlANOOvkBzYyzvpqBr5kim0= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200826063541eucas1p25d190a48f46f33e47788594980fc2ad1~uveyUv41l0402704027eucas1p2s; Wed, 26 Aug 2020 06:35:41 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 8A.33.06456.DB2064F5; Wed, 26 Aug 2020 07:35:41 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200826063540eucas1p2dc6829c66ae13b8e787ca40b9aede3df~uvexv_2_J0401804018eucas1p2k; Wed, 26 Aug 2020 06:35:40 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200826063540eusmtrp262a1eb3c5d27915d22297ddfc0094071~uvexvaUnQ0466204662eusmtrp2Z; Wed, 26 Aug 2020 06:35:40 +0000 (GMT) X-AuditID: cbfec7f2-809ff70000001938-d9-5f4602bd17a0 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id A8.53.06017.CB2064F5; Wed, 26 Aug 2020 07:35:40 +0100 (BST) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200826063540eusmtip21783f52e3b3c400cdc13258da026b04c~uvexKjbwI0092600926eusmtip2C; Wed, 26 Aug 2020 06:35:40 +0000 (GMT) From: Marek Szyprowski To: dri-devel@lists.freedesktop.org, iommu@lists.linux-foundation.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org Subject: [PATCH v9 22/32] drm: xen: fix common struct sg_table related issues Date: Wed, 26 Aug 2020 08:33:06 +0200 Message-Id: <20200826063316.23486-23-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200826063316.23486-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0WSe0hTYRjG+87Zzs6mk9O0/NJKGBRYpJkGJy3L0DhdSIv+KstWHlTUKZta Sug0spyXMqFMJFdzzWumybykqMs2Q1qllppaDaWwWPOeWsw2j9p/v/d5n4fn5ePDUUEL2wWP EifQErEoRojxWBrdgmFXK3IkbLey2JXMNbxGyNrCGja5pMlHyb5ZM0aWV75CSEWbHznTZ0TI utGPbLK3uRgjqztHOOREpZlNdkyMscnf9QXIIT5V9bAKUMOqJkC1zilYVMPcVzb1JVuPUM9L 06ghyyhKFQyoAfVyoo9FvRiUYVRefQWgpuu2htif5e0Pp2OikmiJp/9FXmRJhQ7E5zlcvWkZ BjJgspMDLg4JHzjSOcuRAx4uIMoAlJXNo8wwA+BkmQy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zsTSJWwgK/EnA1dYKNYBFQlZt6bwwxi8wrYScxY0cMMsUJeYvWGA2A2J1D8eHc/G4gtJGAr cXrtDOYJjHwLGBlWMYqklhbnpucWG+kVJ+YWl+al6yXn525iBMbNtmM/t+xg7HoXfIhRgINR iYd3AZtrvBBrYllxZe4hRgkOZiURXqezp+OEeFMSK6tSi/Lji0pzUosPMZoCHTWRWUo0OR8Y 03kl8YamhuYWlobmxubGZhZK4rwdAgdjhATSE0tSs1NTC1KLYPqYODilGhgvaFs3chqfYVUQ vnHysfJ3To0GrZeHO5nWPZ9ZzJ87R+izkMiZ+y5/ko53pQQflFp5/+qfCtZZ2izmS59MnXkg mKmv9UTfZf3cmaEr9i+UEilgmMdzecYSN70TayRNuFrnlHnkqPF+rMo5xJO36IX0SQ7XtxsM tV8mCveoHZq32/tXzGuewFQlluKMREMt5qLiRACCkIX+sQIAAA== X-CMS-MailID: 20200826063540eucas1p2dc6829c66ae13b8e787ca40b9aede3df X-Msg-Generator: CA X-RootMTR: 20200826063540eucas1p2dc6829c66ae13b8e787ca40b9aede3df X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200826063540eucas1p2dc6829c66ae13b8e787ca40b9aede3df References: <20200826063316.23486-1-m.szyprowski@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: Bartlomiej Zolnierkiewicz , David Airlie , Oleksandr Andrushchenko , xen-devel@lists.xenproject.org, Robin Murphy , Christoph Hellwig , linux-arm-kernel@lists.infradead.org, Marek Szyprowski MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function returns the number of the created entries in the DMA address space. However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and dma_unmap_sg must be called with the original number of the entries passed to the dma_map_sg(). struct sg_table is a common structure used for describing a non-contiguous memory buffer, used commonly in the DRM and graphics subsystems. It consists of a scatterlist with memory pages and DMA addresses (sgl entry), as well as the number of scatterlist entries: CPU pages (orig_nents entry) and DMA mapped pages (nents entry). It turned out that it was a common mistake to misuse nents and orig_nents entries, calling DMA-mapping functions with a wrong number of entries or ignoring the number of mapped entries returned by the dma_map_sg() function. Fix the code to refer to proper nents or orig_nents entries. This driver reports the number of the pages in the imported scatterlist, so it should refer to sg_table->orig_nents entry. Signed-off-by: Marek Szyprowski Acked-by: Oleksandr Andrushchenko --- drivers/gpu/drm/xen/xen_drm_front_gem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel diff --git a/drivers/gpu/drm/xen/xen_drm_front_gem.c b/drivers/gpu/drm/xen/xen_drm_front_gem.c index 39ff95b75357..0e57c80058b2 100644 --- a/drivers/gpu/drm/xen/xen_drm_front_gem.c +++ b/drivers/gpu/drm/xen/xen_drm_front_gem.c @@ -216,7 +216,7 @@ xen_drm_front_gem_import_sg_table(struct drm_device *dev, return ERR_PTR(ret); DRM_DEBUG("Imported buffer of size %zu with nents %u\n", - size, sgt->nents); + size, sgt->orig_nents); return &xen_obj->base; }