Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4978427yba; Tue, 30 Apr 2019 07:19:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqzH4YDOMJaETKe74hvyl24X82tw8J0w8v4nkQokxUWatgjYrvwyUULRltnZqpJ2K0cfYf1p X-Received: by 2002:a63:cc48:: with SMTP id q8mr37494264pgi.202.1556633986604; Tue, 30 Apr 2019 07:19:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556633986; cv=none; d=google.com; s=arc-20160816; b=ako6LPN2VQKIsgwPZJjFZLTeqCXA2ijJmLlu3lKtvnniwwCfaMv7K6SQ28KpRY0q/L Uze5fYZcYecF5Yt4b/PmMdtAVMRpOK3mTiZSNwk1vhlhJol4V0UsJ6zAG59vEtoD0sBg Jh2zvHjx3wB5kQEX3LF8hX2sM0hhdwNATofxgTIM34V9fFzOIcv/m1h20+AGGknWGa/J gtKd80MyIKF0l1w3NZ8dG8uT8ahlLPs20khHTNU+W1tQCc7LyeYoFkN7xA8lZBoeziAn 7tNqZ3wE34HFB6R+w9gWMBmb/7ZRk0vdXtG72ovac9CdB1PwMgk/X7jaaz6MIhe55/qn tLSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date; bh=DOYl3cA9MmmoiNzXWdDsM5Rf3YUEdJytMe45s//zvTI=; b=X7JUlpkplUhpQ4ZfJ57hOWUIEXGkpDNK5HP/S9mxcxaQu1ujLnI2VWhS65PiddYDhO R+jKk629Sf81Dzo1IEyX4IIA/IPg6veeoi9C656wErlR0o3SqIGHqTI5DwkJLXpuy9lS OdWJgeSnnFilEtSCtyah6xk7fcRZ0BcuOGLzUc2NBA/JndEW/2K8SPGMrrZ/PygtmW/x R3yYl+tKWtfogzKm2XlpATSiEYu0FQePnKwO7KgFCTur6jmhVwcSEPlHj0jqL5lVFn/0 BMDFvAdB3tqjy3+5jVemTKXWtTQLu/pg1SJTpnickaT24V2G2DIt3urLOZcTorEkg1E0 4GAg== 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 i3si22492595plt.237.2019.04.30.07.19.29; Tue, 30 Apr 2019 07:19:46 -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; 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 S1727205AbfD3ORH (ORCPT + 99 others); Tue, 30 Apr 2019 10:17:07 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:35386 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726164AbfD3ORH (ORCPT ); Tue, 30 Apr 2019 10:17:07 -0400 Received: (qmail 2055 invoked by uid 2102); 30 Apr 2019 10:17:06 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 30 Apr 2019 10:17:06 -0400 Date: Tue, 30 Apr 2019 10:17:06 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: "Tangnianyao (ICT)" cc: mathias.nyman@intel.com, , , Subject: Re: [RFC] Question about reset order for xhci controller and pci In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 30 Apr 2019, Tangnianyao (ICT) wrote: > On 2019/4/29 22:06, Alan Stern wrote: > > Hi, Alan > > > On Mon, 29 Apr 2019, Tangnianyao (ICT) wrote: > > > >> Using command "echo 1 > /sys/bus/pci/devices/0000:7a:02.0/reset" > >> on centos7.5 system to reset xhci. > >> > >> On 2019/4/26 11:07, Tangnianyao (ICT) wrote: > >>> Hi,all > >>> > >>> I've meet a problem about reset xhci and it may be caused by the > >>> reset order of pci and xhci. > >>> Using xhci-pci, when users send reset command in os(centos or red-hat os), > >>> it would first reset PCI device by pci_reset_function. During this > >>> process, it would disable BME(Bus Master Enable) and set BME=0, and > >>> then enable it and set BME=1. > >>> And then it comes to xhci reset process. First, it would send an > >>> endpoint stop command in xhci_urb_dequeue. However, this stop ep command > >>> fails to finish. The reason is that BME is set to 0 in former process and > >>> xhci RUN/STOP changes to 0, and when BME is set to 1 again, RUN/STOP doesn't > >>> recover to 1. > >>> I've checked BME behavior in xhci spec, it shows that "If the BME bit is set to 0 > >>> when xHC is running, the xHC may treat this as a Host Controller Error, asserting > >>> HCE(1) and immediately halt(R/S=0 and HCH=1). Recovery from this state will > >>> require an HCRST." It seems that the stop ep command failure is reasonable. > >>> Maybe I've missed something and please let me know. > > > > Your email subject says "Question about...". What is the question? > > > Sorry I didn't descibe it clearly. > When sending a reset command, now the reset order is first BME and then xhci. > BME reset would make xhci controller stop, resulting in xhci reset failure, > because it can't finish stop ep command in xhci_urb_dequeue. > I'm not sure if this situation is in expectation. Probably it isn't. > > Also, given that your question concerns what happens when you write to > > /sys/bus/pci/..., perhaps you should consider mailing it to some PCI > > maintainers as well as to the USB maintainers. > > ok, I will mailing it to PCI maintainer as well. > > > Perhaps the reset was not meant to be used the way you are doing it. > > A more conservative approach would be to unbind xhci-hcd from the > > device before doing the reset and then rebind it afterward. > > > > Alan Stern > > > > > > . > > > > I think this approach not work. When reset BME, xhci controller is stopped and > can't recover even BME is set enable later. According to xhci spec, it's appropriate. > When rebind it afterward, with xhci stop, xhci driver would consider the > xhci controller already died and it fails to work again. > > To recover xhci, now I rmmod xhci-pci.ko and then insmod it again. That's basically what I meant. "rmmod xhci-pci" does an unbind, and "insmod xhci-pci.ko" does a rebind. So long as you do the unbind before the reset and the rebind after the reset, you should be okay. Perhaps you misunderstood what I wrote; it sounds like you're doing the reset first and then the unbind. Alan Stern