From patchwork Wed Sep 26 16:18:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Hellstrom X-Patchwork-Id: 10616135 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4A25A913 for ; Wed, 26 Sep 2018 16:19:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E8D72B3D3 for ; Wed, 26 Sep 2018 16:19:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 325EE2B3D9; Wed, 26 Sep 2018 16:19:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BDEA22B3D8 for ; Wed, 26 Sep 2018 16:19:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 225B76E497; Wed, 26 Sep 2018 16:19:11 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM04-BN3-obe.outbound.protection.outlook.com (mail-bn3nam04on061c.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe4e::61c]) by gabe.freedesktop.org (Postfix) with ESMTPS id 99A5789C88 for ; Wed, 26 Sep 2018 16:19:09 +0000 (UTC) Received: from localhost.localdomain (155.4.205.56) by DM6PR05MB4588.namprd05.prod.outlook.com (2603:10b6:5:9f::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1185.14; Wed, 26 Sep 2018 16:19:06 +0000 From: Thomas Hellstrom To: dri-devel@lists.freedesktop.org Subject: [PATCH -next 02/18] drm/vmwgfx: Modify the resource validation interface Date: Wed, 26 Sep 2018 18:18:23 +0200 Message-Id: <20180926161839.4549-2-thellstrom@vmware.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180926161839.4549-1-thellstrom@vmware.com> References: <20180926161839.4549-1-thellstrom@vmware.com> MIME-Version: 1.0 X-Originating-IP: [155.4.205.56] X-ClientProxiedBy: VI1PR0601CA0020.eurprd06.prod.outlook.com (2603:10a6:800:1e::30) To DM6PR05MB4588.namprd05.prod.outlook.com (2603:10b6:5:9f::25) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cbd986db-069d-4d99-df7f-08d623cbc8c6 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:DM6PR05MB4588; X-Microsoft-Exchange-Diagnostics: 1; DM6PR05MB4588; 3:gGdMwdKmJrFUOY+CZGy8FySdJZgHG7YVjuGh8XVUT7ejQm8GTzw1M40Lo41zusWa/unREsWXJx5EQRMDxVRFUS2qsrE7VW2+y/wvUtNdLF5GABkVRW6lhY3mIsqzHenli1ub0s1dlpRTwQ0Qq9QgNszOxJULMTIPbAFfJVOtmJKmAQBPkTNQpLb4QKJfV1PDodOYOiJXfLpVS9bsyMCPBJbWihRFjiJf7vTCBJMMxhEQ5soL8c4PPn3Pd4ShOLQ5; 25:yo7CIvmLAOrxrAFZe12imeToaeE3Q5yjaFBQs7GpZcdm/pdmpjwOQEopHvRI22sd67nifQtO+edVgB0NtLbswoYYFEziKy5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LXWKl1yj2UB7nM1BsTlHo9pSAqnevnLFqwp8I9zE/Fc4zD3VMfyGv5pAYGNr+vFcP76SkDDTBweDJ6IADBHkuQroBXVzprTGrh0=; 4:xuHuoTaYDaItkmSYmnSxNAlkzNVFUCyTX8fA9gACoOROhCxDl/cO7CS04WNj9E9aoasc+XzEv8gWozGKEQEUFzFTmXxgu81HBosGgIxqf3k5VuOkt2ZCG8XFDLHvTQ/1ugJTgcxI+SnEX/Q24T4uHwL61Rwe+nUN9n4gppvnKi08r6LwGABvyAq0jdAldFCAGQVJwBazusapsjMTe6Ngg3YDtOpzvGWRFaSv+0njwUZ/IqQMd6vEzXUQrd1x8YkoOgO43hSGMSKhEBWFFVqxHKjVlu0AFaJBBz5TeSJs1E8D8TeSw8MFK3vBVSaumoTS X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(61668805478150); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3231355)(944501410)(52105095)(3002001)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123558120)(20161123560045)(20161123562045)(201708071742011)(7699051)(76991041); SRVR:DM6PR05MB4588; BCL:0; PCL:0; RULEID:; SRVR:DM6PR05MB4588; X-Forefront-PRVS: 08076ABC99 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(346002)(376002)(366004)(396003)(136003)(39860400002)(199004)(189003)(11346002)(186003)(105586002)(36756003)(47776003)(26005)(66066001)(6512007)(2351001)(305945005)(14444005)(446003)(2361001)(486006)(16526019)(106356001)(7736002)(5660300001)(476003)(6666003)(53936002)(86362001)(6486002)(575784001)(97736004)(69590400006)(478600001)(68736007)(50466002)(25786009)(8936002)(316002)(16586007)(48376002)(956004)(2616005)(386003)(76176011)(6506007)(3846002)(6916009)(51416003)(1076002)(4326008)(8676002)(81166006)(50226002)(6116002)(107886003)(2906002)(81156014)(52116002)(34290500001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR05MB4588; H:localhost.localdomain; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: vmware.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM6PR05MB4588; 23:3njfqfua46fBD75Wg4XpXzs3wwetHPAKvG0ZmVdyG?= W2C1BFFrdkPmaEhK8e7adtdHqWWFCUUd2WzZ5hkXwKadE01NuxjS6X6nMc75DjyChadmxASgDawcSkdrUfzql0F2O9bsz/OPVLwimKa2PPebLbDxZEmSb0yY8FS2xOk2WjKpnnRqhi6KaTfeeuGt5FY8zmXlpIMx+7CWxId3/lgP2t1IbJEqOvdHfaloHZez+SxAgPom/4CHFJm4Ho9KbPULrMQbbxFVbKVzZYNmaoXj0ZZZUSS4RkmsTilHoffW15Y2KVuSZggqd4dVXK3PjO1fP7RubyfZ7RBmG6k5d70SVAiQyjH1ZX/j1kSSTKGXA65Epzlnfi8y9Eh/lh5BsxERyV0Q0IegUhlL5HUDw6cM0nhOlFPo3Z2Rx3xZ/gHUJiFsBRF0rOyD0Wnw2VP6mn8CzzPXyxBLmA6hSibfA4pdD6vQ5CnnyZ5pt9QzN5it+Qya9Bs2hJnd7JN8Rd2/Eym4kpetoDZtt392btf3aO+XQuWu8UdT73V2dNjoG1nMFiYO7dDHltRs9kXPj6LAovQxpCV6XfPwzkDlOyT5I1bNwIm+fA11rISEGbHM4S12UO6cQE715fOxPkB5s4bDxSqb7TGIiERQPVbHRDVRiJyjZS/YF32QumVGEfPy2KASLRUoT2pe89+0Av+0tNfacC/6WCwYPDCvyQilYPddy4paowKcKvqcnuE/RmunWxGnmoNQSnnNLUlf0vjT54fV9KZko7FpfiVe/x4c3tp1VBkiWX8iyooxgMMTRQTkUDTADZqV5W2ZpUGxx4Po2aCfNBBxL5wcBTWnCT0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gm0QOv5yJC6KhawvGYaPVYzSWaY3du4hIJVd+jQxhNJqHVIGmmWiFX75mFolYiQBO3Y/FfCqVp39b32mTLAnvaZBZjx7dxNUA6o0sHtr1bNHt3iSDgz2zmBWCtXbewZb4705zrZwXek99/HX8pUX80lplyVmANzpf5+ZSRpftFztB7nmv9+OACvsOANxBsb4ml82eSBPSFNa7MU2j0zAIu8Z2HDQ/EofLMV9aCfRTWmKqouV6AaxNNN0wVIlQYyeFOEUhQdySLVZZe036jtSC561GxfgphL1YpCp+548lmapki2jtTo3XAMrTFEmQM++0uxaSA==; 5:A/vWlD/hNsRU63BNJZXEYVqYm3KWEXejfRUaKAINSs53Gnvb9+fjDkexjS1sw7Ukz5aYrG3tuYwgg5rGtvupvQWv8OtI0PIxh8vaLj8zd62z2kspWwx1OiB4M6Scbs2wOdFdRVVD2TWJ2FLsNATbdoRwpILceqUKFdlFGEgTZRs=; 7:rOPRlNfRXd+rue5dbCt/v3CgJVbY4pEbHRBuTFR3LcqwyAwYs4UMWHEJeyVJUh7UDIAIsn5NE0NQtwuWAD8XL8SKoCuW+yRxldVk9PZnudCVlCk6l7o5DCMmAyGOnJ7uRGW1erCg0T1nCn+wGQl74AqOVdea7RAjUs2VVLCKiElxbgr81C4PC4xxfq4MjTftJk08KRkesOiOlSPje/CZfimTbb3XJrOWrKkFQr8U/ChL08YGFhdbe8T0PpVedz4L SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM6PR05MB4588; 20:UA8FsL+QAB3IChMdwMyKsMRzCJjkFHQ6OXQepZpwIK0wyksVmtwZqnuon8hAEaVV1ApLUBzN7NzyfYXdutWGyNGSvTl6qsNIj1ouizoWKzqEi5I5TP3LdKczO+HKtrBDZ871LDRsFLN7KUWbUicKDtDYkACZOGfhmvMHXpK/qQg= X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2018 16:19:06.4937 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cbd986db-069d-4d99-df7f-08d623cbc8c6 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR05MB4588 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 , linux-graphics-maintainer@vmware.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Allow selecting interruptible or uninterruptible waits to match expectations of callers. Signed-off-by: Thomas Hellstrom Reviewed-by: Deepak Rawat Reviewed-by: Sinclair Yeh --- drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 13 ++++++++----- drivers/gpu/drm/vmwgfx/vmwgfx_validation.c | 2 +- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h index 1abe21758b0d..f1a5de351d80 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h @@ -628,7 +628,7 @@ extern void vmw_resource_unreference(struct vmw_resource **p_res); extern struct vmw_resource *vmw_resource_reference(struct vmw_resource *res); extern struct vmw_resource * vmw_resource_reference_unless_doomed(struct vmw_resource *res); -extern int vmw_resource_validate(struct vmw_resource *res); +extern int vmw_resource_validate(struct vmw_resource *res, bool intr); extern int vmw_resource_reserve(struct vmw_resource *res, bool interruptible, bool no_backup); extern bool vmw_resource_needs_backup(const struct vmw_resource *res); diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c index 1f134570b759..cfc87313a431 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c @@ -659,7 +659,7 @@ static int vmw_resources_validate(struct vmw_sw_context *sw_context) struct vmw_resource *res = val->res; struct vmw_buffer_object *backup = res->backup; - ret = vmw_resource_validate(res); + ret = vmw_resource_validate(res, true); if (unlikely(ret != 0)) { if (ret != -ERESTARTSYS) DRM_ERROR("Failed to validate resource.\n"); diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c index 0c25bb8faf80..e5659bf28ee1 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c @@ -2713,7 +2713,7 @@ int vmw_kms_helper_resource_prepare(struct vmw_resource *res, ctx->buf = vmw_bo_reference(res->backup); } - ret = vmw_resource_validate(res); + ret = vmw_resource_validate(res, interruptible); if (ret) goto out_revert; return 0; diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c index 92003ea5a219..315b3d60567d 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c @@ -587,15 +587,18 @@ static int vmw_resource_do_evict(struct ww_acquire_ctx *ticket, /** * vmw_resource_validate - Make a resource up-to-date and visible * to the device. - * - * @res: The resource to make visible to the device. + * @res: The resource to make visible to the device. + * @intr: Perform waits interruptible if possible. * * On succesful return, any backup DMA buffer pointed to by @res->backup will * be reserved and validated. * On hardware resource shortage, this function will repeatedly evict * resources of the same type until the validation succeeds. + * + * Return: Zero on success, -ERESTARTSYS if interrupted, negative error code + * on failure. */ -int vmw_resource_validate(struct vmw_resource *res) +int vmw_resource_validate(struct vmw_resource *res, bool intr) { int ret; struct vmw_resource *evict_res; @@ -633,7 +636,7 @@ int vmw_resource_validate(struct vmw_resource *res) write_unlock(&dev_priv->resource_lock); /* Trylock backup buffers with a NULL ticket. */ - ret = vmw_resource_do_evict(NULL, evict_res, true); + ret = vmw_resource_do_evict(NULL, evict_res, intr); if (unlikely(ret != 0)) { write_lock(&dev_priv->resource_lock); list_add_tail(&evict_res->lru_head, lru_list); @@ -914,7 +917,7 @@ int vmw_resource_pin(struct vmw_resource *res, bool interruptible) /* Do we really need to pin the MOB as well? */ vmw_bo_pin_reserved(vbo, true); } - ret = vmw_resource_validate(res); + ret = vmw_resource_validate(res, interruptible); if (vbo) ttm_bo_unreserve(&vbo->base); if (ret) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_validation.c b/drivers/gpu/drm/vmwgfx/vmwgfx_validation.c index 5bc00eafe381..dbb58cce0987 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_validation.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_validation.c @@ -479,7 +479,7 @@ int vmw_validation_res_validate(struct vmw_validation_context *ctx, bool intr) struct vmw_resource *res = val->res; struct vmw_buffer_object *backup = res->backup; - ret = vmw_resource_validate(res); + ret = vmw_resource_validate(res, intr); if (ret) { if (ret != -ERESTARTSYS) DRM_ERROR("Failed to validate resource.\n");