Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4036147pxb; Mon, 8 Feb 2021 06:31:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJykNunFI/pCppBXSNE6ZvOGJu2D5eVDqqbYBtq3HiDB6ioJqhJU9YBzc4SBuOSqzXpifVcL X-Received: by 2002:a50:9dc9:: with SMTP id l9mr17334384edk.377.1612794674622; Mon, 08 Feb 2021 06:31:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612794674; cv=none; d=google.com; s=arc-20160816; b=bRRZIRJJhPvMryCGsvIUV3gW+Ga0w8EjeoFkRdlTyFCZw30XULDNpW5rWP1uTAjYr3 D9DHaM0Qlwt9lY/nLQMXMNW+cF6+Zsh+Fp4QUxtrfalOTD69rlKDmhXrSagiV8k7JOzQ dfxgqOJ6BBU2LV6Y8HmRAZTvCiBdsVfhIvvBtqLh4jPmjRVioLNCUaD99YGXnXPpnW4J JtgXZLOlVCQBUr9oOHyX+2o1Yq6P4YN2z7bZmSOTCpHY9tAWZVTeF+FM60gdumNT3R/4 J1hK5h8NXwzZ1vHFgujzwDuC96DeazbA+joG5384Ci7y4xlKF0PpekgKYkD/WLDzvjxr n8HA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=pKNShYqLTbQuYTXJN7g8Qdvk/xXpn+k+l1XLhObW3Fk=; b=JSD3hPRBsgch8PWOfdZN7ssJDAa944105wccvJs6M3x+IZaAorcThSEn1lKugXFR4Q s5n578nJ0WVJHHcneyJAk8O9Kwp67tfGVo9soboksjf1kfOtX3RICS0PtqZD3OkJWCFf O5ceZkSTW+VuHaawlyqeG/Nw0UcreHi0pjNiwMaInJwGP+E3eQLdDVbtnL2vEt0S8vKm 3aHtFDoPWIhCO7lBQQJ0v/apDwcLUfAi6/qI42w4Dhf6Xi0D4rq62IxL9h4QBEl+6WFI G1s/4+h+GcgQDcjAh/G7hFC2T+YWEBXrZSYUh34ctasWX/gzsx6fj32KSYZTUVOJUtPi ooGg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cc7si12377774edb.462.2021.02.08.06.30.43; Mon, 08 Feb 2021 06:31:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232563AbhBHO3G (ORCPT + 99 others); Mon, 8 Feb 2021 09:29:06 -0500 Received: from mail.baikalelectronics.com ([87.245.175.226]:57456 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232377AbhBHOIE (ORCPT ); Mon, 8 Feb 2021 09:08:04 -0500 From: Serge Semin To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Jakub Kicinski , Joao Pinto , Jose Abreu , Maxime Coquelin CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Vyacheslav Mitrofanov , Russell King , Andrew Lunn , Heiner Kallweit , , , , Subject: [PATCH 17/20] net: stmmac: Add 'cause' arg to the service task executioner Date: Mon, 8 Feb 2021 17:03:38 +0300 Message-ID: <20210208140341.9271-18-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20210208140341.9271-1-Sergey.Semin@baikalelectronics.ru> References: <20210208140341.9271-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to have a more descriptive and coherent service task interface let's add the cause argument to the stmmac_service_event_schedule() method. It will be used to test-and-set the corresponding flag in the private device state variable, and execute the service handler if the flag hasn't been set. By doing so we'll be able to activate the service sub-task just by calling the stmmac_service_event_schedule() method. Note currently there is only a single user of the service tasks interface. It's used to handle a case of the critical device errors to cause the interface reset. The changes provided here will also prevent the global error handler from being called twice if the service task has already being executed while reset sub-task still isn't started. Signed-off-by: Serge Semin --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 08112b6e7afd..f3ced94b3f4e 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -174,16 +174,18 @@ static void stmmac_enable_all_queues(struct stmmac_priv *priv) } } -static void stmmac_service_event_schedule(struct stmmac_priv *priv) +static void stmmac_service_event_schedule(struct stmmac_priv *priv, + unsigned long cause) { - queue_work(priv->wq, &priv->service_task); + if (!test_and_set_bit(cause, &priv->state)) + queue_work(priv->wq, &priv->service_task); } static void stmmac_global_err(struct stmmac_priv *priv) { netif_carrier_off(priv->dev); - set_bit(STMMAC_RESET_REQUESTED, &priv->state); - stmmac_service_event_schedule(priv); + + stmmac_service_event_schedule(priv, STMMAC_RESET_REQUESTED); } /** @@ -4658,8 +4660,6 @@ static const struct net_device_ops stmmac_netdev_ops = { static void stmmac_reset_subtask(struct stmmac_priv *priv) { - if (!test_and_clear_bit(STMMAC_RESET_REQUESTED, &priv->state)) - return; if (test_bit(STMMAC_DOWN, &priv->state)) return; @@ -4680,7 +4680,8 @@ static void stmmac_service_task(struct work_struct *work) struct stmmac_priv *priv = container_of(work, struct stmmac_priv, service_task); - stmmac_reset_subtask(priv); + if (test_and_clear_bit(STMMAC_RESET_REQUESTED, &priv->state)) + stmmac_reset_subtask(priv); } /** -- 2.29.2