From patchwork Wed Jul 5 16:29:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 784727 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 3x2mbM6dfyz9s71 for ; Thu, 6 Jul 2017 02:31:27 +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="SDlIZQs3"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751703AbdGEQb0 (ORCPT ); Wed, 5 Jul 2017 12:31:26 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:36197 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751696AbdGEQb0 (ORCPT ); Wed, 5 Jul 2017 12:31:26 -0400 Received: by mail-lf0-f68.google.com with SMTP id f28so21434688lfi.3 for ; Wed, 05 Jul 2017 09:31:25 -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=YLFUBJX2TRSuh2EJmnB4PwnfRRsvzvHABk7qztFojpg=; b=SDlIZQs3wA2jpE9hMTfq/89zavcSLQlwIomTJG2CVnNxS9eT8apVZ6+8Bb5PVGL8rr oMJ/J6Kua4f0pVTLapATPgZ1tu6h1Ymo+Am2wy8IXTmXVQKDC0sktZJLqQM3T4i35rjV ntkS9gvFmyxW8lKJ8VmmwKR9l0K71Ca5T/crDICOZgjrxaHaRt4q3KYFQyV95Bmy197j /SoEvFKcAawax9iAYuVegFK+0gyvqIdhxeuPJKPBRk/SoCP+PflNl55wvy3aPmffOVOD zI3D5anjG1uOEKW2RUmOt8G8VNpAUi6Je0xU7DWrcp1XWCX0S74qX+2pP07bZ+Hscj00 P/XA== 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=YLFUBJX2TRSuh2EJmnB4PwnfRRsvzvHABk7qztFojpg=; b=pq0AJPsnQKKjQidhKRk8QHECwTUn6TCmScrJvtgfZVe7zGu/KW5bwI0cW+yyIo8Hsb WJa+PFz0t04DQSeeEGIb16XNqCVbtvHULfVjg6pspI8hCIjRhxaTpAUXhIfCLxLyczC/ VqUIUWQOwujTcamcppt0r+1FX/imfTvZ8EEwCLRHLWysFx2bfiQMMdxQxg25DeHulIeI q4vNK5iZOorsUBc+6GmnDk7u7M3KYGGnR+E6ikh+7/6nNMk7i5aDAqk0bu6BXdXfU5/C 3/fW4KnCLf9NXLyJypooey1qjthb9J2s0uvGzobtg9U6cHvkq/A0m50oVMfXNSDPEMKg hO5A== X-Gm-Message-State: AIVw111NNxkXY+6+kTvD5GS9Rx3N80g8oEj/WsCFVEadiaOs38YsJ0/W 8jw9L4ZK2qJYNA== X-Received: by 10.25.151.137 with SMTP id z131mr5017748lfd.24.1499272284484; Wed, 05 Jul 2017 09:31:24 -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.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Jul 2017 09:31:23 -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 1/4] iommu/tegra: gart: Don't unnecessarily allocate registers context Date: Wed, 5 Jul 2017 19:29:45 +0300 Message-Id: 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 GART looses it's state only in case of a deepest suspend level. Let's not waste memory if machine doesn't support that suspend level. Signed-off-by: Dmitry Osipenko --- drivers/iommu/tegra-gart.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/drivers/iommu/tegra-gart.c b/drivers/iommu/tegra-gart.c index 37e708fdbb5a..1557a6a9a438 100644 --- a/drivers/iommu/tegra-gart.c +++ b/drivers/iommu/tegra-gart.c @@ -31,6 +31,8 @@ #include #include +#include + #include /* bitmap of the page sizes currently supported */ @@ -354,10 +356,13 @@ static int tegra_gart_suspend(struct device *dev) u32 *data = gart->savedata; unsigned long flags; - spin_lock_irqsave(&gart->pte_lock, flags); - for_each_gart_pte(gart, iova) - *(data++) = gart_read_pte(gart, iova); - spin_unlock_irqrestore(&gart->pte_lock, flags); + if (gart->savedata != NULL) { + spin_lock_irqsave(&gart->pte_lock, flags); + for_each_gart_pte(gart, iova) + *(data++) = gart_read_pte(gart, iova); + spin_unlock_irqrestore(&gart->pte_lock, flags); + } + return 0; } @@ -366,9 +371,12 @@ static int tegra_gart_resume(struct device *dev) struct gart_device *gart = dev_get_drvdata(dev); unsigned long flags; - spin_lock_irqsave(&gart->pte_lock, flags); - do_gart_setup(gart, gart->savedata); - spin_unlock_irqrestore(&gart->pte_lock, flags); + if (gart->savedata != NULL) { + spin_lock_irqsave(&gart->pte_lock, flags); + do_gart_setup(gart, gart->savedata); + spin_unlock_irqrestore(&gart->pte_lock, flags); + } + return 0; } @@ -412,10 +420,16 @@ static int tegra_gart_probe(struct platform_device *pdev) gart->iovmm_base = (dma_addr_t)res_remap->start; gart->page_count = (resource_size(res_remap) >> GART_PAGE_SHIFT); - gart->savedata = vmalloc(sizeof(u32) * gart->page_count); - if (!gart->savedata) { - dev_err(dev, "failed to allocate context save area\n"); - return -ENOMEM; + /* + * The registers store/restore is required only in case of a + * deepest sleep state, do not waste memory if it's unnecessary. + */ + if (tegra_pmc_get_suspend_mode() == TEGRA_SUSPEND_LP0) { + gart->savedata = vmalloc(sizeof(u32) * gart->page_count); + if (!gart->savedata) { + dev_err(dev, "failed to allocate context save area\n"); + return -ENOMEM; + } } platform_set_drvdata(pdev, gart);