From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755727AbdABO4c (ORCPT ); Mon, 2 Jan 2017 09:56:32 -0500 Received: from mga02.intel.com ([134.134.136.20]:57279 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755652AbdABO4a (ORCPT ); Mon, 2 Jan 2017 09:56:30 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,432,1477983600"; d="scan'208";a="918148657" Subject: Re: [PATCH 2/2] usb: host: xhci: Handle the right timeout command To: Baolin Wang References: <0c39bfed1cf6f7b747e702aa841f82c9d2140f27.1480922249.git.baolin.wang@linaro.org> <584EC7B9.6040100@linux.intel.com> <5857B794.2070100@linux.intel.com> <5857CEE4.6040007@intel.com> <5858B3AE.90705@linux.intel.com> <5858D231.7040407@linux.intel.com> <5858DB52.8060707@linux.intel.com> <58594A9A.10507@linux.intel.com> <585A7D06.4000105@linux.intel.com> Cc: Lu Baolu , Mathias Nyman , Greg KH , USB , LKML , Mark Brown , "Lu, Baolu" From: Mathias Nyman Message-ID: <586A6A61.8040902@linux.intel.com> Date: Mon, 2 Jan 2017 16:57:37 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27.12.2016 05:07, Baolin Wang wrote: > Hi, > > On 21 December 2016 at 21:00, Mathias Nyman > wrote: >> On 21.12.2016 04:22, Baolin Wang wrote: >>> >>> Hi Mathias, >>> >>> On 20 December 2016 at 23:13, Mathias Nyman >>> wrote: >>>> >>>> On 20.12.2016 09:30, Baolin Wang wrote: >>>> ... >>>> >>>> Alright, I gathered all current work related to xhci races and timeouts >>>> and put them into a branch: >>>> >>>> git://git.kernel.org/pub/scm/linux/kernel/git/mnyman/xhci.git >>>> timeout_race_fixes >>>> >>>> Its based on 4.9 >>>> It includes a few other patches just to avoid conflicts and make my life >>>> easier >>>> >>>> Interesting patches are: >>>> >>>> ee4eb91 xhci: remove unnecessary check for pending timer >>>> 0cba67d xhci: detect stop endpoint race using pending timer instead of >>>> counter. >>>> 4f2535f xhci: Handle command completion and timeout race >>>> b9d00d7 usb: host: xhci: Fix possible wild pointer when handling abort >>>> command >>>> 529a5a0 usb: xhci: fix possible wild pointer >>>> 4766555 xhci: Fix race related to abort operation >>>> de834a3 xhci: Use delayed_work instead of timer for command timeout >>>> 69973b8 Linux 4.9 >>>> >>>> The fixes for command queue races will go to usb-linus and stable, the >>>> reworks for stop ep watchdog timer will go to usb-next. >>> >>> >>> How about applying below patch in your 'timeout_race_fixes' branch? >>> [PATCH] usb: host: xhci: Clean up commands when stop endpoint command is >>> timeout >>> https://lkml.org/lkml/2016/12/13/94 >>> >> >> usb_hc_died() should eventyally end up calling xhci_mem_cleanup() >> which will cleanup the command queue. But I need to look into that > > usb_hc_died() did not call xhci_mem_cleanup() to clean up command > queue, it just disconnects all children devices attached on the dying > hub. I did not find where it will clean up the command queue when > issuing usb_hc_died(). Also before issuing usb_hc_died() in > xhci_handle_command_timeout(), we will call > xhci_cleanup_command_queue(). I think it should same as in > xhci_stop_endpoint_command_watchdog(). > You're right, it doesn't call xhci_mem_cleanup. Need to look at this after getting first series of fixes to usb-linus -Mathias