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=-0.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,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 36C89C2D0EC for ; Sat, 28 Mar 2020 18:36:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1362D20732 for ; Sat, 28 Mar 2020 18:36:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Bjn3/ZMS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726977AbgC1Sgz (ORCPT ); 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-Google-Smtp-Source: ADFU+vvj7xBW8YgzYefpKHgpnS8IasnPvFs7tQ1xw3iG07/FjIZop9WE6ytmhD+MGsO5JAtYB+aIgp90MlIPv8WqjKo= 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