Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp474975rdb; Tue, 23 Jan 2024 05:36:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IFRqDTbJkvghq9/bY/Zvq7kuHS8groKVyW1Z095o8CHOM+5nQm4G/ft7nNwwqNSuARiFibt X-Received: by 2002:a05:622a:86:b0:42a:4e7a:9b6b with SMTP id o6-20020a05622a008600b0042a4e7a9b6bmr782146qtw.93.1706017002747; Tue, 23 Jan 2024 05:36:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706017002; cv=pass; d=google.com; s=arc-20160816; b=ZMEU4wnj5Ass6Ftv0d9rpk78038mMTKxuAUDOpthOXFj2k0WB0LMrL4SGSmnt2eXwt uQ939qwmLfBj9Frmxa7O7zZbyo9eg9kGd+wYDpgTw0LqqWFTAgs3NVJePGXflZpqdxe/ sTOubxrlVqbhGur8FI3s482oIWfKpJLbHREgaKIseKlRZGDD5P1JS4Ysg4bGfJEAn09f 0swChf8wZqtwpLNBwGXRONThLK0T558mVg4hf9EAVcMff3n6eYqqTpq/GTpxcN3+jJva 1aegQqY6n4zxVfsnA4WF4BDtkD2cALphm4ZOfBT6YPv4dYh9ZkqlOJsAggvYoJ+OW7hx A8Kg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=sdk+0ooNrUf6Lwnkeu0jt3YKftoUzkN3CJ1b3AdwA+w=; fh=14GBiR5qcUlaVkYgVkgOpQmqu3RIxYkwQYghyBUKz/g=; b=llDSUcXuDzAd7pTNK6QaMEt+Kk/U56WiFfE5/nndWozZAZkFR+rgFm/U/snL+NTPPv 3peEGGV6gDWw05tLC3fstDCbUCPc9aS/ffjX6pcrl2LwHEOt6Uvt/YKMZd220rPmdAbE uziPPfEiQs26BQGSqBqNe+Fo2/J2+Sda+M/cSBk9I9Zq4g84BDIlM/if4gzSM6TuK9DD /IueG8eSfGQ1qKemciOko/xt+PihyJZbxC15dWuxO4ebnG8aMJGVE1sKarvztnQQmKjP ZNZ8hENJTTGPaaeLilR6NkY6GhYmLYcZicMI/S00x9fsszIljpJOsa2XfMKRs5PkiFc/ 2RiA== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-35391-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35391-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id a20-20020a05622a02d400b0042a56cd0230si68619qtx.388.2024.01.23.05.36.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 05:36:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-35391-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-35391-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35391-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 4CA661C21122 for ; Tue, 23 Jan 2024 13:36:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 233D15F541; Tue, 23 Jan 2024 13:36:35 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0E7AE33CC; Tue, 23 Jan 2024 13:36:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706016994; cv=none; b=N/1F6C8HAkDvUtkea5CG7hBHphfrtOs54mD22Pmsrodb0kV6lMzLgWSt5Ujvt0Dq8P8hZi9b0iD/HkWzAbs9axdQK54xKtL2T+45n7O6jwabQwoz1Hx6dt5fLdaot5qF1wFbQRpkYyeea4krJS73ZkC7k0KjkZuHqmCGBewiNcw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706016994; c=relaxed/simple; bh=6iQ0DISi3QxwIKFZR+AE3nFxCcqYjepQqrZX7GECL4A=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Thhc3BQ+Hx+iQFtbvJDI1AEmQ6MhosdhJiH3u7Gwc1RccdTO+brcULuqa20f7Z930S3cmyS48SAlOe4K5GZDBZdXP8W8NwIKnaDPD/TE/Z7f6BwiAmLRdOqpFPlFL7eHlFro3IfQ4X8cKiIIMb3fpkEMJjqSUSjLCV1ZNzPjqFg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 908CF1FB; Tue, 23 Jan 2024 05:37:16 -0800 (PST) Received: from [10.1.196.40] (e121345-lin.cambridge.arm.com [10.1.196.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0E5083F762; Tue, 23 Jan 2024 05:36:29 -0800 (PST) Message-ID: <9722b637-68d7-4cba-928c-9782dd5413fa@arm.com> Date: Tue, 23 Jan 2024 13:36:28 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 1/1] irqchip/gic-v3: Enable non-coherent redistributors/ITSes ACPI probing Content-Language: en-GB To: Lorenzo Pieralisi , linux-kernel@vger.kernel.org Cc: Mark Rutland , "Rafael J. Wysocki" , Marc Zyngier , linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev, Fang Xiang , Robert Moore References: <20240123110332.112797-1-lpieralisi@kernel.org> <20240123110332.112797-2-lpieralisi@kernel.org> From: Robin Murphy In-Reply-To: <20240123110332.112797-2-lpieralisi@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 23/01/2024 11:03 am, Lorenzo Pieralisi wrote: > The GIC architecture specification defines a set of registers for > redistributors and ITSes that control the sharebility and cacheability > attributes of redistributors/ITSes initiator ports on the interconnect > (GICR_[V]PROPBASER, GICR_[V]PENDBASER, GITS_BASER). > > Architecturally the GIC provides a means to drive shareability and > cacheability attributes signals but it is not mandatory for designs to > wire up the corresponding interconnect signals that control the > cacheability/shareability of transactions. > > Redistributors and ITSes interconnect ports can be connected to > non-coherent interconnects that are not able to manage the > shareability/cacheability attributes; this implicitly makes the > redistributors and ITSes non-coherent observers. > > To enable non-coherent GIC designs on ACPI based systems, parse the MADT > GICC/GICR/ITS subtables non-coherent flags to determine whether the > respective components are non-coherent observers and force the > shareability attributes to be programmed into the redistributors and > ITSes registers. > > An ACPI global function (acpi_get_madt_revision()) is added to retrieve > the MADT revision, in that it is essential to check the MADT revision > before checking for flags that were added with MADT revision 7 so that > if the kernel is booted with an ACPI MADT table with revision < 7 it > skips parsing the newly added flags (that should be zeroed reserved > values for MADT versions < 7 but they could turn out to be buggy and > should be ignored). FWIW, Reviewed-by: Robin Murphy I guess the most contentious parts disappeared in Marc's refactoring, so what's left seems entirely straightforward and innocuous to me. I'd also agree that there seems no real value in going out of our way to police the firmware for consistency - if at least one entry says to apply the quirk, then applying the quirk is the right and safest thing to do, so all we could really do on top of that is add extra complexity to be able to say "hey, firmware did a silly thing!", but if we're starting from the premise that hardware did an inadvisable thing to begin with, maybe we should have similarly realistic expectations of the corresponding firmware anyway :) Cheers, Robin. > Signed-off-by: Lorenzo Pieralisi > Cc: Robin Murphy > Cc: Mark Rutland > Cc: "Rafael J. Wysocki" > Cc: Marc Zyngier > --- > drivers/acpi/processor_core.c | 15 +++++++++++++++ > drivers/irqchip/irq-gic-v3-its.c | 4 ++++ > drivers/irqchip/irq-gic-v3.c | 9 +++++++++ > include/linux/acpi.h | 3 +++ > 4 files changed, 31 insertions(+) > > diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c > index b203cfe28550..915713c0e9b7 100644 > --- a/drivers/acpi/processor_core.c > +++ b/drivers/acpi/processor_core.c > @@ -215,6 +215,21 @@ phys_cpuid_t __init acpi_map_madt_entry(u32 acpi_id) > return rv; > } > > +int __init acpi_get_madt_revision(void) > +{ > + struct acpi_table_header *madt = NULL; > + int revision; > + > + if (ACPI_FAILURE(acpi_get_table(ACPI_SIG_MADT, 0, &madt))) > + return -EINVAL; > + > + revision = madt->revision; > + > + acpi_put_table(madt); > + > + return revision; > +} > + > static phys_cpuid_t map_mat_entry(acpi_handle handle, int type, u32 acpi_id) > { > struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; > diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c > index fec1b58470df..a60c560ce891 100644 > --- a/drivers/irqchip/irq-gic-v3-its.c > +++ b/drivers/irqchip/irq-gic-v3-its.c > @@ -5591,6 +5591,10 @@ static int __init gic_acpi_parse_madt_its(union acpi_subtable_headers *header, > goto node_err; > } > > + if (acpi_get_madt_revision() >= 7 && > + (its_entry->flags & ACPI_MADT_ITS_NON_COHERENT)) > + its->flags |= ITS_FLAGS_FORCE_NON_SHAREABLE; > + > err = its_probe_one(its); > if (!err) > return 0; > diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c > index 98b0329b7154..8cb8dff86c12 100644 > --- a/drivers/irqchip/irq-gic-v3.c > +++ b/drivers/irqchip/irq-gic-v3.c > @@ -2356,6 +2356,11 @@ gic_acpi_parse_madt_redist(union acpi_subtable_headers *header, > pr_err("Couldn't map GICR region @%llx\n", redist->base_address); > return -ENOMEM; > } > + > + if (acpi_get_madt_revision() >= 7 && > + (redist->flags & ACPI_MADT_GICR_NON_COHERENT)) > + gic_data.rdists.flags |= RDIST_FLAGS_FORCE_NON_SHAREABLE; > + > gic_request_region(redist->base_address, redist->length, "GICR"); > > gic_acpi_register_redist(redist->base_address, redist_base); > @@ -2380,6 +2385,10 @@ gic_acpi_parse_madt_gicc(union acpi_subtable_headers *header, > return -ENOMEM; > gic_request_region(gicc->gicr_base_address, size, "GICR"); > > + if (acpi_get_madt_revision() >= 7 && > + (gicc->flags & ACPI_MADT_GICC_NON_COHERENT)) > + gic_data.rdists.flags |= RDIST_FLAGS_FORCE_NON_SHAREABLE; > + > gic_acpi_register_redist(gicc->gicr_base_address, redist_base); > return 0; > } > diff --git a/include/linux/acpi.h b/include/linux/acpi.h > index b7165e52b3c6..4eedab0e51c3 100644 > --- a/include/linux/acpi.h > +++ b/include/linux/acpi.h > @@ -284,6 +284,9 @@ static inline bool invalid_phys_cpuid(phys_cpuid_t phys_id) > return phys_id == PHYS_CPUID_INVALID; > } > > + > +int __init acpi_get_madt_revision(void); > + > /* Validate the processor object's proc_id */ > bool acpi_duplicate_processor_id(int proc_id); > /* Processor _CTS control */