Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp624620pxb; Fri, 29 Oct 2021 17:03:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlLIoAydWCA4X2LDEyclSti1gQ04nPpYzs10C7kIrSF5EFnJkgiyr4h9sN4oIX0VdmoyyO X-Received: by 2002:a17:906:c20e:: with SMTP id d14mr18059431ejz.80.1635552202462; Fri, 29 Oct 2021 17:03:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635552202; cv=none; d=google.com; s=arc-20160816; b=CftJrBOFRd8WGDOKUI5lRokOKwES6FCXIZIX1E4wNitaKln3GB7aMCVq4zt6huHUft 94S6q3iwOODHPUrrVKWJcn3a93t0vxkXpeQwk1z2eAoLes6+wabopU7aLvpojpqa0k5e wXnf4SR87X4ZJtMAeUoieX3/QrIlH1/gMnLMuPw8NlBCEWsEIOXWh4EAjnSBwavPyyhz G0EHx5Ze8ufQEWEvSnIJ6hA0ChohUvPQ5b02R3ac2u1ao2RpZnsBmqMThFc+RFJErjWH ZcajhiubV1hMnw673oXCQibrbqE/5Obb35J00E33b5IzFJa/TFEH6+FMjcuRmXbh4NyJ lgQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=5g5uYOpUvbfjxaJiICWjHW49d1Em+rTKi4gF70TOHxg=; b=CGvrYfK4mE9/igz7q49dF0u3s9uL06Zg+wbijMjiDtqI2aGpcDcga/4kdP3wFYsgdT SeXNwQuxovX5b1VZc1l2RkYc3ccAYRHu81p/J+UpBnqDWm9W4DG9T+vVmE38f7lMEMiX ubWzT2ejL3Ik+8YxgxPcK/eniXgZKV9CmqroTkLBl4xj8QmG459WTumv4SWsOiEmkKVX HOCOtyfj6Zr97HFl+ElMw5/EOQIzlvqGaSduSV7vntAepC8Rbyz9gn0YIxK2nyDNDJU/ 3SAZTR/nZNzV3Zh7jdWgpIoG9LlFhniJiSiq3VpCBhACsv8dXYwaD8jI0UFFxjwkSzLl t1JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JggKoMhl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dz21si11792015edb.38.2021.10.29.17.02.57; Fri, 29 Oct 2021 17:03:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JggKoMhl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231616AbhJ3AC3 (ORCPT + 99 others); Fri, 29 Oct 2021 20:02:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231154AbhJ3AC3 (ORCPT ); Fri, 29 Oct 2021 20:02:29 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6158C061570 for ; Fri, 29 Oct 2021 16:59:59 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id f3so15892678lfu.12 for ; Fri, 29 Oct 2021 16:59:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5g5uYOpUvbfjxaJiICWjHW49d1Em+rTKi4gF70TOHxg=; b=JggKoMhlfFspzcDUsIkc347dS7xht2N8D6Ij6xACaoNBJdGrQOZmVnkuJlGDgtHdlH IQEGiAZBzfrpI4fRfyb0N6bCAdm9mMfBNujFv89B5lZMaqOKosmVtAyjzKcOTS6ZddY0 JrmIYSDglEIKMpO0NF3EX1Pd0uGtkuqHaoc8wOPrNzrnjG+kj3OyiSDqFiLJSxHqymh3 KSxdlocXpFcaHiIHyonAZ2FhZGCimyRS7VUSO3QTfLlfa2NGTGo0dw/2cakK8VAzwM1j G6ndx9q5ajcRNwsGaYxj9h09CYjCOocgAHsGMJwR8Dxv2PjajogZG6q7NrCBv2vZ4GUh 0jLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5g5uYOpUvbfjxaJiICWjHW49d1Em+rTKi4gF70TOHxg=; b=KwweqXdTBBJ3aBC+3JmyWNDuCLdGfeeEU4USq5lwdqxOxbM3sL1mUitZIfcQR/TdVK QnhNmlafT/P0vA9SP5dXO5t7orT22apUdrIvTEJiQ51w1JnUU5QT7qGbuPGZYwzO0Ece bR4uw2aXcgHFiVcdmplR9QEn4XTA57+KfFRFCq+/h3H+LGlq7RfTt2eD/DCAIu5OvfOI yxNKeug3PQZYV72ATAjRbIiFuyRKVW93pSfponE1/2vdvfoi4S9r1UXx0kovdZIFpYQy b9ODYCSr9V5IijR37UlFXVMOemAyvS5VZPZ0fkzjEqzdGJv4FhJ+w5vqEgbJ+J54Ivyz b05A== X-Gm-Message-State: AOAM533cduOptozvNgOndCJh/ZGjZh4F5jEXTzDTTxWZE1kPwYiMspgI ArCH8DgGaWGLrlX7pu61E9q7ufw7znzX+M/uO7HeRw== X-Received: by 2002:a05:6512:2022:: with SMTP id s2mr12509876lfs.661.1635551998004; Fri, 29 Oct 2021 16:59:58 -0700 (PDT) MIME-Version: 1.0 References: <20211029214833.2615274-1-tadeusz.struk@linaro.org> In-Reply-To: <20211029214833.2615274-1-tadeusz.struk@linaro.org> From: John Stultz Date: Fri, 29 Oct 2021 16:59:46 -0700 Message-ID: Subject: Re: [PATCH v2] media: venus: Synchronize probe() between venus_core and enc/dec To: Tadeusz Struk Cc: Stanimir Varbanov , Andy Gross , Bjorn Andersson , Mauro Carvalho Chehab , Lee Jones , Amit Pundir , linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 29, 2021 at 2:48 PM Tadeusz Struk wrote: > > Venus video encode/decode hardware driver consists of three modules. > The parent module venus-core, and two sub modules venus-enc and venus-dec. > The venus-core module allocates a common structure that is used by the > enc/dec modules, loads the firmware, and performs some common hardware > initialization. Since the three modules are loaded one after the other, > and their probe functions can run in parallel it is possible that > the venc_probe and vdec_probe functions can finish before the core > venus_probe function, which then can fail when, for example it > fails to load the firmware. In this case the subsequent call to venc_open > causes an Oops as it tries to dereference already uninitialized structures > through dev->parent and the system crashes in __pm_runtime_resume() as in > the trace below: > > [ 26.064835][ T485] Internal error: Oops: 96000006 [#1] PREEMPT SMP > [ 26.270914][ T485] Hardware name: Thundercomm Dragonboard 845c (DT) > [ 26.285019][ T485] pc : __pm_runtime_resume+0x34/0x178 > [ 26.286374][ T213] lt9611 10-003b: hdmi cable connected > [ 26.290285][ T485] lr : venc_open+0xc0/0x278 [venus_enc] > [ 26.290326][ T485] Call trace: > [ 26.290328][ T485] __pm_runtime_resume+0x34/0x178 > [ 26.290330][ T485] venc_open+0xc0/0x278 [venus_enc] > [ 26.290335][ T485] v4l2_open+0x184/0x294 > [ 26.290340][ T485] chrdev_open+0x468/0x5c8 > [ 26.290344][ T485] do_dentry_open+0x260/0x54c > [ 26.290349][ T485] path_openat+0xbe8/0xd5c > [ 26.290352][ T485] do_filp_open+0xb8/0x168 > [ 26.290354][ T485] do_sys_openat2+0xa4/0x1e8 > [ 26.290357][ T485] __arm64_compat_sys_openat+0x70/0x9c > [ 26.290359][ T485] invoke_syscall+0x60/0x170 > [ 26.290363][ T485] el0_svc_common+0xb8/0xf8 > [ 26.290365][ T485] do_el0_svc_compat+0x20/0x30 > [ 26.290367][ T485] el0_svc_compat+0x24/0x84 > [ 26.290372][ T485] el0t_32_sync_handler+0x7c/0xbc > [ 26.290374][ T485] el0t_32_sync+0x1b8/0x1bc > [ 26.290381][ T485] ---[ end trace 04ca7c088b4c1a9c ]--- > [ 26.290383][ T485] Kernel panic - not syncing: Oops: Fatal exception > > This can be fixed by synchronizing the three probe functions and > only allowing the venc_probe() and vdec_probe() to pass when venus_probe() > returns success. > > Changes in v2: > - Change locking from mutex_lock to mutex_trylock > in venc_probe and vdec_probe to avoid potential deadlock. > > Signed-off-by: Tadeusz Struk This works for me, and avoids the deadlock I was hitting with the earlier version of the patch! Tested-by: John Stultz thanks so much! -john