From patchwork Wed Jul 5 16:29:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 784729 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3x2mbP2sBxz9s71 for ; Thu, 6 Jul 2017 02:31:29 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="hNVqidmI"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751784AbdGEQb3 (ORCPT ); Wed, 5 Jul 2017 12:31:29 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:32826 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751678AbdGEQb2 (ORCPT ); Wed, 5 Jul 2017 12:31:28 -0400 Received: by mail-lf0-f67.google.com with SMTP id t72so21505600lff.0 for ; Wed, 05 Jul 2017 09:31:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=usdhS2gNxNUPd78QNSbc/gYipresd+dOx08iow+uEi8=; b=hNVqidmIhQ1YZtVQkO0Ej6Tfq2qDtoOWYL3B8g95BbNZhV7T6fHi0P0DO8WdyzUx0A g2zD6Gpre8zD0118pq4okAMy7KrmPBSZQZ6pMnTI81MhL7tpUj1tRfbOvtLvHb2LBv9M fjZL8BcInqKzTXJ244jkmhhJ80X2yAwBkRJtrC1ULzMMV8ciYpwHaWUb52aWuJ1KI5WQ Iai1RImF9U16vfHqhVvQAe/h6pSsSuN5kIE3ykuYK+6Z32846DMo8unqp3HZCr0t3THK Ha9ejBOn6e4CXSrUluo9xQL9VeRhRKF+peS3UaqpRzm0xPMIO4MLKS7ZTiCFY328BXps oCag== 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:in-reply-to:references; bh=usdhS2gNxNUPd78QNSbc/gYipresd+dOx08iow+uEi8=; b=Q4APM6aJWv1PTwhzXr/NqL9JLpjnz8vwA5AYrZ+orSS+66ViE+0fSJ8LwLWnaf16c2 9thaM43CIx+BflMgVnCgrMhXWtSDRzB10cffsyS4pb0886vX2jPkWn6k/BFBFAqCAnrW yMgLkQixixd4Zmdcnno+qz0oaR/QO8LVMHJYr3BT/tWurrgKRqztpNPwQOdNf4877BAU SWXkl0m09MEMYpTzm5S3qAC+ssLLf8h0aUFTG4xCER+Mzwu7/dYN0uFR+5ZpMjXRCGDN kMpRUBUHTLF8zZB7vFfwgqFSE2SRts2+eu89Z2pJxhW4mAN4EjHvr9jKUGAmPw9JPbzh GFXQ== X-Gm-Message-State: AIVw112cfBXnZIt40eXIMD1woO0gEgAINuA5nxhiPzNV2NmTVOsjzGTL infxwe6+yjCd5Q== X-Received: by 10.46.32.157 with SMTP id g29mr7653286lji.27.1499272286891; Wed, 05 Jul 2017 09:31:26 -0700 (PDT) Received: from localhost.localdomain (ppp109-252-91-87.pppoe.spdop.ru. [109.252.91.87]) by smtp.gmail.com with ESMTPSA id x11sm4260108ljd.5.2017.07.05.09.31.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Jul 2017 09:31:26 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Joerg Roedel , Jonathan Hunter Cc: Hiroshi Doyu , linux-tegra@vger.kernel.org, iommu@lists.linux-foundation.org Subject: [PATCH v1 3/4] iommu/tegra: gart: Move PFN validation out of spinlock Date: Wed, 5 Jul 2017 19:29:47 +0300 Message-Id: <301b5e91fae43beae4542e8c4a7d5ca6a6918ba0.1499270277.git.digetx@gmail.com> X-Mailer: git-send-email 2.13.2 In-Reply-To: References: In-Reply-To: References: Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org Validation of page frame number doesn't require protection with a spinlock, let's move it out of spinlock for consistency. Signed-off-by: Dmitry Osipenko Acked-by: Thierry Reding --- drivers/iommu/tegra-gart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/tegra-gart.c b/drivers/iommu/tegra-gart.c index 54699e341110..55fdb56d85ea 100644 --- a/drivers/iommu/tegra-gart.c +++ b/drivers/iommu/tegra-gart.c @@ -276,13 +276,13 @@ static int gart_iommu_map(struct iommu_domain *domain, unsigned long iova, if (!gart_iova_range_valid(gart, iova, bytes)) return -EINVAL; - spin_lock_irqsave(&gart->pte_lock, flags); pfn = __phys_to_pfn(pa); if (!pfn_valid(pfn)) { dev_err(gart->dev, "Invalid page: %pa\n", &pa); - spin_unlock_irqrestore(&gart->pte_lock, flags); return -EINVAL; } + + spin_lock_irqsave(&gart->pte_lock, flags); pte = gart_read_pte(gart, iova); if (pte & GART_ENTRY_PHYS_ADDR_VALID) { spin_unlock_irqrestore(&gart->pte_lock, flags);