From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8259623817C for ; Sun, 29 Jun 2025 20:15:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751228152; cv=none; b=OAM6l9lstlegh++72Nc9UQV1BT6QFMqgx0GYUP49zQZ/NYShxNjcm4F9AL2veh8WGEolkyLrSvhm5yNMMV2riZsJQM2WSVe9k2pijue3OS1GvXkCALohlVLW+f+snOXJlNIQqUkFTx9mSu+pIie3BVgk2NcEnsuJtnH8AtEDDZY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751228152; c=relaxed/simple; bh=9sCjXl7H9h2L5IAUGNMz/8rL0vIV5pHmuIlPBhTn+OY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=t9Fk1I2SJdNKA9bs3y5lxPpHw7LKYQpE78yaeKc9H3LGCQK0YORTsiszqM2EHD3tgWw5ZN/1ZvxCPQP2SJK6gB/RsEGgOp9elaT3URzNt5r+z2n08v2m6YT8lrzkiAdXef66xbXY6T7gm1Hh8VkzpChNiEg1w+gIejbTvDKlQyw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=nz4j9fx/; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject 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.b="nz4j9fx/" Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 55TIrIgi015161 for ; Sun, 29 Jun 2025 20:15:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:message-id:mime-version :subject:to; s=qcppdkim1; bh=UKy+/4DqHxMfzHA5JdzyoIJf/leW4BZrrND X5QxgVxM=; b=nz4j9fx/Y/RSrJmFN3QPwED5QCrXOm8783bodYkrCPUwuHAxE6U wMcI8Buy9f5L8pBnwh/j5SEiqcEfoXDDNKX4Saz1PuTurPwBFTixpDYAtthNPjVR cMrknHle1YqnIkJ/zdE8PUNYHBrvexH+fW/3rhZ0f5BxLUFofKnPeMMD8BsI2f8N xfHcoOKO/egf68yKnG9pw/FtK4D6KjNPsTYZwbTC/AANjW9VZTiDP24Bxj8tcysp uMb0Mv68pIotcbqbAlUxZAF3np2kEveXlX7gH1QdKueAZW6OAcgWUewinaO9al7Q w0JgY6Hs2KqP5kvop72b8gl51VP1FUlHPmg== Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 47j63k2tdy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Sun, 29 Jun 2025 20:15:48 +0000 (GMT) Received: by mail-pf1-f200.google.com with SMTP id d2e1a72fcca58-748cf01de06so3608795b3a.3 for ; Sun, 29 Jun 2025 13:15:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751228148; x=1751832948; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=UKy+/4DqHxMfzHA5JdzyoIJf/leW4BZrrNDX5QxgVxM=; b=G0/tbFTZguc/MyO9cG0TWUAKZGYF6edNf68bxnBHYvHIPqR7siW4ri5YMxa/lvb/w8 URC0ybc+iRcwOQyEPpW1guAv41lYHUX+B1pkF42x7jH7S+GkVB9EcCI+U+GTo7R0x2hy dpPunEa/iE6lJ0rcTMDjt4/POrSS3c6CXk69boRErNfOvRFl+xcknDm7Y//0OHgmIPAw wbi01r1hanqjwXsokkBnWJBBcCL1a3864xiZQzRY1lW/P5X3Qypsko75g2jF+KqSmlfs PczYzFBgoZQ3nkk/44EpJVaXkRNGpz00YZQ1FHUIWB7oPtOHN2Jx988CPFVN6J8rgZMS GbaA== X-Forwarded-Encrypted: i=1; AJvYcCWsDFyntq+7RNjZvekVlNS5FJaD4QG/P9Rs7B14okzI+RfXldJ36zY2ETzESADwzd9DdhfgHlBivK1RD2M=@vger.kernel.org X-Gm-Message-State: AOJu0YxtWmxcz5lY+z2sK1IsEYY7FLXFUZU61wzuDMJYdMrY0ymmwCyQ 68/MMDcW+p69olQckU/GAyLUUGcGOKpaaG7i7+FFDEyi5vzJ1u8gFdAfZLrSslroT42vXcToUMx jcu0LuaKpJHKHb4uP01XUAxlz2ltHI19rVOnsWx4Sfiju2hNlgQS2/pZ9/8w/yIDHWUE= X-Gm-Gg: ASbGnctyEccQ4vzqPu/XGGUghThqqabm0fZgScoNiHjCy0ppJPLzxzTvXFm7x+vbTmD 6zH1X11JLuuZ7DfM5P1G04xK4qgypUHFLpmB17WoBwAFB882Iz/bqAJO7QUsOmCl9+TF0oyQQQl yMXeXSpGbwX8OR5q9A4gvjxyFVmK2j65CPMRA9OLUy9QTVuQOcHMpLI/RV48UaIiinnfz9Lbti1 pmuKJepkHzzHfPXXyQhh3pVbTYuJBbKwtZDzwtgP09QgQWdilovQpompRqGfYbY7SWtJLE/M6aO 97dCO0QMjv9um9vqwqAncyCEtXwGKIc4mg== X-Received: by 2002:a05:6a00:2409:b0:748:eedb:902a with SMTP id d2e1a72fcca58-74af702a36fmr14364062b3a.17.1751228147513; Sun, 29 Jun 2025 13:15:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFXXNnZecKoPPYVRMCoHyQ/vx5IeHoF7xrH5dxJ0FWSSQDHRJdxrZ6S8ueB1z9L5IRNIEMCbg== X-Received: by 2002:a05:6a00:2409:b0:748:eedb:902a with SMTP id d2e1a72fcca58-74af702a36fmr14364038b3a.17.1751228147017; Sun, 29 Jun 2025 13:15:47 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:5b3e:de60:4fda:e7b1]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-74af57ef4dbsm7267926b3a.160.2025.06.29.13.15.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Jun 2025 13:15:46 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Connor Abbott , Antonino Maniscalco , Danilo Krummrich , Rob Clark , Abhinav Kumar , Arnd Bergmann , =?UTF-8?q?Christian=20K=C3=B6nig?= , David Airlie , Dmitry Baryshkov , Eugene Lepshy , Haoxiang Li , Jessica Zhang , Jun Nie , Konrad Dybcio , Krzysztof Kozlowski , linaro-mm-sig@lists.linaro.org (moderated list:DMA BUFFER SHARING FRAMEWORK:Keyword:\bdma_(?:buf|fence|resv)\b), linux-kernel@vger.kernel.org (open list), linux-media@vger.kernel.org (open list:DMA BUFFER SHARING FRAMEWORK:Keyword:\bdma_(?:buf|fence|resv)\b), Maarten Lankhorst , Marijn Suijten , Maxime Ripard , Sean Paul , Simona Vetter , Sumit Semwal , Thomas Zimmermann Subject: [PATCH v9 00/42] drm/msm: sparse / "VM_BIND" support Date: Sun, 29 Jun 2025 13:12:43 -0700 Message-ID: <20250629201530.25775-1-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.50.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Authority-Analysis: v=2.4 cv=ZKfXmW7b c=1 sm=1 tr=0 ts=68619ef4 cx=c_pps a=mDZGXZTwRPZaeRUbqKGCBw==:117 a=xqWC_Br6kY4A:10 a=6IFa9wvqVegA:10 a=e5mUnYsNAAAA:8 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=pGLkceISAAAA:8 a=zBYVM8QCAAAA:8 a=Kgy_UhXEN60RKTLpf-gA:9 a=eVM1_HBmYRkA:10 a=YgSuLXRpIuYA:10 a=te1wHPZ5H10A:10 a=zc0IvFSfCIW2DFIPzwfm:22 a=Vxmtnl_E_bksehYqCbjh:22 a=ArXkYGXkE6hBHcUMFODu:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNjI5MDE3MSBTYWx0ZWRfXxmdDCJSi5sfR e/rQpVuH+CUsYGEhwWbGzLhV5bIgpCXOg7MHlVxvQ8dacoMa/BKY5/d29KPQUghJexGZPAMqHhe BbeKyJ21IN7mLL1ix+67ruVDHPjmH0P5TNEOCqIgQoN/wUMxZLQdT/McZpO1cCfQm1zARhfLYXB n8kZu2pP8QTLA0D90raz5uhmaaCfBzY9SljMi0Z/+tYxjWeE7YgSYmZK9YhYorg7AmKdGdKe52T lQKrMiqOBx4vGIDkPF6/Ta6qdv/z+EaTgFhURkatCyhi9Rc0p5GNwtAUw7p1qVgI/kYMGv4VKRN Y5VXP9NMAvvgi1SbbHDyox9N97Vx3etHlHeIgkZ1ZvVaOwnrnk6mtqY0rtGgRE8Ln+raf4II8lN N5Q59AH2ZixLFqsKQnqvSSkyfIJAUQ5Bgibg/uF91fn5zZtVn4SHxLZub95E5seGyA8D5AgM X-Proofpoint-ORIG-GUID: C9XVKKfiLYJjfKbbp2ecyDDACSMMKf3F X-Proofpoint-GUID: C9XVKKfiLYJjfKbbp2ecyDDACSMMKf3F X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-06-27_05,2025-06-27_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxscore=0 mlxlogscore=999 spamscore=0 suspectscore=0 bulkscore=0 priorityscore=1501 lowpriorityscore=0 phishscore=0 impostorscore=0 malwarescore=0 clxscore=1015 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2506290171 Conversion to DRM GPU VA Manager[1], and adding support for Vulkan Sparse Memory[2] in the form of: 1. A new VM_BIND submitqueue type for executing VM MSM_SUBMIT_BO_OP_MAP/ MAP_NULL/UNMAP commands 2. A new VM_BIND ioctl to allow submitting batches of one or more MAP/MAP_NULL/UNMAP commands to a VM_BIND submitqueue I did not implement support for synchronous VM_BIND commands. Since userspace could just immediately wait for the `SUBMIT` to complete, I don't think we need this extra complexity in the kernel. Synchronous/immediate VM_BIND operations could be implemented with a 2nd VM_BIND submitqueue. The corresponding mesa MR: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32533 Changes in v9: - Rework VM_BIND throttling to not use gpu-sched's waitqueue - Link to v8: https://lore.kernel.org/all/20250629140537.30850-1-robin.clark@oss.qualcomm.com/ Changes in v8: - Just a rebase and collecting tags - Link to v7: https://lore.kernel.org/all/20250625184918.124608-1-robin.clark@oss.qualcomm.com/ Changes in v7: - Rebase on, and use, gpuvm locking helpers[4], included in this series. - Various small fixes - Link to v6: https://lore.kernel.org/all/20250605183111.163594-1-robin.clark@oss.qualcomm.com/ Changes in v6: - Drop io-pgtable-arm patch as it has already been picked up in the iommu tree. - Rework to drop gpuvm changes. To mitigate the limitation of gpuvm when it comes to lazy unmap (and to avoid ~5ms of unmap per pageflip!) a vma_ref refcount is added. This refcount is incremented when a BO is pinned for scanout, and for userspace handles and dma-bufs. The VMA is torn down when this count drops to zero, breaking the reference loop between the VM_BO and BO. But as long as a pin or userspace handle is keeping a reference to the BO live, we allow the harmless reference loop to live. (This is only for kernel managed VMs, which includes the kms VM.) If no userspace process has some sort of handle to the BO, it is unlikely to be reused again. (The exception is GET_FB, but in that case the vma_ref >= 1 due to pin for scan- out.) - Drop gpu sched changes for throttling and move this into the driver. We can re-visit a more generic solution when some other driver realizes they need the same thing. - Link to v5: https://lore.kernel.org/all/20250519175348.11924-1-robdclark@gmail.com/ Changes in v5: - Improved drm/sched enqueue_credit comments, and better define the return from drm_sched_entity_push_job() - Improve DRM_GPUVM_VA_WEAK_REF comments, and additional WARN_ON()s to make it clear that some of the gpuvm functionality is not available in this mode. - Link to v4: https://lore.kernel.org/all/20250514175527.42488-1-robdclark@gmail.com/ Changes in v4: - Various locking/etc fixes - Optimize the pgtable preallocation. If userspace sorts the VM_BIND ops then the kernel detects ops that fall into the same 2MB last level PTD to avoid duplicate page preallocation. - Add way to throttle pushing jobs to the scheduler, to cap the amount of potentially temporary prealloc'd pgtable pages. - Add vm_log to devcoredump for debugging. If the vm_log_shift module param is set, keep a log of the last 1< msm_context drm/msm: Improve msm_context comments drm/msm: Rename msm_gem_address_space -> msm_gem_vm drm/msm: Remove vram carveout support drm/msm: Collapse vma allocation and initialization drm/msm: Collapse vma close and delete drm/msm: Don't close VMAs on purge drm/msm: Stop passing vm to msm_framebuffer drm/msm: Refcount framebuffer pins drm/msm: drm_gpuvm conversion drm/msm: Convert vm locking drm/msm: Use drm_gpuvm types more drm/msm: Split out helper to get iommu prot flags drm/msm: Add mmu support for non-zero offset drm/msm: Add PRR support drm/msm: Rename msm_gem_vma_purge() -> _unmap() drm/msm: Drop queued submits on lastclose() drm/msm: Lazily create context VM drm/msm: Add opt-in for VM_BIND drm/msm: Mark VM as unusable on GPU hangs drm/msm: Add _NO_SHARE flag drm/msm: Crashdump prep for sparse mappings drm/msm: rd dumping prep for sparse mappings drm/msm: Crashdump support for sparse drm/msm: rd dumping support for sparse drm/msm: Extract out syncobj helpers drm/msm: Use DMA_RESV_USAGE_BOOKKEEP/KERNEL drm/msm: Add VM_BIND submitqueue drm/msm: Support IO_PGTABLE_QUIRK_NO_WARN_ON drm/msm: Support pgtable preallocation drm/msm: Split out map/unmap ops drm/msm: Add VM_BIND ioctl drm/msm: Add VM logging for VM_BIND updates drm/msm: Add VMA unmap reason drm/msm: Add mmu prealloc tracepoint drm/msm: use trylock for debugfs drm/msm: Bump UAPI version drm/msm: Defer VMA unmap for fb unpins drm/msm: Add VM_BIND throttling drivers/gpu/drm/drm_gem.c | 14 +- drivers/gpu/drm/drm_gpuvm.c | 132 +- drivers/gpu/drm/msm/Kconfig | 1 + drivers/gpu/drm/msm/Makefile | 1 + drivers/gpu/drm/msm/adreno/a2xx_gpu.c | 25 +- drivers/gpu/drm/msm/adreno/a2xx_gpummu.c | 5 +- drivers/gpu/drm/msm/adreno/a3xx_gpu.c | 17 +- drivers/gpu/drm/msm/adreno/a4xx_gpu.c | 17 +- drivers/gpu/drm/msm/adreno/a5xx_debugfs.c | 4 +- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 22 +- drivers/gpu/drm/msm/adreno/a5xx_power.c | 2 +- drivers/gpu/drm/msm/adreno/a5xx_preempt.c | 10 +- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 32 +- drivers/gpu/drm/msm/adreno/a6xx_gmu.h | 2 +- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 49 +- drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c | 6 +- drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 10 +- drivers/gpu/drm/msm/adreno/adreno_device.c | 4 - drivers/gpu/drm/msm/adreno/adreno_gpu.c | 98 +- drivers/gpu/drm/msm/adreno/adreno_gpu.h | 23 +- .../drm/msm/disp/dpu1/dpu_encoder_phys_wb.c | 11 +- drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c | 20 +- drivers/gpu/drm/msm/disp/dpu1/dpu_formats.h | 3 +- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 18 +- drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 22 +- drivers/gpu/drm/msm/disp/dpu1/dpu_plane.h | 2 - drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c | 6 +- drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c | 28 +- drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c | 18 +- drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c | 4 +- drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c | 19 +- drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c | 18 +- drivers/gpu/drm/msm/dsi/dsi_host.c | 14 +- drivers/gpu/drm/msm/msm_drv.c | 185 +- drivers/gpu/drm/msm/msm_drv.h | 30 +- drivers/gpu/drm/msm/msm_fb.c | 33 +- drivers/gpu/drm/msm/msm_fbdev.c | 2 +- drivers/gpu/drm/msm/msm_gem.c | 536 +++--- drivers/gpu/drm/msm/msm_gem.h | 296 +++- drivers/gpu/drm/msm/msm_gem_prime.c | 65 + drivers/gpu/drm/msm/msm_gem_shrinker.c | 104 +- drivers/gpu/drm/msm/msm_gem_submit.c | 300 ++-- drivers/gpu/drm/msm/msm_gem_vma.c | 1513 ++++++++++++++++- drivers/gpu/drm/msm/msm_gpu.c | 208 ++- drivers/gpu/drm/msm/msm_gpu.h | 144 +- drivers/gpu/drm/msm/msm_gpu_trace.h | 14 + drivers/gpu/drm/msm/msm_iommu.c | 302 +++- drivers/gpu/drm/msm/msm_kms.c | 18 +- drivers/gpu/drm/msm/msm_kms.h | 2 +- drivers/gpu/drm/msm/msm_mmu.h | 38 +- drivers/gpu/drm/msm/msm_rd.c | 62 +- drivers/gpu/drm/msm/msm_ringbuffer.c | 10 +- drivers/gpu/drm/msm/msm_submitqueue.c | 96 +- drivers/gpu/drm/msm/msm_syncobj.c | 172 ++ drivers/gpu/drm/msm/msm_syncobj.h | 37 + include/drm/drm_gem.h | 10 +- include/drm/drm_gpuvm.h | 8 + include/uapi/drm/msm_drm.h | 149 +- 58 files changed, 3731 insertions(+), 1260 deletions(-) create mode 100644 drivers/gpu/drm/msm/msm_syncobj.c create mode 100644 drivers/gpu/drm/msm/msm_syncobj.h -- 2.50.0