From patchwork Thu Aug 15 16:59:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11096131 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 114A16C5 for ; Thu, 15 Aug 2019 17:00:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 019512887B for ; Thu, 15 Aug 2019 17:00:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9C4A28837; Thu, 15 Aug 2019 17:00:26 +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=-8.0 required=2.0 tests=BAYES_00,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 6821128650 for ; Thu, 15 Aug 2019 17:00:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730643AbfHORA0 (ORCPT ); Thu, 15 Aug 2019 13:00:26 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:43693 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729084AbfHORAZ (ORCPT ); Thu, 15 Aug 2019 13:00:25 -0400 Received: by mail-pf1-f195.google.com with SMTP id v12so1601440pfn.10; Thu, 15 Aug 2019 10:00:24 -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=3nK98dgFoyjBvX7GN5x7UY25xQPiZUMPFR2l0frTXk0=; b=VNWxlaGzdZIIppEwlc6lC084plrHsbKyGgFtdhKT8ZMPe4co79SVcZUyjwoqShL5OB Tc7V90bjULG6N94KNiBfPkxboAJniGi/vFYnJGOqe50RWxAZk/IcTv8wZtiVxveTwc93 y8BfYXmwcCu/LQ40wzlR59tHhSsEny8krqMV2eUjo3D8JM0GOl5KgzcWSbsKri4STtpT eZKj/N9qLz/6cLCRaC+7RTFV8ZtEQMTc3n0bTJPGPEgFK2Tjtq3KZKYBS5aYTb3Ij91/ KySPJgAp/jq8n1/H0SnH8N7nja5eJZs4f8MFgt3ej7Pm7GIj/CmJxoPdqtCzUKDMgPpA QvyA== 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=3nK98dgFoyjBvX7GN5x7UY25xQPiZUMPFR2l0frTXk0=; b=dPPr2X7+3R2QX4y9AcjNnk0utp9BF/eOTjMKAvv3Oy65GnZ/FPlo5n0MC0IKleW1jC mGw2KbqyBjLSOJy3HvsOJInRf74j7VSJ8tga9S8WwQOh/qVgNwbmApAVgc83F1NrsNYV KRd8k+BB/Og7rgs3g/lfoRCJr+zKxMq9tSu4G4MNYSXMxMr7x8V8Ac5NMXg0uMBjxorc P0+qKd6XcKwhx3QaktGEDEZHzHpk7wyZuqaiO92rbqsFY19Pa9dsW8JWC0MrHvSf7YEC RhP1D2Xy/2msSPQDP1s2VnW05CmpkIlB+u0KBGsCFuIqJ/iklqtivgzRocZD3rm+jBxE Sy4Q== X-Gm-Message-State: APjAAAUx/JfEwdmU3cRgHWCz/srSaMq13ZP6EwVBloRgWmsYMqKEOCne GsvlgeJBNjGwhlPV81boO1dlJMVH3Sc= X-Google-Smtp-Source: APXvYqwpsnTtERDRec76lXOv668Lb26b4nhGOo3/y6Qa6tILPiCrbP784XJhT6Esw43s+z3WtZ5c4A== X-Received: by 2002:a62:107:: with SMTP id 7mr6485812pfb.4.1565888424464; Thu, 15 Aug 2019 10:00:24 -0700 (PDT) Received: from mita-MS-7A45.lan ([240f:34:212d:1:12:b19f:559d:7305]) by smtp.gmail.com with ESMTPSA id b30sm3943942pfr.117.2019.08.15.10.00.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Aug 2019 10:00:23 -0700 (PDT) From: Akinobu Mita To: linux-block@vger.kernel.org, linux-leds@vger.kernel.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org Cc: Akinobu Mita , Frank Steiner , Jacek Anaszewski , Pavel Machek , Dan Murphy , Jens Axboe , "James E.J. Bottomley" , "Martin K. Petersen" , Hannes Reinecke Subject: [PATCH v4 1/5] block: umem: rename LED_* macros to MEMCTRL_LED_* Date: Fri, 16 Aug 2019 01:59:55 +0900 Message-Id: <1565888399-21550-2-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1565888399-21550-1-git-send-email-akinobu.mita@gmail.com> References: <1565888399-21550-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The umem driver defines LED_* macros for MEMCTRLCMD_LEDCTRL register values. The LED_OFF and LED_ON macros conflict with the LED subsystem's LED_OFF and LED_ON enums. This renames these LED_* macros to MEMCTRL_LED_* in umem driver. Cc: Frank Steiner Cc: Jacek Anaszewski Cc: Pavel Machek Cc: Dan Murphy Cc: Jens Axboe Cc: "James E.J. Bottomley" Cc: "Martin K. Petersen" Cc: Hannes Reinecke Acked-by: Pavel Machek Signed-off-by: Akinobu Mita --- drivers/block/umem.c | 20 ++++++++++---------- drivers/block/umem.h | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/block/umem.c b/drivers/block/umem.c index 1f3f9e0..1109308 100644 --- a/drivers/block/umem.c +++ b/drivers/block/umem.c @@ -167,14 +167,14 @@ static int set_userbit(struct cardinfo *card, int bit, unsigned char state) } /* - * NOTE: For the power LED, use the LED_POWER_* macros since they differ + * NOTE: For the power LED, use the MEMCTRL_LED_POWER_* macros since they differ */ static void set_led(struct cardinfo *card, int shift, unsigned char state) { unsigned char led; led = readb(card->csr_remap + MEMCTRLCMD_LEDCTRL); - if (state == LED_FLIP) + if (state == MEMCTRL_LED_FLIP) led ^= (1<desc[page->headcnt]; writel(0, card->csr_remap + DMA_PCI_ADDR); @@ -477,7 +477,7 @@ static void process_page(unsigned long data) } if (debug & DEBUG_LED_ON_TRANSFER) - set_led(card, LED_REMOVE, LED_OFF); + set_led(card, MEMCTRL_LED_REMOVE, MEMCTRL_LED_OFF); if (card->check_batteries) { card->check_batteries = 0; @@ -652,13 +652,13 @@ HW_TRACE(0x36); static void set_fault_to_battery_status(struct cardinfo *card) { if (card->battery[0].good && card->battery[1].good) - set_led(card, LED_FAULT, LED_OFF); + set_led(card, MEMCTRL_LED_FAULT, MEMCTRL_LED_OFF); else if (card->battery[0].warned || card->battery[1].warned) - set_led(card, LED_FAULT, LED_ON); + set_led(card, MEMCTRL_LED_FAULT, MEMCTRL_LED_ON); else if (!card->battery[0].good && !card->battery[1].good) - set_led(card, LED_FAULT, LED_FLASH_7_0); + set_led(card, MEMCTRL_LED_FAULT, MEMCTRL_LED_FLASH_7_0); else - set_led(card, LED_FAULT, LED_FLASH_3_5); + set_led(card, MEMCTRL_LED_FAULT, MEMCTRL_LED_FLASH_3_5); } static void init_battery_timer(void); @@ -919,8 +919,8 @@ static int mm_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) } /* Clear the LED's we control */ - set_led(card, LED_REMOVE, LED_OFF); - set_led(card, LED_FAULT, LED_OFF); + set_led(card, MEMCTRL_LED_REMOVE, MEMCTRL_LED_OFF); + set_led(card, MEMCTRL_LED_FAULT, MEMCTRL_LED_OFF); batt_status = readb(card->csr_remap + MEMCTRLSTATUS_BATTERY); diff --git a/drivers/block/umem.h b/drivers/block/umem.h index 5838497..cc9cb37 100644 --- a/drivers/block/umem.h +++ b/drivers/block/umem.h @@ -32,16 +32,16 @@ #define MEM_2_GB 0xe0 #define MEMCTRLCMD_LEDCTRL 0x08 -#define LED_REMOVE 2 -#define LED_FAULT 4 -#define LED_POWER 6 -#define LED_FLIP 255 -#define LED_OFF 0x00 -#define LED_ON 0x01 -#define LED_FLASH_3_5 0x02 -#define LED_FLASH_7_0 0x03 -#define LED_POWER_ON 0x00 -#define LED_POWER_OFF 0x01 +#define MEMCTRL_LED_REMOVE 2 +#define MEMCTRL_LED_FAULT 4 +#define MEMCTRL_LED_POWER 6 +#define MEMCTRL_LED_FLIP 255 +#define MEMCTRL_LED_OFF 0x00 +#define MEMCTRL_LED_ON 0x01 +#define MEMCTRL_LED_FLASH_3_5 0x02 +#define MEMCTRL_LED_FLASH_7_0 0x03 +#define MEMCTRL_LED_POWER_ON 0x00 +#define MEMCTRL_LED_POWER_OFF 0x01 #define USER_BIT1 0x01 #define USER_BIT2 0x02 From patchwork Thu Aug 15 16:59:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11096135 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 B9AA3112C for ; Thu, 15 Aug 2019 17:00:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A631928833 for ; Thu, 15 Aug 2019 17:00:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9ACB828892; Thu, 15 Aug 2019 17: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=-8.0 required=2.0 tests=BAYES_00,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 3609C28837 for ; Thu, 15 Aug 2019 17:00:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730703AbfHORAa (ORCPT ); Thu, 15 Aug 2019 13:00:30 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:39051 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730645AbfHORAa (ORCPT ); Thu, 15 Aug 2019 13:00:30 -0400 Received: by mail-pf1-f195.google.com with SMTP id f17so1614935pfn.6; Thu, 15 Aug 2019 10:00:30 -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=xxf/HVq1oOiY+aojPeB31TYL+w9kpCEUs73K8+rOlTU=; b=IKpar9/n3E44vPKBFMEBRCSPPacAA08WCi64jmrLiCYzafoWZKeT5jkmqbfwy1Vfz9 l6q2/uqdeiqcbEhc9OKpxSHmi88ufvosCfllwVLWVOLup0q9OuEvT/JQ9mMmO0tkbuGg qJK3NhMD7R0w5caFyNt2QpCfnFAciclDH+HZLpb1MJxl9g66qdlOyBIGLHtoUzFUChXy RgU3vHu0aNUhS0YdoddUQ/Ep6sbgGDf00kV/zxu+n3ttQ+V6SPey8W+lIvgh8lxqiG3+ I7qEA9fWep6u0HmRfL5CrzyJ17X7FuvNKXErE7wat8oxuMQqdkSJZ6eAiROZp/vzWGym 5caw== 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=xxf/HVq1oOiY+aojPeB31TYL+w9kpCEUs73K8+rOlTU=; b=CFYc6/vH1VsbeILpJy7X/IsxeOADFDikdgbYOBFl45Gw53+fxwVfC78uMY/H1o3sYS XMXxiK8NRtvajdyyLRr5al0XJ+7Rppq9AK6/5S0Fzip9UnbJcZ52IKFKLIAzrDB/1csP /2EUCYLDEVLiUYNH6oerIX46WTP/cnMNS7n6S0AQzffLvukOhmIUrw6UVBIu4ahkxAlb U1P7Db/fh5dHLhk0aCDeZ8Bg3OPcJ7t/h3LMK6usoHTOV0xzn7R62nGlIfqDeGETxrEo hOdg661oyq3GEMx7FDUxv5PpN7iZaCEXti2rPwUjwzZXyqnVtMEqeT7C/xRG3VtoziM4 zQJw== X-Gm-Message-State: APjAAAVp/TkBp1Ohjqh3mlRWAdrbQtWnP1cOgzK8eSScL1MG9gGXD45u 9I9BSLi0CAUKwPtn8APkJm62kTAxUA8= X-Google-Smtp-Source: APXvYqygZQaoBkNFKnu6+kJdA4Cp0uFcK7UCbZ8o2eiLuEO382GKfs4l97MbwVEoly7Aw+BlD5Kt8w== X-Received: by 2002:a17:90a:f484:: with SMTP id bx4mr3115007pjb.61.1565888429737; Thu, 15 Aug 2019 10:00:29 -0700 (PDT) Received: from mita-MS-7A45.lan ([240f:34:212d:1:12:b19f:559d:7305]) by smtp.gmail.com with ESMTPSA id b30sm3943942pfr.117.2019.08.15.10.00.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Aug 2019 10:00:29 -0700 (PDT) From: Akinobu Mita To: linux-block@vger.kernel.org, linux-leds@vger.kernel.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org Cc: Akinobu Mita , Frank Steiner , Jacek Anaszewski , Pavel Machek , Dan Murphy , Jens Axboe , "James E.J. Bottomley" , "Martin K. Petersen" , Hannes Reinecke Subject: [PATCH v4 2/5] scsi: mvsas: rename LED_* enums to SGPIO_LED_* Date: Fri, 16 Aug 2019 01:59:56 +0900 Message-Id: <1565888399-21550-3-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1565888399-21550-1-git-send-email-akinobu.mita@gmail.com> References: <1565888399-21550-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The mvsas driver declares LED_* enums for enum sgpio_led_status. The LED_OFF and LED_ON enums cause redeclaration of enumerator with the LED subsystem's LED_OFF and LED_ON enums. This adds 'SGPIO_' prefix to these enums in mvsas driver. Cc: Frank Steiner Cc: Jacek Anaszewski Cc: Pavel Machek Cc: Dan Murphy Cc: Jens Axboe Cc: "James E.J. Bottomley" Cc: "Martin K. Petersen" Cc: Hannes Reinecke Reviewed-by: Hannes Reinecke Acked-by: Pavel Machek Signed-off-by: Akinobu Mita --- drivers/scsi/mvsas/mv_94xx.c | 2 +- drivers/scsi/mvsas/mv_94xx.h | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/scsi/mvsas/mv_94xx.c b/drivers/scsi/mvsas/mv_94xx.c index fc0b8eb..3558a625 100644 --- a/drivers/scsi/mvsas/mv_94xx.c +++ b/drivers/scsi/mvsas/mv_94xx.c @@ -1085,7 +1085,7 @@ static int mvs_94xx_gpio_write(struct mvs_prv_info *mvs_prv, block &= ~((0x7 << MVS_SGPIO_DCTRL_ACT_SHIFT) << driveshift); /* hardwire activity bit to SOF */ - block |= LED_BLINKA_SOF << ( + block |= SGPIO_LED_BLINKA_SOF << ( MVS_SGPIO_DCTRL_ACT_SHIFT + driveshift); break; diff --git a/drivers/scsi/mvsas/mv_94xx.h b/drivers/scsi/mvsas/mv_94xx.h index a243182..2c96ff1 100644 --- a/drivers/scsi/mvsas/mv_94xx.h +++ b/drivers/scsi/mvsas/mv_94xx.h @@ -275,23 +275,23 @@ enum sgpio_registers { }; enum sgpio_led_status { - LED_OFF = 0, - LED_ON = 1, - LED_BLINKA = 2, - LED_BLINKA_INV = 3, - LED_BLINKA_SOF = 4, - LED_BLINKA_EOF = 5, - LED_BLINKB = 6, - LED_BLINKB_INV = 7, + SGPIO_LED_OFF = 0, + SGPIO_LED_ON = 1, + SGPIO_LED_BLINKA = 2, + SGPIO_LED_BLINKA_INV = 3, + SGPIO_LED_BLINKA_SOF = 4, + SGPIO_LED_BLINKA_EOF = 5, + SGPIO_LED_BLINKB = 6, + SGPIO_LED_BLINKB_INV = 7, }; -#define DEFAULT_SGPIO_BITS ((LED_BLINKA_SOF << \ +#define DEFAULT_SGPIO_BITS ((SGPIO_LED_BLINKA_SOF << \ MVS_SGPIO_DCTRL_ACT_SHIFT) << (8 * 3) | \ - (LED_BLINKA_SOF << \ + (SGPIO_LED_BLINKA_SOF << \ MVS_SGPIO_DCTRL_ACT_SHIFT) << (8 * 2) | \ - (LED_BLINKA_SOF << \ + (SGPIO_LED_BLINKA_SOF << \ MVS_SGPIO_DCTRL_ACT_SHIFT) << (8 * 1) | \ - (LED_BLINKA_SOF << \ + (SGPIO_LED_BLINKA_SOF << \ MVS_SGPIO_DCTRL_ACT_SHIFT) << (8 * 0)) /* From patchwork Thu Aug 15 16:59:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11096139 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 93A856C5 for ; Thu, 15 Aug 2019 17:00:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 844272887B for ; Thu, 15 Aug 2019 17:00:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7865D288BD; Thu, 15 Aug 2019 17:00:37 +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=-8.0 required=2.0 tests=BAYES_00,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 BDAD62887B for ; Thu, 15 Aug 2019 17:00:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730730AbfHORAg (ORCPT ); Thu, 15 Aug 2019 13:00:36 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:37970 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730645AbfHORAg (ORCPT ); Thu, 15 Aug 2019 13:00:36 -0400 Received: by mail-pg1-f195.google.com with SMTP id e11so1548505pga.5; Thu, 15 Aug 2019 10:00:35 -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=tuWIrZdeip2SwEu1Up/Cgz1RXLdTxno3PAy39P4ux3s=; b=Sc/hFVtBa1kDleXupt6VxqKCVfqsUCGiT9MBL7ZrtpWFeW6BSE5VfigLZwVyr43zG6 QkyaiQ6jcXANdaaRSh+raVNgY+hdDkbYwmeVMk3Tc+Aky0yG/Gx5gl7b+BSMoU6F8Zte i6YaOhvWC665Gdx4g8/k4Y7TzaSme50hfOlKa83FtQXwNzUybIO447o7LpgyGHK9Yw/d 0GHp/0UiNtYma83x9/390TkDAPpsbDGtMH2pUiZU1EPT4w88+Ywd+TDdq8mvS9KwWW4n 7S2A16bbwmEzdTqg32w2VzPxtvhoX4ua1HhuRqffsCd50PfQKS2KKq8Ca9r+39nnQXtf t3oA== 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=tuWIrZdeip2SwEu1Up/Cgz1RXLdTxno3PAy39P4ux3s=; b=Z0ZjpPhNnEhm1Gvt6Km63g8P/XeV4ou1sl/MPUyWM8d+ufTAzDzSsYL0f23T8XUSNL aFNU/FY+ilcvlgkMYUqrbQUJGxN969MRalcURR782S6j0eJvRhGiulgCoj8s4dWRqx9G HV4VtZMFkrOo5V/YXNB1Z1SNbHyIh1s1FdTzfb9ar/aoSCZ0IX4fQGB2Vr5RUyDeZf7/ pHZJjCrCSUh7RQz9nZHoBd0vAwW7IL+t/VXDL7cM/yM7yUQ18UDyFl8ULSKa0HD67pcL mMvmTP360AN1kw86OXiATs+9zIlQkhwvDbNXrSy5skZey9FIevf/LJTUu94BxHPn42Gb 82wA== X-Gm-Message-State: APjAAAVxSh7sXLh7X0L7VHzt7rXaWLtNiJsIIrjgcLkFShtgp0pTnTmp 8zXZ4VCJhkT3h3Fqr+x+2YcBhz4+66k= X-Google-Smtp-Source: APXvYqyEb6YHlds52FFvJadwAnFCxPLcpKH0blH2HteX/ZuPbIT3I2s2dyxATa45s8g5HYhSPABLvQ== X-Received: by 2002:a63:f91c:: with SMTP id h28mr4023147pgi.397.1565888435282; Thu, 15 Aug 2019 10:00:35 -0700 (PDT) Received: from mita-MS-7A45.lan ([240f:34:212d:1:12:b19f:559d:7305]) by smtp.gmail.com with ESMTPSA id b30sm3943942pfr.117.2019.08.15.10.00.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Aug 2019 10:00:34 -0700 (PDT) From: Akinobu Mita To: linux-block@vger.kernel.org, linux-leds@vger.kernel.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org Cc: Akinobu Mita , Frank Steiner , Jacek Anaszewski , Pavel Machek , Dan Murphy , Jens Axboe , "James E.J. Bottomley" , "Martin K. Petersen" , GOTO Masanori , YOKOTA Hiroshi , Hannes Reinecke Subject: [PATCH v4 3/5] scsi: nsp32: rename LED_* macros to EXT_PORT_LED_* Date: Fri, 16 Aug 2019 01:59:57 +0900 Message-Id: <1565888399-21550-4-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1565888399-21550-1-git-send-email-akinobu.mita@gmail.com> References: <1565888399-21550-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The nsp32 driver defines LED_ON and LED_OFF macros for EXT_PORT_DDR or EXT_PORT register values. The LED_OFF and LED_ON macros conflict with the LED subsystem's LED_OFF and LED_ON enums. This renames these LED_* macros to EXT_PORT_LED_* in nsp32 driver. Cc: Frank Steiner Cc: Jacek Anaszewski Cc: Pavel Machek Cc: Dan Murphy Cc: Jens Axboe Cc: "James E.J. Bottomley" Cc: "Martin K. Petersen" Cc: GOTO Masanori Cc: YOKOTA Hiroshi Cc: Hannes Reinecke Reviewed-by: Hannes Reinecke Acked-by: Pavel Machek Signed-off-by: Akinobu Mita --- drivers/scsi/nsp32.c | 7 ++++--- drivers/scsi/nsp32.h | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c index 70db792..8170358 100644 --- a/drivers/scsi/nsp32.c +++ b/drivers/scsi/nsp32.c @@ -763,7 +763,8 @@ static int nsp32_arbitration(struct scsi_cmnd *SCpnt, unsigned int base) if (arbit & ARBIT_WIN) { /* Arbitration succeeded */ SCpnt->result = DID_OK << 16; - nsp32_index_write1(base, EXT_PORT, LED_ON); /* PCI LED on */ + /* PCI LED on */ + nsp32_index_write1(base, EXT_PORT, EXT_PORT_LED_ON); } else if (arbit & ARBIT_FAIL) { /* Arbitration failed */ SCpnt->result = DID_BUS_BUSY << 16; @@ -1137,8 +1138,8 @@ static int nsp32hw_init(nsp32_hw_data *data) nsp32_write2(base, IRQ_CONTROL, 0); /* PCI LED off */ - nsp32_index_write1(base, EXT_PORT_DDR, LED_OFF); - nsp32_index_write1(base, EXT_PORT, LED_OFF); + nsp32_index_write1(base, EXT_PORT_DDR, EXT_PORT_LED_OFF); + nsp32_index_write1(base, EXT_PORT, EXT_PORT_LED_OFF); return TRUE; } diff --git a/drivers/scsi/nsp32.h b/drivers/scsi/nsp32.h index ab0726c..a7553ea 100644 --- a/drivers/scsi/nsp32.h +++ b/drivers/scsi/nsp32.h @@ -306,8 +306,8 @@ typedef u16 u16_le; #define EXT_PORT_DDR 0x02 /* BASE+08, IDX+02, B, R/W */ #define EXT_PORT 0x03 /* BASE+08, IDX+03, B, R/W */ -# define LED_ON (0) -# define LED_OFF BIT(0) +# define EXT_PORT_LED_ON (0) +# define EXT_PORT_LED_OFF BIT(0) #define IRQ_SELECT 0x04 /* BASE+08, IDX+04, W, R/W */ # define IRQSELECT_RESELECT_IRQ BIT(0) From patchwork Thu Aug 15 16:59:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11096143 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 ABFA1112C for ; Thu, 15 Aug 2019 17:00:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B646204BF for ; Thu, 15 Aug 2019 17:00:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E8382887B; Thu, 15 Aug 2019 17:00:43 +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=-8.0 required=2.0 tests=BAYES_00,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 8372A204BF for ; Thu, 15 Aug 2019 17:00:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730775AbfHORAm (ORCPT ); Thu, 15 Aug 2019 13:00:42 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:34977 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730645AbfHORAm (ORCPT ); Thu, 15 Aug 2019 13:00:42 -0400 Received: by mail-pg1-f195.google.com with SMTP id n4so1560730pgv.2; Thu, 15 Aug 2019 10:00:41 -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=oqX/UKin0oQTLnMVUUl0S4gSZge29Cs03GMZoH5D3LE=; b=dR08MjwtGtpznDDXZ2Expju7lK8AHauc1wGGw2dymY5yb9L0m1C+CGHlb1W3dFUcqO TOvfpcX3SOIKN5wyJl2MuyxZEPZqu0kaXsyMRoQ9lD+s94U5O8xq+t6PG92k27WpQI1z T5QMOmr0AR8OyLE8wSBR48gEtPu3Cz+r1Sbt5yZn0+NHHSsUzCT61B4b0fRGgZmq5Prm 9zSWmIeyiXBKu45Mt8xhzawbfzWBLL8XxAEXDYmmZc02T4mHPQcNUiZoYOdqypVZUXZf rNfbGKlLfky8DeqnNfImAaFV6nxYnZSe95wSGbZK4PxsE7n57MhtVw9rnV2PKcASk21X L9lA== 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=oqX/UKin0oQTLnMVUUl0S4gSZge29Cs03GMZoH5D3LE=; b=uUnJTNOUS0rfGqeiyBuz2AVc/JKpCSoS18NIKnmTzrL/SQynP2cf/FRsyjlyWkC5Of UtRP7FTrIN7sqi2TreWmhm4WR3jeHoRmgZxSPuWPoAfSzxbMJ6A5M19ZKskJ0bLJCPcY 5cUpqnraF35HSUC63EsGSwv6BXE0wGkoUshYsO74KIp419PCZVwr/Uxbxui1fX3mitdu CnHI+Ovy0V7AQqU4c9S4xWmpnzYqgTOv8QaWuRQaPBY2qdc6frfybat5iK1bUlnwxAvY J4v2eulWNRUJyy3xavdoaQOX8ngxpqciS3qTpV/LVfCN/G3g+Q9AjwFDgkHsRMJFZMm8 igBg== X-Gm-Message-State: APjAAAVfAi7N2rYMqY48M5sPe50KPiqCKNREV+LgaTNlp9KgaLVvU9dj jXaGdoOz6Nc4k8xjgK2fthkYjMHGnhY= X-Google-Smtp-Source: APXvYqxavwfOIRXB4UmKThL9Gs1o9ti0I/aFI9gvYeNTorrYJu2bOEZCpiIPbbAPX3532fR6oKcbeg== X-Received: by 2002:aa7:9197:: with SMTP id x23mr6335375pfa.95.1565888440835; Thu, 15 Aug 2019 10:00:40 -0700 (PDT) Received: from mita-MS-7A45.lan ([240f:34:212d:1:12:b19f:559d:7305]) by smtp.gmail.com with ESMTPSA id b30sm3943942pfr.117.2019.08.15.10.00.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Aug 2019 10:00:40 -0700 (PDT) From: Akinobu Mita To: linux-block@vger.kernel.org, linux-leds@vger.kernel.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org Cc: Akinobu Mita , Frank Steiner , Jacek Anaszewski , Pavel Machek , Dan Murphy , Jens Axboe , "James E.J. Bottomley" , "Martin K. Petersen" , Hannes Reinecke Subject: [PATCH v4 4/5] block: introduce LED block device activity trigger Date: Fri, 16 Aug 2019 01:59:58 +0900 Message-Id: <1565888399-21550-5-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1565888399-21550-1-git-send-email-akinobu.mita@gmail.com> References: <1565888399-21550-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This allows LEDs to be controlled by block device activity. We already have ledtrig-disk (LED disk activity trigger), but the lower level disk drivers need to utilize ledtrig_disk_activity() to make the LED blink. The LED block device trigger doesn't require the lower level drivers to have any instrumentation. The activity is collected by polling the disk stats. Example: echo block-nvme0n1 > /sys/class/leds/diy/trigger The LED block device activity trigger periodically polls the disk stats to collect the activity. However, it is pointless to poll while the block device is in quiescent state. So there is an optional interface to stop and restart polling disk stats for the lower-level block drivers. Cc: Frank Steiner Cc: Jacek Anaszewski Cc: Pavel Machek Cc: Dan Murphy Cc: Jens Axboe Cc: "James E.J. Bottomley" Cc: "Martin K. Petersen" Cc: Hannes Reinecke Signed-off-by: Akinobu Mita --- * v4 - Squash patch 'add interface to stop and restart polling disk stats' into the ledtrig-blk introduction patch - Rename 'led' to 'led_trig' in struct ledtrig_blk .../ABI/testing/sysfs-class-led-trigger-blk | 37 +++ block/genhd.c | 2 + drivers/leds/trigger/Kconfig | 9 + drivers/leds/trigger/Makefile | 1 + drivers/leds/trigger/ledtrig-blk.c | 259 +++++++++++++++++++++ include/linux/genhd.h | 3 + include/linux/leds.h | 38 +++ 7 files changed, 349 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-led-trigger-blk create mode 100644 drivers/leds/trigger/ledtrig-blk.c diff --git a/Documentation/ABI/testing/sysfs-class-led-trigger-blk b/Documentation/ABI/testing/sysfs-class-led-trigger-blk new file mode 100644 index 0000000..73472c3 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-class-led-trigger-blk @@ -0,0 +1,37 @@ +What: /sys/class/leds//interval +Date: Aug 2019 +KernelVersion: 5.4 +Contact: linux-leds@vger.kernel.org +Description: + Specifies the duration of the LED blink in milliseconds. + Defaults to 50 ms. + +What: /sys/class/leds//read +Date: Aug 2019 +KernelVersion: 5.4 +Contact: linux-leds@vger.kernel.org +Description: + Signal data read on the block device. + If set to 0, the LED will not blink on data read. + If set to 1 (default), the LED will blink for the milliseconds + specified in interval to signal data read. + +What: /sys/class/leds//write +Date: Aug 2019 +KernelVersion: 5.4 +Contact: linux-leds@vger.kernel.org +Description: + Signal data written on the block device. + If set to 0, the LED will not blink on data written. + If set to 1 (default), the LED will blink for the milliseconds + specified in interval to signal data written. + +What: /sys/class/leds//discard +Date: Aug 2019 +KernelVersion: 5.4 +Contact: linux-leds@vger.kernel.org +Description: + Signal data discarded on the block device. + If set to 0, the LED will not blink on data discarded. + If set to 1 (default), the LED will blink for the milliseconds + specified in interval to signal data discarded. diff --git a/block/genhd.c b/block/genhd.c index 54f1f0d3..1c68861 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -745,6 +745,7 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk, disk_add_events(disk); blk_integrity_add(disk); + ledtrig_blk_register(disk); } void device_add_disk(struct device *parent, struct gendisk *disk, @@ -766,6 +767,7 @@ void del_gendisk(struct gendisk *disk) struct disk_part_iter piter; struct hd_struct *part; + ledtrig_blk_unregister(disk); blk_integrity_del(disk); disk_del_events(disk); diff --git a/drivers/leds/trigger/Kconfig b/drivers/leds/trigger/Kconfig index ce9429c..e399a11 100644 --- a/drivers/leds/trigger/Kconfig +++ b/drivers/leds/trigger/Kconfig @@ -144,4 +144,13 @@ config LEDS_TRIGGER_AUDIO the audio mute and mic-mute changes. If unsure, say N +config LEDS_TRIGGER_BLOCK + bool "LED Block device Trigger" + depends on BLOCK + help + This allows LEDs to be controlled by block device activity. + This trigger doesn't require the lower level drivers to have any + instrumentation. The activity is collected by polling the disk stats. + If unsure, say Y. + endif # LEDS_TRIGGERS diff --git a/drivers/leds/trigger/Makefile b/drivers/leds/trigger/Makefile index 733a83e..60200eb 100644 --- a/drivers/leds/trigger/Makefile +++ b/drivers/leds/trigger/Makefile @@ -15,3 +15,4 @@ obj-$(CONFIG_LEDS_TRIGGER_PANIC) += ledtrig-panic.o obj-$(CONFIG_LEDS_TRIGGER_NETDEV) += ledtrig-netdev.o obj-$(CONFIG_LEDS_TRIGGER_PATTERN) += ledtrig-pattern.o obj-$(CONFIG_LEDS_TRIGGER_AUDIO) += ledtrig-audio.o +obj-$(CONFIG_LEDS_TRIGGER_BLOCK) += ledtrig-blk.o diff --git a/drivers/leds/trigger/ledtrig-blk.c b/drivers/leds/trigger/ledtrig-blk.c new file mode 100644 index 0000000..de05e92 --- /dev/null +++ b/drivers/leds/trigger/ledtrig-blk.c @@ -0,0 +1,259 @@ +// SPDX-License-Identifier: GPL-2.0 +// LED Kernel Blockdev Trigger +// Derived from ledtrig-netdev.c + +#include +#include +#include +#include +#include "../leds.h" + +enum ledtrig_blk_attr { + LEDTRIG_BLK_READ, + LEDTRIG_BLK_WRITE, + LEDTRIG_BLK_DISCARD +}; + +struct ledtrig_blk_data { + struct delayed_work work; + struct led_classdev *led_cdev; + + atomic_t interval; + u64 last_activity; + + unsigned long mode; +}; + +static ssize_t ledtrig_blk_attr_show(struct device *dev, char *buf, + enum ledtrig_blk_attr attr) +{ + struct ledtrig_blk_data *trig_data = led_trigger_get_drvdata(dev); + + return sprintf(buf, "%u\n", test_bit(attr, &trig_data->mode)); +} + +static ssize_t ledtrig_blk_attr_store(struct device *dev, const char *buf, + size_t size, enum ledtrig_blk_attr attr) +{ + struct ledtrig_blk_data *trig_data = led_trigger_get_drvdata(dev); + unsigned long state; + int ret; + + ret = kstrtoul(buf, 0, &state); + if (ret) + return ret; + + if (state) + set_bit(attr, &trig_data->mode); + else + clear_bit(attr, &trig_data->mode); + + return size; +} + +static ssize_t read_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + return ledtrig_blk_attr_show(dev, buf, LEDTRIG_BLK_READ); +} +static ssize_t read_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t size) +{ + return ledtrig_blk_attr_store(dev, buf, size, LEDTRIG_BLK_READ); +} +static DEVICE_ATTR_RW(read); + +static ssize_t write_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + return ledtrig_blk_attr_show(dev, buf, LEDTRIG_BLK_WRITE); +} +static ssize_t write_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t size) +{ + return ledtrig_blk_attr_store(dev, buf, size, LEDTRIG_BLK_WRITE); +} +static DEVICE_ATTR_RW(write); + +static ssize_t discard_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + return ledtrig_blk_attr_show(dev, buf, LEDTRIG_BLK_DISCARD); +} +static ssize_t discard_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t size) +{ + return ledtrig_blk_attr_store(dev, buf, size, LEDTRIG_BLK_DISCARD); +} +static DEVICE_ATTR_RW(discard); + +static ssize_t interval_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct ledtrig_blk_data *trig_data = led_trigger_get_drvdata(dev); + + return sprintf(buf, "%u\n", + jiffies_to_msecs(atomic_read(&trig_data->interval))); +} +static ssize_t interval_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t size) +{ + struct ledtrig_blk_data *trig_data = led_trigger_get_drvdata(dev); + unsigned long value; + int ret; + + ret = kstrtoul(buf, 0, &value); + if (ret) + return ret; + + /* impose some basic bounds on the timer interval */ + if (value >= 5 && value <= 10000) { + cancel_delayed_work_sync(&trig_data->work); + atomic_set(&trig_data->interval, msecs_to_jiffies(value)); + schedule_delayed_work(&trig_data->work, + atomic_read(&trig_data->interval) * 2); + } + + return size; +} +static DEVICE_ATTR_RW(interval); + +static struct attribute *ledtrig_blk_attrs[] = { + &dev_attr_read.attr, + &dev_attr_write.attr, + &dev_attr_discard.attr, + &dev_attr_interval.attr, + NULL +}; +ATTRIBUTE_GROUPS(ledtrig_blk); + +static void ledtrig_blk_work(struct work_struct *work) +{ + struct ledtrig_blk_data *trig_data = + container_of(work, struct ledtrig_blk_data, work.work); + struct gendisk *disk = container_of(trig_data->led_cdev->trigger, + struct gendisk, led_trig.trig); + u64 activity = 0; + + if (test_bit(LEDTRIG_BLK_READ, &trig_data->mode)) + activity += part_stat_read(&disk->part0, ios[STAT_READ]); + if (test_bit(LEDTRIG_BLK_WRITE, &trig_data->mode)) + activity += part_stat_read(&disk->part0, ios[STAT_WRITE]); + if (test_bit(LEDTRIG_BLK_DISCARD, &trig_data->mode)) + activity += part_stat_read(&disk->part0, ios[STAT_DISCARD]); + + if (trig_data->last_activity != activity) { + unsigned long interval; + + led_stop_software_blink(trig_data->led_cdev); + interval = jiffies_to_msecs(atomic_read(&trig_data->interval)); + led_blink_set_oneshot(trig_data->led_cdev, &interval, &interval, + 0); + + trig_data->last_activity = activity; + } + + if (atomic_read(&disk->led_trig.enable_count)) + schedule_delayed_work(&trig_data->work, + atomic_read(&trig_data->interval) * 2); +} + +static int ledtrig_blk_activate(struct led_classdev *led_cdev) +{ + struct ledtrig_blk_data *trig_data; + + trig_data = kzalloc(sizeof(*trig_data), GFP_KERNEL); + if (!trig_data) + return -ENOMEM; + + trig_data->mode = BIT(LEDTRIG_BLK_READ) | BIT(LEDTRIG_BLK_WRITE) | + BIT(LEDTRIG_BLK_DISCARD); + + atomic_set(&trig_data->interval, msecs_to_jiffies(50)); + trig_data->last_activity = 0; + trig_data->led_cdev = led_cdev; + + INIT_DELAYED_WORK(&trig_data->work, ledtrig_blk_work); + + led_set_trigger_data(led_cdev, trig_data); + + schedule_delayed_work(&trig_data->work, + atomic_read(&trig_data->interval) * 2); + + return 0; +} + +static void ledtrig_blk_deactivate(struct led_classdev *led_cdev) +{ + struct ledtrig_blk_data *trig_data = led_get_trigger_data(led_cdev); + + cancel_delayed_work_sync(&trig_data->work); + kfree(trig_data); +} + +void ledtrig_blk_disable(struct gendisk *disk) +{ + if (disk) + atomic_dec(&disk->led_trig.enable_count); +} +EXPORT_SYMBOL_GPL(ledtrig_blk_disable); + +void ledtrig_blk_enable(struct gendisk *disk) +{ + struct led_classdev *led_cdev; + + if (!disk) + return; + + atomic_inc(&disk->led_trig.enable_count); + + read_lock(&disk->led_trig.trig.leddev_list_lock); + + list_for_each_entry(led_cdev, &disk->led_trig.trig.led_cdevs, + trig_list) { + struct ledtrig_blk_data *trig_data = + led_get_trigger_data(led_cdev); + + schedule_delayed_work(&trig_data->work, + atomic_read(&trig_data->interval) * 2); + } + + read_unlock(&disk->led_trig.trig.leddev_list_lock); +} +EXPORT_SYMBOL_GPL(ledtrig_blk_enable); + +int ledtrig_blk_register(struct gendisk *disk) +{ + int ret; + + disk->led_trig.trig.name = kasprintf(GFP_KERNEL, "block-%s", + disk->disk_name); + if (!disk->led_trig.trig.name) + return -ENOMEM; + + disk->led_trig.trig.activate = ledtrig_blk_activate; + disk->led_trig.trig.deactivate = ledtrig_blk_deactivate; + disk->led_trig.trig.groups = ledtrig_blk_groups; + + atomic_set(&disk->led_trig.enable_count, 1); + + ret = led_trigger_register(&disk->led_trig.trig); + if (ret) { + kfree(disk->led_trig.trig.name); + disk->led_trig.trig.name = NULL; + } + + return ret; +} +EXPORT_SYMBOL_GPL(ledtrig_blk_register); + +void ledtrig_blk_unregister(struct gendisk *disk) +{ + if (!disk->led_trig.trig.name) + return; + + led_trigger_unregister(&disk->led_trig.trig); + kfree(disk->led_trig.trig.name); + disk->led_trig.trig.name = NULL; +} +EXPORT_SYMBOL_GPL(ledtrig_blk_unregister); diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 8b5330d..d4fdb21 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -17,6 +17,7 @@ #include #include #include +#include #include #ifdef CONFIG_BLOCK @@ -219,6 +220,8 @@ struct gendisk { int node_id; struct badblocks *bb; struct lockdep_map lockdep_map; + + struct ledtrig_blk led_trig; }; static inline struct gendisk *part_to_disk(struct hd_struct *part) diff --git a/include/linux/leds.h b/include/linux/leds.h index 9b2bf57..fd2eb7c 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -517,4 +517,42 @@ static inline void ledtrig_audio_set(enum led_audio type, } #endif +struct gendisk; + +#ifdef CONFIG_LEDS_TRIGGER_BLOCK + +struct ledtrig_blk { + struct led_trigger trig; + atomic_t enable_count; +}; + +void ledtrig_blk_enable(struct gendisk *disk); +void ledtrig_blk_disable(struct gendisk *disk); +int ledtrig_blk_register(struct gendisk *disk); +void ledtrig_blk_unregister(struct gendisk *disk); + +#else + +struct ledtrig_blk { +}; + +static inline void ledtrig_blk_enable(struct gendisk *disk) +{ +} + +static inline void ledtrig_blk_disable(struct gendisk *disk) +{ +} + +static inline int ledtrig_blk_register(struct gendisk *disk) +{ + return 0; +} + +static inline void ledtrig_blk_unregister(struct gendisk *disk) +{ +} + +#endif /* CONFIG_LEDS_TRIGGER_BLOCK */ + #endif /* __LINUX_LEDS_H_INCLUDED */ From patchwork Thu Aug 15 16:59:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11096149 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 B5FFA1398 for ; Thu, 15 Aug 2019 17:00:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A5ED328705 for ; Thu, 15 Aug 2019 17:00:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A5962886E; Thu, 15 Aug 2019 17: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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 2283D28705 for ; Thu, 15 Aug 2019 17:00:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730781AbfHORAr (ORCPT ); Thu, 15 Aug 2019 13:00:47 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:34639 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730645AbfHORAr (ORCPT ); Thu, 15 Aug 2019 13:00:47 -0400 Received: by mail-pf1-f195.google.com with SMTP id b24so1635823pfp.1; Thu, 15 Aug 2019 10:00:46 -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=h/9CsJGmHC2k7mkEH3qy3JiPzHPuCIzjhAVDf1/O6Fc=; b=FG9XfN38rVy8J0Fx0L2GzzGLSo97RVUwi5K/zZqiLn2lB+N5hVN0/NnyMRhdtJ0nHb 9UWP3HtGJQdgzzEQWnBNwQ5I6JURKASkwLfVMfrUu5BKJb7EYe34YPJ9xMiZMoyH1Mfs gbvcp8DAu2ZNh+aiO2+ssoENG2ZFJkRXkUmYFt2Ggm+f0H3pvIt7sSpYsaGTDz5TI+ia Wp4ySYiQGhfdydmfXelMl45OEtN4zux54nxMopIYN1l9Vah3SP6F6G7MZhIzcIevGCHy jYOv3ccTVCusx29O4rEa74Fd7DvZTqjPuNiu/OTkq27COxtdjAJT/e9QCdzXDxpteiTE DgSw== 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=h/9CsJGmHC2k7mkEH3qy3JiPzHPuCIzjhAVDf1/O6Fc=; b=ccIMovtx0zWqCDGN9y9njIjc3UPqXUEDyV3r4G68uLP7H0UaHrkmdY8p7WkBWgXcCI 6iOJN3Sy7kBVZmHXEUQqaZ3WJN9bu/eHe907BjnVSNO+mpkXr9t95etkNvSxd6LQXUSP TKRLuEDG51UpN2efmZQ5PhHskWh5iMXdDJr7+4MLF6p3pXGeSR8EM+lic52u/R3afiJM 3yQShAb9HdEL0b7nXF5M8Hsx5WTjlXtFWj/uikssWYSoeXOhi5Xmlh1NOCZOuJQNC9Zo s3WODHIkfSUqcZImiif4+YVhRnxMKLyUCGpxgDv8YDzxiFYO8kikqjY1DKHxmzWvT/cP ndig== X-Gm-Message-State: APjAAAXeRbxM/U7SakDQjlFzeBSntbrhZt2zbEAS6inY8zlS+AcpoIeH bSHF00vf5BqEAE9CU50+GHW7AdFfhWo= X-Google-Smtp-Source: APXvYqx5Y2iCVnEH/8slULuy/zuvvskR3ra4nGVYiDkW+XMdYezUCKW03mAvHWTYTragLPLC5z2pgw== X-Received: by 2002:a63:2705:: with SMTP id n5mr74184pgn.224.1565888446274; Thu, 15 Aug 2019 10:00:46 -0700 (PDT) Received: from mita-MS-7A45.lan ([240f:34:212d:1:12:b19f:559d:7305]) by smtp.gmail.com with ESMTPSA id b30sm3943942pfr.117.2019.08.15.10.00.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Aug 2019 10:00:45 -0700 (PDT) From: Akinobu Mita To: linux-block@vger.kernel.org, linux-leds@vger.kernel.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org Cc: Akinobu Mita , Frank Steiner , Jacek Anaszewski , Pavel Machek , Dan Murphy , Jens Axboe , "James E.J. Bottomley" , "Martin K. Petersen" , Hannes Reinecke Subject: [PATCH v4 5/5] scsi: sd: stop polling disk stats by ledtrig-blk during runtime suspend Date: Fri, 16 Aug 2019 01:59:59 +0900 Message-Id: <1565888399-21550-6-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1565888399-21550-1-git-send-email-akinobu.mita@gmail.com> References: <1565888399-21550-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The LED block device activity trigger periodically polls the disk stats to collect the activity. However, it is pointless to poll while the scsi device is in runtime suspend. This stops polling disk stats when the device is successfully runtime suspended, and restarts polling when the device is successfully runtime resumed. Cc: Frank Steiner Cc: Jacek Anaszewski Cc: Pavel Machek Cc: Dan Murphy Cc: Jens Axboe Cc: "James E.J. Bottomley" Cc: "Martin K. Petersen" Cc: Hannes Reinecke Signed-off-by: Akinobu Mita --- drivers/scsi/sd.c | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 149d406..5f73142 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -3538,7 +3538,7 @@ static int sd_suspend_common(struct device *dev, bool ignore_stop_errors) { struct scsi_disk *sdkp = dev_get_drvdata(dev); struct scsi_sense_hdr sshdr; - int ret = 0; + int ret; if (!sdkp) /* E.g.: runtime suspend following sd_remove() */ return 0; @@ -3550,18 +3550,16 @@ static int sd_suspend_common(struct device *dev, bool ignore_stop_errors) if (ret) { /* ignore OFFLINE device */ if (ret == -ENODEV) - return 0; - - if (!scsi_sense_valid(&sshdr) || - sshdr.sense_key != ILLEGAL_REQUEST) - return ret; + goto success; /* * sshdr.sense_key == ILLEGAL_REQUEST means this drive * doesn't support sync. There's not much to do and * suspend shouldn't fail. */ - ret = 0; + if (!scsi_sense_valid(&sshdr) || + sshdr.sense_key != ILLEGAL_REQUEST) + return ret; } } @@ -3569,11 +3567,14 @@ static int sd_suspend_common(struct device *dev, bool ignore_stop_errors) sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n"); /* an error is not worth aborting a system sleep */ ret = sd_start_stop_device(sdkp, 0); - if (ignore_stop_errors) - ret = 0; + if (ret && !ignore_stop_errors) + return ret; } - return ret; +success: + ledtrig_blk_disable(sdkp->disk); + + return 0; } static int sd_suspend_system(struct device *dev) @@ -3589,19 +3590,24 @@ static int sd_suspend_runtime(struct device *dev) static int sd_resume(struct device *dev) { struct scsi_disk *sdkp = dev_get_drvdata(dev); - int ret; if (!sdkp) /* E.g.: runtime resume at the start of sd_probe() */ return 0; - if (!sdkp->device->manage_start_stop) - return 0; + if (sdkp->device->manage_start_stop) { + int ret; + + sd_printk(KERN_NOTICE, sdkp, "Starting disk\n"); + ret = sd_start_stop_device(sdkp, 1); + if (ret) + return ret; - sd_printk(KERN_NOTICE, sdkp, "Starting disk\n"); - ret = sd_start_stop_device(sdkp, 1); - if (!ret) opal_unlock_from_suspend(sdkp->opal_dev); - return ret; + } + + ledtrig_blk_enable(sdkp->disk); + + return 0; } /**