Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3465017ybi; Fri, 5 Jul 2019 07:49:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqwrtoMlc8bxjc4iNq4TP2VirH5pWHL/uxqT3WQYGsAwnceP/Ry0fi9z3qdnckTp/SpRU0r5 X-Received: by 2002:a65:5b4b:: with SMTP id y11mr5904567pgr.244.1562338156766; Fri, 05 Jul 2019 07:49:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562338156; cv=none; d=google.com; s=arc-20160816; b=iEfFSglyD3vfg5A60xyhxFg5sVOHqVSEcZUoTwD5fAyVAAud74im4mlx7Y07WrDiSY oBxn2x/0Bxwhu3AcP5+HBL8IGYgeC2+WfzFSFpBisuFuYyMZ23V82s+TETbYRSxkpp+h YIlZckeLUdLV4o5KVNYXVLYYdT9myf+rBfv0WyvCGKIrB83Lqdvy19Ggs2YhM6AX+Me6 MnRAsmJ5B+6FB+Ezuhha+tVnn13Lfcly4jb2x0V2qV/c0qytRngQ2BUyd2IGTx1o878X DPPXm++hrRZOXuQTyM42bNKwfGoTmVK+QsyanWHVWd7P5iQ+7afeEGUjHXyHffrssXfB n3+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=u7KgAyQowANlphvuJcvefk4JoB8cIIbciEehkbcGJKE=; b=UOFJX9idZH+Z+dXMMoCOOXWX8N3QsTkNfIMjgE2VPDSAeJMk7EZORJNFiSvdObNRbE ZPnKbUiB3UWE+iFl1T41AVpHo8ROGAZjEj6JVP7+TG5Vj7W60+bc0FWr0q61x+yfJlpK 6uGrnaJ/0fjVAj56i2CDkvXeAD9L11Fy+NYoF2Fk6ugY5jXaFK+xhe7T8j7D3KbTq1U/ amHBjZu3Yw8jdhIgW+dGrM9Di4/YHtbNDwAyw034BtOOVNZr/E7LptKS0v8Y8JfLGiZ8 kLdpjZ9goZs/BMIFyM2bvN3L0xlvKjB1PV/ZB+wWPG2FIfY/PY0v/BfN8qDiNEiee4gV d8zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fxB1Q9Gf; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v22si10156446pfe.275.2019.07.05.07.49.01; Fri, 05 Jul 2019 07:49:16 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fxB1Q9Gf; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726765AbfGEOoU (ORCPT + 99 others); Fri, 5 Jul 2019 10:44:20 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:37305 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725926AbfGEOoU (ORCPT ); Fri, 5 Jul 2019 10:44:20 -0400 Received: by mail-lj1-f195.google.com with SMTP id z28so589351ljn.4; Fri, 05 Jul 2019 07:44:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=u7KgAyQowANlphvuJcvefk4JoB8cIIbciEehkbcGJKE=; b=fxB1Q9Gf3qr8zXsgafNXTpZesztA2sfVuxBUoIJYzv2n708SjhhGIR0dH+CLA7ros5 2U0rQu/CcCfWPt430p/EZAAWi9zD3FJsWABd1IiFvj7de/RW+3H3J667T8TKrBjAXwRr TM1Ghy16jFwAP0mVUM0r27OYrmQASLz2Xtev3Xi5D0B3VZFeOaRi/x3KL1tCaMB7d/OI HpEmVZz1+dGswD5iitTWscZYrxRLB5mqwnUx5nsqCdrn9Mu4x9i0iGUszu2G4kewJ/+o 5daGtAGzxW+FCMtIONrU/XwxWh4cgFT2xPegHFiq9chZ/kO+a2faPLBXyGv1BRJQLKUm LcmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=u7KgAyQowANlphvuJcvefk4JoB8cIIbciEehkbcGJKE=; b=nb6v7WKDPOfj3WUp1Mwx089+b+Qdnt5kmkpP2TpW9fROH9IdT+RwmQHo02+l8kcjxs zscTD7ma0OLOhtlIgtxDBgZSDtYx6fWUJB//Yr/SW+w8HaDoGOAh86FDWRtE2m5AMlSv b6LaCQVigZrOZen11uEeXDgudZu5DP8GMj33RB93VxKuWUJjbPEnieAtalzKYmVsvZxu JxZtYMuO4SAd+V9Irb9yhr82YPvRZ6CXksRsb+q/uxdoUwFeckPC3e7FBiWb4Ix+z6zQ ZKQjK6PFzd167duc2Mk/z3Djkcc9mF3cO9vyy3Vx80A2T5p3h0r8buGGBuxS+spEKbQG 5pVw== X-Gm-Message-State: APjAAAX5Cu/0WkhoFEJiFA5zSLkwoyclOu8Gtl+jiDvT5yCWQrsncT9I LcAi42MfMlCgE4gnL6ZY1mi6hjE1g2PBCGz0xLY= X-Received: by 2002:a2e:900c:: with SMTP id h12mr2286212ljg.197.1562337858382; Fri, 05 Jul 2019 07:44:18 -0700 (PDT) MIME-Version: 1.0 References: <20190705095800.43534-1-mika.westerberg@linux.intel.com> <20190705095800.43534-8-mika.westerberg@linux.intel.com> In-Reply-To: <20190705095800.43534-8-mika.westerberg@linux.intel.com> From: Yehezkel Bernat Date: Fri, 5 Jul 2019 17:44:01 +0300 Message-ID: Subject: Re: [PATCH 7/8] thunderbolt: Add support for Intel Ice Lake To: Mika Westerberg 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > +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. > + } > + > + return 0; > +} > +