From patchwork Tue Nov 5 14:00:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 178507 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp709772ocf; Tue, 5 Nov 2019 06:01:51 -0800 (PST) X-Google-Smtp-Source: APXvYqxYcUA+p/nCBAGkEMZ/1DIb73JrmnGL0vVB+lZs6Jt4gSJjdnNCmEvcuNIOlGDf3xdpvepj X-Received: by 2002:a17:906:bd2:: with SMTP id y18mr22034453ejg.315.1572962511550; Tue, 05 Nov 2019 06:01:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572962511; cv=none; d=google.com; s=arc-20160816; b=damwOBN95LLenIi2JHvd1uiFUJpbhsSnOX7oBYhIOmyy7URF1Ti52ij53L2F9B+ROQ fKIRqvdaHBwe2Fv6ShCRvYms+2K49CWC06LfxbDkrV0oZ0lLqm21pkWvixleCL5mTooN 8gLVy19YYbqtrIv1XgPZcWInQkIYkIRyAIHvk6ZvyuS8vLz8FvSKhGv2klVPqeWQ/sKV hOpnM1vVvIlHUYg6CB93yG236jsk+OIy+iHe0rjU2nZih0TOqMHR5ii5duoqI3PlGpQe oNww2RF9QyOVQ4LTE0Aobt91XImWh58e+T6zmU+3YfR1TuE0uc4ZHOD5IZ/kxSVGU8zu 9oOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=DytK5ZfNQDTyFQ9kvyYcuDXQB7MIOphvtCQ9eA53fOk=; b=ldwW6k9DyUlze6RY0sn3rBRQySC82yrkqPPZHFEPg4wk/c3o3rt9fOS4/12Mjj8yNM dWthPsqfe4i7AC6Hqioi+6eL20yq0pJx4zAXQ9Livng5ywLym9th8S7cKSOID3NIjZeX C47tHbG5pRzE1oUYG3Plqu5dm9ihrrg0y4yVtYdo98koKtFlNhoR0t7bMdPhtymv4Ys/ q3TV6ktGnqdNWXC5w/3QTEYLrd6gYmhXQkrks3km3TOJcczhd5iRrJsDDH8Gc9Snl9Jk q+kSwz3JM/G8khUExqhEqdvxZf/EeXdeHwTxWhIzCtuh1Jp8Yn6TMUm2aYCwu1A7m3wY 42Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=yrgeKv7a; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dk11si13340421ejb.97.2019.11.05.06.01.51; Tue, 05 Nov 2019 06:01:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=yrgeKv7a; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389414AbfKEOBr (ORCPT + 5 others); Tue, 5 Nov 2019 09:01:47 -0500 Received: from lelv0143.ext.ti.com ([198.47.23.248]:35154 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389377AbfKEOBr (ORCPT ); Tue, 5 Nov 2019 09:01:47 -0500 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id xA5E1f5R038178; Tue, 5 Nov 2019 08:01:41 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1572962501; bh=DytK5ZfNQDTyFQ9kvyYcuDXQB7MIOphvtCQ9eA53fOk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=yrgeKv7aDdjQaAbIiyW8ZERkZDAo1pKPFIrMLGV92vBUrNiYOg6LCq3Amz7+UOUfJ JNVGwegQfqS2J77wNpRalEJ2cSk7pzjyR0caFiESwx2BTAH66kry0ZUdckMM7MduGs gT/okgs4mqXvWX2t7zEV3hirByAdVHbvtm5tEHa0= Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id xA5E1fpn008046 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 5 Nov 2019 08:01:41 -0600 Received: from DFLE101.ent.ti.com (10.64.6.22) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Tue, 5 Nov 2019 08:01:24 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE101.ent.ti.com (10.64.6.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Tue, 5 Nov 2019 08:01:24 -0600 Received: from sokoban.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id xA5E1FFm068289; Tue, 5 Nov 2019 08:01:38 -0600 From: Tero Kristo To: , , CC: , Subject: [PATCHv2 09/22] crypto: add timeout to crypto_wait_req Date: Tue, 5 Nov 2019 16:00:58 +0200 Message-ID: <20191105140111.20285-10-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191105140111.20285-1-t-kristo@ti.com> References: <20191105140111.20285-1-t-kristo@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Currently crypto_wait_req waits indefinitely for an async crypto request to complete. This is bad as it can cause for example the crypto test manager to hang without any notification as to why it has happened. Instead of waiting indefinitely, add a 1 second timeout to the call, and provide a warning print if a timeout happens. Signed-off-by: Tero Kristo --- include/linux/crypto.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) -- 2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/include/linux/crypto.h b/include/linux/crypto.h index 19ea3a371d7b..41279eeecb21 100644 --- a/include/linux/crypto.h +++ b/include/linux/crypto.h @@ -682,8 +682,15 @@ static inline int crypto_wait_req(int err, struct crypto_wait *wait) switch (err) { case -EINPROGRESS: case -EBUSY: - wait_for_completion(&wait->completion); + err = wait_for_completion_timeout(&wait->completion, + msecs_to_jiffies(1000)); reinit_completion(&wait->completion); + if (!err) { + pr_err("%s: timeout for %p\n", __func__, wait); + err = -ETIMEDOUT; + break; + } + err = wait->err; break; };