From patchwork Fri Sep 25 14:55:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 11799951 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 5B3AE112C for ; Fri, 25 Sep 2020 14:55:45 +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 2E6AF206F7 for ; Fri, 25 Sep 2020 14:55:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RzhC6wA0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2E6AF206F7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com 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 44DAA6ED11; Fri, 25 Sep 2020 14:55:44 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ej1-x641.google.com (mail-ej1-x641.google.com [IPv6:2a00:1450:4864:20::641]) by gabe.freedesktop.org (Postfix) with ESMTPS id 508AA6ED19 for ; Fri, 25 Sep 2020 14:55:43 +0000 (UTC) Received: by mail-ej1-x641.google.com with SMTP id r7so3993247ejs.11 for ; Fri, 25 Sep 2020 07:55:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=RutlKtRpt9bk66pnLU8lxpgIYD/UbI40WUX9sv8pWns=; b=RzhC6wA0ggFbV2knXHtPkjmdo+pTzvSSFMcX7WtJ4v+fcGwMkpvtySYqT5Mvxr3eP1 TNrJHHh55btiqU4q8ELI0+FVefHvFh70DJ0+Dg0kJcXqcbMIPL7Frj7zNE6wlIHrcozN mhdVGeeHXdEqnF10zGK4D8IqcaL1dNmQ23VE9xuV8zIh5yZliyeD2JQXUHd35JNCCMtw BsJQS7bP9RAuVOZtIxuMjFedQmZobAGpzZnIwdwCTmpBiu+Wj6gUhhZkvWXUatKppH4P w7qRSrSb/ugaMK89Fd2O0nTbbtGBTSqU+MQ55P+Lq7YKF92xkgv5el7jji7DKPNWMApa B5gQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=RutlKtRpt9bk66pnLU8lxpgIYD/UbI40WUX9sv8pWns=; b=h7Z8ZVi3KB1yD1l/9n/1vV/IbPyDHNgzPu9nKSLUaOXOEJj35dvkOZDTin6QkGZ1mt mvRZ/6mYdtJI8jjrnGLqehWlIOZNcyvr/ns0HDIQnE/yFWcCQbO3ocGEI+i5Cc3DpTZp ONruTPKcDmNm3L420NCxZC3r1Wvks7ewjai1A6BZYBLT5AdeFnbZr3BVet9Vx/573z/Z rDldCXGI8DdjRaebzQdlzFITU1E1uxGFPBuhcc/yl73lY5b7IiWoj6Rns8Fz00AB+B2m hifgWjx47e9+Q9mWuA0PsOvy7s/qZNnbNwX2Ks5mNFd+tbmSYeNcfum7GB5Nkh44HupD +4Gw== X-Gm-Message-State: AOAM532RY5FAnK1Sg88qKx6NHSXfQ0ifynJki415RFyDnRBA9yS3gkSI IYzSytD6NGwsTIaH5AdJd/0wX0eEVww= X-Google-Smtp-Source: ABdhPJx0urppDAWkRmaf0XOK2xK5D6Zcpn05F94lE3ulVwiWCgUQ9PM+An+rJjMi3auKmA1Yv7O6wQ== X-Received: by 2002:a17:906:b784:: with SMTP id dt4mr3295119ejb.376.1601045741724; Fri, 25 Sep 2020 07:55:41 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:c75e:403f:87d4:6d00]) by smtp.gmail.com with ESMTPSA id lo25sm2029990ejb.53.2020.09.25.07.55.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Sep 2020 07:55:41 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: dri-devel@lists.freedesktop.org, ray.huang@amd.com, airlied@redhat.com Subject: [PATCH 1/5] drm/ttm: move SG flag check into ttm_bo_vm_reserve Date: Fri, 25 Sep 2020 16:55:36 +0200 Message-Id: <20200925145540.1214-1-christian.koenig@amd.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Just check earlier if a BO can be page faulted in the first place. Signed-off-by: Christian König Reviewed-by: Dave Airlie --- drivers/gpu/drm/ttm/ttm_bo_vm.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c index 98a006fc30a5..991ef132e108 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c @@ -157,6 +157,15 @@ vm_fault_t ttm_bo_vm_reserve(struct ttm_buffer_object *bo, return VM_FAULT_NOPAGE; } + /* + * Refuse to fault imported pages. This should be handled + * (if at all) by redirecting mmap to the exporter. + */ + if (bo->ttm && (bo->ttm->page_flags & TTM_PAGE_FLAG_SG)) { + dma_resv_unlock(bo->base.resv); + return VM_FAULT_SIGBUS; + } + return 0; } EXPORT_SYMBOL(ttm_bo_vm_reserve); @@ -281,13 +290,6 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf, vm_fault_t ret = VM_FAULT_NOPAGE; unsigned long address = vmf->address; - /* - * Refuse to fault imported pages. This should be handled - * (if at all) by redirecting mmap to the exporter. - */ - if (bo->ttm && (bo->ttm->page_flags & TTM_PAGE_FLAG_SG)) - return VM_FAULT_SIGBUS; - if (bdev->driver->fault_reserve_notify) { struct dma_fence *moving = dma_fence_get(bo->moving);