Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.11 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796068424; b=BSaxCuMfuzbA4ZiUzPAyX0RYajacxtb4IVps6xEIx3Vb1Y+kwj0CnnN7kQTBQ6e9FuY0 wReoraBoUAZlug9GjsaV7nV4ehwiEvh8VJk1HuH05Ha39VSPHzNXle58nDRtqkABBkSZc Wp1ZF9izAA7Bmz5fEeMvhRCci7FzRZYU0lQT3arYCNEJWlWCt0Ex9qwKQe9qVs+h0VXP5 OqQazpPbG3UjMxPAVB98nhsAc7CNylvoEsSIWc2aqC3Nr19acW0t3PgF4hW/mowGz9ZBG /hD6kaKaLso3Ba5KeOEsgox5TvGPTyPHvoMJIoW0FprUOdf1ba+ojHot86Fcen9n+kg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796068424; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=77+E+GeKUs82O7Se3u1M8bj+CDi5DqbKaDt+K0xMNns=; b=e7Y+QixRzKaih6TzyWhWBZ/csfIK+ThCbbinNRI3L3mVZTqDTPzfgbNlLdP5atAlJ+ox 5POSMUuija1uuL7lowof8zvfwqQqzJ609Xub0a1bpETivsR2fpYciEqylz24R6uSDAUCv 5DNTx8RoRESwEZ4JaBvKBl7V++62X3OpFmWxtqng3H/S/CLR6PRk5hhmWf67xU01zAY4B yZ5LSya1iFJMgbsXnsYWCd2lyaz/xWlXs9vJ1ZBAArzOyEou8r6K3ay60ZVz1TaS0gc7w c9K0+EqbgN075JJ58JgWXzYMQu/cB2sae2iUmbHA/gNjkMycaY9W1gKVa/AQIzV4Rwg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=b+QOsH3W; arc=none smtp.remote-ip=198.175.65.11 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45041606A686; Mon, 30 Nov 2026 19:53:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 45041606A686 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=b+QOsH3W DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796068424; x=1827604424; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=77+E+GeKUs82O7Se3u1M8bj+CDi5DqbKaDt+K0xMNns=; b=b+QOsH3WaVzluu62hS1Wdxe6Hi5EZh4CMc2CCrrq/posanF0MuKEuEsj 6U/Mn6jlQxm51v/f9TT59KY4XI3/8Y+du9/RnsVkmT89eVn//rMWwOB+w iLYpwvS8z7hJeESDdUOvt80zqovqgtZwYTWhjWESHcxmvWQyX722owsF/ /DfxfpgVX5KgESnGO6AV/Zb2FPGGa/TTVc4f1TctrcK+za3Gufl2W3ZL4 YycbJloVvqErYlh9fzgIZIdx5YyW/frFIOYY5XEk7OFHznGFnzCwobkLs vHFGFdG24ZbejijnEtp5KJXtY/McwIHyAeOpCR0WDWgYNnRviT5pCKH3y Q==; X-CSE-ConnectionGUID: yntANIjcT1GXBu39r4gwAA== X-CSE-MsgGUID: zYMoQMBXT66hEbGD1go4yg== X-IronPort-AV: E=McAfee;i="6800,10657,11982"; a="4805774" X-IronPort-AV: E=Sophos;i="6.27,243,1787036400"; d="scan'208";a="4805774" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2026 11:53:41 -0800 X-CSE-ConnectionGUID: iAVPC4K2ROe+vTEu02uzgA== X-CSE-MsgGUID: ihS7zNgOT4q4MOqkf4sy0Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,243,1787036400"; d="scan'208";a="13036629" Received: from jf5300-15a101203tc.jf.intel.com (HELO meta-crater2c.jf.intel.com) ([10.54.113.49]) by orviesa002.jf.intel.com with ESMTP; 30 Nov 2026 11:53:40 -0800 From: Daniel Byrne To: Vinod Koul , dmaengine@vger.kernel.org Cc: Vinicius Costa Gomes , Dave Jiang , Frank Li , Fenghua Yu , Dan Williams , linux-kernel@vger.kernel.org, Daniel Byrne , stable@vger.kernel.org Subject: [PATCH v2 07/10] dmaengine: idxd: don't sleep for a descriptor in the prep callbacks Date: Mon, 30 Nov 2026 11:47:18 -0800 Message-ID: <20261130194721.1900266-8-daniel1.byrne@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261130194721.1900266-1-daniel1.byrne@intel.com> References: <20261130194721.1900266-1-daniel1.byrne@intel.com> X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The dmaengine prep callbacks may be called from atomic context, and ntb_transport calls idxd's memcpy prep from its receive tasklet and from ndo_start_xmit. Both idxd prep callbacks allocate their descriptor with IDXD_OP_BLOCK, which sleeps on the sbitmap wait queue while every slot of the work queue is in flight, so a queue pair that outruns the work queue schedules in atomic context. Allocate with IDXD_OP_NONBLOCK and return NULL on an exhausted pool, as ioat, plx_dma and mv_xor do when their rings are full. ntb_transport falls back to a CPU copy. A polled client needs this as well. Only its own query frees a polled descriptor's slot, so a prep that slept for a slot while that client held the whole pool would wait on itself. Clients that can sleep and do not fall back see the change. dmatest reports a prep error, sleeps 100 ms and counts a failure when threads_per_chan exceeds the queue's descriptor count, which is the size of a dedicated queue and the threshold of a shared one. It can also do so with exactly as many threads as descriptors, when a thread that its callback woke prepares again before the interrupt thread has freed that callback's slot. ntb_perf sleeps 10 ms each time it overruns the pool, which caps its reported bandwidth at about the pool size times the chunk size per 10 ms. iaa_crypto allocates outside the prep callbacks and keeps the blocking allocation. Fixes: 8f47d1a5e545 ("dmaengine: idxd: connect idxd to dmaengine subsystem") Fixes: 2112b8f4fb5c ("dmaengine: idxd: add missing callback function to support DMA_INTERRUPT") Cc: stable@vger.kernel.org # 5.6+ Signed-off-by: Daniel Byrne --- New in v2 (was carried by v1 of the polled-status series). drivers/dma/idxd/dma.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/dma/idxd/dma.c b/drivers/dma/idxd/dma.c index c116416e10e5..2f68fdad3f16 100644 --- a/drivers/dma/idxd/dma.c +++ b/drivers/dma/idxd/dma.c @@ -93,7 +93,8 @@ idxd_dma_prep_interrupt(struct dma_chan *c, unsigned long flags) return NULL; op_flag_setup(flags, &desc_flags); - desc = idxd_alloc_desc(wq, IDXD_OP_BLOCK); + /* Prep may run in atomic context: fail rather than wait for a slot. */ + desc = idxd_alloc_desc(wq, IDXD_OP_NONBLOCK); if (IS_ERR(desc)) return NULL; @@ -120,7 +121,8 @@ idxd_dma_submit_memcpy(struct dma_chan *c, dma_addr_t dma_dest, return NULL; op_flag_setup(flags, &desc_flags); - desc = idxd_alloc_desc(wq, IDXD_OP_BLOCK); + /* Prep may run in atomic context: fail rather than wait for a slot. */ + desc = idxd_alloc_desc(wq, IDXD_OP_NONBLOCK); if (IS_ERR(desc)) return NULL; -- 2.43.0