Received: by 10.223.176.5 with SMTP id f5csp2321430wra; Wed, 31 Jan 2018 21:49:29 -0800 (PST) X-Google-Smtp-Source: AH8x225gg+xg4ZpOS8SshFIlER8AdwtcYWZQzDIzh01OoIFrtLFP15eCQ0wUpaTwvQnGcJuKuj89 X-Received: by 2002:a17:902:bc3:: with SMTP id 61-v6mr28501445plr.407.1517464169356; Wed, 31 Jan 2018 21:49:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517464169; cv=none; d=google.com; s=arc-20160816; b=H9Do0+L6TybHl2H8eVK2vFB4EfrKI8h6cgDf4Ty3hydmrvA/JYTsWFRVZJDVwDxNZE hvSQjbP92vmtW8MJCojI+5B8uAn7HIP7MnVotLffwoQ/r/sbG+jHLFjAnl30MzidLToa fUUqRUTxg0ZjZ/ADVsatgQNf1xKISpoIB3kTMTRzx72zYk4RCYrTXTiXE82huH6fFOiH xRii3r885Edtm3TLVPmdN70WNEdI3m0Nbe0/ofeNXEDbNSNqlyQcaMC0lEremBSmH8VH PiCqBAGASdpvNt9wnsdN4GT2DskMh2c91ehjeOfPIi5coV5MmY2DLgvUAtH9wqtkbVYk NbWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-id:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from :arc-authentication-results; bh=Gzw9z9cYiwl1dS2pDa/dp6k8oO8e8Wt4U7LOyp0xDMs=; b=1EiQSFXf44whhzRYYMbDdrop9XZjB2qonVQZME+hS+Uezrr8Qpi65vViCHhAOCWgSW pfjBmHNIK9CajoQE/jWPC6P4DVpldUpxZyQaPBF+dGFLiGogFeu3s24i8W16Td8FVecA yd38vWF/rQ+948MLPrhIDpJIRA2WC9Kak+BiFp3LeCHxsnYFtLyJxA4yo+A7BTiwniUT bXc82mOLxorNKGy7A7tzwWsMrf0xHGEdj7U0uGyK4xfKKxISaWzkF3bQA9oqGzVxNTVs kg2WX7ffAjcKA4wkKnzEHQ7EOQ/Xb60tyosWhy++TK/JjK4sAk+AMMenjkxAPtawGm8W h5HA== 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 j72si1455890pfk.24.2018.01.31.21.49.15; Wed, 31 Jan 2018 21:49:29 -0800 (PST) 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 S1751647AbeBAFsj convert rfc822-to-8bit (ORCPT + 99 others); Thu, 1 Feb 2018 00:48:39 -0500 Received: from mail5.windriver.com ([192.103.53.11]:48644 "EHLO mail5.wrs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751602AbeBAFse (ORCPT ); Thu, 1 Feb 2018 00:48:34 -0500 Received: from ALA-HCB.corp.ad.wrs.com (ala-hcb.corp.ad.wrs.com [147.11.189.41]) by mail5.wrs.com (8.15.2/8.15.2) with ESMTPS id w115mGJA007073 (version=TLSv1 cipher=AES128-SHA bits=128 verify=OK); Wed, 31 Jan 2018 21:48:20 -0800 Received: from ALA-MBC.corp.ad.wrs.com ([169.254.1.48]) by ALA-HCB.corp.ad.wrs.com ([147.11.189.41]) with mapi id 14.03.0361.001; Wed, 31 Jan 2018 21:48:13 -0800 From: "Yoshida, Shigeru" To: "stern@rowland.harvard.edu" CC: "Bai, Haiqing" , "gregkh@linuxfoundation.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] ohci-hcd: Fix race condition caused by ohci_urb_enqueue() and io_watchdog_func() Thread-Topic: [PATCH] ohci-hcd: Fix race condition caused by ohci_urb_enqueue() and io_watchdog_func() Thread-Index: AQHTmncRqxjtZV1slkO7r5QpQNTFa6OOqw2AgADm5YA= Date: Thu, 1 Feb 2018 05:48:13 +0000 Message-ID: <20180201.144911.2171407625301691891.shigeru.yoshida@windriver.com> References: <1517390197-32323-1-git-send-email-Haiqing.Bai@windriver.com> In-Reply-To: Accept-Language: ja-JP, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [128.224.232.213] Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Alan, Thank you for your commenting. On Wed, 31 Jan 2018 11:02:47 -0500, Alan Stern wrote: >> To address above scenario, this patch introduces timer_running flag to >> ohci_hcd structure. Setting true to ohci->timer_running indicates >> io_watchdog_func() is scheduled or is running. ohci_urb_enqueue() >> checks the flag when it schedules the watchdog (step 4 and 12 above), >> so ohci->prev_frame_no is not overwritten while io_watchdog_func() is >> running. > > Instead of adding an extra flag variable, which has to be kept in sync > with the timer routine, how about defining a special sentinel value for > prev_frame_no? For example: > > #define IO_WATCHDOG_OFF 0xffffff00 > > Then whenever the timer isn't scheduled or running, set > ohci->prev_frame_no to IO_WATCHDOG_OFF. And instead of testing > timer_pending(), compare prev_frame_no to this special value. > > I think that approach will be slightly more robust. It's reasonable since ohci->prev_frame_no is not used while the watchdog timer is stopped. I think we must choose an invalid frame number for the special sentinel value, but I'm not sure which value is adequate for it. Is 0xffffff00 an invalid frame number, otherwise how about simply -1(0xffffffff)? Thanks, Shigeru