From patchwork Thu Mar 29 10:00:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Dongsheng" X-Patchwork-Id: 10314833 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A5D8460383 for ; Thu, 29 Mar 2018 10:02:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9AE292A24A for ; Thu, 29 Mar 2018 10:02:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F6882A2E2; Thu, 29 Mar 2018 10:02:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0CD122A24A for ; Thu, 29 Mar 2018 10:02:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752561AbeC2KBe (ORCPT ); Thu, 29 Mar 2018 06:01:34 -0400 Received: from mx01.hxt-semitech.com.96.203.223.in-addr.arpa ([223.203.96.7]:51279 "EHLO barracuda.hxt-semitech.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751325AbeC2KBd (ORCPT ); Thu, 29 Mar 2018 06:01:33 -0400 X-ASG-Debug-ID: 1522317690-093b7e77020c060001-I98ny2 Received: from HXTBJIDCEMVIW01.hxtcorp.net ([10.128.0.14]) by barracuda.hxt-semitech.com with ESMTP id zZJJrEIBr69VYkvh (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 29 Mar 2018 18:01:30 +0800 (CST) X-Barracuda-Envelope-From: dongsheng.wang@hxt-semitech.com Received: from ubuntu.hxtcorp.net (10.5.21.103) by HXTBJIDCEMVIW01.hxtcorp.net (10.128.0.14) with Microsoft SMTP Server (TLS) id 15.0.847.32; Thu, 29 Mar 2018 18:01:30 +0800 From: Wang Dongsheng To: , CC: , , , , , , Wang Dongsheng Subject: [RFC PATCH 1/2] driver core: add new dl device status DL_DEV_PROBE_FAILED Date: Thu, 29 Mar 2018 03:00:59 -0700 X-ASG-Orig-Subj: [RFC PATCH 1/2] driver core: add new dl device status DL_DEV_PROBE_FAILED Message-ID: <1522317660-11080-2-git-send-email-dongsheng.wang@hxt-semitech.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522317660-11080-1-git-send-email-dongsheng.wang@hxt-semitech.com> References: <1522317660-11080-1-git-send-email-dongsheng.wang@hxt-semitech.com> MIME-Version: 1.0 X-Originating-IP: [10.5.21.103] X-ClientProxiedBy: HXTBJIDCEMVIW02.hxtcorp.net (10.128.0.15) To HXTBJIDCEMVIW01.hxtcorp.net (10.128.0.14) X-Barracuda-Connect: UNKNOWN[10.128.0.14] X-Barracuda-Start-Time: 1522317690 X-Barracuda-Encrypted: ECDHE-RSA-AES256-SHA X-Barracuda-URL: https://192.168.50.101:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at hxt-semitech.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Bayes: INNOCENT GLOBAL 0.6040 1.0000 0.7684 X-Barracuda-Spam-Score: 0.77 X-Barracuda-Spam-Status: No, SCORE=0.77 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=9.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.49406 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently the initialization state of device is DL_DEV_NO_DRIVER. The problem is, after probe failure the state will also be set to DL_DEV_NO_DRIVER as well. And the device is not linked, it has no supplier or consumer. Thus adding a new state to distinguish probe failure and not-probed-yet. Signed-off-by: Wang Dongsheng --- Documentation/driver-api/device_link.rst | 2 +- drivers/base/base.h | 2 +- drivers/base/core.c | 22 ++++++++++++++++++++-- drivers/base/dd.c | 2 +- include/linux/device.h | 1 + 5 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Documentation/driver-api/device_link.rst b/Documentation/driver-api/device_link.rst index 70e328e..9054403 100644 --- a/Documentation/driver-api/device_link.rst +++ b/Documentation/driver-api/device_link.rst @@ -247,7 +247,7 @@ State machine :c:func:`device_links_unbind_consumers()`.) * If the probe fails, links to suppliers revert back to ``DL_STATE_AVAILABLE``. - (Call to :c:func:`device_links_no_driver()` from :c:func:`really_probe()`.) + (Call to :c:func:`device_links_probe_failed()` from :c:func:`really_probe()`.) * If the probe succeeds, links to suppliers progress to ``DL_STATE_ACTIVE``. (Call to :c:func:`device_links_driver_bound()` from :c:func:`driver_bound()`.) diff --git a/drivers/base/base.h b/drivers/base/base.h index d800de6..f9931d9 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -158,6 +158,6 @@ extern void device_links_read_unlock(int idx); extern int device_links_check_suppliers(struct device *dev); extern void device_links_driver_bound(struct device *dev); extern void device_links_driver_cleanup(struct device *dev); -extern void device_links_no_driver(struct device *dev); +extern void device_links_probe_failed(struct device *dev); extern bool device_links_busy(struct device *dev); extern void device_links_unbind_consumers(struct device *dev); diff --git a/drivers/base/core.c b/drivers/base/core.c index 5847364..31d4f68 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -452,10 +452,28 @@ static void __device_links_no_driver(struct device *dev) dev->links.status = DL_DEV_NO_DRIVER; } -void device_links_no_driver(struct device *dev) +static void __device_links_probe_failed(struct device *dev) +{ + struct device_link *link, *ln; + + list_for_each_entry_safe_reverse(link, ln, &dev->links.suppliers, + c_node) { + if (link->flags & DL_FLAG_STATELESS) + continue; + + if (link->flags & DL_FLAG_AUTOREMOVE) + __device_link_del(link); + else if (link->status != DL_STATE_SUPPLIER_UNBIND) + WRITE_ONCE(link->status, DL_STATE_AVAILABLE); + } + + dev->links.status = DL_DEV_PROBE_FAILED; +} + +void device_links_probe_failed(struct device *dev) { device_links_write_lock(); - __device_links_no_driver(dev); + __device_links_probe_failed(dev); device_links_write_unlock(); } diff --git a/drivers/base/dd.c b/drivers/base/dd.c index de6fd09..90d57e0 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -492,7 +492,7 @@ static int really_probe(struct device *dev, struct device_driver *drv) blocking_notifier_call_chain(&dev->bus->p->bus_notifier, BUS_NOTIFY_DRIVER_NOT_BOUND, dev); pinctrl_bind_failed: - device_links_no_driver(dev); + device_links_probe_failed(dev); devres_release_all(dev); driver_sysfs_remove(dev); dev->driver = NULL; diff --git a/include/linux/device.h b/include/linux/device.h index b093405..bf9630a 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -794,6 +794,7 @@ struct device_link { enum dl_dev_state { DL_DEV_NO_DRIVER = 0, DL_DEV_PROBING, + DL_DEV_PROBE_FAILED, DL_DEV_DRIVER_BOUND, DL_DEV_UNBINDING, };