Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp1064088rdh; Fri, 27 Oct 2023 03:55:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGgyZVKOmPfS7Ud2Gbjrlxx5UaSyE4fTMOCbi71B6q1QUT0JH1Jwk0u7bvRGh8JZWMT1Fgb X-Received: by 2002:a25:ab89:0:b0:d9b:37dd:a3d7 with SMTP id v9-20020a25ab89000000b00d9b37dda3d7mr2076515ybi.17.1698404121541; Fri, 27 Oct 2023 03:55:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698404121; cv=none; d=google.com; s=arc-20160816; b=QWq/9VLXNrtlFn+5CejzLLGpOpzimgdl48ImTqzLNHNk44bv3IA+dz88dPDXa129Z5 PU/yaIlG6P8I+hjWVT4l6x0TbWflSa/4rH6Y3Gx/YCE84nRmB32Dw/H8vixqb5gQjFVp DS+Ty4E/dNDNuCY/jbKK0iCzCnr++HpmAoTtKLFhahrdaOV4+L81KgkSj3kMmDj/Ex99 vbblQg2WUGqi8cTa4BlPAQdZNY1Jhx+tA0tSSqNcafnIfEexKpm899CLRzbgM4l+Z80Z bUbAtPLmmis45xNpx/olVIWFGyZ8Nkaf6sEOv/EQ4yuVo26lLbEFZVe3RdLVtv1LcoS0 hJgQ== 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; bh=W12MmrAEbimU77fQz6s4yaVCD8FQ6NzJtFTVWjTnlkE=; fh=kjuqaHkJwKgVTOCrSYXVGooHO6COyLyb7rpzHLawCbQ=; b=Fn91v48I54AkmCfTIfCzuA9mhA+IOyAamw0HKHbl4Q/uYsLX4xEIbngu+7pNJjaBwY QTCcTBwK/xE2V0Uc7zsBdmchcvbqeN+Nr229jVnw9WCRloVqvdnw0TpqNJe2djBhjH5N BRgb+2hKbAKz2TwGfIskSjVzZ9AbOg6nleIoQutkFdNDnPxsgsH0TN7d1+R0kgMHUBha 86pVKJV+nXv0blhu+6m1tiBlzBroT8Z33N6YKmLtKWOgotsOMnfaflAQulq+3jgdFPG6 uDO6lw3UZiYUaXFCFOP6IAfORRxnPYOEYo67vD08fjiJacVOByV/t6Zh9INrmK2IUVkz kWnA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id y76-20020a25dc4f000000b00d8185415873si2218907ybe.489.2023.10.27.03.55.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 03:55:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 6D35983650B1; Fri, 27 Oct 2023 03:55:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345671AbjJ0KzP (ORCPT + 99 others); Fri, 27 Oct 2023 06:55:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345696AbjJ0KzO (ORCPT ); Fri, 27 Oct 2023 06:55:14 -0400 Received: from abb.hmeau.com (abb.hmeau.com [144.6.53.87]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD9D69C for ; Fri, 27 Oct 2023 03:55:11 -0700 (PDT) Received: from loth.rohan.me.apana.org.au ([192.168.167.2]) by formenos.hmeau.com with smtp (Exim 4.94.2 #2 (Debian)) id 1qwKUd-00BebO-E5; Fri, 27 Oct 2023 18:55:08 +0800 Received: by loth.rohan.me.apana.org.au (sSMTP sendmail emulation); Fri, 27 Oct 2023 18:55:13 +0800 Date: Fri, 27 Oct 2023 18:55:13 +0800 From: Herbert Xu To: Giovanni Cabiddu Cc: linux-crypto@vger.kernel.org, qat-linux@intel.com, Mikulas Patocka Subject: Re: [PATCH] crypto: qat - fix deadlock in backlog processing Message-ID: References: <20231020153330.70845-1-giovanni.cabiddu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231020153330.70845-1-giovanni.cabiddu@intel.com> X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 27 Oct 2023 03:55:17 -0700 (PDT) On Fri, Oct 20, 2023 at 04:33:21PM +0100, Giovanni Cabiddu wrote: > If a request has the flag CRYPTO_TFM_REQ_MAY_BACKLOG set, the function > qat_alg_send_message_maybacklog(), enqueues it in a backlog list if > either (1) there is already at least one request in the backlog list, or > (2) the HW ring is nearly full or (3) the enqueue to the HW ring fails. > If an interrupt occurs right before the lock in qat_alg_backlog_req() is > taken and the backlog queue is being emptied, then there is no request > in the HW queues that can trigger a subsequent interrupt that can clear > the backlog queue. In addition subsequent requests are enqueued to the > backlog list and not sent to the hardware. > > Fix it by holding the lock while taking the decision if the request > needs to be included in the backlog queue or not. This synchronizes the > flow with the interrupt handler that drains the backlog queue. > > For performance reasons, the logic has been changed to try to enqueue > first without holding the lock. > > Fixes: 386823839732 ("crypto: qat - add backlog mechanism") > Reported-by: Mikulas Patocka > Closes: https://lore.kernel.org/all/af9581e2-58f9-cc19-428f-6f18f1f83d54@redhat.com/T/ > Signed-off-by: Giovanni Cabiddu > --- > .../intel/qat/qat_common/qat_algs_send.c | 46 ++++++++++--------- > 1 file changed, 25 insertions(+), 21 deletions(-) Patch applied. Thanks. -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt