From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-f182.google.com (mail-yw1-f182.google.com [209.85.128.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E09771E5B63 for ; Mon, 27 Apr 2026 03:26:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777260383; cv=none; b=pchSeVjVJvjUQmg8QA3Y6fierC4UsZlOwtj+0yAsXfF/G9EpFNe1Y++PUmdoMIlhkId7sqENzfe+jz/kM3H+AjWlr6Hu96PuG0v/e4JrTNfvRK/gjCr5UEQLb57N5XxDnOshbo36HFIehq7kYPDqz0ijwZ8uOP3E/YwaruyVVKE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777260383; c=relaxed/simple; bh=nqvj57KyioIL2PzkBGckZgOX3gNQ7keOp2XX5NnhH1A=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=BeZdppX0Z8j1k2KrlzcyOtHGyavSFK0ZdSKJxdMokxv08RUP+FxmHpr1Oo2j5c8kBlvvP1R7+6We364icNO59cAk1zipqQhB2A9xlxysom7wgtgakTkmdxbu13QKE6NLWmPW78uiYZCNM9MD9mfOVqFPOHRRnafCOE3r9od4bpA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=sung-woo.kim; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.128.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=sung-woo.kim Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-yw1-f182.google.com with SMTP id 00721157ae682-79a535e7c00so104802197b3.3 for ; Sun, 26 Apr 2026 20:26:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777260381; x=1777865181; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=nkfGwwfLBvGDGBedAG45wh5V1KcMlUL2EI/8teegCSQ=; b=aXTOxLq1YBorNuTLotNya6ynNFu0teBYqqb5QterBlMgJ+ha+LzVlGdgwbTa1p0zjS r4IEfvYUezx54fzB9TO9wyDX4usaiZAASL8/Oc+KtkNIYALZBL1Xeu0fUcX0TvaqsaOm NKXvOFWYviPOleyuwDUbR/A9cEv56JjwQMOYePa7DmyoiW7os48e/uqsKrLRM2qSNbDL 9uTe9d4NnZgTmmXnQAtHx5DU1BstgCIEslP5GUVSB8QAVfc0zWZP5YRReM5rR+t2ZC0U TTxbLoBnlZGgeIu0SkQIWiAAaYMc7f+8NHFTfFD6lzX7TRzhSxOAsLti7/nVIqvEMSsp YN+A== X-Forwarded-Encrypted: i=1; AFNElJ8IFsA6sWC9ESsfpMP7quQi2uUaivyoP5rqwFYzzTUImW0DBYtpZJ/bvkGqxSFKguefj7sBO0GAXHF9PtI=@vger.kernel.org X-Gm-Message-State: AOJu0YwEC9vcuA6SRtuzsT3Nt+wEtGgzhKnFb6e/f+AMY0W7fXZ7VFpY CA1PudNKBKgEUD/4vSq2x/CXyzp3SO6fKCyPlBNQM5RYG49B5rS4rd1w X-Gm-Gg: AeBDiesP2rsGB/5aiPpDUkt9KjyZ0pgn0FuY0YEviSo1XCAW/fzHoGQZ5LuJvmn6tGG 2oPDW1b9iisN8udvBxuV57tseozZzJa9/WSYmw8BUW2sIeWtFuej6DZzITrlJF8uHthLGTswYJs fJAFxRk/5X2Y20K6nE0BEBDi+7fGymqKHbzXTaT4TZcqNZd8YEaI6GPVNhN5oynCTeyGVT93UQ0 Od8d4TxKgGl4BbL7p6ZmCWifHjg+EoDvk8VEgq8IHs5tc8l8Wo/LzRET6DpWqqa9PrrcnRx1Egg TPRomRWgBQ+7a8gaiO6ntprgGO7ZFI0LwD6yO0d7EwvHnkFgZic+B5Z8xayg6CTJsXVaF2JIJrZ 7jaG4sS+8flytJn7HfA1oBFwhwgMxxeXU1CjSp5WB0gqD+i9xO+zNYCd75L+CD34yOCY1aSqC52 96uEoZ32Zz16faCsLXeKd3WwgKniuTrxo= X-Received: by 2002:a05:690e:24db:b0:650:2257:e085 with SMTP id 956f58d0204a3-65310a2c277mr27421691d50.30.1777260380940; Sun, 26 Apr 2026 20:26:20 -0700 (PDT) Received: from tofu.. ([128.210.0.165]) by smtp.googlemail.com with ESMTPSA id 956f58d0204a3-65314b26b56sm14087239d50.4.2026.04.26.20.26.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Apr 2026 20:26:19 -0700 (PDT) From: Sungwoo Kim To: Davidlohr Bueso , Jonathan Cameron , Dave Jiang , Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Robert Richter , Li Ming , Gregory Price , Ben Widawsky Cc: Dave Tian , Sungwoo Kim , linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 0/2] cxl/region: Fix race conditions in cxl region unregistration. Date: Sun, 26 Apr 2026 23:20:07 -0400 Message-ID: <20260427032010.916681-2-iam@sung-woo.kim> X-Mailer: git-send-email 2.47.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This version mainly addresses Dave's comments and meaningful issues reported by Sashiko AI[1]. Overview ======== This patch series fixes race conditions in cxl region unregistration. devm_release_action() should be called once, otherwise, it warns about the second call. However, the current implementation has a race condition that allows multiple calls to devm_release_action(). The details are in each patch. To fix these, the first patch adds a new function that guarantees that devm_release_action() is called only once. Using this function, the second patch subsitutes the current use of devm_release_action() in cxl region with the new function. Change in v3 ============ Addressed Dave's comments: - Split and made this in a patch series. - Enhanced a commit log explaining why a workqueue is used in the first patch. - Added a context on how these issues were found and what impact was observed and how that effects a user in the second patch. Sashiko AI review fixes: - Fixed construct_region() as it also can race. - Used a driver's wq instead of system wq so unbinding can drain a work. [1] https://sashiko.dev/#/patchset/20260422045637.3048249-2-iam%40sung-woo.kim Earlier approach: v2: https://lore.kernel.org/linux-cxl/20260422045637.3048249-2-iam@sung-woo.kim/ v1: https://lore.kernel.org/linux-cxl/20260308185958.2453707-2-iam@sung-woo.kim/ Sungwoo Kim (2): cxl/region: serialize devm action removal via scheduled work cxl/region: Fix a race bug in delete_region_store() drivers/cxl/core/port.c | 6 +++++ drivers/cxl/core/region.c | 47 ++++++++++++++++++++++++++++++++++----- drivers/cxl/cxl.h | 9 ++++++++ 3 files changed, 57 insertions(+), 5 deletions(-) -- 2.47.3