Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2835547imm; Thu, 24 May 2018 17:12:29 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq3+sKpaJr2ZZ/6IbVwJM5tf98NCksR75nrzUuVmheFAKrpSMXnqbQtzQzQYO8IAY0P2b62 X-Received: by 2002:a17:902:bcc5:: with SMTP id o5-v6mr137952pls.349.1527207149264; Thu, 24 May 2018 17:12:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527207149; cv=none; d=google.com; s=arc-20160816; b=PHFQztiUXsAvd1krryomrzwZ1amkiZpech0lgPz5+GHIIDrtI1ClwTZ4ZS8Vr8KmMh NDrnghSgJZaVHSQ1+7hXRGTSiUkaXlanOUn1VVRdYt0tEsPtmlshkE6Q4F1KD/JmhSc/ 97VuCQiYIqdSl3ijly9+dxt+J7mBLZOOgWwoTkVSuevl6F20bxNI3yBmh9Bi0kfPrKp3 rrZfPVJ7YFtgHv/K1y8v5qWc85KdyP0wbj7RktPk3ksXN7se8aleCLALCKMcRK13snT9 2plFLK5+yv/kYvzuNNVNC7Z7QXxhX3uJePf+9G3R34a7Yaz1Au4fSxLz7jf1MAR3EW5e 1Trg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=9CCv86tHYluq5HENkFsqomM7DGc+IISuZ335ngB8FTo=; b=qqjjsnEDulp+TOX1K5hgpfHDPARW9NEjrLwUkI0q5nfJUBHmhcGxsaBybGcn+1yjFQ BPUQRuyWrjdNqvc+V/VH/s4gnFFyzskGr0G0Giz+FoHMUmnZjUhtUhz0fnFfPD2NgPQh H/XDuJEBqApR1Lt/+FpbKMI9ebEN3NsKEuKW4K1K0QP5cjV9e21Z64fySyd9sYwCTuLN rmRyoKF77uvQ9GN8t7v8NZh7jUukUtZU38XHywiyyoVvGa1qSfp8yGSHZYSt399F1yHF g61q7lwsKYz3hY/FxBqAITRzwuj0lKh9A+1P9m6Wrp/bkp0FdQyo7bgig8Tnvn3zk/tM iyPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=bnd90wz8; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 206-v6si22051117pfw.130.2018.05.24.17.12.14; Thu, 24 May 2018 17:12:29 -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=@google.com header.s=20161025 header.b=bnd90wz8; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S970249AbeEXOAa (ORCPT + 99 others); Thu, 24 May 2018 10:00:30 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:42814 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965515AbeEXOA1 (ORCPT ); Thu, 24 May 2018 10:00:27 -0400 Received: by mail-pf0-f193.google.com with SMTP id p14-v6so932398pfh.9 for ; Thu, 24 May 2018 07:00:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=9CCv86tHYluq5HENkFsqomM7DGc+IISuZ335ngB8FTo=; b=bnd90wz8CPQctXq+mDJZ9/SVgY5OYrMW8MU3a4NBpQ/NP9Gewpx4jMJmGVP1ikkfQX rtpuOnIpyNvdPGgLvLDBq1Aul166gwrpfMnqvktOnO0pJdS7Mr8gEwMthVCYJjyt/QRj XGSdXkUlR6CoUTUEKYrxg3/Y+a+0Tfaa2W/19y1PwNDNdC3sHP6gT5np0sYVvz4JlZB8 5m4WA6/Or6Bnbf2i/YsrCxADVAxG5IODgRFTWVa1Mr7MqmN11q/zrZayIoiUJO0JpU00 KCb/GLtuJCcIMLcjgdlNa6lErd8qOmlED6QJibLucQiLanu+0NIWwq7ujJRnG3Er+ab1 qClA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=9CCv86tHYluq5HENkFsqomM7DGc+IISuZ335ngB8FTo=; b=Cb1pVKOyY30SInZaISCXczm3bi+gdQsMtD8pbU0JARvKYuGgeRfbPJyVJXcNK/gxnl 8IfsQBb8WFDeXT2qMaZqvgbElgW4uco5n33D8Awae9/nHu65npVcjvmGS4lJdRU5qak0 rg1R1Z6wVOJ9PqFIGhh7hjVbctdbQCBfvKwM+Uj6zQM4hTeoVDEW6HUfWDKDnbLTOGtr tGd7s5wacU12LkfOLYAd/LhstrDqQW0CGiQ+7s8RIIcDRHRhZ2Oipe2n/j0Uj6b8g1Oa 5panDtK7oPYPSV1g5G9cclyrasfub0VYtfTZREYICIkqPLit2mb1LhxrYVaQgZOhGYss tHgQ== X-Gm-Message-State: ALKqPweo0+v62eoLDL6dHYCoDWMFMvLzVs3p8SAS3v+BfHMdu5hCv1Ot fkvJGLnuC8KVA+L51qovilKufg== X-Received: by 2002:a62:4184:: with SMTP id g4-v6mr7433627pfd.51.1527170426284; Thu, 24 May 2018 07:00:26 -0700 (PDT) Received: from google.com ([2401:fa00:fc:202:ac57:d0e0:7094:5]) by smtp.gmail.com with ESMTPSA id f189-v6sm14231886pgc.51.2018.05.24.07.00.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 May 2018 07:00:25 -0700 (PDT) Date: Thu, 24 May 2018 22:00:21 +0800 From: Martin Liu To: Alan Stern Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, jenhaochen@google.com, liumartin@google.com Subject: Re: [RFC] driver core: don't hold dev's parent lock when using async probe Message-ID: <20180524140021.GA214888@google.com> References: <20180522141227.GA118442@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 22, 2018 at 01:09:44PM -0400, Alan Stern wrote: > On Tue, 22 May 2018, martin_liu wrote: > > > not sure if we still need 'bf74ad5bc417 ("[PATCH] Hold the > > device's parent's lock during probe and remove")' since it has > > been there over 10 years. If we still need it and hard to fix it > > , the simple way is to find a place not to allow USB subsystem > > drivers to have async probe capability. Any suggestion is welcome. > > I don't think the "allows_async_probing" attribute is the best way to > attack this. Some other approach, like a special-purpose flag, might > be better. > > Yes, USB still needs to have parent's locks held during probing. > Here's the reason. A USB device can have multiple interfaces, each > bound to its own driver. A driver may sometimes need to issue a reset, > but in USB there's no way to reset a single interface. Only the entire > device can be reset, and of course this affects all the interfaces. > Therefore a driver needs to acquire the device lock before it can issue > a reset. > > The problem is that the driver's thread may already hold the device > lock. During a normal probe sequence, for example, the interfaces get > probed by the hub driver while it owns the device lock. But for probes > under other circumstances (for example, if the user writes to the > driver's "bind" attribute in sysfs), the device lock might not be held. > > A driver cannot tell these two cases apart. The only way to make it > work all the time is to have the caller _always_ hold the device lock > while the driver is probed (or the removed, for that matter). > > Alan Stern Thanks for the reply and more detail about the backgroud. I'd like to have a conclusion about it. Please kindly correct me if my understanding is wrong. Regarding to the "special-purpose flag", do you mean we could find a place in USB subsystem to have the flag set (not sure if it's easy to find it). Driver core would be base on the flag to decide if we need to hold the device's parent's lock. Martin