From patchwork Thu May 5 10:18:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quan Xu X-Patchwork-Id: 9023241 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AEEF5BF29F for ; Thu, 5 May 2016 10:20:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C85DB203B4 for ; Thu, 5 May 2016 10:20:09 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id D85DD203B0 for ; Thu, 5 May 2016 10:20:08 +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 1ayGMI-0002UM-P0; Thu, 05 May 2016 10:18:14 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ayGMG-0002UC-NE for xen-devel@lists.xen.org; Thu, 05 May 2016 10:18:12 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id CE/C2-07120-4ED1B275; Thu, 05 May 2016 10:18:12 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrNKsWRWlGSWpSXmKPExsVywNykQvexrHa 4wYpXChZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8asL+vZC7arVmw4f4mtgfGHShcjB4eQQIXE rcOBXYycHBICvBJHls1ghbD9JRpeXGHrYuQCKmlglNi8ZQY7hLOLUWLNriOsEM4aRompm6eyg bSwCahIzGh+xw5iiwgoS/T++s0CUsQssI1ZYu/TSWBFwgL5EnNPfWYGWS0iUCDRMkUcot5Nov 3zaSYQmwVoztcJz1lAbF6BYInblzdAnbGfSaL3+FR2kF5OAXuJyfdzQWoYBcQkvp9aA9bLLCA ucevJfCaIFwQkluw5zwxhi0q8fPwP6jVFib/rWxlBxjALaEqs36UP0aooMaX7ITvEWkGJkzOf sEACSE5i4w+uCYySs5AsmIXQPAtJ8ywkzQsYWVYxqhenFpWlFuka6yUVZaZnlOQmZuboGhqY6 eWmFhcnpqfmJCYV6yXn525iBEYiAxDsYOz453SIUZKDSUmUl3GjVrgQX1J+SmVGYnFGfFFpTm rxIUYZDg4lCd6jMtrhQoJFqempFWmZOcCUAJOW4OBREuFlA6YFId7igsTc4sx0iNQpRkUpcd6 lIH0CIImM0jy4NlgausQoKyXMywh0iBBPQWpRbmYJqvwrRnEORiWgCpDxPJl5JXDTXwEtZgJa /H6uJsjikkSElFQDY/gPaZ2pTxzcd+byHQhtWmmj8WSCW/7h9tJCf9XjWRasLAVhwWcj/7v+4 J5iU+iw4P7do5/+etubWR45yf3m5tzcD4+k/n4rEawSlZgb8Vjc2rGVW9HWaM2pS2aPBU7nsv 9YMH3JRrbZj+cmeDfIOK73/SltKrn+bHWd5UXZ/6dn/Yud23c7TImlOCPRUIu5qDgRABrQDvo +AwAA X-Env-Sender: quan.xu@intel.com X-Msg-Ref: server-6.tower-21.messagelabs.com!1462443490!12709500!1 X-Originating-IP: [192.55.52.120] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.34; banners=-,-,- X-VirusChecked: Checked Received: (qmail 58212 invoked from network); 5 May 2016 10:18:11 -0000 Received: from mga04.intel.com (HELO mga04.intel.com) (192.55.52.120) by server-6.tower-21.messagelabs.com with SMTP; 5 May 2016 10:18:11 -0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP; 05 May 2016 03:18:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,581,1455004800"; d="scan'208";a="969253537" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga002.jf.intel.com with ESMTP; 05 May 2016 03:18:09 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 5 May 2016 03:18:09 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.148]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.58]) with mapi id 14.03.0248.002; Thu, 5 May 2016 18:18:07 +0800 From: "Xu, Quan" To: Jan Beulich Thread-Topic: [Xen-devel] [PATCH v3 09/10] IOMMU: propagate IOMMU Device-TLB flush error up to IOMMU suspending Thread-Index: AQHRofmUok4coPIU5UyjQiaBg5Gy1p+nhz0AgACGYJD//+o8AIACMi5g Date: Thu, 5 May 2016 10:18:06 +0000 Message-ID: <945CA011AD5F084CBEA3E851C0AB28894B8A94D5@SHSMSX101.ccr.corp.intel.com> References: <1461921917-48394-1-git-send-email-quan.xu@intel.com> <1461921917-48394-10-git-send-email-quan.xu@intel.com> <945CA011AD5F084CBEA3E851C0AB28894B8A841B@SHSMSX101.ccr.corp.intel.com> <5729D23002000078000E861C@prv-mh.provo.novell.com> In-Reply-To: <5729D23002000078000E861C@prv-mh.provo.novell.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Cc: "Tian, Kevin" , Stefano Stabellini , "Wu, Feng" , Liu Jinsong , "dario.faggioli@citrix.com" , "xen-devel@lists.xen.org" , Julien Grall , SuraveeSuthikulpanit , Andrew Cooper , Keir Fraser Subject: Re: [Xen-devel] [PATCH v3 09/10] IOMMU: propagate IOMMU Device-TLB flush error up to IOMMU suspending 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On May 04, 2016 4:43 PM, Jan Beulich wrote: > >>> On 04.05.16 at 04:14, wrote: > > On May 04, 2016 10:00 AM, Tian, Kevin wrote: > >> > From: Xu, Quan > >> > Sent: Friday, April 29, 2016 5:25 PM diff --git > >> > a/xen/arch/x86/acpi/power.c b/xen/arch/x86/acpi/power.c index > >> > 2885e31..9097333 100644 > >> > --- a/xen/arch/x86/acpi/power.c > >> > +++ b/xen/arch/x86/acpi/power.c > >> > @@ -45,6 +45,8 @@ void do_suspend_lowlevel(void); > >> > > >> > static int device_power_down(void) { > >> > + int err; > >> > + > >> > console_suspend(); > >> > > >> > time_suspend(); > >> > @@ -53,11 +55,22 @@ static int device_power_down(void) > >> > > >> > ioapic_suspend(); > >> > > >> > - iommu_suspend(); > >> > + err = iommu_suspend(); > >> > + > >> > + if ( err ) > >> > + goto iommu_suspend_error; > >> > > >> > lapic_suspend(); > >> > > >> > return 0; > >> > + > >> > + iommu_suspend_error: > >> > + ioapic_resume(); > >> > + i8259A_resume(); > >> > + time_resume(); > >> > + console_resume(); > >> > + > >> > + return err; > >> > } > >> > >> Jan had comment to better reuse device_power_up... looks no change in > >> this version. > > > > Yes, __iiuc__, this may be an optimization, but not a must. > > We can discuss this in detail In this version. > > As an optimization it would indeed be quite pointless here. My request was > more for maintainability: By re-using the function future changes don't need > to go to two places, and hence there's no risk of one of them getting > forgotten. > Jan, What about this one as below: --- Quan --- a/xen/arch/x86/acpi/power.c +++ b/xen/arch/x86/acpi/power.c @@ -43,6 +43,17 @@ struct acpi_sleep_info acpi_sinfo; void do_suspend_lowlevel(void); +enum dev_power_type { + TYPE_ALL, + TYPE_CONSOLE, + TYPE_TIME, + TYPE_I8259A, + TYPE_IOAPIC, + TYPE_IOMMU, + TYPE_LAPIC, + TYPE_UNKNOWN +}; + static int device_power_down(void) { console_suspend(); @@ -53,26 +64,35 @@ static int device_power_down(void) ioapic_suspend(); - iommu_suspend(); + if ( iommu_suspend() ) + return TYPE_IOMMU; lapic_suspend(); return 0; } -static void device_power_up(void) +static void device_power_up(enum dev_power_type type) { - lapic_resume(); - - iommu_resume(); - - ioapic_resume(); - - i8259A_resume(); - - time_resume(); - - console_resume(); + switch ( type ) { + case TYPE_ALL: + case TYPE_LAPIC: + lapic_resume(); + case TYPE_IOMMU: + iommu_resume(); + case TYPE_IOAPIC: + ioapic_resume(); + case TYPE_I8259A: + i8259A_resume(); + case TYPE_TIME: + time_resume(); + case TYPE_CONSOLE: + console_resume(); + break; + default: + BUG(); + break; + } } static void freeze_domains(void) @@ -169,6 +189,7 @@ static int enter_state(u32 state) { printk(XENLOG_ERR "Some devices failed to power down."); system_state = SYS_STATE_resume; + device_power_up(error); goto done; } @@ -196,7 +217,7 @@ static int enter_state(u32 state) write_cr4(cr4 & ~X86_CR4_MCE); write_efer(read_efer()); - device_power_up(); + device_power_up(TYPE_ALL); mcheck_init(&boot_cpu_data, 0); write_cr4(cr4);