From 030cf6885022647656be6fe53e86dd320a6a6d51 Mon Sep 17 00:00:00 2001 From: Venkata Rao Kakani Date: Mon, 25 Jun 2018 13:00:59 +0530 Subject: [PATCH] driver-core: remove lock for platform devices during probe During driver probe procedure, lock on the parent of platform devices could be removed to make probe in parallel. Change-Id: I5457869e056a55b51dd91937d6202947b13977eb Signed-off-by: vkakani Signed-off-by: Wei Li --- Makefile | 4 +++- drivers/base/dd.c | 20 +++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index ea532bf51579..609770fc3666 100644 --- a/Makefile +++ b/Makefile @@ -404,7 +404,9 @@ KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ -Wno-format-security \ -std=gnu89 $(call cc-option,-fno-PIE) - +ifeq ($(TARGET_BOARD_TYPE),auto) +KBUILD_CFLAGS += -DCONFIG_PLATFORM_AUTO +endif KBUILD_AFLAGS_KERNEL := KBUILD_CFLAGS_KERNEL := KBUILD_AFLAGS := -D__ASSEMBLY__ $(call cc-option,-fno-PIE) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 0dd6379ac215..7e00d10d5a94 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "base.h" #include "power/power.h" @@ -642,6 +643,20 @@ void device_initial_probe(struct device *dev) { __device_attach(dev, true); } +#ifdef CONFIG_PLATFORM_AUTO +static inline int lock_parent(struct device *dev) +{ + if (!dev->parent || dev->bus == &platform_bus_type) + return 0; + + return 1; +} +#else +static inline int lock_parent(struct device *dev) +{ + return dev->parent ? 1 : 0; +} +#endif static int __driver_attach(struct device *dev, void *data) { @@ -659,14 +674,13 @@ static int __driver_attach(struct device *dev, void *data) if (!driver_match_device(drv, dev)) return 0; - - if (dev->parent) /* Needed for USB */ + if (lock_parent(dev)) device_lock(dev->parent); device_lock(dev); if (!dev->driver) driver_probe_device(drv, dev); device_unlock(dev); - if (dev->parent) + if (lock_parent(dev)) device_unlock(dev->parent); return 0;