Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7599451imu; Wed, 14 Nov 2018 21:26:11 -0800 (PST) X-Google-Smtp-Source: AJdET5ccbfSfkJYyIXVzU2m1aBC/Wb5BJvkbrzP+syP+wvVQi5CBB432q652AHQn2bvVqY1O75JC X-Received: by 2002:a17:902:6b0c:: with SMTP id o12mr4907322plk.291.1542259571670; Wed, 14 Nov 2018 21:26:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542259571; cv=none; d=google.com; s=arc-20160816; b=hdCID2vpcvhvXqfrMUj5vDyP86X5c3sXXo8DgSMYGI9K0LoPEbE+xmHuEA5kARFBlj rIZIX/9lYjwAhelX/d5JzaMLcdhn61b++LNkO0/XId1OEes493D1gVwjGoQtZuiirw6Z EvFydTv2CRWlpXzH6IeRo/4QAHwxWP06zRa2XV17MLFUi9RuyYecySm4DCFDCZ+GFHnc DEYlbGMlcgp4KhETNj/7x4U4JQ5Y4101hRU3RT87w7BKUjrO4N4kiW7wfXHRF4lC3yXn lRKFcRU4JU1mi8CX+IyQPLYC5UxfOeJrZTCPgY4iY5VmjbE9UxTyDk2mwJMHxW96WFU9 5ekg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=mYXWvOf+X/O2EWMPqSDTGpCTAb50FAYSLpAue84Mv+w=; b=0vccneL8fM95u/CeXzEG2xfUcgLlX323FFKesHS00VOko+XXbEc575jQGLqBQy+/j9 NHy56kLTX0vXn4GTfWIO9KYMkvdWNjmlqSuvUGpPMmKpY5KFJ0qIj+pF6yAv49m5YRtA fJde34CairgHLD8zr7dmli+umyBqg0PCYnWvL+QaJHNFsJONt7Yl6YcTrhTrd1lPfv+9 LcL3Pm5ur/0NIZfwFt8z0/Qar1+EpkbKwzzrBSIRKJ2cpuPuTJmuqCIUbSMPbtCxwEck HoY3ooT35ZN5B+kqh1er7yLFJTD3lMVg43WV9p/KSuJn8iu3dZtVNzK0HHRvAmQJVom4 nW3Q== 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 d24-v6si26072823plr.127.2018.11.14.21.25.43; Wed, 14 Nov 2018 21:26:11 -0800 (PST) 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 S1728002AbeKOPbD (ORCPT + 99 others); Thu, 15 Nov 2018 10:31:03 -0500 Received: from ms.tdt.de ([195.243.126.94]:60830 "EHLO mail.dev.tdt.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726821AbeKOPbD (ORCPT ); Thu, 15 Nov 2018 10:31:03 -0500 Received: from localhost.localdomain (unknown [10.2.3.20]) by mail.dev.tdt.de (Postfix) with ESMTPSA id 38644209AA; Thu, 15 Nov 2018 05:24:40 +0000 (UTC) From: Martin Schiller To: andrew@lunn.ch, sergei.shtylyov@cogentembedded.com, f.fainelli@gmail.com Cc: davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Martin Schiller Subject: [PATCH v5] net: phy: mdio-gpio: Fix working over slow can_sleep GPIOs Date: Thu, 15 Nov 2018 06:24:28 +0100 Message-Id: <20181115052428.8133-1-ms@dev.tdt.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181114061703.11026-1-ms@dev.tdt.de> References: <20181114061703.11026-1-ms@dev.tdt.de> X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.dev.tdt.de Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Up until commit 7e5fbd1e0700 ("net: mdio-gpio: Convert to use gpiod functions where possible"), the _cansleep variants of the gpio_ API was used. After that commit and the change to gpiod_ API, the _cansleep() was dropped. This then results in WARN_ON() when used with GPIO devices which do sleep. Add back the _cansleep() to avoid this. Fixes: 7e5fbd1e0700 ("net: mdio-gpio: Convert to use gpiod functions where possible") Signed-off-by: Martin Schiller --- v5: - reworked commit message - added "Fixes:" tag - based on DaveM net tree instead of mainline v4: - remove linewrap of kernel message v3: - modified commit summary - fixed commit cites in commit message - fixed line continuation v2: - fixed copy/paste bug in warning about slow GPIO pins --- drivers/net/phy/mdio-gpio.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c index 33265747bf39..3a5a24daf384 100644 --- a/drivers/net/phy/mdio-gpio.c +++ b/drivers/net/phy/mdio-gpio.c @@ -63,7 +63,7 @@ static void mdio_dir(struct mdiobb_ctrl *ctrl, int dir) * assume the pin serves as pull-up. If direction is * output, the default value is high. */ - gpiod_set_value(bitbang->mdo, 1); + gpiod_set_value_cansleep(bitbang->mdo, 1); return; } @@ -78,7 +78,7 @@ static int mdio_get(struct mdiobb_ctrl *ctrl) struct mdio_gpio_info *bitbang = container_of(ctrl, struct mdio_gpio_info, ctrl); - return gpiod_get_value(bitbang->mdio); + return gpiod_get_value_cansleep(bitbang->mdio); } static void mdio_set(struct mdiobb_ctrl *ctrl, int what) @@ -87,9 +87,9 @@ static void mdio_set(struct mdiobb_ctrl *ctrl, int what) container_of(ctrl, struct mdio_gpio_info, ctrl); if (bitbang->mdo) - gpiod_set_value(bitbang->mdo, what); + gpiod_set_value_cansleep(bitbang->mdo, what); else - gpiod_set_value(bitbang->mdio, what); + gpiod_set_value_cansleep(bitbang->mdio, what); } static void mdc_set(struct mdiobb_ctrl *ctrl, int what) @@ -97,7 +97,7 @@ static void mdc_set(struct mdiobb_ctrl *ctrl, int what) struct mdio_gpio_info *bitbang = container_of(ctrl, struct mdio_gpio_info, ctrl); - gpiod_set_value(bitbang->mdc, what); + gpiod_set_value_cansleep(bitbang->mdc, what); } static const struct mdiobb_ops mdio_gpio_ops = { @@ -162,6 +162,10 @@ static int mdio_gpio_probe(struct platform_device *pdev) if (ret) return ret; + if (gpiod_cansleep(bitbang->mdc) || gpiod_cansleep(bitbang->mdio) || + gpiod_cansleep(bitbang->mdo)) + dev_warn(&pdev->dev, "Slow GPIO pins might wreak havoc into MDIO bus timing"); + if (pdev->dev.of_node) { bus_id = of_alias_get_id(pdev->dev.of_node, "mdio-gpio"); if (bus_id < 0) { -- 2.11.0