From patchwork Mon Jun 27 09:23:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quan Xu X-Patchwork-Id: 9200131 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5719F6075F for ; Mon, 27 Jun 2016 09:26:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4723328452 for ; Mon, 27 Jun 2016 09:26:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3BBF328488; Mon, 27 Jun 2016 09:26:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2538328452 for ; Mon, 27 Jun 2016 09:26:30 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bHSm2-0006ZN-80; Mon, 27 Jun 2016 09:24:10 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bHSm0-0006ZH-QA for xen-devel@lists.xen.org; Mon, 27 Jun 2016 09:24:08 +0000 Received: from [85.158.137.68] by server-6.bemta-3.messagelabs.com id AC/1B-24961-7B0F0775; Mon, 27 Jun 2016 09:24:07 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrNKsWRWlGSWpSXmKPExsVywNwkVnf7h4J wg9MneSyWfFzM4sDocXT3b6YAxijWzLyk/IoE1owrLx0LpnJWnP/RwN7AuJu9i5GTQ0igUmL2 pa1MILaEAK/EkWUzWCFsf4kvC0+wdDFyAdU0MEqs+rqPGcLZwyix9cwSJghnF6PEooWvGCGcN YwSnXe6weayCahIzGh+B2aLCJhLbF2yhRHEZhbIkvj6cyoLiC0sIC7xf9UPZogaGYl5bXOAaj iAbD2JKavtQcIsAqoSr97dBmvlFQiW+LJrMth5jAJiEt9PrWGCGCkucevJfKgXBCSW7DnPDGG LSrx8/I8V5DYJgbnMEv9eToIqkpY4tu461J+KEn/Xt0LdpiOxYPcnNghbW2LZwtfMEIsFJU7O fMICcpuQgJzExh9cExilZiFZPQtJ9ywk3bOQdC9gZFnFqFGcWlSWWqRraKiXVJSZnlGSm5iZo 2toYKyXm1pcnJiempOYVKyXnJ+7iREYqQxAsINx9W+nQ4ySHExKorzbHuWGC/El5adUZiQWZ8 QXleakFh9ilOHgUJLgTXpfEC4kWJSanlqRlpkDTBkwaQkOHiUR3nPvgNK8xQWJucWZ6RCpU4y KUuK8RiB9AiCJjNI8uDZYmrrEKCslzMsIdIgQT0FqUW5mCar8K0ZxDkYlYd4SkCk8mXklcNNf AS1mAlrMWp0PsrgkESEl1cBYpJKn0bAxvGlLsFJHU/6NStfaa44x0fz5v2uKJsx/+kn/0JkFr bkympsyFv2+u1G76hVD1rEZJbcZN+YY+4bZvOQO1CyzcFgX0/T52zQN5RlqaUqrjC5GztIM8g i6vmldf0DM2s8PpwZdNqq58vDuScG6q5N+Hj2XYa6X1Rl084mQo/ZvPkklluKMREMt5qLiRAA G0FNxTgMAAA== X-Env-Sender: quan.xu@intel.com X-Msg-Ref: server-9.tower-31.messagelabs.com!1467019446!10751087!1 X-Originating-IP: [192.55.52.93] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTkyLjU1LjUyLjkzID0+IDMyNDY2NQ==\n X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 37663 invoked from network); 27 Jun 2016 09:24:07 -0000 Received: from mga11.intel.com (HELO mga11.intel.com) (192.55.52.93) by server-9.tower-31.messagelabs.com with SMTP; 27 Jun 2016 09:24:07 -0000 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP; 27 Jun 2016 02:24:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,536,1459839600"; d="scan'208";a="725564017" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by FMSMGA003.fm.intel.com with ESMTP; 27 Jun 2016 02:24:01 -0700 Received: from fmsmsx158.amr.corp.intel.com (10.18.116.75) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 27 Jun 2016 02:23:59 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx158.amr.corp.intel.com (10.18.116.75) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 27 Jun 2016 02:23:59 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.8]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.107]) with mapi id 14.03.0248.002; Mon, 27 Jun 2016 17:23:58 +0800 From: "Xu, Quan" To: "xen-devel@lists.xen.org" Thread-Topic: FIXME question Thread-Index: AdHQVMbxUwoYwQfXRlGvQyUxHyLrbw== Date: Mon, 27 Jun 2016 09:23:57 +0000 Message-ID: <945CA011AD5F084CBEA3E851C0AB28894B8F6A68@SHSMSX101.ccr.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYWYwOWZkM2MtNWM0OC00NTE2LThiMDMtN2ZhNmJkMjRmYzBjIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6ImhvOGVmZzMwdTVDNVVLUG1UZEhVQWpYTVcyczNMVDNFQTlLcit1RkJUWGM9In0= x-ctpclassification: CTP_IC x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Cc: "Tian, Kevin" , "Wu, Feng" , Jan Beulich Subject: [Xen-devel] FIXME question X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Hi, When I read IOMMU code, In xen/drivers/passthrough/vtd/intremap.c : pi_update_irte().. There are a FIXME -- '' * FIXME: For performance reasons we should store the 'iommu' pointer in * 'struct msi_desc' in some other place, so we don't need to waste * time searching it here. " IMO, we are better to store the 'iommu' pointer in pci_dev, then could I fix it as: 1. save a void *iommu in pci_dev structure: -Quan --- a/xen/include/xen/pci.h +++ b/xen/include/xen/pci.h @@ -83,6 +83,8 @@ struct pci_dev { #define PT_FAULT_THRESHOLD 10 } fault; u64 vf_rlen[6]; + + void *iommu; /* No common IOMMU struct so use void pointer */ }; 2. Save iommu pointer in 'struct pci_dev' when to add device: --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -1994,6 +1994,7 @@ static int intel_iommu_enable_device(struct pci_dev *pdev) if ( ret <= 0 ) return ret; + pdev->iommu = drhd->iommu; ret = enable_ats_device(pdev->seg, pdev->bus, pdev->devfn, drhd->iommu); 3. use iommu pointer from pci_dev instead of calling acpi_find_matched_drhd_unit each time (also fix the related code).