Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2956263ybi; Mon, 17 Jun 2019 13:28:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqwdcaR+RGMleeCp7k0ymhi6QbIRkiz0b/2vGmyrEQBKWvzpgBtqzamfqoyUXj1TQvzfENDA X-Received: by 2002:a17:902:d715:: with SMTP id w21mr110535666ply.234.1560803311346; Mon, 17 Jun 2019 13:28:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560803311; cv=none; d=google.com; s=arc-20160816; b=zwdbVPgiWwaDNRt1xPkkzpbrhBqe5X5oH9dTNPhuAsM549LexWIrtigMFCZJqm/sLE VeQTJ/yzX7ipEAVYeGf7Ka9PHSj0OnfVNeATlOGPKYeVenqIxmQgopDsC9FEfllWCJsm VfCXVFzVsKIIBehB6V7iDq1X1frGk67Xg8XXqLsmSQytyxqtLRSlJGP0dKGQMPp22Ui5 8sOAXNYkFo+PvQ5s0C1Gx4huUg7VHKy178YzPEhy7/tJKQvgGNnB5u20kJcTCQI3KGIj 797q1EnJU90VY9FF3s9CZwt2KEcmLgcJfTvVvP4Hh4DdgFcVJKFIGiZr3Gtvl6AYoyLa hQEw== 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=HBZ75IKDYyZ4WilF4x2RUyRtRRr5NkqX+aHh1xkIWLk=; b=ggMQG8sem+Q9mN7ZB96qOhIyrld+ymukDoy9DPdnWyHvpfGpXBq7323qmzrkczFXap KOSdkNLjEZpk26W2Txdxsxaln0Vqyrpc/36iE5h9aIi8DTBX72vyHJMD8I8cKIhEiseh QgsewvqQh/ejHuv09WsXzRqWlyerSQjNWuat/Lt0OPyfiXUO7Zd+FN6yQR2gUAPsta9l ZyEOcRjkHgj5GME+bURn/I263Emjtoq0CCHbFckHiMgo5XB2Skjg33KFygP6X2n+TMNx s2tzYlDwM5/QfkwBAdTy//dS9+82vpXl2FUnNIWuiUUnMes1Npb8HOBiReR45FIPh0Gj M63A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@shipmail.org header.s=mail header.b=PEbXVYUY; 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 i124si11758778pfe.139.2019.06.17.13.28.16; Mon, 17 Jun 2019 13:28:31 -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 (test mode) header.i=@shipmail.org header.s=mail header.b=PEbXVYUY; 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 S1728064AbfFQU1s (ORCPT + 99 others); Mon, 17 Jun 2019 16:27:48 -0400 Received: from ste-pvt-msa2.bahnhof.se ([213.80.101.71]:46402 "EHLO ste-pvt-msa2.bahnhof.se" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726741AbfFQU1s (ORCPT ); Mon, 17 Jun 2019 16:27:48 -0400 Received: from localhost (localhost [127.0.0.1]) by ste-pvt-msa2.bahnhof.se (Postfix) with ESMTP id 88EB33FAD8; Mon, 17 Jun 2019 22:18:18 +0200 (CEST) Authentication-Results: ste-pvt-msa2.bahnhof.se; dkim=pass (1024-bit key; unprotected) header.d=shipmail.org header.i=@shipmail.org header.b=PEbXVYUY; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at bahnhof.se X-Spam-Flag: NO X-Spam-Score: -3.099 X-Spam-Level: X-Spam-Status: No, score=-3.099 tagged_above=-999 required=6.31 tests=[ALL_TRUSTED=-1, BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no Authentication-Results: ste-ftg-msa2.bahnhof.se (amavisd-new); dkim=pass (1024-bit key) header.d=shipmail.org Received: from ste-pvt-msa2.bahnhof.se ([127.0.0.1]) by localhost (ste-ftg-msa2.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Flga4_RR7zCy; Mon, 17 Jun 2019 22:18:05 +0200 (CEST) Received: from mail1.shipmail.org (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) (Authenticated sender: mb878879) by ste-pvt-msa2.bahnhof.se (Postfix) with ESMTPA id 6B8753F252; Mon, 17 Jun 2019 22:18:05 +0200 (CEST) Received: from localhost.localdomain.localdomain (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) by mail1.shipmail.org (Postfix) with ESMTPSA id 2F691361999; Mon, 17 Jun 2019 22:18:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=shipmail.org; s=mail; t=1560802685; bh=0OCS847VhF4p4ZkW88dxoqjOEDCCvJZwECAtiDuXG38=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PEbXVYUYvggduL4xRSMP/RsiYkumjGsjdEEURZbKbay3j/ix0t0kAh3TiSdpFWUux Xfwt2dDsS0uIBA9s8pAn4aMo+m/0LRIIXyMo3s8rzETaxZHxD9pABBb+gXOrxSsczX 3FDGbcTIC5UM0b7w5UtmTvEcJGIOw5inNXzpO3ks= From: =?UTF-8?q?Thomas=20Hellstr=C3=B6m=20=28VMware=29?= To: dri-devel@lists.freedesktop.org Cc: linux-graphics-maintainer@vmware.com, pv-drivers@vmware.com, linux-kernel@vger.kernel.org Subject: [PATCH v7 4/9] drm/ttm: Allow the driver to provide the ttm struct vm_operations_struct Date: Mon, 17 Jun 2019 22:17:51 +0200 Message-Id: <20190617201756.12587-5-thomas@shipmail.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190617201756.12587-1-thomas@shipmail.org> References: <20190617201756.12587-1-thomas@shipmail.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Hellstrom Add a pointer to the struct vm_operations_struct in the bo_device, and assign that pointer to the default value currently used. The driver can then optionally modify that pointer and the new value can be used for each new vma created. Cc: "Christian König" Signed-off-by: Thomas Hellstrom Reviewed-by: Christian König --- drivers/gpu/drm/ttm/ttm_bo.c | 1 + drivers/gpu/drm/ttm/ttm_bo_vm.c | 6 +++--- include/drm/ttm/ttm_bo_driver.h | 6 ++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index c7de667d482a..6953dd264172 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -1739,6 +1739,7 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev, mutex_lock(&ttm_global_mutex); list_add_tail(&bdev->device_list, &glob->device_list); mutex_unlock(&ttm_global_mutex); + bdev->vm_ops = &ttm_bo_vm_ops; return 0; out_no_sys: diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c index 6dacff49c1cc..196e13a0adad 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c @@ -395,7 +395,7 @@ static int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned long addr, return ret; } -static const struct vm_operations_struct ttm_bo_vm_ops = { +const struct vm_operations_struct ttm_bo_vm_ops = { .fault = ttm_bo_vm_fault, .open = ttm_bo_vm_open, .close = ttm_bo_vm_close, @@ -448,7 +448,7 @@ int ttm_bo_mmap(struct file *filp, struct vm_area_struct *vma, if (unlikely(ret != 0)) goto out_unref; - vma->vm_ops = &ttm_bo_vm_ops; + vma->vm_ops = bdev->vm_ops; /* * Note: We're transferring the bo reference to @@ -480,7 +480,7 @@ int ttm_fbdev_mmap(struct vm_area_struct *vma, struct ttm_buffer_object *bo) ttm_bo_get(bo); - vma->vm_ops = &ttm_bo_vm_ops; + vma->vm_ops = bo->bdev->vm_ops; vma->vm_private_data = bo; vma->vm_flags |= VM_MIXEDMAP; vma->vm_flags |= VM_IO | VM_DONTEXPAND; diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index c9b8ba492f24..a2d810a2504d 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h @@ -442,6 +442,9 @@ extern struct ttm_bo_global { * @driver: Pointer to a struct ttm_bo_driver struct setup by the driver. * @man: An array of mem_type_managers. * @vma_manager: Address space manager + * @vm_ops: Pointer to the struct vm_operations_struct used for this + * device's VM operations. The driver may override this before the first + * mmap() call. * lru_lock: Spinlock that protects the buffer+device lru lists and * ddestroy lists. * @dev_mapping: A pointer to the struct address_space representing the @@ -460,6 +463,7 @@ struct ttm_bo_device { struct ttm_bo_global *glob; struct ttm_bo_driver *driver; struct ttm_mem_type_manager man[TTM_NUM_MEM_TYPES]; + const struct vm_operations_struct *vm_ops; /* * Protected by internal locks. @@ -488,6 +492,8 @@ struct ttm_bo_device { bool no_retry; }; +extern const struct vm_operations_struct ttm_bo_vm_ops; + /** * struct ttm_lru_bulk_move_pos * -- 2.20.1