Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1120824ybg; Thu, 4 Jun 2020 01:18:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFoEEFoL7Yk45lGQ1POB+zl4/IBPMlzlk1HEp15KRiTRchjZWfL0sIDhuwHjPehR8OZJVZ X-Received: by 2002:a05:6402:6c6:: with SMTP id n6mr3055207edy.277.1591258723120; Thu, 04 Jun 2020 01:18:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591258723; cv=none; d=google.com; s=arc-20160816; b=IkHOB5X8+yatoYhsbAyFN1M/M2BZglliFwIDEZwG7nCqKoYv1OLlcwm8TJAAIx5DEf YrLU6ujXyOHRoz/3MdmqAZJQ/pAmct0E2Y8ce2VzTgYD2sXM3Q8Hq0w6xW0dv91w2OrK f//laAcfovjCT8vJmxxovaTg7VGJlwssCO9EcHp4VhN6oWE4BY6MIKMDPqhee/KWZC20 Vj/v9SpCgr9h9hZRB7xnXqNfX64uiKtyy9SFd1wLZRg2D58uzc/Dglb2X3UlddhKjwqb WnIIrIj+B/qxglGUBvgIH1AiK3ea0Aoi/VjaCZ1EAkZzgusLq2L28D+T8Y06LsVH5Ch+ Pr+g== 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=JO6albsu9ail3aAxe1jjEWcSoPjULvK53jZ9O0zdFWo=; b=Dd1ruLJtOUZDgJjnQFFbjFCKj16muXd7IBt8hYt8rBCNAgC6YGYyBk9Jj+4COE4Nqs ld/XxAXHck2GRaZQlANsOUCo3Rcek3fN4+z6bVGwkKcP5EFFYB/HVa3Q5VWHiboQdOs5 XVi2Y42d8JyULhD4LjWWv61JfabeunjQbguJPpk4Fmuy6/dMSVEnkWZn/I+WUSLrggmP lMApu3qwDd6uTI8uzaxpWGyW0Hsa/sCEgHnyzF1mr+XmXzlTwmiZnIsOmM7GmOEbF1DO yJgyMp/4IShC6YHkR0RP5/nDLgHYj4xC1nVXF5eW6dKwHbQzUHV5Ro3qVxqmuolEb/qX K1bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=lnZAfT6Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w23si1378635edl.586.2020.06.04.01.18.20; Thu, 04 Jun 2020 01:18:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=lnZAfT6Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727021AbgFDINo (ORCPT + 99 others); Thu, 4 Jun 2020 04:13:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727110AbgFDIMq (ORCPT ); Thu, 4 Jun 2020 04:12:46 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2739CC03E96D for ; Thu, 4 Jun 2020 01:12:46 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id c71so4284158wmd.5 for ; Thu, 04 Jun 2020 01:12:46 -0700 (PDT) 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=JO6albsu9ail3aAxe1jjEWcSoPjULvK53jZ9O0zdFWo=; b=lnZAfT6Yff+IJyU+6wsUrqsOgP2Gj+BMlZtMrYghbDpPPGSv/zoqP2grdoO4AOw05E uLOJb/YvDpIETJrOA8RWtcCTW3/8iagYeIGfCzBgEwAJEkP3SyZ5oE2wCQuq2Ve1iyQR bh1mKlhPqlAZFzfugxhI6xRlys9QcfRU1N110= 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=JO6albsu9ail3aAxe1jjEWcSoPjULvK53jZ9O0zdFWo=; b=kwpCw/PLp+drRtprqjwMJ5U4NdwreekqbYqwZwyL78aWY3B17mN3UwAZjBxhGL/7ks 0qZ4+mACEkTXBx65u1F/bM4uzbzFIwjShHG/inBQ7DzEi3VyrD5Zkf31rWcXGRoRzm7z L3D6tKIpYqCDslJpcHLNtzm8rM6GHIVmPrYvY3ktPS93sUGoUSEhRaQ/2jVa5rnSmziM GS9lNAq0MUqQjxXxRPOfeDMFBhVGGEjPKeQ2fLSJ2fHjeopr8Zn7jTYpSkMsj68bxtuR ZY4UNXqxRNoPSdG4Q4HzNhUVQrBbUqHdWjMc33CoeDpowv4NYNBAArCiTfTU+U/BkJZV /Y/Q== X-Gm-Message-State: AOAM532Q4C8SkyeXkd6Sqq1Jv3YAW7UIldtdMoAT2xA/UXjrEp2qco/9 BSIh3kScU7cWopdlZd2UWBjHqg== X-Received: by 2002:a7b:c385:: with SMTP id s5mr3041559wmj.121.1591258364877; Thu, 04 Jun 2020 01:12:44 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id f11sm6873305wrj.2.2020.06.04.01.12.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2020 01:12:44 -0700 (PDT) From: Daniel Vetter To: DRI Development Cc: Intel Graphics Development , LKML , linux-rdma@vger.kernel.org, amd-gfx@lists.freedesktop.org, Daniel Vetter , linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, Chris Wilson , Maarten Lankhorst , =?UTF-8?q?Christian=20K=C3=B6nig?= , Daniel Vetter Subject: [PATCH 10/18] drm/amdgpu: use dma-fence annotations in cs_submit() Date: Thu, 4 Jun 2020 10:12:16 +0200 Message-Id: <20200604081224.863494-11-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200604081224.863494-1-daniel.vetter@ffwll.ch> References: <20200604081224.863494-1-daniel.vetter@ffwll.ch> 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 This is a bit tricky, since ->notifier_lock is held while calling dma_fence_wait we must ensure that also the read side (i.e. dma_fence_begin_signalling) is on the same side. If we mix this up lockdep complaints, and that's again why we want to have these annotations. A nice side effect of this is that because of the fs_reclaim priming for dma_fence_enable lockdep now automatically checks for us that nothing in here allocates memory, without even running any userptr workloads. Cc: linux-media@vger.kernel.org Cc: linaro-mm-sig@lists.linaro.org Cc: linux-rdma@vger.kernel.org Cc: amd-gfx@lists.freedesktop.org Cc: intel-gfx@lists.freedesktop.org Cc: Chris Wilson Cc: Maarten Lankhorst Cc: Christian König Signed-off-by: Daniel Vetter --- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index a25fb59c127c..e109666aec14 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c @@ -1212,6 +1212,7 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p, struct amdgpu_job *job; uint64_t seq; int r; + bool fence_cookie; job = p->job; p->job = NULL; @@ -1226,6 +1227,8 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p, */ mutex_lock(&p->adev->notifier_lock); + fence_cookie = dma_fence_begin_signalling(); + /* If userptr are invalidated after amdgpu_cs_parser_bos(), return * -EAGAIN, drmIoctl in libdrm will restart the amdgpu_cs_ioctl. */ @@ -1262,12 +1265,14 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p, amdgpu_vm_move_to_lru_tail(p->adev, &fpriv->vm); ttm_eu_fence_buffer_objects(&p->ticket, &p->validated, p->fence); + dma_fence_end_signalling(fence_cookie); mutex_unlock(&p->adev->notifier_lock); return 0; error_abort: drm_sched_job_cleanup(&job->base); + dma_fence_end_signalling(fence_cookie); mutex_unlock(&p->adev->notifier_lock); error_unlock: -- 2.26.2