Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6316227imu; Tue, 13 Nov 2018 22:38:02 -0800 (PST) X-Google-Smtp-Source: AJdET5fBb8vZs7xJdXosfGHn2+oLLykFCiSXLnOg3jKCXYAclns14b7auad4tL2E9sOwEneXOUUL X-Received: by 2002:a17:902:4523:: with SMTP id m32-v6mr655371pld.276.1542177482444; Tue, 13 Nov 2018 22:38:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542177482; cv=none; d=google.com; s=arc-20160816; b=emhp1qntx16WXVvW1Whr3tnvKPYanP8+pHNBfZ3z/ZlzDzoQ4xOMk5dVnNngaqnkXK pkQ0y+shaVTosgSdcTXZPegTQd4uDnC3X+SjZxhHdWcLD10K8ZsDcPE1n/Md2ki/fxN1 1juTxxYbqOEJ+72KYCn5IWfwe0ep+IXk0W5uDYB90mC9NLV7M0IZjEw5+YVCrNQgF/yw 490jsS12VKSZSZLU3JEHlBGnbOl+4JKN+y9h+3Mw0Dkta5M8brDOAEJyNkjiyOnAuAU9 rOj1YeogbYKNSV8HQryrmESkfucVePMQtVTDc05DWrvUiluILUjoJdQ4Vbn2z9Nhgu4t SFfw== 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=0fhgbaFgRa6RP36t4IJt4AABCr8PQURnyu4o08r3idE=; b=ToGiJxYnWreBcR6o8+5FBgRaxmvlwGJ1BWlk0/Gw6O2CwUtxUMkauAoZISUu1Ua1/g AXAkZFq4ooXQlGg1d5IvTlr/9aJN4COxqpBbZMilBHNuvDlGlhwXGht93yyCiIno9xF1 TTGp6WAvks/cTPOX/BL3uJAZe2vkYC3d3ZB+EVpp6K8NE+K4DYObvm1wgSAtZ+Y3ZJW/ Vk38fnltsbxIcIQ6IV7X7FOsD/WfyZwGXhP/+ZeTIVaBQO/i/ufyqGmz9h0CWOAZZBZj 7uucvoqJLjO7gfX8oO+F88aHsRAPo3ZUHRTM6h27VxRVVgP1b7h46qTgkSnI0Xc+JF0S dvEA== 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 a28si25038035pgl.530.2018.11.13.22.37.47; Tue, 13 Nov 2018 22:38:02 -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 S1731508AbeKNQjC (ORCPT + 99 others); Wed, 14 Nov 2018 11:39:02 -0500 Received: from ms.tdt.de ([195.243.126.94]:57512 "EHLO mail.dev.tdt.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727770AbeKNQjC (ORCPT ); Wed, 14 Nov 2018 11:39:02 -0500 Received: from localhost.localdomain (unknown [10.2.3.20]) by mail.dev.tdt.de (Postfix) with ESMTPSA id 510262084C; Wed, 14 Nov 2018 06:37:09 +0000 (UTC) From: Martin Schiller To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: andrew@lunn.ch, f.fainelli@gmail.com, davem@davemloft.net, Martin Schiller Subject: [PATCH v2] net: phy: mdio-gpio: fix access that may sleep Date: Wed, 14 Nov 2018 07:37:03 +0100 Message-Id: <20181114063703.13379-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.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.dev.tdt.de Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This commit re-enables support for slow GPIO pins. It was initially introduced by commit 2d6c9091ab7630dfcf34417c6683ce4764d7d40a and got lost by commit 7e5fbd1e0700f1bdb94508f84ec2aeb01eed7b12 Also add a warning about slow GPIO pins like it is done in i2c-gpio. Signed-off-by: Martin Schiller --- v2: - fixed copy/paste bug in warning about slow GPIO pins --- drivers/net/phy/mdio-gpio.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c index 33265747bf39..6c1cca14689b 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,11 @@ 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