Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5865792imm; Mon, 27 Aug 2018 05:50:56 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbwMbHx2kQBX7dHTT3p0g3N85lzVSQIyOBfWtx2L7i9tK4JJicYsJVkIj27sw42/U6dub47 X-Received: by 2002:a17:902:bb0c:: with SMTP id l12-v6mr13117611pls.5.1535374256111; Mon, 27 Aug 2018 05:50:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535374256; cv=none; d=google.com; s=arc-20160816; b=i9wwhU76qGE04iLP34VnyCDrK4OxyqCvRj1/qNXYWxzZcWiryCAFvB0P/e34vJNK3+ o/FDPM1rvlgRGFtTn2FlwTYNHBOeCnJGRZENzJgxAZzUfRlVPC1nMVTWQ9O4cD4OHd8d v7TpgmwskbzqluZP38Rx+Z50IWjki639USgUc6Gf2IM7X4DWeGRsgMpSFFaHIfnfSpgy PU/YRMvbIOg0RmY4ruYxDaaJME4VmT8Ilok6lQgoAAXlJBhN1MRrMmfqOhDNRKWdiaYn g8GNVRc4TuZVFvwMGK5ZvCyCKOrLJ3mv/1VOcCFoAcR9v+641UqYhb9RDaUzTg16JC3S I/yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=wygN2mrmS4koYC+ONZbBWo00ZQWYcl/O1esymJPHIOo=; b=L7JEK8HVKdQzMlBkCqkowzIjfzx94+Q/Y4eHAzn41RECSeDDpfCir7tHVQzkstHbaH 0LDI14/tG39LhXH544aB3ljQRkQdztKIcXUh0jUmZL+8AZxlcnEu4apgvZ+o9tP/u9O9 kxD4nS3Grak4sEQ1xa/gUXmC47RUm6383DyLpMF/S72A8fQQzFwivlaCqQ0m2+bGe0b4 ZOl1V7CwohqoqVybFg6mEw3EYjZvNl3KFdyzbKcLonM4TWmO35kPRFuRXXR+PrkJFBaX 4nnFnN1XKPWXOQPlF17V4FEL8ltIQDk2z+nlWQYh+Oefi/yNTemhqjur+Y965LgpDWz8 jbHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=hXYlEh9Y; dkim=pass header.i=@codeaurora.org header.s=default header.b=BjrsufzW; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x6-v6si10981248pgg.249.2018.08.27.05.50.40; Mon, 27 Aug 2018 05:50:56 -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=@codeaurora.org header.s=default header.b=hXYlEh9Y; dkim=pass header.i=@codeaurora.org header.s=default header.b=BjrsufzW; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727158AbeH0QgD (ORCPT + 99 others); Mon, 27 Aug 2018 12:36:03 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:44444 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726809AbeH0QgD (ORCPT ); Mon, 27 Aug 2018 12:36:03 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 01DDB60600; Mon, 27 Aug 2018 12:49:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1535374171; bh=P34mUxrd2An7JXH3tkcxLwW4XhPDwa23B1WDJRoF+HY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=hXYlEh9YNQASughBTczVDMYFTw4j+pLnKoU5tl64jMuhcU6hycJ/t7XBm5/BZBDbq 2nGNvv5YGFkIFE3wWbTK/7gUSGP/Mlqud/n3QvWqEBi1lxBAPo0EwQ4l9dPo+fqpmY 2c6aJvClVl32i+gIzDlAqUTKFWQWimg7sMizFcGs= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 03D35601DA; Mon, 27 Aug 2018 12:49:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1535374170; bh=P34mUxrd2An7JXH3tkcxLwW4XhPDwa23B1WDJRoF+HY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=BjrsufzWWdrME8GyFQfEeA1mbVNqCrs2Q38WbQEMs5SKztCxaDlhq659V3f+oTnVC 5rcpx+mDM9RDbsS7IYfMVRWTbM/h8rEtMNRKFb8BoRfZNSZ1LyQGTBUYPZOw3jpFj2 y+b3/MR6CFWUEitLW1cwxo6V4HNGwMHpi9LUFHeY= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 27 Aug 2018 18:19:29 +0530 From: Vikash Garodia To: Alexandre Courbot Cc: Stanimir Varbanov , Hans Verkuil , Mauro Carvalho Chehab , robh@kernel.org, mark.rutland@arm.com, Andy Gross , Arnd Bergmann , bjorn.andersson@linaro.org, Linux Media Mailing List , LKML , linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-media-owner@vger.kernel.org Subject: Re: [PATCH v6 3/4] venus: firmware: add no TZ boot and shutdown routine In-Reply-To: References: <1535034528-11590-1-git-send-email-vgarodia@codeaurora.org> <1535034528-11590-4-git-send-email-vgarodia@codeaurora.org> <9e9417cf2fccfed4015f6893045e4f7f@codeaurora.org> Message-ID: <002138192bcb3f7e6bf55e090d1b5328@codeaurora.org> X-Sender: vgarodia@codeaurora.org User-Agent: Roundcube Webmail/1.2.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-08-27 08:36, Alexandre Courbot wrote: > On Fri, Aug 24, 2018 at 9:26 PM Vikash Garodia > wrote: >> >> Hi Alex, >> >> On 2018-08-24 13:09, Alexandre Courbot wrote: >> > On Thu, Aug 23, 2018 at 11:29 PM Vikash Garodia >> > wrote: >> >> [snip] >> >> >> +struct video_firmware { >> >> + struct device *dev; >> >> + struct iommu_domain *iommu_domain; >> >> +}; >> >> + >> >> /** >> >> * struct venus_core - holds core parameters valid for all instances >> >> * >> >> @@ -98,6 +103,7 @@ struct venus_caps { >> >> * @dev: convenience struct device pointer >> >> * @dev_dec: convenience struct device pointer for decoder device >> >> * @dev_enc: convenience struct device pointer for encoder device >> >> + * @fw: a struct for venus firmware info >> >> * @no_tz: a flag that suggests presence of trustzone >> >> * @lock: a lock for this strucure >> >> * @instances: a list_head of all instances >> >> @@ -130,6 +136,7 @@ struct venus_core { >> >> struct device *dev; >> >> struct device *dev_dec; >> >> struct device *dev_enc; >> >> + struct video_firmware fw; >> > >> > Since struct video_firmware is only used here I think you can declare >> > it inline, i.e. >> > >> > struct { >> > struct device *dev; >> > struct iommu_domain *iommu_domain; >> > } fw; >> > >> > This structure is actually a good candidate to hold the firmware >> > memory area start address and size. >> >> I can make it inline. >> Memory area and size are common parameters populated >> locally while loading the firmware with or without tz. Firmware struct >> has >> info more specific to firmware device. >> >> [snip] >> >> > >> >> +{ >> >> + struct iommu_domain *iommu_dom; >> >> + struct device *dev; >> >> + int ret; >> >> + >> >> + dev = core->fw.dev; >> >> + if (!dev) >> >> + return -EPROBE_DEFER; >> >> + >> >> + iommu_dom = iommu_domain_alloc(&platform_bus_type); >> >> + if (!iommu_dom) { >> >> + dev_err(dev, "Failed to allocate iommu domain\n"); >> >> + return -ENOMEM; >> >> + } >> >> + >> >> + ret = iommu_attach_device(iommu_dom, dev); >> >> + if (ret) { >> >> + dev_err(dev, "could not attach device\n"); >> >> + goto err_attach; >> >> + } >> > >> > I think like the above belongs more in venus_firmware_init() >> > (introduced in patch 4/4) than here. There is no reason to >> > detach/reattach the iommu if we stop the firmware. >> >> Consider the case when we want to reload the firmware during error >> recovery. >> Boot and shutdown will be needed in such case without the need to >> populate >> the firmware device again. > > Is there a need to reattach the iommu domain in case of an error? re-attach is not needed. We can have alloc/attach in init and detach/free in deinit. map/reset and unmap/reset can continue to remain in boot and shutdown calls. Let me know if this is good, i can repatch the series.