Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3197699imm; Sun, 29 Jul 2018 12:36:55 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeWb+/6GDka834ChdBvoqtEF6mej13rg01LzaXPHOhF+rKzI9Oqso4FQNe2Df9KQREzf0hR X-Received: by 2002:a17:902:9042:: with SMTP id w2-v6mr13908086plz.61.1532893015514; Sun, 29 Jul 2018 12:36:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532893015; cv=none; d=google.com; s=arc-20160816; b=vTSToIvzIZGVqgZN1h/6oWtkeRaYEFQiUDfcMD3dkvcm9qmW9hbduRb82Wf0MpN53/ sKX3i+JdJjbA1EsjC5WxYMJu7DWKL5WAauFkbhGO0coZDOZ33BzLBPNCm8UbRixEEPvj NDnLVqnehpv2sC/qh5w1ka0OZk3I8a0QP1ERXB3pS8cCTxpeL3hA/iA5ss5Mmf80GG7d 9TloRymWqBAOAcNQmcj/QFyTWWIeIFgNG/FVZXLO8eYuaso5vR6NSr6e5lQDlkxJXWcR r9HmeSOC7LvbSYooRvTROxn47nmslUM0YVLpe4cVK7hWsMJPIYpAobS3buPVyvMJo2qt GRSQ== 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:arc-authentication-results; bh=KS/ZRt8IApYtZ+JHPXMOlCTf1Q6gHoMbsuReH+uEAi0=; b=SMUEpfYd5aohf4yT3HEMPZTzPm/H9NxsRiNYi1+cCa2DdBgH0J4ttQ8bUk91l0nbOs O7UiYeXu4vjNdRgXA4AWD3Pj7g4Ih5bRcsFnTAOteIxLtSqsRZsx9nC5PEpnP6pQ525Z FvcXG46JZluQw/hc3LOCTKqeiP7a5+OBVgGH5ti9ZIGKb3zhVBAU3Lhkosrg/Npu4e+u nQnSnjLSrsqy/s1LYikk8Q3yANAVRwiYMdFMeAX68bIrCwfRD1qQRN+4RgXnNbyxJeer YjE8n9IY2VQYiZBVsOz1whMvHct+3vYrwLTepPL2jIfecI+xb67+YHuVskQBUgW8bIRW fn9Q== 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 a67-v6si3288349pla.135.2018.07.29.12.36.41; Sun, 29 Jul 2018 12:36:55 -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 S1728629AbeG2VHG (ORCPT + 99 others); Sun, 29 Jul 2018 17:07:06 -0400 Received: from emh07.mail.saunalahti.fi ([62.142.5.117]:47466 "EHLO emh07.mail.saunalahti.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726586AbeG2VHG (ORCPT ); Sun, 29 Jul 2018 17:07:06 -0400 X-Greylist: delayed 510 seconds by postgrey-1.27 at vger.kernel.org; Sun, 29 Jul 2018 17:07:04 EDT Received: from darkstar.musicnaut.iki.fi (85-76-68-182-nat.elisa-mobile.fi [85.76.68.182]) by emh07.mail.saunalahti.fi (Postfix) with ESMTP id 24121B004B; Sun, 29 Jul 2018 22:27:04 +0300 (EEST) Date: Sun, 29 Jul 2018 22:27:03 +0300 From: Aaro Koskinen To: Georgios Tsotsos Cc: Greg Kroah-Hartman , James Hogan , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 2/2] Staging: octeon-usb: Changes macro CVMX_WAIT_FOR_FIELD32 to function call. Message-ID: <20180729192703.GA14390@darkstar.musicnaut.iki.fi> References: <20180727151527.GA2209@kroah.com> <0e52fbfefc34fe064201da9ad93e12e50e1e816c.1532864087.git.tsotsos@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0e52fbfefc34fe064201da9ad93e12e50e1e816c.1532864087.git.tsotsos@gmail.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Sun, Jul 29, 2018 at 02:40:35PM +0300, Georgios Tsotsos wrote: > +/** > + * Loop through register until txfflsh or rxfflsh become zero. > + * > + * @usb: USB block > + * @address: 64bit address to read > + * @timeout_usec: Timeout > + * @fflsh_type: Indicates fflsh type, 0 for txfflsh, 1 for rxfflsh > + * > + */ > +static int cvmx_wait_for_field32(struct octeon_hcd *usb, u64 address, > + u64 timeout_usec, int fflsh_type) You should change the name of the function, as it's no longer generic "wait for any field" to reach specified condition. The "address" should be calculated from "usb" inside the function. The timeout is always 100, you could just omit it. Nobody is ever checking the result, so it's also redundant... [...] > +{ > + int result; > + u64 done = cvmx_get_cycle() + timeout_usec * > + (u64)octeon_get_clock_rate / 1000000; > + > + union cvmx_usbcx_grstctl c; > + > + while (1) { > + c.u32 = cvmx_usb_read_csr32(usb, address); > + if (fflsh_type == 0 && c.s.txfflsh == 0) { > + result = 0; > + break; > + } else if (fflsh_type == 1 && c.s.rxfflsh == 0) { > + result = 0; > + break; > + } else if (cvmx_get_cycle() > done) { > + result = -1; > + break; > + } > + > + __delay(100); > + } > + return result; > +} > + > static void cvmx_fifo_setup(struct octeon_hcd *usb) > { > union cvmx_usbcx_ghwcfg3 usbcx_ghwcfg3; > @@ -635,11 +648,9 @@ static void cvmx_fifo_setup(struct octeon_hcd *usb) > /* Flush all FIFOs */ > USB_SET_FIELD32(address, cvmx_usbcx_grstctl, txfnum, 0x10); > USB_SET_FIELD32(address, cvmx_usbcx_grstctl, txfflsh, 1); > - CVMX_WAIT_FOR_FIELD32(address, cvmx_usbcx_grstctl, > - c.s.txfflsh == 0, 100); > + cvmx_wait_for_field32(usb, address, 0, 100); How did you test this patch? The parameters are in wrong order, you are specifying 0 timeout. > USB_SET_FIELD32(address, cvmx_usbcx_grstctl, rxfflsh, 1); > - CVMX_WAIT_FOR_FIELD32(address, cvmx_usbcx_grstctl, > - c.s.rxfflsh == 0, 100); > + cvmx_wait_for_field32(usb, address, 1, 100); Also wrong order here. A.