From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.168.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796090920; b=al4WDVFdLSvMHicUIf7QVoYXaY3q2nVY7I5WCUZSAos7Hex4AaqShGorVzoavb5e2ESD VtXK+XVqkb3Tq4hys08+Esew/AYPTjI6x5cvvO1i+M6BuiY7zabXKMmCtoRrz+kS4A01Y u0g+AvttHQfjpYjnsM9fWy7hNM8Bk4QDQGuKivS/W59rjFnZtPkx6dSkSxXX8Uyu5lpmS KEYGxcA5Pj/ABPWIcq+8R2StDx2aV2Od88SkOpVX7qqh5Ta+A2IAqz1h8b/VuMiYb3YHK aNFb/pSDA/PWo6I8KmymcnjH8GqLGsYi2+YnPQXzRoOd135BT5dkcEYII6fm9iUqkxw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796090920; h=DMARC-Filter:Received:DKIM-Signature:Received:Received: DKIM-Signature:X-Google-DKIM-Signature:X-Forwarded-Encrypted: X-Gm-Message-State:X-Gm-Gg:X-Received:X-Received:Received:Message-ID: Date:MIME-Version:User-Agent:Subject:To:Cc:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding:X-Proofpoint-ORIG-GUID:X-Proofpoint-GUID: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-Spam-Info: X-Authority-Analysis:X-Proofpoint-Virus-Version: X-Proofpoint-Spam-Details; bh=Wm/2boCu2PFkkRWWMC8vnPWnI+lRazYMfviEhxAkk90=; b=BZjMhxn5AwoqAIeXY/Wg8JuLJ6b3H9eaZBDm0qJM2tFG56AHTxga0gOpQsG56E9Ip8QV gRYfZPLsrofZHIjFLUkwwFIZrBxFWKptyJREXMGSZPYoaTAV+nWOT/Jvcjltb3+C3C03X EN8MQELu2GHV1+3iOUxiM17cXP6X8MridIT6OzaPhTSsoUiRYGZ50ReC9usnN86D2GgcS Uir4L4BpTOQSSAU1Jod+97eOVIxT5t6NsWS8czW51lZdNTOLE7of3warOOWU5qF4cGCaJ hSDy4pddWQjbJre5BXvSvB6Z2q8f7wytfCqmOWTzUEuZUwpJa9mg5vTqgMSAzj+y52w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=KWXKNxTA; dkim=pass header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=ETrdcnkM; arc=none smtp.remote-ip=205.220.168.131 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5CAFC606A320 for ; Tue, 1 Dec 2026 02:08:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5CAFC606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=KWXKNxTA; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=ETrdcnkM Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B10WWXm3341000 for ; Tue, 1 Dec 2026 02:08:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= Wm/2boCu2PFkkRWWMC8vnPWnI+lRazYMfviEhxAkk90=; b=KWXKNxTAuxFjmgQJ pxXZBrBQ9svKXcfSMEHz3HLEP80BokbHKDF+TcTh/fMLSRhFmdwhY3B3fWJ/rDeh gH8MKuNlOw76XicFyTb7FTc8oimMLKqvIDHT4GPocmyHAeN4in6wlmIJ2CgpNU40 QDpJFe2u2swQJn0BCmQPHyYFKsuGMHQsEfAKxy/p4sCPXjBsag9wX1rRpTDMW1Hh qam3afCez5NAHt6aEhQc5uM6hcPwf12QL6mOn/r+FE2FZXj8bqsNWoRbVuiX+sxj UGz3l6fDprw3ceEQ7DW3ITbR1CtFnl0R+QfrM0sNCOi6hkhZ/aB/I8v5IrVrBhUt 5KDrXg== Received: from mail-dl1-f70.google.com (mail-dl1-f70.google.com [74.125.82.70]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j972duk61-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 01 Dec 2026 02:08:39 +0000 (GMT) Received: by mail-dl1-f70.google.com with SMTP id a92af1059eb24-1b592e9841bso9146965c88.1 for ; Mon, 30 Nov 2026 18:08:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1796090919; x=1796695719; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Wm/2boCu2PFkkRWWMC8vnPWnI+lRazYMfviEhxAkk90=; b=ETrdcnkM4u0dLqBrO3w5RshLTjzJHrQQqly+s4iB9srv3K+dJ/CNiK6q0ewju5380z 45eQoEdMu4WZMvYnisldYRsjWJ5BmGV/hAWW8Ytp0fQ5i4Qff0lr9la+OH1bJoWxJlgv krI7NFWocUQqSmxRKqU4uZ+gF3UUr4srzz8LhSFc9SqsKvXuuiuEoT1qdIr9bVY5KZtI 8J3Gfk+zRGaU8bVc51z6il19v6U1i3NeAgWn+xr3ekR9zDAPEf//DQczuLW+tUuUjAxp dfFusRs2Jii3Z9ze7HZ9fSA24Qh9tM/ohX7rxGANNpylp9JbeBQuZvHT7gBD7qTuHBli eETQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796090919; x=1796695719; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Wm/2boCu2PFkkRWWMC8vnPWnI+lRazYMfviEhxAkk90=; b=WDWfbnpRjRQmlYFkLunaJiYLZsdsb3up1mauBdW2NknUMY7rVyKJewcniEZyCtH41s xYlNTxwyFhPK10HwsOLpOu+/8hXt19ArAniQ7rm6Yk+0Blw0e48+SQFJJUTqz4SBLIO3 y6K3JYhOPG+JfO53c/ozjQinjUq/PUP63AxMiInqkS1xf8N9N27SDKzslyD4/dDGbu4Z yo5Pi19pqAKvywer5sjMTqHWHdTv9+rYheGr4rHQ+Kk1xr7S9mvqnMJ5/uTntx8ZPGlT fGmAtR3fNGl+cQ86qxCZO/jpqkHBmbOgLKlc6X+f6tRg7oVCpVTAItN0eVZFXtHFbnFW 6aSg== X-Forwarded-Encrypted: i=1; AL+hErFu7YdwV/YoYUn1tJmZmmX+quKyLclUyCQULgkYvloI8d2xPhRHZlBySRbaZR23BVlRWCD3zxuixrlAVUA=@vger.kernel.org X-Gm-Message-State: APuU4Z/uiMhMFO0s5H4PMoJ0SaLqkuRpzLB02CwgzeM+w15xnPrcS8Ri qhchCYHNpFE+1EaSLoxKqYyen8HTFMuz9538lz8tpq/+/YAJpGPR6lgwMBgtX4mwq7MX0c2ohuF exb4Y+9bM/3SIfXoOzHKx9P4f9imcY++CZuv/IXzPDEYjZPEO3SLwBdqFpiWyMtt2rOE= X-Gm-Gg: AZFdTZe9YOOLG6u27AP8oF9lnb0Xe+cb0f6hS7tUbcxfQRiVrxgYTShhM6N4MzcwZ1V vFJNmT2j+cH68rkX8peswMRXcNdcwohGqq/fOM73cMLDhzoaFdDepcZeEeMXFmQR7NvZgQzM4f3 I9N5hqtLvH/EhIiTBH2hN+riLoc7tAb5Ojc3rat8iQX44/MV1BcEm0beEopSJ8LJB1TvaNoBRAX ue30OCoo5RjlnUjjwb/QRFzFc52AhHkUENCYYRMY/MkPuo9X/Qctwd5erCWiqBafGWRiGavqzp0 KgjVEPh2Hqm/NJcY3m5xbH1iBKuume3mPTAQj25L/ZSpBGtBkKZDvJpNUfw4L+hTzpc14Tvjx1o C1hbwHc10U6uPsCwMdShph3YC6dc2bwyVjsAEti4xw7aA6ISSE5itrZ6kA9Z9juFSjuKGv/k1nN UMqt3lUBWgOBjtgUEEAtSvPmw= X-Received: by 2002:a05:693c:8604:b0:386:b3e6:e741 with SMTP id 5a478bee46e88-386b3e6e883mr21772535eec.26.1796090918485; Mon, 30 Nov 2026 18:08:38 -0800 (PST) X-Received: by 2002:a05:693c:8604:b0:386:b3e6:e741 with SMTP id 5a478bee46e88-386b3e6e883mr21772512eec.26.1796090917963; Mon, 30 Nov 2026 18:08:37 -0800 (PST) Received: from [10.226.59.182] (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-386f6651e2asm30017945eec.27.2026.11.30.18.08.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Nov 2026 18:08:37 -0800 (PST) Message-ID: <7c07a388-c58e-4d8e-8291-31b462d84d00@oss.qualcomm.com> Date: Mon, 30 Nov 2026 19:08:36 -0700 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] accel/qaic: drain the control workqueue before the device is freed To: Yaohan Li , ogabbay@kernel.org Cc: carl.vanderlip@oss.qualcomm.com, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, jacek.lawrynowicz@linux.intel.com References: <20261118072448.1259909-1-shunsheng1218@gmail.com> <20261119022919.1493567-1-shunsheng1218@gmail.com> Content-Language: en-US From: Jeff Hugo In-Reply-To: <20261119022919.1493567-1-shunsheng1218@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Proofpoint-ORIG-GUID: TuYK7g9UmtJCIB5f6f7L7L8xnXY3EP17 X-Proofpoint-GUID: TuYK7g9UmtJCIB5f6f7L7L8xnXY3EP17 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjAxMDAwOCBTYWx0ZWRfXyvkw3qQtqPam +cHwUyUddPRoh2Vr7bioyIGjLqAhlE0MEA8DWFQtbRQDaMUO8tABMra0AURmR7KNuHI/dRQTMPf AjKEBpjoQEL/7g8JuSLNWaxG38thj7lw+mOkmGS7YbxvdsKdwJBirwDVmY0WFx0ehd1thK1+2Bl N2ketQrb9C4zvEe3gAGfFSPct01RUhYdKsWCTRL7Q79naciqKIN2zrvupvxkQeZjd2tOnbmCRIJ 88Zlxwpen/4ai9gvc4KIanRzRUKePfApT81T81THp5uTUGIZcPEwGvetGG5xdSiRMW2rd/p/9ie /xHITJ23U9Gm8EtVS1e7xEFsy53R4yUT4bKo+/5tiKlSNyytfEFk7FZKYmMrYt6/T0XtFifiPVh +ao3fHMxbqVR8CLzaCp4zexp/iq+CkwzqV7JkEUNoU4+Y9GWuJUlf+QhTqDnzwVC752dMhm37sk Y4ibNMCZ1ecFM9HDXZA== X-Proofpoint-Spam-Info: AW1haW4tMjYxMjAxMDAwOCBTYWx0ZWRfX2U7yj+OcuYAD ykTZ+QewFmD3Rd5Ryp01ljGyzGi7notsLdllwPkovKQbdz0lkOUbeoDYTPK/Xnq0yKGvM0vILPO 2Rxb2UwMSo0gO+KSSyQD+RV6FR4Egwo= X-Authority-Analysis: v=2.4 cv=V5joQuni c=1 sm=1 tr=0 ts=6b0e2c27 cx=c_pps a=SvEPeNj+VMjHSW//kvnxuw==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=4-cyVghr8-U9VK_0:21 a=IkcTkHD0fZMA:10 a=pUM-KoujPXoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=YMgV9FUhrdKAYTUUvYB2:22 a=pGLkceISAAAA:8 a=9K5WRLFAe3GqWrLAY9UA:9 a=QEXdDO2ut3YA:10 a=Kq8ClHjjuc5pcCNDwlU0:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-30_05,2026-11-30_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 spamscore=0 lowpriorityscore=0 phishscore=0 clxscore=1015 malwarescore=0 bulkscore=0 suspectscore=0 priorityscore=1501 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612010008 On 11/18/2026 7:29 PM, Yaohan Li wrote: > qaic_pci_remove() tears the MHI controller down and destroys the DRM > device, but nothing drains qdev->cntl_wq. qdev itself is allocated with > devm_kzalloc_flex() and is freed as soon as the PCI device is unbound, > while cntl_wq is a DRM-managed resource that survives until the last > open file drops its reference to the DRM device. > > resp_work is queued from qaic_mhi_dl_xfer_cb() and resp_worker() > dereferences qdev, so a work item that is still queued, or still > running, when the driver instance goes away touches freed memory. > > mhi_power_down() moves the controller to the shutdown state, disables > the interrupt and flushes the state worker that destroys the channel > devices, and mhi_unregister_controller() removes the controller, so no > data event can reach qaic_mhi_dl_xfer_cb() once > qaic_mhi_free_controller() has returned. Flushing the workqueue after > it therefore covers every work item that can still be queued. > > Fixes: 22ec9a3b73dd ("accel/qaic: Leverage DRM managed APIs to release resources") > Signed-off-by: Yaohan Li > > --- > Prepared against v7.4-rc1-1969-g666539eecdf4. > > Compile tested only: arm64, aarch64-linux-gnu-gcc 11.4, CONFIG_DRM_ACCEL=y and > CONFIG_DRM_ACCEL_QAIC=m. No hardware was available, so the removal path was > not exercised and no race injection was run. > > AI assistance: prepared with Claude (Anthropic) as a coding assistant; the > author reviewed the reasoning and takes responsibility for the content. > > Changes in v2: > - Correct Fixes: to 22ec9a3b73dd, the commit that moved the device release > to DRM managed resources. No code change. > --- > drivers/accel/qaic/qaic_drv.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/drivers/accel/qaic/qaic_drv.c b/drivers/accel/qaic/qaic_drv.c > index 90c0d31e414a..c4c3f450e67b 100644 > --- a/drivers/accel/qaic/qaic_drv.c > +++ b/drivers/accel/qaic/qaic_drv.c > @@ -625,6 +625,15 @@ static void qaic_pci_remove(struct pci_dev *pdev) > > qaic_dev_reset_clean_local_state(qdev); > qaic_mhi_free_controller(qdev->mhi_cntrl, link_up); > + > + /* > + * The control channel is gone, so nothing can queue resp_work any > + * more. Drain it before qdev is freed: the workqueue belongs to the > + * DRM device and may outlive this driver instance, and resp_worker() > + * dereferences qdev. > + */ > + flush_workqueue(qdev->cntl_wq); > + > qaic_destroy_drm_device(qdev, QAIC_NO_PARTITION); > } > It seems like this should belong in the MHI channel remove. Also, why is the cntl_wq unique in this regard?