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 2F4C4C3DA4A for ; Tue, 6 Aug 2024 00:10:21 +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=pzW81Z1+ejzvzocPlyk5IKqKIFtNo7GowTERWKEH7DM=; b=daqBbE5kXw9K50uqcVLyAcbvg9 ysQUi78mPtDpDM5l7qcNdwamJDA2J6iujlV41DsIMK/QWBtieTojvkEjN2yGp1YPSMHYjufJSgD2m KPsYF8XCeLO/MZkLQ36wLtYbojckxWF5VX2OWHWLfO0oWIdXDlMzRQK9VA9k/4UB4BUt/d/hBqCjo FyNwl37QrQGMqCKKLn52l7SYYrfMCiLMUpY7/U00jE4r9JLF+Tgl/nycjs0lDIeg3gY1I4fg5iDUf FnHi7vSM5ApHLf4SZ/FafVrXYTFgFr0V+k5CO6XTORYkB1bkfKJrWfxyK3QL+TZT0nGSIFH2ngEF+ nwIsVlIg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sb7mB-000000003f3-4AUl; Tue, 06 Aug 2024 00:10:08 +0000 Received: from mgamail.intel.com ([198.175.65.10]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sb7lf-000000003ZC-32Nm for linux-arm-kernel@lists.infradead.org; Tue, 06 Aug 2024 00:09:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1722902976; x=1754438976; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=QGYJ7DgsY5F9LBDwcmkATvyG2daQNLbHe+euRgQ464k=; b=DUR2uHCQyO/s5RYTd9HaCzOxYVSU5aJNxcTNw+k5/OAzYRCGnkA7CJwl I9ePvOjJoXJ6RuelAbSnmYP/rqm41OL0wJo3UcepfKI2+Ol4ozvroKkQk jy/hkhK2mRi2TlAQSHbrxFIRwgRHdfy0G8qdav6g4826dyn57uMV3bjFE 5YhM+fPqHiTysrCNNpTwUmEOdnX1JpWM4iA94lQlUhlKsQzeilsN1jaCj jIBMaZDxxpxBpoQlbVPW9mG8VSrKFIXtBzz874Aa/1t9pjiy3a0AIM0RO /jmFDvksW6O1qsl61ENS20EiQyiwNIOtoiji9YE8cR4oEcyh/q3Rx/WcM w==; X-CSE-ConnectionGUID: 0OUo0/FXTG2EFVsqDn+5rA== X-CSE-MsgGUID: SuvOEqPHSwSNgUl1gLGcHw== X-IronPort-AV: E=McAfee;i="6700,10204,11155"; a="38348385" X-IronPort-AV: E=Sophos;i="6.09,266,1716274800"; d="scan'208";a="38348385" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2024 17:09:33 -0700 X-CSE-ConnectionGUID: gXo9lAvsTK6FFdmTeNzY5w== X-CSE-MsgGUID: VAFTA9alSLicwxlBfg3oMQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,266,1716274800"; d="scan'208";a="56260351" Received: from blu2-mobl.ccr.corp.intel.com (HELO [10.124.240.228]) ([10.124.240.228]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2024 17:09:28 -0700 Message-ID: Date: Tue, 6 Aug 2024 08:09:26 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: baolu.lu@linux.intel.com, Kunkun Jiang , Robin Murphy , Joerg Roedel , Jason Gunthorpe , 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 , Will Deacon 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> Content-Language: en-US From: Baolu Lu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240805_170935_860415_E1CEFDBC X-CRM114-Status: GOOD ( 19.71 ) 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/5 23:32, Pranjal Shrivastava wrote: > On Mon, Aug 05, 2024 at 01:30:01PM +0100, Will Deacon wrote: >> On Mon, Aug 05, 2024 at 08:13:09PM +0800, Kunkun Jiang wrote: >>> On 2024/8/2 22:38, Pranjal Shrivastava wrote: >>>> Hey, >>>> On Mon, Jul 29, 2024 at 11:02 AM Baolu Lu wrote: >>>>> On 2024/7/24 18:24, Will Deacon wrote: >>>>>> On Wed, Jul 24, 2024 at 05:22:59PM +0800, Kunkun Jiang wrote: >>>>>>> On 2024/7/24 9:42, Kunkun Jiang wrote: >>>>>>>> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c >>>>>>>> 1797 while (!queue_remove_raw(q, evt)) { >>>>>>>> 1798 u8 id = FIELD_GET(EVTQ_0_ID, evt[0]); >>>>>>>> 1799 >>>>>>>> 1800 ret = arm_smmu_handle_evt(smmu, evt); >>>>>>>> 1801 if (!ret || !__ratelimit(&rs)) >>>>>>>> 1802 continue; >>>>>>>> 1803 >>>>>>>> 1804 dev_info(smmu->dev, "event 0x%02x >>>>>>>> received:\n", id); >>>>>>>> 1805 for (i = 0; i < ARRAY_SIZE(evt); ++i) >>>>>>>> 1806 dev_info(smmu->dev, "\t0x%016llx\n", >>>>>>>> 1807 (unsigned long >>>>>>>> long)evt[i]); >>>>>>>> 1808 >>>>>>>> 1809 cond_resched(); >>>>>>>> 1810 } >>>>>>>> >>>>>>>> The smmu-v3 driver cannot print event information when "ret" is 0. >>>>>>>> Unfortunately due to commit 3dfa64aecbaf >>>>>>>> ("iommu: Make iommu_report_device_fault() return void"), the default >>>>>>>> return value in arm_smmu_handle_evt() is 0. Maybe a trace should >>>>>>>> be added here? >>>>>>> Additional explanation. Background introduction: >>>>>>> 1.A device(VF) is passthrough(VFIO-PCI) to a VM. >>>>>>> 2.The SMMU has the stall feature. >>>>>>> 3.Modified guest device driver to generate an event. >>>>>>> >>>>>>> This event handling process is as follows: >>>>>>> arm_smmu_evtq_thread >>>>>>> ret = arm_smmu_handle_evt >>>>>>> iommu_report_device_fault >>>>>>> iopf_param = iopf_get_dev_fault_param(dev); >>>>>>> // iopf is not enabled. >>>>>>> // No RESUME will be sent! >>>>>>> if (WARN_ON(!iopf_param)) >>>>>>> return; >>>>>>> if (!ret || !__ratelimit(&rs)) >>>>>>> continue; >>>>>>> >>>>>>> In this scenario, the io page-fault capability is not enabled. >>>>>>> There are two problems here: >>>>>>> 1. The event information is not printed. >>>>>>> 2. The entire device(PF level) is stalled,not just the current >>>>>>> VF. This affects other normal VFs. >>>>>> Oh, so that stall is probably also due to b554e396e51c ("iommu: Make >>>>>> iopf_group_response() return void"). I agree that we need a way to >>>>>> propagate error handling back to the driver in the case that >>>>>> 'iopf_param' is NULL, otherwise we're making the unexpected fault >>>>>> considerably more problematic than it needs to be. >>>>>> >>>>>> Lu -- can we add the -ENODEV return back in the case that >>>>>> iommu_report_device_fault() doesn't even find a 'iommu_fault_param' for >>>>>> the device? >>>>> Yes, of course. The commit b554e396e51c was added to consolidate the >>>>> drivers' auto response code in the core with the assumption that driver >>>>> only needs to call iommu_report_device_fault() for reporting an iopf. >>>>> >>>> I had a go at taking Jason's diff and implementing the suggestions in >>>> this thread. >>>> Kunkun -- please can you see if this fixes the problem for you? >>> Okay, I'll test it as soon as I can. >> It looks like the diff sent by Pranjal has whitespace mangling, so I >> don't think you'll be able to apply it. >> >> Pranjal -- please can you send an unmangled version? If you want to test >> out your mail setup, I'm happy to be a guinea pig so you don't spam the >> mailing lists! > Ugh, apologies for that, something went wrong with my client. > Kunkun -- Please let me know if this fixes the problem. > Lu -- It looks like the intel->page_response callback doesn't expect a > NULL event, so, for now, I immediately return in that case. LMK what you > think? That's okay. We had such check there before the refactoring. Thanks, baolu