Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp265rwb; Thu, 27 Jul 2023 08:31:04 -0700 (PDT) X-Google-Smtp-Source: APBJJlGDsACVKBXWcNY0cYO7BGTy09FWURGeMPI1ypVa+caspTuFEuOJfloX4JP8R6GbeDtY4W3U X-Received: by 2002:a05:6a00:1ad3:b0:675:ef91:7922 with SMTP id f19-20020a056a001ad300b00675ef917922mr5008365pfv.4.1690471863963; Thu, 27 Jul 2023 08:31:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690471863; cv=none; d=google.com; s=arc-20160816; b=iyBv2hZ6JRoeP3MkdFxMwQNydweFRsZNi0Qex57op7nxfLuwMphucpuXeFPpkJWtr7 aASZXv8Rq9/EgFGFuvrGC112khm55nWn3xIHfqHfmS9agdO1omm9W948qr5c2BuwEt3v tnKxN6qN5Xc/PVyExXuWZzsqv0XKQMRp7zMrofQ17zxyum5Zi7HH9qFkaiYMiameqpNt 86l45YpIAlB0TnIUxDyGV2L+nSxJJWYjPheVSvvIj/0AXFcEaH7PjWE47V2WJy3ejcXp RzLDJ0xISmSMWFacJR+hPtsQ5rUexQ0cO6olAKqMjJeP/5x9YBo20a3GJOGngSqAKzpD Q8Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=BWvrBBI0xeShoFk34NbmQuANn71umzLfZCKEpR5Gmg8=; fh=ySf6eC/QNzT5mA8/CWzLDt1tRWLt1g57caQsE+MODMY=; b=PLN4ICNmoHM5N9Eq32mGXRsSAPPPGtCMGNt7KUJ4Wj7g7Vmm43LNmw6U9W342fqOQI pfK9tIjnmoaSRSdBA2UsZi9Uv0vsR+4z+fm0B0x5Pm7dotNqiVt9tYlZHjKf8gZa/fRu nfpYj+UeP87i5tf2MiQ0u/W10lKzcKlcEMFJ2DZFZOLYDNmTaPO9O1VDEGa0/lYdc7Ab J7CsLqX0h+eXONGZROYiBBErIt5DrzgfLN6xqQzCUM3R3wRd3DjyVf908dB3x/mgVTfB lYJlrxC5hEyVPflIbg//j6lnqOiIH0O2eNWqqHaa3hzkIJjFbjFvrvC2AB98fFK/LvKZ W4zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=sOmsxuOE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d20-20020a63d654000000b005533750837csi1408851pgj.681.2023.07.27.08.30.41; Thu, 27 Jul 2023 08:31:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=sOmsxuOE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233800AbjG0OfO (ORCPT + 99 others); Thu, 27 Jul 2023 10:35:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232141AbjG0OfN (ORCPT ); Thu, 27 Jul 2023 10:35:13 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25A522D47; Thu, 27 Jul 2023 07:35:09 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-31781e15a0cso675789f8f.3; Thu, 27 Jul 2023 07:35:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690468507; x=1691073307; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=BWvrBBI0xeShoFk34NbmQuANn71umzLfZCKEpR5Gmg8=; b=sOmsxuOEWzRHYy24bTXdFP8ZH6spjFMw8Ab3/zPupI0xiwahJLv+/I+rft3AigBK72 30+sZv1jP9lQpmT2mat9zJBREOTrBSb9dTbUyi/q1cCprkrPKLkUrDwTOiz0N/KkVASD ZiSRRpi2uroa5HiB4t8qLqBDKneQ/HTk+oaXZo+XTR2Cd3tIyEgsdCl9LAE2e3MsHmm9 7pHN23pBgbnKTwbBANXGCOYwdDePyGf5m+yBU185fd9Koggsx0qN9aNorC78cwkjOpML lnoaJFsuYOFxvCRnENFRJPSBcxGDWkUhdiAZnPDrabUtqveFyKeFQipWCuHx6YQITbo3 8Mhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690468507; x=1691073307; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=BWvrBBI0xeShoFk34NbmQuANn71umzLfZCKEpR5Gmg8=; b=kbk3LAhQdyD8OnHrRPjqHbRBv1dw1di1nGOZlPa8LYZCjxi0c5jHd1C6CcRebcdbq2 YyLrLMaVp+Vdsq4rZjXFJsAONisqyUm2+kqhfc7ByNiSrBhACGgu4XE2O00nsJxxq9+e oUNn5Sd60mgDwJerEX4gIHrBWYk1d3AdbNnJuE8czVyiW6z9NmdyNfMfgaP36xdTfWvc jCBjb/53tA8CTyCTukBcyyC8w6arwpqv7LgkL4KdTlYm0FwV8uzQR7i6vVKQQcZe7+hK 2AoUyrSSraw/KSUnybD5znfO3QD1N5HHqlYunpLjwtlY+ttZUbab22YTwALw2XRzhgMS G+4Q== X-Gm-Message-State: ABy/qLZaFNhlWwku31nU2zwaZw6H6Csrpkb68HlGlWUUeVYp7Df+8eJY EIW1ewpv6mSpjh+Y05ku1G/dZpnxPxl8+DU5QiP9oaEfnTKVOTtT X-Received: by 2002:adf:f549:0:b0:317:5849:c2e0 with SMTP id j9-20020adff549000000b003175849c2e0mr1930019wrp.9.1690468507116; Thu, 27 Jul 2023 07:35:07 -0700 (PDT) MIME-Version: 1.0 References: <20230726104827.60382-1-dg573847474@gmail.com> <9378e69f-2bd4-9d8d-c736-b8799f6ebecc@deltatee.com> <0e4caa6c-d5bd-61e7-2ef6-300973cd2db6@deltatee.com> <46ceea13-c8ba-8d67-604e-b761feabc50c@sw-optimization.com> In-Reply-To: <46ceea13-c8ba-8d67-604e-b761feabc50c@sw-optimization.com> From: Chengfeng Ye Date: Thu, 27 Jul 2023 22:34:55 +0800 Message-ID: Subject: Re: [PATCH] dmaengine: plx_dma: Fix potential deadlock on &plxdev->ring_lock To: Eric Schwarz , Christophe JAILLET , vkoul@kernel.org, Yunbo Yu , Logan Gunthorpe Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Eric, > W/ special emphasis on commit edf10919e5fc ("dmaengine: altera: fix > spinlock usage") > spin_lock_bh was changed to spin_lock_irqsave w/ this patch. Yeah, that patch is to fix the deadlock between irq and kernel thread thus use spin_lock_irqsave(), exactly the kind of bug that I am reporting about. But slight difference is the deadlock on that commit concerns hardirq and thus fixed by spin_lock_irqsave(), but this one concerns softirq. > For uniformity reason across drivers and also that not something else > gets missed please compare your requirements and solution to the > implementation of the "altera-msgdma" driver (altera-msgdma.c). Maybe for our case spin_lock_bh() seems to be enough since we are handling deadlock between tasklet and kernel thread. It's truth that uniformity is an important concern, also as I glance at other DMA driver, in general spin_lock_irqsave() is more frequently used than spin_lock_bh(). But this driver already consistently uses spin_lock_bh() on &plxdev->ring_lock, only change to spin_lock_irqsave() at this function could instead make the code seems a bit weird. Even though my original patch did use spin_lock_irqsave(), now I think at least for this bug fix just revert back to spin_lock_bh() may be better and will not complicate things much. Thanks, Chengfeng