From patchwork Wed Jun 8 08:59:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quan Xu X-Patchwork-Id: 9163741 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 50A536088F for ; Wed, 8 Jun 2016 09:05:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40A1D28363 for ; Wed, 8 Jun 2016 09:05:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3551728391; Wed, 8 Jun 2016 09:05:45 +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 762CE2838F for ; Wed, 8 Jun 2016 09:05:44 +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 1bAZOt-0004Jj-AH; Wed, 08 Jun 2016 09:03:47 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bAZOr-0004Fi-UL for xen-devel@lists.xen.org; Wed, 08 Jun 2016 09:03:46 +0000 Received: from [193.109.254.147] by server-8.bemta-14.messagelabs.com id 3E/4B-08354-17FD7575; Wed, 08 Jun 2016 09:03:45 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrNLMWRWlGSWpSXmKPExsVywNwkQrfgfni 4wfFHshZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8b8jk72go1eFVeXHmBqYHxv1MXIySEkUCkx b8kSdhBbQoBX4siyGawQtr/ExYavzBA1NRLzW+ezgNhsAioSM5rfgdWLCEhLXPt8mbGLkYuDW WA+o8TLR3eBEhwcwgIJErPbQ0BqWARUJZ4ffMcEYvMKOEm0bj8EtUtBYtmXtcwg5ZxA8a3HSi FWOUps2/2EZQIj7wJGhlWM6sWpRWWpRbpmeklFmekZJbmJmTm6hoYmermpxcWJ6ak5iUnFesn 5uZsYgYHAAAQ7GP9OcD7EKMnBpCTKq+geHi7El5SfUpmRWJwRX1Sak1p8iFGGg0NJgrf2HlBO sCg1PbUiLTMHGJIwaQkOHiURXimQNG9xQWJucWY6ROoUo6KUOK8oSEIAJJFRmgfXBouDS4yyU sK8jECHCPEUpBblZpagyr9iFOdgVBLmDQOZwpOZVwI3/RXQYiagxcuPgC0uSURISTUwbi6t+u IY57Sqfy7Do4/LDt7gqFOY7LjOKavRQCwi6fCVV3/CbvLvWZM81ezVhMXTZt7b4njLMJ/3TM0 8dyWphb+uGTmEXBKre7a5zO/Fyyd3t7VYKAWbfZDvyz4gvXH/jE2tH+t4Zf4uklueqO77OzE7 QXrP2x4bke/bU1xOtFUYH3jIVKHNqMRSnJFoqMVcVJwIAGvcAMZ+AgAA X-Env-Sender: quan.xu@intel.com X-Msg-Ref: server-9.tower-27.messagelabs.com!1465376607!46437496!10 X-Originating-IP: [192.55.52.88] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTkyLjU1LjUyLjg4ID0+IDM3NDcyNQ==\n X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 30396 invoked from network); 8 Jun 2016 09:03:44 -0000 Received: from mga01.intel.com (HELO mga01.intel.com) (192.55.52.88) by server-9.tower-27.messagelabs.com with SMTP; 8 Jun 2016 09:03:44 -0000 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 08 Jun 2016 02:03:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,438,1459839600"; d="scan'208";a="983224015" Received: from xen-commits.sh.intel.com ([10.239.82.178]) by fmsmga001.fm.intel.com with ESMTP; 08 Jun 2016 02:03:43 -0700 From: "Xu, Quan" To: xen-devel@lists.xen.org Date: Wed, 8 Jun 2016 16:59:04 +0800 Message-Id: <1465376344-28290-12-git-send-email-quan.xu@intel.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1465376344-28290-1-git-send-email-quan.xu@intel.com> References: <1465376344-28290-1-git-send-email-quan.xu@intel.com> Cc: Kevin Tian , dario.faggioli@citrix.com, Feng Wu , Jan Beulich , Quan Xu Subject: [Xen-devel] [PATCH v7 11/11] vt-d: add __must_check annotation to IOMMU flush pointers and handlers 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: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Quan Xu Signed-off-by: Quan Xu Reviewed-by: Jan Beulich CC: Jan Beulich CC: Kevin Tian CC: Feng Wu v7: using !! instead of ?: . Acked-by: Kevin Tian --- xen/drivers/passthrough/vtd/iommu.c | 44 ++++++++++++++++++------------------ xen/drivers/passthrough/vtd/iommu.h | 11 +++++---- xen/drivers/passthrough/vtd/qinval.c | 14 ++++++------ 3 files changed, 36 insertions(+), 33 deletions(-) diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c index 8ad862e..fc5c76c 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -335,10 +335,9 @@ static void iommu_flush_write_buffer(struct iommu *iommu) } /* return value determine if we need a write buffer flush */ -static int flush_context_reg( - void *_iommu, - u16 did, u16 source_id, u8 function_mask, u64 type, - int flush_non_present_entry) +static int __must_check flush_context_reg(void *_iommu, u16 did, u16 source_id, + u8 function_mask, u64 type, + bool_t flush_non_present_entry) { struct iommu *iommu = (struct iommu *) _iommu; u64 val = 0; @@ -389,7 +388,7 @@ static int flush_context_reg( } static int __must_check iommu_flush_context_global(struct iommu *iommu, - int flush_non_present_entry) + bool_t flush_non_present_entry) { struct iommu_flush *flush = iommu_get_flush(iommu); return flush->context(iommu, 0, 0, 0, DMA_CCMD_GLOBAL_INVL, @@ -399,7 +398,7 @@ static int __must_check iommu_flush_context_global(struct iommu *iommu, static int __must_check iommu_flush_context_device(struct iommu *iommu, u16 did, u16 source_id, u8 function_mask, - int flush_non_present_entry) + bool_t flush_non_present_entry) { struct iommu_flush *flush = iommu_get_flush(iommu); return flush->context(iommu, did, source_id, function_mask, @@ -408,9 +407,10 @@ static int __must_check iommu_flush_context_device(struct iommu *iommu, } /* return value determine if we need a write buffer flush */ -static int flush_iotlb_reg(void *_iommu, u16 did, - u64 addr, unsigned int size_order, u64 type, - int flush_non_present_entry, int flush_dev_iotlb) +static int __must_check flush_iotlb_reg(void *_iommu, u16 did, u64 addr, + unsigned int size_order, u64 type, + bool_t flush_non_present_entry, + bool_t flush_dev_iotlb) { struct iommu *iommu = (struct iommu *) _iommu; int tlb_offset = ecap_iotlb_offset(iommu->ecap); @@ -475,8 +475,8 @@ static int flush_iotlb_reg(void *_iommu, u16 did, } static int __must_check iommu_flush_iotlb_global(struct iommu *iommu, - int flush_non_present_entry, - int flush_dev_iotlb) + bool_t flush_non_present_entry, + bool_t flush_dev_iotlb) { struct iommu_flush *flush = iommu_get_flush(iommu); int status; @@ -494,8 +494,8 @@ static int __must_check iommu_flush_iotlb_global(struct iommu *iommu, } static int __must_check iommu_flush_iotlb_dsi(struct iommu *iommu, u16 did, - int flush_non_present_entry, - int flush_dev_iotlb) + bool_t flush_non_present_entry, + bool_t flush_dev_iotlb) { struct iommu_flush *flush = iommu_get_flush(iommu); int status; @@ -514,8 +514,8 @@ static int __must_check iommu_flush_iotlb_dsi(struct iommu *iommu, u16 did, static int __must_check iommu_flush_iotlb_psi(struct iommu *iommu, u16 did, u64 addr, unsigned int order, - int flush_non_present_entry, - int flush_dev_iotlb) + bool_t flush_non_present_entry, + bool_t flush_dev_iotlb) { struct iommu_flush *flush = iommu_get_flush(iommu); int status; @@ -570,7 +570,7 @@ static int __must_check iommu_flush_all(void) rc = iommu_flush_context_global(iommu, 0); if ( rc <= 0 ) { - int flush_dev_iotlb = find_ats_dev_drhd(iommu) ? 1 : 0; + bool_t flush_dev_iotlb = !!find_ats_dev_drhd(iommu); int ret = iommu_flush_iotlb_global(iommu, 0, flush_dev_iotlb); ASSERT(ret <= 0); @@ -595,7 +595,7 @@ static int __must_check iommu_flush_iotlb(struct domain *d, struct domain_iommu *hd = dom_iommu(d); struct acpi_drhd_unit *drhd; struct iommu *iommu; - int flush_dev_iotlb; + bool_t flush_dev_iotlb; int iommu_domid; int rc = 0; @@ -610,7 +610,7 @@ static int __must_check iommu_flush_iotlb(struct domain *d, if ( !test_bit(iommu->index, &hd->arch.iommu_bitmap) ) continue; - flush_dev_iotlb = find_ats_dev_drhd(iommu) ? 1 : 0; + flush_dev_iotlb = !!find_ats_dev_drhd(iommu); iommu_domid= domain_iommu_domid(d, iommu); if ( iommu_domid == -1 ) continue; @@ -1453,7 +1453,7 @@ int domain_context_mapping_one( */ if ( rc <= 0 ) { - int flush_dev_iotlb = find_ats_dev_drhd(iommu) ? 1 : 0; + bool_t flush_dev_iotlb = !!find_ats_dev_drhd(iommu); int ret = iommu_flush_iotlb_dsi(iommu, 0, 1, flush_dev_iotlb); ASSERT(ret <= 0); @@ -1614,7 +1614,7 @@ int domain_context_unmap_one( */ if ( rc <= 0 ) { - int flush_dev_iotlb = find_ats_dev_drhd(iommu) ? 1 : 0; + bool_t flush_dev_iotlb = !!find_ats_dev_drhd(iommu); int ret = iommu_flush_iotlb_dsi(iommu, iommu_domid, 0, flush_dev_iotlb); ASSERT(ret <= 0); @@ -1845,7 +1845,7 @@ int iommu_pte_flush(struct domain *d, u64 gfn, u64 *pte, struct acpi_drhd_unit *drhd; struct iommu *iommu = NULL; struct domain_iommu *hd = dom_iommu(d); - int flush_dev_iotlb; + bool_t flush_dev_iotlb; int iommu_domid; int rc = 0; @@ -1857,7 +1857,7 @@ int iommu_pte_flush(struct domain *d, u64 gfn, u64 *pte, if ( !test_bit(iommu->index, &hd->arch.iommu_bitmap) ) continue; - flush_dev_iotlb = find_ats_dev_drhd(iommu) ? 1 : 0; + flush_dev_iotlb = !!find_ats_dev_drhd(iommu); iommu_domid= domain_iommu_domid(d, iommu); if ( iommu_domid == -1 ) continue; diff --git a/xen/drivers/passthrough/vtd/iommu.h b/xen/drivers/passthrough/vtd/iommu.h index c55ee08..e6cf738 100644 --- a/xen/drivers/passthrough/vtd/iommu.h +++ b/xen/drivers/passthrough/vtd/iommu.h @@ -514,10 +514,13 @@ struct ir_ctrl { }; struct iommu_flush { - int (*context)(void *iommu, u16 did, u16 source_id, - u8 function_mask, u64 type, int non_present_entry_flush); - int (*iotlb)(void *iommu, u16 did, u64 addr, unsigned int size_order, - u64 type, int flush_non_present_entry, int flush_dev_iotlb); + int __must_check (*context)(void *iommu, u16 did, u16 source_id, + u8 function_mask, u64 type, + bool_t non_present_entry_flush); + int __must_check (*iotlb)(void *iommu, u16 did, u64 addr, + unsigned int size_order, u64 type, + bool_t flush_non_present_entry, + bool_t flush_dev_iotlb); }; struct intel_iommu { diff --git a/xen/drivers/passthrough/vtd/qinval.c b/xen/drivers/passthrough/vtd/qinval.c index b81b0bd..aa7841a 100644 --- a/xen/drivers/passthrough/vtd/qinval.c +++ b/xen/drivers/passthrough/vtd/qinval.c @@ -274,9 +274,9 @@ int iommu_flush_iec_index(struct iommu *iommu, u8 im, u16 iidx) return __iommu_flush_iec(iommu, IEC_INDEX_INVL, im, iidx); } -static int flush_context_qi( - void *_iommu, u16 did, u16 sid, u8 fm, u64 type, - int flush_non_present_entry) +static int __must_check flush_context_qi(void *_iommu, u16 did, + u16 sid, u8 fm, u64 type, + bool_t flush_non_present_entry) { int ret = 0; struct iommu *iommu = (struct iommu *)_iommu; @@ -305,10 +305,10 @@ static int flush_context_qi( return ret; } -static int flush_iotlb_qi( - void *_iommu, u16 did, - u64 addr, unsigned int size_order, u64 type, - int flush_non_present_entry, int flush_dev_iotlb) +static int __must_check flush_iotlb_qi(void *_iommu, u16 did, u64 addr, + unsigned int size_order, u64 type, + bool_t flush_non_present_entry, + bool_t flush_dev_iotlb) { u8 dr = 0, dw = 0; int ret = 0;