Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp587287pxu; Thu, 7 Jan 2021 12:39:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJzp8DiKc8hjSmFeR4pOnspjuYS42IBOdof3WObW90omk9DVBisuKqZJxV6N4xRAt64fsP34 X-Received: by 2002:a17:906:cce9:: with SMTP id ot41mr475960ejb.46.1610051944670; Thu, 07 Jan 2021 12:39:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610051944; cv=none; d=google.com; s=arc-20160816; b=TcGE5JFtYg2Gnl1/MAYpBBHmvBzxwWkd8oQaatrSO744ceh5KzD97PkhHJfuP+/us3 hOrVN1nPhKt95VExScdeKUiGaCNWtwwde+n8oEEIDMvxpJXYFxvzRCqo5pbJ6aBPI6eI lH2TYnJe4cIEupZiv2jBYBy2xcLKwhs5RATeksxqReSCXeMjVwoLHJqqX+Kf36cICU6d BaN/smRz6QZVXcrutGkILWQ5jlK5wMTWEKY783hahGJSxSAVAyEtbSpvYJGaItSDiwQ2 oNRdgJji4J+OoOKw/Z6HrjTYFVgN8Fma5ZXDCFbvlG0I3iaHLROBMNMzmddORaOpLrn+ nLAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=CWDZ/IXCcDsUzlixaReXieuAeZSEiXEYqLx1Z7nb4VE=; b=w8RLKufp3UHMAbiChQEDVc+rH+hLcUl4hZZqP54R+D4zQbUOaf2lBK/nLwoeD0fGdF rG0RxFfkvc+myJPgPNzQh24DeGaygCgkut5Tv1G8SaShGoCVtEuBABbUoC+e1GQO1/xo EYGW5YLoh6qI1gBZrSxvFY49KP9jtZk+rV2FyDtNO6zI2S/K4lMKZK9len8lWCFmLlHX WI7e30s3Y6xoWCCc342itlh+fy/ZFVakOv7YIba1eErtVoramMKb5p7Ctiwg5ogjmDOn EAJjv/UXS+h//bSK6IV3YGBc81rdhdMzC1ei8MByrLoFBugTgQEAW521ElHRTx/ZGooB x1dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NVRc3omb; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g19si2688847edf.599.2021.01.07.12.38.40; Thu, 07 Jan 2021 12:39:04 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NVRc3omb; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726616AbhAGUgY (ORCPT + 99 others); Thu, 7 Jan 2021 15:36:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:56510 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725944AbhAGUgY (ORCPT ); Thu, 7 Jan 2021 15:36:24 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 916D723447; Thu, 7 Jan 2021 20:35:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1610051743; bh=po85gdl4mbGgQ3zoAKeD43WPxXK5RT1mSTU3OKiNhVs=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=NVRc3ombNUhTsi7VIIbCgBTp1kgiAL1Ji/eNtcLjti6qYZY+t+QEoPGIH1xW4UdJ9 25QMgWFqBBAEx6d/Y27Y/Y6n/dwK1ent3pAwLqei9u1HrkCKZv785sqYUepu0/vkta 69GFvDk9iuqliL0u4s0XeULeOBJttxi40nVtmrGJ8DHrRUn/GB19V6WRf9oOkoqJhk Ru+YV6Ypu3rwuv+DRNGTLYkL0D1bowS1u/yZVTRFxaLAv1oaG2mXYeg1/iKrtN2zBc Dg9fkEmcQxixmbkCE1hSpcfHPXGK4Z48lpY5eONeAmtM4aPcaNxC9/QArsz6V9EF42 retcQ/wii/u3A== Received: by mail-ej1-f43.google.com with SMTP id t16so11433697ejf.13; Thu, 07 Jan 2021 12:35:43 -0800 (PST) X-Gm-Message-State: AOAM533J5B0sDqWMwHaYWr1ugRTL5MI4a9+747DpnWKcBQw+OaTpTKDZ beTyP7xBmaYpTkuvCsgrJNM2dh2UtaVCQEmSYA== X-Received: by 2002:a17:907:2111:: with SMTP id qn17mr370152ejb.525.1610051742082; Thu, 07 Jan 2021 12:35:42 -0800 (PST) MIME-Version: 1.0 References: <20210105045735.1709825-1-jeremy.linton@arm.com> <5d4f85a4-248b-b62e-f976-63c6214bf588@arm.com> In-Reply-To: <5d4f85a4-248b-b62e-f976-63c6214bf588@arm.com> From: Rob Herring Date: Thu, 7 Jan 2021 13:35:30 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] arm64: PCI: Enable SMC conduit To: Jeremy Linton Cc: linux-arm-kernel , PCI , Lorenzo Pieralisi , Bjorn Helgaas , Catalin Marinas , Will Deacon , Sudeep Holla , Mark Rutland , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 7, 2021 at 12:45 PM Jeremy Linton wrote= : > > Hi, > > On 1/7/21 11:36 AM, Rob Herring wrote: > > On Thu, Jan 7, 2021 at 9:24 AM Jeremy Linton wr= ote: > >> > >> Hi, > >> > >> > >> On 1/7/21 9:28 AM, Rob Herring wrote: > >>> On Mon, Jan 4, 2021 at 9:57 PM Jeremy Linton = wrote: > >>>> > >>>> Given that most arm64 platform's PCI implementations needs quirks > >>>> to deal with problematic config accesses, this is a good place to > >>>> apply a firmware abstraction. The ARM PCI SMMCCC spec details a > >>>> standard SMC conduit designed to provide a simple PCI config > >>>> accessor. This specification enhances the existing ACPI/PCI > >>>> abstraction and expects power, config, etc functionality is handled > > (trimming) > > >>>> > >>>> +static int smccc_pcie_check_conduit(u16 seg) > >>> > >>> check what? Based on how you use this, perhaps _has_conduit() instead= . > >> > >> Sure. > >> > >>> > >>>> +{ > >>>> + struct arm_smccc_res res; > >>>> + > >>>> + if (arm_smccc_1_1_get_conduit() =3D=3D SMCCC_CONDUIT_NONE) > >>>> + return -EOPNOTSUPP; > >>>> + > >>>> + arm_smccc_smc(SMCCC_PCI_VERSION, 0, 0, 0, 0, 0, 0, 0, &res); > >>>> + if ((int)res.a0 < 0) > >>>> + return -EOPNOTSUPP; > >>>> + > >>>> + arm_smccc_smc(SMCCC_PCI_SEG_INFO, seg, 0, 0, 0, 0, 0, 0, &re= s); > >>>> + if ((int)res.a0 < 0) > >>>> + return -EOPNOTSUPP; > >>> > >>> Don't you need to check that read and write functions are supported? > >> > >> In theory no, the first version of the specification makes them > >> mandatory for all implementations. There isn't a partial access method= , > >> so nothing works if only read or write were implemented. > > > > Then the spec should change: > > > > 2.3.3 Caller responsibilities > > The caller has the following responsibilities: > > =E2=80=A2 The caller must ensure that this function is implemented befo= re > > issuing a call. This function is discoverable > > by calling PCI_FEATURES with pci_func_id set to 0x8400_0132. > > > > > > I guess knowing the version is ensuring, but the 2nd sentence makes it > > seem that is how one should ensure. > > Ok, yes i understand, I will add the check. > > > > > Related, are there any sort of tests for the interface? I generally > > don't think the kernel's job is validating firmware (a frequent topic > > for DT), but we should have something. Maybe an SMC unittest module? > > If nothing else, seems like we should have at least one PCI_FEATURES > > call to make sure it works. We don't want to add it later only to find > > that it breaks on some firmware implementations. Though we can just > > add firmware quirks. ;) > > I'm not aware of any unit tests at the moment. My testing so far has > been against these patches: > https://review.trustedfirmware.org/q/topic:"Arm_PCI_Config_Space_Interfac= e" > > But given the next version does the PCI_FEATURES calls, that will > satisfy your concern, right? Somewhat, but that doesn't replace the need for unittests. We have PSCI checker, maybe the same thing should be required here. Otherwise, implementations will only be as good as what Linux currently expects. Rob