Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp7258974rwp; Tue, 18 Jul 2023 12:26:32 -0700 (PDT) X-Google-Smtp-Source: APBJJlFMl+M7gYj+z/EdEG5hvMqF9kArFPIDUMmu8sNYRJWtenFzGtz8XYpBihxTYXnz5NUVL09T X-Received: by 2002:a5d:594e:0:b0:314:c86:bee5 with SMTP id e14-20020a5d594e000000b003140c86bee5mr441390wri.2.1689708392108; Tue, 18 Jul 2023 12:26:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689708392; cv=none; d=google.com; s=arc-20160816; b=VTeNIRzWft+1TCizFjeriqyDA6mTJKa6FckbvJovNHmSNhF0ciSH5d925AuwC7aXUv KkV1EylIudyPRbr+T7PZOegWm2BixAUmpdFAnIooJ106HT3Vgmpy9CxaKheSaa5Lu2ck d8DA8h1bgFqa844MRkq4/4jAVtPmKrJt2icxmqLoT4gxRER8xxlIHGkn3Eq72VYPFfz/ eW+RUqkjLzIbhhWFSyu+bnui4xDZzvFRgSpY2acNTH7AN85dzfEy3hp91zA1KZAl333U 7ZKbXA6rppKGcJYp7GwIDkJ1Ax99HfntrMlPsHrvFmTQbhoXGzru+DTPh8lpX01N/lNv sI0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=ZQa9k2+6j6lALLr/TaoBsR6l8x/z7nc4yjW53EyLC0o=; fh=knmgIyE7U6L/qVagE6EkzgzU77zaZQDXisUbUBTgwfY=; b=ZiWc4wtJ3dh2Rxev16/bxpU/x3YzXoH9hwKVf2YV7v1v8Nv0C4TsviYNUE/2bWzlVK n0b8wB2ndQNs2I5AWH73B8xKOSZid2KX080HAEIRFSFSiIVBj5sBijKBSbSjEQ0u0X6r UYgCtMAaTaDjYbYErO+hCwJZrP6zFSulwUmOIaARIcznzzWnEKolYRLnPT03X0wdRmrz rvlV2EhMuu500BJGZm1KVUhLRfJ7ZAWNy3qpaUY9g0ZVTMFBKD2CexDyO5ZHN8Qplmzb u4f22vwNfk8J7R4Dm9YzfwBi/m3RjsEzpP1s4QzVE7URWTQuPSpB4H0VQ5/Gh81ppaVy TvcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=WvTwiJCM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id be25-20020a0564021a3900b005217be808fesi1639654edb.541.2023.07.18.12.26.07; Tue, 18 Jul 2023 12:26:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=WvTwiJCM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229780AbjGRTKi (ORCPT + 99 others); Tue, 18 Jul 2023 15:10:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229504AbjGRTKh (ORCPT ); Tue, 18 Jul 2023 15:10:37 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEACDF4; Tue, 18 Jul 2023 12:10:35 -0700 (PDT) Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36IBQa1j024657; Tue, 18 Jul 2023 19:10:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=qcppdkim1; bh=ZQa9k2+6j6lALLr/TaoBsR6l8x/z7nc4yjW53EyLC0o=; b=WvTwiJCMWNQgVyndOal5wLD1bTYTflR3SQe51IxHtskCPq9EbZ9wev8xPZFw7kvZ3V1l vqP1ujMmjAGoGF5ZH5+WYeuCqG235nzXdFIx37aLPHPlxA0dvRm5O/UO2nzCDlOXatQs YfUZvyIe/qWHwYA6ldwM38Kcii3upVJWvVmiiiKaj4pMubPQluyAsgKuvAZywen/+c00 OY+BYVFQlmCAbSsUpeC+u+LnDVRT7VY2GY7pdPRf/MdHi8olD8rrdtOm1ZEoN+r8lZXm gs6MAxPFY48GxoNbtmKLXXyrOMq5Koy/5Wkpja/DeFnC41jNpageIjbbC7lHK4kAQypG rw== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rwn909rp7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 18 Jul 2023 19:10:18 +0000 Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 36IJAHqg001448 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 18 Jul 2023 19:10:17 GMT Received: from [10.110.49.60] (10.80.80.8) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Tue, 18 Jul 2023 12:10:16 -0700 Message-ID: Date: Tue, 18 Jul 2023 12:10:16 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH 2/2] firmware: arm_scmi: Add qcom hvc/shmem transport Content-Language: en-US To: Bjorn Andersson CC: , , , , , , , , , , References: <20230718160833.36397-1-quic_nkela@quicinc.com> <20230718160833.36397-3-quic_nkela@quicinc.com> <5c76250b-4415-950e-6aab-7ccbdc6ca83a@quicinc.com> <6uelwa7fpzbw757rbb2j3u4ogagypdzyqj5mykyhlkkkvrnfin@ttonjpfn7nxc> From: Nikunj Kela In-Reply-To: <6uelwa7fpzbw757rbb2j3u4ogagypdzyqj5mykyhlkkkvrnfin@ttonjpfn7nxc> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: 2rCKIEvQwGE0gIHOH4CQWeHyot3clfz7 X-Proofpoint-ORIG-GUID: 2rCKIEvQwGE0gIHOH4CQWeHyot3clfz7 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-18_14,2023-07-18_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 bulkscore=0 phishscore=0 spamscore=0 adultscore=0 mlxlogscore=999 lowpriorityscore=0 mlxscore=0 suspectscore=0 impostorscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307180174 X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/18/2023 12:07 PM, Bjorn Andersson wrote: > On Tue, Jul 18, 2023 at 11:53:24AM -0700, Nikunj Kela wrote: >> On 7/18/2023 11:29 AM, Bjorn Andersson wrote: >>> On Tue, Jul 18, 2023 at 09:08:33AM -0700, Nikunj Kela wrote: >>>> diff --git a/drivers/firmware/arm_scmi/qcom_hvc.c b/drivers/firmware/arm_scmi/qcom_hvc.c > [..] >>>> +static int qcom_hvc_chan_setup(struct scmi_chan_info *cinfo, >>>> + struct device *dev, bool tx) >>>> +{ > [..] >>>> + /* 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) >>> Relying on an undocumented convention that following the region >>> specified in DeviceTree are two architecture specifically sized integers >>> isn't good practice. >>> >>> This should be covered by the DeviceTree binding, in one way or another. >> ok. Usually, DTBs don't allow non-hw properties in the dtb. I can try adding >> a property as cap-id-width if its allowed. >> > If you remove the additional part, per the next comment, DeviceTree > would be oblivious to these properties. I'll don't know if the > DeviceTree people have any concerns/suggestions about this. ok. > >>>> + */ >>>> + >>>> + scmi_info->shmem = devm_ioremap(dev, res.start, >>>> + size + 2 * sizeof(unsigned long)); >>> I don't find any code that uses the size of the defined shm, so I don't >>> think you need to do this dance. >> Right! I can remove the addition part. >>>> + 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 >>> Please don't make the in-memory representation depend on architecture >>> specific data types. Quite likely you didn't compile test one of these >>> variants? >>> >>> Just define the in-memory representation as u32 + u64. >> I tested this for ARM64, I didn't test it for 32bit since Hypervisor doesn't >> support it currently. In future, it may add 32 bit support too. > I'd not be surprised if the capability id is 64 bit on a 32-bit machine > as well, it's not really a property of the architecture. on 32bit machine, you will have to use SMC32 convention. lt will mean that the parameters can only be 32 bit long. If you keep cap-id 64 bit in 32bit machines, then it has to be passed in two parameters. Are you suggesting, I make this driver dependent on ARM64 and only care about 64 bit for now? > > But regardless, always using 64 bits in your memory representation will > at worst waste a few bytes. But the result is a better defined > interface, and you can avoid the conditional code. > > Regards, > Bjorn