From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932331AbcCIME3 (ORCPT ); Wed, 9 Mar 2016 07:04:29 -0500 Received: from mga02.intel.com ([134.134.136.20]:4093 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753559AbcCIMER (ORCPT ); Wed, 9 Mar 2016 07:04:17 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,311,1455004800"; d="scan'208";a="920117988" Date: Wed, 9 Mar 2016 14:04:11 +0200 From: Mika Westerberg To: Dmitry Torokhov Cc: Jiri Kosina , Benjamin Tissoires , Andrew Duggan , Benson Leung , Dan Carpenter , Gabriele Mazzotta , Doug Anderson , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, "Rafael J. Wysocki" Subject: Re: [PATCH v3] HID: i2c-hid: Fix suspend/resume when already runtime suspended Message-ID: <20160309120411.GF1796@lahna.fi.intel.com> References: <20160308230323.GA4382@dtor-ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160308230323.GA4382@dtor-ws> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 08, 2016 at 03:03:23PM -0800, Dmitry Torokhov wrote: > On ACPI-based systems ACPI power domain code runtime resumes device before > calling suspend method, which ensures that i2c-hid suspend code starts with > device not in low-power state and with interrupts enabled. > > On other systems, especially if device is not a part of any power domain, > we may end up calling driver's system-level suspend routine while the > device is runtime-suspended (with controller in presumably low power state > and interrupts disabled). This will result in interrupts being essentially > disabled twice, and we will only re-enable them after both system resume > and runtime resume methods complete. Unfortunately i2c_hid_resume() calls > i2c_hid_hwreset() and that only works properly if interrupts are enabled. > > Also if device is runtime-suspended driver's suspend code may fail if it > tries to issue I/O requests. > > Let's fix it by runtime-resuming the device if we need to run HID driver's > suspend code and also disabling interrupts only if device is not already > runtime-suspended. Also on resume we mark the device as running at full > power (since that is what resetting will do to it). > > Signed-off-by: Doug Anderson > Signed-off-by: Dmitry Torokhov Tested on a couple of Intel Skylake and Baytrail based systems and power management of I2C connected HID devices still seems to work just fine. Tested-by: Mika Westerberg