Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp849941ybb; Sat, 28 Mar 2020 11:38:32 -0700 (PDT) X-Google-Smtp-Source: ADFU+vv5yaQNWTrRnlGq/plkla3zwzZCtUjmbxuhLf5uC2Lhitc/5eSJCPnolosrz41aH6YzQBnX X-Received: by 2002:a05:6830:96:: with SMTP id a22mr3454173oto.212.1585420712001; Sat, 28 Mar 2020 11:38:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585420711; cv=none; d=google.com; s=arc-20160816; b=DfNs/Mx1siH67DuYy+72E45WWAQn153NfV0aPx3xyzNS+67wlsIgLX7PzVpuJ9JXRK i/V3TF1idZ2krB7G1fpcVqCYo60Q7j9ZMojGnWZIb6SRHw2UxPyyxT3blD8Z6TEMkSR/ 9+ooas5IZbN/wZP/bS7PXRw3OTUTaYDXGvPANer+obB+Zz1cStIYwJooh+dyce6XZDJW Qs0GJh5bFE9Ds/AuL0vt7x8noXOufx+fNPbCXwpOeAUVYeEHunfb/8H5l7AS0fq1RYx8 gnuM54a2EZJG+FpjB/a3RZ8wUCWNIw4+8oz/djSKfFkBI/71RECMqCr5WL5SqAwwfj2o YpQQ== 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:dkim-signature; bh=0HI24KR/yCjlJFsLLO6kOQCApuZY67HrR4f/HELwj00=; b=D3PIONXFGOkgJyhEHMbLiuOPt9Kxbr+l+JEn0GxJKmTOymDFAt2VGSax1T+dbeqpfY rE4synd8nYk3UikfVsCWFPEl/DDzWVbckDH5fi4mf1IJmmdlSwMdmvou3oxsYU2H5wnx cThvJy8TAeqniTpJEOp6hSQx2T97UvpJAyADFwC5gm2Byk2x5BJiFg1uwbD95chXBS+b GdGsUSnrt0j7mvKqa+gDvntBt9nXtH2+ddxXSkQ0z2vD3mIegC4S5vjncZQ5QiuYUA1U 5Gk7Cp9j+dYfgn/XtVmBW/QxvKFRVqXO+Wp+OKblcHR6Y58TPS+/5ec6YmBm0EDTouJg ggfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Bjn3/ZMS"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g9si4433002otn.100.2020.03.28.11.38.19; Sat, 28 Mar 2020 11:38:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Bjn3/ZMS"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726751AbgC1Sgz (ORCPT + 99 others); Sat, 28 Mar 2020 14:36:55 -0400 Received: from mail-il1-f195.google.com ([209.85.166.195]:36136 "EHLO mail-il1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725882AbgC1Sgz (ORCPT ); Sat, 28 Mar 2020 14:36:55 -0400 Received: by mail-il1-f195.google.com with SMTP id p13so11910901ilp.3; Sat, 28 Mar 2020 11:36:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0HI24KR/yCjlJFsLLO6kOQCApuZY67HrR4f/HELwj00=; b=Bjn3/ZMSjI5MgkcB5gKK6N4zFjMVoFTSxcltL3PA99UZvBgXDgAOataat0yBdZVoqE NH/0OggUWvfgrio+/Usro0z9coMiVVo64z+Ln5aQgcxfw4feFgn+HtkwH7mrWJCnPGE2 HKqmsQoZGerQe6AjWMGTP1n8+SNzk6IVEChHV39pY8GLRUYnLiJwMUAZxqCourq0RyLY pCPSDwMaFYSKYZfU+gkFh+BeUED8m5CfdGuTbfJazHFg5insTKlELMAZGfCPaPk0Aqk9 NYm6bxxNZc3SqBkQRE300iLkiF0BDCxKz1y/Kd2Stf2b1/BQQJeA1JOGYlS/PLRrlncv 0qzQ== 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=0HI24KR/yCjlJFsLLO6kOQCApuZY67HrR4f/HELwj00=; b=lx26CZDDaML69rm41uVuGH7igx2oQdBRE729WG+s4SyP3PetmO8v5YxJfbJP/wlX1s yIJQGHwRK1/xr48KpCfh56rzCPKIZ2lpX2A+P9aqLmePRfDgJtvHActpu15urhU8D/QE Bjy7ZIajen0HhTtEKPo8431KmoYJcTH2F9obnxPeHffw522OMHbOpcJzDOaCxihDKH0E 4i2xEKWCegmEQmtTj53XfTz6WlzRgdKoXzKwq93zx+IUrLaKk2zeGhcIXiIpVqpD2OCu /5phwqTTRDYVbsjUmjE4I1aBUSF8QUgStUuYeitVLLIpn155MVUxWX4gP2PsOnGdne0t kbcw== X-Gm-Message-State: ANhLgQ1Y8YFkpd8WOpjDv7I9SmraoLxTmxtVjei006DeWBgcjn4MW823 wgl0XUgS+teLAeS0tuI+5mivLeIFROq39sSOy44= X-Received: by 2002:a92:cb49:: with SMTP id f9mr4613117ilq.193.1585420613730; Sat, 28 Mar 2020 11:36:53 -0700 (PDT) MIME-Version: 1.0 References: <20200327162126.29705-1-m.szyprowski@samsung.com> <14063C7AD467DE4B82DEDB5C278E8663FFFBFCE1@fmsmsx107.amr.corp.intel.com> In-Reply-To: <14063C7AD467DE4B82DEDB5C278E8663FFFBFCE1@fmsmsx107.amr.corp.intel.com> From: Shane Francis Date: Sat, 28 Mar 2020 18:36:42 +0000 Message-ID: Subject: Re: [PATCH v2] drm/prime: fix extracting of the DMA addresses from a scatterlist To: "Ruhl, Michael J" , Marek Szyprowski Cc: "dri-devel@lists.freedesktop.org" , "linux-samsung-soc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" , Bartlomiej Zolnierkiewicz , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Alex Deucher 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 On Fri, Mar 27, 2020 at 6:31 PM Ruhl, Michael J wrote: > Is there an example of what the scatterlist would look like in this case? > > Does each SG entry always have the page and dma info? or could you have > entries that have page information only, and entries that have dma info only? > > If the same entry has different size info (page_len = PAGE_SIZE, > dma_len = 4 * PAGE_SIZE?), are we guaranteed that the arrays (page and addrs) have > been sized correctly? > > Just trying to get my head wrapped around this. > > Thanks, > > Mike > My understanding is that page_len and dma_len in this case could have different values (looking at iommu_dma_map_sg within dma-iommu.c), this seems to add some padding calculated by using the device iova domain to s_length but sg_dma_len is set to the original length The scatterlists table can also get reduced down within "__finalise_sg" possibly causing (if reduced) the dma_len of the last table elements to be 0 (page_len would not be 0 in this case). Documentation around looping & accessing scatterlists in DMA-API.txt states that sg_dma_address() and sg_dma_len() should be used when accessing addr and len rather than sg->address and sg->length. Maybe it would be worth splitting this out into 2 functions to avoid potential issues with the above use case ? Regards, Shane Francis