From patchwork Fri Apr 20 10:18:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: 0v3rdr0n3@gmail.com X-Patchwork-Id: 10352809 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 0EEC5602B1 for ; Fri, 20 Apr 2018 14:19:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F345D28789 for ; Fri, 20 Apr 2018 14:19:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E708B2873B; Fri, 20 Apr 2018 14:19:33 +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=-6.4 required=2.0 tests=BAYES_00, DATE_IN_PAST_03_06, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 878412873B for ; Fri, 20 Apr 2018 14:19:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755064AbeDTOTc (ORCPT ); Fri, 20 Apr 2018 10:19:32 -0400 Received: from mail-it0-f68.google.com ([209.85.214.68]:39376 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755052AbeDTOTb (ORCPT ); Fri, 20 Apr 2018 10:19:31 -0400 Received: by mail-it0-f68.google.com with SMTP id 85-v6so2677409iti.4; Fri, 20 Apr 2018 07:19:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fF110tUkYJ0r2hSJhvaIctPq2Do4DZgXYy5TmqJVeWM=; b=WGfp4w5cjWAG0QEjIyIFtxd0RVA5KNsbx0jskjVd7O3knq4uLXW6TNN0zmQi7D+DsV 4efn0QVSmwhTJxuKmyN5v4/FRbb/UACsXfP6NYTuhNmitRbcAXskq3z+reE15uNfZYpS IGHyedE6Tztu4ETt+JE3U0BhBVsuLR+3rI61nFAfUMwBjpXZkHG417dKO98E0Oc9Gpln Is1RBPIzep74/G0dzbomRjsMVDi1vVf2Bjw3p0z2PVJkHLeHSXXjEqBL1wqKh3i+lzG5 zXOHkqVNFFix0/bHvPD39+z2CqeTWD4QZM73A2J9xd+xyulMATdtLgDu8Q0bjl04LY32 5Kpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fF110tUkYJ0r2hSJhvaIctPq2Do4DZgXYy5TmqJVeWM=; b=erLFrfMfbV/9pwK5jKkItSAYrW+U+GsIwcl6uOfzo1hkvyagfR1qX10jrItOx1nsNp XFthAUodW1LTD4ZilffRCx4CCZ6Z+YkGf27zf1uiE0DYg9RmrFHoniJxhHJx0oigZFh2 7jivg48R3MUtlikDVYRq05PVGT4TsCx3hRkBHdQ49wGzj9z48S63J63C/8g39XO5hEWE K1TgrLpdg+HcjQz8ZLqY0p7rXenQsbAqPn2EWDMQJZSWdt/nNJtBapExC28o+V0iEBTM Ltmm0f/ZYGyPVqQZfKEoWdcgDp63/M+VxSeJGL76fsLkMEbIXVdANj0cT7pyKd3mM0aQ vR4Q== X-Gm-Message-State: ALQs6tDuSLAGW/PEeFM5FLSaBOqkZmeJeX5YlOlXKE1uYa3b0ZZkWrHV 0Po8Abs1Rr/ifCYVLW8E6ya//w== X-Google-Smtp-Source: AIpwx4+tx9qvrTkwHWHrwluX6M0535jn8Fwr61rBvWQl5rxFd0naP93JGmxJFd2AamDoWmdDmJRSwQ== X-Received: by 2002:a24:c885:: with SMTP id w127-v6mr3035968itf.93.1524233970958; Fri, 20 Apr 2018 07:19:30 -0700 (PDT) Received: from pride.cinci.rr.com (cpe-74-136-84-14.kya.res.rr.com. [74.136.84.14]) by smtp.gmail.com with ESMTPSA id f10-v6sm2927833iob.49.2018.04.20.07.19.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Apr 2018 07:19:30 -0700 (PDT) From: 0v3rdr0n3@gmail.com To: linux-pm@vger.kernel.org, linux-ide@vger.kernel.org Cc: samorris@lexmark.com Subject: [PATCH v2 3/3] ata: allow runtime pm of transport layer if no devices attached Date: Fri, 20 Apr 2018 10:18:34 +0000 Message-Id: <20180420101834.15783-3-0v3rdr0n3@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180420101834.15783-1-0v3rdr0n3@gmail.com> References: <20180420101834.15783-1-0v3rdr0n3@gmail.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Samuel Morris If no devices are detected on boot, and hotplug is disabled, let the transport layer suspend automatically to save power. Signed-off-by: Samuel Morris --- Changes: - camel case -> snake case --- drivers/ata/libata-scsi.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 89a9d4a2efc8..7c47a0f8aba9 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -51,6 +51,7 @@ #include #include #include +#include #include "libata.h" #include "libata-transport.h" @@ -4568,6 +4569,7 @@ int ata_scsi_add_hosts(struct ata_host *host, struct scsi_host_template *sht) void ata_scsi_scan_host(struct ata_port *ap, int sync) { int tries = 5; + int dev_attached = 0; struct ata_device *last_failed_dev = NULL; struct ata_link *link; struct ata_device *dev; @@ -4591,12 +4593,18 @@ void ata_scsi_scan_host(struct ata_port *ap, int sync) if (!IS_ERR(sdev)) { dev->sdev = sdev; scsi_device_put(sdev); + dev_attached = 1; } else { dev->sdev = NULL; } } } +#ifdef CONFIG_AHCI_HOTPLUG_DISABLED + if (!dev_attached) + pm_runtime_allow(&ap->tdev); +#endif + /* If we scanned while EH was in progress or allocation * failure occurred, scan would have failed silently. Check * whether all devices are attached.