Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3613140imm; Tue, 29 May 2018 10:10:48 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqHDKHSxEd6p605JCcJFwEg/t8/NdmUAKwA5QMsfaKnDaWicH0JXlXG/dXhn2+VsAYUH0Ag X-Received: by 2002:a17:902:781:: with SMTP id 1-v6mr18545283plj.150.1527613848333; Tue, 29 May 2018 10:10:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527613848; cv=none; d=google.com; s=arc-20160816; b=Nf0aCE/wDRNhd4hUFmlzQ36REux9vLn/BPG5zWiaKtzNdwZsGUtKx2Q3lAxEpWlRkc Es7czI7zEljFjeA01F68QHxUV9V9STM8l3pVwNw5vwl9LPxEnoFa65JP8kp7JEwgEr+U trvanUOSvoOnsQ3KjGnV7mNp7UKFD1ugsHbIfdCXMWVsGO6oAf80qFa0WrHufF5EgmjA zY/bsXyAYonRxzxBzv1nvz2LDadNNNhpTkbZgp5QXUJPftShLqggBdgl4xt1xPiK2AVS 7QKzHPSTOgQDRXq9MhE/eheJ6zULl6W9Mq/jU0CCQShIJzD2iiN/TcgHCohqeo6TLILS A7GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=GPx3RqpsCRdDES9qI5j5FtgHC9XBlQWM1IzWL67mzaM=; b=DYo0iSbIeelS151ta8ESqFOBi+flN0feDnP2TZWXEk8zYujgkduvxRzjuLavt5LHPc 1fWxk11zep6X/i/qQTMnJVLd3mJhWQkukRX6TXnt0dpobeEm7aWqcyJTISxbolFkntx5 5oo0yXllqjZmCQOnzHOHflqts7SO9Qu8fAa9DrRWw0UfkixjkUpnxBJV5ylOE6C0VOK/ 1UB7ePVhPvB8A8mvFOiNWi4d7gSZPVxe2ahKnCo+V3lkeNyOuppc9BOsqLklm2sjhApz DXCaRtKOlaEboI2hbgNo8J7yUtCQzcK4fMiszyIvWzaPX7y+gmYhXNSiyQ6OXwi4uBLq mBQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=I8UfsEsA; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d26-v6si25283299pge.500.2018.05.29.10.10.34; Tue, 29 May 2018 10:10:48 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=I8UfsEsA; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965352AbeE2RIQ (ORCPT + 99 others); Tue, 29 May 2018 13:08:16 -0400 Received: from mail-qt0-f195.google.com ([209.85.216.195]:46812 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965095AbeE2RIJ (ORCPT ); Tue, 29 May 2018 13:08:09 -0400 Received: by mail-qt0-f195.google.com with SMTP id h5-v6so11550121qtm.13; Tue, 29 May 2018 10:08:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=GPx3RqpsCRdDES9qI5j5FtgHC9XBlQWM1IzWL67mzaM=; b=I8UfsEsAq/MFZf8U0OIwUu26B0K8+kNdZ2J1uDxWGXlyti8K5cJFyiozsEaK1FPBUv ooD4SU6Zd2BTcFmaLrVMPDUOCWAcDI/8oV8F2CzS/z0pM9ihXKmsy1VEmamVGdn79HL9 LTwfZZdaerbe05jno9GmuURbhnTTb146FqZFNSivxQWQUrpJzS+/fthCabKA0t1ZZ73q +m3ygmJSbK8TSST7vRN/s/gqrwV9+ST4inoZvo9CaoblBqWnyQd91OgtCBMng3e1E1S2 iJF5JYB81fjddkWFXe2XCKgzOlWIH3M1Uh36aLQLnQ6iAuFTXF2rrEZXMhXhnT6xtuO5 28ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=GPx3RqpsCRdDES9qI5j5FtgHC9XBlQWM1IzWL67mzaM=; b=TTo56yWSDiJJ0TJm3dsB1HdfNco+QLOtY7xSZ23MvHgiumCqwsPOAbfuFrqJ5d2cWg FbxjTjcOCOOOkoAxskkx25ngpTzAspMAC7rkH3NDT++eRvtaXpFm4LfXNqSq6vEg4nXs lHFR+pe6gz4OzYhqJK8ttt8F2KELBy55ygGGc8MHB8uN26jnL6ACjmKbPTDCC9+m/Uwz uu+bMViS7tMncWmjRLc2SBKMTYjQgB7YmWTxCob6FpUfvL7yDwX+sbrA4Vcwa0CayBE+ rSiOvjJuskKkZrINrm10DQofJ2mU00t485N01V3nePeDpAK/+ghsdPZ2zd2pLlia+IQ8 mDyA== X-Gm-Message-State: ALKqPwdYEvZeSE2GFTTJfipTmmW2cc7gUHI9m6HqBfJvhodDqr0vEz9m vIn9hHVXnquSF5ubb/U7pR36HWKaQzrA3suQ3a8= X-Received: by 2002:ac8:190c:: with SMTP id t12-v6mr9839632qtj.278.1527613689052; Tue, 29 May 2018 10:08:09 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a0c:9896:0:0:0:0:0 with HTTP; Tue, 29 May 2018 10:08:08 -0700 (PDT) In-Reply-To: <20180529163428.234106-1-liumartin@google.com> References: <20180529163428.234106-1-liumartin@google.com> From: Andy Shevchenko Date: Tue, 29 May 2018 20:08:08 +0300 Message-ID: Subject: Re: [RFC PATCH v3] driver core: hold dev's parent lock when needed To: Martin Liu Cc: Greg Kroah-Hartman , "Krogerus, Heikki" , Johan Hovold , Alan Stern , Linux Kernel Mailing List , USB , jenhaochen@google.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 29, 2018 at 7:34 PM, Martin Liu wrote: > SOC have internal I/O buses that can't be proved for devices. The Perhaps SoC as a common abbr for system-on-chip. > devices on the buses can be accessed directly without additinal > configuration required. This type of bus is represented as > "simple-bus". In some platforms, we name "soc" with "simple-bus" > attribute and many devices are hooked under it desribed in DT > (device tree). described > > In commit 'bf74ad5bc417 introduce ("[PATCH] Hold the device's > parent's lock during probe and remove")' The formal commit reference doesn't include '' (surrounding quotes) and words in square brackets (like [PATCH] here). > to solve USB subsystem > lock sequence since usb device's characteristic. Thus "soc" usb or USB ? > needs to be locked whenever a device and driver's probing > happen under "soc" bus. During this period, an async driver > tries to probe a device which is under the "soc" bus would be > blocked until previous driver finish the probing and release "soc" > lock. And the next probing under the "soc" bus need to wait for > async finish. Because of that, driver's async probe for init > time improvement will be shadowed. > > Since many devices don't have USB devices' characteristic, they > actually don't need parent's lock. Thus, we introduce a lock flag > in bus_type struct and driver core would lock the parent lock base > on the flag. For usbsystem, we set this flag in usb relatvie USB system USB relative > bus_type struct to keep original lock behavior in driver core. > > Async probe could have more benefit after this patch. > - if (dev->parent) /* Needed for USB */ > + if (dev->parent && dev->bus->need_parent_lock) So, why not to use bus directly like bus->...? > device_lock(dev->parent); > device_release_driver(dev); > - if (dev->parent) > + if (dev->parent && dev->bus->need_parent_lock) > device_unlock(dev->parent); Ditto here and everywhere else in the patch where applicable. > + .need_parent_lock = 1, > + .need_parent_lock = 1, > + .need_parent_lock = 1, It's boolean, you need to use true or false. Check and fix your code correspondingly. > + bool need_parent_lock; -- With Best Regards, Andy Shevchenko