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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 6D191C3DA7F for ; Wed, 7 Aug 2024 05:35:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:To:Subject:Cc:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=TapGg62SWvplo+MgQP+GYft2JPusREbOvxBe4FcQFRI=; b=xpc0pyR7KmMtbmEDAWTrfB8uu7 OGc0D5efHBhPdv0c/KUQ0AugJ9OUxrRzlZLe9K1be5CCDBX6NTKD1IpKh+NY7oF5CpLn6P23skgYH n2qvcg6T4STwZ3VSyJRWbOZy+rG27xeycol4LtsRc//oBz1nxbBo+klHRsQm//p7O9rM8J10aQizH xQlZO5MEK286AKW1nRnSsJidqu/vw8tA13u6cI6eL/ZdMZW6Mre6UFE3yf8ySjbxUQOKxnRuvC6JZ hWZL9VoyY3hD4Be9CvSolyKdb9AoDnKovl2baCHC47yjby5oeBhX1dT4N2pf1UZHS6lovYC0PPzj0 T04noJhA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sbZKt-00000003t1k-25oM; Wed, 07 Aug 2024 05:35:47 +0000 Received: from mgamail.intel.com ([192.198.163.8]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sbZKL-00000003snj-2hKq for linux-arm-kernel@lists.infradead.org; Wed, 07 Aug 2024 05:35:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1723008913; x=1754544913; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=hGVnw0pu3bPOom0FlMmVfOfs7KNbrtqDnyGrJinkMHE=; b=QNqSjitCFJA81Ma7I2XbA+3pPcVaSdE+vPov3tDvWqbbpQuyceNaDl0f TfT/dIf6iyuAYZ32iTuVyabMKrvVRQ7RgN/kwwxuSnLq4f8mTTy4jwRH2 0v6D2hqJlwp2/9tdq+ZL74LgEwvWnJyMPv37vSUVspZtHDMaXbSd+tb7s j/fpiHlztoUlO5fzNXu0q0awO8/RfJGZKd/jNF8zgEq9+N5gtQK+PDRv+ JeGdtNhxp77Lz7kEOw0EeOff+7swqTOrbl2bMpxWUF0a54a/EUEpWdksr EGniY0PyCiMtK+ndaAvUGLgohFsSRgdhsa4tmIrsnCeBZDdHT1uBlo0Dy A==; X-CSE-ConnectionGUID: kNnYDp7rQcWOh2D9HTDGng== X-CSE-MsgGUID: N85YgqDYTPOZXqyFIMQnmA== X-IronPort-AV: E=McAfee;i="6700,10204,11156"; a="38567746" X-IronPort-AV: E=Sophos;i="6.09,269,1716274800"; d="scan'208";a="38567746" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Aug 2024 22:35:10 -0700 X-CSE-ConnectionGUID: UHCp/JICRoOljhNN5St32A== X-CSE-MsgGUID: +FbrnZteQeqM/PO8cAPXGQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,269,1716274800"; d="scan'208";a="56956181" Received: from blu2-mobl.ccr.corp.intel.com (HELO [10.125.248.220]) ([10.125.248.220]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Aug 2024 22:35:06 -0700 Message-ID: <315e95d4-064d-4322-a9d3-97e96c013b4d@linux.intel.com> Date: Wed, 7 Aug 2024 13:35:03 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: baolu.lu@linux.intel.com, Will Deacon , Kunkun Jiang , Robin Murphy , Joerg Roedel , Nicolin Chen , Michael Shavit , Mostafa Saleh , "moderated list:ARM SMMU DRIVERS" , iommu@lists.linux.dev, linux-kernel@vger.kernel.org, wanghaibin.wang@huawei.com, yuzenghui@huawei.com, tangnianyao@huawei.com Subject: Re: [bug report] iommu/arm-smmu-v3: Event cannot be printed in some scenarios To: Pranjal Shrivastava , Jason Gunthorpe References: <6147caf0-b9a0-30ca-795e-a1aa502a5c51@huawei.com> <7d5a8b86-6f0d-50ef-1b2f-9907e447c9fc@huawei.com> <20240724102417.GA27376@willie-the-truck> <5e8e6857-44c9-40a1-f86a-b8b5aae65bfb@huawei.com> <20240805123001.GB9326@willie-the-truck> <20240806124943.GF676757@ziepe.ca> Content-Language: en-US From: Baolu Lu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240806_223513_772731_E8B9E284 X-CRM114-Status: GOOD ( 21.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2024/8/6 23:58, Pranjal Shrivastava wrote: > On Tue, Aug 06, 2024 at 09:49:43AM -0300, Jason Gunthorpe wrote: >> On Mon, Aug 05, 2024 at 03:32:50PM +0000, Pranjal Shrivastava wrote: >>> Here's the updated diff: >>> diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c >>> index a31460f9f3d4..ed2b106e02dd 100644 >>> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c >>> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c >>> @@ -1777,7 +1777,7 @@ static int arm_smmu_handle_evt(struct arm_smmu_device *smmu, u64 *evt) >>> goto out_unlock; >>> } >>> >>> - iommu_report_device_fault(master->dev, &fault_evt); >>> + ret = iommu_report_device_fault(master->dev, &fault_evt); >>> out_unlock: >>> mutex_unlock(&smmu->streams_mutex); >>> return ret; >>> diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c >>> index 0e3a9b38bef2..7684e7562584 100644 >>> --- a/drivers/iommu/intel/svm.c >>> +++ b/drivers/iommu/intel/svm.c >>> @@ -532,6 +532,9 @@ void intel_svm_page_response(struct device *dev, struct iopf_fault *evt, >>> bool last_page; >>> u16 sid; >>> >>> + if (!evt) >>> + return; >>> + >> I'm not sure this make sense?? >> >> The point of this path is for the driver to retire the fault with a >> failure. This prevents that from happing on Intel and we are back to >> loosing track of a fault. >> >> All calls to iommu_report_device_fault() must result in >> page_response() properly retiring whatever the event was. >> >>> +static void iopf_error_response(struct device *dev, struct iommu_fault *fault) >>> +{ >>> + const struct iommu_ops *ops = dev_iommu_ops(dev); >>> + struct iommu_page_response resp = { >>> + .pasid = fault->prm.pasid, >>> + .grpid = fault->prm.grpid, >>> + .code = IOMMU_PAGE_RESP_INVALID >>> + }; >>> + >>> + ops->page_response(dev, NULL, &resp); >>> +} >> The issue originates here, why is this NULL? >> >> void iommu_report_device_fault(struct device *dev, struct iopf_fault *evt) >> { >> >> The caller has an evt? I think we should pass it down. > Hmm, I agree, I don't see `iommu_report_device_fault` be called anywhere > with a NULL evt. Hence, it does make sense to pass the evt down and > ensure we don't lose track of the event. > > I'm assuming that we retired the if (!evt) check from intel->page > response since we didn't have any callers of intel->page_response > with a NULL evt. (Atleast, for now, I don't see that happen). > > Lu, Will -- Any additional comments/suggestions for this? No. If evt is passed down in the above code, there is no need to add such check anymore. Thanks, baolu