Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4365852ybi; Tue, 11 Jun 2019 05:36:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqwfeSTu5cuTxE+v/28xratFYKnSHJ79R/bzKhOw3Tl9G+aoGY3lXLKY1IpH0V9t0VCX7/vB X-Received: by 2002:a65:5004:: with SMTP id f4mr20653003pgo.268.1560256566131; Tue, 11 Jun 2019 05:36:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560256566; cv=none; d=google.com; s=arc-20160816; b=xsXqBlst6Ghsh6SrKo2lx552+OLV5UJWjhJAvWlZ98dt3dlONkOUS/5bkTiIIfKW6b XZGH1ARDoWd2Yv6VGtL4inrK+V4yJEtCXOcJIwpylO/8aDEwrx9xbUrU+xYFWYgHc2vB kOiXsFyHHyaCY4nD9y+ta4KdC7n2TmyyPZko1r0nYw+HtxxKqoDJPn3ACW5jp0Lrwu+B bns8gxi1V7jltpSWzzQCm/dJoIpvTU7VZEoiSjM6XOXq+amE/bM9sMwxhanEsGg9G1d4 e8LQp4ogLyePiS7GA7qjXMxe7wjDWpSxcb4uTxz8TGTT8FD8pyUlZRh9i7JWsfgZb4WY LOLA== 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=u8FlGEfownmcfdOAh6IsAVVcLHZyk1tWe/WTm+NumLwB3xg0QH7QTI1GwJW7LQdugS EFzOAvKViKZVslnXOwjkdjOCxF6PmKLTpkj2prGQzsEsaERnJwlezewx/MKpBlqid7ls 8OBuDY9u1TxCPLeDT+CAVO1LeNofs05H5Rbbczno+SiD0n0ye7uiZSPEl0y92x7vQRNg 6wm7MhVs7WPbPiUaBJv/HPP5Ue74KxpNsX5I9IW66tRlVtJS8MKjnDh+81NowerpM5Xe ydm5+77Xn3U9FGOcUVRwQz3uaywX882wNeDd14PNK8dLP6b4hZ07qX7C+mP1Vv80JSNU 9vdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@vmwopensource.org header.s=mail header.b=0174Lzv6; 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 m12si6443368pgd.402.2019.06.11.05.35.49; Tue, 11 Jun 2019 05:36:06 -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=0174Lzv6; 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 S2389757AbfFKMfK (ORCPT + 99 others); Tue, 11 Jun 2019 08:35:10 -0400 Received: from pio-pvt-msa2.bahnhof.se ([79.136.2.41]:37244 "EHLO pio-pvt-msa2.bahnhof.se" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388392AbfFKMfJ (ORCPT ); Tue, 11 Jun 2019 08:35:09 -0400 Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa2.bahnhof.se (Postfix) with ESMTP id 4E98A3FA61; Tue, 11 Jun 2019 14:25:21 +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=0174Lzv6; 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 QB2Bejz6D5Zt; Tue, 11 Jun 2019 14:25:09 +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 E2ECA3F53F; Tue, 11 Jun 2019 14:25:08 +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 A21EC361B57; Tue, 11 Jun 2019 14:25:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=vmwopensource.org; s=mail; t=1560255908; bh=0OCS847VhF4p4ZkW88dxoqjOEDCCvJZwECAtiDuXG38=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0174Lzv6lxagtJ/fYaMLdPUN7MtIl7bIqarLqppevQLSO9EeRncOZMWD6rPQfqe/f 6MUHVadnKAFWfQGPofbV7Zq7+N4dqEz/28kN9ds0OptA6w/rjvDcL/StAja9pH2e8f 26v4wwvgPUcu5ovqmH+77yVdjzS/l/X9K+i9FyDI= 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, Thomas Hellstrom , =?UTF-8?q?Christian=20K=C3=B6nig?= Subject: [PATCH v4 4/9] drm/ttm: Allow the driver to provide the ttm struct vm_operations_struct Date: Tue, 11 Jun 2019 14:24:49 +0200 Message-Id: <20190611122454.3075-5-thellstrom@vmwopensource.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190611122454.3075-1-thellstrom@vmwopensource.org> References: <20190611122454.3075-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