From patchwork Tue Jun 1 00:51:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 451844 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=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 ACE17C4708F for ; Tue, 1 Jun 2021 00:52:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8F33D6138C for ; Tue, 1 Jun 2021 00:52:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232592AbhFAAx4 (ORCPT ); Mon, 31 May 2021 20:53:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:46020 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232516AbhFAAxt (ORCPT ); Mon, 31 May 2021 20:53:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CF74A6136E; Tue, 1 Jun 2021 00:52:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622508728; bh=zhw273xMoQcDBrWZhOAv58cvBFsHXq8mkER13wTIyW0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d6Ui0IpJubSyEyqovq/YjQ5ougb/os0g5Jso19mzpUH9b/ZhmOnN6TLXgl6r8Zvn5 TgIS2NQnUm7LCJLSF4FPmXwJmLhrG76K16IErOFryY5FhNE+C45KmCOBAmo+hFnGbg Y00zy4Ro/CSYr1AdqxqnEYZcT3qFh+jYC9arxmn/9PzynWfs1yruTQrcxWWiFikfOU Mto3L2UZptPABUwQZVWUhVRSLIbQMJ5w8pOgcaNv6YxCzdCZcfYrZWkFdQNivlSoRQ h1VAijVTUQoXB/Y5XJ8RSC5lsPpnRQAmI4yjDcS+xrTe9eN+CAeHfPg1EDpkmXXmiB AfFvTxPbg9JLA== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: netdev@vger.kernel.org, Pavel Machek , Dan Murphy , Russell King , Andrew Lunn , Matthias Schiffer , Jacek Anaszewski , Mauro Carvalho Chehab , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH leds v2 04/10] leds: trigger: netdev: support HW offloading Date: Tue, 1 Jun 2021 02:51:49 +0200 Message-Id: <20210601005155.27997-5-kabel@kernel.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210601005155.27997-1-kabel@kernel.org> References: <20210601005155.27997-1-kabel@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add support for HW offloading of the netdev trigger. We are only offloading if the link is up and rx/tx blinking is requested. Signed-off-by: Marek BehĂșn --- drivers/leds/trigger/ledtrig-netdev.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/leds/trigger/ledtrig-netdev.c b/drivers/leds/trigger/ledtrig-netdev.c index 9a98f9c5b8d0..1f1b63d5a78d 100644 --- a/drivers/leds/trigger/ledtrig-netdev.c +++ b/drivers/leds/trigger/ledtrig-netdev.c @@ -52,9 +52,17 @@ static void set_baseline_state(struct led_netdev_data *trigger_data) if (!led_cdev->blink_brightness) led_cdev->blink_brightness = led_cdev->max_brightness; - if (!test_bit(NETDEV_LED_MODE_LINKUP, &trigger_data->mode)) + if (!test_bit(NETDEV_LED_MODE_LINKUP, &trigger_data->mode)) { + led_trigger_offload_stop(led_cdev); led_set_brightness(led_cdev, LED_OFF); - else { + } else { + bool blink = test_bit(NETDEV_LED_TX, &trigger_data->mode) || + test_bit(NETDEV_LED_RX, &trigger_data->mode); + /* Try offload to HW only if RX/TX blinking is requested */ + if (blink) + if (!led_trigger_offload(led_cdev)) + return; + if (test_bit(NETDEV_LED_LINK, &trigger_data->mode)) led_set_brightness(led_cdev, led_cdev->blink_brightness); @@ -64,8 +72,7 @@ static void set_baseline_state(struct led_netdev_data *trigger_data) /* If we are looking for RX/TX start periodically * checking stats */ - if (test_bit(NETDEV_LED_TX, &trigger_data->mode) || - test_bit(NETDEV_LED_RX, &trigger_data->mode)) + if (blink) schedule_delayed_work(&trigger_data->work, 0); } }