Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3469014ybi; Fri, 5 Jul 2019 07:53:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqy7tJIABWYnxGcBufXVXZQhK/NobiU1hC7ZbRKH9gVy8yMHSbjUXDGaIhJpWzdiRg3TM6/v X-Received: by 2002:a17:902:2e81:: with SMTP id r1mr6215985plb.0.1562338424526; Fri, 05 Jul 2019 07:53:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562338424; cv=none; d=google.com; s=arc-20160816; b=gKIPL9werDf1scgjBPLUVWR91eOZq/TFKRq0UOaxKjGEmwX0ziqXPvPhG7NtviHUne 20CiLXS9hMz2EhAnjJjpb169/z+SzAfe0cfXJE+QD2viZkZhN7q6TJwWS3cFAca0//D8 ZtEJ9fLIcLAc8mE1kmVhOWo0SVyUieRvh9lHCEzcbNW7Kt7Z2TSo6tasZ/Pm4gwkOlwc JdaMkRlOgopb+Kz1ul8yh+4DyfDWJ82HGG2Q7Svef1AWYwmpjNpQUrdniIIBy/66YlQ9 coclGsevevafSCc/KNFctkfak/9XKNqgDkXF6f7EQOPcwmhBttuBA3q480+CIgdKzieP wntw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=A65hScK6gm93YpD/X6L9smk8ajaWkyIMHdHKT3AaSr0=; b=o6qkleLPXMif1bFgLRSrGp4fG9W1ZCihFQuzNIpURpcyOjPo0C8KyJoDHJnZYtVSbG vYxIg4Njm0gmSn4G24YPBajUhUwP4ImOrX8SZP9OZDMzk0EUF796xOd3uA2XQaZWGPLv jtKuR0X0weRw4Aio5Sop+2uQEi2Ayo0EeIsA/CJBjkcLHrZQVnUzLtOtllQfMZGzG5hk jp4kHFg+9IZ0md/4EYdWN+MPPHzTnkLu/YyzCaj5+yijF5MdQONd4vfDdfmfXveuVdy9 mumMyhvg20O3D/xbRdDPd9yc3Kcx35gMqjxvVMIryjgm0GFJM10aH6+n3d7sGbEYacve iPUA== 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 i3si8947828plb.205.2019.07.05.07.53.29; Fri, 05 Jul 2019 07:53:44 -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 S1727488AbfGEOvM (ORCPT + 99 others); Fri, 5 Jul 2019 10:51:12 -0400 Received: from mga18.intel.com ([134.134.136.126]:25617 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725865AbfGEOvL (ORCPT ); Fri, 5 Jul 2019 10:51:11 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Jul 2019 07:51:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,455,1557212400"; d="scan'208";a="185201897" Received: from lahna.fi.intel.com (HELO lahna) ([10.237.72.157]) by fmsmga001.fm.intel.com with SMTP; 05 Jul 2019 07:51:07 -0700 Received: by lahna (sSMTP sendmail emulation); Fri, 05 Jul 2019 17:51:06 +0300 Date: Fri, 5 Jul 2019 17:51:06 +0300 From: Mika Westerberg To: Yehezkel Bernat Cc: LKML , Andreas Noever , Michael Jamet , "Rafael J . Wysocki" , Len Brown , Lukas Wunner , Mario Limonciello , Anthony Wong , linux-acpi@vger.kernel.org, raanan.avargil@intel.com Subject: Re: [PATCH 7/8] thunderbolt: Add support for Intel Ice Lake Message-ID: <20190705145106.GA2640@lahna.fi.intel.com> References: <20190705095800.43534-1-mika.westerberg@linux.intel.com> <20190705095800.43534-8-mika.westerberg@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 05, 2019 at 05:44:01PM +0300, Yehezkel Bernat wrote: > On Fri, Jul 5, 2019 at 12:58 PM Mika Westerberg > wrote: > > > > +static void icm_icl_rtd3_veto(struct tb *tb, const struct icm_pkg_header *hdr) > > +{ > > + const struct icm_icl_event_rtd3_veto *pkg = > > + (const struct icm_icl_event_rtd3_veto *)hdr; > > + struct icm *icm = tb_priv(tb); > > + > > + tb_dbg(tb, "ICM rtd3 veto=0x%08x\n", pkg->veto_reason); > > + > > + if (pkg->veto_reason) { > > + if (!icm->veto) { > > + icm->veto = true; > > + /* Keep the domain powered while veto is in effect */ > > + pm_runtime_get(&tb->dev); > > + } > > + } else { > > + if (icm->veto) { > > + icm->veto = false; > > + /* Allow the domain suspend now */ > > + pm_runtime_mark_last_busy(&tb->dev); > > + pm_runtime_put_autosuspend(&tb->dev); > > Handling the removal of the veto is duplicated below. Worth introducing as a > helper function? > > > + } > > + } > > +} > > + > > ... > > > @@ -1853,6 +1943,18 @@ static void icm_complete(struct tb *tb) > > if (tb->nhi->going_away) > > return; > > > > + /* > > + * If RTD3 was vetoed before we entered system suspend allow it > > + * again now before driver ready is sent. Firmware sends a new RTD3 > > + * veto if it is still the case after we have sent it driver ready > > + * command. > > + */ > > + if (icm->veto) { > > + icm->veto = false; > > + pm_runtime_mark_last_busy(&tb->dev); > > + pm_runtime_put_autosuspend(&tb->dev); > > + } > > + > > Here is the duplication. Indeed, I'll put it to a helper function. > > +static int nhi_suspend_power_down(struct tb *tb) > > +{ > > + int ret; > > + > > + /* > > + * If there is no device connected we need to perform an additional > > + * handshake through LC mailbox and force power down before > > + * entering D3. > > + */ > > + ret = device_for_each_child(&tb->root_switch->dev, NULL, > > + nhi_device_connected); > > + if (!ret) { > > + lc_mailbox_cmd(tb->nhi, LC_PREPARE_FOR_RESET); > > + ret = lc_mailbox_cmd_complete(tb->nhi, > > + LC_MAILBOX_TIMEOUT); > > + if (ret) > > + return ret; > > + > > + return nhi_power_down(tb->nhi); > > Just to be sure: unforce power is done only if no device is connected? > My understanding of the comment above was that unforce power should be done > anyway (so it should be outside of this if block), and the difference between > the cases is only about the additional LC mailbox message. I guess I misread it. nhi_power_down() should be only called if no device was connected so it should be in correct place. I can try to clarify the comment a bit, though.