Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp330085pxb; Thu, 26 Aug 2021 04:18:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVabA0LhghH42UDetsha2mrcWxpqS9XCiYvyDk9AjSohfo/pRtWOVWV/lTglikxcVeQTVX X-Received: by 2002:a5d:9ad0:: with SMTP id x16mr2637713ion.182.1629976738113; Thu, 26 Aug 2021 04:18:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629976738; cv=none; d=google.com; s=arc-20160816; b=ZSJGBg2LIOstEMwfDzTs9qDJjskjFadtA2qw2pwGoA81EIF1mg9l69XbOyd49VrAou WB8VGqe01E05VHcaag9Z4VkFiArR4D4HNTg1YSPryX0JTnp1+SXHbQ1DyyvUBgpaHneM CCx/yxuBVYdO6c1GpIoVBCQMZsMfveriY/pGG7drBSHWisHI7uzfOBMFqyDW41SLwoaq lRmBdElAOVQF01GKQF6dMH+2ik9E5mZcIB/HE4EvH7PabF0iTsQbfmgoutLNBMCGb0A9 l/ZxB0qh9HZHGMrJ5XcZ2ZEnL/D5Maj3ydSScLRRtthVPfFDEm3axq4KNcaOHKFtX7/K evfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=PmC4WYD7mpCE0FgBPCm+vyNCR9LINCrIHvVmmmjNRAs=; b=ZUI86nARKjaNdsNa3suZhC9KEeOATfeq9eQhfJh5f9zdWu3vsXVMvxq415gf3qq6GY tIBHwx+hKHO0NvgLlkp35A/Zx8G6ddgMMBZyRWqP+aCBfN9BZWvLGo5t+Ees2bRLmH3s 7AgEBn5MFDSbWECWjp1m42ki/E3yW+C1aGLZDqBBlkMUz5fbNX5x5H7Stw27yW9qav1A 45aX2m4/9Y88W7+3JuU7gRXjni1AIU5d7UbSd+eSJr2EdtSXD2uFtfnP+/viqP5oyXYm emSbj3jEWi3EBIkZQv4/2u1kJPDzm2ccfgAtGN2jyINT2mswIy6Cr6iFNPkbbRH7g71v ELLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NaMxParJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m11si2809403jaj.5.2021.08.26.04.18.46; Thu, 26 Aug 2021 04:18:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NaMxParJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241887AbhHZLSW (ORCPT + 99 others); Thu, 26 Aug 2021 07:18:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:57610 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233736AbhHZLSV (ORCPT ); Thu, 26 Aug 2021 07:18:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0A3E3610A4; Thu, 26 Aug 2021 11:17:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1629976654; bh=rj+1dxJfAFKdj8Dhrnrr16eUI58mr8w3p7l4glHVvx0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NaMxParJDyi+yixAw+EbULYF6f5FIuXp59gnMDB9xGPA4AqozC6ZkuNhfV1DshSYD ANt4pSy4OgJaw1Pn5ktDc+378vF0A9NGubMsZMolPilYHc0YIQdmNTTw2x20NN4jYG e/N++lLUB5pXl63NzhSON1rfDsLDQnr2VWaPduFw= Date: Thu, 26 Aug 2021 13:17:30 +0200 From: Greg Kroah-Hartman To: Jeaho Hwang Cc: Peter Chen , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, team-linux@rtst.co.kr, mkbyeon@lselectric.co.kr, khchoib@lselectric.co.kr Subject: Re: [PATCH v2] usb: chipidea: add loop timeout for hw_ep_set_halt() Message-ID: References: <20210817064353.GA669425@ubuntu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210817064353.GA669425@ubuntu> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 17, 2021 at 03:43:53PM +0900, Jeaho Hwang wrote: > If ctrl EP priming is failed (very rare case in standard linux), > hw_ep_set_halt goes infinite loop. waiting 100 times was enough > for zynq7000. > > Signed-off-by: Jeaho Hwang > > diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c > index 8834ca613721..d73fadb18f32 100644 > --- a/drivers/usb/chipidea/udc.c > +++ b/drivers/usb/chipidea/udc.c > @@ -209,6 +209,9 @@ static int hw_ep_prime(struct ci_hdrc *ci, int num, int dir, int is_ctrl) > return 0; > } > > +/* enough for zynq7000 evaluation board */ > +#define HW_EP_SET_HALT_COUNT_MAX 100 > + > /** > * hw_ep_set_halt: configures ep halt & resets data toggle after clear (execute > * without interruption) > @@ -221,6 +224,7 @@ static int hw_ep_prime(struct ci_hdrc *ci, int num, int dir, int is_ctrl) > */ > static int hw_ep_set_halt(struct ci_hdrc *ci, int num, int dir, int value) > { > + int count = HW_EP_SET_HALT_COUNT_MAX; > if (value != 0 && value != 1) You need a blank line after "int count..." > return -EINVAL; > > @@ -232,9 +236,9 @@ static int hw_ep_set_halt(struct ci_hdrc *ci, int num, int dir, int value) > /* data toggle - reserved for EP0 but it's in ESS */ > hw_write(ci, reg, mask_xs|mask_xr, > value ? mask_xs : mask_xr); > - } while (value != hw_ep_get_halt(ci, num, dir)); > + } while (value != hw_ep_get_halt(ci, num, dir) && --count > 0); > > - return 0; > + return count ? 0 : -EAGAIN; Please spell this out: if (count) return 0; return -EAGAIN; And will the caller properly handle this? thanks, greg k-h