From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7DE6CC4338F for ; Thu, 29 Jul 2021 01:58:54 +0000 (UTC) Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1BF106056C for ; Thu, 29 Jul 2021 01:58:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1BF106056C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kernelnewbies.org Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.94.2) (envelope-from ) id 1m8vJw-0003IC-Ef; Wed, 28 Jul 2021 21:58:48 -0400 Received: from mail-oi1-x236.google.com ([2607:f8b0:4864:20::236]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1m8vFs-0002k2-MQ for kernelnewbies@kernelnewbies.org; Wed, 28 Jul 2021 21:54:36 -0400 Received: by mail-oi1-x236.google.com with SMTP id 21so6321419oin.8 for ; Wed, 28 Jul 2021 18:54:36 -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 :mime-version:content-transfer-encoding; bh=As8Tkf4mRo7Mi47sb2gawTIsMDIBW35dWzDfuJXzf24=; b=KAXxg7WDVZEiBctmG67MeAut2sjCZTRyAlgzgozM0u4dV10MjAmjS86P3FlU+oRh+d ghx90pJrqPDbf7Bp8D/UAD3HFl51KaHhxydnKfpWLyaL/lMrpvgZ3tOl4MwjPhzpuU+m HPQNjmomvkHC98rUTLOnoCCxeLQfa+I167ai5XSSD2UE721s6UCl8ozJgaYAwteTKkc/ 10Ba3iV2uv7CC4zjuuYBIFTWALir0n3mP/oci/LS9L7K0k2CHxZKeMPFwp89VepBYeqQ +aK0bJS6GnSwYJZbCRS02GZriHFHuWNQZ5GesGwVxHEC+cDkoT3Dy8sqWFM86au913Bh oeVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=As8Tkf4mRo7Mi47sb2gawTIsMDIBW35dWzDfuJXzf24=; b=XZqOdnFZrt/yt/FPPzwpFBdmF+73aTHkA/w918BEA+g+GwS0FjxvsgZm5M/dXK25jI V8dVaojY81i2jL9DiAXE9+S4qLLs6Mb+hu03yO5Jb14tGSwnhF0qNlAX/CZoQMLVdlZt LXrnJ1/IMDn4fdn3JrsM8V1ezTqo6OPvUnOBdqawwBIPK9UsPikIhsd6lIB1wjHyW+tT +wv9V9xGl7SSHr4pAKVYojQcJZvAw3HKDzMvrPJrlwoLV9By5EFoIF/mFHH2e6Bf+tQR zuDq6RWgiQpRmOtR1AkEduOC09sF1Hxh7/1lIRIv6cRmkT9wWzYVPKQV/H1nqkssjn6Q xKkA== X-Gm-Message-State: AOAM5320KBjXNrk/JkA9UHZX6cICGiZceW1D6MDtMb0PLfKI+GDQaNMQ DoJCANBlkmwg+v8C6mn3tQHo7S33q2MbvJ76 X-Google-Smtp-Source: ABdhPJxzLQsJ5CMubDia3i29fHRTGMkjAZX1g4DtO40aQk4OXdjunp+l7c/f+gIhfdtLP3dwYUm99g== X-Received: by 2002:aca:d11:: with SMTP id 17mr8341809oin.19.1627523674550; Wed, 28 Jul 2021 18:54:34 -0700 (PDT) Received: from ian.penurio.us ([47.184.51.90]) by smtp.gmail.com with ESMTPSA id c11sm311424otm.37.2021.07.28.18.54.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jul 2021 18:54:33 -0700 (PDT) From: Ian Pilcher To: linux-block@vger.kernel.org, linux-leds@vger.kernel.org Subject: [RFC PATCH 8/8] block: Blink device LED when request is sent to low-level driver Date: Wed, 28 Jul 2021 20:53:44 -0500 Message-Id: <20210729015344.3366750-9-arequipeno@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210729015344.3366750-1-arequipeno@gmail.com> References: <20210729015344.3366750-1-arequipeno@gmail.com> MIME-Version: 1.0 Cc: axboe@kernel.dk, Ian Pilcher , linux-kernel@vger.kernel.org, pavel@ucw.cz, kernelnewbies@kernelnewbies.org X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kernelnewbies-bounces@kernelnewbies.org * Don't wait to lock the device's LED trigger mutex; just don't blink the LED this time if it can't be locked right away, i.e. if mutex_trylock() fails. Signed-off-by: Ian Pilcher --- block/blk-ledtrig.c | 24 ++++++++++++++++++++++++ block/blk-ledtrig.h | 9 +++++++++ block/blk-mq.c | 2 ++ 3 files changed, 35 insertions(+) diff --git a/block/blk-ledtrig.c b/block/blk-ledtrig.c index 2d324df45149..1b475530ce6c 100644 --- a/block/blk-ledtrig.c +++ b/block/blk-ledtrig.c @@ -544,3 +544,27 @@ ssize_t blk_ledtrig_devattr_show(struct device *const dev, return (ssize_t)(name_len + 1); } + + +/* + * + * Try to blink an LED + * + */ + +void __blk_ledtrig_try_blink(struct gendisk *const gd) +{ + if (mutex_trylock(&gd->ledtrig_mutex)) { + + if (gd->ledtrig != NULL) { + + unsigned long delay_on = 75; + unsigned long delay_off = 25; + + led_trigger_blink_oneshot(&gd->ledtrig->trigger, + &delay_on, &delay_off, 0); + } + + mutex_unlock(&gd->ledtrig_mutex); + } +} diff --git a/block/blk-ledtrig.h b/block/blk-ledtrig.h index 5d228905edbf..146deda92a8e 100644 --- a/block/blk-ledtrig.h +++ b/block/blk-ledtrig.h @@ -27,10 +27,19 @@ ssize_t blk_ledtrig_devattr_show(struct device *const dev, struct device_attribute *const attr, char *const buf); +void __blk_ledtrig_try_blink(struct gendisk *gd); + +static inline void blk_ledtrig_try_blink(struct gendisk *const gd) +{ + if (gd != NULL) + __blk_ledtrig_try_blink(gd); +} + #else // CONFIG_BLK_LED_TRIGGERS static inline void blk_ledtrig_init(void) {} static inline void blk_ledtrig_disk_init(const struct gendisk *gd) {} +static inline void blk_ledtrig_try_blink(const struct gendisk *gd) {} // Real function (declared in include/linux/blk-ledtrig.h) returns a bool. // This is only here for del_gendisk() (in genhd.c), which doesn't check diff --git a/block/blk-mq.c b/block/blk-mq.c index 2c4ac51e54eb..5593ece7b676 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -40,6 +40,7 @@ #include "blk-stat.h" #include "blk-mq-sched.h" #include "blk-rq-qos.h" +#include "blk-ledtrig.h" static DEFINE_PER_CPU(struct llist_head, blk_cpu_done); @@ -1381,6 +1382,7 @@ bool blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx *hctx, struct list_head *list, switch (ret) { case BLK_STS_OK: queued++; + blk_ledtrig_try_blink(rq->rq_disk); break; case BLK_STS_RESOURCE: case BLK_STS_DEV_RESOURCE: -- 2.31.1 _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies