From patchwork Tue Aug 20 14:53:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 11103957 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2FDB6174A for ; Tue, 20 Aug 2019 14:54:04 +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 1880222DA9 for ; Tue, 20 Aug 2019 14:54:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1880222DA9 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 1B2316E42E; Tue, 20 Aug 2019 14:53:56 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by gabe.freedesktop.org (Postfix) with ESMTPS id DB0436E402 for ; Tue, 20 Aug 2019 14:53:53 +0000 (UTC) Received: by mail-ed1-x542.google.com with SMTP id m44so6649473edd.9 for ; Tue, 20 Aug 2019 07:53:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CdwHAb7ZPDfBP0UbOZKMmtGmYuLNauAEc2DOfgM2fkg=; b=mV0dzwLYT34N9KO0R0tSvrP/kofWpTn3CU/UcMLTMkU3KMTPubSaopqj88uUNNzc71 p0zgEqCZKICmv7JFSRp+G8QZzS5lcr+aJzsIG5MyU6Tap0xkfKHlDEdKyNgblviGIs03 X7LXGH/YUU1Ih9NwLAqtakj2zaUke0qBjLeLmVFfbHsSHmsbMNrtG5ROANj1yJlqB9RE qmzXA5YoC+Yj351n9ALBy0aRqPW2/v46HT0BpRbD4m4nSumEWDBEUhMbRNkjtFPc4Tnx IGkRWyZDgJHD4f9EJtuGHC0mgYKqZbHD+W9xGrbKQV/VBbZYVD9lyiev0aCiKcTlcnpO oW1A== X-Gm-Message-State: APjAAAWNwdvuPMRgbppMzRLbs4K86E0mcXmwNoADxc4WtUDbd5lX1CTI Di+sukh35AFa557qyeUwpQJ7rSUFIdvHlA== X-Google-Smtp-Source: APXvYqz6w4nIkLDcD7Pi4H7qZDis/dATHqrreS4ooqJsT3KBWVWXdhKjrRR7UWGSjkXsoa+fZ8gZVg== X-Received: by 2002:a05:6402:1446:: with SMTP id d6mr32052510edx.102.1566312831689; Tue, 20 Aug 2019 07:53:51 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:569e:0:3106:d637:d723:e855]) by smtp.gmail.com with ESMTPSA id a16sm2644744ejr.10.2019.08.20.07.53.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 07:53:50 -0700 (PDT) From: Daniel Vetter To: DRI Development Subject: [PATCH 3/3] drm/ttm: remove ttm_bo_wait_unreserved Date: Tue, 20 Aug 2019 16:53:36 +0200 Message-Id: <20190820145336.15649-4-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.23.0.rc1 In-Reply-To: <20190820145336.15649-1-daniel.vetter@ffwll.ch> References: <20190820145336.15649-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CdwHAb7ZPDfBP0UbOZKMmtGmYuLNauAEc2DOfgM2fkg=; b=f6Jny7bsmy5xKFPwtA4+4AjVW7/hZzhlaoPtURHzaSk74Di3wUq+9ZnBXMApQ45sXA OsEjO6XSo4/TIEy32WgaNt2ZbCzOxOltDkpGvvf6AmK/ESV6MhjzNzhDhVASOb/plICX I/NrWCcwN7D9Yi4FOXzG5/xsoYTq0Db1Y5Si4= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Hellstrom , Daniel Vetter , Intel Graphics Development , Huang Rui , VMware Graphics , Gerd Hoffmann , Daniel Vetter , Christian Koenig Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" With nouveau fixed all ttm-using drives have the correct nesting of mmap_sem vs dma_resv, and we can just lock the buffer. Assuming I didn't screw up anything with my audit of course. Signed-off-by: Daniel Vetter Cc: Christian Koenig Cc: Huang Rui Cc: Gerd Hoffmann Cc: "VMware Graphics" Cc: Thomas Hellstrom --- drivers/gpu/drm/ttm/ttm_bo.c | 34 --------------------------------- drivers/gpu/drm/ttm/ttm_bo_vm.c | 26 +------------------------ include/drm/ttm/ttm_bo_api.h | 1 - 3 files changed, 1 insertion(+), 60 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 20ff56f27aa4..a952dd624b06 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -1954,37 +1954,3 @@ void ttm_bo_swapout_all(struct ttm_bo_device *bdev) ; } EXPORT_SYMBOL(ttm_bo_swapout_all); - -/** - * ttm_bo_wait_unreserved - interruptible wait for a buffer object to become - * unreserved - * - * @bo: Pointer to buffer - */ -int ttm_bo_wait_unreserved(struct ttm_buffer_object *bo) -{ - int ret; - - /* - * In the absense of a wait_unlocked API, - * Use the bo::wu_mutex to avoid triggering livelocks due to - * concurrent use of this function. Note that this use of - * bo::wu_mutex can go away if we change locking order to - * mmap_sem -> bo::reserve. - */ - ret = mutex_lock_interruptible(&bo->wu_mutex); - if (unlikely(ret != 0)) - return -ERESTARTSYS; - if (!dma_resv_is_locked(bo->base.resv)) - goto out_unlock; - ret = dma_resv_lock_interruptible(bo->base.resv, NULL); - if (ret == -EINTR) - ret = -ERESTARTSYS; - if (unlikely(ret != 0)) - goto out_unlock; - dma_resv_unlock(bo->base.resv); - -out_unlock: - mutex_unlock(&bo->wu_mutex); - return ret; -} diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c index 76eedb963693..505e1787aeea 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c @@ -125,31 +125,7 @@ static vm_fault_t ttm_bo_vm_fault(struct vm_fault *vmf) &bdev->man[bo->mem.mem_type]; struct vm_area_struct cvma; - /* - * Work around locking order reversal in fault / nopfn - * between mmap_sem and bo_reserve: Perform a trylock operation - * for reserve, and if it fails, retry the fault after waiting - * for the buffer to become unreserved. - */ - if (unlikely(!dma_resv_trylock(bo->base.resv))) { - if (vmf->flags & FAULT_FLAG_ALLOW_RETRY) { - if (!(vmf->flags & FAULT_FLAG_RETRY_NOWAIT)) { - ttm_bo_get(bo); - up_read(&vmf->vma->vm_mm->mmap_sem); - (void) ttm_bo_wait_unreserved(bo); - ttm_bo_put(bo); - } - - return VM_FAULT_RETRY; - } - - /* - * If we'd want to change locking order to - * mmap_sem -> bo::reserve, we'd use a blocking reserve here - * instead of retrying the fault... - */ - return VM_FAULT_NOPAGE; - } + dma_resv_lock(bo->base.resv, NULL); /* * Refuse to fault imported pages. This should be handled diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h index 43c4929a2171..6b50e624e3e2 100644 --- a/include/drm/ttm/ttm_bo_api.h +++ b/include/drm/ttm/ttm_bo_api.h @@ -765,7 +765,6 @@ ssize_t ttm_bo_io(struct ttm_bo_device *bdev, struct file *filp, int ttm_bo_swapout(struct ttm_bo_global *glob, struct ttm_operation_ctx *ctx); void ttm_bo_swapout_all(struct ttm_bo_device *bdev); -int ttm_bo_wait_unreserved(struct ttm_buffer_object *bo); /** * ttm_bo_uses_embedded_gem_object - check if the given bo uses the