From patchwork Sun Aug 11 19:59:41 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: 11089051 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9381F14DB for ; Sun, 11 Aug 2019 20:00:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85D2E27CEA for ; Sun, 11 Aug 2019 20:00:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A31727E71; Sun, 11 Aug 2019 20:00:23 +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=-7.9 required=2.0 tests=BAYES_00,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 0547F27CEA for ; Sun, 11 Aug 2019 20:00:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726053AbfHKUAW (ORCPT ); Sun, 11 Aug 2019 16:00:22 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:33094 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725730AbfHKUAW (ORCPT ); Sun, 11 Aug 2019 16:00:22 -0400 Received: by mail-pg1-f195.google.com with SMTP id n190so7611704pgn.0; Sun, 11 Aug 2019 13:00:21 -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=DEOH8uNw8KONdKDvi8Ngr/ONfB9Xs89RwTe8hFQNqvU=; b=pU7yyIPTuFUVuvCg1SOtUJsfORkS9JxdoHkqEYHNMscPkcC2o2ZmqMCiBu6RCXn+YZ 81XQz4V8NpPuKAFMKI+DMGlC3CUKDlgo9wAciDj41GWiIwCP+gCkcP0vXvh/ZoqlZ54l JwhwRzeQ9Zmk4HvCOCs5QGah/pDXKgYl+NsJfRxG/LVNWvZkGUodj8II+g+Fehg8sSJz 9QTgLo5jMPh0AL1VzoY0v/KJNJF5jpUoeftfQ2Hv3CWDDySr05k5E4WnCASOc4w/jMsd iu/ONGMeGaC/Bcgz1WFrrDakw9bGMJbf7U2rcGDZm578g+n8m7dXt50cwXsexwc7Fu2x 2U5Q== X-Gm-Message-State: APjAAAWreiVgNCsx6rzMZyDsCtzLr+WwkwoAMyTYovZQX2c6GhfS+mCi xR+DAxKkXfvjmwNfj2doHAk= X-Google-Smtp-Source: APXvYqzco74I4qFZOTePjWYhTdcpMFGA/ix5uvj8pCG8UgmR6wgLubXkXNhuG/GoofPTLHNJ2CGkhA== X-Received: by 2002:a65:4243:: with SMTP id d3mr15454210pgq.119.1565553621358; Sun, 11 Aug 2019 13:00:21 -0700 (PDT) Received: from localhost.localdomain (broadband-188-32-48-208.ip.moscow.rt.ru. [188.32.48.208]) by smtp.googlemail.com with ESMTPSA id a3sm106119167pfc.70.2019.08.11.13.00.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 Aug 2019 13:00:20 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Lukas Wunner , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Denis Efremov Subject: [PATCH v2 1/4] PCI: pciehp: Add pciehp_set_indicators() to jointly set LED indicators Date: Sun, 11 Aug 2019 22:59:41 +0300 Message-Id: <20190811195944.23765-2-efremov@linux.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190811195944.23765-1-efremov@linux.com> References: <20190811195944.23765-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 X-Virus-Scanned: ClamAV using ClamSMTP Add pciehp_set_indicators() to set power and attention indicators with a single register write. Thus, avoiding waiting twice for Command Complete. enum pciehp_indicator introduced to switch between the indicators statuses. Signed-off-by: Denis Efremov Reviewed-by: Lukas Wunner --- drivers/pci/hotplug/pciehp.h | 14 ++++++++++++ drivers/pci/hotplug/pciehp_hpc.c | 38 ++++++++++++++++++++++++++++++++ include/uapi/linux/pci_regs.h | 2 ++ 3 files changed, 54 insertions(+) diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h index 8c51a04b8083..17305a6f01f1 100644 --- a/drivers/pci/hotplug/pciehp.h +++ b/drivers/pci/hotplug/pciehp.h @@ -150,6 +150,17 @@ struct controller { #define NO_CMD_CMPL(ctrl) ((ctrl)->slot_cap & PCI_EXP_SLTCAP_NCCS) #define PSN(ctrl) (((ctrl)->slot_cap & PCI_EXP_SLTCAP_PSN) >> 19) +enum pciehp_indicator { + ATTN_NONE = -1, + ATTN_ON = 1, + ATTN_BLINK = 2, + ATTN_OFF = 3, + PWR_NONE = -1, + PWR_ON = 1, + PWR_BLINK = 2, + PWR_OFF = 3, +}; + void pciehp_request(struct controller *ctrl, int action); void pciehp_handle_button_press(struct controller *ctrl); void pciehp_handle_disable_request(struct controller *ctrl); @@ -167,6 +178,9 @@ 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); +void pciehp_set_indicators(struct controller *ctrl, + enum pciehp_indicator pwr, + enum pciehp_indicator 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..5a690b1579ec 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -443,6 +443,44 @@ 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, + enum pciehp_indicator pwr, + enum pciehp_indicator attn) +{ + u16 cmd = 0, mask = 0; + + if ((!PWR_LED(ctrl) || pwr == PWR_NONE) && + (!ATTN_LED(ctrl) || attn == ATTN_NONE)) + return; + + switch (pwr) { + case PWR_ON: + case PWR_BLINK: + case PWR_OFF: + cmd = pwr << PCI_EXP_SLTCTL_PWR_IND_OFFSET; + mask = PCI_EXP_SLTCTL_PIC; + break; + default: + break; + } + + switch (attn) { + case ATTN_ON: + case ATTN_BLINK: + case ATTN_OFF: + cmd |= attn << PCI_EXP_SLTCTL_ATTN_IND_OFFSET; + mask |= PCI_EXP_SLTCTL_AIC; + break; + default: + break; + } + + 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)) diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h index f28e562d7ca8..18722d1f54a0 100644 --- a/include/uapi/linux/pci_regs.h +++ b/include/uapi/linux/pci_regs.h @@ -591,10 +591,12 @@ #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_OFFSET 0x6 /* Attention Indicator Offset */ #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 */ #define PCI_EXP_SLTCTL_PIC 0x0300 /* Power Indicator Control */ +#define PCI_EXP_SLTCTL_PWR_IND_OFFSET 0x8 /* Power Indicator Offset */ #define PCI_EXP_SLTCTL_PWR_IND_ON 0x0100 /* Power Indicator on */ #define PCI_EXP_SLTCTL_PWR_IND_BLINK 0x0200 /* Power Indicator blinking */ #define PCI_EXP_SLTCTL_PWR_IND_OFF 0x0300 /* Power Indicator off */ From patchwork Sun Aug 11 19:59:42 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: 11089053 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B334314DB for ; Sun, 11 Aug 2019 20:00:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A641B27CEA for ; Sun, 11 Aug 2019 20:00:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A65627E71; Sun, 11 Aug 2019 20:00:31 +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=-7.9 required=2.0 tests=BAYES_00,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 3F60A27CEA for ; Sun, 11 Aug 2019 20:00:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725900AbfHKUAa (ORCPT ); Sun, 11 Aug 2019 16:00:30 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:42171 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725730AbfHKUAa (ORCPT ); Sun, 11 Aug 2019 16:00:30 -0400 Received: by mail-pl1-f194.google.com with SMTP id ay6so47114137plb.9; Sun, 11 Aug 2019 13:00: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=LaIHh46yjXhfCVkLKVS3bPQlaeFndy0Zcw4KFCKa1iU=; b=Bz+YIOqAaYOrkb/3r7eTtEKFWEqvRJ3vTUSS714NuwgRWwPvn7qXn4kd2WAN82qwTv bi1wNeaPwSf7ZApu1s3d87908FR/0Ky6ruLnVcMex6hz9j+r0ZP6hbCA1kfYIPnPPk8R jx2ZDrA+lA0YM8/r993pVKY83kwlPDkuPEaNJOXzzO5Xz4+nJM38BQ3ODcidWZEgZPcp FMEFTHMTVxvp1qXvt6rZ+89s0cUE5l+cgzxaAPQf3k0y+TGonKVV+6bOqa9R1oax3tIm Rta5xdG7NZ26alKUpSdLAZP4CL2V/MmClAOoOUi0hKHUWvyUuR02weAMpq13ICAZwrCs QQFQ== X-Gm-Message-State: APjAAAWoJpKkaAUzH8RCiW2+7wO1aKeTzzS7MQH8/S0fSdm4qsF/PUfB K7KAPvvUS+V0/h+3zIw9jV+BzkEBWa8= X-Google-Smtp-Source: APXvYqxPjVz4NOLh+Qxw44GOKy7UZl/eZMA82WZab2BQPfq00c333jbggWy/UzGrHO7FdXBP6WRerQ== X-Received: by 2002:a17:902:b212:: with SMTP id t18mr23071753plr.246.1565553629863; Sun, 11 Aug 2019 13:00:29 -0700 (PDT) Received: from localhost.localdomain (broadband-188-32-48-208.ip.moscow.rt.ru. [188.32.48.208]) by smtp.googlemail.com with ESMTPSA id a3sm106119167pfc.70.2019.08.11.13.00.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 Aug 2019 13:00:29 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Lukas Wunner , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Denis Efremov Subject: [PATCH v2 2/4] PCI: pciehp: Switch LED indicators with a single write Date: Sun, 11 Aug 2019 22:59:42 +0300 Message-Id: <20190811195944.23765-3-efremov@linux.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190811195944.23765-1-efremov@linux.com> References: <20190811195944.23765-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 X-Virus-Scanned: ClamAV using ClamSMTP 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: Lukas Wunner Signed-off-by: Denis Efremov Reviewed-by: Kuppuswamy Sathyanarayanan --- drivers/pci/hotplug/pciehp_ctrl.c | 14 +++++--------- drivers/pci/hotplug/pciehp_hpc.c | 3 +-- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c index 631ced0ab28a..258a4060466d 100644 --- a/drivers/pci/hotplug/pciehp_ctrl.c +++ b/drivers/pci/hotplug/pciehp_ctrl.c @@ -42,8 +42,7 @@ 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, PWR_OFF, ATTN_ON); } /** @@ -90,8 +89,7 @@ static int board_added(struct controller *ctrl) } } - pciehp_green_led_on(ctrl); - pciehp_set_attention_status(ctrl, 0); + pciehp_set_indicators(ctrl, PWR_ON, ATTN_OFF); return 0; err_exit: @@ -172,8 +170,7 @@ 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, PWR_BLINK, ATTN_OFF); schedule_delayed_work(&ctrl->button_work, 5 * HZ); break; case BLINKINGOFF_STATE: @@ -187,12 +184,11 @@ 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, PWR_ON, ATTN_OFF); } else { ctrl->state = OFF_STATE; - pciehp_green_led_off(ctrl); + pciehp_set_indicators(ctrl, PWR_OFF, ATTN_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 5a690b1579ec..68b880bc30db 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -676,8 +676,7 @@ 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, PWR_OFF, ATTN_ON); } /* From patchwork Sun Aug 11 19:59:43 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: 11089055 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7B8FC6C5 for ; Sun, 11 Aug 2019 20:00:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6CEAA20072 for ; Sun, 11 Aug 2019 20:00:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E0BC205F7; Sun, 11 Aug 2019 20:00:44 +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=-7.9 required=2.0 tests=BAYES_00,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 80C9720072 for ; Sun, 11 Aug 2019 20:00:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726519AbfHKUAl (ORCPT ); Sun, 11 Aug 2019 16:00:41 -0400 Received: from mail-pf1-f174.google.com ([209.85.210.174]:41390 "EHLO mail-pf1-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725730AbfHKUAl (ORCPT ); Sun, 11 Aug 2019 16:00:41 -0400 Received: by mail-pf1-f174.google.com with SMTP id 196so1507427pfz.8; Sun, 11 Aug 2019 13:00:41 -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=5zwYEn0EGzt3ihkxPgMtY2Od6wvLZC2PAG88t/1eLAc=; b=D7LlZQNh+4MZhCONrQMAPloInd984ahOAboAGxmzKNSGN1Lb/cCV/2EfWS41kkZcOs IyuhdoNhhk+ZVBQoVo1PK1z1dSMK5GfacWn90xlxFK7dbN25K88DJFy1Amy/3YmwkhJ7 DqeLzb3fn3/bIYwalqJXPBVy/mpS4gD0hMy7078PEHfVFG2ohuAM9XVCKHh4u0lE50O7 26+K9A0iKCTL81jccdFkE+HOhcVog2pKCqpxMZNmpSFd5EfodsO927WPDPyy/DuenLVG P1qgk3RbCHZ+kr/yRUVUUflZBIvVc2Vdcg9FwyRbId7uGL92MZq7gq4rf4Fn+33K3oX9 1K0Q== X-Gm-Message-State: APjAAAVV6FaHDRNdkR/SZTEPTKRRA5f4TRGo77YzUJ36aSazQhSaiA3i zAcinEvpi7BIXN2b6IzZQ9gup5aTW5o= X-Google-Smtp-Source: APXvYqyuBGml8pVT7eEjOB9MThSHpZaDW38yhInYfo3vi3m6W7OZTwZ2XxKmlsZmzk6CcWmbQkgwvg== X-Received: by 2002:a65:514c:: with SMTP id g12mr27364662pgq.76.1565553640938; Sun, 11 Aug 2019 13:00:40 -0700 (PDT) Received: from localhost.localdomain (broadband-188-32-48-208.ip.moscow.rt.ru. [188.32.48.208]) by smtp.googlemail.com with ESMTPSA id a3sm106119167pfc.70.2019.08.11.13.00.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 Aug 2019 13:00:40 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Lukas Wunner , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Denis Efremov Subject: [PATCH v2 3/4] PCI: pciehp: Replace pciehp_set_attention_status() Date: Sun, 11 Aug 2019 22:59:43 +0300 Message-Id: <20190811195944.23765-4-efremov@linux.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190811195944.23765-1-efremov@linux.com> References: <20190811195944.23765-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 X-Virus-Scanned: ClamAV using ClamSMTP This patch replaces pciehp_set_attention_status() with pciehp_set_indicators(). Signed-off-by: Denis Efremov Reviewed-by: Lukas Wunner Reviewed-by: Kuppuswamy Sathyanarayanan --- drivers/pci/hotplug/pciehp.h | 4 +++- drivers/pci/hotplug/pciehp_hpc.c | 25 ------------------------- 2 files changed, 3 insertions(+), 26 deletions(-) diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h index 17305a6f01f1..9a2a2d0db9d2 100644 --- a/drivers/pci/hotplug/pciehp.h +++ b/drivers/pci/hotplug/pciehp.h @@ -181,7 +181,6 @@ void pciehp_get_power_status(struct controller *ctrl, u8 *status); void pciehp_set_indicators(struct controller *ctrl, enum pciehp_indicator pwr, enum pciehp_indicator 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); @@ -200,6 +199,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 pciehp_set_attention_status(ctrl, status) \ + pciehp_set_indicators(ctrl, PWR_NONE, (status == 0 ? ATTN_OFF : status)) + static inline const char *slot_name(struct controller *ctrl) { return hotplug_slot_name(&ctrl->hotplug_slot); diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index 68b880bc30db..fb4bea16063a 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, enum pciehp_indicator pwr, enum pciehp_indicator attn) From patchwork Sun Aug 11 19:59:44 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: 11089057 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 471E014DB for ; Sun, 11 Aug 2019 20:00:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A1F220072 for ; Sun, 11 Aug 2019 20:00:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E30D205F7; Sun, 11 Aug 2019 20:00:48 +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=-7.9 required=2.0 tests=BAYES_00,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 C06E920072 for ; Sun, 11 Aug 2019 20:00:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726548AbfHKUAr (ORCPT ); Sun, 11 Aug 2019 16:00:47 -0400 Received: from mail-pg1-f171.google.com ([209.85.215.171]:41989 "EHLO mail-pg1-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725730AbfHKUAq (ORCPT ); Sun, 11 Aug 2019 16:00:46 -0400 Received: by mail-pg1-f171.google.com with SMTP id t132so48418164pgb.9; Sun, 11 Aug 2019 13:00:46 -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=9Y4XP7JAJyaimCnaOAIX3TqTCdrib5Ua49eEV4fQoIw=; b=iRghUUsUlooUioOUKK6nhun4hMVS0nvwiJkFHGsIgYDGA1wsXBVIOqgrZbUqX9k5l/ xSbaEy7n/23xQKrwEaCEVjsB8WdXyuFm2uqTwZPZZNA/Vlvo+yDw/kcfKdyd4lS2Nsh4 0Vy1aH5h/qo6+zA/cualIs2euOudB/VGef+1KmzUI8fjjuxBdZbV1Vws+/KWK5aYWBGw Ld4M8wPbC+foh4s9maXxBFlxMNd5gCJW8sYo7leYJ8Eoi1P/KJiBtV3tUNHLNgevfbjt hZeAk79lh/ESD+Pf7KtKwf2PFiSTDrwlhDVA9K8/d/wvsWz9UtaTEmyFoPDgbrtgb2xQ GQTg== X-Gm-Message-State: APjAAAU7WJ2rh80DT6OhPKaui46/X9dhN1dDwsq5o2SOyx830ZHr9mHH Gu0oAmCgPGtdckYNmfnuXsRTd6Dx6C4= X-Google-Smtp-Source: APXvYqy/2kOV9B5u3mzwwHoCnwEcO+tMQABwTQADTaADEBVlWhzWIUDDsz8x9YCzgiGkGmKVoLs5cQ== X-Received: by 2002:a17:90a:8985:: with SMTP id v5mr19918219pjn.136.1565553646158; Sun, 11 Aug 2019 13:00:46 -0700 (PDT) Received: from localhost.localdomain (broadband-188-32-48-208.ip.moscow.rt.ru. [188.32.48.208]) by smtp.googlemail.com with ESMTPSA id a3sm106119167pfc.70.2019.08.11.13.00.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 Aug 2019 13:00:45 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Lukas Wunner , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Denis Efremov Subject: [PATCH v2 4/4] PCI: pciehp: Replace pciehp_green_led_{on,off,blink}() Date: Sun, 11 Aug 2019 22:59:44 +0300 Message-Id: <20190811195944.23765-5-efremov@linux.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190811195944.23765-1-efremov@linux.com> References: <20190811195944.23765-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 X-Virus-Scanned: ClamAV using ClamSMTP This patch replaces pciehp_green_led_{on,off,blink}() with pciehp_set_indicators(). Reviewed-by: Lukas Wunner Signed-off-by: Denis Efremov Reviewed-by: Kuppuswamy Sathyanarayanan --- drivers/pci/hotplug/pciehp.h | 12 ++++++++--- drivers/pci/hotplug/pciehp_hpc.c | 36 -------------------------------- 2 files changed, 9 insertions(+), 39 deletions(-) diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h index 9a2a2d0db9d2..6cdcb1ca561f 100644 --- a/drivers/pci/hotplug/pciehp.h +++ b/drivers/pci/hotplug/pciehp.h @@ -183,9 +183,6 @@ void pciehp_set_indicators(struct controller *ctrl, enum pciehp_indicator 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); @@ -202,6 +199,15 @@ int pciehp_get_raw_indicator_status(struct hotplug_slot *h_slot, u8 *status); #define pciehp_set_attention_status(ctrl, status) \ pciehp_set_indicators(ctrl, PWR_NONE, (status == 0 ? ATTN_OFF : status)) +#define pciehp_green_led_on(ctrl) \ + pciehp_set_indicators(ctrl, PWR_ON, ATTN_NONE) + +#define pciehp_green_led_off(ctrl) \ + pciehp_set_indicators(ctrl, PWR_OFF, ATTN_NONE) + +#define pciehp_green_led_blink(ctrl) \ + pciehp_set_indicators(ctrl, PWR_BLINK, ATTN_NONE) + static inline const char *slot_name(struct controller *ctrl) { return hotplug_slot_name(&ctrl->hotplug_slot); diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index fb4bea16063a..8362d24405fd 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -456,42 +456,6 @@ void pciehp_set_indicators(struct controller *ctrl, cmd); } -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);