Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp4002981ybl; Mon, 26 Aug 2019 04:04:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqy/gWQuM91J8gxmpDsoGzIq6V2f3PuITnr1l6yTV5M2ELAfP2EPpI7grOlMYmAj6bGvfaEm X-Received: by 2002:a63:2157:: with SMTP id s23mr16311955pgm.167.1566817445278; Mon, 26 Aug 2019 04:04:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566817445; cv=none; d=google.com; s=arc-20160816; b=TKWvp2EhFJPBwo7TdMt4aJB5TB5/pjsC96jnpo819fps7bKmwOvhgq5wwNTe5184OC 2L8JGF+57cgmnv1Qhla01SnADE9EvO2n7us5x2ThxHDSsfNPCi1y0FYxuF1KgrbBM8FD /yHNQzdrmldw61kWsnAuQW8lsj6ndWrEJC7ww2CRAlL5m1MkqpRDjZ3pUZTljUGT6aWd TvQELS/9sKJ6y0rC9R4hHsFLvkeSW7JFMDFZcS1xh16+JmQr47ss736oytT+suMNCd4K 65W0WlXu1qMwiwaF+FmiBeICxlHq0y3me5K25OJCO/jYFCdJdQpYiyfFjx9DZSXW7y/O IlIQ== 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:mime-version :references:in-reply-to:organization:message-id:date:subject:cc:to :from; bh=vxzqtdJm8cGfegWfVjtKfJ4Tqiccry8/8YPnE8/ycVk=; b=Bx6TOch22AzhhWRjLMB0DbvPRbMqDxeQJGeoxIXzTJlwXYPh9V8W4T5V+keYGofXNY w0ugNXHc7nRzp14Jtm0HHlSSvb9P1GB4QVqv5RGvDbqaOyupcOcUDnEZ/Bkrz+GsMe/C +DQ7ttycEeZ86nT5+5ionyOKeyvT+kCigK4KspTfsVo7p0WXQE4ajL0A5QSNQjdXyxkY HJxYnvdn0obX1gFFeStumYUz+WoOpfISLIOjJuSPHjFUZwB4rVhZu7i7BvOwEhvqT5Zh eQrLW1EJfPj4Y6Az/H0XXYObbPm31GqyMX3Oq+3DDF5FLWYKV1YmbiU+9/nHQDxQPkjd 7MyQ== 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 a24si9899589pfi.205.2019.08.26.04.03.48; Mon, 26 Aug 2019 04:04: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 S1730490AbfHZIPe (ORCPT + 99 others); Mon, 26 Aug 2019 04:15:34 -0400 Received: from mga05.intel.com ([192.55.52.43]:1488 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727951AbfHZIPe (ORCPT ); Mon, 26 Aug 2019 04:15:34 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Aug 2019 01:15:34 -0700 X-IronPort-AV: E=Sophos;i="5.64,431,1559545200"; d="scan'208";a="174133517" Received: from jkrzyszt-desk.ger.corp.intel.com ([172.22.244.17]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Aug 2019 01:15:31 -0700 From: Janusz Krzysztofik To: Lu Baolu Cc: David Woodhouse , Joerg Roedel , iommu@lists.linux-foundation.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, =?utf-8?B?TWljaGHFgg==?= Wajdeczko Subject: Re: [RFC PATCH] iommu/vt-d: Fix IOMMU field not populated on device hot re-plug Date: Mon, 26 Aug 2019 10:15:21 +0200 Message-ID: <7536805.yzB8ZXLclH@jkrzyszt-desk.ger.corp.intel.com> Organization: Intel Technology Poland sp. z o.o. - ul. Slowackiego 173, 80-298 Gdansk - KRS 101882 - NIP 957-07-52-316 In-Reply-To: <00f1a3a7-7ff6-e9a0-d9de-a177af6fd64b@linux.intel.com> References: <20190822142922.31526-1-janusz.krzysztofik@linux.intel.com> <00f1a3a7-7ff6-e9a0-d9de-a177af6fd64b@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Lu, On Friday, August 23, 2019 3:51:11 AM CEST Lu Baolu wrote: > Hi, > > On 8/22/19 10:29 PM, Janusz Krzysztofik wrote: > > When a perfectly working i915 device is hot unplugged (via sysfs) and > > hot re-plugged again, its dev->archdata.iommu field is not populated > > again with an IOMMU pointer. As a result, the device probe fails on > > DMA mapping error during scratch page setup. > > > > It looks like that happens because devices are not detached from their > > MMUIO bus before they are removed on device unplug. Then, when an > > already registered device/IOMMU association is identified by the > > reinstantiated device's bus and function IDs on IOMMU bus re-attach > > attempt, the device's archdata is not populated with IOMMU information > > and the bad happens. > > > > I'm not sure if this is a proper fix but it works for me so at least it > > confirms correctness of my analysis results, I believe. So far I > > haven't been able to identify a good place where the possibly missing > > IOMMU bus detach on device unplug operation could be added. > > Which kernel version are you testing with? Does it contain below commit? > > commit 458b7c8e0dde12d140e3472b80919cbb9ae793f4 > Author: Lu Baolu > Date: Thu Aug 1 11:14:58 2019 +0800 I was using an internal branch based on drm-tip which didn't contain this commit yet. Fortunately it has been already merged into drm-tip over last weekend and has effectively fixed the issue. Thanks, Janusz > iommu/vt-d: Detach domain when move device out of group > > When removing a device from an iommu group, the domain should > be detached from the device. Otherwise, the stale domain info > will still be cached by the driver and the driver will refuse > to attach any domain to the device again. > > Cc: Ashok Raj > Cc: Jacob Pan > Cc: Kevin Tian > Fixes: b7297783c2bb6 ("iommu/vt-d: Remove duplicated code for > device hotplug") > Reported-and-tested-by: Vlad Buslov > Suggested-by: Robin Murphy > Link: https://lkml.org/lkml/2019/7/26/1133 > Signed-off-by: Lu Baolu > Signed-off-by: Joerg Roedel > > Best regards, > Lu Baolu > > > > > Signed-off-by: Janusz Krzysztofik > > --- > > drivers/iommu/intel-iommu.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c > > index 12d094d08c0a..7cdcd0595408 100644 > > --- a/drivers/iommu/intel-iommu.c > > +++ b/drivers/iommu/intel-iommu.c > > @@ -2477,6 +2477,9 @@ static struct dmar_domain *dmar_insert_one_dev_info(struct intel_iommu *iommu, > > if (info2) { > > found = info2->domain; > > info2->dev = dev; > > + > > + if (dev && !dev->archdata.iommu) > > + dev->archdata.iommu = info2; > > } > > } > > > > >