Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5141745ybl; Wed, 22 Jan 2020 11:06:24 -0800 (PST) X-Google-Smtp-Source: APXvYqwsIWOyW9ChylIW9zIDr2BgbMNaE19HLi8W+Z6uPrPpjaIWE6AWtj61L66ww89wneB90vWX X-Received: by 2002:a9d:7410:: with SMTP id n16mr8788238otk.23.1579719983573; Wed, 22 Jan 2020 11:06:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579719983; cv=none; d=google.com; s=arc-20160816; b=ZWmhzbaPk28Al5kgWs3RdH7DuEK6swLy4qGrFDxmp/O4B114umsM7zxaN/n3k/kBvl pPjfhx30Ow25hub/Np8b1J0UAsKFLA8bn0wqLO/n6SBLOda50UDIdwpeqRwcDuLH/HDM TSnOysrpnqPceO5rTqUC7EE42/8YQtJ+giJofehSnKqwXpWjLtYgPPZTKrvw/3GZIyev BljGY2kUCtPENbk8ZicjgWvF2Xy0tuu9vHDSlPEoIiCLcG83eoE2J+eWcSrEaq6H1/aU ZSZam+Pg5IzG/+SG8HAcnjv+fAnuSnFqO9hHKrKBfJsTljHey5jRtgMRtBq+3DaHDrys jWrw== 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; bh=Ng4dIuUg5yRz0hwu5xj9+THWjTPrMNRdcfA9pUbwfPM=; b=d7M85/JjzmeS3tVZLn+u7qiI0gR7t6S8C4crj426lBswQteeEWKFdAGTK/qzPXZ2vN z2GOxUmCqiQa8TR/4SgFbzehP+Ih/jw7nvM7g34VXrmuF1/IZ8jBmtYmrSbM+nqXiCxx OVw1oQJUXgMSiJjtY4AyP8sAxUzSBNXgdk3tkVkEg8SIo06Yp61wZ65bgOuZScfYqZCP 6Ibj7emIbC+YZIgocksxKkKEBI+9VSWyWGUGHvv3t2IJdst0WBDsVI/AM0Ao02tvSoKP UACk61L2tJaVjoymg8Hf9SsQPcCwg2KOGJONsRL8w0YrS7GCXmbhQF/yYoLgtygT+5LU JNng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gud8B4T6; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n7si24193825otk.277.2020.01.22.11.06.11; Wed, 22 Jan 2020 11:06:23 -0800 (PST) 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=@linaro.org header.s=google header.b=gud8B4T6; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729016AbgAVTEt (ORCPT + 99 others); Wed, 22 Jan 2020 14:04:49 -0500 Received: from mail-io1-f65.google.com ([209.85.166.65]:43738 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728984AbgAVTEt (ORCPT ); Wed, 22 Jan 2020 14:04:49 -0500 Received: by mail-io1-f65.google.com with SMTP id n21so333891ioo.10 for ; Wed, 22 Jan 2020 11:04:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Ng4dIuUg5yRz0hwu5xj9+THWjTPrMNRdcfA9pUbwfPM=; b=gud8B4T6J/lhDZTcVVFxBnmPb1Hxjv6kX7chQ4j7pKsmrsqlKqYL1hI9pQVaRmnorG jTlx9RSgNtL1F45UcWFPDiSa7cUY7SoEvYpcjK6QlDD3B3A+97Brf3ctF1G/qYdTuBo3 wyWPNKrbmlAS8IDiw7CyhEgmQTpvNilQYpUJmRw0UD6A0aIC4ONeYEVUosVfOIzY/DzU RfdvKnP3MzYYm6surnK/AzS1okdou1vAkAQyZp9Dcei52jgIiPdiD4mzP+HAR7jR5b0h IXXrTzrSbgy5FV8O1lUFLkjO4g/CPZxAFKqQPdOPcu8Toi/uIFldL1KOch1EfBUYGJ+M LayA== 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=Ng4dIuUg5yRz0hwu5xj9+THWjTPrMNRdcfA9pUbwfPM=; b=iJxOs4niUEeWmjbICcwv/NAC+JvS4UbhSqMG6UljQkLFfVWOOSz/kkyjOrtI18uNhY TWTlB7AE1pd141T/SWwzu9+syEDuhyaDQEc6Dbt5Qk1ciF9UE2JhJgyWSUqVwzPKpELR PFbPQRcpt+zZQ3FE2GeSButkfAVD+2TW2CfU1+876a8HT3/W51s57BtSsMSbeNGSRCox yKV4RDUAUGZF1MBqEW0PBfBPDtKE2/By1QiZAojF5wvzizMYBxV7C/0hAdL44b8ENlGm /ftSttIgGsxIh9CpXjm2atLDwrJL6J+vDum5P6J1jh29KdXhsiy9Jc0DEXZY8UiNEwuY MdVA== X-Gm-Message-State: APjAAAXs0gu2WY33jBthpvSzgePEpMzGliGuzPu8jQRXhHcWqbA56yoX 9FDmKhnzvWxg3kzQu1VTeXzB/27tWnGgvcR6vzGmAQ== X-Received: by 2002:a02:864b:: with SMTP id e69mr8235435jai.83.1579719888182; Wed, 22 Jan 2020 11:04:48 -0800 (PST) MIME-Version: 1.0 References: <20191227053215.423811-1-bjorn.andersson@linaro.org> <20191227053215.423811-3-bjorn.andersson@linaro.org> <20200110211846.GA11555@xps15> <20200122020234.GT1511@yoga> In-Reply-To: <20200122020234.GT1511@yoga> From: Mathieu Poirier Date: Wed, 22 Jan 2020 12:04:37 -0700 Message-ID: Subject: Re: [PATCH v2 2/8] remoteproc: qcom: Introduce driver to store pil info in IMEM To: Bjorn Andersson Cc: Rob Herring , Mark Rutland , Ohad Ben-Cohen , linux-arm-msm , devicetree@vger.kernel.org, Linux Kernel Mailing List , linux-remoteproc , Sibi Sankar , Rishabh Bhatnagar 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 Tue, 21 Jan 2020 at 19:02, Bjorn Andersson wrote: > > On Fri 10 Jan 13:18 PST 2020, Mathieu Poirier wrote: > > On Thu, Dec 26, 2019 at 09:32:09PM -0800, Bjorn Andersson wrote: > [..] > > > diff --git a/drivers/remoteproc/qcom_pil_info.c b/drivers/remoteproc/qcom_pil_info.c > > > new file mode 100644 > > > index 000000000000..b0897ae9eae5 > > > --- /dev/null > > > +++ b/drivers/remoteproc/qcom_pil_info.c > > > @@ -0,0 +1,150 @@ > > > +// SPDX-License-Identifier: GPL-2.0-only > > > +/* > > > + * Copyright (c) 2019 Linaro Ltd. > > > + */ > > > +#include > > > +#include > > > +#include > > > +#include > > > +#include > > > +#include > > > +#include > > > +#include > > > > These should be in alphabetical order if there is no depencencies > > between them, something checkpatch complains about. > > > > Of course. > > > > + > > > +struct pil_reloc_entry { > > > + char name[8]; > > > > Please add a #define for the name length and reuse it in qcom_pil_info_store() > > > > Ok > > [..] > > > +void qcom_pil_info_store(const char *image, phys_addr_t base, size_t size) > > > +{ > > > + struct pil_reloc_entry *entry; > > > + int idx = -1; > > > + int i; > > > + > > > + mutex_lock(&reloc_mutex); > > > + if (!_reloc) > > > > Since it is available, I would use function qcom_pil_info_available(). Also > > checkpatch complains about indentation problems related to the 'if' condition > > but I can't see what makes it angry. > > > > Sure thing, and I'll double check the indentation. > > > > + goto unlock; > > > + > > > + for (i = 0; i < PIL_INFO_ENTRIES; i++) { > > > + if (!_reloc->entries[i].name[0]) { > > > + if (idx == -1) > > > + idx = i; > > > + continue; > > > + } > > > + > > > + if (!strncmp(_reloc->entries[i].name, image, 8)) { > > > + idx = i; > > > + goto found; > > > + } > > > + } > > > + > > > + if (idx == -1) { > > > + dev_warn(_reloc->dev, "insufficient PIL info slots\n"); > > > + goto unlock; > > > > Given how this function is used in the next patch I think an error should be > > reported to the caller. > > > > Just to clarify, certain global errors will cause the entire device to > be reset and allow memory contents to be extracted for analysis in post > mortem tools. This patch ensures that this information contains > (structured) information about where each remote processor is loaded. > Afaict the purpose of propagating errors from this function would be for > the caller to abort the launching of a remote processor. > > I think it's better to take the risk of having insufficient data for the > post mortem tools than to fail booting a remote processor for a reason > that won't affect normal operation. I understand the reasoning. In that case it is probably best to let the caller decide what to do with the returned error than deal with it locally, especially since this is an exported function. When using qcom_pil_info_store(), I would write a comment that justifies the reason for ignoring the return value (what you have above is quite good). Otherwise it is just a matter of time before automated tools pickup on the anomaly and send patches to fix it. Thanks, Mathieu > > > > + } > > > + > > > +found: > > > + entry = &_reloc->entries[idx]; > > > + stracpy(entry->name, image); > > > > Function stracpy() isn't around in mainline. > > > > Good catch, I'll spin this with a strscpy() to avoid build errors until > stracpy lands. > > > > + entry->base = base; > > > + entry->size = size; > > > + > > > + regmap_bulk_write(_reloc->map, _reloc->offset + idx * sizeof(*entry), > > > + entry, sizeof(*entry) / _reloc->val_bytes); > > > > Same here - the error code should be handled and reported to the caller. > > > > Will undo the "allocation" of _reloc->entries[idx] on failure, let me > know what you think about my reasoning above regarding propagating this > error (or in particular acting upon the propagated value). > > > > + > > > +unlock: > > > + mutex_unlock(&reloc_mutex); > > > +} > > > +EXPORT_SYMBOL_GPL(qcom_pil_info_store); > [..] > > > +static int pil_reloc_probe(struct platform_device *pdev) > > > +{ > > > + struct pil_reloc *reloc; > > > + > > > + reloc = devm_kzalloc(&pdev->dev, sizeof(*reloc), GFP_KERNEL); > > > + if (!reloc) > > > + return -ENOMEM; > > > + > > > + reloc->dev = &pdev->dev; > > > + reloc->map = syscon_node_to_regmap(pdev->dev.parent->of_node); > > > + if (IS_ERR(reloc->map)) > > > + return PTR_ERR(reloc->map); > > > + > > > + if (of_property_read_u32(pdev->dev.of_node, "offset", &reloc->offset)) > > > + return -EINVAL; > > > + > > > + reloc->val_bytes = regmap_get_val_bytes(reloc->map); > > > + if (reloc->val_bytes < 0) > > > + return -EINVAL; > > > + > > > + regmap_bulk_write(reloc->map, reloc->offset, reloc->entries, > > > + sizeof(reloc->entries) / reloc->val_bytes); > > > > Error code handling. > > > > Yes, that makes sense. > > Thanks for the review Mathieu! > > Regards, > Bjorn > > > Thanks, > > Mathieu > > > > > + > > > + mutex_lock(&reloc_mutex); > > > + _reloc = reloc; > > > + mutex_unlock(&reloc_mutex); > > > + > > > + return 0; > > > +} > > > + > > > +static int pil_reloc_remove(struct platform_device *pdev) > > > +{ > > > + mutex_lock(&reloc_mutex); > > > + _reloc = NULL; > > > + mutex_unlock(&reloc_mutex); > > > + > > > + return 0; > > > +} > > > + > > > +static const struct of_device_id pil_reloc_of_match[] = { > > > + { .compatible = "qcom,pil-reloc-info" }, > > > + {} > > > +}; > > > +MODULE_DEVICE_TABLE(of, pil_reloc_of_match); > > > + > > > +static struct platform_driver pil_reloc_driver = { > > > + .probe = pil_reloc_probe, > > > + .remove = pil_reloc_remove, > > > + .driver = { > > > + .name = "qcom-pil-reloc-info", > > > + .of_match_table = pil_reloc_of_match, > > > + }, > > > +}; > > > +module_platform_driver(pil_reloc_driver); > > > + > > > +MODULE_DESCRIPTION("Qualcomm PIL relocation info"); > > > +MODULE_LICENSE("GPL v2"); > > > diff --git a/drivers/remoteproc/qcom_pil_info.h b/drivers/remoteproc/qcom_pil_info.h > > > new file mode 100644 > > > index 000000000000..0372602fae1d > > > --- /dev/null > > > +++ b/drivers/remoteproc/qcom_pil_info.h > > > @@ -0,0 +1,8 @@ > > > +/* SPDX-License-Identifier: GPL-2.0 */ > > > +#ifndef __QCOM_PIL_INFO_H__ > > > +#define __QCOM_PIL_INFO_H__ > > > + > > > +void qcom_pil_info_store(const char *image, phys_addr_t base, size_t size); > > > +bool qcom_pil_info_available(void); > > > + > > > +#endif > > > -- > > > 2.24.0 > > >