From patchwork Mon Aug 19 16:06:40 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: 11101339 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 B2DEB1398 for ; Mon, 19 Aug 2019 16:07:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A29F427F94 for ; Mon, 19 Aug 2019 16:07:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 968B6284F5; Mon, 19 Aug 2019 16:07:25 +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 23B7E2852A for ; Mon, 19 Aug 2019 16:07:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727628AbfHSQHY (ORCPT ); Mon, 19 Aug 2019 12:07:24 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:40638 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726211AbfHSQHY (ORCPT ); Mon, 19 Aug 2019 12:07:24 -0400 Received: by mail-wm1-f65.google.com with SMTP id v19so44703wmj.5; Mon, 19 Aug 2019 09:07:22 -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=pSCyhJxea4L6srfYRJAutvNS3KK4aXxYTi6Whyjb/cA=; b=KqTr1I1BCVPCgcdEJiaqEqMW17KiearG5zRgaUiwKMYyXjle+4bMPwhXY0/k6WKB7L aYABRnHsl4UZoe4YHVPyjbv6ryeFfKHUKHAKV1419c0ek/wO9eisXvxwDyq6pXWZzj4K /22gA8E7D/e7RCo5lAipTlICpELyx8eyTXUSoA0zUMJpilmziXozfveW/pldtKYRy0wW 1QVolouTsU1Exj0LMa894yOmKOVODb5cfXD2e4Q9EU9e9VxVS1l4Ggbm6221mkPFuptC lgrXzM9XCUgrpJIZJV1oYHaA2esb3FqmaCCLaYuYkvtmomioVIMxJj5rTVoL3cTEiJ5i 6isA== X-Gm-Message-State: APjAAAX+583oVRUd7E7pKG21euBfZBzCOh8VR0E1qMPcP6fYWCpxCU2i Z31Ry0sieH5IPCYcYb4lZvoFj/fv X-Google-Smtp-Source: APXvYqwakYtiUs+DhugY8neaGBWmUFfUS3kBIG+NTpyFcIiR+mp0sHOyMD0Y5+EDtRVekLwkKvNMIw== X-Received: by 2002:a1c:6087:: with SMTP id u129mr20888429wmb.108.1566230841870; Mon, 19 Aug 2019 09:07:21 -0700 (PDT) Received: from green.intra.ispras.ru (bran.ispras.ru. [83.149.199.196]) by smtp.googlemail.com with ESMTPSA id b136sm32442189wme.18.2019.08.19.09.07.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2019 09:07:21 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Denis Efremov , Lukas Wunner , sathyanarayanan kuppuswamy , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/4] PCI: pciehp: Add pciehp_set_indicators() to jointly set LED indicators Date: Mon, 19 Aug 2019 19:06:40 +0300 Message-Id: <20190819160643.27998-2-efremov@linux.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190819160643.27998-1-efremov@linux.com> References: <20190819160643.27998-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. Signed-off-by: Denis Efremov --- drivers/pci/hotplug/pciehp.h | 1 + drivers/pci/hotplug/pciehp_hpc.c | 29 +++++++++++++++++++++++++++++ include/uapi/linux/pci_regs.h | 2 ++ 3 files changed, 32 insertions(+) diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h index 8c51a04b8083..0e272bf3deb4 100644 --- a/drivers/pci/hotplug/pciehp.h +++ b/drivers/pci/hotplug/pciehp.h @@ -167,6 +167,7 @@ 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, 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..5474b9854a7f 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -443,6 +443,35 @@ 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)) + switch (pwr) { + case PCI_EXP_SLTCTL_PWR_IND_ON: + case PCI_EXP_SLTCTL_PWR_IND_BLINK: + case PCI_EXP_SLTCTL_PWR_IND_OFF: + cmd |= pwr; + mask |= PCI_EXP_SLTCTL_PIC; + } + + if (ATTN_LED(ctrl)) + switch (attn) { + case PCI_EXP_SLTCTL_ATTN_IND_ON: + case PCI_EXP_SLTCTL_ATTN_IND_BLINK: + case PCI_EXP_SLTCTL_ATTN_IND_OFF: + 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)) diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h index f28e562d7ca8..291788b58f3a 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_NONE 0x0 /* Attention Indicator noop */ #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_NONE 0x0 /* Power Indicator noop */ #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 Mon Aug 19 16:06: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: 11101343 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 1572A174A for ; Mon, 19 Aug 2019 16:07:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0565B288CA for ; Mon, 19 Aug 2019 16:07:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ED92628915; Mon, 19 Aug 2019 16:07: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 1D180288CA for ; Mon, 19 Aug 2019 16:07:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727820AbfHSQH0 (ORCPT ); Mon, 19 Aug 2019 12:07:26 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:33474 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727808AbfHSQHZ (ORCPT ); Mon, 19 Aug 2019 12:07:25 -0400 Received: by mail-wm1-f65.google.com with SMTP id p77so364398wme.0; Mon, 19 Aug 2019 09:07:24 -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=6fBWOoTnMQEPZRIQlIOv38c83RVBeb0n7h4D/lIFHhY=; b=QUTxfzt1MvbfVJA8m2pLbG0PBLVn9Tmwy5QaYRW/smRvrCVMrYG8YZq9j7xODUKPfu nkIRZsBml0ss8OHpFt66a+mWXdOgeuor8KVdiNJ1JRmYCg1E3gZriesyawcz7UyWE/q7 yeAwAAvDRhTtY0WLhYeI0nxbJOsuaCmDnGLDHYxxB/oYno5GB/z7Byq1iY+4N431WQ+z gC3Aq0UrvLMia9j65Uf0xYdCbnMEM6cmRy0IFE4qt2ptp/5Bl8p3+7bHpP0IM+KH9tfK DwWo6FtaijKzjjgyh30pamHXeALbISLtQCkomcNOVXaNjv5AUEmodw49OTE4fV9PSxqS 3Gnw== X-Gm-Message-State: APjAAAVR0k9ngHSkJV3vRCHdlpHDmo7Fu+kKAK1yMBWmplAAKLjOROtk l2TF/TcgQOyaFWZyAbaLxDUt+Bqd X-Google-Smtp-Source: APXvYqyy3iunIi0iSV/oXYaYrEvGxgsax9NxRmtX3rcCpjL6tpqGEsS55kbdXozMOm+VfpzCBFzkCQ== X-Received: by 2002:a1c:5402:: with SMTP id i2mr21261549wmb.41.1566230843726; Mon, 19 Aug 2019 09:07:23 -0700 (PDT) Received: from green.intra.ispras.ru (bran.ispras.ru. [83.149.199.196]) by smtp.googlemail.com with ESMTPSA id b136sm32442189wme.18.2019.08.19.09.07.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2019 09:07:23 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Denis Efremov , Lukas Wunner , sathyanarayanan kuppuswamy , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/4] PCI: pciehp: Switch LED indicators with a single write Date: Mon, 19 Aug 2019 19:06:41 +0300 Message-Id: <20190819160643.27998-3-efremov@linux.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190819160643.27998-1-efremov@linux.com> References: <20190819160643.27998-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: Kuppuswamy Sathyanarayanan Reviewed-by: Lukas Wunner Signed-off-by: Denis Efremov Reviewed-by: Kuppuswamy Sathyanarayanan --- 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 5474b9854a7f..aa4252d11be2 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -667,8 +667,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 Mon Aug 19 16:06: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: 11101341 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 AB828174A for ; Mon, 19 Aug 2019 16:07:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B24028396 for ; Mon, 19 Aug 2019 16:07:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F1F9283AF; Mon, 19 Aug 2019 16:07:29 +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 245B22890A for ; Mon, 19 Aug 2019 16:07:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727859AbfHSQH2 (ORCPT ); Mon, 19 Aug 2019 12:07:28 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:34132 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726211AbfHSQH1 (ORCPT ); Mon, 19 Aug 2019 12:07:27 -0400 Received: by mail-wr1-f66.google.com with SMTP id s18so9314512wrn.1; Mon, 19 Aug 2019 09:07:26 -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=ZlCirgQ1m4IWeI3/PKcAVhZrtcd45ruBHRKNo3AHfnA=; b=G10vzs1fyM6aNKHJIw/JDXmnIK9p6ta+UnEGJIM3fZ7my4jflkjknKXq/cd08J5aem ZMN5RqqQWb09yoXilsiq2XaKpFkBt0Bn4Ai55IVaT+YbsgcHsXOg06wJMIKMlWsOD5Kg juliDpxtHQGzawP+oqE+VCZhBIlrfwO1EPPPM9ZOS/tuU3B1cgWvFxq9QVT1GW9YNZoQ 3527D4qAIAJOpNu8cLFrrkK6vI12EmHrdaoJY4w1vnYIO1Bl1jaXYlU8b2Y5KpWDA7hi WvBa4g7RiEfmIMzg/IDCnjBmQt/j1igF0FN+HIa+w1IVC3OaiWBaoeH1FWffSYmCcD08 q+EQ== X-Gm-Message-State: APjAAAUIeEaCVat5bRPouUMj5XkE8/RgndLzybW69Mu0E3+brwwCkUor bbuHAk+6axW8aOOuBPxyT4Y= X-Google-Smtp-Source: APXvYqyOHvccCAKuQaXP7eVoQtEHRq3+NRtFn3BtfUF64z+8jI95pQ2clcquWi6umwMkzDIoR3LlOg== X-Received: by 2002:adf:dfc4:: with SMTP id q4mr27971559wrn.54.1566230845737; Mon, 19 Aug 2019 09:07:25 -0700 (PDT) Received: from green.intra.ispras.ru (bran.ispras.ru. [83.149.199.196]) by smtp.googlemail.com with ESMTPSA id b136sm32442189wme.18.2019.08.19.09.07.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2019 09:07:25 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Denis Efremov , Lukas Wunner , sathyanarayanan kuppuswamy , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 3/4] PCI: pciehp: Remove pciehp_set_attention_status() Date: Mon, 19 Aug 2019 19:06:42 +0300 Message-Id: <20190819160643.27998-4-efremov@linux.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190819160643.27998-1-efremov@linux.com> References: <20190819160643.27998-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 Remove pciehp_set_attention_status() and use pciehp_set_indicators() instead, since the code is mostly the same. Signed-off-by: Denis Efremov Reviewed-by: Kuppuswamy Sathyanarayanan --- 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 0e272bf3deb4..acda513f37d7 100644 --- a/drivers/pci/hotplug/pciehp.h +++ b/drivers/pci/hotplug/pciehp.h @@ -168,7 +168,6 @@ 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, 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 aa4252d11be2..8f894fd5cd27 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 291788b58f3a..27d9f5bc1812 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_NONE 0x0 /* Attention Indicator noop */ #define PCI_EXP_SLTCTL_ATTN_IND_ON 0x0040 /* Attention Indicator on */ #define PCI_EXP_SLTCTL_ATTN_IND_BLINK 0x0080 /* Attention Indicator blinking */ From patchwork Mon Aug 19 16:06: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: 11101345 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 139F21398 for ; Mon, 19 Aug 2019 16:07:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03E81209CD for ; Mon, 19 Aug 2019 16:07:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC456288CA; Mon, 19 Aug 2019 16:07:34 +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 597A8285AB for ; Mon, 19 Aug 2019 16:07:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726211AbfHSQHd (ORCPT ); Mon, 19 Aug 2019 12:07:33 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:43394 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727865AbfHSQH3 (ORCPT ); Mon, 19 Aug 2019 12:07:29 -0400 Received: by mail-wr1-f65.google.com with SMTP id y8so9283962wrn.10; Mon, 19 Aug 2019 09:07:28 -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=J6GaCUg1JsCqoVd2udtQCNNU0NqEG0Fb+1qaGVREJyo=; b=LRCU/hIqszhr6EsL6Urrdq95c1haUOd4X8p+Xnry9Fjn3xVnHKvp4uQiZ6hRGjHO2L Uzgq08TzjwmEFCozs5IFFD0mzipQYZZHDVLYIKSU7NC6HGXW8LZv6Et4RMAi4BsXk3MH CiawXsYuKo19Nl0RmWQZsh73s3Z2g/cvPmGkuBD4UzXcgPlKeDIZXbp3Wp75sOdRqyjz YTqSh9gslENP1ituEhufEl07GFFhAAPmSR8zbO8E/TbsbkEgVSCsgNMVMRerdzpCBxOL mQQSykhsNJKC3CqpKBz5yvb97Qv8FGpbfuc6wYIhp+EIOxmRgZY3u6+/UqzMIONS5QBB g1SQ== X-Gm-Message-State: APjAAAVPJjBrVLPFN1BBHLzzk0gdXYQwDL21e8PJxjuDz6J/vZp9qau2 v4DQ9OOypL+1PQdYQMg53OU= X-Google-Smtp-Source: APXvYqxxA9WgM8LziEo1y//g/56kvEfbFae6gbGgxCszx/RG7LMfuEvwuvK8rlniYbHxTAco8T5Mvw== X-Received: by 2002:adf:ce8d:: with SMTP id r13mr20854901wrn.37.1566230847978; Mon, 19 Aug 2019 09:07:27 -0700 (PDT) Received: from green.intra.ispras.ru (bran.ispras.ru. [83.149.199.196]) by smtp.googlemail.com with ESMTPSA id b136sm32442189wme.18.2019.08.19.09.07.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2019 09:07:27 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Denis Efremov , Lukas Wunner , sathyanarayanan kuppuswamy , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 4/4] PCI: pciehp: Remove pciehp_green_led_{on,off,blink}() Date: Mon, 19 Aug 2019 19:06:43 +0300 Message-Id: <20190819160643.27998-5-efremov@linux.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190819160643.27998-1-efremov@linux.com> References: <20190819160643.27998-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 Remove pciehp_green_led_{on,off,blink}() and use pciehp_set_indicators() instead, since the code is mostly the same. Signed-off-by: Denis Efremov Reviewed-by: Kuppuswamy Sathyanarayanan --- drivers/pci/hotplug/pciehp.h | 3 --- drivers/pci/hotplug/pciehp_ctrl.c | 12 ++++++++--- drivers/pci/hotplug/pciehp_hpc.c | 36 ------------------------------- 3 files changed, 9 insertions(+), 42 deletions(-) diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h index acda513f37d7..da429345cf70 100644 --- a/drivers/pci/hotplug/pciehp.h +++ b/drivers/pci/hotplug/pciehp.h @@ -170,9 +170,6 @@ void pciehp_get_power_status(struct controller *ctrl, u8 *status); 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); diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c index 232f7bfcfce9..862fe86e87cc 100644 --- a/drivers/pci/hotplug/pciehp_ctrl.c +++ b/drivers/pci/hotplug/pciehp_ctrl.c @@ -65,7 +65,9 @@ static int board_added(struct controller *ctrl) return retval; } - pciehp_green_led_blink(ctrl); + pciehp_set_indicators(ctrl, PCI_EXP_SLTCTL_PWR_IND_BLINK, + PCI_EXP_SLTCTL_ATTN_IND_NONE); + /* Check link training status */ retval = pciehp_check_link_status(ctrl); @@ -124,7 +126,9 @@ static void remove_board(struct controller *ctrl, bool safe_removal) } /* turn off Green LED */ - pciehp_green_led_off(ctrl); + pciehp_set_indicators(ctrl, PCI_EXP_SLTCTL_PWR_IND_OFF, + PCI_EXP_SLTCTL_ATTN_IND_NONE); + } static int pciehp_enable_slot(struct controller *ctrl); @@ -311,7 +315,9 @@ 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 */ + pciehp_set_indicators(ctrl, PCI_EXP_SLTCTL_PWR_IND_OFF, + PCI_EXP_SLTCTL_ATTN_IND_NONE); 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 8f894fd5cd27..9dc1ecd703b9 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -447,42 +447,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);