From patchwork Sat Aug 10 17:54: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: 11088623 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 E3F9F1399 for ; Sat, 10 Aug 2019 17:55:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CAED722638 for ; Sat, 10 Aug 2019 17:55:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE2A426E3A; Sat, 10 Aug 2019 17:55: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=-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 39EC122638 for ; Sat, 10 Aug 2019 17:55:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726136AbfHJRzd (ORCPT ); Sat, 10 Aug 2019 13:55:33 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:36212 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725884AbfHJRzd (ORCPT ); Sat, 10 Aug 2019 13:55:33 -0400 Received: by mail-pg1-f194.google.com with SMTP id l21so47407168pgm.3; Sat, 10 Aug 2019 10:55:32 -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=PmIPB6mpwRGbhjpdu5g6+bYsqRrGPw+jzXIFXUmiX/4=; b=rMGTB26PZzfQPjNuaOz1PdVTNvl4YlNb3nNq+dBmEXUUSO8ucQNXpLW4shoe951H3P 6yCKP0PSCTWBRnKy7o4IK6gwovXK/d2QLrhcWsjTP2cGXcQq+sM/58F9EdDQ2clvT5ry SJ8R9bFfWst6IIF80FlA2Y3/Fowj24in5ZRNe4fvXdVYYhkVROe3F7ZWNAGYfssRcxwg xpp47M0pJIIuQO1anLt3/e054VFNN7fpYadCxE/pwVfUvP1lBo9sUCOq5h3cxnSuL5I1 RRimwqdNeuCPKvCzi+PytMffNGxBAhQD4oS4mbv83P2kGz7domnO/UbQy9ROhy715XtB t6lA== 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=PmIPB6mpwRGbhjpdu5g6+bYsqRrGPw+jzXIFXUmiX/4=; b=aDHgevXIJon9d1Yt1GEfQgHfrHYtj2eQ7evQkvzsHqqGU9XLLNuRzEwjIPsr+aOPei 7bd8LEEXW/9M4yuJU9NSUHeHsOdINDOhG1CEZOt7S9KdEaEYAqELhVcG/Xw/LQGza++9 hi8OFlQpRla2UvlzIC2UtHAdK8UmcM0x9O/y3b6xsL/hQdFzJJoFgEUR5Mz1En4kR7ve WpQJVwwjKKnsf22bA9bajZ/hd4BgGvzXwTeSB3vpq1xIWAv8MX1NuthfQ74TssfOlhlV Teu3NzzFdMYQxMciz1stXMTOTslpGRhulyryJ/ysayR0oGrXgdlPOryHZM/Q7UmbHsWP 6TUg== X-Gm-Message-State: APjAAAW5FNzgI+lcOLCBpipGTTS3KdSVsM5n3LjFMow5e9euRsVIx9s6 Eq6dBewXQSRt//BBf+vqS2mGNew3VQg= X-Google-Smtp-Source: APXvYqxwUrt6hrxviYyAAYYiew/16nbDXI4MNwzMURXf4jbdSSAQHJNWRuXnfFIOoaIUD0liPM7N+Q== X-Received: by 2002:a17:90a:7788:: with SMTP id v8mr15933812pjk.132.1565459732302; Sat, 10 Aug 2019 10:55:32 -0700 (PDT) Received: from mita-MS-7A45.lan ([240f:34:212d:1:a137:2bda:e96e:808]) by smtp.gmail.com with ESMTPSA id 185sm102146544pfd.125.2019.08.10.10.55.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 10 Aug 2019 10:55:31 -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 v3 1/6] block: umem: rename LED_* macros to MEMCTRL_LED_* Date: Sun, 11 Aug 2019 02:54:58 +0900 Message-Id: <1565459703-30513-2-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1565459703-30513-1-git-send-email-akinobu.mita@gmail.com> References: <1565459703-30513-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 Signed-off-by: Akinobu Mita Acked-by: Pavel Machek --- 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 Sat Aug 10 17:54: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: 11088627 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 3B69C112C for ; Sat, 10 Aug 2019 17:55:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A541201BD for ; Sat, 10 Aug 2019 17:55:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D53126E1A; Sat, 10 Aug 2019 17:55:39 +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 9862E201BD for ; Sat, 10 Aug 2019 17:55:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726212AbfHJRzi (ORCPT ); Sat, 10 Aug 2019 13:55:38 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:42608 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726048AbfHJRzi (ORCPT ); Sat, 10 Aug 2019 13:55:38 -0400 Received: by mail-pg1-f193.google.com with SMTP id t132so47408318pgb.9; Sat, 10 Aug 2019 10:55:37 -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=XgQKdFPyq4/igad3UxcEd6J37M+Y3GDA6fYhzatJ2Z3doFBBfkLiwl8BI4vNCEj+UH O5C2UnDadOqsHpU9g2NnRnGAN9jnaeMGwekCFzRWGOCZzKlqx/a/kdSLPRTmvyNcPun1 jsdnrC7IAtv8PA/xem6DhQI3k7anZ3eb59tzBQDD6BJg2PrLYP7c7F+gLhyhiJaXrGcp GrZByG5YwWhcvlCSckJQ/aCxKkeeUJ/EKMVdVJn0M/DlxZRzEQIEP6ka6vfkmXdNLrGv vSDhGM6tR85W7UBuQsUlmGuCUUAeDoXgjiaSn4AvVIOT3GT5GC/boqsObuqQk09z/h/m UuqQ== 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=hBzjoQwnhwoHzhrESh9nakSPgCUsFm/NNfa3OVT7Pw2m3qLJedZbNRVqIQvQkf5gyH ePEDSGeVE4mK2SkWY3C9YWG59X1VfY2vzQpkPl6ZqFko6ps1MPT3Y3eub+kpH3iZZoII x/aRx9foKasAwWeKyWbO94RwO6KdbkC05YunjWqCvwipFysLisHuO1BAcyO0lqCK8Q7x 4STs3P6d+j820FdPVCRAdxZMh4MTlwTdgLlE09lZ34VYJ2apf05RXr0JyXI2Da+Ajj4J vBNngCirQY1iso/mR4mW3cUofxkM2cbFiE9Do+Kky7VJYgTYMPoi6OgBqcfkIn4D49Ah bntQ== X-Gm-Message-State: APjAAAVh2hESLvlEY8mSekyoyozh1XJlfgxTV8wbAsANLERuz5P9RP/q 44+scOzGLqWQCisYi+7poQpmJJyyLII= X-Google-Smtp-Source: APXvYqx+qII4lVboFkSeKu2D27nWV5kO0BFoKHrSQGrW/XAkxubiMEeV9ski/vlVYOFvqdOAEOddUQ== X-Received: by 2002:a65:5144:: with SMTP id g4mr23027005pgq.202.1565459737248; Sat, 10 Aug 2019 10:55:37 -0700 (PDT) Received: from mita-MS-7A45.lan ([240f:34:212d:1:a137:2bda:e96e:808]) by smtp.gmail.com with ESMTPSA id 185sm102146544pfd.125.2019.08.10.10.55.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 10 Aug 2019 10:55:36 -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 v3 2/6] scsi: mvsas: rename LED_* enums to SGPIO_LED_* Date: Sun, 11 Aug 2019 02:54:59 +0900 Message-Id: <1565459703-30513-3-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1565459703-30513-1-git-send-email-akinobu.mita@gmail.com> References: <1565459703-30513-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 Acked-by: Pavel Machek --- 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 Sat Aug 10 17:55:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11088631 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 49D05112C for ; Sat, 10 Aug 2019 17:55:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 34B7822A65 for ; Sat, 10 Aug 2019 17:55:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 277B3201BD; Sat, 10 Aug 2019 17:55: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 9F82B201BD for ; Sat, 10 Aug 2019 17:55:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726225AbfHJRzm (ORCPT ); Sat, 10 Aug 2019 13:55:42 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:37476 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726048AbfHJRzm (ORCPT ); Sat, 10 Aug 2019 13:55:42 -0400 Received: by mail-pg1-f196.google.com with SMTP id d1so14595690pgp.4; Sat, 10 Aug 2019 10:55: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=tuWIrZdeip2SwEu1Up/Cgz1RXLdTxno3PAy39P4ux3s=; b=aViEr1NQQDYNuTA2BHp2Xh6TL7DCfTOEtIRwXYazb2Mpau/q79W3tvuljGj9+ELOMn gHJRBijithncHllSt3KPrXEyzMr/Z2gizvBuCIh0kIf7kYIzwHwdZyhih3MG5Vkg0FIg oRN/jasrT/iaOrSbTUXKgNL55A0mmpJoE5Cyg7KC09yoXvCKVNgjbG2DoiGtdJZB7e59 I98iV9NDXYJw7I4fYE2YcsZ3MSZeUXPn39de6XRRhhgmZbnSiXEbCayfLJGt/2kmGjGT RNB1dW8CiTxdjEI3OdoD9nHZnZf5lzKjakqiIDokVcn7CK2pxDc6FOtEX4aHqAonzQ/P b7yQ== 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=rNhDIdX/c7/6tijEuTROz/dn/Rm/hXfL3yGH6C7tTOeG6gvnRdTK1vfpwQda4tjUZR wMZzt2Kw55bkjzNQSq9PpuP9ylFQd4iBzkdiLdVOKPdIYkQdbs62GFJXoJgpAwZQ1SlA YBy9OlulJTfSQnLCUA26oK4dRmZUsfL64AfXOhxU0yEWV6CdeCfHK3gQIDiGZ8DbPaev XmqBNWl/DCRICf53XpqYn9Lz1V5QrCBLsBEXiZtTaCH6LG/v96NungDoD93RHDwp//Qr rhFOhk8iFnP/sfStW/PanAycYAse0bSbOhqPmTPhsQD9Vsc9uGAvQvT3DVsWGXuzFbQR cJkg== X-Gm-Message-State: APjAAAXtvjWbIuy+P3k07G9m20dTrubIGCAL9QubKwj5IOBow/9Ggnuv 4H8wQtkmVEHt8ect2gixpgADG+0bZFg= X-Google-Smtp-Source: APXvYqygEe6YPo5KJGV1pbKiWifgPPBKFu3bqF9nw8QG6BpnKrDT8d3s73tlEa4eSqtah8I4w4oh4Q== X-Received: by 2002:a65:6552:: with SMTP id a18mr23552119pgw.208.1565459741187; Sat, 10 Aug 2019 10:55:41 -0700 (PDT) Received: from mita-MS-7A45.lan ([240f:34:212d:1:a137:2bda:e96e:808]) by smtp.gmail.com with ESMTPSA id 185sm102146544pfd.125.2019.08.10.10.55.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 10 Aug 2019 10:55: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" , GOTO Masanori , YOKOTA Hiroshi , Hannes Reinecke Subject: [PATCH v3 3/6] scsi: nsp32: rename LED_* macros to EXT_PORT_LED_* Date: Sun, 11 Aug 2019 02:55:00 +0900 Message-Id: <1565459703-30513-4-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1565459703-30513-1-git-send-email-akinobu.mita@gmail.com> References: <1565459703-30513-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 Sat Aug 10 17:55:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11088637 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 E8FE914F7 for ; Sat, 10 Aug 2019 17:55:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D42B6201BD for ; Sat, 10 Aug 2019 17:55:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C809B22A65; Sat, 10 Aug 2019 17:55:47 +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 E7EEB22638 for ; Sat, 10 Aug 2019 17:55:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726239AbfHJRzq (ORCPT ); Sat, 10 Aug 2019 13:55:46 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:35487 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725884AbfHJRzp (ORCPT ); Sat, 10 Aug 2019 13:55:45 -0400 Received: by mail-pf1-f195.google.com with SMTP id u14so47706034pfn.2; Sat, 10 Aug 2019 10:55:45 -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=BOPdeTQtkqBw3W9t11SGA8PB1LPWuWz/oWm3mXmZWoY=; b=PhWSj40mbjaEGaaeM9yBQa+jfcVKjQ++yncGp0IH8mO6qVYi0v43XydxX0lyCBUV5T 08Ba17qZiDR4vK6MVGqiq3LKUFfEh/dwFSO7v6lXB3oKAZBm1+H4Jv7c5u7IOcr3ZWYt gALGYdP+SBXSFTrCXPMTyJzuNXWQTYDh7HZLW6zEsBif2/3LBSGoWCNX0rijcvBkANkn o5B0psfOzhJMCa1bNeS5xDZTbdTLR0hDTwSn5kyKEfnQloKeTtdKiqPd08s8RiDLxmJE cbwo/pj4kEKdRPg1HuC0BasM7b7LKii/I8o2gEGlL9aYlVg90V72YNoQUj2vL6kGgb4H 8oMA== 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=BOPdeTQtkqBw3W9t11SGA8PB1LPWuWz/oWm3mXmZWoY=; b=jH+rLTCwhv5RMXrciYX97Aa/N7MeflV1UF7QFf3HJK2x9SZDKrj83v6nTklCuUEOCy m2yGjQv3IvjLPlv2kUJGyekgeMIJPNAkeUXtkkJPaoUywUGds2HaN5ZZQBbPD9T1eG3B zKeH6cUHyA7wm6B6+mIwf1pcwOU2uekU/iq2dEC/zNYzutf4LQUUWKkyUqFcnoQUKsrm aD3+CsuCTwr7sgLyJiaug7OC0pQCC5NNvNUf8MXobrRnRj0EKWWTDEL1F9PGvk0cTwZK y4khP5FEN0y6D79QKoP1Un4b9q5jy5uCC2DEJ1qp7a48PAHjo9FAiKep+STT05x3rQpF mwiw== X-Gm-Message-State: APjAAAUDnNrC1x8fpvyYYC+oF64ouQn5XeJPApFy5WUyr0qfaXjoXs3M LIFKdNfst7JOcWJD/Fu/e3yNEMXmnlA= X-Google-Smtp-Source: APXvYqyURb3iARdiIfNtdRWD3b3+Ezcml3cik17aswgFiwYZL4/hyWKaJJXPqw3bTwZxrn49F7E2Lw== X-Received: by 2002:a65:64c5:: with SMTP id t5mr23664573pgv.168.1565459744629; Sat, 10 Aug 2019 10:55:44 -0700 (PDT) Received: from mita-MS-7A45.lan ([240f:34:212d:1:a137:2bda:e96e:808]) by smtp.gmail.com with ESMTPSA id 185sm102146544pfd.125.2019.08.10.10.55.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 10 Aug 2019 10:55:44 -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 v3 4/6] block: introduce LED block device activity trigger Date: Sun, 11 Aug 2019 02:55:01 +0900 Message-Id: <1565459703-30513-5-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1565459703-30513-1-git-send-email-akinobu.mita@gmail.com> References: <1565459703-30513-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 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 --- * v3 - Add ABI documentation - Add more detail to Kconfig help text .../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 | 225 +++++++++++++++++++++ include/linux/genhd.h | 3 + include/linux/leds.h | 27 +++ 7 files changed, 304 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..d5808c9 --- /dev/null +++ b/drivers/leds/trigger/ledtrig-blk.c @@ -0,0 +1,225 @@ +// 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); + 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; + } + + 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); +} + +int ledtrig_blk_register(struct gendisk *disk) +{ + int ret; + + disk->led.trig.name = kasprintf(GFP_KERNEL, "block-%s", + disk->disk_name); + if (!disk->led.trig.name) + return -ENOMEM; + + disk->led.trig.activate = ledtrig_blk_activate; + disk->led.trig.deactivate = ledtrig_blk_deactivate; + disk->led.trig.groups = ledtrig_blk_groups; + + ret = led_trigger_register(&disk->led.trig); + if (ret) { + kfree(disk->led.trig.name); + disk->led.trig.name = NULL; + } + + return ret; +} +EXPORT_SYMBOL_GPL(ledtrig_blk_register); + +void ledtrig_blk_unregister(struct gendisk *disk) +{ + if (!disk->led.trig.name) + return; + + led_trigger_unregister(&disk->led.trig); + kfree(disk->led.trig.name); + disk->led.trig.name = NULL; +} +EXPORT_SYMBOL_GPL(ledtrig_blk_unregister); diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 8b5330d..b2c934e 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; }; 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..395fa61 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -517,4 +517,31 @@ 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; +}; + +int ledtrig_blk_register(struct gendisk *disk); +void ledtrig_blk_unregister(struct gendisk *disk); + +#else + +struct ledtrig_blk { +}; + +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 Sat Aug 10 17:55:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11088639 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 B85F4112C for ; Sat, 10 Aug 2019 17:55:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3BF8201BD for ; Sat, 10 Aug 2019 17:55:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9774F26E1A; Sat, 10 Aug 2019 17:55:50 +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 1124E201BD for ; Sat, 10 Aug 2019 17:55:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726259AbfHJRzt (ORCPT ); Sat, 10 Aug 2019 13:55:49 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:42148 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726014AbfHJRzt (ORCPT ); Sat, 10 Aug 2019 13:55:49 -0400 Received: by mail-pf1-f194.google.com with SMTP id q10so47671899pff.9; Sat, 10 Aug 2019 10:55:49 -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=AVfMX6QMV6PyqWsJPtDzTdoOO2jzzS21Op+O5L+8L7o=; b=N7lbfhIpqmHugedPRlThgo1zTW075TGIwh7ISCztXOsmWo2iYU1OgHE+ofsd7qa1/I 6fvlqI2D+7kXkVNioAIo943hXTyRoAsOliSAWjjFQsNtyHYd32IOMv7ej+G6NkpCa8XE oSknfnlzP2WfM+jlXlv3AFdgHkQHas4YQ4Eprj8aWgu/gNc4EY7/mu9B1UMh2rikEfig WQGQ23hr9gYBNuyfm22FG/iFONSI8YseuZi+xVAA1KrdshYt4qTMr44wenru9uqRsXBS O/ki7++iCiLqOAteQutNBugglv031kPnL023+5Oc/nkdLTKInqQXjguHTGaUzgEwu/Zx zChw== 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=AVfMX6QMV6PyqWsJPtDzTdoOO2jzzS21Op+O5L+8L7o=; b=JtDdGTwDup0TrRwHn+l+7bD8E2QkG5QO1D5WL4DUpCB+eLe6DegGa5mcf9wttVdkdQ eIOW/7ZTXq4r17HuDQg3XRYEI831fis6OjP+JOahDeGcO3WtpDV/0X3I+dSbp6JxnKdD ZDQzSC2f4KXrTDJ01EfHzctkyw186js0cj/povpt0bOPISJzm0e42vJoZGCtxfMX3fp2 urb6FfeNhJ8MO1Sm7zRgT+4+924ZPJRxJRwcsPiSf+AH9BF8FppB+qJN7D6W56A1tFpf KlpIPFE7mX2VqW7ooMw8xpJV2hKjPK+xmAdPCILQQWw7G2HTNbG9hhl82xsHlJF7SroZ W6XA== X-Gm-Message-State: APjAAAWIZ4gZqbl6Vqp+Adv3EQh2YQywDvvG9R9T8nQFwRZzCI3e1MZo Sx/7Ddv9TAL5vNQhFeWBVHqhcaezxU0= X-Google-Smtp-Source: APXvYqwjSdrkeXQ+uvDURUhSgaO64jF+/9IW/MzfGhAlKHO7CZudOuJ9DFi/SFDlARo2GpOcC9Z2lw== X-Received: by 2002:a17:90a:cd03:: with SMTP id d3mr152787pju.117.1565459748683; Sat, 10 Aug 2019 10:55:48 -0700 (PDT) Received: from mita-MS-7A45.lan ([240f:34:212d:1:a137:2bda:e96e:808]) by smtp.gmail.com with ESMTPSA id 185sm102146544pfd.125.2019.08.10.10.55.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 10 Aug 2019 10:55:47 -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 v3 5/6] ledtrig-blk: add interface to stop and restart polling disk stats Date: Sun, 11 Aug 2019 02:55:02 +0900 Message-Id: <1565459703-30513-6-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1565459703-30513-1-git-send-email-akinobu.mita@gmail.com> References: <1565459703-30513-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 block device is in quiescent state. This provides 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 --- drivers/leds/trigger/ledtrig-blk.c | 37 +++++++++++++++++++++++++++++++++++-- include/linux/leds.h | 11 +++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/drivers/leds/trigger/ledtrig-blk.c b/drivers/leds/trigger/ledtrig-blk.c index d5808c9..6b826ed 100644 --- a/drivers/leds/trigger/ledtrig-blk.c +++ b/drivers/leds/trigger/ledtrig-blk.c @@ -153,8 +153,9 @@ static void ledtrig_blk_work(struct work_struct *work) trig_data->last_activity = activity; } - schedule_delayed_work(&trig_data->work, - atomic_read(&trig_data->interval) * 2); + if (atomic_read(&disk->led.enable_count)) + schedule_delayed_work(&trig_data->work, + atomic_read(&trig_data->interval) * 2); } static int ledtrig_blk_activate(struct led_classdev *led_cdev) @@ -190,6 +191,36 @@ static void ledtrig_blk_deactivate(struct led_classdev *led_cdev) kfree(trig_data); } +void ledtrig_blk_disable(struct gendisk *disk) +{ + if (disk) + atomic_dec(&disk->led.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.enable_count); + + read_lock(&disk->led.trig.leddev_list_lock); + + list_for_each_entry(led_cdev, &disk->led.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.leddev_list_lock); +} +EXPORT_SYMBOL_GPL(ledtrig_blk_enable); + int ledtrig_blk_register(struct gendisk *disk) { int ret; @@ -203,6 +234,8 @@ int ledtrig_blk_register(struct gendisk *disk) disk->led.trig.deactivate = ledtrig_blk_deactivate; disk->led.trig.groups = ledtrig_blk_groups; + atomic_set(&disk->led.enable_count, 1); + ret = led_trigger_register(&disk->led.trig); if (ret) { kfree(disk->led.trig.name); diff --git a/include/linux/leds.h b/include/linux/leds.h index 395fa61..fd2eb7c 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -523,8 +523,11 @@ struct gendisk; 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); @@ -533,6 +536,14 @@ void ledtrig_blk_unregister(struct gendisk *disk); 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; From patchwork Sat Aug 10 17:55:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11088645 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 1E42B14F7 for ; Sat, 10 Aug 2019 17:55:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 090E7201BD for ; Sat, 10 Aug 2019 17:55:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F147122A65; Sat, 10 Aug 2019 17:55:55 +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 8713222638 for ; Sat, 10 Aug 2019 17:55:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726284AbfHJRzy (ORCPT ); Sat, 10 Aug 2019 13:55:54 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:33044 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726014AbfHJRzy (ORCPT ); Sat, 10 Aug 2019 13:55:54 -0400 Received: by mail-pf1-f194.google.com with SMTP id g2so47693129pfq.0; Sat, 10 Aug 2019 10:55:54 -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=ezPjll7Lb5sAV1hP9STQ2H5TEWxJogWsWbSW7y+KFt8hKb48Uc6nbNCEiJHuxAeqHA 7UzTKft2gkU9gK1+83GaQU5HrmqlshJxETLy3P6NAhzmzEBEszr7pLK7w25zRBbjySqp OZOQE4fBLDV0iLkIPzRy4UWpRD4RDqG+pn3hclJ0igWjzJuvdukgkXmHdZ7VVK0P/BA2 /0ZLPBDn1A2xu1bW572g7bTPIXOw96XakrAKTDe99583c+Y+UWTiUSPe8IfmYwMdFpj2 +v/drnpSO1KPgGt3c2SzbPrWFp4r2t5jFN6KYVe88i03JTpkqghSKG8o7sK8+4HN3b3T +V3A== 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=K5XyPcRZaAYQI19IRaZsOek3hyc6sO+2RcZ7vNBdL68ASXqW31Q6wohHbG7Ic7tmNc QaUq9VnIgeLVOyYVrdoIGmbvujJGgVAFDs7qCY1yzmmHXESA+PxKAsTyH0k0gR0AWmWq 8NlFF1Q4IxlzEFt1xeOarRqHURNskacGysjEuiKOzJW/gWMHrKaZNekqvR1jgGD0fJpL 12N4adYqL8p6wZbEEXvFTS13p7DORP/L6BChRkrzqmLDYka/Lv4OuCXky9I/KfgmAhRy uSs5yiJS2l4nkjBpCU6WPd8MLlatpe375RK+oveRQN29OBxbfhh/uyfjmJTvxAIpDCne 2gvA== X-Gm-Message-State: APjAAAU2f4F+zD7AqDGGTSnZMJWaJi+S6E4OYxQ+V4AeEVtpEng0fYMN wrPQJAmiTQHu4hOvqcV0jJvK6H/MF8U= X-Google-Smtp-Source: APXvYqzF2UwGISoFhldo7ZZvtdBY4gBhWZntLgvppdH9tAoUWH7GgkeTyFQlSEYAwteeWPypa4ORuA== X-Received: by 2002:a17:90a:2041:: with SMTP id n59mr15025439pjc.6.1565459753633; Sat, 10 Aug 2019 10:55:53 -0700 (PDT) Received: from mita-MS-7A45.lan ([240f:34:212d:1:a137:2bda:e96e:808]) by smtp.gmail.com with ESMTPSA id 185sm102146544pfd.125.2019.08.10.10.55.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 10 Aug 2019 10:55:53 -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 v3 6/6] scsi: sd: stop polling disk stats by ledtrig-blk during runtime suspend Date: Sun, 11 Aug 2019 02:55:03 +0900 Message-Id: <1565459703-30513-7-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1565459703-30513-1-git-send-email-akinobu.mita@gmail.com> References: <1565459703-30513-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; } /**