Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp878922ybm; Wed, 27 May 2020 10:09:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrkCCxMmLjFJV8EVgZ1BPPv/sJ1CfdWy65ubW3679lRc9qEpmzuAm33agzQDNohE/ZWQ30 X-Received: by 2002:a17:906:f198:: with SMTP id gs24mr6771159ejb.547.1590599347598; Wed, 27 May 2020 10:09:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590599347; cv=none; d=google.com; s=arc-20160816; b=SskPc7GDxxEw4JxfdKSMRH/ftMyxUmu3s3FvZDs2umTjDbdXpy9Xn66fqKI0uUWOzE cfMFDBh37YgkMDc2uffxO3GDABytucq187hE6PdTFiuMiZ5cAm2Sg099NNDJYVfuyQnw nZNI8cPbBsg2oQfsX/Fx9fyyJj+GSdAYilRearBkU5D1aGlUW5Q7x2WMMiDVq7CzOdbe mKGpYO91JQXjfP5syKq2gYG0b1t7xn504fGW6+otgCuvlz96OQnc4fxkgKOhgfbTb8JV EOGAhxLo2MoHe3sgTBun0IkR9DT3DVT32bZNyaUwkAqqEIvfIKgQnFKdw7TQ13AEOxNd 0BkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=43PO/+jxSog77gXfSldxEmt2DngUb4XnI2YNrw/D4u4=; b=o9aK9wgTopkfP7eXo7DR/5F+pvFFNHIi89XWb5vNhPFMFIMAVLKWlnDvk16ukCe16F uccmg24DXABK6wE2df1v0ru+RKYTjOf+v1eYlvtE1b72PssxfJphK5aX8bmlbXAEKWpn oc+dGka0oFHbkugutgZClS3ckonfCkpKHhP3TMdKY75dYB3Koa0QMChnF9Y9iGr2CeGo Nwm5SwYkLbYU1gtDTs2PQUCt1hBw3ofQBadlxTjGHmjFiMoaCmt+r8nvZGYi5LRcUaWz Z7fgZKjkK5FWMFvvXuI0f98d15SL9w4RRtf5orc7khHNaHqx2lgqliLp/JCoQvj5yLId Ri0A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id do5si2893423ejc.105.2020.05.27.10.08.38; Wed, 27 May 2020 10:09:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729098AbgE0Lxj (ORCPT + 99 others); Wed, 27 May 2020 07:53:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728762AbgE0Lx2 (ORCPT ); Wed, 27 May 2020 07:53:28 -0400 Received: from theia.8bytes.org (8bytes.org [IPv6:2a01:238:4383:600:38bc:a715:4b6d:a889]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B0D1C08C5C2 for ; Wed, 27 May 2020 04:53:28 -0700 (PDT) Received: by theia.8bytes.org (Postfix, from userid 1000) id C97624F2; Wed, 27 May 2020 13:53:24 +0200 (CEST) From: Joerg Roedel To: Joerg Roedel Cc: linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, Suravee Suthikulpanit , jroedel@suse.de Subject: [PATCH 10/10] iommu/amd: Remove redundant devid checks Date: Wed, 27 May 2020 13:53:13 +0200 Message-Id: <20200527115313.7426-11-joro@8bytes.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200527115313.7426-1-joro@8bytes.org> References: <20200527115313.7426-1-joro@8bytes.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joerg Roedel Checking the return value of get_device_id() in a code-path which has already done check_device() is not needed, as check_device() does the same check and bails out if it fails. Signed-off-by: Joerg Roedel --- drivers/iommu/amd/iommu.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index 2504aa184837..db149c1a35bf 100644 --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -413,13 +413,8 @@ static void iommu_ignore_device(struct device *dev) static void amd_iommu_uninit_device(struct device *dev) { struct iommu_dev_data *dev_data; - int devid; - - devid = get_device_id(dev); - if (devid < 0) - return; - dev_data = search_dev_data(devid); + dev_data = dev_iommu_priv_get(dev); if (!dev_data) return; @@ -2173,16 +2168,12 @@ static void amd_iommu_probe_finalize(struct device *dev) static void amd_iommu_release_device(struct device *dev) { + int devid = get_device_id(dev); struct amd_iommu *iommu; - int devid; if (!check_device(dev)) return; - devid = get_device_id(dev); - if (devid < 0) - return; - iommu = amd_iommu_rlookup_table[devid]; amd_iommu_uninit_device(dev); -- 2.17.1