From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 141EAC47256 for ; Tue, 5 May 2020 09:24:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F1ADE206CC for ; Tue, 5 May 2020 09:24:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728583AbgEEJYv (ORCPT ); Tue, 5 May 2020 05:24:51 -0400 Received: from mail-oi1-f193.google.com ([209.85.167.193]:38374 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725766AbgEEJYu (ORCPT ); Tue, 5 May 2020 05:24:50 -0400 Received: by mail-oi1-f193.google.com with SMTP id r66so1396581oie.5; Tue, 05 May 2020 02:24:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fA6tjdmApvG0BpsjkTdWv9/ZTQZ9vjPp82obp9l863E=; b=KuMdbSTevVVyIcYYwphkz89h1ykWQxiWyG2eWWDmtjnV+yzVc4tt2q8+BeaOpzjM1U yCoOgzHHy2BrTq5b3au0LHxkOhhw4Z9k4bLPrwuO/lytRpt6mL2+haUmOV1DQFjy4VXY 1zNA43sIG/9b81RppTbGgEmH5N581W6CE9EUyScqWgQDE38GaloJ9gt4wTnypxmoQDsX W+EQyre3gBrosnxRDrqg2St+AdOSbKgPKyhqcbTzAvNrNJSivm/xbeBfql/gQdM9KVsk 5WZzmCaE6u3AfXJXu/yrUHpSwZrvhJLLQ1magehi2GgProOFXFZOm/8Ymn6xRHF42yyh iMdw== X-Gm-Message-State: AGi0PuarmqkJr6sohlcUqKgki7AcwsDBScsPOP4hlxLXa1y4giZPspff 9/bcY/NHnL9l35nLVGTQwfX7b/e+jS736vysKlk= X-Google-Smtp-Source: APiQypKOjAo7caYTLLrvaP2LfYH11Xj01QYaa+uBtqm/9mZJ41Mdkz0F6pXJ47B38HgwsYDHPLvoSnLN/Mh8S4elUzU= X-Received: by 2002:aca:f541:: with SMTP id t62mr1674694oih.148.1588670688206; Tue, 05 May 2020 02:24:48 -0700 (PDT) MIME-Version: 1.0 References: <20200505083926.28503-1-m.szyprowski@samsung.com> <20200505084614.30424-1-m.szyprowski@samsung.com> <20200505084614.30424-18-m.szyprowski@samsung.com> In-Reply-To: <20200505084614.30424-18-m.szyprowski@samsung.com> From: Geert Uytterhoeven Date: Tue, 5 May 2020 11:24:37 +0200 Message-ID: Subject: Re: [PATCH v3 18/25] drm: rcar-du: fix common struct sg_table related issues To: Marek Szyprowski Cc: DRI Development , Linux IOMMU , linaro-mm-sig@lists.linaro.org, Linux Kernel Mailing List , Christoph Hellwig , Robin Murphy , Bartlomiej Zolnierkiewicz , Linux ARM , David Airlie , Daniel Vetter , Mauro Carvalho Chehab , Laurent Pinchart , Kieran Bingham , Linux Media Mailing List , Linux-Renesas Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Marek, On Tue, May 5, 2020 at 10:48 AM Marek Szyprowski wrote: > The Documentation/DMA-API-HOWTO.txt states that dma_map_sg returns the > numer of the created entries in the DMA address space. However the > subsequent calls to dma_sync_sg_for_{device,cpu} and dma_unmap_sg must be > called with the original number of the entries passed to dma_map_sg. The > sg_table->nents in turn holds the result of the dma_map_sg call as stated > in include/linux/scatterlist.h. A common mistake was to ignore a result > of the dma_map_sg function and don't use the sg_table->orig_nents at all. > > To avoid such issues, lets use common dma-mapping wrappers operating > directly on the struct sg_table objects and adjust references to the > nents and orig_nents respectively. > > Signed-off-by: Marek Szyprowski > --- > For more information, see '[PATCH v3 00/25] DRM: fix struct sg_table nents > vs. orig_nents misuse' thread: https://lkml.org/lkml/2020/5/5/187 For the modern lore-users: https://lore.kernel.org/r/20200505083926.28503-1-m.szyprowski@samsung.com/ Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FCC9C47256 for ; Tue, 5 May 2020 09:24:55 +0000 (UTC) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (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 5F5C920721 for ; Tue, 5 May 2020 09:24:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5F5C920721 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 2E7AB22879; Tue, 5 May 2020 09:24:55 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Zcf+ZKiwb9xp; Tue, 5 May 2020 09:24:54 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id 5866B204A7; Tue, 5 May 2020 09:24:54 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D66DFC088B; Tue, 5 May 2020 09:24:53 +0000 (UTC) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 30702C0175 for ; Tue, 5 May 2020 09:24:52 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 22115204A7 for ; Tue, 5 May 2020 09:24:52 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id efGDVyVDqB8c for ; Tue, 5 May 2020 09:24:49 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-oi1-f193.google.com (mail-oi1-f193.google.com [209.85.167.193]) by silver.osuosl.org (Postfix) with ESMTPS id 194D62047D for ; Tue, 5 May 2020 09:24:49 +0000 (UTC) Received: by mail-oi1-f193.google.com with SMTP id a2so1212705oia.11 for ; Tue, 05 May 2020 02:24:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fA6tjdmApvG0BpsjkTdWv9/ZTQZ9vjPp82obp9l863E=; b=l83fcDYTq7Awnk2QCoCTpthD0JeQvn3ll9cI2EcKAd8QXxOqZW2kOt/37Kkupmz4B8 UCHTgVLsCD0zK+g0l69VLN/arBDGdLP34JrqHhhuCk2MMRsqapeMs8XXyyyxqCt9uFVa 8OEY7b8kCmqLX/h0o3dT5EefmhsgQ4Sm6TJF1oT1qCyejxXVoEJsmrsgchBRVSycd3Fk D4+nWkIhxGQ7/lnA0ljjo99ZZbL/LEIarl6LHgtUfl3nyZG2NwWGD8POkaugALHCj0WW hL9rkRBGYbVIVnj/LxtRVNfiDVcoK6ZT5W1ldPWHejrMVywb2IVJh21LsGY6j3kzKj94 NxXA== X-Gm-Message-State: AGi0PuZbuldx38Fx99I6DGMACOtHrTkd0i7oQHHAsjG6h5naxVEijJMh Qpf7dPXbtp+j1iC1PkktxmyKdQmn+hKoRv9DZu4= X-Google-Smtp-Source: APiQypKOjAo7caYTLLrvaP2LfYH11Xj01QYaa+uBtqm/9mZJ41Mdkz0F6pXJ47B38HgwsYDHPLvoSnLN/Mh8S4elUzU= X-Received: by 2002:aca:f541:: with SMTP id t62mr1674694oih.148.1588670688206; Tue, 05 May 2020 02:24:48 -0700 (PDT) MIME-Version: 1.0 References: <20200505083926.28503-1-m.szyprowski@samsung.com> <20200505084614.30424-1-m.szyprowski@samsung.com> <20200505084614.30424-18-m.szyprowski@samsung.com> In-Reply-To: <20200505084614.30424-18-m.szyprowski@samsung.com> From: Geert Uytterhoeven Date: Tue, 5 May 2020 11:24:37 +0200 Message-ID: Subject: Re: [PATCH v3 18/25] drm: rcar-du: fix common struct sg_table related issues To: Marek Szyprowski Cc: Linux-Renesas , Bartlomiej Zolnierkiewicz , David Airlie , Linux Kernel Mailing List , DRI Development , linaro-mm-sig@lists.linaro.org, Linux IOMMU , Kieran Bingham , Laurent Pinchart , Daniel Vetter , Mauro Carvalho Chehab , Robin Murphy , Christoph Hellwig , Linux ARM , Linux Media Mailing List X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" Hi Marek, On Tue, May 5, 2020 at 10:48 AM Marek Szyprowski wrote: > The Documentation/DMA-API-HOWTO.txt states that dma_map_sg returns the > numer of the created entries in the DMA address space. However the > subsequent calls to dma_sync_sg_for_{device,cpu} and dma_unmap_sg must be > called with the original number of the entries passed to dma_map_sg. The > sg_table->nents in turn holds the result of the dma_map_sg call as stated > in include/linux/scatterlist.h. A common mistake was to ignore a result > of the dma_map_sg function and don't use the sg_table->orig_nents at all. > > To avoid such issues, lets use common dma-mapping wrappers operating > directly on the struct sg_table objects and adjust references to the > nents and orig_nents respectively. > > Signed-off-by: Marek Szyprowski > --- > For more information, see '[PATCH v3 00/25] DRM: fix struct sg_table nents > vs. orig_nents misuse' thread: https://lkml.org/lkml/2020/5/5/187 For the modern lore-users: https://lore.kernel.org/r/20200505083926.28503-1-m.szyprowski@samsung.com/ Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71C6CC47247 for ; Tue, 5 May 2020 09:24:57 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 3FD7520721 for ; Tue, 5 May 2020 09:24:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="WlfS+Qk9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3FD7520721 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=47jdHZorR+dD7tolkaW9JWxJ4wnvI8vC/MFJRdn4AAA=; b=WlfS+Qk91CBdiV d7dRmbwA3R7OFQCrfe7O8oKsfg2aYQKzNbM2EtCA3jfMv4dAZAoyQNvDgNNHGKI9kKvxbwPyPCIev WGyvylsDXLaVssd7ehUqBJHtMrj+ezxgoe986CfuUufKLbu1bQwm3097rA5VP8ctpMlD2okdKse93 3p7fgRqepPU/WP2TBjsZJmX4ZFo6rUz7a80OK3PS1w+WpNAf5IfzpY37MUafsLjU++btFzmYob4gT ZPouhK30uM4DByNhgMv9HOosP+LR3AIh1ygSbsI8SjdRsHLCNxfivmdN2LXW1tv2dAdeRjeSn6WV0 eNqCe6SaJHIv79v+ILsg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jVtou-0005lP-8j; Tue, 05 May 2020 09:24:56 +0000 Received: from mail-oi1-f193.google.com ([209.85.167.193]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jVtoo-0005jv-9h for linux-arm-kernel@lists.infradead.org; Tue, 05 May 2020 09:24:54 +0000 Received: by mail-oi1-f193.google.com with SMTP id o24so1419496oic.0 for ; Tue, 05 May 2020 02:24:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fA6tjdmApvG0BpsjkTdWv9/ZTQZ9vjPp82obp9l863E=; b=X7XNrFsEX6EtUt9Qfkn+TMW6MZ51KaQeReZhP4+NU2OxAhW2kxEVRu7yekd1KD4/h0 zM2/iU5+DF3sHN9ZWjtgtULXNQYHqfzj3ISsLaaxPIqqfLqDKapFQ9ly+T8NZ/k4MMDF VZtn+yB7X5uyIW2elC1P8d9nzPhzHEV+iYpuvIpy3Kgmydd9od0Lq4KzQfwSM8CapLbd pv9Njaa2QcdkO4kOVQ/kCpJbqmLCn3Nrru7OTtSxGozn3YVsSziwFen7ZgEaA2HNzhH0 UyM++lTnWFAwm9q4QYsjvIPsAlxz7TtzNVTJhLdkPL6Hk7xsW5nnTwlacPsRme0k9vVd /iFA== X-Gm-Message-State: AGi0PuZdGhcSzvUBhw59zC+ONih9aogb+Tze0kQdC0+NTHGMCsR98cfp wGSxf6CUmQAiOy706GcIOF30G9sDXgh6l5KEYek= X-Google-Smtp-Source: APiQypKOjAo7caYTLLrvaP2LfYH11Xj01QYaa+uBtqm/9mZJ41Mdkz0F6pXJ47B38HgwsYDHPLvoSnLN/Mh8S4elUzU= X-Received: by 2002:aca:f541:: with SMTP id t62mr1674694oih.148.1588670688206; Tue, 05 May 2020 02:24:48 -0700 (PDT) MIME-Version: 1.0 References: <20200505083926.28503-1-m.szyprowski@samsung.com> <20200505084614.30424-1-m.szyprowski@samsung.com> <20200505084614.30424-18-m.szyprowski@samsung.com> In-Reply-To: <20200505084614.30424-18-m.szyprowski@samsung.com> From: Geert Uytterhoeven Date: Tue, 5 May 2020 11:24:37 +0200 Message-ID: Subject: Re: [PATCH v3 18/25] drm: rcar-du: fix common struct sg_table related issues To: Marek Szyprowski X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200505_022453_116756_7726B068 X-CRM114-Status: GOOD ( 12.71 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Linux-Renesas , Bartlomiej Zolnierkiewicz , David Airlie , Linux Kernel Mailing List , DRI Development , linaro-mm-sig@lists.linaro.org, Linux IOMMU , Kieran Bingham , Laurent Pinchart , Daniel Vetter , Mauro Carvalho Chehab , Robin Murphy , Christoph Hellwig , Linux ARM , Linux Media Mailing List Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Marek, On Tue, May 5, 2020 at 10:48 AM Marek Szyprowski wrote: > The Documentation/DMA-API-HOWTO.txt states that dma_map_sg returns the > numer of the created entries in the DMA address space. However the > subsequent calls to dma_sync_sg_for_{device,cpu} and dma_unmap_sg must be > called with the original number of the entries passed to dma_map_sg. The > sg_table->nents in turn holds the result of the dma_map_sg call as stated > in include/linux/scatterlist.h. A common mistake was to ignore a result > of the dma_map_sg function and don't use the sg_table->orig_nents at all. > > To avoid such issues, lets use common dma-mapping wrappers operating > directly on the struct sg_table objects and adjust references to the > nents and orig_nents respectively. > > Signed-off-by: Marek Szyprowski > --- > For more information, see '[PATCH v3 00/25] DRM: fix struct sg_table nents > vs. orig_nents misuse' thread: https://lkml.org/lkml/2020/5/5/187 For the modern lore-users: https://lore.kernel.org/r/20200505083926.28503-1-m.szyprowski@samsung.com/ Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93D5DC47247 for ; Tue, 5 May 2020 09:24:50 +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 70A46206CC for ; Tue, 5 May 2020 09:24:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 70A46206CC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org 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 E290C6E598; Tue, 5 May 2020 09:24:49 +0000 (UTC) Received: from mail-oi1-f193.google.com (mail-oi1-f193.google.com [209.85.167.193]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0959F6E598 for ; Tue, 5 May 2020 09:24:49 +0000 (UTC) Received: by mail-oi1-f193.google.com with SMTP id j16so1219459oih.10 for ; Tue, 05 May 2020 02:24:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fA6tjdmApvG0BpsjkTdWv9/ZTQZ9vjPp82obp9l863E=; b=RO/0AAxEbUcayLZiB6Hq+ZYArgbwZUhhlP2KYVrXQ6hqjLZwwukLhWBu1EfktbQg+w +FFFBSo6XxM/GLSXnZ4KWO8RTNQIPKJ9v1QhNfovuN4BARxT9DF2xYeYxXyrHx8kCwER ARZzNIUyY/79JY2jD4VRvxZYmFgg/T8M6Y0E/X4PXnzOMlw88P28nN/RTcXPiHHNjjJP MX8vr+qz80p2/BHaO+YDEwt/zo6dBllzsBlRqVY/plNTaLC1L0NtPA2vOnXiuujBAbs6 KnFH6QHz2po9i4CnNYndRFgPCGJkZ30x1Q3hn9az5MmgNLsNm8qiQb34Z0nAhR8n0a+C Rwug== X-Gm-Message-State: AGi0PuYxWeU7IGpOZyLr7KirI6SPLn/mXUd4gDM8Ks9VUbor+OZ9a3eI 8NshKAEAfTVvMv8w4q2tjBDOuJ7WyXymc7Bvnvk= X-Google-Smtp-Source: APiQypKOjAo7caYTLLrvaP2LfYH11Xj01QYaa+uBtqm/9mZJ41Mdkz0F6pXJ47B38HgwsYDHPLvoSnLN/Mh8S4elUzU= X-Received: by 2002:aca:f541:: with SMTP id t62mr1674694oih.148.1588670688206; Tue, 05 May 2020 02:24:48 -0700 (PDT) MIME-Version: 1.0 References: <20200505083926.28503-1-m.szyprowski@samsung.com> <20200505084614.30424-1-m.szyprowski@samsung.com> <20200505084614.30424-18-m.szyprowski@samsung.com> In-Reply-To: <20200505084614.30424-18-m.szyprowski@samsung.com> From: Geert Uytterhoeven Date: Tue, 5 May 2020 11:24:37 +0200 Message-ID: Subject: Re: [PATCH v3 18/25] drm: rcar-du: fix common struct sg_table related issues To: Marek Szyprowski 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: Linux-Renesas , Bartlomiej Zolnierkiewicz , David Airlie , Linux Kernel Mailing List , DRI Development , linaro-mm-sig@lists.linaro.org, Linux IOMMU , Kieran Bingham , Laurent Pinchart , Mauro Carvalho Chehab , Robin Murphy , Christoph Hellwig , Linux ARM , Linux Media Mailing List Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Hi Marek, On Tue, May 5, 2020 at 10:48 AM Marek Szyprowski wrote: > The Documentation/DMA-API-HOWTO.txt states that dma_map_sg returns the > numer of the created entries in the DMA address space. However the > subsequent calls to dma_sync_sg_for_{device,cpu} and dma_unmap_sg must be > called with the original number of the entries passed to dma_map_sg. The > sg_table->nents in turn holds the result of the dma_map_sg call as stated > in include/linux/scatterlist.h. A common mistake was to ignore a result > of the dma_map_sg function and don't use the sg_table->orig_nents at all. > > To avoid such issues, lets use common dma-mapping wrappers operating > directly on the struct sg_table objects and adjust references to the > nents and orig_nents respectively. > > Signed-off-by: Marek Szyprowski > --- > For more information, see '[PATCH v3 00/25] DRM: fix struct sg_table nents > vs. orig_nents misuse' thread: https://lkml.org/lkml/2020/5/5/187 For the modern lore-users: https://lore.kernel.org/r/20200505083926.28503-1-m.szyprowski@samsung.com/ Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel