From patchwork Tue Dec 15 20:27:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tadeusz Struk X-Patchwork-Id: 7857101 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 536999F349 for ; Tue, 15 Dec 2015 20:30:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7DA9C203C1 for ; Tue, 15 Dec 2015 20:30:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A3CBA203C0 for ; Tue, 15 Dec 2015 20:30:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933661AbbLOUao (ORCPT ); Tue, 15 Dec 2015 15:30:44 -0500 Received: from mga03.intel.com ([134.134.136.65]:38204 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933651AbbLOUan (ORCPT ); Tue, 15 Dec 2015 15:30:43 -0500 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP; 15 Dec 2015 12:30:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,434,1444719600"; d="scan'208";a="708273015" Received: from tstruk-mobl1.jf.intel.com (HELO tstruk-mobl1.intel.com) ([134.134.171.80]) by orsmga003.jf.intel.com with ESMTP; 15 Dec 2015 12:30:43 -0800 Subject: Re: [patch] crypto: qat - fix some timeout tests To: Dan Carpenter References: <20151215100515.GB20848@mwanda> Cc: Herbert Xu , "David S. Miller" , Bruce Allan , Pingchao Yang , qat-linux@intel.com, linux-crypto@vger.kernel.org, kernel-janitors@vger.kernel.org From: Tadeusz Struk Message-ID: <567077AB.8040602@intel.com> Date: Tue, 15 Dec 2015 12:27:23 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <20151215100515.GB20848@mwanda> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 12/15/2015 02:05 AM, Dan Carpenter wrote: > We do an "if (!times)" test later to see if we ran the loop too many > times, but because it is a postop negate that means times is -1 when we > exit that way. I have fixed this by changing it from a post op to a > preop. > > Fixes: b3416fb8a2f5 ('crypto: qat - Intel(R) QAT accelengine part of fw loader') > Signed-off-by: Dan Carpenter > --- > This means we only loop 9999 times instead of 10000 like before but I > figure it probably doesn't matter. > > diff --git a/drivers/crypto/qat/qat_common/qat_hal.c b/drivers/crypto/qat/qat_common/qat_hal.c > index 45c1739..2b078a6 100644 > --- a/drivers/crypto/qat/qat_common/qat_hal.c > +++ b/drivers/crypto/qat/qat_common/qat_hal.c > @@ -171,7 +171,7 @@ static int qat_hal_wait_cycles(struct icp_qat_fw_loader_handle *handle, > > qat_hal_rd_ae_csr(handle, ae, PROFILE_COUNT, &base_cnt); > base_cnt &= 0xffff; > - while ((int)cycles > elapsed_cycles && times--) { > + while ((int)cycles > elapsed_cycles && --times) { > if (chk_inactive) > qat_hal_rd_ae_csr(handle, ae, ACTIVE_CTX_STATUS, &csr); > > Since the times var is an signed int I think we should rather change the condition: Pingchao could you test and send a patch please. Thanks diff --git a/drivers/crypto/qat/qat_common/qat_hal.c b/drivers/crypto/qat/qat_common/qat_hal.c index 45c1739..864a5ea 100644 --- a/drivers/crypto/qat/qat_common/qat_hal.c +++ b/drivers/crypto/qat/qat_common/qat_hal.c @@ -186,7 +186,7 @@ static int qat_hal_wait_cycles(struct icp_qat_fw_loader_handle *handle, if (elapsed_cycles >= 8 && !(csr & (1 << ACS_ABO_BITPOS))) return 0; } - if (!times) { + if (!(0 < times)) { pr_err("QAT: wait_num_cycles time out\n"); return -EFAULT; }