Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp853775ybz; Fri, 1 May 2020 09:43:05 -0700 (PDT) X-Google-Smtp-Source: APiQypJdVd1ODkFgl/E5wDvBU0e7P0faS6PcFf9CJAf7PYlB7CCW179QWJn9PUohGq14/6L1Wa9q X-Received: by 2002:a17:906:a2d3:: with SMTP id by19mr4112478ejb.370.1588351385411; Fri, 01 May 2020 09:43:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588351385; cv=none; d=google.com; s=arc-20160816; b=gz52aP6+7ulwPu0UTydTdSNVRAYlVMP9Es7YzAvggOZzfPYIymJwE3urTYMAOJBg3u 2kcowogGWS4/zJyGrVjuGeY1f9dHmz2QyYw6krMCAQIbbg2yjan7pyYa+hI39JSRFCCb 0g0LeZNsapHGsmkVafmzIjxJc7PvYVkauHg/p/Bo7THI8dJGnVKyhAB7VSkkY9OuE2h1 u+YX4xsgYl4qzkGmVkhCkQ7mkO6m/l90ZxdmyhbsjbxXp+atTAlDwRMUf9EHcxRiKH+2 qo4rqGSMG+gceF1ZDfPOW5tZPX6wGwTSOXX5gDIZ6TeLbzhibcFWeLXm1EBX4VePw0Qn YWfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=QsGkSUYXA8Ywne+rTt5Fo8BfcRab+olfZZ9PqmHF16g=; b=fQmKeJW4O0blz/i3n4e7amQct3M+N0aVtU2qArKvhFoXjSqsIIi/tcawErsF77gdBN YUObEee5vVkgfXXFxGC3fKQhPOY0KkE4Fp2p33AHm4JTaqrL9SjQR97gIHpYFlvZClV7 eXCW5Pr6WjObxushFIHUQpYwSFK0ib+2o37+u7B+9XsJzV16NeN4axsltJetgrJ3muzg Vzc/VQnaalNJbH7OMx0DD+yBQgy28qiwGXaEs6m6juevBvHYD+P+qTHphTbl9kUywIHH Qq1NStbIZpoNHiaBUZeXxlndjc9BSCUIEyky5eVp6wLRPM7tFUx8XxsxBM0S4U1QK1yS oHuA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn8si1783880edb.142.2020.05.01.09.42.41; Fri, 01 May 2020 09:43:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730016AbgEAQky (ORCPT + 99 others); Fri, 1 May 2020 12:40:54 -0400 Received: from lhrrgout.huawei.com ([185.176.76.210]:2146 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728443AbgEAQkx (ORCPT ); Fri, 1 May 2020 12:40:53 -0400 Received: from lhreml724-chm.china.huawei.com (unknown [172.18.7.108]) by Forcepoint Email with ESMTP id C1CF8C4B4B34BF9888AE; Fri, 1 May 2020 17:40:51 +0100 (IST) Received: from [127.0.0.1] (10.47.3.165) by lhreml724-chm.china.huawei.com (10.201.108.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1913.5; Fri, 1 May 2020 17:40:50 +0100 Subject: Re: [PATCH 5/5] arm/arm64: smccc: Add ARCH_SOC_ID support To: Sudeep Holla CC: "linux-arm-kernel@lists.infradead.org" , Mark Rutland , Lorenzo Pieralisi , Catalin Marinas , "linux-kernel@vger.kernel.org" , Steven Price , "harb@amperecomputing.com" , Will Deacon References: <20200430114814.14116-1-sudeep.holla@arm.com> <20200430114814.14116-6-sudeep.holla@arm.com> <426ff8ab-9c13-4301-a91e-989c19c4ff58@huawei.com> <20200501160521.GB24840@bogus> From: John Garry Message-ID: Date: Fri, 1 May 2020 17:40:08 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.1.2 MIME-Version: 1.0 In-Reply-To: <20200501160521.GB24840@bogus> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.47.3.165] X-ClientProxiedBy: lhreml727-chm.china.huawei.com (10.201.108.78) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/05/2020 17:05, Sudeep Holla wrote: > On Fri, May 01, 2020 at 04:25:27PM +0100, John Garry wrote: >> On 30/04/2020 12:48, Sudeep Holla wrote: >>> +static int __init smccc_soc_init(void) >>> +{ >>> + struct device *dev; >>> + int ret, soc_id_rev; >>> + struct arm_smccc_res res; >>> + static char soc_id_str[8], soc_id_rev_str[12]; >>> + >>> + if (arm_smccc_get_version() < ARM_SMCCC_VERSION_1_2) >>> + return 0; >>> + >>> + ret = smccc_soc_id_support_check(); >>> + if (ret) >>> + return ret; >>> + >>> + arm_smccc_1_1_invoke(ARM_SMCCC_ARCH_SOC_ID, 0, &res); >>> + >>> + ret = smccc_map_error_codes(res.a0); >>> + if (ret) >>> + return ret; >>> + >>> + soc_id_version = res.a0; >>> + >>> + arm_smccc_1_1_invoke(ARM_SMCCC_ARCH_SOC_ID, 1, &res); >>> + >>> + ret = smccc_map_error_codes(res.a0); >>> + if (ret) >>> + return ret; >>> + >>> + soc_id_rev = res.a0; >>> + >>> + soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); >>> + if (!soc_dev_attr) >>> + return -ENOMEM; >>> + >>> + sprintf(soc_id_str, "0x%04x", IMP_DEF_SOC_ID(soc_id_version)); >>> + sprintf(soc_id_rev_str, "0x%08x", soc_id_rev); >>> + >>> + soc_dev_attr->soc_id = soc_id_str; >>> + soc_dev_attr->revision = soc_id_rev_str; >>> + >>> + soc_dev = soc_device_register(soc_dev_attr); >>> + if (IS_ERR(soc_dev)) { >>> + ret = PTR_ERR(soc_dev); >>> + goto free_soc; >>> + } >>> + >>> + dev = soc_device_to_device(soc_dev); >>> + >> >> Just wondering, what about if the platform already had a SoC driver - now it >> could have another one, such that we may have multiple sysfs soc devices, >> right? >> > > Yes I had a quick look at that. > > 1. Such platform has option not to implement this SOC_ID if it doesn't > really require it. True > > 2. If the firmware starts implementing it on some variants, then we can > distinguish them with compatibles and blacklist them from the other > SoC driver if having both is an issue > > 3. SoC bus layer supports adding multiple SoC ID driver and it may show > up as /sys/devices/soc which may or may not be fine. Yeah, it's this scenario which I'm concerned about, where some userspace expects, for example, soc0 to have a soc id from a known, expected list, and now may get something else. However it could be argued then that userspace is just too fragile then and there is no read problem here. But this > happens only if neither [1] nor [2] is done. I am happy to see if there's > any solution for this. Any suggestions ? Not sure, but taking a slight deviation, maybe a way could be found to supplement this dev attribute info to other ARM soc drivers. Cheers, John