From patchwork Tue Dec 10 13:09:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Lawrynowicz X-Patchwork-Id: 13901416 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BFF38E7717F for ; Tue, 10 Dec 2024 13:09:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7B0F510E8CA; Tue, 10 Dec 2024 13:09:47 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="OarPhwi8"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6B1C810E5CB for ; Tue, 10 Dec 2024 13:09:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1733836184; x=1765372184; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Kins5pRBzjG2BfRs5W6rRnhUS4kpsEx0TMCHyLNnups=; b=OarPhwi8WwdHuZOjV748FeRsH8C/Iyg9GHDzBcGfVuMZ5i7IMFdy5f2R m4GaA3b8Ou+5iFaahzPl22nsOcPbx/CIfkvo9GHknrXct7sfTWP4yy7r2 8VZgbpKfcXWsg24BhmwAJoJ7NA18cXt9Ar0julRMKhEuc66L/9hGsxBny TUwPBNmbzKo0af1biaA5HJBVzeJ5A9ZjukXC5o+rFGuyI+zXIrfKpfjjw fiNMDV+bX/LXINA8bCis2FEen3/Lr6hQ2b5+wxHkPPiEWX/FnUfSlZBSf A1R3BpSNziyfOxyzIrMXtfJJbYA0Fk2ZGAQMvQQ+LnSW3qSqWjlzr3j2d Q==; X-CSE-ConnectionGUID: OsNVrAmMSHGg+n3YFscYwA== X-CSE-MsgGUID: CAbMC7hrQ2eEwElNQg/r9w== X-IronPort-AV: E=McAfee;i="6700,10204,11282"; a="34080111" X-IronPort-AV: E=Sophos;i="6.12,222,1728975600"; d="scan'208";a="34080111" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2024 05:09:44 -0800 X-CSE-ConnectionGUID: NAGnexRgSbeHscYKd9XPmQ== X-CSE-MsgGUID: eRmEsOjIQmeP0iafsVh8Cw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,222,1728975600"; d="scan'208";a="95242036" Received: from jlawryno.igk.intel.com ([10.91.220.59]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2024 05:09:42 -0800 From: Jacek Lawrynowicz To: dri-devel@lists.freedesktop.org Cc: oded.gabbay@gmail.com, quic_jhugo@quicinc.com, Jacek Lawrynowicz , stable@vger.kernel.org, Karol Wachowski Subject: [PATCH 1/3] accel/ivpu: Fix general protection fault in ivpu_bo_list() Date: Tue, 10 Dec 2024 14:09:37 +0100 Message-ID: <20241210130939.1575610-2-jacek.lawrynowicz@linux.intel.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20241210130939.1575610-1-jacek.lawrynowicz@linux.intel.com> References: <20241210130939.1575610-1-jacek.lawrynowicz@linux.intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Check if ctx is not NULL before accessing its fields. Fixes: 37dee2a2f433 ("accel/ivpu: Improve buffer object debug logs") Cc: # v6.8 Signed-off-by: Jacek Lawrynowicz Reviewed-by: Karol Wachowski Reviewed-by: Jeffrey Hugo --- drivers/accel/ivpu/ivpu_gem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/accel/ivpu/ivpu_gem.c b/drivers/accel/ivpu/ivpu_gem.c index d8e97a760fbc0..16178054e6296 100644 --- a/drivers/accel/ivpu/ivpu_gem.c +++ b/drivers/accel/ivpu/ivpu_gem.c @@ -409,7 +409,7 @@ static void ivpu_bo_print_info(struct ivpu_bo *bo, struct drm_printer *p) mutex_lock(&bo->lock); drm_printf(p, "%-9p %-3u 0x%-12llx %-10lu 0x%-8x %-4u", - bo, bo->ctx->id, bo->vpu_addr, bo->base.base.size, + bo, bo->ctx ? bo->ctx->id : 0, bo->vpu_addr, bo->base.base.size, bo->flags, kref_read(&bo->base.base.refcount)); if (bo->base.pages) From patchwork Tue Dec 10 13:09:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Lawrynowicz X-Patchwork-Id: 13901415 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 29F39E77180 for ; Tue, 10 Dec 2024 13:09:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C2DF710E8C7; Tue, 10 Dec 2024 13:09:46 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="XRRg58lr"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) by gabe.freedesktop.org (Postfix) with ESMTPS id ED62910E8C7 for ; Tue, 10 Dec 2024 13:09:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1733836186; x=1765372186; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Gcq+X6hIjP+NuICh65wQedWsph1z0FwxkCftGkiyaGo=; b=XRRg58lrUYcEKlC8cqHQzywR6vkL9XU2tVrN+vrK5FiUerUMI/SLQ+Rn eAVWsEk3exe7IgBcoLkarA3lOj7mgTi3Slxdk1BvS+DyoX2VNZIhJAnSs /nTlQg0K2rdeuP4usyuE5FHqrvTsJJk+zLtU41o1PxK8JjJajz1Y2eeei SLCmhoxdKwIT8gLW1YOIwghvJnUI1Kyyyk0UmearATCHAWsmABlCB3Pe6 Xjjqs5BuaB+I2Vqy49qO3742OC8tCmAROgpaFya0xkT43YryZbTOWKYiW cOd6Ocax2KrXl2h3YwxyWbcqvXgKC/ZOy1DqR6Lu2i+9nSE3JmVBsVzD2 Q==; X-CSE-ConnectionGUID: KTh0m5sTT0qbDS1doHgeCQ== X-CSE-MsgGUID: 9K8Q6EW2SN2MQTXeZY8wLQ== X-IronPort-AV: E=McAfee;i="6700,10204,11282"; a="34080115" X-IronPort-AV: E=Sophos;i="6.12,222,1728975600"; d="scan'208";a="34080115" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2024 05:09:46 -0800 X-CSE-ConnectionGUID: T9a40iDkTdOL2+N6Anbujw== X-CSE-MsgGUID: /AmFCNpSRnuJxV8bhftcxw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,222,1728975600"; d="scan'208";a="95242043" Received: from jlawryno.igk.intel.com ([10.91.220.59]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2024 05:09:44 -0800 From: Jacek Lawrynowicz To: dri-devel@lists.freedesktop.org Cc: oded.gabbay@gmail.com, quic_jhugo@quicinc.com, Jacek Lawrynowicz , Karol Wachowski Subject: [PATCH 2/3] accel/ivpu: Fix memory leak in ivpu_mmu_reserved_context_init() Date: Tue, 10 Dec 2024 14:09:38 +0100 Message-ID: <20241210130939.1575610-3-jacek.lawrynowicz@linux.intel.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20241210130939.1575610-1-jacek.lawrynowicz@linux.intel.com> References: <20241210130939.1575610-1-jacek.lawrynowicz@linux.intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add appropriate error handling to ensure all allocated resources are released upon encountering an error. Fixes: a74f4d991352 ("accel/ivpu: Defer MMU root page table allocation") Cc: Karol Wachowski Signed-off-by: Jacek Lawrynowicz Reviewed-by: Karol Wachowski Reviewed-by: Jeffrey Hugo --- drivers/accel/ivpu/ivpu_mmu_context.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/accel/ivpu/ivpu_mmu_context.c b/drivers/accel/ivpu/ivpu_mmu_context.c index 891967a95bc3c..0af614dfb6f92 100644 --- a/drivers/accel/ivpu/ivpu_mmu_context.c +++ b/drivers/accel/ivpu/ivpu_mmu_context.c @@ -612,18 +612,22 @@ int ivpu_mmu_reserved_context_init(struct ivpu_device *vdev) if (!ivpu_mmu_ensure_pgd(vdev, &vdev->rctx.pgtable)) { ivpu_err(vdev, "Failed to allocate root page table for reserved context\n"); ret = -ENOMEM; - goto unlock; + goto err_ctx_fini; } ret = ivpu_mmu_cd_set(vdev, vdev->rctx.id, &vdev->rctx.pgtable); if (ret) { ivpu_err(vdev, "Failed to set context descriptor for reserved context\n"); - goto unlock; + goto err_ctx_fini; } -unlock: mutex_unlock(&vdev->rctx.lock); return ret; + +err_ctx_fini: + mutex_unlock(&vdev->rctx.lock); + ivpu_mmu_context_fini(vdev, &vdev->rctx); + return ret; } void ivpu_mmu_reserved_context_fini(struct ivpu_device *vdev) From patchwork Tue Dec 10 13:09:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Lawrynowicz X-Patchwork-Id: 13901417 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 30492E77180 for ; Tue, 10 Dec 2024 13:09:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4722310E8CF; Tue, 10 Dec 2024 13:09:50 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="HEc4BZvH"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) by gabe.freedesktop.org (Postfix) with ESMTPS id B048410E8CB for ; Tue, 10 Dec 2024 13:09:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1733836188; x=1765372188; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gs3pQyhAtuTtqsflnavxroyRBi2uR2QXMjWyUdGPln4=; b=HEc4BZvHwHLcQLQ+7qRUme5banzzMvVCss70Ncx+vUm7c/+Yvw4o2CKq 20JK7YdvBTbKu4HB2AVSQMc7QSmud21+foJu7x4YZXnW9s9aiD0nLFdic BHAf+FiQoHvLiYq6CzVK1OT2gTJZW0GHlxZiCVgPv9IBXuIVUYDcrz+rk 3aKeB3aVRk1E87EbKPGajRXf36DvG7MZ9LKnhoCSMaT4eeoNjf8Va3R9n kxn6FFvNhtCJdqboWs7AihxMLAwljWMTIU4V9BvxY5lxKcPC8MtYdRGSL S49mqvTrM3YVXZuP2bhJXzYIzapwDKg/1G7Enkz1fBIS/CYaOmrMH3knW w==; X-CSE-ConnectionGUID: /KVv7vVXTX+VYBwtZEs5qg== X-CSE-MsgGUID: /5u3ayurSpuyOek6bk3eUA== X-IronPort-AV: E=McAfee;i="6700,10204,11282"; a="34080125" X-IronPort-AV: E=Sophos;i="6.12,222,1728975600"; d="scan'208";a="34080125" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2024 05:09:48 -0800 X-CSE-ConnectionGUID: 5X3wo6H4SfqBm5AMrmYskw== X-CSE-MsgGUID: 4NWQVyBYTqiXVgqKb+j15w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,222,1728975600"; d="scan'208";a="95242050" Received: from jlawryno.igk.intel.com ([10.91.220.59]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2024 05:09:46 -0800 From: Jacek Lawrynowicz To: dri-devel@lists.freedesktop.org Cc: oded.gabbay@gmail.com, quic_jhugo@quicinc.com, Jacek Lawrynowicz , stable@vger.kernel.org, Karol Wachowski Subject: [PATCH 3/3] accel/ivpu: Fix WARN in ivpu_ipc_send_receive_internal() Date: Tue, 10 Dec 2024 14:09:39 +0100 Message-ID: <20241210130939.1575610-4-jacek.lawrynowicz@linux.intel.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20241210130939.1575610-1-jacek.lawrynowicz@linux.intel.com> References: <20241210130939.1575610-1-jacek.lawrynowicz@linux.intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Move pm_runtime_set_active() to ivpu_pm_inti() so when ivpu_ipc_send_receive_internal() is executed before ivpu_pm_enable() it already has correct runtime state, even if last resume was not successful. Fixes: 8ed520ff4682 ("accel/ivpu: Move set autosuspend delay to HW specific code") Cc: # v6.7+ Signed-off-by: Jacek Lawrynowicz Reviewed-by: Karol Wachowski Reviewed-by: Jeffrey Hugo --- drivers/accel/ivpu/ivpu_pm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/accel/ivpu/ivpu_pm.c b/drivers/accel/ivpu/ivpu_pm.c index dbc0711e28d13..949f4233946c6 100644 --- a/drivers/accel/ivpu/ivpu_pm.c +++ b/drivers/accel/ivpu/ivpu_pm.c @@ -378,6 +378,7 @@ void ivpu_pm_init(struct ivpu_device *vdev) pm_runtime_use_autosuspend(dev); pm_runtime_set_autosuspend_delay(dev, delay); + pm_runtime_set_active(dev); ivpu_dbg(vdev, PM, "Autosuspend delay = %d\n", delay); } @@ -392,7 +393,6 @@ void ivpu_pm_enable(struct ivpu_device *vdev) { struct device *dev = vdev->drm.dev; - pm_runtime_set_active(dev); pm_runtime_allow(dev); pm_runtime_mark_last_busy(dev); pm_runtime_put_autosuspend(dev);