Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp252940imm; Thu, 26 Jul 2018 18:19:22 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcM7XT1xOV4eSaNR0u+trfnIF5p8WUAASMjURChbN96ujp1mS1M3uKEpNKAaurRcp4pOtEi X-Received: by 2002:a63:7a43:: with SMTP id j3-v6mr3949806pgn.363.1532654362656; Thu, 26 Jul 2018 18:19:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532654362; cv=none; d=google.com; s=arc-20160816; b=qYJ6njuY/T2xu0f0EqxIVJ8GXXTT3kglfl81sTmOj5wL+M1pD7iWAgbtT/VEgCevqL J7lFTy+zNIuKiodFZLjh3rueEO918NcOLYYgFZDN5FfID9ix4rmiDDivfuqU5Onemzzl 1wtkBzcRR2e3aAJ9ncoX8wmWYyXzXJEWtFDi2/qQV8++u4RhoWZ/yLzMo2iko1PWPxvc u2bTq8glv/BN5LtvcHF96w4r42ldMMXtTTKI64i2DjMldyAY2zN50oTorTtKAMEl9FXR qWUb8CF54jJcpHcEO8NopcpHRgePaKx5SXbQneImDczYGwJhdxrvKXIrcGeIAb9Dzi3x U32A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject:dkim-signature :arc-authentication-results; bh=ODloMAzNcUY29Epgu/gvVDiKDIGTK2rY1PuMeJllD+0=; b=Z+gh4sL9Ynmedmn7RR0txqy3rnBlEihRwQM9Xyg/YBdkXBr+kBz/EwUFFRmXRqLTdw CoU8Df+lyFV1hthHuJQhOQ8uf8nNDb0L71CaTi59RrbpEj+sX1YmvdqWoQSjm+atoEvs O05RSBP8CF6uzL+39Iz2B+fE9CX9FspVItVtxcHyOmVocyaWIom6NHox763PaUE9Z0Yt +a78rdVWaz+4SOiCjwQZpBeDJsxDjAQqCvT8WJ8cY2scJkLIug1QKX1fYahuGqEskG53 9JYp5mR5xMnxnn8I+nkPJZ13AFa3fXxIy/RK3OtutAByHGERpY3X7NMipxKi3+GRlz6K sEpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=le2cAeZQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f9-v6si2695151pgi.12.2018.07.26.18.19.07; Thu, 26 Jul 2018 18:19:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=le2cAeZQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732043AbeG0ChK (ORCPT + 99 others); Thu, 26 Jul 2018 22:37:10 -0400 Received: from lelv0142.ext.ti.com ([198.47.23.249]:57460 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731737AbeG0ChJ (ORCPT ); Thu, 26 Jul 2018 22:37:09 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id w6R1HhZw045720; Thu, 26 Jul 2018 20:17:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1532654263; bh=ODloMAzNcUY29Epgu/gvVDiKDIGTK2rY1PuMeJllD+0=; h=Subject:From:To:CC:References:Date:In-Reply-To; b=le2cAeZQ4fhI9oSDlegHCRXYz9BYNYfbEd3sy/yHSB6rNd0OBwgfTIvU78XUUm/sx l0ps4M1hM0vMrzSYhTvmeeWlw04IOiGgII/LgZh8gai0mWKYPpjd6PKdUV4izFuETk l71o/KtMQdc7g564GTjiAJV0XymlHQlSJRqErGYg= Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w6R1HhvA031521; Thu, 26 Jul 2018 20:17:43 -0500 Received: from DFLE108.ent.ti.com (10.64.6.29) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Thu, 26 Jul 2018 20:17:43 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Thu, 26 Jul 2018 20:17:43 -0500 Received: from [128.247.58.153] (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w6R1Hhw3013385; Thu, 26 Jul 2018 20:17:43 -0500 Subject: Re: [PATCH v2 1/1] remoteproc: correct rproc_free_vring() to avoid invalid kernel paging From: Suman Anna To: Loic PALLARDY , "bjorn.andersson@linaro.org" , "ohad@wizery.com" CC: "linux-remoteproc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Arnaud POULIQUEN , "benjamin.gaignard@linaro.org" References: <1530863212-16584-1-git-send-email-loic.pallardy@st.com> <8e943f4d2a1b4e10a8a0756c737d53a8@SFHDAG7NODE2.st.com> <56aeb569-cd4d-3769-fdad-ee3d4dbdc19b@ti.com> Message-ID: <62bfadef-d330-4724-12c0-d4b2f3999980@ti.com> Date: Thu, 26 Jul 2018 20:17:43 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <56aeb569-cd4d-3769-fdad-ee3d4dbdc19b@ti.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/26/2018 06:51 PM, Suman Anna wrote: > Hi Loic, > > On 07/26/2018 02:48 AM, Loic PALLARDY wrote: >> Hi Suman, >>> >>> Hi Loic, >>> >>> On 07/06/2018 02:46 AM, Loic Pallardy wrote: >>>> If rproc_start() failed, rproc_resource_cleanup() is called to clean >>>> debugfs entries, then associated iommu mappings, carveouts and vdev. >>>> Issue occurs when rproc_free_vring() is trying to reset vring resource >>>> table entry. >>>> At this time, table_ptr is pointing on loaded resource table and carveouts >>>> already released, so access to loaded resource table is generating a kernel >>>> paging error: >>> >>> Are you using a device specific CMA pool or carveout, and if so, where >>> the pool is? If not, where is the default CMA pool? I am trying to >>> reproduce the issue on my platform with the start failure as you >>> suggested, but haven't seen it so far. That said, I have seen the exact >>> same crash when using HighMEM CMA pools on my downstream kernel >>> when >>> stopping the processor, and the root cause is essentially the same as >>> what you summarized here. The issue was present with LowMem pools as >>> well, but got masked because of the kernel linear mapping. >> >> I have a carveout declared in firmware resource table for co-processor code and data, and st driver has a specific >> reserved memory region to fit fix address space requested by co-processor. >> So CPU access to code and loaded resource table area is granted thanks to allocation done by rproc_handle_carveout(). > > Where are the vrings getting allocated from? > > In anycase, I prefer that we should actually reset the table_ptr in > rproc_start() in failure cases (undo the operation essentially) as we > don't call rproc_stop() in those cases. This will result in symmetric > code. We already have the reset handled in rproc_stop() added recently > in commit 0a8b81cb2e41 ("remoteproc: Reset table_ptr on stop"). Let me > know what you think, I can send a quick patch. FYI, patch for the same posted here, https://patchwork.kernel.org/patch/10546555/ regards Suman >> >>> >>>> >>>> [ 12.696535] Unable to handle kernel paging request at virtual address >>> f0f357cc >>>> [ 12.696540] pgd = (ptrval) >>>> [ 12.696542] [f0f357cc] *pgd=6d2d0811, *pte=00000000, *ppte=00000000 >>>> [ 12.696558] Internal error: Oops: 807 [#1] SMP ARM >>>> [ 12.696563] Modules linked in: rpmsg_core v4l2_mem2mem >>> videobuf2_dma_contig sti_drm v4l2_common vida >>>> [ 12.696598] CPU: 1 PID: 48 Comm: kworker/1:1 Tainted: G W >>> 4.18.0-rc2-00018-g3170fdd-8 >>>> [ 12.696602] Hardware name: STi SoC with Flattened Device Tree >>>> [ 12.696625] Workqueue: events request_firmware_work_func >>>> [ 12.696659] PC is at rproc_free_vring+0x84/0xbc [remoteproc] >>>> [ 12.696667] LR is at rproc_free_vring+0x70/0xbc [remoteproc] >>>> >>>> This patch proposes to simply remove reset of resource table vring entries, >>>> as firmware and resource table are reloaded at each rproc boot. >>>> rproc_trigger_recovery() not impacted as resources not touched during >>> recovery >>>> procedure. >>> >>> And error recovery doesn't work for me after the rproc_start, stop got >>> introduced. >> Recovery no available on B2260, but I'll test it on another platform this week >> >> Regards, >> Loic >>> >>> regards >>> Suman >>> >>>> >>>> Signed-off-by: Loic Pallardy >>>> --- >>>> Changes from V1: typo fixes in commit message >>>> >>>> drivers/remoteproc/remoteproc_core.c | 6 ------ >>>> 1 file changed, 6 deletions(-) >>>> >>>> diff --git a/drivers/remoteproc/remoteproc_core.c >>> b/drivers/remoteproc/remoteproc_core.c >>>> index a9609d9..9a8b47c 100644 >>>> --- a/drivers/remoteproc/remoteproc_core.c >>>> +++ b/drivers/remoteproc/remoteproc_core.c >>>> @@ -289,16 +289,10 @@ void rproc_free_vring(struct rproc_vring *rvring) >>>> { >>>> int size = PAGE_ALIGN(vring_size(rvring->len, rvring->align)); >>>> struct rproc *rproc = rvring->rvdev->rproc; >>>> - int idx = rvring->rvdev->vring - rvring; >>>> - struct fw_rsc_vdev *rsc; >>>> >>>> dma_free_coherent(rproc->dev.parent, size, rvring->va, rvring- >>>> dma); >>>> idr_remove(&rproc->notifyids, rvring->notifyid); >>>> >>>> - /* reset resource entry info */ >>>> - rsc = (void *)rproc->table_ptr + rvring->rvdev->rsc_offset; >>>> - rsc->vring[idx].da = 0; >>>> - rsc->vring[idx].notifyid = -1; >>>> } >>>> >>>> static int rproc_vdev_do_probe(struct rproc_subdev *subdev) >>>> >> >