Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp177128ybt; Tue, 16 Jun 2020 20:35:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzclMhsbW++VvF/zZsAEX3v1dpQOUAOiNjdXW/5OkfRF2KrbHZveSabTYpaYodqnzU9D9L5 X-Received: by 2002:a17:906:648e:: with SMTP id e14mr5561489ejm.308.1592364931578; Tue, 16 Jun 2020 20:35:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592364931; cv=none; d=google.com; s=arc-20160816; b=wqyf7dZ2AqFgtEuwDFMlkqixwAiN636keT9V9MdTmXmC8Y8LhHRN5hd4LuNCvV04Uj VJ1GSg9+lLJysNK/+J9+jx/kkihK8ndTreUyidP7n+nzjNTsyyPC7P+nplkYWp40swjY a5kEzsDgfFiF2LGLRBZ8VuPoUrZOaDhMDKz5xnZhcU5L2lsx1AFCsniip+YIM82XmLJ2 rluAViqNtjH9M4EE/IgQk+rLwlz1q13IcMZmc+o1xIbj5NGNrR/Zc+JDsYwTjonVl6Es pps1M1LgDgftQ0+liIFVrmTRmMdxDjLGGoq2cynVVaX7Wxq+yzs9G6ykDzctlD0DucI2 6q/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9ZZXQEp1varx5CR2s6EKgHR6uqmX28df2mtW01Bo6oc=; b=dF8NG4CV1kjV9tX7pRFvfEH5gZOFF+nOgjYnczmyyzIhUG2ZgdqI48XJVzKE0NawuJ SkcyJTY0GGYb2DHF1dw3Cnu0KrDKCPW6pMISd/V6vAkjekBkdepB6eQ7htEX8W4m8toy o82HVBChmvMkJGYcSd+OGwQBsi5Qi5bguDD8xhizKZCPuoDEGKpmo5MA0X7i7YOxJF8r oKCWKhETqelpsG5eo3ua1ipPb+Me5UjyznZ+Y01j5qY8T2+2mQ2ypWO91zo3oBiCC1bv zSFnHmI7LOm1aSGFvflZy1DagYT4ZlTN643nGBhYXV7CgOks8tqWRpscXqbrghHGvSVB URFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bRPFMMoj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qk2si12536551ejb.271.2020.06.16.20.35.08; Tue, 16 Jun 2020 20:35:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bRPFMMoj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726784AbgFQDab (ORCPT + 99 others); Tue, 16 Jun 2020 23:30:31 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:60023 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726703AbgFQDab (ORCPT ); Tue, 16 Jun 2020 23:30:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592364630; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9ZZXQEp1varx5CR2s6EKgHR6uqmX28df2mtW01Bo6oc=; b=bRPFMMojD22UrTBbDpBd2Ch5u9Df+RM/zLVjZNOY8hYiWR+lL4l+MRQ2v3Dmq0x6eISb3t X+sKRnzZFJY6qRebuPzII03hRctbebGjo8TB1GoyGGwtzKH9nHHgzKNPd/z6/dXkf8zYa4 0YoaNHNpUNK0C1G/ecv2xkUjUn4v3mg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-18-X6qc-4UqMiif4jM_1owsrQ-1; Tue, 16 Jun 2020 23:30:27 -0400 X-MC-Unique: X6qc-4UqMiif4jM_1owsrQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 30BB787342D; Wed, 17 Jun 2020 03:30:25 +0000 (UTC) Received: from jason-ThinkPad-X1-Carbon-6th.redhat.com (ovpn-13-217.pek2.redhat.com [10.72.13.217]) by smtp.corp.redhat.com (Postfix) with ESMTP id B0D475C1BD; Wed, 17 Jun 2020 03:30:18 +0000 (UTC) From: Jason Wang To: mst@redhat.com, jasowang@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Cc: rob.miller@broadcom.com, lingshan.zhu@intel.com, eperezma@redhat.com, lulu@redhat.com, shahafs@mellanox.com, hanand@xilinx.com, mhabets@solarflare.com, gdawar@xilinx.com, saugatm@xilinx.com, vmireyno@marvell.com, zhangweining@ruijie.com.cn, eli@mellanox.com Subject: [PATCH 3/4] vdpa: get_iova_range() is mandatory for device specific DMA translation Date: Wed, 17 Jun 2020 11:29:46 +0800 Message-Id: <20200617032947.6371-4-jasowang@redhat.com> In-Reply-To: <20200617032947.6371-1-jasowang@redhat.com> References: <20200617032947.6371-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to let userspace work correctly, get_iova_range() is a must for the device that has its own DMA translation logic. Signed-off-by: Jason Wang --- drivers/vdpa/vdpa.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c index de211ef3738c..ab7af978ef70 100644 --- a/drivers/vdpa/vdpa.c +++ b/drivers/vdpa/vdpa.c @@ -82,6 +82,10 @@ struct vdpa_device *__vdpa_alloc_device(struct device *parent, if (!!config->dma_map != !!config->dma_unmap) goto err; + if ((config->dma_map || config->set_map) && + !config->get_iova_range) + goto err; + err = -ENOMEM; vdev = kzalloc(size, GFP_KERNEL); if (!vdev) -- 2.20.1