Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp491020ybj; Tue, 5 May 2020 02:26:40 -0700 (PDT) X-Google-Smtp-Source: APiQypIMbGjA55nfd2AUFAcBMnBZxUgL7fM2FQRHUlUxnSBGo4j0QGfPrHTmRIPcKy94nfmK3wJY X-Received: by 2002:a17:906:68d7:: with SMTP id y23mr1831200ejr.85.1588670800607; Tue, 05 May 2020 02:26:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588670800; cv=none; d=google.com; s=arc-20160816; b=ENIYAbDdg+hxjsJBIlgZx7edLdih/o6bHc9mYRL+LHhxEeTVIxCr6i+Is68WJ5HRx8 ik/lZroH5rW2TsIZwL3DBPMemkh3wHPy5hnv4Bb2wPEszyvf+OcCEGghfxF0T1NVdL7W 0wn5tQImL4DimtGSabsKp+pyjni+zhHVA4gqLPVMxUA7gBqc2ihuOyicTaEzbiJlXOK6 d0nAN+okUZpaz/+w3N4FkzZYs2Q5ormP7O/PJNciHF78lPg8jwERopJ5itMVjfDTGNTc fLcqu0tAtc+KTTl/pT2DNWI6TK1B3XIOlQAalFje7pcMt7YpUi0PgolK4QFZjFmPmJbg B/kQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=fA6tjdmApvG0BpsjkTdWv9/ZTQZ9vjPp82obp9l863E=; b=AHYfeW/YDkoDUZX05v+rgRUDs4WK3gDpZRJZ0okTIv3NQMEycufy+R5ctZOIf6iXjN 3sxcYfMB6SxX3ebG6dwlRqpq6endcNCoGQNsFMSXipEKDrMNna3PwiF6m6tPkf4jx26X cpx8fDxOjaW23by6FPR+YxKG0lHGAKJ0YskQg+FhePR13zZvhw1fw7qfelB/JK+pl3Zt u+XDG7Yk1q+wKVhxyGtjBtvqPQqn7ix6hTUmOfUDldpN0GTRTnSUq2eNcTUKqpykXIIa 4+P1eNN4xWYzxyDuYXogG9Iw50nVmCBKpp+4aj0fKDN3uuPSeDkxHGj15/99tYnipoTc kY5w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k16si762319ejr.429.2020.05.05.02.26.15; Tue, 05 May 2020 02:26:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728549AbgEEJYv (ORCPT + 99 others); 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-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