From patchwork Tue Sep 3 11:10:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis Efremov (Oracle)" X-Patchwork-Id: 11127681 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9968514F7 for ; Tue, 3 Sep 2019 11:10:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 84A5122DBF for ; Tue, 3 Sep 2019 11:10:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728753AbfICLKd (ORCPT ); Tue, 3 Sep 2019 07:10:33 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:39051 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727667AbfICLKb (ORCPT ); Tue, 3 Sep 2019 07:10:31 -0400 Received: by mail-wr1-f68.google.com with SMTP id t16so17031554wra.6; Tue, 03 Sep 2019 04:10:30 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=OB/ebM0xFR6Mxp0KUgqKdXbK7ynlwFq+qhqH3UbFDaQ=; b=Y2K3p/BA1YyFIOkgHprG5ow2XJHpdyL658zymLfh0Lqa7ZjdWijf6bJRn9cip/EbY1 1IU1AApMWmi1NGFPozhQlTdoO5CocqvxTDrEK7M81cGs2BYaG4OgjUvH2e1xw5yUkzSB JDgxL++TGopGx4bGJN2TcPXLX1fiuU5NXVN+TmGlIDh85vntnkHx69+s8kIXkIvSFPyu Jz4rBP0kCk4e8axOyrHxPbUDVWisZYd+gXZCMvzuQjEuQDO1Hqipzfo/9pro3cxh/uq7 tT0o8qqxrpxToHWWnUNaSmcaEaEfxRI4ERNOQ2PudMt/QbPHiHBeoHINPTgMohtWxWzK 0XWQ== X-Gm-Message-State: APjAAAVfBxbuKJL07A1HQjvmdbsZwEYCkTmdQ2pLNSimZA2Y+xFtye15 BEZl/GOD//nuBrXqHI9kb/w= X-Google-Smtp-Source: APXvYqzMmBDG91dqagyUiTXYHlQfpPEzIBQ/B+F79d8p6nMHFbvuQBsxb3AWGs8szaAARXsRTJ8S9Q== X-Received: by 2002:adf:ba0c:: with SMTP id o12mr24515859wrg.284.1567509030018; Tue, 03 Sep 2019 04:10:30 -0700 (PDT) Received: from black.home (broadband-188-32-48-208.ip.moscow.rt.ru. [188.32.48.208]) by smtp.googlemail.com with ESMTPSA id w12sm4363572wrg.47.2019.09.03.04.10.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2019 04:10:29 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Denis Efremov , Lukas Wunner , linux-pci@vger.kernel.org, Kuppuswamy Sathyanarayanan , Oliver O'Halloran , linux-kernel@vger.kernel.org Subject: [PATCH v4 1/4] PCI: pciehp: Add pciehp_set_indicators() to jointly set LED indicators Date: Tue, 3 Sep 2019 14:10:18 +0300 Message-Id: <20190903111021.1559-2-efremov@linux.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190903111021.1559-1-efremov@linux.com> References: <20190903111021.1559-1-efremov@linux.com> MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Add pciehp_set_indicators() to set power and attention indicators with a single register write. Thus, avoiding waiting twice for Command Complete. Signed-off-by: Denis Efremov --- drivers/pci/hotplug/pciehp.h | 5 +++++ drivers/pci/hotplug/pciehp_hpc.c | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h index 8c51a04b8083..0214e09e91a4 100644 --- a/drivers/pci/hotplug/pciehp.h +++ b/drivers/pci/hotplug/pciehp.h @@ -167,6 +167,11 @@ int pciehp_power_on_slot(struct controller *ctrl); void pciehp_power_off_slot(struct controller *ctrl); void pciehp_get_power_status(struct controller *ctrl, u8 *status); +/* Special values for leaving indicators unchanged */ +#define PCI_EXP_SLTCTL_ATTN_IND_NONE -1 /* Attention Indicator noop */ +#define PCI_EXP_SLTCTL_PWR_IND_NONE -1 /* Power Indicator noop */ +void pciehp_set_indicators(struct controller *ctrl, int pwr, int attn); + void pciehp_set_attention_status(struct controller *ctrl, u8 status); void pciehp_get_latch_status(struct controller *ctrl, u8 *status); int pciehp_query_power_fault(struct controller *ctrl); diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index bd990e3371e3..4d0fe39ef049 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -443,6 +443,27 @@ void pciehp_set_attention_status(struct controller *ctrl, u8 value) pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, slot_cmd); } +void pciehp_set_indicators(struct controller *ctrl, int pwr, int attn) +{ + u16 cmd = 0, mask = 0; + + if (PWR_LED(ctrl) && pwr > 0) { + cmd |= pwr; + mask |= PCI_EXP_SLTCTL_PIC; + } + + if (ATTN_LED(ctrl) && attn > 0) { + cmd |= attn; + mask |= PCI_EXP_SLTCTL_AIC; + } + + if (cmd) { + pcie_write_cmd_nowait(ctrl, cmd, mask); + ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__, + pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, cmd); + } +} + void pciehp_green_led_on(struct controller *ctrl) { if (!PWR_LED(ctrl)) From patchwork Tue Sep 3 11:10:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis Efremov (Oracle)" X-Patchwork-Id: 11127683 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 15EC917EF for ; Tue, 3 Sep 2019 11:10:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F342E22DCC for ; Tue, 3 Sep 2019 11:10:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728860AbfICLKu (ORCPT ); Tue, 3 Sep 2019 07:10:50 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:52522 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727667AbfICLKt (ORCPT ); Tue, 3 Sep 2019 07:10:49 -0400 Received: by mail-wm1-f68.google.com with SMTP id t17so17681487wmi.2; Tue, 03 Sep 2019 04:10:47 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=/JZWeFamsO4Isg/LD+2KIcQomVjj1vItid4mxiHlSfQ=; b=jh65utJL2OReMNC5QeoCnDZLvJzjCWQGwYy51LW5Cehg/YQC5yDcpE9u5ZUcp+sM22 VS8yVusdMEbN6aCRLCaYObHyBUS3RoJZdrP/DUhSk9jLOl2KHFZiylMRbUWu/n5L0ceI sD7KuFJGKKvDxcQQrGrb59dFEzOgcGwCOWV1Ilk/4F5X7MWXoM1kLblvlbMR4LKeIV7A +pANvddiDjYbCsQR7N+MW3Go0oa+285FVP3jQ1mlE/YTtZm51oWAW4bTp0KYacJ3699L ug3w0cH+dlNV8BS55WQcWaIdUwHu8JzZxhH5j9Ms1NjgW9M2LwYt1yLcgsPc2WyaTcwA PLmA== X-Gm-Message-State: APjAAAWmeyrqGbngUGLl5HwVt2Zyb2mKZOB48iQjibiaTn4379Dxpt9U XxSk/L1y9y5dpPRqjeDCpnYAkPCt X-Google-Smtp-Source: APXvYqzcdB7i0kpa39goRE4oXcTqkb9IrnFabUOMTcUV64ZcIiCgrOHwqGgg1hFodzxEVHKP4sjAzw== X-Received: by 2002:a1c:4b14:: with SMTP id y20mr9401219wma.10.1567509046689; Tue, 03 Sep 2019 04:10:46 -0700 (PDT) Received: from black.home (broadband-188-32-48-208.ip.moscow.rt.ru. [188.32.48.208]) by smtp.googlemail.com with ESMTPSA id w12sm4363572wrg.47.2019.09.03.04.10.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2019 04:10:46 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Denis Efremov , Lukas Wunner , linux-pci@vger.kernel.org, Kuppuswamy Sathyanarayanan , Oliver O'Halloran , linux-kernel@vger.kernel.org Subject: [PATCH v4 2/4] PCI: pciehp: Switch LED indicators with a single write Date: Tue, 3 Sep 2019 14:10:19 +0300 Message-Id: <20190903111021.1559-3-efremov@linux.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190903111021.1559-1-efremov@linux.com> References: <20190903111021.1559-1-efremov@linux.com> MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org This patch replaces all consecutive switches of power and attention indicators with pciehp_set_indicators() call. Thus, performing only single write to a register. Reviewed-by: Kuppuswamy Sathyanarayanan Reviewed-by: Lukas Wunner Signed-off-by: Denis Efremov --- drivers/pci/hotplug/pciehp_ctrl.c | 19 ++++++++++--------- drivers/pci/hotplug/pciehp_hpc.c | 4 ++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c index 631ced0ab28a..232f7bfcfce9 100644 --- a/drivers/pci/hotplug/pciehp_ctrl.c +++ b/drivers/pci/hotplug/pciehp_ctrl.c @@ -42,8 +42,8 @@ static void set_slot_off(struct controller *ctrl) msleep(1000); } - pciehp_green_led_off(ctrl); - pciehp_set_attention_status(ctrl, 1); + pciehp_set_indicators(ctrl, PCI_EXP_SLTCTL_PWR_IND_OFF, + PCI_EXP_SLTCTL_ATTN_IND_ON); } /** @@ -90,8 +90,8 @@ static int board_added(struct controller *ctrl) } } - pciehp_green_led_on(ctrl); - pciehp_set_attention_status(ctrl, 0); + pciehp_set_indicators(ctrl, PCI_EXP_SLTCTL_PWR_IND_ON, + PCI_EXP_SLTCTL_ATTN_IND_OFF); return 0; err_exit: @@ -172,8 +172,8 @@ void pciehp_handle_button_press(struct controller *ctrl) slot_name(ctrl)); } /* blink green LED and turn off amber */ - pciehp_green_led_blink(ctrl); - pciehp_set_attention_status(ctrl, 0); + pciehp_set_indicators(ctrl, PCI_EXP_SLTCTL_PWR_IND_BLINK, + PCI_EXP_SLTCTL_ATTN_IND_OFF); schedule_delayed_work(&ctrl->button_work, 5 * HZ); break; case BLINKINGOFF_STATE: @@ -187,12 +187,13 @@ void pciehp_handle_button_press(struct controller *ctrl) cancel_delayed_work(&ctrl->button_work); if (ctrl->state == BLINKINGOFF_STATE) { ctrl->state = ON_STATE; - pciehp_green_led_on(ctrl); + pciehp_set_indicators(ctrl, PCI_EXP_SLTCTL_PWR_IND_ON, + PCI_EXP_SLTCTL_ATTN_IND_OFF); } else { ctrl->state = OFF_STATE; - pciehp_green_led_off(ctrl); + pciehp_set_indicators(ctrl, PCI_EXP_SLTCTL_PWR_IND_OFF, + PCI_EXP_SLTCTL_ATTN_IND_OFF); } - pciehp_set_attention_status(ctrl, 0); ctrl_info(ctrl, "Slot(%s): Action canceled due to button press\n", slot_name(ctrl)); break; diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index 4d0fe39ef049..d2c60d844d30 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -659,8 +659,8 @@ static irqreturn_t pciehp_ist(int irq, void *dev_id) if ((events & PCI_EXP_SLTSTA_PFD) && !ctrl->power_fault_detected) { ctrl->power_fault_detected = 1; ctrl_err(ctrl, "Slot(%s): Power fault\n", slot_name(ctrl)); - pciehp_set_attention_status(ctrl, 1); - pciehp_green_led_off(ctrl); + pciehp_set_indicators(ctrl, PCI_EXP_SLTCTL_PWR_IND_OFF, + PCI_EXP_SLTCTL_ATTN_IND_ON); } /* From patchwork Tue Sep 3 11:10:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis Efremov (Oracle)" X-Patchwork-Id: 11127687 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D4DEC14F7 for ; Tue, 3 Sep 2019 11:11:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BFD4322D6D for ; Tue, 3 Sep 2019 11:11:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728883AbfICLKv (ORCPT ); Tue, 3 Sep 2019 07:10:51 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:42337 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728838AbfICLKv (ORCPT ); Tue, 3 Sep 2019 07:10:51 -0400 Received: by mail-wr1-f67.google.com with SMTP id b16so16991381wrq.9; Tue, 03 Sep 2019 04:10:49 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=uNN831oAcxJIf6qZK0bKvNkU4fX+CR0u9Z6WK9p3j/Y=; b=sq8N1Fha0022AHVDkqIwtk3foG4WLpFJSILS/jijJ4bzZ1+w8SL3D9TITuXQgJeWwu Cf7+Wyk1eFDEGDPYIc0uOQ3dQvdGiz0uOMq0BJ0lHhTIaEycBSZW5FHx6naHjNDUCFGE KP2dhDQhvRNoS75Zdm7Ee1lmCkKKP+iY9BQpGEnRPiVpwjKhyS7O2ZwwX4REYGi+3N5u qLfL0cxNvrUb3KV94DpNRplBSXiYf8TpYbx/Lo/MhPMBA0m9RiwIEufNNn3Fi8FleN2F 0g6lNC01rTgYAKaXf25FISBMLCEem4Aa/2V06MC+kdqC6NMc4+eGt74orcwRwpDvrAgX zChg== X-Gm-Message-State: APjAAAUdyhsK1NaxjjFpfdiSDfABYXobK4JgeVyPmwxr+tOlVbm18+7W eo5q+23K8vEsEM7BxtcwqBw= X-Google-Smtp-Source: APXvYqzNyGzht6qwN8mEr0ZTZC6Gb/u9QgAk9j8A7nsnpaqmaiNK2LPY8hG+J+EtpYpFhNWCd2fLyQ== X-Received: by 2002:adf:ee4a:: with SMTP id w10mr27197684wro.138.1567509049162; Tue, 03 Sep 2019 04:10:49 -0700 (PDT) Received: from black.home (broadband-188-32-48-208.ip.moscow.rt.ru. [188.32.48.208]) by smtp.googlemail.com with ESMTPSA id w12sm4363572wrg.47.2019.09.03.04.10.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2019 04:10:48 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Denis Efremov , Lukas Wunner , linux-pci@vger.kernel.org, Kuppuswamy Sathyanarayanan , Oliver O'Halloran , linux-kernel@vger.kernel.org Subject: [PATCH v4 3/4] PCI: pciehp: Remove pciehp_set_attention_status() Date: Tue, 3 Sep 2019 14:10:20 +0300 Message-Id: <20190903111021.1559-4-efremov@linux.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190903111021.1559-1-efremov@linux.com> References: <20190903111021.1559-1-efremov@linux.com> MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Remove pciehp_set_attention_status() and use pciehp_set_indicators() instead, since the code is mostly the same. Reviewed-by: Kuppuswamy Sathyanarayanan Signed-off-by: Denis Efremov --- drivers/pci/hotplug/pciehp.h | 1 - drivers/pci/hotplug/pciehp_core.c | 7 ++++++- drivers/pci/hotplug/pciehp_hpc.c | 25 ------------------------- include/uapi/linux/pci_regs.h | 1 + 4 files changed, 7 insertions(+), 27 deletions(-) diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h index 0214e09e91a4..cf59f70a33cc 100644 --- a/drivers/pci/hotplug/pciehp.h +++ b/drivers/pci/hotplug/pciehp.h @@ -172,7 +172,6 @@ void pciehp_get_power_status(struct controller *ctrl, u8 *status); #define PCI_EXP_SLTCTL_PWR_IND_NONE -1 /* Power Indicator noop */ void pciehp_set_indicators(struct controller *ctrl, int pwr, int attn); -void pciehp_set_attention_status(struct controller *ctrl, u8 status); void pciehp_get_latch_status(struct controller *ctrl, u8 *status); int pciehp_query_power_fault(struct controller *ctrl); void pciehp_green_led_on(struct controller *ctrl); diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c index 6ad0d86762cb..7a86ea90ed94 100644 --- a/drivers/pci/hotplug/pciehp_core.c +++ b/drivers/pci/hotplug/pciehp_core.c @@ -102,8 +102,13 @@ static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status) struct controller *ctrl = to_ctrl(hotplug_slot); struct pci_dev *pdev = ctrl->pcie->port; + if (status) + status <<= PCI_EXP_SLTCTL_ATTN_IND_SHIFT; + else + status = PCI_EXP_SLTCTL_ATTN_IND_OFF; + pci_config_pm_runtime_get(pdev); - pciehp_set_attention_status(ctrl, status); + pciehp_set_indicators(ctrl, PCI_EXP_SLTCTL_PWR_IND_NONE, status); pci_config_pm_runtime_put(pdev); return 0; } diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index d2c60d844d30..eeac2e704c75 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -418,31 +418,6 @@ int pciehp_set_raw_indicator_status(struct hotplug_slot *hotplug_slot, return 0; } -void pciehp_set_attention_status(struct controller *ctrl, u8 value) -{ - u16 slot_cmd; - - if (!ATTN_LED(ctrl)) - return; - - switch (value) { - case 0: /* turn off */ - slot_cmd = PCI_EXP_SLTCTL_ATTN_IND_OFF; - break; - case 1: /* turn on */ - slot_cmd = PCI_EXP_SLTCTL_ATTN_IND_ON; - break; - case 2: /* turn blink */ - slot_cmd = PCI_EXP_SLTCTL_ATTN_IND_BLINK; - break; - default: - return; - } - pcie_write_cmd_nowait(ctrl, slot_cmd, PCI_EXP_SLTCTL_AIC); - ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__, - pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, slot_cmd); -} - void pciehp_set_indicators(struct controller *ctrl, int pwr, int attn) { u16 cmd = 0, mask = 0; diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h index f28e562d7ca8..de3e58afc564 100644 --- a/include/uapi/linux/pci_regs.h +++ b/include/uapi/linux/pci_regs.h @@ -591,6 +591,7 @@ #define PCI_EXP_SLTCTL_CCIE 0x0010 /* Command Completed Interrupt Enable */ #define PCI_EXP_SLTCTL_HPIE 0x0020 /* Hot-Plug Interrupt Enable */ #define PCI_EXP_SLTCTL_AIC 0x00c0 /* Attention Indicator Control */ +#define PCI_EXP_SLTCTL_ATTN_IND_SHIFT 6 /* Attention Indicator shift */ #define PCI_EXP_SLTCTL_ATTN_IND_ON 0x0040 /* Attention Indicator on */ #define PCI_EXP_SLTCTL_ATTN_IND_BLINK 0x0080 /* Attention Indicator blinking */ #define PCI_EXP_SLTCTL_ATTN_IND_OFF 0x00c0 /* Attention Indicator off */ From patchwork Tue Sep 3 11:10:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis Efremov (Oracle)" X-Patchwork-Id: 11127685 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4A58817EF for ; Tue, 3 Sep 2019 11:11:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2D85723711 for ; Tue, 3 Sep 2019 11:11:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728933AbfICLLB (ORCPT ); Tue, 3 Sep 2019 07:11:01 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:52547 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728838AbfICLLA (ORCPT ); Tue, 3 Sep 2019 07:11:00 -0400 Received: by mail-wm1-f65.google.com with SMTP id t17so17682144wmi.2; Tue, 03 Sep 2019 04:10:59 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=ePgnJvYxWrV7sbrqetU6IzX5b2sFn8WAvNr4Gv1qEEY=; b=eTEr/b6xMARK2Q0RJnEx0VVL5NpE+UXXxzu/3e4BWK5LJ5kHx1HstvSyAGklpZPTCS cOmQahq0vDY2GWzos6p9mtdvdwTbXCAkJGZ39v91EYwY3MDyORY44E1uU3JKUsOZbQ72 KjsvEWmShjmQQbtyDxdpscVVaRtnZatfX1RU08lelAPaMRCtJ0o/v9QIp0PFUAvciMWD 6F38Ya+pCnzT014tAP3jv4lsMilkiPlbXP4IG6aCM8X1SXeKME6dzyDNxlosV4wLZB33 qZLFNhq4Ihy3GyLwM0AnRc72deMh/GYEm6ZwZlvREQE94/Ops7nEDpXvDhIcdJvGFhyL 5DZQ== X-Gm-Message-State: APjAAAVDVdzcTy5vao0/x0GiOt/C/bPaPKJO7aW7SoewG1VnDGldmJWE 2L9disuboLDTJnmO4A+efdg= X-Google-Smtp-Source: APXvYqyTBFtV0K2tErOWmuzozNDfw2iFPVwjisLK5ZPWLkUGePsJBVCM4L9CwkC4fG9ToooS8qvT6w== X-Received: by 2002:a1c:7c1a:: with SMTP id x26mr44727496wmc.115.1567509059271; Tue, 03 Sep 2019 04:10:59 -0700 (PDT) Received: from black.home (broadband-188-32-48-208.ip.moscow.rt.ru. [188.32.48.208]) by smtp.googlemail.com with ESMTPSA id w12sm4363572wrg.47.2019.09.03.04.10.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2019 04:10:58 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Denis Efremov , Lukas Wunner , linux-pci@vger.kernel.org, Kuppuswamy Sathyanarayanan , Oliver O'Halloran , linux-kernel@vger.kernel.org Subject: [PATCH v4 4/4] PCI: pciehp: Remove pciehp_green_led_{on,off,blink}() Date: Tue, 3 Sep 2019 14:10:21 +0300 Message-Id: <20190903111021.1559-5-efremov@linux.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190903111021.1559-1-efremov@linux.com> References: <20190903111021.1559-1-efremov@linux.com> MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Remove pciehp_green_led_{on,off,blink}() and use pciehp_set_indicators() instead, since the code is mostly the same. Reviewed-by: Kuppuswamy Sathyanarayanan Signed-off-by: Denis Efremov --- drivers/pci/hotplug/pciehp.h | 6 +++--- drivers/pci/hotplug/pciehp_ctrl.c | 7 +++--- drivers/pci/hotplug/pciehp_hpc.c | 36 ------------------------------- 3 files changed, 7 insertions(+), 42 deletions(-) diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h index cf59f70a33cc..dcbf790b7508 100644 --- a/drivers/pci/hotplug/pciehp.h +++ b/drivers/pci/hotplug/pciehp.h @@ -174,9 +174,6 @@ void pciehp_set_indicators(struct controller *ctrl, int pwr, int attn); void pciehp_get_latch_status(struct controller *ctrl, u8 *status); int pciehp_query_power_fault(struct controller *ctrl); -void pciehp_green_led_on(struct controller *ctrl); -void pciehp_green_led_off(struct controller *ctrl); -void pciehp_green_led_blink(struct controller *ctrl); bool pciehp_card_present(struct controller *ctrl); bool pciehp_card_present_or_link_active(struct controller *ctrl); int pciehp_check_link_status(struct controller *ctrl); @@ -190,6 +187,9 @@ int pciehp_get_attention_status(struct hotplug_slot *hotplug_slot, u8 *status); int pciehp_set_raw_indicator_status(struct hotplug_slot *h_slot, u8 status); int pciehp_get_raw_indicator_status(struct hotplug_slot *h_slot, u8 *status); +#define set_power_indicator(ctrl, x) \ + pciehp_set_indicators(ctrl, (x), PCI_EXP_SLTCTL_ATTN_IND_NONE) + static inline const char *slot_name(struct controller *ctrl) { return hotplug_slot_name(&ctrl->hotplug_slot); diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c index 232f7bfcfce9..d0f55f695770 100644 --- a/drivers/pci/hotplug/pciehp_ctrl.c +++ b/drivers/pci/hotplug/pciehp_ctrl.c @@ -65,7 +65,7 @@ static int board_added(struct controller *ctrl) return retval; } - pciehp_green_led_blink(ctrl); + set_power_indicator(ctrl, PCI_EXP_SLTCTL_PWR_IND_BLINK); /* Check link training status */ retval = pciehp_check_link_status(ctrl); @@ -124,7 +124,7 @@ static void remove_board(struct controller *ctrl, bool safe_removal) } /* turn off Green LED */ - pciehp_green_led_off(ctrl); + set_power_indicator(ctrl, PCI_EXP_SLTCTL_PWR_IND_OFF); } static int pciehp_enable_slot(struct controller *ctrl); @@ -311,7 +311,8 @@ static int pciehp_enable_slot(struct controller *ctrl) pm_runtime_get_sync(&ctrl->pcie->port->dev); ret = __pciehp_enable_slot(ctrl); if (ret && ATTN_BUTTN(ctrl)) - pciehp_green_led_off(ctrl); /* may be blinking */ + /* may be blinking */ + set_power_indicator(ctrl, PCI_EXP_SLTCTL_PWR_IND_OFF); pm_runtime_put(&ctrl->pcie->port->dev); mutex_lock(&ctrl->state_lock); diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index eeac2e704c75..9fd8f99132bb 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -439,42 +439,6 @@ void pciehp_set_indicators(struct controller *ctrl, int pwr, int attn) } } -void pciehp_green_led_on(struct controller *ctrl) -{ - if (!PWR_LED(ctrl)) - return; - - pcie_write_cmd_nowait(ctrl, PCI_EXP_SLTCTL_PWR_IND_ON, - PCI_EXP_SLTCTL_PIC); - ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__, - pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, - PCI_EXP_SLTCTL_PWR_IND_ON); -} - -void pciehp_green_led_off(struct controller *ctrl) -{ - if (!PWR_LED(ctrl)) - return; - - pcie_write_cmd_nowait(ctrl, PCI_EXP_SLTCTL_PWR_IND_OFF, - PCI_EXP_SLTCTL_PIC); - ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__, - pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, - PCI_EXP_SLTCTL_PWR_IND_OFF); -} - -void pciehp_green_led_blink(struct controller *ctrl) -{ - if (!PWR_LED(ctrl)) - return; - - pcie_write_cmd_nowait(ctrl, PCI_EXP_SLTCTL_PWR_IND_BLINK, - PCI_EXP_SLTCTL_PIC); - ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__, - pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, - PCI_EXP_SLTCTL_PWR_IND_BLINK); -} - int pciehp_power_on_slot(struct controller *ctrl) { struct pci_dev *pdev = ctrl_dev(ctrl);