Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1644946ybl; Wed, 28 Aug 2019 18:46:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqwgfDJNyhUKTBQX34JCrOtbkNgpuRCssy0spOXVA3B7IPOjOV2o3CUW1iFwS4Tjdmy73A0T X-Received: by 2002:a17:902:6a84:: with SMTP id n4mr7366168plk.109.1567043165196; Wed, 28 Aug 2019 18:46:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567043165; cv=none; d=google.com; s=arc-20160816; b=yun5GDlw8clWFIuHMRqEDLEGhO0lS51iHhOkMn89urEkNRYa3n96wwOVh6jVfOoP/r cOY5tpVABr+sQwNfDJITIL3kE1buNA75NoAqW6jxjjaav8GHCiJ79l7ZbqVNzj6E4EGw k724ZRHbPSHhxHS/1QST1IjQOmH9/7SrsRq9SoH2zeRxiMcGWN85x4n3AQb1lCaii1n1 LUNG1q8kCNXh7oUoX+8WBwnCtG4rHTCiyhPyu1lBXMca+GriFzPP8sSobK7WI94xl/Cu GUnEXEvFxufKpPvqi1eWvIZ2tBvZwlJBxIROlr+7l+lkGW7qK9BvUwJoxjlDS6ZP7Arn RzPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:cc; bh=QCvxKQKJct9qPiuOv/V7mqgDp92iRp4G7fOW/1pnXcI=; b=yTA3icD5cP4AsD0BdNXddcI8IPecV/C8bPWRQUjC7UDvoRntvUDFc5Xa6C7p1v5vqs +lW2+XA/xDnd/upFdbMLVBZ+z0JOshRtbQksoZr9hVFBkErlihQXeSouhJFI1OJJsbC0 KNu6J3d64QU6fuiQdIgTvhvlQzEzUCTMFp847QO9Gue0EuSoknQYsEdi91e7ffzpOC+9 purzVVhLG8C8dhdn3TxOhhpxSbkeskSwKWmH0jUL74sdPIwyiGeydHYKulUVBBjJjJjb ZMfBA7w8PMGt4JRawPxZnZG9ldH0EusiPapcmJxdIWJz17XDO8viglo30NUDsii6kfn3 1z5Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r9si566512plo.104.2019.08.28.18.45.49; Wed, 28 Aug 2019 18:46:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726973AbfH2Bow (ORCPT + 99 others); Wed, 28 Aug 2019 21:44:52 -0400 Received: from mga02.intel.com ([134.134.136.20]:55417 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726081AbfH2Bov (ORCPT ); Wed, 28 Aug 2019 21:44:51 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Aug 2019 18:44:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,442,1559545200"; d="scan'208";a="380606108" Received: from allen-box.sh.intel.com (HELO [10.239.159.136]) ([10.239.159.136]) by fmsmga005.fm.intel.com with ESMTP; 28 Aug 2019 18:44:48 -0700 Cc: baolu.lu@linux.intel.com, David Woodhouse , Joerg Roedel , iommu@lists.linux-foundation.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, =?UTF-8?Q?Micha=c5=82_Wajdeczko?= Subject: Re: [RFC PATCH] iommu/vt-d: Fix IOMMU field not populated on device hot re-plug To: Janusz Krzysztofik References: <20190822142922.31526-1-janusz.krzysztofik@linux.intel.com> <29020717.Hl6jQjRASr@jkrzyszt-desk.ger.corp.intel.com> <8f505c10-6256-c561-1aea-b3817388c5b2@linux.intel.com> <3275480.HMaYE7B3nd@jkrzyszt-desk.ger.corp.intel.com> From: Lu Baolu Message-ID: <0cf4e930-1132-1e7f-815b-57a08a1fe5de@linux.intel.com> Date: Thu, 29 Aug 2019 09:43:31 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <3275480.HMaYE7B3nd@jkrzyszt-desk.ger.corp.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Janusz, On 8/28/19 10:17 PM, Janusz Krzysztofik wrote: >> We should avoid kernel panic when a intel_unmap() is called against >> a non-existent domain. > Does that mean you suggest to replace > BUG_ON(!domain); > with something like > if (WARN_ON(!domain)) > return; > and to not care of orphaned mappings left allocated? Is there a way to inform > users that their active DMA mappings are no longer valid and they shouldn't > call dma_unmap_*()? > >> But we shouldn't expect the IOMMU driver not >> cleaning up the domain info when a device remove notification comes and >> wait until all file descriptors being closed, right? > Shouldn't then the IOMMU driver take care of cleaning up resources still > allocated on device remove before it invalidates and forgets their pointers? > You are right. We need to wait until all allocated resources (iova and mappings) to be released. How about registering a callback for BUS_NOTIFY_UNBOUND_DRIVER, and removing the domain info when the driver detachment completes? > Thanks, > Janusz Best regards, Baolu