Received: by 2002:a05:7412:8598:b0:f9:33c2:5753 with SMTP id n24csp328488rdh; Mon, 18 Dec 2023 23:17:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IFCU/ObDTpVjU3DW9GEcFtFlUK7P80usOSNAC07p77PmuUihrEXhPQfiY2nJQkcjkcn+cYz X-Received: by 2002:a05:620a:2402:b0:77f:b3e3:ca09 with SMTP id d2-20020a05620a240200b0077fb3e3ca09mr9270085qkn.58.1702970226625; Mon, 18 Dec 2023 23:17:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702970226; cv=none; d=google.com; s=arc-20160816; b=HPCJkBGosVgEW7vONu+V0X69Su0J/ghkKUAOG+9gR07O3VIfFtkFUTR2Y6ahJFge8+ ILIjVLGRRyC4g5UXgFu7HrWXgjADFSGsM9uZMmgrkFbkHL6DiUPvllap2wEloTx52qFW P+Y9vqqUm45QZ8ED0gGojy0xLpbG2fWd5u6/ClLVNNRcn7bFsm6bSlqgmPaF7QRf4UDJ B73xYpfKYigI6fhU2csJ6dmiw6XTPb/+w+s0rbQR6D+YLPj+r5lxI/MBpmwNXas8uU5o Yxmn7bX78X2nfkOWanYOB/j50defx4KKz9fwCrOAFHPlpnVHaIOHx7/vRTRse2F4RSB/ fU0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id:dkim-signature; bh=ZV5vlYVhKMgAqcPG9zjROTasigicfW/pnnaG1R52Xlk=; fh=dZOScNno4IfFIPI4dectHKgKUkNw4ey/f6vFJ681XZA=; b=TFJvUQv+mw44jBnLuuiTmlen7sgtoOmozKDv2t8RJXD5xcZDeX6LOkeWeX8HwLOfCj VlmMrrnimS4giqZwhGYZ5QEhM7pKBGHyU4UMXTSNkbrr6xDctQNSOVJFaeB2AjSenoYS T0oZ1sf8Rg28f9znqdGTIdi5gCzTpeEg4CgUZKdkD/wtqP4LtE3yp0rlLdL/w4yoe12O WfPWBPfUbhKMjEYwcsQ+5NvQoCekAHTccxVrwWQRjaDNs2Adhkli1fLHF9KNJLZKnblQ FmvBwcpcM1dbBODqF8fnmiqKEx/D5xL/cib9EHcv2eV78RJglDTujtkq7rEuAEXweFyp dkPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mimf+mH9; spf=pass (google.com: domain of linux-kernel+bounces-4791-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4791-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id oq30-20020a05620a611e00b0077fb0be08f7si8760389qkn.199.2023.12.18.23.17.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 23:17:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4791-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mimf+mH9; spf=pass (google.com: domain of linux-kernel+bounces-4791-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4791-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 634E81C232F9 for ; Tue, 19 Dec 2023 07:17:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DE1678F4D; Tue, 19 Dec 2023 07:16:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="mimf+mH9" X-Original-To: linux-kernel@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E26213AD8; Tue, 19 Dec 2023 07:16:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702970216; x=1734506216; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=e1H4euSynEtAK+MQ7n5ddNUb1SBbebH7TmVLRdIdcdM=; b=mimf+mH91DwNBYn62ufbbu9mhs68d6jNXm2VBpVh7TOT8h0FgWHJfaXR M3NfyVWZMogPj/ZRsk3rHMnDpvIf3khbJoJzYY6TWbXqjcQO38fSjhiwC maexaGUvhkSDv8mJtd6T+AjdGX5nymBcrNTjzpWIwXPnGJSixFSRnl+jn 0KUdR+rSyLiMnRj6k7UPf78EDDuL5l3sb//JRMHN3H0ullV2q83ApQDJ1 CG0a5QAfttF5ik111QLHl9AjzkT7PpH+AnEwc1RxoFQkaSoc8w1z/+/Ul ORswsaVIRboZIL3qZx1JDGDit9tLuCdihgbjOdbJTlYwEjSL+OA1+nEC/ w==; X-IronPort-AV: E=McAfee;i="6600,9927,10928"; a="426751052" X-IronPort-AV: E=Sophos;i="6.04,287,1695711600"; d="scan'208";a="426751052" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Dec 2023 23:16:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,287,1695711600"; d="scan'208";a="17500248" Received: from zhaohaif-mobl.ccr.corp.intel.com (HELO [10.93.26.36]) ([10.93.26.36]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Dec 2023 23:16:53 -0800 Message-ID: <2fa95471-e22e-46b7-8f23-f4e6abbbd69b@linux.intel.com> Date: Tue, 19 Dec 2023 15:16:50 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 2/2] iommu/vt-d: don's issue devTLB flush request when device is disconnected To: Baolu Lu , bhelgaas@google.com, dwmw2@infradead.org, will@kernel.org, robin.murphy@arm.com, lukas@wunner.de Cc: linux-pci@vger.kernel.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org References: <20231217114902.3836260-1-haifeng.zhao@linux.intel.com> <20231217114902.3836260-3-haifeng.zhao@linux.intel.com> From: Ethan Zhao In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 12/19/2023 2:57 PM, Baolu Lu wrote: > On 2023/12/19 14:49, Ethan Zhao wrote: >>>> diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c >>>> index 74e8e4c17e81..182eb5df244d 100644 >>>> --- a/drivers/iommu/intel/pasid.c >>>> +++ b/drivers/iommu/intel/pasid.c >>>> @@ -476,6 +476,23 @@ devtlb_invalidation_with_pasid(struct >>>> intel_iommu *iommu, >>>>   { >>>>       struct device_domain_info *info; >>>>       u16 sid, qdep, pfsid; >>>> +    struct pci_dev *pdev; >>>> + >>>> +    pdev = to_pci_dev(dev); >>>> +    if (!pdev) >>>> +        return; >>>> + >>>> +    /* >>>> +     * If endpoint device's link was brough down by user's pci >>>> configuration >>>> +     * access to it's hotplug capable slot link control register, >>>> as sequence >>>> +     * response for DLLSC, pciehp_ist() will set the device >>>> error_state to >>>> +     * pci_channel_io_perm_failure. Checking device's state here >>>> to avoid >>>> +     * issuing meaningless devTLB flush request to it, that might >>>> cause lockup >>>> +     * warning or deadlock because too long time waiting in >>>> interrupt context. >>>> +     */ >>>> + >>>> +    if (pci_dev_is_disconnected(pdev)) >>>> +        return; >>>>         info = dev_iommu_priv_get(dev); >>>>       if (!info || !info->ats_enabled) >>> >>> It's likely better to check the device status after verifying >>> ats_enabled. How about below change? >>> >>> diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c >>> index 74e8e4c17e81..fa19c6cdfd8b 100644 >>> --- a/drivers/iommu/intel/pasid.c >>> +++ b/drivers/iommu/intel/pasid.c >>> @@ -481,6 +481,9 @@ devtlb_invalidation_with_pasid(struct >>> intel_iommu *iommu, >>>         if (!info || !info->ats_enabled) >>>                 return; >>> >>> +       if (pci_dev_is_disconnected(to_pci_dev(dev))) >> >> I like this kind of simplicity, but rationalist always brings me back >> to the no-error(ugly) >> >> style.  ???? > > The rational is that Intel IOMMU driver only supports PCI ATS. So if > device is marked as ATS supported, then it must be a PCI device. > Therefore, it's safe to convert it to pci_device with to_pci_dev(). Fair engough ! Thanks, Ethan > > If you move this up before ATS checking, then you need to check > dev_is_pci(). > > Best regards, > baolu >