From patchwork Mon Oct 21 11:15:22 2019 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: 11202881 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 D777813B1 for ; Mon, 21 Oct 2019 18:51:44 +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 BFB5E2086D for ; Mon, 21 Oct 2019 18:51:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BFB5E2086D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AA9606E207; Mon, 21 Oct 2019 18:51:41 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by gabe.freedesktop.org (Postfix) with ESMTPS id 28A1E88FCF; Mon, 21 Oct 2019 11:15:30 +0000 (UTC) Received: by mail-wm1-x341.google.com with SMTP id v3so1442295wmh.1; Mon, 21 Oct 2019 04:15:30 -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:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7c5Qzq9KoeAeHZDAZpUJnWCjxxzWTWUy42GlQzoDXV0=; b=ZXRbcThPtQ1P23TsfOsyDwNM+1MDeZ5v2MxtE9RW8N3/cQ1xXY/AavIyW0EasiDOeZ CZL1NnAgxHnwy9y46V4ZgPTHd0dm4Ga2px+V1cTvJ5HeJCR6Kb51tEM6QAT57uYnhmFV YpPLQt0Fkxq2D8gpBr0L46/aMpZhdJxHsv8EUdAoy9pTPYYwVf2k0xsd92Vpxh7OgVw2 ZKR7YJoS+uudhJAsQN/C8pIK7ax3KvHSnhWkr8PzNdF4wjJFPIzIibGcQLQfEjOISg0N f9kTIM4M5Lz9E2Ai1KR5LeAQcrIJ3e+UoZuLT7rmc6V+T+Plp6USb9GtA7AvSQ36EuwS eihw== X-Gm-Message-State: APjAAAVPWkwh+V3PMaMvxlyHLGmL17I7OJm/6v/MxXEAQBL4SqZOEjT9 6e8s+hYPbOc4SjinABQvyo71Mz2L X-Google-Smtp-Source: APXvYqxW81KRS6pTbAx1n00iEXUv6tQFsMzKCBICUSmt+H08oQcDhMvCeGT/1W/4ZZq6o1rbXHhWtQ== X-Received: by 2002:a1c:e912:: with SMTP id q18mr19108187wmc.29.1571656528599; Mon, 21 Oct 2019 04:15:28 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:c194:dd41:4bef:70cc]) by smtp.gmail.com with ESMTPSA id l9sm13152415wme.45.2019.10.21.04.15.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 04:15:28 -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, sumit.semwal@linaro.org, linaro-mm-sig@lists.linaro.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org, daniel@ffwll.ch Date: Mon, 21 Oct 2019 13:15:22 +0200 Message-Id: <20191021111524.14793-2-christian.koenig@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191021111524.14793-1-christian.koenig@amd.com> References: <20191021111524.14793-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 21 Oct 2019 18:51:32 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=7c5Qzq9KoeAeHZDAZpUJnWCjxxzWTWUy42GlQzoDXV0=; b=HSOPmb5Mmgc4EWngj+Xfe3rtVV7heQZosok7UrRHMB33Pd7lRsZqElsgybATdAb1Di 6rzbSIh81Xiz0aLQSg6daozUrYKexTTIXpBjFfJKtyEnwJ1ybuVQE/GirIvb1SlWe89+ dkFS8MMOG4DtJGguTymO7Ewcl/PI60apRJIEkohJp3OkEpLrbhbuPyoIHH1snw+etvPV HWdyu0LyGdOOIYBPHpNbRIf/+eS9aFU71au4MVPyk/mmm8fJuiFHq6ETd960GQGYDWzV nc0o+6UTIDgbo/iIyijmnRyNwdJk7syJ2cJouwk2yf7W/9PoXxDYZi5nFapyHQPIevcQ 6Evw== Subject: [Intel-gfx] [PATCH 2/4] dma-buf: stop using the dmabuf->lock so much X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" The attachment list is now protected by the dma_resv object. So we can drop holding this lock to allow concurrent attach and detach operations. Signed-off-by: Christian König Reviewed-by: Daniel Vetter --- drivers/dma-buf/dma-buf.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index 753be84b5fd6..c736e67ae1a1 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -685,8 +685,6 @@ dma_buf_dynamic_attach(struct dma_buf *dmabuf, struct device *dev, attach->dmabuf = dmabuf; attach->dynamic_mapping = dynamic_mapping; - mutex_lock(&dmabuf->lock); - if (dmabuf->ops->attach) { ret = dmabuf->ops->attach(dmabuf, attach); if (ret) @@ -696,8 +694,6 @@ dma_buf_dynamic_attach(struct dma_buf *dmabuf, struct device *dev, list_add(&attach->node, &dmabuf->attachments); dma_resv_unlock(dmabuf->resv); - mutex_unlock(&dmabuf->lock); - /* When either the importer or the exporter can't handle dynamic * mappings we cache the mapping here to avoid issues with the * reservation object lock. @@ -726,7 +722,6 @@ dma_buf_dynamic_attach(struct dma_buf *dmabuf, struct device *dev, err_attach: kfree(attach); - mutex_unlock(&dmabuf->lock); return ERR_PTR(ret); err_unlock: @@ -776,14 +771,12 @@ void dma_buf_detach(struct dma_buf *dmabuf, struct dma_buf_attachment *attach) dma_resv_unlock(attach->dmabuf->resv); } - mutex_lock(&dmabuf->lock); dma_resv_lock(dmabuf->resv, NULL); list_del(&attach->node); dma_resv_unlock(dmabuf->resv); if (dmabuf->ops->detach) dmabuf->ops->detach(dmabuf, attach); - mutex_unlock(&dmabuf->lock); kfree(attach); } EXPORT_SYMBOL_GPL(dma_buf_detach); @@ -1247,14 +1240,6 @@ static int dma_buf_debug_show(struct seq_file *s, void *unused) "size", "flags", "mode", "count", "ino"); list_for_each_entry(buf_obj, &db_list.head, list_node) { - ret = mutex_lock_interruptible(&buf_obj->lock); - - if (ret) { - seq_puts(s, - "\tERROR locking buffer object: skipping\n"); - continue; - } - seq_printf(s, "%08zu\t%08x\t%08x\t%08ld\t%s\t%08lu\t%s\n", buf_obj->size, buf_obj->file->f_flags, buf_obj->file->f_mode, @@ -1307,7 +1292,6 @@ static int dma_buf_debug_show(struct seq_file *s, void *unused) count++; size += buf_obj->size; - mutex_unlock(&buf_obj->lock); } seq_printf(s, "\nTotal %d objects, %zu bytes\n", count, size);