From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 DFA88C36000 for ; Tue, 17 Sep 2024 09:41:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:CC:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=rVVmQPcwTSus71ETasIqw7oZH8e1wL19MfvMqR3xvj8=; b=ixb4JcMhHNpcV/5Pa5ynDUaHN3 td9m26L84RxhL8z3UmvDCMEAfqg/rvt4n9uYfhMBWIeH/Ybf1Ai6iUyQe23CNpAMJy/OIYZZKN8PV KDNcB/QUtbevnbTpFRn8349hxexnfI6+tFojGQIZtP2jS1rOsFC9YSezga/ldVAmxw+G8D9jNfQwT 1EDxAtQzDw+jp3Tj8VTCowCat9kAj9nnK9wBGeIYkLxaivvJlQTN0va7vcWrriDL417m/654znk/p P3IxqgIdYya/sbzhuF6Oa2rxuQ4DT8f27IjI68iBukDRKZuUHashiBag5NOzPvLG/pIalUbNhJOeV FJA7qyBg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sqUi6-00000005r35-1SVo; Tue, 17 Sep 2024 09:41:26 +0000 Received: from lelv0142.ext.ti.com ([198.47.23.249]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sqUgz-00000005qpi-16hH for linux-arm-kernel@lists.infradead.org; Tue, 17 Sep 2024 09:40:18 +0000 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 48H9eCeR106185; Tue, 17 Sep 2024 04:40:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1726566012; bh=rVVmQPcwTSus71ETasIqw7oZH8e1wL19MfvMqR3xvj8=; h=Date:Subject:To:CC:References:From:In-Reply-To; b=SNks2fauBEt/CaNQWHz1ZAD4l8jLYw7V4P2ZYYQBZtnOKAJszUkNCTyLSbybZpOPR xBcXPMB/wewt3fmM6fh7Tqv8vebwMktG1E+Har7zJITvxTZ0JK7jBaMnCjEvgNMwtN uxH6gypwmy5UzJvvP2k+JsoRWsg1x+JdkwUSosCU= Received: from DFLE105.ent.ti.com (dfle105.ent.ti.com [10.64.6.26]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTP id 48H9eCO0029608; Tue, 17 Sep 2024 04:40:12 -0500 Received: from DFLE106.ent.ti.com (10.64.6.27) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Tue, 17 Sep 2024 04:40:12 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DFLE106.ent.ti.com (10.64.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Tue, 17 Sep 2024 04:40:12 -0500 Received: from [172.24.227.151] (uda0510294.dhcp.ti.com [172.24.227.151]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 48H9e9j4058142; Tue, 17 Sep 2024 04:40:10 -0500 Message-ID: Date: Tue, 17 Sep 2024 15:10:08 +0530 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH] remoteproc: k3-r5: Fix check performed in k3_r5_rproc_{mbox_callback/kick} To: Mathieu Poirier , "Kumar, Udit" CC: Siddharth Vadapalli , Hari Nagalla , Andrew Davis , , , , , References: <20240916083131.2801755-1-s-vadapalli@ti.com> Content-Language: en-US From: Beleswar Prasad Padhi In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240917_024017_436780_350FD405 X-CRM114-Status: GOOD ( 26.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Mathieu, On 17/09/24 14:07, Mathieu Poirier wrote: > On Mon, 16 Sept 2024 at 23:20, Kumar, Udit wrote: >> On 9/16/2024 8:50 PM, Mathieu Poirier wrote: >>> On Mon, 16 Sept 2024 at 02:31, Siddharth Vadapalli wrote: >>>> Commit f3f11cfe8907 ("remoteproc: k3-r5: Acquire mailbox handle during >>>> probe routine") introduced a check in the "k3_r5_rproc_mbox_callback()" and >>>> "k3_r5_rproc_kick()" callbacks, causing them to exit if the remote core's >>>> state is "RPROC_DETACHED". However, the "__rproc_attach()" function that is >>>> responsible for attaching to a remote core, updates the state of the remote >>>> core to "RPROC_ATTACHED" only after invoking "rproc_start_subdevices()". >>>> >>>> The "rproc_start_subdevices()" function triggers the probe of the Virtio >>>> RPMsg devices associated with the remote core, which require that the >>>> "k3_r5_rproc_kick()" and "k3_r5_rproc_mbox_callback()" callbacks are >>>> functional. Hence, drop the check in the callbacks. >>> Honestly, I am very tempted to just revert f3f11cfe8907 and ea1d6fb5b571. >> >> Please don't :) , it will break rproc in general for k3 devices. >> > Why not - it is already broken anyway. Reverting the patches will > force TI to actually think about the feature in terms of design, > completeness and testing. The merge window opened on Sunday - I'm not > going to merge whack-a-mole patches and hope the right fix comes > along. Apologies for causing this trouble, Mathieu. I have accumulated various use-cases of the driver, including this, and hereon will keep in mind while posting further patches. > >> Couple of solutions for this race around condition (in mine preference >> order) >> > This is for the TI team to discuss _and_ test thoroughly. From hereon > and until I see things improve, all patches from TI will need to be > tagged with R-B and T-B tags (collected on the mailing lists) from two > different individuals before I look at them. Understood, that is a fair ask. Hereon, I will also attach my test logs for all the usecases I've tested a patch with, to give more visibility on the testing done. > >> 1) In >> https://elixir.bootlin.com/linux/v6.11/source/drivers/remoteproc/ti_k3_r5_remoteproc.c#L190 >> have a check , if probe in is progress or not >> >> 2) >> https://elixir.bootlin.com/linux/v6.11/source/drivers/remoteproc/ti_k3_r5_remoteproc.c#L1205 >> -- correct the state to ON or something else >> >> 3) Move condition >> https://elixir.bootlin.com/linux/v6.11/source/drivers/remoteproc/remoteproc_core.c#L1360 >> before rproc_start_subdevices >> >> calling >> >> >> >>>> Fixes: f3f11cfe8907 ("remoteproc: k3-r5: Acquire mailbox handle during probe routine") >>>> Signed-off-by: Siddharth Vadapalli >>>> --- >>>> >>>> Hello, >>>> >>>> Since the commit being fixed is not yet a part of Mainline Linux, this >>>> patch is based on linux-next tagged next-20240913. >>>> >>>> An alternative to this patch will be a change to the "__rproc_attach()" >>>> function in the "remoteproc_core.c" driver with >>>> rproc->state = RPROC_ATTACHED; >>>> being set after "rproc_attach_device()" is invoked, but __before__ >>>> invoking "rproc_start_subdevices()". Since this change will be performed >>>> in the common Remoteproc Core, it appeared to me that fixing it in the >>>> TI remoteproc driver is the correct approach. >>>> >>>> The equivalent of this patch for ti_k3_dsp_remoteproc.c might also be >>>> required, which I shall post if the current patch is acceptable. >>>> >>>> Kindly review and share your feedback on this patch. >>>> >>>> Regards, >>>> Siddharth. >>>> >>>> drivers/remoteproc/ti_k3_r5_remoteproc.c | 8 -------- >>>> 1 file changed, 8 deletions(-) >>>> >>>> diff --git a/drivers/remoteproc/ti_k3_r5_remoteproc.c b/drivers/remoteproc/ti_k3_r5_remoteproc.c >>>> index 747ee467da88..4894461aa65f 100644 >>>> --- a/drivers/remoteproc/ti_k3_r5_remoteproc.c >>>> +++ b/drivers/remoteproc/ti_k3_r5_remoteproc.c >>>> @@ -194,10 +194,6 @@ static void k3_r5_rproc_mbox_callback(struct mbox_client *client, void *data) >>>> const char *name = kproc->rproc->name; >>>> u32 msg = omap_mbox_message(data); >>>> >>>> - /* Do not forward message from a detached core */ >>>> - if (kproc->rproc->state == RPROC_DETACHED) >>>> - return; >>>> - >>>> dev_dbg(dev, "mbox msg: 0x%x\n", msg); >>>> >>>> switch (msg) { >>>> @@ -233,10 +229,6 @@ static void k3_r5_rproc_kick(struct rproc *rproc, int vqid) >>>> mbox_msg_t msg = (mbox_msg_t)vqid; >>>> int ret; >>>> >>>> - /* Do not forward message to a detached core */ >>>> - if (kproc->rproc->state == RPROC_DETACHED) >>>> - return; >>>> - >>>> /* send the index of the triggered virtqueue in the mailbox payload */ >>>> ret = mbox_send_message(kproc->mbox, (void *)msg); >>>> if (ret < 0) >>>> -- >>>> 2.40.1 >>>>