Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp101844imu; Thu, 10 Jan 2019 19:09:43 -0800 (PST) X-Google-Smtp-Source: ALg8bN7z8rCHqQ9ofNn2ck8NZBJ+ITrbFjcHYCSKWZ9bV9p7QeMwJ84sEFal0/ygvzMLHt78j83x X-Received: by 2002:a17:902:22f:: with SMTP id 44mr12812216plc.137.1547176183297; Thu, 10 Jan 2019 19:09:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547176183; cv=none; d=google.com; s=arc-20160816; b=C6t8waByQzxLCFOVI0zeInplPKCTlZdDpEzpdVEfeiQgr2euWvG4y93vNr9J7wakak 4Wchse87JaC9laXv5Fw21ThLCkaJcffr2sLP3frw1vFgx6JPphLJnjcP507A1bkpl7VS EOX3fVONW9qDBiB3r7F3jBBbFq90P8ypyt5iAzpoEGChSOe9IzKcdGVVWxZwbfoPa366 AXhjmoM2v5OKsQfYIz45EOYVXofE8nlZFnneblwywpyD+YWLsJfJz0b+h+dt/tFeMm5o mOV0PV8inXdrD7qO+jxXD/0vjNFm9Q4IlG8G64xAFuAfyEjMD2ETFiLBzUZc0+TGg6su ih/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=CGbGciDXDaOFaw7tyoURQCK72kHq4YbWapdOxjk8N70=; b=CA/ki9hxVjLiLzdFXxHOZd4uVwPDx525YSj6TSuYn76mWqWzf+EKLN6l//O+f5Q8SM hrPJb78WhNjUDKuSZYCzJM36iX4jOk9d+HzHUxbdQG+jBsG4HU1lAo8PxWKDy2jo+/u6 AYCF4YhyHSUDTxuE7W3LvINZpa49a0ugmmSYFt9LpTkyA5RbsPk4F8biuABWjAGxWqPq 1E8lwLWPk2qWYyLICXMS9YOtdF2yrFHGoNlTP15++p6g1i/+MDY/uFAMgL2CvS0p9H68 BISPF1IUUyT0pVYlSQYVmUijAYb8h1hiO5cuKWj5CRxUf9RAPyTRoexb4srYgAhIE0Eb mfkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=EikjmN81; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z128si72189572pgb.372.2019.01.10.19.09.25; Thu, 10 Jan 2019 19:09:43 -0800 (PST) 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=@ziepe.ca header.s=google header.b=EikjmN81; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730368AbfAJXmW (ORCPT + 99 others); Thu, 10 Jan 2019 18:42:22 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:38090 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729110AbfAJXmV (ORCPT ); Thu, 10 Jan 2019 18:42:21 -0500 Received: by mail-pf1-f196.google.com with SMTP id q1so6037103pfi.5 for ; Thu, 10 Jan 2019 15:42:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=CGbGciDXDaOFaw7tyoURQCK72kHq4YbWapdOxjk8N70=; b=EikjmN81xd0nQYwSQaGSTWnffwVY5+AHktdBEvhGsIF2HmmPw/R/OlTfhTMwj10EZE 5KPxZCr+qIRKeMKeUufebHuguv/APZnaE8YNW1a6fPptcbADcT6ov5wIFeo5l018BId+ PBpYWzJNXx3PrQ/wfhZ4ckh/y23Q5nCEZ4lXJT6VBG2wOg/C9rNY1uxrWYE0W88RxiYU o5HPbrjaa+bGJJtqcApZsGIpECsGFb34+3CetwTLDGWlU4w4/Y9fcU7p36zuYk3nMbGk hWSh+iY8RsUnHeH+y8HrtUCWJFinAhL/bvEEZX8azURWciKjfISAovS3zmjWOX3KjfiC 0ixw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=CGbGciDXDaOFaw7tyoURQCK72kHq4YbWapdOxjk8N70=; b=Wre2a6D8YY97ubTDdtuEHqtJ0DBTvdAsVpevR4ZUumZTNU5dtzCHZK/JPRfsCzTNFB KAxqovxDlRdaeQraFJ+dqJ1F73bnPH2f+u8HuzTAA1u096/W5gcDHJ5yGl4D52iz+Rj2 E/oA/7TZtfEaar0tyADX4WlrxqU4IRbIvz39MISntKYvueCnBaxpPj7j/ywubxdc995t vqT+NiB/9aCyWfo2uSjNLfrNxQIjOuaUa5I0LX+f25qjFHpsjDV4oPRUqafg7YxcAoLM xjBWvE8SfbF7mJbdyeTiSDkrg/luqdYtixAoRTkts9Q07S82dhj6NmovniNYDTH0DSnT 8j3w== X-Gm-Message-State: AJcUukcYigHRARg6t/8JDfGw2G13JoQIvecM32xhcB5LDLCUt75WzClZ dlHP+33R14vHgk2femxuCKc7+Q== X-Received: by 2002:a63:4948:: with SMTP id y8mr11205161pgk.32.1547163740837; Thu, 10 Jan 2019 15:42:20 -0800 (PST) Received: from ziepe.ca (S010614cc2056d97f.ed.shawcable.net. [174.3.196.123]) by smtp.gmail.com with ESMTPSA id v12sm105948442pgg.41.2019.01.10.15.42.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Jan 2019 15:42:19 -0800 (PST) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1ghjxq-0001Fq-Ic; Thu, 10 Jan 2019 16:42:18 -0700 Date: Thu, 10 Jan 2019 16:42:18 -0700 From: Jason Gunthorpe To: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, Christoph Hellwig Cc: Shiraz Saleem , Imre Deak , Daniel Vetter , linux-media@vger.kernel.org, Yong Zhi , Sakari Ailus , Bingbu Cao , Tian Shu Qiu , Jian Xu Zheng , Sinclair Yeh , Thomas Hellstrom , dri-devel@lists.freedesktop.org Subject: Re: [PATCH] lib/scatterlist: Provide a DMA page iterator Message-ID: <20190110234218.GM6890@ziepe.ca> References: <20190104223531.GA1705@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190104223531.GA1705@ziepe.ca> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 04, 2019 at 03:35:31PM -0700, Jason Gunthorpe wrote: > Commit 2db76d7c3c6d ("lib/scatterlist: sg_page_iter: support sg lists w/o > backing pages") introduced the sg_page_iter_dma_address() function without > providing a way to use it in the general case. If the sg_dma_len is not > equal to the dma_length callers cannot safely use the > for_each_sg_page/sg_page_iter_dma_address combination. > > Resolve this API mistake by providing a DMA specific iterator, > for_each_sg_dma_page(), that uses the right length so > sg_page_iter_dma_address() works as expected with all sglists. A new > iterator type is introduced to provide compile-time safety against wrongly > mixing accessors and iterators. > > Signed-off-by: Jason Gunthorpe > drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 26 ++++++++++-- > drivers/gpu/drm/vmwgfx/vmwgfx_mob.c | 26 +++++++----- > drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 42 +++++++++++++------ > drivers/media/pci/intel/ipu3/ipu3-cio2.c | 4 +- > include/linux/scatterlist.h | 49 ++++++++++++++++++---- > lib/scatterlist.c | 26 ++++++++++++ > 6 files changed, 134 insertions(+), 39 deletions(-) > > I'd like to run this patch through the RDMA tree as we have another > series in the works that wants to use the for_each_sg_dma_page() API. > > The changes to vmwgfx make me nervous, it would be great if someone > could test and ack them? > > Changes since the RFC: > - Rework vmwgfx too [CH] > - Use a distinct type for the DMA page iterator [CH] > - Do not have a #ifdef [CH] ChristophH: Will you ack? Are you still OK with the vmwgfx reworking, or should we go back to the original version that didn't have the type safety so this driver can be left broken? Thanks, Jason