From patchwork Thu Apr 11 18:47:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Murphy X-Patchwork-Id: 10896689 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 DD6001515 for ; Thu, 11 Apr 2019 18:50:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C2DF028DC7 for ; Thu, 11 Apr 2019 18:50:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B271228DB9; Thu, 11 Apr 2019 18:50:29 +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=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 59C4528DB9 for ; Thu, 11 Apr 2019 18:50:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=n3fv8rhUxuAg0hGhKapv8f0wruZTgAjCCPRtgOuXOxg=; b=UFOWS1J8gOEZYBmCBieNRml3gj wQhCqMCn73xPJRL+0SKzlWov2LTGoMLCzpWQwfB/T89/LYaAgcgvKlA48bW21q/0gR8e5ggpz61Jj b8vRrSbKwz30ZVw9W9Fb1q+I6nIsk062fYjTTaLWQ5PCiPsr3OY/F65kZwzOMWuHCjetKTmqrcXat dZcxRhc0PCqJxpP1IwxR6eHn/AktSqaX0qe/OeNZ5ZzKNBvvKsTnHnFmTZebREjSQ8V0L9IOd6e6B zvTBp36r05BHgIWGd/5OT1g8gAqA/Vkj86RajswA+GooQYeH4E2fE8rOVaXkwCGp37vk5Eocm/owF EciKq1uw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hEemI-000504-0f; Thu, 11 Apr 2019 18:50:26 +0000 Received: from merlin.infradead.org ([205.233.59.134]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hEelP-0002tB-IP for linux-rockchip@bombadil.infradead.org; Thu, 11 Apr 2019 18:49:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=DMnZhta68iAX33CpRchMA+yMZHDHOGcPtQBVqQabrNw=; b=UD8Y6qB7WZHW/zSK2Do43pxGk jkGVNpY+vIMt7FOP07j9nG9BXQMEdIQAfvAQQv4qXHxL6vYnB+EOlLZBctRfBN9mru4BRA478HVjk NpCNGQWjs3uQhGrUs/trArizagA0S15K0ybkwPwHwsYQhdsVIDH5u12rUj6ZGD1VWqRzcvJqqZ5BI 0U2CHdCfCo0N6w6gr0I7othFcDVii9678C4k/ZJgGbyMxeBap/tvD8Yw20RHI1Vb0w2cNGGRSRrjG 2U/WWIl97xP/j3mwaqCRK6qC2JZ4ANdHtjhxPEUdy4NEa/okhR1zP0vm5yV9GzoJBaTyQvfvLi69b yQM08WjPQ==; Received: from mail-ed1-x542.google.com ([2a00:1450:4864:20::542]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hEelN-0003dm-SH for linux-rockchip@lists.infradead.org; Thu, 11 Apr 2019 18:49:30 +0000 Received: by mail-ed1-x542.google.com with SMTP id d13so6148379edr.5 for ; Thu, 11 Apr 2019 11:49:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=googlenew; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DMnZhta68iAX33CpRchMA+yMZHDHOGcPtQBVqQabrNw=; b=KrxWIEikxDdZvLu8UnFVjW0EcG/PU1SormZHDInUdtOAg+J8UeRfz2zXDqrYBYevOn JwyWhZgYwU6QtoPuE0mXZ1Oe5eYGnMUIagbCpUNbdwOBGj5GuTN3H7Op5ODJ3yxVBy4a HJv3vGEEQWldc4EKVLOm7+5le7P2BEiIWuDF1OhwdjSym2xlj9kWG98u6Ge2wHvP8QAZ tWipMQtzFYHT0eFwweBjtWhr2X29dn3Z6GXvM4PStsLb8BJAl2VsSyrgiCcO2JqfpiLQ mZIfb9bKl4Awxr45GpXcPVoobD3hUoYj2Adz7S2v77C2kyg4y/sYDgRpJl/SvI0brDXa u9JQ== 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; bh=DMnZhta68iAX33CpRchMA+yMZHDHOGcPtQBVqQabrNw=; b=pD2t5prMHKxGkgScLOT+OTgLl+mhN1iLZDDv8ln64QnQOPGMzNXbNHCymSzR3oNrE1 nwLrykdW5wbf4lVikn4QLEIwUVDJlvkrXVyYQuZOwMWawU6pRvcD1y0HJgUsi5LwIBp2 nEnelFhxGeWMxiZKP7cdDN4s5tn5luOVpDPg9RSbpRBpP1YponwX+9NI72N1U/KwVobL frYTFCR9F8gvoGgHfvyfuKygt5jvzmpr6kC62JBN6V2LvzwOg9vX6ymsGWtQcECb4+Fv gvzPlSNTWKBUHRGHUiM2lvYF44rpV0HNlW9nrrUg8eDnnk7rjrO0LUIyG9ODQ3qrTA07 Uq9w== X-Gm-Message-State: APjAAAXsw7HSqoEmLHMiYC+WQ/XPBkCwVfVu1yU0pqyWNOLDGm/hA1HK E+rT3HVHkwG7WmjzgYYTLsEGZw== X-Google-Smtp-Source: APXvYqxGXfYCaCRlvVgksxX9b5Eab0yr+jZV0UQmnyepRxSCDJinf+ClgjALBi9ceksiejLlB/1QXw== X-Received: by 2002:a17:906:e285:: with SMTP id gg5mr27392064ejb.229.1555008568161; Thu, 11 Apr 2019 11:49:28 -0700 (PDT) Received: from localhost.localdomain ([80.233.32.123]) by smtp.gmail.com with ESMTPSA id b10sm1285130edi.28.2019.04.11.11.49.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Apr 2019 11:49:27 -0700 (PDT) From: Tom Murphy To: iommu@lists.linux-foundation.org Subject: [PATCH 9/9] iommu/amd: Add allocated domain to global list earlier Date: Thu, 11 Apr 2019 19:47:38 +0100 Message-Id: <20190411184741.27540-10-tmurphy@arista.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190411184741.27540-1-tmurphy@arista.com> References: <20190411184741.27540-1-tmurphy@arista.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190411_144929_987054_90AA081F X-CRM114-Status: GOOD ( 14.72 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Heiko Stuebner , jamessewart@arista.com, Will Deacon , David Brown , Marek Szyprowski , linux-samsung-soc@vger.kernel.org, dima@arista.com, Joerg Roedel , Krzysztof Kozlowski , linux-rockchip@lists.infradead.org, Kukjin Kim , Andy Gross , Marc Zyngier , linux-arm-msm@vger.kernel.org, linux-mediatek@lists.infradead.org, Matthias Brugger , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, Tom Murphy , linux-kernel@vger.kernel.org, murphyt7@tcd.ie, Rob Clark , Robin Murphy MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP dma_ops_domain_free() expects domain to be in a global list. Arguably, could be called before protection_domain_init(). Signed-off-by: Dmitry Safonov Signed-off-by: Tom Murphy --- drivers/iommu/amd_iommu.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index 02b351834a3b..bfb021d656aa 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c @@ -1801,8 +1801,12 @@ static struct protection_domain *dma_ops_domain_alloc(void) if (!domain) return NULL; - if (protection_domain_init(domain)) - goto free_domain; + if (protection_domain_init(domain)) { + kfree(domain); + return NULL; + } + + add_domain_to_list(domain); domain->mode = PAGE_MODE_3_LEVEL; domain->pt_root = (void *)get_zeroed_page(GFP_KERNEL); @@ -1824,8 +1828,6 @@ static struct protection_domain *dma_ops_domain_alloc(void) /* Initialize reserved ranges */ iommu_dma_copy_reserved_iova(&reserved_iova_ranges, &domain->domain); - add_domain_to_list(domain); - return domain; free_cookie: