Received: by 10.192.165.156 with SMTP id m28csp1425517imm; Wed, 11 Apr 2018 19:35:25 -0700 (PDT) X-Google-Smtp-Source: AIpwx488RONOxEkJvh6587kViSIR9q38dEmRi9O7GTfDBAFnvUAAAEVn4rODUy2CQVHKuJy0EsEd X-Received: by 10.98.234.6 with SMTP id t6mr6117111pfh.38.1523500525777; Wed, 11 Apr 2018 19:35:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523500525; cv=none; d=google.com; s=arc-20160816; b=FtnLZMagstYNY5O0/rd1b22yGVOpyqPA+WYEZY3AikfyJIPv2FgzimAAW807YgKmZ/ hUVuBCEQ25cDSI6cOclqdF+nAB8JMax2Hd3eo9aSk2ApMr96K8ZKu1GeW0ZS5b3q5A0c 8CM8ijcgcJi0FbsAeS8WvO5ppfC9qpRm619NG9f7PWY0bRQ9soANoMioaKZrBGg+998f ZETlqKNO3h3Hqk4BGyfCYZW3mavR2vmPAa0UqGFSR3W1xkLzp560XVwiGXYJ0NtPcsLs iq3MsIEkFfeNn1CIrh61K4HpjXxwAHPoelYkLy5bNUbfaDLXAD8z0iRKvLL/Doo1Os8j YHjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=F9J7/EzldnD1pdI4ne5HzDuXjuyJtiwAuVK9gYU4Ig4=; b=MHNrF7pFJfWcnVzVLa2x2YwrmkaI0bo5H6t8XHhT5C2cMx9CNZUzID1RUeNsCxtp0V u/xw9SmsGQ0bCfv5qfqVZBsnVPobXlvVsSX+2ByMWsz7ztQWYEvRJcIMM7rSOYaKx3vZ rRB5rORnUrppxaB359OW+WKK1I5Adpmx9yBDXeZq+WA0u3YeFY/Tl5zlmtm8nXPVxkVu 3RDqeUUryM4Ux7RDpDbuIsipeXIpaHkQIGBRfQd/O9VCCBFUGkzPao39rGCjKc7ZFLOI h6uw4fsjiHqMym/+QqNOt4cqY4EDLQWRvT+dnbb2Y3MYTFQ0Q/m9jrNw2yvmPui4/HZp ksmw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k6si1796358pfi.83.2018.04.11.19.34.48; Wed, 11 Apr 2018 19:35:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752498AbeDLCbm (ORCPT + 99 others); Wed, 11 Apr 2018 22:31:42 -0400 Received: from anchovy1.45ru.net.au ([203.30.46.145]:37203 "EHLO anchovy1.45ru.net.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752068AbeDLCbk (ORCPT ); Wed, 11 Apr 2018 22:31:40 -0400 Received: (qmail 23000 invoked by uid 5089); 12 Apr 2018 02:31:38 -0000 Received: by simscan 1.2.0 ppid: 22902, pid: 22903, t: 0.0822s scanners: regex: 1.2.0 attach: 1.2.0 clamav: 0.88.3/m:40/d:1950 Received: from unknown (HELO ?192.168.0.122?) (preid@electromag.com.au@203.59.235.95) by anchovy1.45ru.net.au with ESMTPA; 12 Apr 2018 02:31:38 -0000 Subject: Re: [PATCH v2] net: dsa: b53: Using sleep-able operations in b53_switch_reset_gpio To: Jia-Ju Bai , f.fainelli@gmail.com, andrew@lunn.ch, vivien.didelot@savoirfairelinux.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <1523497702-7200-1-git-send-email-baijiaju1990@gmail.com> From: Phil Reid Message-ID: Date: Thu, 12 Apr 2018 10:31:22 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <1523497702-7200-1-git-send-email-baijiaju1990@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-AU Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/04/2018 09:48, Jia-Ju Bai wrote: > b53_switch_reset_gpio() is never called in atomic context. > > The call chain ending up at b53_switch_reset_gpio() is: > [1] b53_switch_reset_gpio() <- b53_switch_reset() <- > b53_reset_switch() <- b53_setup() > > b53_switch_reset_gpio() is set as ".setup" in struct dsa_switch_ops. > This function is not called in atomic context. > > Despite never getting called from atomic context, b53_switch_reset_gpio() > calls non-sleep operations mdelay() and gpio_set_value(). > They are not necessary and can be replaced with msleep() > and gpio_set_value_cansleep(). > > This is found by a static analysis tool named DCNS written by myself. > And I also manually check it. > > Signed-off-by: Jia-Ju Bai > --- > v2: > * Use gpio_set_value_cansleep() to replace gpio_set_value() additionally. > Thanks for Florian and Phil for good advice. > --- > drivers/net/dsa/b53/b53_common.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c > index 274f367..36cc60d 100644 > --- a/drivers/net/dsa/b53/b53_common.c > +++ b/drivers/net/dsa/b53/b53_common.c > @@ -596,11 +596,11 @@ static void b53_switch_reset_gpio(struct b53_device *dev) > > /* Reset sequence: RESET low(50ms)->high(20ms) > */ > - gpio_set_value(gpio, 0); > - mdelay(50); > + gpio_set_value_cansleep(gpio, 0); > + msleep(50); > > - gpio_set_value(gpio, 1); > - mdelay(20); > + gpio_set_value_cansleep(gpio, 1); > + msleep(20); > > dev->current_page = 0xff; > } > FWIW: Reviewed-by: Phil Reid