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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA6A7C6FA82 for ; Fri, 16 Sep 2022 14:38:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230265AbiIPOiz (ORCPT ); Fri, 16 Sep 2022 10:38:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231328AbiIPOiq (ORCPT ); Fri, 16 Sep 2022 10:38:46 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6192CB40EF for ; Fri, 16 Sep 2022 07:38:45 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id dv25so49827721ejb.12 for ; Fri, 16 Sep 2022 07:38:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=2hekt6nHmDXb09svRYspIovCwUxYyIVHgZSXoQyIl+k=; b=SFH1piZ1wl+dYjTFfiOzjwm5fI+/WSD0vBB9yBMmjrbolDnWC/6U9TVbGpDPit/0ES UUWUzIMXDJswTFPpUSs2bQz1HKHAlff4k2OO982m7E2ogYAaAlCcz+v6pL6YXHn7JZ09 263HOyhB9k8djHzypKXBiHPWGswf9IMrrY0odun/7GVSrmRHrtorYPkfRwkXf79IOyhU rsTJO7Kie/UsasSir2ML+YdjREDVgRnjk1VSA1ZA7xpfUu60Xu2CKXq5NELJHbDCB2To IoR0qoMNN7IOJY031zmLjTFaKb1fNbBHf+e6M0wKl30ktbsDQdlx9EZwtUk9ydlQK7Qu myEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=2hekt6nHmDXb09svRYspIovCwUxYyIVHgZSXoQyIl+k=; b=0DcO8tgO281fuS7esFSED5Lxgf1ppeo7VTc/dt+Dd4NUCC0U46gqoTKoBV7nwwfYDP 5bKmRS64sqCaf5zAEAaF4JhErPlPs+Dg3FqnmMNL8CiW/nJMyzdOVxFSPc7VjvK7DBIo 62ZqUN5Ol7FPAG7E0FAc2bqjraPe4lncnB8Oj0auB5AG5HSem0h02fjMQaTljp0jv/ql L8EaFgxi1z/hUtHNQ+LrwE1BkKsGDmqMq2ODHE3xjVCxnKU8wmhanuQPiISF23775kr8 R+VdXsbfeZl5jozXLSesLQwBtsEllXr1slUP6uXZzQ9kDnaIFjje1NoNRzc8s0RHvf9g MxsA== X-Gm-Message-State: ACrzQf2wHLBkDWA00skmRaPFJ0j96fCfzikcwJ7Pbv8C62cpeHQQttNl 8gmjMaBy3JZZXFvEbWiocaTDyg== X-Google-Smtp-Source: AMsMyM520XIqN6p3HKYAlwE92zHeNJJ+Fe5xeWMnuVrGvp0QrtwA4dQnKiX2weHwOi8VZ2B4Q7JoXw== X-Received: by 2002:a17:906:7944:b0:73c:838:ac3d with SMTP id l4-20020a170906794400b0073c0838ac3dmr3824004ejo.242.1663339123786; Fri, 16 Sep 2022 07:38:43 -0700 (PDT) Received: from linaro.org ([94.52.112.99]) by smtp.gmail.com with ESMTPSA id p21-20020a170906499500b0078082f95e5csm1393062eju.204.2022.09.16.07.38.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 07:38:41 -0700 (PDT) Date: Fri, 16 Sep 2022 17:38:40 +0300 From: Abel Vesa To: Srinivas Kandagatla Cc: Amol Maheshwari , Andy Gross , Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Ekansh Gupta , Bharath Kumar , Himateja Reddy , Anirudh Raghavendra , Arnd Bergmann , Greg Kroah-Hartman , linux-arm-msm@vger.kernel.org, Linux Kernel Mailing List , devicetree@vger.kernel.org Subject: Re: [PATCH v3 08/10] misc: fastrpc: Safekeep mmaps on interrupted invoke Message-ID: References: <20220909133938.3518520-1-abel.vesa@linaro.org> <20220909133938.3518520-9-abel.vesa@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org On 22-09-16 13:58:35, Srinivas Kandagatla wrote: > > > On 09/09/2022 14:39, Abel Vesa wrote: > > If the userspace daemon is killed in the middle of an invoke (e.g. > > audiopd listerner invoke), we need to skip the unmapping on device > > release, otherwise the DSP will crash. So lets safekeep all the maps > > only if there is in invoke interrupted, by attaching them to the channel > > context (which is resident until RPMSG driver is removed), and free them > > on RPMSG driver remove. > > > > Signed-off-by: Abel Vesa > > --- > > drivers/misc/fastrpc.c | 15 +++++++++++++++ > > 1 file changed, 15 insertions(+) > > > > diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c > > index 6b2a552dbdba..bc1e8f003d7a 100644 > > --- a/drivers/misc/fastrpc.c > > +++ b/drivers/misc/fastrpc.c > > @@ -275,6 +275,7 @@ struct fastrpc_channel_ctx { > > struct fastrpc_device *secure_fdevice; > > struct fastrpc_device *fdevice; > > struct fastrpc_buf *remote_heap; > > + struct list_head invoke_interrupted_mmaps; > > bool secure; > > bool unsigned_support; > > }; > > @@ -1119,6 +1120,8 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel, > > struct fastrpc_invoke_args *args) > > { > > struct fastrpc_invoke_ctx *ctx = NULL; > > + struct fastrpc_buf *buf, *b; > > + > > int err = 0; > > if (!fl->sctx) > > @@ -1182,6 +1185,13 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel, > > fastrpc_context_put(ctx); > > } > > + if (err == -ERESTARTSYS) { > > + list_for_each_entry_safe(buf, b, &fl->mmaps, node) { > > + list_del(&buf->node); > > + list_add_tail(&buf->node, &fl->cctx->invoke_interrupted_mmaps); > > + } > > + } > > + > > if (err) > > dev_dbg(fl->sctx->dev, "Error: Invoke Failed %d\n", err); > > @@ -2277,6 +2287,7 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev) > > dev_set_drvdata(&rpdev->dev, data); > > dma_set_mask_and_coherent(rdev, DMA_BIT_MASK(32)); > > INIT_LIST_HEAD(&data->users); > > + INIT_LIST_HEAD(&data->invoke_interrupted_mmaps); > > spin_lock_init(&data->lock); > > idr_init(&data->ctx_idr); > > data->domain_id = domain_id; > > @@ -2301,6 +2312,7 @@ static void fastrpc_notify_users(struct fastrpc_user *user) > > static void fastrpc_rpmsg_remove(struct rpmsg_device *rpdev) > > { > > struct fastrpc_channel_ctx *cctx = dev_get_drvdata(&rpdev->dev); > > + struct fastrpc_buf *buf, *b; > > struct fastrpc_user *user; > > unsigned long flags; > > @@ -2315,6 +2327,9 @@ static void fastrpc_rpmsg_remove(struct rpmsg_device *rpdev) > > if (cctx->secure_fdevice) > > misc_deregister(&cctx->secure_fdevice->miscdev); > > + list_for_each_entry_safe(buf, b, &cctx->invoke_interrupted_mmaps, node) > > + list_del(&buf->node); > > + > When would you free these? > looks like we are leaking even after dsp is down.. > Should we not do fastrpc_buf_free() here? Yes, we should. I forgot to add it. Will send a new version. Thanks. > > > > --srini > > > if (cctx->remote_heap) > > fastrpc_buf_free(cctx->remote_heap);