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=-3.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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 AB531C388F7 for ; Tue, 10 Nov 2020 14:14:51 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ED986207D3 for ; Tue, 10 Nov 2020 14:14:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="ZMmpCnGx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ED986207D3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3278F89262; Tue, 10 Nov 2020 14:14:50 +0000 (UTC) Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by gabe.freedesktop.org (Postfix) with ESMTPS id C24A189262 for ; Tue, 10 Nov 2020 14:14:49 +0000 (UTC) Received: by mail-wr1-x430.google.com with SMTP id b6so1480266wrt.4 for ; Tue, 10 Nov 2020 06:14:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=8IcGGTKYyeJzANG/fH/4OAuqD6l1LU2uOKX7qMbCBZA=; b=ZMmpCnGxT6S84bDoG46UlaLwRiQ1gDDBqsmHOxrOomO6S/WC7lm/CkFL6l/jEbG2VE 0uUNIVSRlyWZIH0XvjuiIhJ7/nyKnTlTHlAbcHB+4tEtMHyv7xEGekHYi1h6UjxMtfaz jxmFK8Yd9UF4q17j06Fs+WDiJwzyKTx95pXes= 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; bh=8IcGGTKYyeJzANG/fH/4OAuqD6l1LU2uOKX7qMbCBZA=; b=CQ4zs6IhayxGvGOo08HpyL2zLZ2vzts93O/3UjLCg86cR9YzHSn+cR1ttpFkMWXTe0 PEEAc5+ncBs8TfRI5lpgE2jVvTXSpaPPG/y4W3IPWWJ35exLajNQA3azIDsfpoe+cDNX x1Bki9qvX5OYFshphOSKQb5gCrgrScHVwDzmg/vXBK789wc4BExajnOjfFb2a0J4QEVC dwUMuBG4zAFGq6kj8Px7w5LzoQnGl+jr80xPVfP3LHSxwA7kyTSK+P7UNRufln8g+L8p eoC0SGtwzzHHNlSuzGFstGtdnBARM2NheXEWTi0iwTny/m0aUNQaZTQYY3Its19Cge9l pG9g== X-Gm-Message-State: AOAM531o87LathzE8WqoO7/S7Kg2iY4Y2PFAYLSN6KnATfaB40YtcRKv 0tdBZvpNE62nO/w1saK9VxDUzg== X-Google-Smtp-Source: ABdhPJzG/UIF3dNTtGW7tPhr4EP9TwE3B/cEGkHpgw4VNMo89aauYpYSkqO0ZWw2XriDN6QoBX/YVQ== X-Received: by 2002:a5d:6046:: with SMTP id j6mr24473612wrt.317.1605017688496; Tue, 10 Nov 2020 06:14:48 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id a128sm3232055wmf.5.2020.11.10.06.14.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2020 06:14:47 -0800 (PST) Date: Tue, 10 Nov 2020 15:14:45 +0100 From: Daniel Vetter To: Jason Gunthorpe Subject: Re: [PATCH v8 1/5] RDMA/umem: Support importing dma-buf as user memory region Message-ID: <20201110141445.GI401619@phenom.ffwll.local> References: <1604616489-69267-1-git-send-email-jianxin.xiong@intel.com> <1604616489-69267-2-git-send-email-jianxin.xiong@intel.com> <20201106000851.GK36674@ziepe.ca> <20201106163953.GR36674@ziepe.ca> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201106163953.GR36674@ziepe.ca> X-Operating-System: Linux phenom 5.7.0-1-amd64 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Leon Romanovsky , "linux-rdma@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , Doug Ledford , "Vetter, Daniel" , Christian Koenig , "Xiong, Jianxin" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Fri, Nov 06, 2020 at 12:39:53PM -0400, Jason Gunthorpe wrote: > On Fri, Nov 06, 2020 at 04:34:07PM +0000, Xiong, Jianxin wrote: > > > > The user could specify a length that is beyond the dma buf, can > > > the dma buf length be checked during get? > > > > In order to check the length, the buffer needs to be mapped. That can be done. > > Do DMA bufs even have definitate immutable lengths? Going to be a > probelm if they can shrink Yup. Unfortunately that's not document in the structures themselves, there's just some random comments sprinkled all over that dma-buf size is invariant, e.g. see the @mmap kerneldoc in dma_buf_ops: https://dri.freedesktop.org/docs/drm/driver-api/dma-buf.html?highlight=dma_buf_ops#c.dma_buf_ops "Because dma-buf buffers have invariant size over their lifetime, ..." Jianxin, can you pls do a kerneldoc patch which updates the comment for dma_buf.size and dma_buf_export_info.size? Thanks, Daniel > > > > Also page_size can be 0 because iova is not OK. iova should be > > > checked for alignment during get as well: > > > > > > iova & (PAGE_SIZE-1) == umem->addr & (PAGE_SIZE-1) > > > > If ib_umem_dmabuf_map_pages is called during get this error is automatically caught. > > The ib_umem_find_best_pgsz() checks this equation, yes. > > So you'd map the sgl before allocating the mkey? This then checks the > length and iova? > > Jason > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel