Received: by 10.213.65.68 with SMTP id h4csp2334465imn; Mon, 9 Apr 2018 01:31:27 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/AEGQ+MaLCbgZkQOfB+zO3ab8oWVJDygcByZcyaOpwCcNgD1ShoyeEJe/WAnknSshgmcAc X-Received: by 10.167.133.23 with SMTP id v23mr3589770pfn.157.1523262687072; Mon, 09 Apr 2018 01:31:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523262687; cv=none; d=google.com; s=arc-20160816; b=L9PpD2JDVlLETPTIelJdq+sC7UJg93IT/1Ot/A8iheTi/saOFjEdKFaiUOXNWfdKSM OuWmo4/5SEgM5gDY3MWF2dvwjdwTuKCXS78/GFHQtNa02fkzuUIZhqniEQNiGAKKxVkO HWZi2cvWlgQQ5KDbxl2cyt4brf7+DG8EZvs7lmuohJ7b4gYtB+jkp5D7+gaeIb1emyV7 nJH3qFNfbra42CIiMk50vzPWkZoXxmIb5ZclJToXsNn7AkzB9KkioiYtBILskNCfbnaC uNphVp14AhAxabXB82xwRTnd/NHrOMcnTh5ERIdjaoAUt9+CqWPZ5QisZx8vmTBaMAKv YKDg== 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-transfer-encoding:content-disposition:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=2vIv64oZt81wN2ipRmyFQeU5xJiIYQ3ek/uhK3s8ZWo=; b=B9/nIPuRRw17gYrbKLXZpNtlkeLgUrtSdUM35BMpj3dYCzltLVunSjE5B91x5AcZ+v f+vpF1FkvH355LlAnhzk5C/Zw64zwfpKOWZUklGkWP2riX+/G2ZpivEnbFqOSki+ckUA Sle9AMBVDmUzGSQOpCDwLrfSg+lX3lJDC9koJlSbBC0s+ZgkjjQjtUac0BT6lt5y8kla Xv6ukfhD8f0plnvPea5J0I4VC399aVi91z+irlOEQPknJ1PPDz1h0vd4E43zybt5ee80 GlRTe48yaGlpd2m0FRedhTeTtcXNseNSJvYNEBaWw7NkDRTjcRHddZ+OQzh7CqGT6NkZ QnwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=ZXylwwmB; 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 j14si10890576pgs.139.2018.04.09.01.30.49; Mon, 09 Apr 2018 01:31:26 -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=fail header.i=@ffwll.ch header.s=google header.b=ZXylwwmB; 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 S1751671AbeDII1p (ORCPT + 99 others); Mon, 9 Apr 2018 04:27:45 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:39454 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751348AbeDII1o (ORCPT ); Mon, 9 Apr 2018 04:27:44 -0400 Received: by mail-wm0-f65.google.com with SMTP id f125so14772675wme.4 for ; Mon, 09 Apr 2018 01:27:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=sender:date:from:to:cc:subject:message-id:mail-followup-to :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=2vIv64oZt81wN2ipRmyFQeU5xJiIYQ3ek/uhK3s8ZWo=; b=ZXylwwmBSC2hCqqBz5RQdzBw6d6oWi9GZ+nDVkxMMXY6RJPBpsPklxAjoR91j5+egE 2NQr7lYkhTF8epQ2TeOOSmiigQpkc+bySUEgP8luM0/kaHRXNNX37B1lfG1a7PyTw/iP hzSpFnKftXK25wOB+qKNqK+sqo13tMORGb7K4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=2vIv64oZt81wN2ipRmyFQeU5xJiIYQ3ek/uhK3s8ZWo=; b=VZGsE0ja28cQUztrNAi94OB0C2aB30nIZUj31OmPbLPUcd7PBfJo/InCIJEcjNhvWt 6qZaB5yG8ZoaWZxUoYVYTtZfcjhs1LoLy+d+1fBPx40oZnan1mQlkuBGHZacm6w6PphH ANLF2iqklSld6Ajk3vuH8bOu1Ux6nS9OYMDAgnD34FDTZ6WLl0YTSv3uXxX7bkj9wCZG HIkZmkDSgzeq/gPzTvtk4UWFDbg/bgrNIsQUTH/HtPQW5Spw50oibv2kb73iDFdz2vkX +RNpSQsLA/egSe6irnf3P0noYECn/Uetis2YOCTVg4CGUBdA9Buw3vBT0qWCKQautqfJ nLrA== X-Gm-Message-State: ALQs6tA/fzQ4At84KXoLc8yprdMXEKNySf57/E2t81PtFsZxBkumOcbN rb3iuAhjMZpXfFD8IvGdL1dLKA== X-Received: by 10.80.250.13 with SMTP id b13mr20683542edq.290.1523262462934; Mon, 09 Apr 2018 01:27:42 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:5635:0:39d2:f87e:2033:9f6]) by smtp.gmail.com with ESMTPSA id d13sm58071edo.65.2018.04.09.01.27.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Apr 2018 01:27:42 -0700 (PDT) Date: Mon, 9 Apr 2018 10:27:40 +0200 From: Daniel Vetter To: Oleksandr Andrushchenko Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, airlied@linux.ie, daniel.vetter@intel.com, seanpaul@chromium.org, gustavo@padovan.org, jgross@suse.com, boris.ostrovsky@oracle.com, konrad.wilk@oracle.com, Oleksandr Andrushchenko Subject: Re: [PATCH 1/1] drm/xen-zcopy: Add Xen zero-copy helper DRM driver Message-ID: <20180409082740.GI31310@phenom.ffwll.local> Mail-Followup-To: Oleksandr Andrushchenko , xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, airlied@linux.ie, daniel.vetter@intel.com, seanpaul@chromium.org, gustavo@padovan.org, jgross@suse.com, boris.ostrovsky@oracle.com, konrad.wilk@oracle.com, Oleksandr Andrushchenko References: <20180329131931.29957-1-andr2000@gmail.com> <20180329131931.29957-2-andr2000@gmail.com> <20180403094734.GT3881@phenom.ffwll.local> <1ef9290a-7564-007d-81c6-cf7db74252f3@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1ef9290a-7564-007d-81c6-cf7db74252f3@gmail.com> X-Operating-System: Linux phenom 4.15.0-1-amd64 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, Apr 06, 2018 at 02:25:08PM +0300, Oleksandr Andrushchenko wrote: > On 04/03/2018 12:47 PM, Daniel Vetter wrote: > > On Thu, Mar 29, 2018 at 04:19:31PM +0300, Oleksandr Andrushchenko wrote: > > > From: Oleksandr Andrushchenko > > > +static int to_refs_grant_foreign_access(struct xen_gem_object *xen_obj) > > > +{ > > > + grant_ref_t priv_gref_head; > > > + int ret, j, cur_ref, num_pages; > > > + struct sg_page_iter sg_iter; > > > + > > > + ret = gnttab_alloc_grant_references(xen_obj->num_pages, > > > + &priv_gref_head); > > > + if (ret < 0) { > > > + DRM_ERROR("Cannot allocate grant references\n"); > > > + return ret; > > > + } > > > + > > > + j = 0; > > > + num_pages = xen_obj->num_pages; > > > + for_each_sg_page(xen_obj->sgt->sgl, &sg_iter, xen_obj->sgt->nents, 0) { > > > + struct page *page; > > > + > > > + page = sg_page_iter_page(&sg_iter); > > Quick drive-by: You can't assume that an sgt is struct page backed. > Do you mean that someone could give me sgt which never > seen sg_assign_page for its entries? Yes. > What are the other use-cases for that to happen? Sharing vram or other resources which are not backed by a struct page. See Christian K?nig's recent work to accomplish just that for admgpu. > > And you probably want to check this at import/attach time. > The check you mean is to make sure that when I call > page = sg_page_iter_page(&sg_iter); > I have to make sure that I get a valid page? Yup. > > -Daniel > Thank you, > Oleksandr Cheers, Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch