From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 97849C433F5 for ; Sat, 14 May 2022 01:46:51 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 3A4D740528; Sat, 14 May 2022 01:46:51 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id n_S8lk2CjMdm; Sat, 14 May 2022 01:46:50 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id 114B6404AA; Sat, 14 May 2022 01:46:50 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id DF76DC0032; Sat, 14 May 2022 01:46:49 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id CF801C002D for ; Sat, 14 May 2022 01:46:48 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id BEAF740516 for ; Sat, 14 May 2022 01:46:48 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wOknp830gVUv for ; Sat, 14 May 2022 01:46:48 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by smtp2.osuosl.org (Postfix) with ESMTPS id 1C98F400AF for ; Sat, 14 May 2022 01:46:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652492808; x=1684028808; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wuco7zHOI8upW/toCZeZhBQ9k0tR0YA88Idt0JHdMVY=; b=IIwU5FlVnhNz4eFXN8RsTJTpGLfn1hfe0AIUQHCFxqgoyNjGHqrZcHNY ZC7OrGh4CuqtZN4hbM1X4G7/DgmO/pkoXpAZgFoB7O5IR5we7pucVDJQt aBwVFGHTb/Oupe09BSmRAjhrxLbpXf0v+x13v4+3I/mkHh1GzzkLTmJGS 7NBOqnCVUcoH2NSh4zfTLlynuZ28w9HkzmCDl2VdX+uBKhfBt6myoFaWM dc5W5d2aowg5JjyFGN9AMJK5fRORYqo6CPj74AVYwVAGSKqTDXnNY+OA8 hZhul/UxDx/q2nt0hinxKc5fAoaT9XFzH8xUDMclSE1r9WkhLofXEdu1w g==; X-IronPort-AV: E=McAfee;i="6400,9594,10346"; a="270388000" X-IronPort-AV: E=Sophos;i="5.91,223,1647327600"; d="scan'208";a="270388000" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2022 18:46:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,223,1647327600"; d="scan'208";a="712630780" Received: from allen-box.sh.intel.com ([10.239.159.48]) by fmsmga001.fm.intel.com with ESMTP; 13 May 2022 18:46:42 -0700 From: Lu Baolu To: Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Paolo Bonzini , David Airlie , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , Daniel Vetter , Kevin Tian , Ashok Raj , Liu Yi L , Jacob Pan , Ning Sun Subject: [PATCH 2/7] agp/intel: Use per device iommu check Date: Sat, 14 May 2022 09:43:17 +0800 Message-Id: <20220514014322.2927339-3-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220514014322.2927339-1-baolu.lu@linux.intel.com> References: <20220514014322.2927339-1-baolu.lu@linux.intel.com> MIME-Version: 1.0 Cc: Steve Wahl , Will Deacon , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, Jason Gunthorpe , Robin Murphy , Christoph Hellwig X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" The IOMMU subsystem has already provided an interface to query whether the IOMMU hardware is enabled for a specific device. This changes the check from Intel specific intel_iommu_gfx_mapped (globally exported by the Intel IOMMU driver) to probing the presence of IOMMU on a specific device using the generic device_iommu_mapped(). This follows commit cca084692394a ("drm/i915: Use per device iommu check") which converted drm/i915 driver to use device_iommu_mapped(). Signed-off-by: Lu Baolu --- drivers/char/agp/intel-gtt.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c index 79a1b65527c2..cfcb450e9b59 100644 --- a/drivers/char/agp/intel-gtt.c +++ b/drivers/char/agp/intel-gtt.c @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include "agp.h" @@ -573,18 +573,15 @@ static void intel_gtt_cleanup(void) */ static inline int needs_ilk_vtd_wa(void) { -#ifdef CONFIG_INTEL_IOMMU const unsigned short gpu_devid = intel_private.pcidev->device; - /* Query intel_iommu to see if we need the workaround. Presumably that - * was loaded first. + /* + * Query iommu subsystem to see if we need the workaround. Presumably + * that was loaded first. */ - if ((gpu_devid == PCI_DEVICE_ID_INTEL_IRONLAKE_D_IG || - gpu_devid == PCI_DEVICE_ID_INTEL_IRONLAKE_M_IG) && - intel_iommu_gfx_mapped) - return 1; -#endif - return 0; + return ((gpu_devid == PCI_DEVICE_ID_INTEL_IRONLAKE_D_IG || + gpu_devid == PCI_DEVICE_ID_INTEL_IRONLAKE_M_IG) && + device_iommu_mapped(&intel_private.pcidev->dev)); } static bool intel_gtt_can_wc(void) -- 2.25.1 _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA267C433FE for ; Sat, 14 May 2022 02:59:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230375AbiENC7A (ORCPT ); Fri, 13 May 2022 22:59:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231226AbiENC6C (ORCPT ); Fri, 13 May 2022 22:58:02 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D88DC199492 for ; Fri, 13 May 2022 18:46:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652492807; x=1684028807; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wuco7zHOI8upW/toCZeZhBQ9k0tR0YA88Idt0JHdMVY=; b=LvVuezdvRNL14aeBxlRTemOXZfCJemHdEPDGreXaBwBWCGBEM3J3uEnp mBmSidITX+nPmpD8HkXbbqD9dCY0XfZ/s/lXDE9M5D8oP7JFaWkDxOyEf lFy69cp1j9d6K4pBiQJ34nopQVyDcX1Np+uC/wMupQmMbAqdjVXl24PiD UyXy95N7K8Wa4/fm25Av+LEdP4YO8/yAImJDZcv7rgPUiwKLEAUOwam1k GGEA03ZQkzs3PKCO/tAhcViAiF3hiBRaDaRMKEGxx2ygw4Ew2cwGD3+UP zK+/hu7TuiqWEiFs+B51j1nygiqL3ptX9wzI3pDgO/J+9sJkZUNxdlGq1 A==; X-IronPort-AV: E=McAfee;i="6400,9594,10346"; a="270581939" X-IronPort-AV: E=Sophos;i="5.91,223,1647327600"; d="scan'208";a="270581939" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2022 18:46:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,223,1647327600"; d="scan'208";a="712630780" Received: from allen-box.sh.intel.com ([10.239.159.48]) by fmsmga001.fm.intel.com with ESMTP; 13 May 2022 18:46:42 -0700 From: Lu Baolu To: Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Paolo Bonzini , David Airlie , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , Daniel Vetter , Kevin Tian , Ashok Raj , Liu Yi L , Jacob Pan , Ning Sun Cc: Will Deacon , Robin Murphy , Jason Gunthorpe , Christoph Hellwig , Steve Wahl , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 2/7] agp/intel: Use per device iommu check Date: Sat, 14 May 2022 09:43:17 +0800 Message-Id: <20220514014322.2927339-3-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220514014322.2927339-1-baolu.lu@linux.intel.com> References: <20220514014322.2927339-1-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The IOMMU subsystem has already provided an interface to query whether the IOMMU hardware is enabled for a specific device. This changes the check from Intel specific intel_iommu_gfx_mapped (globally exported by the Intel IOMMU driver) to probing the presence of IOMMU on a specific device using the generic device_iommu_mapped(). This follows commit cca084692394a ("drm/i915: Use per device iommu check") which converted drm/i915 driver to use device_iommu_mapped(). Signed-off-by: Lu Baolu --- drivers/char/agp/intel-gtt.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c index 79a1b65527c2..cfcb450e9b59 100644 --- a/drivers/char/agp/intel-gtt.c +++ b/drivers/char/agp/intel-gtt.c @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include "agp.h" @@ -573,18 +573,15 @@ static void intel_gtt_cleanup(void) */ static inline int needs_ilk_vtd_wa(void) { -#ifdef CONFIG_INTEL_IOMMU const unsigned short gpu_devid = intel_private.pcidev->device; - /* Query intel_iommu to see if we need the workaround. Presumably that - * was loaded first. + /* + * Query iommu subsystem to see if we need the workaround. Presumably + * that was loaded first. */ - if ((gpu_devid == PCI_DEVICE_ID_INTEL_IRONLAKE_D_IG || - gpu_devid == PCI_DEVICE_ID_INTEL_IRONLAKE_M_IG) && - intel_iommu_gfx_mapped) - return 1; -#endif - return 0; + return ((gpu_devid == PCI_DEVICE_ID_INTEL_IRONLAKE_D_IG || + gpu_devid == PCI_DEVICE_ID_INTEL_IRONLAKE_M_IG) && + device_iommu_mapped(&intel_private.pcidev->dev)); } static bool intel_gtt_can_wc(void) -- 2.25.1