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 C1B52C001B0 for ; Wed, 19 Jul 2023 06:29:36 +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=1EaiRUnqEwARSAO/yiYknEiC8i9EV/MQNzPDfWKfz7U=; b=HVZGrHtqTeg6NY pykIZwuIzcv3pthhLTzsWKwd0ye7/hy/dxVLwqa828CE9v4ymK5iZ7Jf7ABOusATF6JuS0t/vb7JB 6XsE/poByLVsticDxXIlxZPKXNYgvCYV3ovP2U4LDTLUriz6w09o9aNAb8GgyFawj4HjPMkAYPb09 TprnX0oW3Wn3LET+mLTB9fy9x40EqGu58rqDSqDCRrdolBTlW4j0djb7sdHcDFFP5FbhsXNL90ZO2 6a3/+16qY018hHO7x9bDsWIWOkgl8Ql/Z33JjUh9WISbVA06UPEs4ZrgqumAPRJsPHyX3zJlZC6Lh k9aZflpxFPvMFqRiw2YA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qM0gX-005kLx-1d; Wed, 19 Jul 2023 06:29:17 +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 1qM0gV-005kKu-11 for linux-arm-kernel@bombadil.infradead.org; Wed, 19 Jul 2023 06:29:15 +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=AtdblGg5jBy/9UdjzY2MwuPaOGVdkK2ygs+jc/rHbsI=; b=cSoDXMz4FMKd2VMtc91/9Am523 +rYMFPtb4HJ4LAiZ/FqiWE6ArNMGBwHuP7gT6LpiXA5u6Y4IbiHhMcgn713K6qsWYxaIrhfL6HDW3 LXNmxUKRdQb2x6MthPmd3XzI7btly4VK+MHZSjRuVcA5ZiN2ByWlELbcZMNcXZyrZ8rquMscnJOEz hJulsz0SD34r23j6rZ4ROKY0pIavDTtRSbMpjKNmM+RRUVZL9oGIxAmsgIXZd7bhTtVqVXVz5YlOK XztJfVTz98mLse2cGO8QYI5hBwmqQEtFdrPJ7OV3JavdFlwLX60vZo/eS7s1h2ZxbECYdEH2+nX9J hVzfiSIA==; Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qLpHM-00Bs5o-2O for linux-arm-kernel@lists.infradead.org; Tue, 18 Jul 2023 18:18:35 +0000 Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-51e57874bfdso8565244a12.0 for ; Tue, 18 Jul 2023 11:18:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689704242; x=1692296242; 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=AtdblGg5jBy/9UdjzY2MwuPaOGVdkK2ygs+jc/rHbsI=; b=DQgV2zHYpUaxjuhMxzP6Oqc1LGh7YqOteKkDPGTEZzBXadvXn756Uubzfkgfjfq90X qRxIKRWbdYNZit0s71pVEoEHFgMH0bIaI1QdKFyyOcxypPTE1a+s7MKmv8BsJXjVj+T2 NELmvM6fo6+mTf1BVawsd/BDQQuDEztFmIltRhyhkVGT2+CemLzmAj9HDAsY1bgyUeOa mP+0o274YlrTwGwqMG7ly3T9/jWDe+i+GoYYEYXGaHX89/pbLON5jfM3KoumV5kDj//K 5AJLOi8GaeoUZqmqaQWob2EG9vfCC/URYT4Dq1XbCRTr8WLPLC/WG3m4VKR06U+yzK6P eEmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689704242; x=1692296242; 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=AtdblGg5jBy/9UdjzY2MwuPaOGVdkK2ygs+jc/rHbsI=; b=ZSQUvqdSisCTX7/RAUtYep6Rr2dOK7OD7EHEE/IceKU5V3HLyEQZ2A+IMHN+4uTmkN fLeKTNPJjeE2oYI7gfcZoYRKl0iK2rx/J9bZz+CafJZabXDy33xCBEWrbif71iIwcsV/ aaen0YXfVOjt0pHdSk7htb/4h0bcHCIDYjiLN2LvxMaTjvKZi5shFsScsRiu/fGa+2TT DFNXSlLCb/iujnLeHmyn0nyMpvVzjpRlPwWwtJMxJ6DWup6Io8tJyTrevPVxXZztJAai n5Nen8+WyLkwi6RL4Zb1Jh1bMTA4keKPLfSxaG5QU28idA0Jz3Xy6+YZGBakHNhSXtJv jqKQ== X-Gm-Message-State: ABy/qLbLyxNbOqsoG82gDW13H1bFziyUJN+ghAdilH03ietrKDJPAoBd PK5lFfuOTGXusiH39+CTpC1jdaijUzXfhPb10CtWgw== X-Google-Smtp-Source: APBJJlGiWY1EKNf9FkiAT/uOh62LJK1rZHb+JAcvP2bwDKhX7gSsrFR2Dvy9OXIbKA28S2qFehsUaQ== X-Received: by 2002:aa7:cd47:0:b0:51f:f079:8761 with SMTP id v7-20020aa7cd47000000b0051ff0798761mr563469edw.15.1689704242657; Tue, 18 Jul 2023 11:17:22 -0700 (PDT) Received: from [192.168.1.20] ([178.197.223.104]) by smtp.gmail.com with ESMTPSA id v15-20020aa7d80f000000b0051e2670d599sm1571865edq.4.2023.07.18.11.17.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 18 Jul 2023 11:17:22 -0700 (PDT) Message-ID: Date: Tue, 18 Jul 2023 20:17:20 +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> From: Krzysztof Kozlowski In-Reply-To: <20230718160833.36397-3-quic_nkela@quicinc.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230718_191833_123940_F676F9AB X-CRM114-Status: GOOD ( 21.77 ) 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 18:08, Nikunj Kela wrote: > Add a new transport channel to the SCMI firmware interface driver for > SCMI message exchange on Qualcomm virtual platforms. > > The hypervisor associates an object-id also known as capability-id > with each hvc doorbell object. The capability-id is used to identify the > doorbell from the VM's capability namespace, similar to a file-descriptor. > ... > + > +static bool qcom_hvc_chan_available(struct device_node *of_node, int idx) > +{ > + struct device_node *np = of_parse_phandle(of_node, "shmem", 0); > + > + if (!np) > + return false; > + > + of_node_put(np); > + return true; > +} > + > +static inline void qcom_hvc_channel_lock_init(struct scmi_qcom_hvc *scmi_info) > +{ > + mutex_init(&scmi_info->shmem_lock); > +} > + > +static inline void > +qcom_hvc_channel_lock_acquire(struct scmi_qcom_hvc *scmi_info, > + struct scmi_xfer *xfer __maybe_unused) Why do you pass unused arguments? > +{ > + mutex_lock(&scmi_info->shmem_lock); Why do you need these wrappers? Why not using mutexes directly? If they are needed, then add lock __acquires annotation. > +} > + > +static inline void qcom_hvc_channel_lock_release(struct scmi_qcom_hvc > + *scmi_info) Same comments. > +{ > + mutex_unlock(&scmi_info->shmem_lock); > +} > + > +static int qcom_hvc_chan_setup(struct scmi_chan_info *cinfo, > + struct device *dev, bool tx) > +{ > + struct device *cdev = cinfo->dev; > + struct scmi_qcom_hvc *scmi_info; > + resource_size_t size; > + struct resource res; > + struct device_node *np; > + unsigned long cap_id; > + u32 func_id; > + int ret, irq; > + > + if (!tx) > + return -ENODEV; > + > + 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. > + 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. Best regards, Krzysztof _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel