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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 28F3EC001DC for ; Wed, 19 Jul 2023 08:08:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=HpKXwfg7YNA0VQc9cp3IlCrg2P9A8QyCc4mszS+Io6o=; b=jCUwj8bLmwLcjl Mb2Sx5oaGa9A0wxX3yFCQoCcTuuYMbhj0pJMH1fl6vANEY9lbFexhePW8txw97uRFgcg7wxtfOMgv p0yiV5CINdiwJAJWrvzzIBnMA04eyVYUpmC8DmZlIuufH3J3Oih4W+ILMQ+lkmXk/88xikVue3/h/ 6D9qQwS2JALPjp/rPa82vj0YlVOvG4LL6RstMW3ujMywbnP8KWZTCzKAE88SFdpdpU7sjeuKYHNUA PUjfUeaAFTcXBd+4zNSvPjuygslwTQdQPLdo77xezFCDDtJf+BwZQ3dyDz0GsmkkcxkLzDny2sXWr W1oqSNHMbf3hI+naxI+w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qM2ER-006EIu-17; Wed, 19 Jul 2023 08:08:23 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qM2EM-006EGu-1R for linux-arm-kernel@bombadil.infradead.org; Wed, 19 Jul 2023 08:08:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date:Message-ID: Sender:Reply-To:Content-ID:Content-Description; bh=YWDxOdiEo182qQTrdfRT1NqU4AQWgKjDTPUDJMk0vho=; b=mMzJY6AiJ1k9hDbXF1QrJxscGt ScQg6RrIruQTyh7p1xIOdy4O0MJF/P/4THxzRF6GvSxvzgkWXs7v+fc8CpcZ5I8XXxw8VD4Y81u9e Sz01EHd2LamDvFYMzqNK050LGjrOlaYcJ+2IADQWHvLPDAriG3L6M6BWnF9WfNlyI4FwzldwlzRwq NhpBhfLzA6rqx39qa0ODiZGATBrKVOtNuv0Zj7E7jUu/KkL7sotmDFYs5X+H8Zz4KmfXIcsaf1rk3 13ZH7luzkdWQ88Wswr7SA4TEG0UUOKLh5ldAZPAtH3aqSmQk1pdvW12qGWWTgvQzwZHR6wxMNa/1o RUfC6GfQ==; Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qLpfv-00Bsu2-0O for linux-arm-kernel@lists.infradead.org; Tue, 18 Jul 2023 18:43:57 +0000 Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-991c786369cso781636166b.1 for ; Tue, 18 Jul 2023 11:43:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689705764; x=1692297764; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=YWDxOdiEo182qQTrdfRT1NqU4AQWgKjDTPUDJMk0vho=; b=oM+zaRthwE4f1r8MkTbNFtjNtHOKecZtu+MAMEo0rp8+TxOC3AczvBqG74Wq+XGe9z ayeOGgPv2iSjCSC8JS5AVBnqntVcodyk/VvMSJcBHxiwtRRRKP8HOHgSTxwGw9NsxM+m 5/ePv26ZjawWFhwQDjYTAvkA+/BdJCX7wz94mKhpWSUunUZJRDl68l6SlNJhOooMXDhK XkRWgjaFHT5joJWlLLpy1vAFUwgB5jnxpZgcLbNQSlwYyLWOfTzekB0N8u/VAYKEXkBM O2UgCYLq1kiV3oAlEcxVRALJhxZtPQPtsuXsq1zYPeIwAEO4NNkQvPK8g8kNcWcsinm3 3B2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689705764; x=1692297764; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YWDxOdiEo182qQTrdfRT1NqU4AQWgKjDTPUDJMk0vho=; b=ilauWgWHYdh7RMC1iqbLvE6WA7cRcGu4EC329vgtlf0NvtWdOYksA3DgpcxXfQ0+uc IRdpLyaInq0Hs2le1p/qOXIrrV2THegJdo2vdzsFfhTmT3LCihtQNF1HFAok36Z0bTzf 5JZHMZNmS0TE1LkgSVjrucE75nOrYZ5zfMm+Xav3j6gWiQBG7aSajc7BZPgHjSqgTN9h 0saivGd3+DZMPuUte1E3T3snBZpbgvkqhGOywQ8uf+uazQQ4apO/Bqavcp122cVDh0Nv wK8Drx1434xdcVUq1qCpQZ2Aorx490UdufQ1MAsCRrd2FdNQw/t478QV35HXcsmKEmJE Er9g== X-Gm-Message-State: ABy/qLYV0mBJWkZGHxgEZXrP43H0YPWk50/BDtLpZkgKv6fiC5DJKJ7O 9icQY/nHc8Yy/Mox6raFKuFw0p1ROakyoiaxLvXhUA== X-Google-Smtp-Source: APBJJlHwuALuQ2dnZX9w3l3xk/u5CDjDpB+cpbIhy0GLp1XygrSwSlaoo21eYMhJ9yJm12JZwn9kMw== X-Received: by 2002:a17:907:78cf:b0:994:2fa9:7444 with SMTP id kv15-20020a17090778cf00b009942fa97444mr641821ejc.42.1689705764057; Tue, 18 Jul 2023 11:42:44 -0700 (PDT) Received: from [192.168.1.20] ([178.197.223.104]) by smtp.gmail.com with ESMTPSA id rp25-20020a170906d97900b009786ae9ed50sm1309961ejb.194.2023.07.18.11.42.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 18 Jul 2023 11:42:43 -0700 (PDT) Message-ID: Date: Tue, 18 Jul 2023 20:42:41 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH 2/2] firmware: arm_scmi: Add qcom hvc/shmem transport Content-Language: en-US To: Nikunj Kela , sudeep.holla@arm.com Cc: cristian.marussi@arm.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org References: <20230718160833.36397-1-quic_nkela@quicinc.com> <20230718160833.36397-3-quic_nkela@quicinc.com> <3ae2d618-490a-06da-b4b6-b5a24b0a9747@quicinc.com> From: Krzysztof Kozlowski In-Reply-To: <3ae2d618-490a-06da-b4b6-b5a24b0a9747@quicinc.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230718_194355_314342_67B7CC92 X-CRM114-Status: GOOD ( 15.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 18/07/2023 20:25, Nikunj Kela wrote: >>> + >>> + scmi_info = devm_kzalloc(dev, sizeof(*scmi_info), GFP_KERNEL); >>> + if (!scmi_info) >>> + return -ENOMEM; >>> + >>> + np = of_parse_phandle(cdev->of_node, "shmem", 0); >>> + if (!of_device_is_compatible(np, "arm,scmi-shmem")) >> You leak here reference. > Wouldn't the devm_* API take care of that implicitly? It is same in > smc.c as well. Thanks for bringing my attention to this. I sent a fix for smc.c. Fix your patch as well, please. >>> + return -ENXIO; >>> + >>> + ret = of_address_to_resource(np, 0, &res); >>> + of_node_put(np); >>> + if (ret) { >>> + dev_err(cdev, "failed to get SCMI Tx shared memory\n"); >>> + return ret; >>> + } >>> + >>> + size = resource_size(&res); >>> + >>> + /* let's map 2 additional ulong since >>> + * func-id & capability-id are kept after shmem. >>> + * +-------+ >>> + * | | >>> + * | shmem | >>> + * | | >>> + * | | >>> + * +-------+ <-- size >>> + * | funcId| >>> + * +-------+ <-- size + sizeof(ulong) >>> + * | capId | >>> + * +-------+ <-- size + 2*sizeof(ulong) >>> + */ >>> + >>> + scmi_info->shmem = devm_ioremap(dev, res.start, >>> + size + 2 * sizeof(unsigned long)); >>> + if (!scmi_info->shmem) { >>> + dev_err(dev, "failed to ioremap SCMI Tx shared memory\n"); >>> + return -EADDRNOTAVAIL; >>> + } >>> + >>> + func_id = readl((void *)(scmi_info->shmem) + size); >>> + >>> +#ifdef CONFIG_ARM64 >>> + cap_id = readq((void *)(scmi_info->shmem) + size + >>> + sizeof(unsigned long)); >>> +#else >>> + cap_id = readl((void *)(scmi_info->shmem) + size + >>> + sizeof(unsigned long)); >>> +#endif >>> + >>> + /* >>> + * If there is an interrupt named "a2p", then the service and >>> + * completion of a message is signaled by an interrupt rather than by >>> + * the return of the hvc call. >>> + */ >>> + irq = of_irq_get_byname(cdev->of_node, "a2p"); >>> + if (irq > 0) { >>> + ret = devm_request_irq(dev, irq, qcom_hvc_msg_done_isr, >>> + IRQF_NO_SUSPEND, >>> + dev_name(dev), scmi_info); >>> + if (ret) { >>> + dev_err(dev, "failed to setup SCMI completion irq\n"); >> return dev_err_probe, unless this is not called in probe... but then >> using devm-interface raises questions. > This is copied as is from existing smc.c I understand and I hope you understand the code you copied. If there is a bug in existing code, please do not copy it to new code (like leaking OF node reference). Best regards, Krzysztof _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel