Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5941451ybi; Wed, 12 Jun 2019 11:05:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqzitvkb+MgSj8XBSf3Wy1nVisr3HKQhjPuqY1XzAZjI2nXcRPqh51YAC9Syq6LtVAj4hEVX X-Received: by 2002:a62:6:: with SMTP id 6mr24070210pfa.159.1560362735556; Wed, 12 Jun 2019 11:05:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560362735; cv=none; d=google.com; s=arc-20160816; b=hdyviVyxRc2JljKtU+qYjPRTalgj27lmj93pn7Ti9q+MUni+YroJ6acbRO+RaM5qDc Z+CEAVJR6srd+hHeaNlOZ5cTlkVGPkKrlcmMSJoEtyw5pf1Tx0kVh+W+Ci2sXRKFyZ3N 1NRqPzb4ENfELH3HVgIctnNIvYT+tqyr/OXJzVjN/Usb7eYNqOUay6SXVIi7Oj4JuFK2 PxYFt1dDFuWKbqq1b/ta1JMAfx7l6FLEjRiDv462dhWiNrinedBFEsSMDd20dBoq5p28 4HxSXV5LWALQCyRuL3rAhMj+571aCAtr/bnqFmbCDLkS5M2X7Ijf/EKEN2haOmoZm1UZ 07YQ== 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=yMzA6IvAkLVzWL3ypDmzqheJsdFjvAikkPSY4s9Aq+ZeO8y0uSUZSwuXwn/vn+6gwn 9l0SFZ1IjItdZnTmN+I4ipjsJvdTkkIc4Ve7oNkzoAuVri5NUSDBW9UNeEO6ugE/LAtJ SuaMHp7pWQhsXKXe9oKaEwjWLARLGbCWi6+1osjJ3R1OY2/+1rE/E+BL059Uqa3AzNPE HScp0gJT372bIh5hCVCP3jFxrsEAap04RKl3ozWxIOtgf6yAkUfsGSqfbDxv6VPFP2HE MZvpsgvsVE24W1baaH1AdfU/n8e2+0IvTgJtNtnNdtB1Hmi3nyUvifJsvdvJwN6macis MABA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@vmwopensource.org header.s=mail header.b=k9y9Rssd; 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 d2si450401pjs.10.2019.06.12.11.05.20; Wed, 12 Jun 2019 11:05:35 -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=@vmwopensource.org header.s=mail header.b=k9y9Rssd; 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 S2501956AbfFLPUb (ORCPT + 99 others); Wed, 12 Jun 2019 11:20:31 -0400 Received: from pio-pvt-msa2.bahnhof.se ([79.136.2.41]:36124 "EHLO pio-pvt-msa2.bahnhof.se" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2439785AbfFLPUa (ORCPT ); Wed, 12 Jun 2019 11:20:30 -0400 Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa2.bahnhof.se (Postfix) with ESMTP id A60FE4135F; Wed, 12 Jun 2019 17:20:23 +0200 (CEST) Authentication-Results: pio-pvt-msa2.bahnhof.se; dkim=pass (1024-bit key; unprotected) header.d=vmwopensource.org header.i=@vmwopensource.org header.b=k9y9Rssd; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at bahnhof.se X-Spam-Flag: NO X-Spam-Score: -3.1 X-Spam-Level: X-Spam-Status: No, score=-3.1 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] autolearn=ham autolearn_force=no Received: from pio-pvt-msa2.bahnhof.se ([127.0.0.1]) by localhost (pio-pvt-msa2.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ya1Ae-sIKO5o; Wed, 12 Jun 2019 17:20:10 +0200 (CEST) Received: from mail1.shipmail.org (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) (Authenticated sender: mb878879) by pio-pvt-msa2.bahnhof.se (Postfix) with ESMTPA id 378A3405E5; Wed, 12 Jun 2019 17:20:10 +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 01685361DE1; Wed, 12 Jun 2019 17:20:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=vmwopensource.org; s=mail; t=1560352810; bh=0OCS847VhF4p4ZkW88dxoqjOEDCCvJZwECAtiDuXG38=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k9y9RssdEDp2LHuSq7fpS6qJlK2q559+qdFnOLj5g2pGD5+dKqd/fO5Fq6L2/nPH5 3++KA0r9bzfjVZDeL5WsVJNwFog2VjQmXsUEPmHQOZQvIDpuB7EMDvGwjhcpRY3hKY EErVQfGIxJOhGai3cpQkdYwxRPUVGXTaSf3SmTTA= 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, hch@infradead.org, Thomas Hellstrom , =?UTF-8?q?Christian=20K=C3=B6nig?= Subject: [PATCH v6 4/9] drm/ttm: Allow the driver to provide the ttm struct vm_operations_struct Date: Wed, 12 Jun 2019 17:19:45 +0200 Message-Id: <20190612151950.2870-5-thellstrom@vmwopensource.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190612151950.2870-1-thellstrom@vmwopensource.org> References: <20190612151950.2870-1-thellstrom@vmwopensource.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