Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp6707757imm; Mon, 27 Aug 2018 22:54:21 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZpOYfAOzc6mrxxSC0IFjTLZ9+agPd4dl93AJdca6E/wttG+hnYTU/1nj6E8rplQsGT7QmQ X-Received: by 2002:a17:902:7e45:: with SMTP id a5-v6mr48059pln.151.1535435661426; Mon, 27 Aug 2018 22:54:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535435661; cv=none; d=google.com; s=arc-20160816; b=uM5aDVbSqQJJlgkkw3paXYvhkXBJ/nMJzz3BTuYfQhXrC+DFawEvkS8YTty618ZM25 Ng5+09tDr5u8xP5MCLJ5tK2ke0agjPaoIHBnr83gjD8wu2Mr3TZUAep1DwQcqiwbtFJv 10DiFj+t1gMGmK/uGHzEd5iosuvFmDFMifH7OQ3D/X+GpOLKs0mkZhyf2MhGmMlIu2ho 9dj9Lrj7izCbcPIVkouMDt8l71eMo43CjbW7FwBKLwZbbXjLq+4aV0qhS7sakGzgDCQG 8c1O+MAv694MnpZRhZg3597W35fehyz4rhMKOnsbAtfJ+mB6qjTJ9hNGJpk66qX76W46 rN3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=G3K1+siUe7b2y/jyNiUK+wBFVCYerA4vW7QO5gHBrsc=; b=U/TIzp25hkIdgsGc9mmFDEXK2qj73O9Jl9B78+RomX/gNH+k/cLBvXLGEkEPFlconB j9rlePrqZn7HCEpijmh8xOxUYU9/epDAZxqBvmpZgLl9rOG7Vva2kcIt0yPNqs3poz74 zVUTKBEK1Zok029npfrslF8n7vXu7DKR1Axo6tZWCKJ/wYsX/A6nUXHEClZqO9/r1g8m E/0+zwAeGmqx+t7b8O7sT8uIZO+Hkr1qdOdLGD2k3bfXJhKdhUSIqGvwyotM81mOxwor vvR4guwDd2wRKu6P4C+b/6L1lvkaR6c7VG/KcoOplZm/aLJvXa51R0Z0IRN4quaQ7+bX Cw9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=g3KohAWB; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y9-v6si138177pgs.521.2018.08.27.22.54.06; Mon, 27 Aug 2018 22:54:21 -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=@chromium.org header.s=google header.b=g3KohAWB; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727177AbeH1JnG (ORCPT + 99 others); Tue, 28 Aug 2018 05:43:06 -0400 Received: from mail-it0-f65.google.com ([209.85.214.65]:50949 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725976AbeH1JnG (ORCPT ); Tue, 28 Aug 2018 05:43:06 -0400 Received: by mail-it0-f65.google.com with SMTP id j81-v6so1008303ite.0 for ; Mon, 27 Aug 2018 22:53:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=G3K1+siUe7b2y/jyNiUK+wBFVCYerA4vW7QO5gHBrsc=; b=g3KohAWB9thaVaZYGs4IU8PrHt4cc7UHeeVBfdpvK3yKXVG89Rwwlk9Kh2FoBjwykc kHP722foQ2EOXSqeyRZjFZdwN0x3qtF5OQ9bc945VUNOShOdP9kW9pMt0BZgs/TxerxL FTHzEvoNKRVXANosPD2pUT8WKKLNgchfDRLRI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=G3K1+siUe7b2y/jyNiUK+wBFVCYerA4vW7QO5gHBrsc=; b=ixb9W4rSf4uyAwsTy0xrhUoD0fScp+LfCvbn3r/M8zcrezqfMgUymwnHKK9E+wI9ms hppCQjOtJgWdXpFhhO02JXa+NsV9ZG0KSS5Epn0JCi/UZbhretYqxxAn8wdCawzheFHQ aOeGnKLg+TxM+H5t6YXGvgeHELCHXJ0huIysUpepf4Zk84LVejqlQ7WL+fZ50B09eh8z 6CfzMB0pT7Z+BEW37ozfu3WGBR9tMeuAImqOlDAkbmXhdhJ1WWnrgiZ8lg+2OkDGFYLj Q5TLsLCs3CoHFkT5rvERNzKy4wgYCM63aCCYhu2x+Kx86tKCXGGV8w6t6Cfwufv0f4XV LPHQ== X-Gm-Message-State: APzg51AIemzxdGDnkZ54pZII4kncaoN3r2YPEXh4pi0b9vju84Y2tfaT j2PEMU9SyUo1qcWRPlM3X10oqXLVITi6lg== X-Received: by 2002:a02:2424:: with SMTP id f36-v6mr20187jaa.35.1535435144232; Mon, 27 Aug 2018 22:45:44 -0700 (PDT) Received: from mail-it0-f49.google.com (mail-it0-f49.google.com. [209.85.214.49]) by smtp.gmail.com with ESMTPSA id j199-v6sm205567itb.43.2018.08.27.22.45.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Aug 2018 22:45:42 -0700 (PDT) Received: by mail-it0-f49.google.com with SMTP id x79-v6so1217198ita.1 for ; Mon, 27 Aug 2018 22:45:42 -0700 (PDT) X-Received: by 2002:a02:579a:: with SMTP id b26-v6mr9585jad.107.1535435141761; Mon, 27 Aug 2018 22:45:41 -0700 (PDT) MIME-Version: 1.0 References: <1535034528-11590-1-git-send-email-vgarodia@codeaurora.org> <1535034528-11590-4-git-send-email-vgarodia@codeaurora.org> <9e9417cf2fccfed4015f6893045e4f7f@codeaurora.org> <002138192bcb3f7e6bf55e090d1b5328@codeaurora.org> In-Reply-To: <002138192bcb3f7e6bf55e090d1b5328@codeaurora.org> From: Alexandre Courbot Date: Tue, 28 Aug 2018 14:45:30 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v6 3/4] venus: firmware: add no TZ boot and shutdown routine To: vgarodia@codeaurora.org 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 27, 2018 at 9:49 PM Vikash Garodia wrote: > > 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. Yeah, the idea is to avoid repeating operations that do not need to be. Thanks!