From patchwork Sat Oct 19 07:10:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandar Rikalo X-Patchwork-Id: 13842574 Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 109F91CC890; Sat, 19 Oct 2024 07:10:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729321847; cv=none; b=ritvkGykxxGcp1Cy1CwWYLZ8sw9HDYSAsDJ685tUmv09INQYr+OJ0heJHCG297xcgSST0xDCSxVoMAM8oVJvQ/ndRynPPReFSCYq+d86q6wuXM0rx/2xU5KLFoTpBpquys+ICNgQGDaOASmNc5pNINm5qxzW/h8uiOd6x08Bc2I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729321847; c=relaxed/simple; bh=cAw1fMa88K0eSA4QdBE4QrEFyFaLSup0xnRQDCeAFRE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SiQslN97GGcUNdGe1yQtTxX8KEpmpVXPZyEeziDOAATEk9TZfnEzAVpP5nxT/e3GyxeWA3Cq7OC1Mn8BoRKRYzvJalLQQOoTNtRYw01qTQyWVaQVC5N+fpM6wikFVV3nsL2MVXjt8CgHIrKTlMwxHsNaFMGZ108dgIxv7mnRFMw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=md1lRrZz; arc=none smtp.client-ip=209.85.218.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="md1lRrZz" Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-a99f646ff1bso341718966b.2; Sat, 19 Oct 2024 00:10:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729321843; x=1729926643; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3bRNszhMVq/3+e44FU1ywn3qp6VaEiQfTqGQh9hECvc=; b=md1lRrZzfH2RPMSJWS2M3Vg8n6JyJVZ6Gv/imdxyobmj8XM7GyhvYc4tESaK2+hI3G +UE6RzRkQArXlXbYk8Eb9gjHiM/S8Eh0SS/Thhg1xH97/MuSSlIWE9E9KccTEQCmZPn+ 9X1bd8z9rjltjcgvz17Of/YFMqz55nXYdjWoKgp4Ps0N9EKrMlYCcI4dh3/TWeyYgloZ DxUNp6lTCuy/pU6dWB+kF6YcFyZMTMV/7Mamh7GCCyLKUZIWimA16nz8B23u/cWX9wxs t8iUeSRirS8uqTyrhLyTwCNEjOinoBqoloSpejZSShfKcHAyqLb6n7WCTKXjrE59qzmt ldXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729321843; x=1729926643; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3bRNszhMVq/3+e44FU1ywn3qp6VaEiQfTqGQh9hECvc=; b=QjjasYGcq+vE2fbnpk5dTH9v+MH0Jr+vP+G2PvCSo/s3+4pKvBBRzdZRF1ir+ICkcH mJwppyAPOfzXVDBj1woLBvW47d7uoo2KIOsStqFiRQ15HUJsN3P2g93FfO+7aV0Gquit RGJ9m0R+2W0+n1cFi2rOmqny+QqnHsN8KeHQkWjG+U1RUKMUef7wfOIN+FDbXt0DMm6m Tm9gXO0JT9M5iP3ka61KnjUA6jfotiwEqtRwhCQUWInMlTfL/UOtVycJxBiL/Kl6QI2Z kLyEC6uHcD6+ktWq1PG4jXoQpAG2H6sbBIcIJMtmJNvW8ioVQh67D6or37EwvcrTfxpT HxXA== X-Forwarded-Encrypted: i=1; AJvYcCUF9ahEM+yU30KkzWNXgv/IH3OmoiHkdAUOneZReTgYGSPrkPXjQfpb4Fx1T3xrl9iZQknokW7qWWF98jI=@vger.kernel.org, AJvYcCVX930FZ5SxLPadM+nWycqFLrECBj+O7trWYu4LH57hhKP+ieW+vDKmDS9vZ4yIsYht1a3zUO+xJpVhsA==@vger.kernel.org X-Gm-Message-State: AOJu0YyFr4WrRSPHwhfrc3zuY2EHwOAnt6ZX2md8Y12QXlfybccKHk1t CNwMJVeaJj5pdJ986nhJ2q1rqArMD2Ormx2k6K/ma5Ca2aiXq4Y1 X-Google-Smtp-Source: AGHT+IGppaA77Lc8gUzFG8Sn2L44DEvG5ITDYyRJPRNkj9KEz0ruBX/VEkB2i2/BvfABZpE+p0wNnA== X-Received: by 2002:a17:906:db08:b0:a99:5234:c56c with SMTP id a640c23a62f3a-a9a69ba5cf8mr400693466b.33.1729321842927; Sat, 19 Oct 2024 00:10:42 -0700 (PDT) Received: from localhost.localdomain ([79.175.114.8]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a68c27841sm180566666b.192.2024.10.19.00.10.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Oct 2024 00:10:42 -0700 (PDT) From: Aleksandar Rikalo To: Thomas Bogendoerfer Cc: Aleksandar Rikalo , Chao-ying Fu , Daniel Lezcano , Geert Uytterhoeven , Greg Ungerer , Hauke Mehrtens , Ilya Lipnitskiy , Jiaxun Yang , linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, Marc Zyngier , Paul Burton , Peter Zijlstra , Serge Semin , Thomas Gleixner , Tiezhu Yang , Gregory CLEMENT Subject: [PATCH v7 01/12] irqchip/mips-gic: Introduce for_each_online_cpu_gic() Date: Sat, 19 Oct 2024 09:10:26 +0200 Message-Id: <20241019071037.145314-2-arikalo@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241019071037.145314-1-arikalo@gmail.com> References: <20241019071037.145314-1-arikalo@gmail.com> Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Paul Burton Parts of code in the MIPS GIC driver operate on the GIC local register block for each online CPU, accessing each via the GIC's other/redirect register block. Abstract the process of iterating over online CPUs & configuring the other/redirect region to access their registers through a new for_each_online_cpu_gic() macro. Signed-off-by: Paul Burton Signed-off-by: Chao-ying Fu Signed-off-by: Dragan Mladjenovic Signed-off-by: Aleksandar Rikalo Tested-by: Serge Semin --- drivers/irqchip/irq-mips-gic.c | 59 +++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 18 deletions(-) diff --git a/drivers/irqchip/irq-mips-gic.c b/drivers/irqchip/irq-mips-gic.c index 76253e864f23..6c7a7d2f0438 100644 --- a/drivers/irqchip/irq-mips-gic.c +++ b/drivers/irqchip/irq-mips-gic.c @@ -66,6 +66,44 @@ static struct gic_all_vpes_chip_data { bool mask; } gic_all_vpes_chip_data[GIC_NUM_LOCAL_INTRS]; +static int __gic_with_next_online_cpu(int prev) +{ + unsigned int cpu; + + /* Discover the next online CPU */ + cpu = cpumask_next(prev, cpu_online_mask); + + /* If there isn't one, we're done */ + if (cpu >= nr_cpu_ids) + return cpu; + + /* + * Move the access lock to the next CPU's GIC local register block. + * + * Set GIC_VL_OTHER. Since the caller holds gic_lock nothing can + * clobber the written value. + */ + write_gic_vl_other(mips_cm_vp_id(cpu)); + + return cpu; +} + +/** + * for_each_online_cpu_gic() - Iterate over online CPUs, access local registers + * @cpu: An integer variable to hold the current CPU number + * @gic_lock: A pointer to raw spin lock used as a guard + * + * Iterate over online CPUs & configure the other/redirect register region to + * access each CPUs GIC local register block, which can be accessed from the + * loop body using read_gic_vo_*() or write_gic_vo_*() accessor functions or + * their derivatives. + */ +#define for_each_online_cpu_gic(cpu, gic_lock) \ + guard(raw_spinlock_irqsave)(gic_lock); \ + for ((cpu) = __gic_with_next_online_cpu(-1); \ + (cpu) < nr_cpu_ids; \ + (cpu) = __gic_with_next_online_cpu(cpu)) + static void gic_clear_pcpu_masks(unsigned int intr) { unsigned int i; @@ -350,37 +388,27 @@ static struct irq_chip gic_local_irq_controller = { static void gic_mask_local_irq_all_vpes(struct irq_data *d) { struct gic_all_vpes_chip_data *cd; - unsigned long flags; int intr, cpu; intr = GIC_HWIRQ_TO_LOCAL(d->hwirq); cd = irq_data_get_irq_chip_data(d); cd->mask = false; - raw_spin_lock_irqsave(&gic_lock, flags); - for_each_online_cpu(cpu) { - write_gic_vl_other(mips_cm_vp_id(cpu)); + for_each_online_cpu_gic(cpu, &gic_lock) write_gic_vo_rmask(BIT(intr)); - } - raw_spin_unlock_irqrestore(&gic_lock, flags); } static void gic_unmask_local_irq_all_vpes(struct irq_data *d) { struct gic_all_vpes_chip_data *cd; - unsigned long flags; int intr, cpu; intr = GIC_HWIRQ_TO_LOCAL(d->hwirq); cd = irq_data_get_irq_chip_data(d); cd->mask = true; - raw_spin_lock_irqsave(&gic_lock, flags); - for_each_online_cpu(cpu) { - write_gic_vl_other(mips_cm_vp_id(cpu)); + for_each_online_cpu_gic(cpu, &gic_lock) write_gic_vo_smask(BIT(intr)); - } - raw_spin_unlock_irqrestore(&gic_lock, flags); } static void gic_all_vpes_irq_cpu_online(void) @@ -469,7 +497,6 @@ static int gic_irq_domain_map(struct irq_domain *d, unsigned int virq, irq_hw_number_t hwirq) { struct gic_all_vpes_chip_data *cd; - unsigned long flags; unsigned int intr; int err, cpu; u32 map; @@ -533,12 +560,8 @@ static int gic_irq_domain_map(struct irq_domain *d, unsigned int virq, if (!gic_local_irq_is_routable(intr)) return -EPERM; - raw_spin_lock_irqsave(&gic_lock, flags); - for_each_online_cpu(cpu) { - write_gic_vl_other(mips_cm_vp_id(cpu)); + for_each_online_cpu_gic(cpu, &gic_lock) write_gic_vo_map(mips_gic_vx_map_reg(intr), map); - } - raw_spin_unlock_irqrestore(&gic_lock, flags); return 0; } From patchwork Sat Oct 19 07:10:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandar Rikalo X-Patchwork-Id: 13842575 Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB3671DD877; Sat, 19 Oct 2024 07:10:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729321848; cv=none; b=JLim4/uVORKUNVvMRj+3z2YprqfyXefwlttkWWg9nTW3goH18creLjwtLZeqh77kFNbNXwhX51uAbt67RmRkhGOe9d6rB9FC2qE1jcdijoActaDY1Eh6YBRyVgWeg/2TxYTO4T5iJImXvHHv+x7hzEoNHuMS4b+f9Dg+e9LJZLg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729321848; c=relaxed/simple; bh=6v8h21BYHwmBn6z3r5CIfCo7toAhvHcTjG+vWOZBQCA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YebUoAtZ4xrPKzIA0u+THwNiagiCag5oNTb+UZGyJMaEjJZJRN18z0oruKjOPVBtgX7Gg55+FH8S0DsgVnmabwLNdehiUMRC6rM4XK4eb79I7+buTz2/bagOzXkA8Imd+tw2Hz98808DkHgaXvCDpu1mhE4HxouoLkSwda+LHKI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lY8OQaYn; arc=none smtp.client-ip=209.85.218.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lY8OQaYn" Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-a99c0beaaa2so454208366b.1; Sat, 19 Oct 2024 00:10:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729321845; x=1729926645; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ajgv0hB3TeKXEQwcY+X8KT/8Qpdg4uMdZRkO0EFzzv0=; b=lY8OQaYni/7Xu7o7aq3gJYKGRh/yTIyaMcB5ggYxQVIGG8q7Pxlihlz56dCq50kEbr Tucfzb51o0ZWmIUhGjsdmx6BjPb/yVW5nzGakjuIh1ilItU+O0ZDgRBTFuQjt1/jv/Qv 2YLGCZ66VaBnlevemFa+McE7c90SuQHwI8xl8v0GRYpbnpppunPJRgxo5t+ISpDMCxAi zWw16ltM/15G2UJa+JcbqdOdeMEH6i7YjNFm4T7GCMO+ED2s5iaeDkn9RskWPEYeoHd8 GWpJeOYF6IWW9ey04fuhhedvNPTUW1rNAMmuOsYlwS49tHQcHQjUdhy/wNrD0psRvXza aIRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729321845; x=1729926645; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ajgv0hB3TeKXEQwcY+X8KT/8Qpdg4uMdZRkO0EFzzv0=; b=FUx3pZ5rxacu7joXFJbvECIsF932UlEUEW2uq1JF5we/vN6R/f+r5Jd9HtDT/NwaWl 1adbhIlBKow8cYYyoT6oHRuAhJVGz13nh6VoCigjpxjWM9UyeyAdhZ41SKUMFKbiXDhU qWdij5tELrEfmj3pNVQj0Xwp+JezhmU/JcBhUqftCfQ55UNJYFAyMBhQbh5pbasi5SCh +hrPJlvHEKUDp6fMVPfpEd29UFjhK+xJuIaT1nkUCTCvPktAJ3yXApeXQEtoeTMZp7fH p48AvE1P6eZgkLMtz/MSAWZqpupYpekc85L8xGy06FZVlKxVictPEMQbh4+8XO4N3R3a il4A== X-Forwarded-Encrypted: i=1; AJvYcCUbK4HLJmTDBZ3y+8v8b7R33eMFHUGIkyV37FESm4QUF4pKkDiBjwdzK19ve9XitwDazda2M9m78gQC1Lo=@vger.kernel.org, AJvYcCV32mVY2s4DNFeaWe/lmF1TEHDH0z+WrjxCgg3fZb5k3NcvRBgWv7bvX789rS73eFqxb19OQmFnmSFYLA==@vger.kernel.org X-Gm-Message-State: AOJu0YwuLwIN46gh3lTcdnONrPyTqJFD9fjBUljICKUarzlGnhkgVty3 2FzND7gVThLPAzI3Oc/jRgPZpJ7S7L/PcXMogR92oZb7eFlcFhQE X-Google-Smtp-Source: AGHT+IGGc93RTo7IldCL3Qbu2wG7N4h7g2lsoXcBox+qzN6GKNJ9wQWn0rCnWc9xm+ek8GG2Z56yqw== X-Received: by 2002:a17:907:60ca:b0:a9a:daa:ef3c with SMTP id a640c23a62f3a-a9a69a7b429mr479551166b.14.1729321844743; Sat, 19 Oct 2024 00:10:44 -0700 (PDT) Received: from localhost.localdomain ([79.175.114.8]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a68c27841sm180566666b.192.2024.10.19.00.10.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Oct 2024 00:10:44 -0700 (PDT) From: Aleksandar Rikalo To: Thomas Bogendoerfer Cc: Aleksandar Rikalo , Chao-ying Fu , Daniel Lezcano , Geert Uytterhoeven , Greg Ungerer , Hauke Mehrtens , Ilya Lipnitskiy , Jiaxun Yang , linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, Marc Zyngier , Paul Burton , Peter Zijlstra , Serge Semin , Thomas Gleixner , Tiezhu Yang , Gregory CLEMENT Subject: [PATCH v7 02/12] irqchip/mips-gic: Support multi-cluster in for_each_online_cpu_gic() Date: Sat, 19 Oct 2024 09:10:27 +0200 Message-Id: <20241019071037.145314-3-arikalo@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241019071037.145314-1-arikalo@gmail.com> References: <20241019071037.145314-1-arikalo@gmail.com> Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Paul Burton Use CM's GCR_CL_REDIRECT register to access registers in remote clusters, so users of gic_with_each_online_cpu() gain support for multi-cluster with no further changes. Signed-off-by: Paul Burton Signed-off-by: Chao-ying Fu Signed-off-by: Dragan Mladjenovic Signed-off-by: Aleksandar Rikalo Signed-off-by: Thomas Gleixner Tested-by: Serge Semin --- drivers/irqchip/irq-mips-gic.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/irqchip/irq-mips-gic.c b/drivers/irqchip/irq-mips-gic.c index 6c7a7d2f0438..29bdfdce2123 100644 --- a/drivers/irqchip/irq-mips-gic.c +++ b/drivers/irqchip/irq-mips-gic.c @@ -88,6 +88,12 @@ static int __gic_with_next_online_cpu(int prev) return cpu; } +static inline void gic_unlock_cluster(void) +{ + if (mips_cps_multicluster_cpus()) + mips_cm_unlock_other(); +} + /** * for_each_online_cpu_gic() - Iterate over online CPUs, access local registers * @cpu: An integer variable to hold the current CPU number @@ -102,6 +108,7 @@ static int __gic_with_next_online_cpu(int prev) guard(raw_spinlock_irqsave)(gic_lock); \ for ((cpu) = __gic_with_next_online_cpu(-1); \ (cpu) < nr_cpu_ids; \ + gic_unlock_cluster(), \ (cpu) = __gic_with_next_online_cpu(cpu)) static void gic_clear_pcpu_masks(unsigned int intr) From patchwork Sat Oct 19 07:10:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandar Rikalo X-Patchwork-Id: 13842576 Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 748911DE3A3; Sat, 19 Oct 2024 07:10:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729321850; cv=none; b=IAyNdM/oNOAqwf7g5c694+3Rj8e7B6Mhx9hwf6MgfPultM3TOVU0Gu/Fx9LMbxMEVmDpUoBTSvqsssPeDoGwMy37A9U8THRe+jGQSABqG8hCZHM3K0aieDmnkDlmvBW2Y3dcQoVYJN/MrZG1NuUO8BEe2LPRrIJpvXVFeI8qS8c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729321850; c=relaxed/simple; bh=F+ZcSGOqx9X/ZvXyBUNOAihkxk6As3xiu6/7A855sXA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=eg0fcUgM3tseD5uQ1oVsVmsc6ZyJ/g/5/1U/bjUL2b6jLFZHlEtFGgMpBbWo/wH6chpRfYu3B4qvVb7rnP3ad9ZIrM/zoNk003pkrZ5LlcGzH5Jv1E/DuvDwn2hbHQV6T1ly6OT+YH2+LcXiGFAANvL1JCKoUWWdwQBDLyHhoIg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=G50LRNVe; arc=none smtp.client-ip=209.85.218.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="G50LRNVe" Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-a9a1b71d7ffso400217266b.1; Sat, 19 Oct 2024 00:10:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729321847; x=1729926647; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jz0kUjpzsFWVo1j1eqZUTSojq1aOuYqxFxKOuRH0s6M=; b=G50LRNVeDrEr4KQmJdYLnv7YfvlYCxB9VnNm9jRA6rcW3VwSuOjQ6xu4JARZfTVU0r G4Ww8dQOE8tZSNLSPrkAFA5hkuv9y/PMW8dvNDxYwkxaBGHBeJ5t/34ucfaYdHF6wzSj Y7GWd18WYTXf37yyaxeHXoDZl7CaWRHuq6FDaRwFNi0srZl5ErMKAM/LZ/+PNU9TgBsa WQEEStzTmKWsnJb6WqMciMamCjMcI/vBgwSQ0+MoOhlzW7QNgh0QFtpUvSvtdabFhJc9 2Rf7wMZEfnxzkW/lDO/IUL4XmswXITMnYEqVpDyMp895+ZJnPdnymVdKjQTaNqe/gxvu FFKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729321847; x=1729926647; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jz0kUjpzsFWVo1j1eqZUTSojq1aOuYqxFxKOuRH0s6M=; b=dIoR/AWee8TYdmMNqzdh99c6C8VpZriS6VezgRPZEj+G74u8zGv+sj6TOI9Y28zkkN hZTcO31PrNAxKC49G6GP0EJK3ASEa4ToL1HIkPtVH3T+MyAMR9vLBmKoi+3jM5Yv/hS8 HpTNbwOhSHioWB3r0XOAYoDawC5NOj56Ly/fRajXWfYpZhmgZnF8oI61ah45BuvzttMS ZZUc1SEtdU+tk7DVogW1s5aEHyF4MfgybllsFN+nYOJ+StNV1iQC33h1a7jMaexEBTap eFcxGay2uvyRqp0GpgeUHTRREQ+z1wsxyu0Imd+Wi9upIzJbZG9+/LkuShUnN21ykqF5 1QuQ== X-Forwarded-Encrypted: i=1; AJvYcCXW4X2qGX45V/5oYLm7U+tN/mdZkHEJiuZj0b2+UGrVOL38teuNT3AY8HtCSAIlAAmCYWoYrAJYBAlaBA==@vger.kernel.org, AJvYcCXWSvIoZumhd+hZL+3UHpfbMVY3BWC1ohZ4ZDd+RH6EH/281ChlUNMXaJalGq29Hpv2OvXIr/a6/3qg95Y=@vger.kernel.org X-Gm-Message-State: AOJu0YzEXtTcgVvsUrBqTqB3divPxtqDdaZC5Xb13k60aWCx7ZmCYRDK rwxr6L4pe/XD6RpFl5WCgxLqjd4I1rk/U0FhGKvAmgRaDudTfWQE X-Google-Smtp-Source: AGHT+IGu3lkYPoo6x2nm8178jeDi1BdfNNEofeFQVnJ5yAzMmtmoaQO4zTRkzYlsyYj0pX52xdOEyw== X-Received: by 2002:a17:907:1b81:b0:a9a:80cc:d7b0 with SMTP id a640c23a62f3a-a9a80ccd822mr99402966b.44.1729321846622; Sat, 19 Oct 2024 00:10:46 -0700 (PDT) Received: from localhost.localdomain ([79.175.114.8]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a68c27841sm180566666b.192.2024.10.19.00.10.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Oct 2024 00:10:46 -0700 (PDT) From: Aleksandar Rikalo To: Thomas Bogendoerfer Cc: Aleksandar Rikalo , Chao-ying Fu , Daniel Lezcano , Geert Uytterhoeven , Greg Ungerer , Hauke Mehrtens , Ilya Lipnitskiy , Jiaxun Yang , linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, Marc Zyngier , Paul Burton , Peter Zijlstra , Serge Semin , Thomas Gleixner , Tiezhu Yang , Gregory CLEMENT Subject: [PATCH v7 03/12] irqchip/mips-gic: Setup defaults in each cluster Date: Sat, 19 Oct 2024 09:10:28 +0200 Message-Id: <20241019071037.145314-4-arikalo@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241019071037.145314-1-arikalo@gmail.com> References: <20241019071037.145314-1-arikalo@gmail.com> Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Chao-ying Fu In multi-cluster MIPS I6500 systems, there is a GIC per cluster. The default shared interrupt setup configured in gic_of_init() will only apply to the GIC in the cluster containing the boot CPU, leaving the GICs of other clusters unconfigured. Similarly configure other clusters. Signed-off-by: Chao-ying Fu Signed-off-by: Dragan Mladjenovic Signed-off-by: Aleksandar Rikalo Tested-by: Serge Semin --- drivers/irqchip/irq-mips-gic.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/drivers/irqchip/irq-mips-gic.c b/drivers/irqchip/irq-mips-gic.c index 29bdfdce2123..d93a076620c7 100644 --- a/drivers/irqchip/irq-mips-gic.c +++ b/drivers/irqchip/irq-mips-gic.c @@ -764,7 +764,7 @@ static int gic_cpu_startup(unsigned int cpu) static int __init gic_of_init(struct device_node *node, struct device_node *parent) { - unsigned int cpu_vec, i, gicconfig; + unsigned int cpu_vec, i, gicconfig, cl, nclusters; unsigned long reserved; phys_addr_t gic_base; struct resource res; @@ -845,11 +845,29 @@ static int __init gic_of_init(struct device_node *node, board_bind_eic_interrupt = &gic_bind_eic_interrupt; - /* Setup defaults */ - for (i = 0; i < gic_shared_intrs; i++) { - change_gic_pol(i, GIC_POL_ACTIVE_HIGH); - change_gic_trig(i, GIC_TRIG_LEVEL); - write_gic_rmask(i); + /* + * Initialise each cluster's GIC shared registers to sane default + * values. + * Otherwise, the IPI set up will be erased if we move code + * to gic_cpu_startup for each cpu. + */ + nclusters = mips_cps_numclusters(); + for (cl = 0; cl < nclusters; cl++) { + if (cl == cpu_cluster(¤t_cpu_data)) { + for (i = 0; i < gic_shared_intrs; i++) { + change_gic_pol(i, GIC_POL_ACTIVE_HIGH); + change_gic_trig(i, GIC_TRIG_LEVEL); + write_gic_rmask(i); + } + } else { + mips_cm_lock_other(cl, 0, 0, CM_GCR_Cx_OTHER_BLOCK_GLOBAL); + for (i = 0; i < gic_shared_intrs; i++) { + change_gic_redir_pol(i, GIC_POL_ACTIVE_HIGH); + change_gic_redir_trig(i, GIC_TRIG_LEVEL); + write_gic_redir_rmask(i); + } + mips_cm_unlock_other(); + } } return cpuhp_setup_state(CPUHP_AP_IRQ_MIPS_GIC_STARTING, From patchwork Sat Oct 19 07:10:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandar Rikalo X-Patchwork-Id: 13842577 Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 653CB1D7994; Sat, 19 Oct 2024 07:10:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729321853; cv=none; b=JQ0ziZkiM8uWRCJcRZ2ezDwzi9HzQfoBecNKGZEzdEc2U5Xe1ZtmHtCsjab5oVlGvIahA6NreMtNsrkaPK6FCJVkWv8tXrNSDnG3m+ZUA71jhY2XpGk17bJBlLhLtkkKg2rmVBnvDcEEhW+E1w4vVDSuMZruVUf+1lWl2ZGX5hk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729321853; c=relaxed/simple; bh=6+4XpwGQzex4RwjZWBggaUIIAguDIaBK+tijuDCECHs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=B9xcRxyz4FbBEhZ9QDW/M677mDy8+an3jFhgK8FkG/KdhSfkJp/3X4D1HzO8pQcXJX12vBY92Xv4M7GRVBgkC3xL1pwzE+jqyLxI/Ow574ybY8XnjRUNDKzxh/IYADeRZJ1abQj07FVIGCdGNPgFz6iQQVWBuhWHPW3oS44FRQ8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=hfIRTjGV; arc=none smtp.client-ip=209.85.218.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hfIRTjGV" Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-a99e3b3a411so613023766b.0; Sat, 19 Oct 2024 00:10:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729321850; x=1729926650; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=p28kChyKpp8Aof+EjnP1QrCd5R/LkFW5YgWutffMgNw=; b=hfIRTjGVhAPr+E1Wkr6rm0dPSPZSbKGZmpj4+urn7aP9zkzYmPyhxlhJ8ZeJVGPHHS RjWaGQNUWCziKYhdnulCdAEuR0Yab0nW2U3cmMiX9ILYV+/KSoAkBh68p4ve72/Ubs/K ugWo2sjMa2uXgee05dWPTM0KWZTP+PZyYtlzLqNtc28tWQE51zH+EUAgu5iTAd3qts5f +zmpohia3j4/F+lA9bwJ8qRP13Vlb+YZCqfMuwjg80gGNtbDopzeZQ2uUMeCjahi+51F Mcm/38Hzik2Bsa+8M+RO9lX7IYEm3L893BbpOfDJXnAD7PEGIAnBaQIquXLDpJuDtoR7 1tkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729321850; x=1729926650; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=p28kChyKpp8Aof+EjnP1QrCd5R/LkFW5YgWutffMgNw=; b=rwCFu7UqYKHN3ikZTbELtsv8zocJDPvTbYXXKMhzZss7MZmB4kLBJVNbZrFWgKbAz4 Q3GCrDHUgZ3UIyyCloWyFeoiiriYy4gtYy8NvIkxV/VXhbE4XNxt08CHY2z7MBKM8cjB BnccJCxl10HEebwJ2juxqHCetKKLHH15pnC37WTKgIdIbh8PadR7GHa9DREPjkBRi7Mw SzAec1BCQJCNKUWWn5XwlWJMhZRJo0jno8BnHNrdwOitS6qX/yJUrizEztPaDhrVsOZb yE4mVotPvdMeulSHO2iC/Tw+7tk+4hYfyl/2uVIQsEQriI6/Zz54wYJEu3bXmekhWMXC xkAQ== X-Forwarded-Encrypted: i=1; AJvYcCWf4uBJ9Rfz5fLRTxD1dIpO+yExXnyZ+qpD+lvyqr3k2hTyy+TqNcDgtkHrYlpkkvqCl2KMjN2HPsgPHf4=@vger.kernel.org, AJvYcCWpM8mZMUISEOqSfACecXGD9k1DRQWlj7cboHWQy8MBqeOFLIQjwkYdZQsmDhJ3fNtmrgjkMmD1BG4LoQ==@vger.kernel.org X-Gm-Message-State: AOJu0YxsyY3i47biGVWajEuXR+/A4inXnjHOynA1I5wWlpnokOzzbQ6q NEUslM4n11WrfWfVPPDWBC2ry4JUpij6gfRnrptcaqSYc5u3fd+h X-Google-Smtp-Source: AGHT+IFO/mMb4MZl/+7SuhRzRspibzTgZ87Yix/J9wM2rHOIqiZQ8KoABKc85h7zP90+fQbVQSRt6w== X-Received: by 2002:a17:907:9811:b0:a99:ffa9:a27 with SMTP id a640c23a62f3a-a9a4cc3abc1mr987430066b.26.1729321849491; Sat, 19 Oct 2024 00:10:49 -0700 (PDT) Received: from localhost.localdomain ([79.175.114.8]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a68c27841sm180566666b.192.2024.10.19.00.10.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Oct 2024 00:10:47 -0700 (PDT) From: Aleksandar Rikalo To: Thomas Bogendoerfer Cc: Aleksandar Rikalo , Chao-ying Fu , Daniel Lezcano , Geert Uytterhoeven , Greg Ungerer , Hauke Mehrtens , Ilya Lipnitskiy , Jiaxun Yang , linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, Marc Zyngier , Paul Burton , Peter Zijlstra , Serge Semin , Thomas Gleixner , Tiezhu Yang , Gregory CLEMENT Subject: [PATCH v7 04/12] irqchip/mips-gic: Multi-cluster support Date: Sat, 19 Oct 2024 09:10:29 +0200 Message-Id: <20241019071037.145314-5-arikalo@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241019071037.145314-1-arikalo@gmail.com> References: <20241019071037.145314-1-arikalo@gmail.com> Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Paul Burton The MIPS I6500 CPU & CM (Coherence Manager) 3.5 introduce the concept of multiple clusters to the system. In these systems, each cluster contains its own GIC, so the GIC isn't truly global any longer. Access to registers in the GICs of remote clusters is possible using a redirect register block much like the redirect register blocks provided by the CM & CPC, and configured through the same GCR_REDIRECT register that mips_cm_lock_other() abstraction builds upon. It is expected that external interrupts are connected identically on all clusters. That is, if there is a device providing an interrupt connected to GIC interrupt pin 0 then it should be connected to pin 0 of every GIC in the system. For the most part, the GIC can be treated as though it is still truly global, so long as interrupts in the cluster are configured properly. This patch introduces support for such multi-cluster systems in the MIPS GIC irqchip driver. A newly introduced gic_irq_lock_cluster() function allows: 1) Configure access to a GIC in a remote cluster via the redirect register block, using mips_cm_lock_other(). Or: 2) Detect that the interrupt in question is affine to the local cluster and plain old GIC register access to the GIC in the local cluster should be used. It is possible to access the local cluster's GIC registers via the redirect block, but keeping the special case for them is both good for performance (because we avoid the locking & indirection overhead of using the redirect block) and necessary to maintain compatibility with systems using CM revisions prior to 3.5 which don't support the redirect block. The gic_irq_lock_cluster() function relies upon an IRQs effective affinity in order to discover which cluster the IRQ is affine to. In order to track this & allow it to be updated at an appropriate point during gic_set_affinity() we select the generic support for effective affinity using CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK. gic_set_affinity() is the one function which gains much complexity. It now deconfigures routing to any VP(E), ie. CPU, on the old cluster when moving affinity to a new cluster. gic_shared_irq_domain_map() moves its update of the IRQs effective affinity to before its use of gic_irq_lock_cluster(), to ensure that operation is on the cluster the IRQ is affine to. The remaining changes are straightforward use of the gic_irq_lock_cluster() function to select between local cluster & remote cluster code-paths when configuring interrupts. Signed-off-by: Paul Burton Signed-off-by: Chao-ying Fu Signed-off-by: Dragan Mladjenovic Signed-off-by: Aleksandar Rikalo Tested-by: Serge Semin --- drivers/irqchip/Kconfig | 1 + drivers/irqchip/irq-mips-gic.c | 161 +++++++++++++++++++++++++++++---- 2 files changed, 143 insertions(+), 19 deletions(-) diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index 341cd9ca5a05..fa011868ec9e 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -345,6 +345,7 @@ config KEYSTONE_IRQ config MIPS_GIC bool + select GENERIC_IRQ_EFFECTIVE_AFF_MASK select GENERIC_IRQ_IPI if SMP select IRQ_DOMAIN_HIERARCHY select MIPS_CM diff --git a/drivers/irqchip/irq-mips-gic.c b/drivers/irqchip/irq-mips-gic.c index d93a076620c7..f42f69bbd6fb 100644 --- a/drivers/irqchip/irq-mips-gic.c +++ b/drivers/irqchip/irq-mips-gic.c @@ -111,6 +111,41 @@ static inline void gic_unlock_cluster(void) gic_unlock_cluster(), \ (cpu) = __gic_with_next_online_cpu(cpu)) +/** + * gic_irq_lock_cluster() - Lock redirect block access to IRQ's cluster + * @d: struct irq_data corresponding to the interrupt we're interested in + * + * Locks redirect register block access to the global register block of the GIC + * within the remote cluster that the IRQ corresponding to @d is affine to, + * returning true when this redirect block setup & locking has been performed. + * + * If @d is affine to the local cluster then no locking is performed and this + * function will return false, indicating to the caller that it should access + * the local clusters registers without the overhead of indirection through the + * redirect block. + * + * In summary, if this function returns true then the caller should access GIC + * registers using redirect register block accessors & then call + * mips_cm_unlock_other() when done. If this function returns false then the + * caller should trivially access GIC registers in the local cluster. + * + * Returns true if locking performed, else false. + */ +static bool gic_irq_lock_cluster(struct irq_data *d) +{ + unsigned int cpu, cl; + + cpu = cpumask_first(irq_data_get_effective_affinity_mask(d)); + BUG_ON(cpu >= NR_CPUS); + + cl = cpu_cluster(&cpu_data[cpu]); + if (cl == cpu_cluster(¤t_cpu_data)) + return false; + + mips_cm_lock_other(cl, 0, 0, CM_GCR_Cx_OTHER_BLOCK_GLOBAL); + return true; +} + static void gic_clear_pcpu_masks(unsigned int intr) { unsigned int i; @@ -157,7 +192,12 @@ static void gic_send_ipi(struct irq_data *d, unsigned int cpu) { irq_hw_number_t hwirq = GIC_HWIRQ_TO_SHARED(irqd_to_hwirq(d)); - write_gic_wedge(GIC_WEDGE_RW | hwirq); + if (gic_irq_lock_cluster(d)) { + write_gic_redir_wedge(GIC_WEDGE_RW | hwirq); + mips_cm_unlock_other(); + } else { + write_gic_wedge(GIC_WEDGE_RW | hwirq); + } } int gic_get_c0_compare_int(void) @@ -225,7 +265,13 @@ static void gic_mask_irq(struct irq_data *d) { unsigned int intr = GIC_HWIRQ_TO_SHARED(d->hwirq); - write_gic_rmask(intr); + if (gic_irq_lock_cluster(d)) { + write_gic_redir_rmask(intr); + mips_cm_unlock_other(); + } else { + write_gic_rmask(intr); + } + gic_clear_pcpu_masks(intr); } @@ -234,7 +280,12 @@ static void gic_unmask_irq(struct irq_data *d) unsigned int intr = GIC_HWIRQ_TO_SHARED(d->hwirq); unsigned int cpu; - write_gic_smask(intr); + if (gic_irq_lock_cluster(d)) { + write_gic_redir_smask(intr); + mips_cm_unlock_other(); + } else { + write_gic_smask(intr); + } gic_clear_pcpu_masks(intr); cpu = cpumask_first(irq_data_get_effective_affinity_mask(d)); @@ -245,7 +296,12 @@ static void gic_ack_irq(struct irq_data *d) { unsigned int irq = GIC_HWIRQ_TO_SHARED(d->hwirq); - write_gic_wedge(irq); + if (gic_irq_lock_cluster(d)) { + write_gic_redir_wedge(irq); + mips_cm_unlock_other(); + } else { + write_gic_wedge(irq); + } } static int gic_set_type(struct irq_data *d, unsigned int type) @@ -285,9 +341,16 @@ static int gic_set_type(struct irq_data *d, unsigned int type) break; } - change_gic_pol(irq, pol); - change_gic_trig(irq, trig); - change_gic_dual(irq, dual); + if (gic_irq_lock_cluster(d)) { + change_gic_redir_pol(irq, pol); + change_gic_redir_trig(irq, trig); + change_gic_redir_dual(irq, dual); + mips_cm_unlock_other(); + } else { + change_gic_pol(irq, pol); + change_gic_trig(irq, trig); + change_gic_dual(irq, dual); + } if (trig == GIC_TRIG_EDGE) irq_set_chip_handler_name_locked(d, &gic_edge_irq_controller, @@ -305,25 +368,72 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *cpumask, bool force) { unsigned int irq = GIC_HWIRQ_TO_SHARED(d->hwirq); + unsigned int cpu, cl, old_cpu, old_cl; unsigned long flags; - unsigned int cpu; + /* + * The GIC specifies that we can only route an interrupt to one VP(E), + * ie. CPU in Linux parlance, at a time. Therefore we always route to + * the first online CPU in the mask. + */ cpu = cpumask_first_and(cpumask, cpu_online_mask); if (cpu >= NR_CPUS) return -EINVAL; - /* Assumption : cpumask refers to a single CPU */ - raw_spin_lock_irqsave(&gic_lock, flags); + old_cpu = cpumask_first(irq_data_get_effective_affinity_mask(d)); + old_cl = cpu_cluster(&cpu_data[old_cpu]); + cl = cpu_cluster(&cpu_data[cpu]); - /* Re-route this IRQ */ - write_gic_map_vp(irq, BIT(mips_cm_vp_id(cpu))); + raw_spin_lock_irqsave(&gic_lock, flags); - /* Update the pcpu_masks */ - gic_clear_pcpu_masks(irq); - if (read_gic_mask(irq)) - set_bit(irq, per_cpu_ptr(pcpu_masks, cpu)); + /* + * If we're moving affinity between clusters, stop routing the + * interrupt to any VP(E) in the old cluster. + */ + if (cl != old_cl) { + if (gic_irq_lock_cluster(d)) { + write_gic_redir_map_vp(irq, 0); + mips_cm_unlock_other(); + } else { + write_gic_map_vp(irq, 0); + } + } + /* + * Update effective affinity - after this gic_irq_lock_cluster() will + * begin operating on the new cluster. + */ irq_data_update_effective_affinity(d, cpumask_of(cpu)); + + /* + * If we're moving affinity between clusters, configure the interrupt + * trigger type in the new cluster. + */ + if (cl != old_cl) + gic_set_type(d, irqd_get_trigger_type(d)); + + /* Route the interrupt to its new VP(E) */ + if (gic_irq_lock_cluster(d)) { + write_gic_redir_map_pin(irq, + GIC_MAP_PIN_MAP_TO_PIN | gic_cpu_pin); + write_gic_redir_map_vp(irq, BIT(mips_cm_vp_id(cpu))); + + /* Update the pcpu_masks */ + gic_clear_pcpu_masks(irq); + if (read_gic_redir_mask(irq)) + set_bit(irq, per_cpu_ptr(pcpu_masks, cpu)); + + mips_cm_unlock_other(); + } else { + write_gic_map_pin(irq, GIC_MAP_PIN_MAP_TO_PIN | gic_cpu_pin); + write_gic_map_vp(irq, BIT(mips_cm_vp_id(cpu))); + + /* Update the pcpu_masks */ + gic_clear_pcpu_masks(irq); + if (read_gic_mask(irq)) + set_bit(irq, per_cpu_ptr(pcpu_masks, cpu)); + } + raw_spin_unlock_irqrestore(&gic_lock, flags); return IRQ_SET_MASK_OK; @@ -471,11 +581,21 @@ static int gic_shared_irq_domain_map(struct irq_domain *d, unsigned int virq, unsigned long flags; data = irq_get_irq_data(virq); + irq_data_update_effective_affinity(data, cpumask_of(cpu)); raw_spin_lock_irqsave(&gic_lock, flags); - write_gic_map_pin(intr, GIC_MAP_PIN_MAP_TO_PIN | gic_cpu_pin); - write_gic_map_vp(intr, BIT(mips_cm_vp_id(cpu))); - irq_data_update_effective_affinity(data, cpumask_of(cpu)); + + /* Route the interrupt to its VP(E) */ + if (gic_irq_lock_cluster(data)) { + write_gic_redir_map_pin(intr, + GIC_MAP_PIN_MAP_TO_PIN | gic_cpu_pin); + write_gic_redir_map_vp(intr, BIT(mips_cm_vp_id(cpu))); + mips_cm_unlock_other(); + } else { + write_gic_map_pin(intr, GIC_MAP_PIN_MAP_TO_PIN | gic_cpu_pin); + write_gic_map_vp(intr, BIT(mips_cm_vp_id(cpu))); + } + raw_spin_unlock_irqrestore(&gic_lock, flags); return 0; @@ -651,6 +771,9 @@ static int gic_ipi_domain_alloc(struct irq_domain *d, unsigned int virq, if (ret) goto error; + /* Set affinity to cpu. */ + irq_data_update_effective_affinity(irq_get_irq_data(virq + i), + cpumask_of(cpu)); ret = irq_set_irq_type(virq + i, IRQ_TYPE_EDGE_RISING); if (ret) goto error; From patchwork Sat Oct 19 07:10:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandar Rikalo X-Patchwork-Id: 13842578 Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 478991DEFD6; Sat, 19 Oct 2024 07:10:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729321856; cv=none; b=bgnyC/TAFShSV9nPWC92pXo8sVPaIBMNoN1NUa2CpQ5SfMu76ZTt/DRAp7R+eZZENzcaSdYyTlB/x+iuW1x/7lEgZgcD5abTfs6o+HVvXohfpzLjvLwEeil63Ac9k0Gn5x5cBWzyebsLDul7QKGHScyk1xgmuQAxTrVFoLssuCc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729321856; c=relaxed/simple; bh=KyjNq/4JWqFWorsEqD2UphoVO/zOCfofXlli3znYEhs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=s32E6gNtRjqbwrPT2Wbq/+HFS/AKMlrYBSrHwMWMliA7CWOAac/D+uLi9/TBa2YHhAfzfKymcT2g3TnhmsatHgE8B1Ah+z1pGse+feE+VqQ2rQYLE0W+ooAQxyzZT7WTlCyiW96O7+7r25FBaZGQXx4WnF69AxDlqYWeUTcL9FA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZvymqrMD; arc=none smtp.client-ip=209.85.218.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZvymqrMD" Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-a9a0472306cso355056666b.3; Sat, 19 Oct 2024 00:10:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729321852; x=1729926652; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=F4c0vwBBm2GJGPzUzcwaUmJw/5o8B/sn9ihY/AAAuUE=; b=ZvymqrMDLtlJyrrTfaZAerKs3RFBJkfMDtQujZMK5qTM48rFNuM5AhSiRkuJFQQQ8J X6iiCpDHJHW7Hsz2Nku1rRNwpZqDoYTROvQ17ADLD7HOFUisYdxbPdnRX5j/ao3V6CTL dnh4ACUGgOW5/gXHeIXd0Onr3yppnoMuz8UQ0rRVeIhoFN3vfzGIF8ndDMO380S41My7 DAgTq+qStzTLHBG2mENCPFtlStQnKouiPAHNHiLzfksCpWMCxTK4wRhDXgkMOfzH4kCa ZyoP6ml/NiSjZfdOlkr5QvtnTy7HZZnGJBIqmZmXne1uZ5bMDJlCetoZgdv8bq3Sb6IM 7XRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729321852; x=1729926652; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=F4c0vwBBm2GJGPzUzcwaUmJw/5o8B/sn9ihY/AAAuUE=; b=AeDaE+ffO6bRaky27yhv90U4Vqb0jpQt6iUpJIUgcsZQNmvz1uBrHefLZaCWl8RTnL +oXm4BXfslynPdFbrXwGVSyYpOhQM+B0q2Xme6FlMrmt3MBVCB+EWq96X6wksqTWtFg7 yx621gOUKl2IiaC6mctL5+R+kFM45tNGAwf6c7Eu1LuXFlmaiwcD9FMw5iP/qSyz/wcp nF1hZ8SFkA+idGbFSLeNG6VPQYjCrTO0aTKNPk90p3lU+4l+9Sz5SBHzRQAHl2ToOqgo DpDs/urkoxv4CxHGvac9InarHBwGJltD4EHt2wbjraHKqFChVP5/r8b60bS+MLKaNyyS PAhg== X-Forwarded-Encrypted: i=1; AJvYcCV5xUFnlfxLxHFHBUxoK0vw49EKdoB2f7+HTq47RzPPLixw64iGS5nASAg6n2PsZUcZEfsgtIDSIqYFz+c=@vger.kernel.org, AJvYcCXXcvtDs8SY1+mQYUKX1VaqclxTkb4nY/qCKVR2mLLs0XqVyy5gv0AuY9BMMgUNkb4fNJ7zKiVxFDhU4Q==@vger.kernel.org X-Gm-Message-State: AOJu0Yy5QRBWh64A8j+iZ6J8ZO1I+1r2wNBfW1kq49SqetEiSEnI3JWG HRCZXRbdtwo7QzNYxvbpfMBp6DMsQJ0Nl9jEeosck6X5SJNCann6 X-Google-Smtp-Source: AGHT+IGBsE1ie/NzpB0I+jNKNxByt2QsmGK+fuU9kdO3H9XaNqgLWxr9+6R+eP5xQzgkmv6fMJTtKQ== X-Received: by 2002:a17:906:4fca:b0:a9a:1bb4:800c with SMTP id a640c23a62f3a-a9a6996979amr477071566b.4.1729321852334; Sat, 19 Oct 2024 00:10:52 -0700 (PDT) Received: from localhost.localdomain ([79.175.114.8]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a68c27841sm180566666b.192.2024.10.19.00.10.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Oct 2024 00:10:51 -0700 (PDT) From: Aleksandar Rikalo To: Thomas Bogendoerfer Cc: Aleksandar Rikalo , Chao-ying Fu , Daniel Lezcano , Geert Uytterhoeven , Greg Ungerer , Hauke Mehrtens , Ilya Lipnitskiy , Jiaxun Yang , linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, Marc Zyngier , Paul Burton , Peter Zijlstra , Serge Semin , Thomas Gleixner , Tiezhu Yang , Gregory CLEMENT Subject: [PATCH v7 05/12] clocksource: mips-gic-timer: Always use cluster 0 counter as clocksource Date: Sat, 19 Oct 2024 09:10:30 +0200 Message-Id: <20241019071037.145314-6-arikalo@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241019071037.145314-1-arikalo@gmail.com> References: <20241019071037.145314-1-arikalo@gmail.com> Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Paul Burton In a multi-cluster MIPS system, there are multiple GICs - one in each cluster - each of which has its independent counter. The counters in each GIC are not synchronized in any way, so they can drift relative to one another through the lifetime of the system. This is problematic for a clock source which ought to be global. Avoid problems by always accessing cluster 0's counter, using cross-cluster register access. This adds overhead so it is applied only on multi-cluster systems. Signed-off-by: Paul Burton Signed-off-by: Chao-ying Fu Signed-off-by: Dragan Mladjenovic Signed-off-by: Aleksandar Rikalo Tested-by: Serge Semin Acked-by: Thomas Bogendoerfer --- drivers/clocksource/mips-gic-timer.c | 39 +++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/drivers/clocksource/mips-gic-timer.c b/drivers/clocksource/mips-gic-timer.c index 110347707ff9..7907b740497a 100644 --- a/drivers/clocksource/mips-gic-timer.c +++ b/drivers/clocksource/mips-gic-timer.c @@ -166,6 +166,37 @@ static u64 gic_hpt_read(struct clocksource *cs) return gic_read_count(); } +static u64 gic_hpt_read_multicluster(struct clocksource *cs) +{ + unsigned int hi, hi2, lo; + u64 count; + + mips_cm_lock_other(0, 0, 0, CM_GCR_Cx_OTHER_BLOCK_GLOBAL); + + if (mips_cm_is64) { + count = read_gic_redir_counter(); + goto out; + } + + hi = read_gic_redir_counter_32h(); + while (true) { + lo = read_gic_redir_counter_32l(); + + /* If hi didn't change then lo didn't wrap & we're done */ + hi2 = read_gic_redir_counter_32h(); + if (hi2 == hi) + break; + + /* Otherwise, repeat with the latest hi value */ + hi = hi2; + } + + count = (((u64)hi) << 32) + lo; +out: + mips_cm_unlock_other(); + return count; +} + static struct clocksource gic_clocksource = { .name = "GIC", .read = gic_hpt_read, @@ -203,6 +234,11 @@ static int __init __gic_clocksource_init(void) gic_clocksource.rating = 200; gic_clocksource.rating += clamp(gic_frequency / 10000000, 0, 99); + if (mips_cps_multicluster_cpus()) { + gic_clocksource.read = &gic_hpt_read_multicluster; + gic_clocksource.vdso_clock_mode = VDSO_CLOCKMODE_NONE; + } + ret = clocksource_register_hz(&gic_clocksource, gic_frequency); if (ret < 0) pr_warn("Unable to register clocksource\n"); @@ -261,7 +297,8 @@ static int __init gic_clocksource_of_init(struct device_node *node) * stable CPU frequency or on the platforms with CM3 and CPU frequency * change performed by the CPC core clocks divider. */ - if (mips_cm_revision() >= CM_REV_CM3 || !IS_ENABLED(CONFIG_CPU_FREQ)) { + if ((mips_cm_revision() >= CM_REV_CM3 || !IS_ENABLED(CONFIG_CPU_FREQ)) && + !mips_cps_multicluster_cpus()) { sched_clock_register(mips_cm_is64 ? gic_read_count_64 : gic_read_count_2x32, gic_count_width, gic_frequency); From patchwork Sat Oct 19 07:10:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Aleksandar Rikalo X-Patchwork-Id: 13842579 Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40B8F1DF262; Sat, 19 Oct 2024 07:10:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729321859; cv=none; b=nwg8DdrQaMIFg2VApIe8sXdHqUcwFlIWierkKI6rVua4a74GGBYuvMe2MD1KSeDXvB5u3VdnESMSpVK6AYvrUKgPSUPXwp3cCpevlVR8pFIgww2wKmnpTNrNxSKKuumDKRmE7XH0yjnqmNWYJuDolkUYgiZA6uvkQihGb5f5/eg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729321859; c=relaxed/simple; bh=V5rAjTu+pU2fpi74fQ5x5suB+2X7eoYvm+lLjy+3z2o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=LDS/OikYn3jK0FhwIeGACyYi/mKhLmG6/LYPcvXzV+mfI5IIbMsfn2JNmtopdeyhz/nuFSHa1gYHKsnh4JQ/A5pYxJhkXvez6iC07l+Om8XcFx35HFEjJWO/6Z488VdZN06A7cJr9zF26dqmkdGSx2BBs2OVyYx8zYeGG+dF1zI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=QXpA+gc9; arc=none smtp.client-ip=209.85.218.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QXpA+gc9" Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-a9a4031f69fso366586766b.0; Sat, 19 Oct 2024 00:10:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729321855; x=1729926655; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1TY2C2Lxi2lZ2EXUmAkUJgOoy7I3aUdzu6U8J4ynR6M=; b=QXpA+gc9T9Cb6TpGr9b6cHWB+Q3tfQzZqT2lAcDOvdEJ/tUYGrOt1bi7fPU9+qRge+ kltz/toQt0WwKwIm8N9OEnSNFM6zOGzcsRmF3uBIIU1AJSwkYgKaAl9zbW2Y0lQAsKPz bYVWmPC0FXIeiz2lyP8HzXdtmOutaYbAZuTH5Y4ab8hOszw1oZD7pQrpDEXZ6aNlW91W s/Bh2pOJmAS8spEydVwLPcDLG+5m1ciMGsWQcq2xOqElK+1QvX+QZ1itHCm7JBhfZdcI 9hVXE5SdPerf4s+2cHO9mVn27PoSr8OaZ6nknqIW5VgbVrrpGmtx5v60LEbtdxgTFHYI LMRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729321855; x=1729926655; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1TY2C2Lxi2lZ2EXUmAkUJgOoy7I3aUdzu6U8J4ynR6M=; b=OsofPbK5XOLGyABxSW16HcWUKsPQ1/ZfE9pfrhqgJDGdJGR1woUoBzHS+aWVO3tHGV znFnj26HdEo/jz3pczUz40lB5nCcx+0o7X7OuyhzU0sZFchOJViyplExWJBhfDdi8Mme O1RnpuZ9S8vdvXJfcGWJjklQzES1EW8+B1AlVrSPsc1OI8Zz2mbtPNuJaUT1gS6FH8ln blf7aN4Yh/uI/yntEfvQsyb01GUqq4RH4J2lt7nbEZy1QWfjwvfjk518/S9umgL1kGgz gDS7XQpGXnxirU6NM8jrggBsyUC9bN/R+a3YuwGYM0Iy2/J0bkeIOiw9y5qzYl4EVUMF y3xg== X-Forwarded-Encrypted: i=1; AJvYcCUl7zbuimAH5oNZ50OJJRFlbPL933fqpkzimDLwNe2R86vWFipTkE9lLi3SSTw3+XL54NLtnSJO3JVwTbM=@vger.kernel.org, AJvYcCV/vnXSxTgpDEUXle0vpGvih9ZNX7K11T2Dc6rd9sKpTX59feBi47pbf3RaMglaE0Z1D5n+Mp7wfo6i5w==@vger.kernel.org X-Gm-Message-State: AOJu0YyxMWDELTxP5PeSHnIX+YmdRiKrewlVwzBehNv1rPYUC/VTO5nZ 1yI2AfuxGIM5V/DhjRYF+xKw+HjYweLZ6pIrXup4/QOeIur7E9jz X-Google-Smtp-Source: AGHT+IEV7/3h0JUHrhmJMQszJL6kUDS2mzOCwK4Q1bg7OTC00KLPrfKhu7HG+S0TEpZfGhtIVg5K4A== X-Received: by 2002:a17:906:6a29:b0:a99:e504:40c5 with SMTP id a640c23a62f3a-a9a69bb4776mr432006366b.39.1729321855209; Sat, 19 Oct 2024 00:10:55 -0700 (PDT) Received: from localhost.localdomain ([79.175.114.8]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a68c27841sm180566666b.192.2024.10.19.00.10.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Oct 2024 00:10:53 -0700 (PDT) From: Aleksandar Rikalo To: Thomas Bogendoerfer Cc: Aleksandar Rikalo , Chao-ying Fu , Daniel Lezcano , Geert Uytterhoeven , Greg Ungerer , Hauke Mehrtens , Ilya Lipnitskiy , Jiaxun Yang , linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, Marc Zyngier , Paul Burton , Peter Zijlstra , Serge Semin , Thomas Gleixner , Tiezhu Yang , Gregory CLEMENT Subject: [PATCH v7 06/12] clocksource: mips-gic-timer: Enable counter when CPUs start Date: Sat, 19 Oct 2024 09:10:31 +0200 Message-Id: <20241019071037.145314-7-arikalo@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241019071037.145314-1-arikalo@gmail.com> References: <20241019071037.145314-1-arikalo@gmail.com> Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Paul Burton In multi-cluster MIPS I6500 systems there is a GIC in each cluster, each with its own counter. When a cluster powers up the counter will be stopped, with the COUNTSTOP bit set in the GIC_CONFIG register. In single cluster systems, it has been fine to clear COUNTSTOP once in gic_clocksource_of_init() to start the counter. In multi-cluster systems, this will only have started the counter in the boot cluster, and any CPUs in other clusters will find their counter stopped which will break the GIC clock_event_device. Resolve this by having CPUs clear the COUNTSTOP bit when they come online, using the existing gic_starting_cpu() CPU hotplug callback. This will allow CPUs in secondary clusters to ensure that the cluster's GIC counter is running as expected. Signed-off-by: Paul Burton Signed-off-by: Chao-ying Fu Signed-off-by: Dragan Mladjenovic Signed-off-by: Aleksandar Rikalo Reviewed-by: Philippe Mathieu-Daudé Tested-by: Serge Semin --- drivers/clocksource/mips-gic-timer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/clocksource/mips-gic-timer.c b/drivers/clocksource/mips-gic-timer.c index 7907b740497a..abb685a080a5 100644 --- a/drivers/clocksource/mips-gic-timer.c +++ b/drivers/clocksource/mips-gic-timer.c @@ -115,6 +115,9 @@ static void gic_update_frequency(void *data) static int gic_starting_cpu(unsigned int cpu) { + /* Ensure the GIC counter is running */ + clear_gic_config(GIC_CONFIG_COUNTSTOP); + gic_clockevent_cpu_init(cpu, this_cpu_ptr(&gic_clockevent_device)); return 0; } @@ -288,9 +291,6 @@ static int __init gic_clocksource_of_init(struct device_node *node) pr_warn("Unable to register clock notifier\n"); } - /* And finally start the counter */ - clear_gic_config(GIC_CONFIG_COUNTSTOP); - /* * It's safe to use the MIPS GIC timer as a sched clock source only if * its ticks are stable, which is true on either the platforms with From patchwork Sat Oct 19 07:10:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandar Rikalo X-Patchwork-Id: 13842580 Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 233B01DF73F; Sat, 19 Oct 2024 07:10:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729321861; cv=none; b=EgmQ3AOPbiYSCcgUjFnWsyz29TK3crlziQT5BWJS+vV3n9AjcXZGLicmkVM/syQH/gw6BYsEsUwMV5UpShAYGi2TW+m+MRdowH1skZod8E2Ln1uiT5RZyWZWrjT42MNxKVMFS/7t2QaemD+3nkBFjv2jYaVIu6Jb77sBCZtpGn8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729321861; c=relaxed/simple; bh=QKto5A9MIMK/IEg/kWynx+UpUoTjf00hu+AW07gvz90=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CAqk7XtQxuH8ldHB36Hqh16mWlemo6Dz/V+XcApnAlkgBW5uFO1tFRf1X03pEUVofaujt7FzKfxKEWd1QpIQ9D2ZnYBUHckT3sSVV/TJoN0nnhWkbVypIh9mI/qjEs4fLQMI4EhY25yRTiigQWH3GjAWF9v5UqsLHIXm5/ReqVw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=MbVy//vB; arc=none smtp.client-ip=209.85.208.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MbVy//vB" Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-5c9362c26d8so6515158a12.1; Sat, 19 Oct 2024 00:10:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729321857; x=1729926657; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5Wui8yC11QzS3zuL6au0E0B/rgxgmkQnWbsEcia4kwc=; b=MbVy//vB3QwMA9iherdI3blVibarD5OV5WjxCFvuIGCmc2a7oi/v/KFqLG4j93DSYJ yoVhZrGEUDMt4NgqxA8auFbRCMJzh41vByPz8BlZe1QfjNAXuzZTj8V2OeHo6/z4gFcV oUJ0iLMzmeojfn2rmKvguuZsZTQ8VaCPnWfBkuZxRPMV/ewWlOk7tdjXOPr6VewcgnFW FKbVbOiDtTvJolzPrWPu6RwYZeYBtLXdDnxuG4nRPE7utCMfEj/Qe5SZL2V8iviPbzgX JuSJvRYbWIlRp8wZof74lcVJNNxbSxI1x7QjJtXS+aIxCA3+n3zRttHfqrJqf2dFQJ74 /p7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729321857; x=1729926657; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5Wui8yC11QzS3zuL6au0E0B/rgxgmkQnWbsEcia4kwc=; b=GiEHogC1zMuafG+T/bm5yNWdqIn+vpjRjdGfNjIqMabiFatXa4+ksXp15vCyz8zVDS HYczAfxWXxDPW55EqPhIstjmFIMUDL43mHnvrqiFG1Prby4kW5PZTGVtRf60aGws61M/ 4hgHzXWVm1gKANuf/UFnDKgwfuqDM/m+ORdsW6fGDEA+pBfJwEJNpXVPV395JYf067hT bNPvSdrG3Jv/dIWnaJkx/ipEQF0fAUO315BhLIKRJLQh65FvscMxfjCuubcYt1TRIw2j CYXqxhscsH8NpKPzF+1CHBfUHaPbHIcN6pprvIE9jniR950Q9VeNTNaZ3ZLLDkOEuhvy KuXQ== X-Forwarded-Encrypted: i=1; AJvYcCU82nSR7uVfq8CdvU0oLzcu9A2Mv0u8nJmGznBalkGSl0NsGlVO4H7HQp3ph3p5tLkZuY7HJW93tgryqA==@vger.kernel.org, AJvYcCXqm9K8po3LbViQhWKuDw64Zy+IFj1PXaaq4ldeZkMX8T6/t3E28Kwtd/31zHRV1cLaJXgHat3rXNJ5Co0=@vger.kernel.org X-Gm-Message-State: AOJu0Yw9Dwd067XSOLCKpuhzJMbR819pntxATOH5zNqTnRL3s7b7guSu CsVs9N3v3H+CXqfo0gCRvzhYZqfbx7xyibUPRnLT5O8PUR/DpSKO X-Google-Smtp-Source: AGHT+IExY8gabkNXEofgxZ5SEDsJU6OlXo5CrynzcFrreQZ+IW5eHKcv48BmoDaVxBxV0O8Kka91Xw== X-Received: by 2002:a17:907:3f2a:b0:a99:f209:cea3 with SMTP id a640c23a62f3a-a9a6a412745mr499118066b.11.1729321857016; Sat, 19 Oct 2024 00:10:57 -0700 (PDT) Received: from localhost.localdomain ([79.175.114.8]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a68c27841sm180566666b.192.2024.10.19.00.10.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Oct 2024 00:10:56 -0700 (PDT) From: Aleksandar Rikalo To: Thomas Bogendoerfer Cc: Aleksandar Rikalo , Chao-ying Fu , Daniel Lezcano , Geert Uytterhoeven , Greg Ungerer , Hauke Mehrtens , Ilya Lipnitskiy , Jiaxun Yang , linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, Marc Zyngier , Paul Burton , Peter Zijlstra , Serge Semin , Thomas Gleixner , Tiezhu Yang , Gregory CLEMENT Subject: [PATCH v7 07/12] MIPS: pm-cps: Use per-CPU variables as per-CPU, not per-core Date: Sat, 19 Oct 2024 09:10:32 +0200 Message-Id: <20241019071037.145314-8-arikalo@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241019071037.145314-1-arikalo@gmail.com> References: <20241019071037.145314-1-arikalo@gmail.com> Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Paul Burton The pm-cps code has up until now used per-CPU variables indexed by core, rather than CPU number, in order to share data amongst sibling CPUs (ie. VPs/threads in a core). This works fine for single cluster systems, but with multi-cluster systems a core number is no longer unique in the system, leading to sharing between CPUs that are not actually siblings. Avoid this issue by using per-CPU variables as they are more generally used - ie. access them using CPU numbers rather than core numbers. Sharing between siblings is then accomplished by: - Assigning the same pointer to entries for each sibling CPU for the nc_asm_enter & ready_count variables, which allow this by virtue of being per-CPU pointers. - Indexing by the first CPU set in a CPUs cpu_sibling_map in the case of pm_barrier, for which we can't use the previous approach because the per-CPU variable is not a pointer. Signed-off-by: Paul Burton Signed-off-by: Dragan Mladjenovic Signed-off-by: Aleksandar Rikalo Tested-by: Serge Semin --- arch/mips/kernel/pm-cps.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/arch/mips/kernel/pm-cps.c b/arch/mips/kernel/pm-cps.c index d09ca77e624d..9369a8dc385e 100644 --- a/arch/mips/kernel/pm-cps.c +++ b/arch/mips/kernel/pm-cps.c @@ -57,10 +57,7 @@ static DEFINE_PER_CPU_ALIGNED(u32*, ready_count); /* Indicates online CPUs coupled with the current CPU */ static DEFINE_PER_CPU_ALIGNED(cpumask_t, online_coupled); -/* - * Used to synchronize entry to deep idle states. Actually per-core rather - * than per-CPU. - */ +/* Used to synchronize entry to deep idle states */ static DEFINE_PER_CPU_ALIGNED(atomic_t, pm_barrier); /* Saved CPU state across the CPS_PM_POWER_GATED state */ @@ -112,9 +109,10 @@ int cps_pm_enter_state(enum cps_pm_state state) cps_nc_entry_fn entry; struct core_boot_config *core_cfg; struct vpe_boot_config *vpe_cfg; + atomic_t *barrier; /* Check that there is an entry function for this state */ - entry = per_cpu(nc_asm_enter, core)[state]; + entry = per_cpu(nc_asm_enter, cpu)[state]; if (!entry) return -EINVAL; @@ -150,7 +148,7 @@ int cps_pm_enter_state(enum cps_pm_state state) smp_mb__after_atomic(); /* Create a non-coherent mapping of the core ready_count */ - core_ready_count = per_cpu(ready_count, core); + core_ready_count = per_cpu(ready_count, cpu); nc_addr = kmap_noncoherent(virt_to_page(core_ready_count), (unsigned long)core_ready_count); nc_addr += ((unsigned long)core_ready_count & ~PAGE_MASK); @@ -158,7 +156,8 @@ int cps_pm_enter_state(enum cps_pm_state state) /* Ensure ready_count is zero-initialised before the assembly runs */ WRITE_ONCE(*nc_core_ready_count, 0); - coupled_barrier(&per_cpu(pm_barrier, core), online); + barrier = &per_cpu(pm_barrier, cpumask_first(&cpu_sibling_map[cpu])); + coupled_barrier(barrier, online); /* Run the generated entry code */ left = entry(online, nc_core_ready_count); @@ -629,12 +628,14 @@ static void *cps_gen_entry_code(unsigned cpu, enum cps_pm_state state) static int cps_pm_online_cpu(unsigned int cpu) { - enum cps_pm_state state; - unsigned core = cpu_core(&cpu_data[cpu]); + unsigned int sibling, core; void *entry_fn, *core_rc; + enum cps_pm_state state; + + core = cpu_core(&cpu_data[cpu]); for (state = CPS_PM_NC_WAIT; state < CPS_PM_STATE_COUNT; state++) { - if (per_cpu(nc_asm_enter, core)[state]) + if (per_cpu(nc_asm_enter, cpu)[state]) continue; if (!test_bit(state, state_support)) continue; @@ -646,16 +647,19 @@ static int cps_pm_online_cpu(unsigned int cpu) clear_bit(state, state_support); } - per_cpu(nc_asm_enter, core)[state] = entry_fn; + for_each_cpu(sibling, &cpu_sibling_map[cpu]) + per_cpu(nc_asm_enter, sibling)[state] = entry_fn; } - if (!per_cpu(ready_count, core)) { + if (!per_cpu(ready_count, cpu)) { core_rc = kmalloc(sizeof(u32), GFP_KERNEL); if (!core_rc) { pr_err("Failed allocate core %u ready_count\n", core); return -ENOMEM; } - per_cpu(ready_count, core) = core_rc; + + for_each_cpu(sibling, &cpu_sibling_map[cpu]) + per_cpu(ready_count, sibling) = core_rc; } return 0; From patchwork Sat Oct 19 07:10:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandar Rikalo X-Patchwork-Id: 13842581 Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03B481DF977; Sat, 19 Oct 2024 07:11:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729321863; cv=none; b=a6yJekVHFBb1qgPHFAWqJXAFNHxyvZMioq2d9pzmjfvnHBSM/nXENHo87IHtvtQ23L9YgngC/xo44L+6wNIHaqKbOaGKJbpSIaCEK2UJKO5ftp1tdHlM26A0zQw+ufk9GVUcSaeuEYHMm9J6yziUvx8Rm4eeoGaxZ3PokQhQebs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729321863; c=relaxed/simple; bh=iEpl4bRLYAAHUaWD31rzMEtaXYAiMCWoJzhMYBOfe3A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pef7prB9scp9ThqX0+Ku02BO5WIFwoCYvJ0maO3l8fvZlLR+ZQQtoeZFyosiA06HY8mufv1AAPiQ96yPDR6Zb4E8rFAePThqTUHjjQ2qgsS6dGnPtuWEn+WalzyUhTMBi+ibEQKrMSjCKzET4ydRCQaiXhxmx9sRwtGFbo09jj8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=nkHNty0x; arc=none smtp.client-ip=209.85.218.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nkHNty0x" Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a9932aa108cso420073266b.2; Sat, 19 Oct 2024 00:11:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729321859; x=1729926659; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HFSiDVa5A8xiC3Vbc7Dsg+Rdaig6Ej2jHPtoNOjMC84=; b=nkHNty0x/SpXAAutnUqN7mUaz6OygI7XDNxaFJ5nv0EB3GvK3EnaWdcsSobY6tquQm NV2FE8x4uuTw0s7gDs9wxeqcCibes2NGAXxCW1RteSQdkc9K1cSpyZTq35StKA8u2Tb1 Biw+TLlzoXc4yf7nD2h0zV3b8Fhq8Ox1wEAtIJZPUOsEwnb+rkAEpnjfFx2vB1bTVByD 5ucq02qb9wROY0vOCIn8eH+ZSNXjjdZeTEfFssLNGN3pbX5pZrZdj4rjOpUyx6rUTU1k nxaWyhuUE+JnlB0GrKmhdwRZaus1jGxjv4rIIWZHlKFdvMTZHLpEbtLZflDeeKk6DRLe zSMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729321859; x=1729926659; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HFSiDVa5A8xiC3Vbc7Dsg+Rdaig6Ej2jHPtoNOjMC84=; b=tIVOXVUxy7BmVdAVveU/aDHyRkbuBnJhe1bdEz3OjpJJPbkgOoPIzozB4zseQ6FuIN fM7SBEWBseixaMld+YRWixNdWPEfNLLnD/nZ3HW1n7ZaRedon+SOeXLSIb6t5PzNw0iu V+z6GynvS7bJ0FGq5VrxWs3CxpYF6hTFPkoEbMn7J5n8S2Al1KgZhgsldr4CVBORxn7L uWXCSunbE/4+evdVnMzLxNzT81O57U0ibxbGyqbxxuvCnMHJ2Q49hvzpEkOq1h45duGD O0SxE5AJvQIDVz6a+sHL19p7Z9he7fTd26hxm/p0+bkx6JzKgB1JtNCFBWaXRbnxnXu/ SZtA== X-Forwarded-Encrypted: i=1; AJvYcCWvBzq8Ot7HoJuQtLOtNrz1rbZG6Rx/zvRwAPFnHRKgSFGJSt2/AROupV910ii4/pMXpe53SfQTdFRBzVk=@vger.kernel.org, AJvYcCXbDBPWyEbHvg+ipVdDQ6msdKVEv8ZtwXj9P+HvCt5OFUMfNL6CgcOte0MCnpHya5LLymGomvGGP3GUpA==@vger.kernel.org X-Gm-Message-State: AOJu0Yw9OcjdOYq4LthC6BGN3yB+6y4IsKS6UdQXSLUWMuusyiOXMjgD Cc3ENV4TdKoXIv5o6ZrCPHPeWwNVJfeeHtOvXbQgBcdN+FnUTWMS X-Google-Smtp-Source: AGHT+IHpJ8Ny1iiYib9h6iYEJJPOiJRnXulP/l/cqbwtNXys1Mp6p4/bpAIwR7hFF1z5DCGjHQVs/g== X-Received: by 2002:a17:907:9623:b0:a9a:90c:8bc with SMTP id a640c23a62f3a-a9a6996989dmr419334166b.12.1729321859079; Sat, 19 Oct 2024 00:10:59 -0700 (PDT) Received: from localhost.localdomain ([79.175.114.8]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a68c27841sm180566666b.192.2024.10.19.00.10.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Oct 2024 00:10:58 -0700 (PDT) From: Aleksandar Rikalo To: Thomas Bogendoerfer Cc: Aleksandar Rikalo , Chao-ying Fu , Daniel Lezcano , Geert Uytterhoeven , Greg Ungerer , Hauke Mehrtens , Ilya Lipnitskiy , Jiaxun Yang , linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, Marc Zyngier , Paul Burton , Peter Zijlstra , Serge Semin , Thomas Gleixner , Tiezhu Yang , Gregory CLEMENT Subject: [PATCH v7 08/12] MIPS: CPS: Introduce struct cluster_boot_config Date: Sat, 19 Oct 2024 09:10:33 +0200 Message-Id: <20241019071037.145314-9-arikalo@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241019071037.145314-1-arikalo@gmail.com> References: <20241019071037.145314-1-arikalo@gmail.com> Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Paul Burton In preparation for supporting multi-cluster systems, introduce a struct cluster_boot_config as an extra layer in the boot configuration maintained by the MIPS Coherent Processing System (CPS) SMP implementation. For now only one struct cluster_boot_config will be allocated & we'll simply defererence its core_config field to find the struct core_boot_config array which can be used to boot as usual. Signed-off-by: Paul Burton Signed-off-by: Dragan Mladjenovic Signed-off-by: Aleksandar Rikalo Tested-by: Serge Semin --- arch/mips/include/asm/smp-cps.h | 6 ++- arch/mips/kernel/asm-offsets.c | 3 ++ arch/mips/kernel/cps-vec.S | 19 ++++++-- arch/mips/kernel/pm-cps.c | 5 +- arch/mips/kernel/smp-cps.c | 82 +++++++++++++++++++++------------ 5 files changed, 81 insertions(+), 34 deletions(-) diff --git a/arch/mips/include/asm/smp-cps.h b/arch/mips/include/asm/smp-cps.h index ab94e50f62b8..a629e948a6fd 100644 --- a/arch/mips/include/asm/smp-cps.h +++ b/arch/mips/include/asm/smp-cps.h @@ -22,7 +22,11 @@ struct core_boot_config { struct vpe_boot_config *vpe_config; }; -extern struct core_boot_config *mips_cps_core_bootcfg; +struct cluster_boot_config { + struct core_boot_config *core_config; +}; + +extern struct cluster_boot_config *mips_cps_cluster_bootcfg; extern void mips_cps_core_boot(int cca, void __iomem *gcr_base); extern void mips_cps_core_init(void); diff --git a/arch/mips/kernel/asm-offsets.c b/arch/mips/kernel/asm-offsets.c index cb1045ebab06..b29944160b28 100644 --- a/arch/mips/kernel/asm-offsets.c +++ b/arch/mips/kernel/asm-offsets.c @@ -404,6 +404,9 @@ void output_cps_defines(void) { COMMENT(" MIPS CPS offsets. "); + OFFSET(CLUSTERBOOTCFG_CORECONFIG, cluster_boot_config, core_config); + DEFINE(CLUSTERBOOTCFG_SIZE, sizeof(struct cluster_boot_config)); + OFFSET(COREBOOTCFG_VPEMASK, core_boot_config, vpe_mask); OFFSET(COREBOOTCFG_VPECONFIG, core_boot_config, vpe_config); DEFINE(COREBOOTCFG_SIZE, sizeof(struct core_boot_config)); diff --git a/arch/mips/kernel/cps-vec.S b/arch/mips/kernel/cps-vec.S index f876309130ad..2ae7034a3d5c 100644 --- a/arch/mips/kernel/cps-vec.S +++ b/arch/mips/kernel/cps-vec.S @@ -19,6 +19,10 @@ #define GCR_CPC_BASE_OFS 0x0088 #define GCR_CL_COHERENCE_OFS 0x2008 #define GCR_CL_ID_OFS 0x2028 +#define CM3_GCR_Cx_ID_CLUSTER_SHF 8 +#define CM3_GCR_Cx_ID_CLUSTER_MSK (0xff << 8) +#define CM3_GCR_Cx_ID_CORENUM_SHF 0 +#define CM3_GCR_Cx_ID_CORENUM_MSK (0xff << 0) #define CPC_CL_VC_STOP_OFS 0x2020 #define CPC_CL_VC_RUN_OFS 0x2028 @@ -271,12 +275,21 @@ LEAF(mips_cps_core_init) */ LEAF(mips_cps_get_bootcfg) /* Calculate a pointer to this cores struct core_boot_config */ + PTR_LA v0, mips_cps_cluster_bootcfg + PTR_L v0, 0(v0) lw t0, GCR_CL_ID_OFS(s1) +#ifdef CONFIG_CPU_MIPSR6 + ext t1, t0, CM3_GCR_Cx_ID_CLUSTER_SHF, 8 + li t2, CLUSTERBOOTCFG_SIZE + mul t1, t1, t2 + PTR_ADDU \ + v0, v0, t1 +#endif + PTR_L v0, CLUSTERBOOTCFG_CORECONFIG(v0) + andi t0, t0, CM3_GCR_Cx_ID_CORENUM_MSK li t1, COREBOOTCFG_SIZE mul t0, t0, t1 - PTR_LA t1, mips_cps_core_bootcfg - PTR_L t1, 0(t1) - PTR_ADDU v0, t0, t1 + PTR_ADDU v0, v0, t0 /* Calculate this VPEs ID. If the core doesn't support MT use 0 */ li t9, 0 diff --git a/arch/mips/kernel/pm-cps.c b/arch/mips/kernel/pm-cps.c index 9369a8dc385e..3de0e05e0511 100644 --- a/arch/mips/kernel/pm-cps.c +++ b/arch/mips/kernel/pm-cps.c @@ -101,12 +101,14 @@ static void coupled_barrier(atomic_t *a, unsigned online) int cps_pm_enter_state(enum cps_pm_state state) { unsigned cpu = smp_processor_id(); + unsigned int cluster = cpu_cluster(¤t_cpu_data); unsigned core = cpu_core(¤t_cpu_data); unsigned online, left; cpumask_t *coupled_mask = this_cpu_ptr(&online_coupled); u32 *core_ready_count, *nc_core_ready_count; void *nc_addr; cps_nc_entry_fn entry; + struct cluster_boot_config *cluster_cfg; struct core_boot_config *core_cfg; struct vpe_boot_config *vpe_cfg; atomic_t *barrier; @@ -136,7 +138,8 @@ int cps_pm_enter_state(enum cps_pm_state state) if (!mips_cps_smp_in_use()) return -EINVAL; - core_cfg = &mips_cps_core_bootcfg[core]; + cluster_cfg = &mips_cps_cluster_bootcfg[cluster]; + core_cfg = &cluster_cfg->core_config[core]; vpe_cfg = &core_cfg->vpe_config[cpu_vpe_id(¤t_cpu_data)]; vpe_cfg->pc = (unsigned long)mips_cps_pm_restore; vpe_cfg->gp = (unsigned long)current_thread_info(); diff --git a/arch/mips/kernel/smp-cps.c b/arch/mips/kernel/smp-cps.c index 395622c37325..f71e2bb58318 100644 --- a/arch/mips/kernel/smp-cps.c +++ b/arch/mips/kernel/smp-cps.c @@ -40,7 +40,7 @@ static DECLARE_BITMAP(core_power, NR_CPUS); static uint32_t core_entry_reg; static phys_addr_t cps_vec_pa; -struct core_boot_config *mips_cps_core_bootcfg; +struct cluster_boot_config *mips_cps_cluster_bootcfg; static unsigned __init core_vpe_count(unsigned int cluster, unsigned core) { @@ -212,8 +212,10 @@ static void __init cps_smp_setup(void) static void __init cps_prepare_cpus(unsigned int max_cpus) { - unsigned ncores, core_vpes, c, cca; + unsigned int nclusters, ncores, core_vpes, c, cl, cca; bool cca_unsuitable, cores_limited; + struct cluster_boot_config *cluster_bootcfg; + struct core_boot_config *core_bootcfg; mips_mt_set_cpuoptions(); @@ -255,40 +257,54 @@ static void __init cps_prepare_cpus(unsigned int max_cpus) setup_cps_vecs(); - /* Allocate core boot configuration structs */ - ncores = mips_cps_numcores(0); - mips_cps_core_bootcfg = kcalloc(ncores, sizeof(*mips_cps_core_bootcfg), - GFP_KERNEL); - if (!mips_cps_core_bootcfg) { - pr_err("Failed to allocate boot config for %u cores\n", ncores); - goto err_out; - } + /* Allocate cluster boot configuration structs */ + nclusters = mips_cps_numclusters(); + mips_cps_cluster_bootcfg = kcalloc(nclusters, + sizeof(*mips_cps_cluster_bootcfg), + GFP_KERNEL); - /* Allocate VPE boot configuration structs */ - for (c = 0; c < ncores; c++) { - core_vpes = core_vpe_count(0, c); - mips_cps_core_bootcfg[c].vpe_config = kcalloc(core_vpes, - sizeof(*mips_cps_core_bootcfg[c].vpe_config), - GFP_KERNEL); - if (!mips_cps_core_bootcfg[c].vpe_config) { - pr_err("Failed to allocate %u VPE boot configs\n", - core_vpes); + for (cl = 0; cl < nclusters; cl++) { + /* Allocate core boot configuration structs */ + ncores = mips_cps_numcores(cl); + core_bootcfg = kcalloc(ncores, sizeof(*core_bootcfg), + GFP_KERNEL); + if (!core_bootcfg) goto err_out; + mips_cps_cluster_bootcfg[cl].core_config = core_bootcfg; + + /* Allocate VPE boot configuration structs */ + for (c = 0; c < ncores; c++) { + core_vpes = core_vpe_count(cl, c); + core_bootcfg[c].vpe_config = kcalloc(core_vpes, + sizeof(*core_bootcfg[c].vpe_config), + GFP_KERNEL); + if (!core_bootcfg[c].vpe_config) + goto err_out; } } /* Mark this CPU as booted */ - atomic_set(&mips_cps_core_bootcfg[cpu_core(¤t_cpu_data)].vpe_mask, - 1 << cpu_vpe_id(¤t_cpu_data)); + cl = cpu_cluster(¤t_cpu_data); + c = cpu_core(¤t_cpu_data); + cluster_bootcfg = &mips_cps_cluster_bootcfg[cl]; + core_bootcfg = &cluster_bootcfg->core_config[c]; + atomic_set(&core_bootcfg->vpe_mask, 1 << cpu_vpe_id(¤t_cpu_data)); return; err_out: /* Clean up allocations */ - if (mips_cps_core_bootcfg) { - for (c = 0; c < ncores; c++) - kfree(mips_cps_core_bootcfg[c].vpe_config); - kfree(mips_cps_core_bootcfg); - mips_cps_core_bootcfg = NULL; + if (mips_cps_cluster_bootcfg) { + for (cl = 0; cl < nclusters; cl++) { + cluster_bootcfg = &mips_cps_cluster_bootcfg[cl]; + ncores = mips_cps_numcores(cl); + for (c = 0; c < ncores; c++) { + core_bootcfg = &cluster_bootcfg->core_config[c]; + kfree(core_bootcfg->vpe_config); + } + kfree(mips_cps_cluster_bootcfg[c].core_config); + } + kfree(mips_cps_cluster_bootcfg); + mips_cps_cluster_bootcfg = NULL; } /* Effectively disable SMP by declaring CPUs not present */ @@ -376,17 +392,23 @@ static void boot_core(unsigned int core, unsigned int vpe_id) static void remote_vpe_boot(void *dummy) { + unsigned int cluster = cpu_cluster(¤t_cpu_data); unsigned core = cpu_core(¤t_cpu_data); - struct core_boot_config *core_cfg = &mips_cps_core_bootcfg[core]; + struct cluster_boot_config *cluster_cfg = + &mips_cps_cluster_bootcfg[cluster]; + struct core_boot_config *core_cfg = &cluster_cfg->core_config[core]; mips_cps_boot_vpes(core_cfg, cpu_vpe_id(¤t_cpu_data)); } static int cps_boot_secondary(int cpu, struct task_struct *idle) { + unsigned int cluster = cpu_cluster(&cpu_data[cpu]); unsigned core = cpu_core(&cpu_data[cpu]); unsigned vpe_id = cpu_vpe_id(&cpu_data[cpu]); - struct core_boot_config *core_cfg = &mips_cps_core_bootcfg[core]; + struct cluster_boot_config *cluster_cfg = + &mips_cps_cluster_bootcfg[cluster]; + struct core_boot_config *core_cfg = &cluster_cfg->core_config[core]; struct vpe_boot_config *vpe_cfg = &core_cfg->vpe_config[vpe_id]; unsigned int remote; int err; @@ -544,12 +566,14 @@ static void cps_kexec_nonboot_cpu(void) static int cps_cpu_disable(void) { unsigned cpu = smp_processor_id(); + struct cluster_boot_config *cluster_cfg; struct core_boot_config *core_cfg; if (!cps_pm_support_state(CPS_PM_POWER_GATED)) return -EINVAL; - core_cfg = &mips_cps_core_bootcfg[cpu_core(¤t_cpu_data)]; + cluster_cfg = &mips_cps_cluster_bootcfg[cpu_cluster(¤t_cpu_data)]; + core_cfg = &cluster_cfg->core_config[cpu_core(¤t_cpu_data)]; atomic_sub(1 << cpu_vpe_id(¤t_cpu_data), &core_cfg->vpe_mask); smp_mb__after_atomic(); set_cpu_online(cpu, false); From patchwork Sat Oct 19 07:10:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandar Rikalo X-Patchwork-Id: 13842582 Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DFC6C1DFD9F; Sat, 19 Oct 2024 07:11:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729321865; cv=none; b=WxZcrzi2/iyCjvwfBQA7/j/GOGxzJSurkn6kS+NXdjlEV38DSwkPe1CL86VL00LvONrDYYkNXZhQx8iVXXygzOZjE3dZPpUw5kLSNNMa6Uf7nc7IdCaVgEKVksFn1WTALoR/A2QuxGPiQsAiCjfxU7pPCtVFQ9GD0GixXIFn/wY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729321865; c=relaxed/simple; bh=C1UWvLBD18ktmGVl3uHYn1SGIWdmhfk3zyDVlPq5Qdo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pGPqrD5rd+xol19dtTOtPe3aFEZ/RKgFjLWrEATGkMPzmPU7483AWQylVf98LK7IRZhEeJgJn3h2hcmChbv60jTNNSbj6+yrSi3I5tdcg7FybWatZfZX4WaK5EDEFQldn/6VISQJEUOAZMT429x0io8HOTCtTdnP6mp1FZqSyL4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=PdEIV6iF; arc=none smtp.client-ip=209.85.218.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PdEIV6iF" Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-a9a156513a1so343862166b.0; Sat, 19 Oct 2024 00:11:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729321861; x=1729926661; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GG/8+pJMCIxCghz+y+ZE8tT8LiRET7/nFHMIKLEQQWY=; b=PdEIV6iFjHK0w1sx458SpdVHzHJDGDPJ1/HtQBbojxfa8WGK/Njrs3PJP1AkPJnSIU k7GZYL8jxdt8uWF5qngNJ5zjubL8OQGP7YXOCTBD58J5O93X3cjm+xOWABBEs6d4lVjf N+kVTldhuxKXL3Xz9E824whi5/7EgwUn7mE55zyojrO4AiOxxSo7K1EU4PC4SE4/qoNZ cunEIaJL/hmTqW7z1sagOIjc0xk6hOXLlwPBioknjOgytxm1tSm7myMmz5AsEfsuYgP1 7gFBVcjsUAJ3QYJvHK3K5dIyCLQThw0D3IOYim4wxip+vBDuPv8JoLClD9FWuKTptOYb 1ufQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729321861; x=1729926661; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GG/8+pJMCIxCghz+y+ZE8tT8LiRET7/nFHMIKLEQQWY=; b=hOCnax7i/jmEjrmmoCBsYEKfrQ8vvhan5HvHF5qqqf0dzOReQ1zwZGf3WwisteRXv/ EbftNmKgOObs2tcq1SfZcBlpQhvLNyBbAnbx+NuwQNT8IrDmflkeYjzmzn8cttDfmSQo B9ofD4bCUBH5DmK98UvRDn9hXxCHq1+Ke0ie5+BP5ZgqB8s8mnloxmWlNIm2R47AlnPv UEaXn8mbEU5JdBxqGPKolsSLSK4zTj+YRBODYe4H5jD8SQ6S7tD3Mztsslq3Qg3Z79Ue 15uKUN5WcgyHDo6Dpk9YeiggSfuUYt/HmgKVrU0NxI8CgqIphAqeO5LHsnUhsEwhZPiN Xk5A== X-Forwarded-Encrypted: i=1; AJvYcCVineE/CUcrAg+SJTOyKGgC6h2J0eEkEKUZkJkeG5xuTyCOfAeAKEDwUo0A5NtWE6M6moVxCLJ2Fc+OvA==@vger.kernel.org, AJvYcCX0rNVte4te189F+n9/lSoR15WjnFmrMbi7zKByk2DE1wy+ypJKOuwBqyRv6GWHKSB0VM9CC5MpWP+EJwI=@vger.kernel.org X-Gm-Message-State: AOJu0YxikHa6xpkWY9uMWjvOBDC/BZlsJ0X65O3nltMZSnkkoSF5nXPV KDQDCk+RcsK3KbAEiNJqlUVbpdYUf0mTZE+Rqi29VL9iz4hcZX1A X-Google-Smtp-Source: AGHT+IECSdbiR/ajyNE4zm3n4gXVbbAmawVWfageMJCZh4ki/Pj9rC821WEqect75au+xW62YxrajA== X-Received: by 2002:a17:906:c10f:b0:a9a:2158:e9d3 with SMTP id a640c23a62f3a-a9a69b7bacfmr439816466b.35.1729321860928; Sat, 19 Oct 2024 00:11:00 -0700 (PDT) Received: from localhost.localdomain ([79.175.114.8]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a68c27841sm180566666b.192.2024.10.19.00.10.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Oct 2024 00:11:00 -0700 (PDT) From: Aleksandar Rikalo To: Thomas Bogendoerfer Cc: Aleksandar Rikalo , Chao-ying Fu , Daniel Lezcano , Geert Uytterhoeven , Greg Ungerer , Hauke Mehrtens , Ilya Lipnitskiy , Jiaxun Yang , linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, Marc Zyngier , Paul Burton , Peter Zijlstra , Serge Semin , Thomas Gleixner , Tiezhu Yang , Gregory CLEMENT Subject: [PATCH v7 09/12] MIPS: CPS: Boot CPUs in secondary clusters Date: Sat, 19 Oct 2024 09:10:34 +0200 Message-Id: <20241019071037.145314-10-arikalo@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241019071037.145314-1-arikalo@gmail.com> References: <20241019071037.145314-1-arikalo@gmail.com> Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Paul Burton Probe for & boot CPUs (cores & VPs) in secondary clusters (ie. not the cluster that began booting Linux) when they are present in systems with CM 3.5 or higher. Signed-off-by: Paul Burton Signed-off-by: Chao-ying Fu Signed-off-by: Dragan Mladjenovic Signed-off-by: Aleksandar Rikalo Tested-by: Serge Semin --- arch/mips/include/asm/mips-cm.h | 18 +++ arch/mips/include/asm/smp-cps.h | 1 + arch/mips/kernel/mips-cm.c | 4 +- arch/mips/kernel/smp-cps.c | 205 ++++++++++++++++++++++++++++---- 4 files changed, 207 insertions(+), 21 deletions(-) diff --git a/arch/mips/include/asm/mips-cm.h b/arch/mips/include/asm/mips-cm.h index 1e782275850a..4d47163647dd 100644 --- a/arch/mips/include/asm/mips-cm.h +++ b/arch/mips/include/asm/mips-cm.h @@ -255,6 +255,12 @@ GCR_ACCESSOR_RW(32, 0x130, l2_config) GCR_ACCESSOR_RO(32, 0x150, sys_config2) #define CM_GCR_SYS_CONFIG2_MAXVPW GENMASK(3, 0) +/* GCR_L2-RAM_CONFIG - Configuration & status of L2 cache RAMs */ +GCR_ACCESSOR_RW(64, 0x240, l2_ram_config) +#define CM_GCR_L2_RAM_CONFIG_PRESENT BIT(31) +#define CM_GCR_L2_RAM_CONFIG_HCI_DONE BIT(30) +#define CM_GCR_L2_RAM_CONFIG_HCI_SUPPORTED BIT(29) + /* GCR_L2_PFT_CONTROL - Controls hardware L2 prefetching */ GCR_ACCESSOR_RW(32, 0x300, l2_pft_control) #define CM_GCR_L2_PFT_CONTROL_PAGEMASK GENMASK(31, 12) @@ -266,6 +272,18 @@ GCR_ACCESSOR_RW(32, 0x308, l2_pft_control_b) #define CM_GCR_L2_PFT_CONTROL_B_CEN BIT(8) #define CM_GCR_L2_PFT_CONTROL_B_PORTID GENMASK(7, 0) +/* GCR_L2_TAG_ADDR - Access addresses in L2 cache tags */ +GCR_ACCESSOR_RW(64, 0x600, l2_tag_addr) + +/* GCR_L2_TAG_STATE - Access L2 cache tag state */ +GCR_ACCESSOR_RW(64, 0x608, l2_tag_state) + +/* GCR_L2_DATA - Access data in L2 cache lines */ +GCR_ACCESSOR_RW(64, 0x610, l2_data) + +/* GCR_L2_ECC - Access ECC information from L2 cache lines */ +GCR_ACCESSOR_RW(64, 0x618, l2_ecc) + /* GCR_L2SM_COP - L2 cache op state machine control */ GCR_ACCESSOR_RW(32, 0x620, l2sm_cop) #define CM_GCR_L2SM_COP_PRESENT BIT(31) diff --git a/arch/mips/include/asm/smp-cps.h b/arch/mips/include/asm/smp-cps.h index a629e948a6fd..10d3ebd890cb 100644 --- a/arch/mips/include/asm/smp-cps.h +++ b/arch/mips/include/asm/smp-cps.h @@ -23,6 +23,7 @@ struct core_boot_config { }; struct cluster_boot_config { + unsigned long *core_power; struct core_boot_config *core_config; }; diff --git a/arch/mips/kernel/mips-cm.c b/arch/mips/kernel/mips-cm.c index 3eb2cfb893e1..9854bc2b6895 100644 --- a/arch/mips/kernel/mips-cm.c +++ b/arch/mips/kernel/mips-cm.c @@ -308,7 +308,9 @@ void mips_cm_lock_other(unsigned int cluster, unsigned int core, FIELD_PREP(CM3_GCR_Cx_OTHER_VP, vp); if (cm_rev >= CM_REV_CM3_5) { - val |= CM_GCR_Cx_OTHER_CLUSTER_EN; + if (cluster != cpu_cluster(¤t_cpu_data)) + val |= CM_GCR_Cx_OTHER_CLUSTER_EN; + val |= CM_GCR_Cx_OTHER_GIC_EN; val |= FIELD_PREP(CM_GCR_Cx_OTHER_CLUSTER, cluster); val |= FIELD_PREP(CM_GCR_Cx_OTHER_BLOCK, block); } else { diff --git a/arch/mips/kernel/smp-cps.c b/arch/mips/kernel/smp-cps.c index f71e2bb58318..4f344c890a23 100644 --- a/arch/mips/kernel/smp-cps.c +++ b/arch/mips/kernel/smp-cps.c @@ -36,12 +36,56 @@ enum label_id { UASM_L_LA(_not_nmi) -static DECLARE_BITMAP(core_power, NR_CPUS); static uint32_t core_entry_reg; static phys_addr_t cps_vec_pa; struct cluster_boot_config *mips_cps_cluster_bootcfg; +static void power_up_other_cluster(unsigned int cluster) +{ + u32 stat, seq_state; + unsigned int timeout; + + mips_cm_lock_other(cluster, CM_GCR_Cx_OTHER_CORE_CM, 0, + CM_GCR_Cx_OTHER_BLOCK_LOCAL); + stat = read_cpc_co_stat_conf(); + mips_cm_unlock_other(); + + seq_state = stat & CPC_Cx_STAT_CONF_SEQSTATE; + seq_state >>= __ffs(CPC_Cx_STAT_CONF_SEQSTATE); + if (seq_state == CPC_Cx_STAT_CONF_SEQSTATE_U5) + return; + + /* Set endianness & power up the CM */ + mips_cm_lock_other(cluster, 0, 0, CM_GCR_Cx_OTHER_BLOCK_GLOBAL); + write_cpc_redir_sys_config(IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)); + write_cpc_redir_pwrup_ctl(1); + mips_cm_unlock_other(); + + /* Wait for the CM to start up */ + timeout = 1000; + mips_cm_lock_other(cluster, CM_GCR_Cx_OTHER_CORE_CM, 0, + CM_GCR_Cx_OTHER_BLOCK_LOCAL); + while (1) { + stat = read_cpc_co_stat_conf(); + seq_state = stat & CPC_Cx_STAT_CONF_SEQSTATE; + seq_state >>= __ffs(CPC_Cx_STAT_CONF_SEQSTATE); + if (seq_state == CPC_Cx_STAT_CONF_SEQSTATE_U5) + break; + + if (timeout) { + mdelay(1); + timeout--; + } else { + pr_warn("Waiting for cluster %u CM to power up... STAT_CONF=0x%x\n", + cluster, stat); + mdelay(1000); + } + } + + mips_cm_unlock_other(); +} + static unsigned __init core_vpe_count(unsigned int cluster, unsigned core) { return min(smp_max_threads, mips_cps_numvps(cluster, core)); @@ -152,6 +196,9 @@ static void __init cps_smp_setup(void) pr_cont(","); pr_cont("{"); + if (mips_cm_revision() >= CM_REV_CM3_5) + power_up_other_cluster(cl); + ncores = mips_cps_numcores(cl); for (c = 0; c < ncores; c++) { core_vpes = core_vpe_count(cl, c); @@ -179,8 +226,8 @@ static void __init cps_smp_setup(void) /* Indicate present CPUs (CPU being synonymous with VPE) */ for (v = 0; v < min_t(unsigned, nvpes, NR_CPUS); v++) { - set_cpu_possible(v, cpu_cluster(&cpu_data[v]) == 0); - set_cpu_present(v, cpu_cluster(&cpu_data[v]) == 0); + set_cpu_possible(v, true); + set_cpu_present(v, true); __cpu_number_map[v] = v; __cpu_logical_map[v] = v; } @@ -188,9 +235,6 @@ static void __init cps_smp_setup(void) /* Set a coherent default CCA (CWB) */ change_c0_config(CONF_CM_CMASK, 0x5); - /* Core 0 is powered up (we're running on it) */ - bitmap_set(core_power, 0, 1); - /* Initialise core 0 */ mips_cps_core_init(); @@ -272,6 +316,10 @@ static void __init cps_prepare_cpus(unsigned int max_cpus) goto err_out; mips_cps_cluster_bootcfg[cl].core_config = core_bootcfg; + mips_cps_cluster_bootcfg[cl].core_power = + kcalloc(BITS_TO_LONGS(ncores), sizeof(unsigned long), + GFP_KERNEL); + /* Allocate VPE boot configuration structs */ for (c = 0; c < ncores; c++) { core_vpes = core_vpe_count(cl, c); @@ -283,11 +331,12 @@ static void __init cps_prepare_cpus(unsigned int max_cpus) } } - /* Mark this CPU as booted */ + /* Mark this CPU as powered up & booted */ cl = cpu_cluster(¤t_cpu_data); c = cpu_core(¤t_cpu_data); cluster_bootcfg = &mips_cps_cluster_bootcfg[cl]; core_bootcfg = &cluster_bootcfg->core_config[c]; + bitmap_set(cluster_bootcfg->core_power, cpu_core(¤t_cpu_data), 1); atomic_set(&core_bootcfg->vpe_mask, 1 << cpu_vpe_id(¤t_cpu_data)); return; @@ -315,13 +364,118 @@ static void __init cps_prepare_cpus(unsigned int max_cpus) } } -static void boot_core(unsigned int core, unsigned int vpe_id) +static void init_cluster_l2(void) { - u32 stat, seq_state; - unsigned timeout; + u32 l2_cfg, l2sm_cop, result; + + while (1) { + l2_cfg = read_gcr_redir_l2_ram_config(); + + /* If HCI is not supported, use the state machine below */ + if (!(l2_cfg & CM_GCR_L2_RAM_CONFIG_PRESENT)) + break; + if (!(l2_cfg & CM_GCR_L2_RAM_CONFIG_HCI_SUPPORTED)) + break; + + /* If the HCI_DONE bit is set, we're finished */ + if (l2_cfg & CM_GCR_L2_RAM_CONFIG_HCI_DONE) + return; + } + + l2sm_cop = read_gcr_redir_l2sm_cop(); + if (WARN(!(l2sm_cop & CM_GCR_L2SM_COP_PRESENT), + "L2 init not supported on this system yet")) + return; + + /* Clear L2 tag registers */ + write_gcr_redir_l2_tag_state(0); + write_gcr_redir_l2_ecc(0); + + /* Ensure the L2 tag writes complete before the state machine starts */ + mb(); + + /* Wait for the L2 state machine to be idle */ + do { + l2sm_cop = read_gcr_redir_l2sm_cop(); + } while (l2sm_cop & CM_GCR_L2SM_COP_RUNNING); + + /* Start a store tag operation */ + l2sm_cop = CM_GCR_L2SM_COP_TYPE_IDX_STORETAG; + l2sm_cop <<= __ffs(CM_GCR_L2SM_COP_TYPE); + l2sm_cop |= CM_GCR_L2SM_COP_CMD_START; + write_gcr_redir_l2sm_cop(l2sm_cop); + + /* Ensure the state machine starts before we poll for completion */ + mb(); + + /* Wait for the operation to be complete */ + do { + l2sm_cop = read_gcr_redir_l2sm_cop(); + result = l2sm_cop & CM_GCR_L2SM_COP_RESULT; + result >>= __ffs(CM_GCR_L2SM_COP_RESULT); + } while (!result); + + WARN(result != CM_GCR_L2SM_COP_RESULT_DONE_OK, + "L2 state machine failed cache init with error %u\n", result); +} + +static void boot_core(unsigned int cluster, unsigned int core, + unsigned int vpe_id) +{ + struct cluster_boot_config *cluster_cfg; + u32 access, stat, seq_state; + unsigned int timeout, ncores; + + cluster_cfg = &mips_cps_cluster_bootcfg[cluster]; + ncores = mips_cps_numcores(cluster); + + if ((cluster != cpu_cluster(¤t_cpu_data)) && + bitmap_empty(cluster_cfg->core_power, ncores)) { + power_up_other_cluster(cluster); + + mips_cm_lock_other(cluster, core, 0, + CM_GCR_Cx_OTHER_BLOCK_GLOBAL); + + /* Ensure cluster GCRs are where we expect */ + write_gcr_redir_base(read_gcr_base()); + write_gcr_redir_cpc_base(read_gcr_cpc_base()); + write_gcr_redir_gic_base(read_gcr_gic_base()); + + init_cluster_l2(); + + /* Mirror L2 configuration */ + write_gcr_redir_l2_only_sync_base(read_gcr_l2_only_sync_base()); + write_gcr_redir_l2_pft_control(read_gcr_l2_pft_control()); + write_gcr_redir_l2_pft_control_b(read_gcr_l2_pft_control_b()); + + /* Mirror ECC/parity setup */ + write_gcr_redir_err_control(read_gcr_err_control()); + + /* Set BEV base */ + write_gcr_redir_bev_base(core_entry_reg); + + mips_cm_unlock_other(); + } + + if (cluster != cpu_cluster(¤t_cpu_data)) { + mips_cm_lock_other(cluster, core, 0, + CM_GCR_Cx_OTHER_BLOCK_GLOBAL); + + /* Ensure the core can access the GCRs */ + access = read_gcr_redir_access(); + access |= BIT(core); + write_gcr_redir_access(access); + + mips_cm_unlock_other(); + } else { + /* Ensure the core can access the GCRs */ + access = read_gcr_access(); + access |= BIT(core); + write_gcr_access(access); + } /* Select the appropriate core */ - mips_cm_lock_other(0, core, 0, CM_GCR_Cx_OTHER_BLOCK_LOCAL); + mips_cm_lock_other(cluster, core, 0, CM_GCR_Cx_OTHER_BLOCK_LOCAL); /* Set its reset vector */ write_gcr_co_reset_base(core_entry_reg); @@ -387,7 +541,17 @@ static void boot_core(unsigned int core, unsigned int vpe_id) mips_cm_unlock_other(); /* The core is now powered up */ - bitmap_set(core_power, core, 1); + bitmap_set(cluster_cfg->core_power, core, 1); + + /* + * Restore CM_PWRUP=0 so that the CM can power down if all the cores in + * the cluster do (eg. if they're all removed via hotplug. + */ + if (mips_cm_revision() >= CM_REV_CM3_5) { + mips_cm_lock_other(cluster, 0, 0, CM_GCR_Cx_OTHER_BLOCK_GLOBAL); + write_cpc_redir_pwrup_ctl(0); + mips_cm_unlock_other(); + } } static void remote_vpe_boot(void *dummy) @@ -413,10 +577,6 @@ static int cps_boot_secondary(int cpu, struct task_struct *idle) unsigned int remote; int err; - /* We don't yet support booting CPUs in other clusters */ - if (cpu_cluster(&cpu_data[cpu]) != cpu_cluster(&raw_current_cpu_data)) - return -ENOSYS; - vpe_cfg->pc = (unsigned long)&smp_bootstrap; vpe_cfg->sp = __KSTK_TOS(idle); vpe_cfg->gp = (unsigned long)task_thread_info(idle); @@ -425,14 +585,15 @@ static int cps_boot_secondary(int cpu, struct task_struct *idle) preempt_disable(); - if (!test_bit(core, core_power)) { + if (!test_bit(core, cluster_cfg->core_power)) { /* Boot a VPE on a powered down core */ - boot_core(core, vpe_id); + boot_core(cluster, core, vpe_id); goto out; } if (cpu_has_vp) { - mips_cm_lock_other(0, core, vpe_id, CM_GCR_Cx_OTHER_BLOCK_LOCAL); + mips_cm_lock_other(cluster, core, vpe_id, + CM_GCR_Cx_OTHER_BLOCK_LOCAL); write_gcr_co_reset_base(core_entry_reg); mips_cm_unlock_other(); } @@ -639,11 +800,15 @@ static void cps_cpu_die(unsigned int cpu) { } static void cps_cleanup_dead_cpu(unsigned cpu) { + unsigned int cluster = cpu_cluster(&cpu_data[cpu]); unsigned core = cpu_core(&cpu_data[cpu]); unsigned int vpe_id = cpu_vpe_id(&cpu_data[cpu]); ktime_t fail_time; unsigned stat; int err; + struct cluster_boot_config *cluster_cfg; + + cluster_cfg = &mips_cps_cluster_bootcfg[cluster]; /* * Now wait for the CPU to actually offline. Without doing this that @@ -695,7 +860,7 @@ static void cps_cleanup_dead_cpu(unsigned cpu) } while (1); /* Indicate the core is powered off */ - bitmap_clear(core_power, core, 1); + bitmap_clear(cluster_cfg->core_power, core, 1); } else if (cpu_has_mipsmt) { /* * Have a CPU with access to the offlined CPUs registers wait From patchwork Sat Oct 19 07:10:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandar Rikalo X-Patchwork-Id: 13842583 Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D28741DFE0F; Sat, 19 Oct 2024 07:11:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729321866; cv=none; b=ibQTMeJNeaXNF/eLM0PLrFtW3S7CKzjzeqYneukA+4KUoLokwxr4D8N/2sc5dKWttmlH+Hm5qLIhS5IjoVZV2MgnyMvyd+kR58KsuX+cayvBpvUzLEAsCes3pgMCUO8lDtasLblDRzCySf/hZWInYHeg2IDrhldlzKtCRKAUPRE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729321866; c=relaxed/simple; bh=K0HzhA8alacM4aGMjW+d/bogSNMW+xZy6jmFTQZC5Xw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YaIenvX3DRH+VsoZ/kZ8wpJRA+hAG2idz9W67CNU1rUR41guxXo/whgPHZGI1ofcHSYzwcJoss/MuLTroJs6j44lb1cyJXaYI9LOYmRaJ4kVKjGmkEBO6vR0i/6RVhCnIw9ZP2ZYV/vwdVs1T3vJVxoORfyYszSQ6SJjwIpszHE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Me3cCNX8; arc=none smtp.client-ip=209.85.218.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Me3cCNX8" Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-a9a3dc089d8so360862766b.3; Sat, 19 Oct 2024 00:11:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729321863; x=1729926663; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jAZgXuitpoye0Y0FrsnQrLaDYihSlv95JKJZ5ie56qU=; b=Me3cCNX87iHmzm+7Q8jpu04CLg1uUoFN9Fge5SfSkAsC2VP+N0weE6yU0+l2tNkbNY X7ZkoKiKg++MFu8b+TMJs0QcNv9ddwvI9lsd9bDTXdwVybMeBW/Hp2J8DjvWvLksRNQ9 mMep7v6Y4upnX825Z3k02P2ed4kzfZYX9d8IGIK8IN3e2r7rQqJP04HNAOIvtU3HFfJ4 UMYKhUVzqbczDiZPhDOw8Nc3H4aWn8omve6i535IvjntqOibbh+M9g4RL72iFOCyEEmo gYkOBYhBWC/oo8W7RusHwKd2SaiqR6jwKN3jvIn7NOpnY+T+7VqY7HvuLo+1l4/3tQ0Q iajg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729321863; x=1729926663; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jAZgXuitpoye0Y0FrsnQrLaDYihSlv95JKJZ5ie56qU=; b=H42/6SEkbxM0OCvaqgIXCTRlwJFHVWgZB/v7eHKaliWsHwnK/izfn6AojllPa5w5kj P97Bz+7or4Xpd7w+1Etf4XR6lZ9W1+J4ZJxGgskVqQjc30kl+ZkWNcCFkMGx4tofUg6u /NJEs9VSGL55EeLhTCgvq3OPa0ypcWW++3XGCAdNex7WtOYstgJ4Pqk2yXokVhlchwIZ QiOP2iy5ZS8U3TtStkI7t/nsPgFg8TXUtm1aQJPBaVMNePFjK+OV8o/Sk6VUxdDybhh/ Ky2xCoWMbOhHY1jJ8EJE+eIj7JJAu/ASYa6+zOCTQ0E8DyAoLssI73fuIKHuB/blUzcS L1Fg== X-Forwarded-Encrypted: i=1; AJvYcCWJblsRhrxTdlX79dgXV3FufA4dgwg6OPHkMxVUXEWl/Vg92RMYwioHmuRU2XGIBZfoTRIXJy7zVdWQoqs=@vger.kernel.org, AJvYcCX3I4DdVLKoRbyT9sysOFGQI0q7tYMGatqpFl18JrtU+5Gm+V/d3Lg/CdXauiW6PD7nUZUoUtLvwFuzJw==@vger.kernel.org X-Gm-Message-State: AOJu0YzLXLMIInusqhWowvgEfqFxHKeuvJxnRbuKzU29lGLRswcKtUGp LQIgDuPbHrCzwq0yVUXRO0ny1MKBgDYo5GeCmtvwzSpPxVCA4xut X-Google-Smtp-Source: AGHT+IEybtMSJJTB1GlywNRQRpKklzRj1/3/mMkf52VBoXC32u7TNHFjKT71CJaNokZhu8eUiNJDKA== X-Received: by 2002:a17:907:7211:b0:a99:55ab:b666 with SMTP id a640c23a62f3a-a9a69a80a16mr479865566b.34.1729321862735; Sat, 19 Oct 2024 00:11:02 -0700 (PDT) Received: from localhost.localdomain ([79.175.114.8]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a68c27841sm180566666b.192.2024.10.19.00.11.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Oct 2024 00:11:02 -0700 (PDT) From: Aleksandar Rikalo To: Thomas Bogendoerfer Cc: Aleksandar Rikalo , Chao-ying Fu , Daniel Lezcano , Geert Uytterhoeven , Greg Ungerer , Hauke Mehrtens , Ilya Lipnitskiy , Jiaxun Yang , linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, Marc Zyngier , Paul Burton , Peter Zijlstra , Serge Semin , Thomas Gleixner , Tiezhu Yang , Gregory CLEMENT Subject: [PATCH v7 10/12] dt-bindings: mips: cpu: Add property for broken HCI information Date: Sat, 19 Oct 2024 09:10:35 +0200 Message-Id: <20241019071037.145314-11-arikalo@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241019071037.145314-1-arikalo@gmail.com> References: <20241019071037.145314-1-arikalo@gmail.com> Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Gregory CLEMENT Some CM3.5 reports show that Hardware Cache Initialization is complete, but in reality it's not the case. They also incorrectly indicate that Hardware Cache Initialization is supported. This optional property allows warning about this broken feature that cannot be detected at runtime. Signed-off-by: Gregory CLEMENT Signed-off-by: Aleksandar Rikalo --- Documentation/devicetree/bindings/mips/cpus.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/mips/cpus.yaml b/Documentation/devicetree/bindings/mips/cpus.yaml index a85137add668..57e93c07ab1b 100644 --- a/Documentation/devicetree/bindings/mips/cpus.yaml +++ b/Documentation/devicetree/bindings/mips/cpus.yaml @@ -47,6 +47,12 @@ properties: clocks: maxItems: 1 + cm3-l2-config-hci-broken: + type: boolean + description: + If present, indicates that the HCI (Hardware Cache Initialization) + information for the L2 cache in multi-cluster configuration is broken. + device_type: true allOf: From patchwork Sat Oct 19 07:10:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandar Rikalo X-Patchwork-Id: 13842584 Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8193C1DFE31; Sat, 19 Oct 2024 07:11:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729321868; cv=none; b=egmFR5DtX9cHDc4AdA+RYCBs0wpJGY8+iZol13dCss995nUzfM7HIjUuurbRr/ogoBJrBJw7Pt2MLt/j20rUK2+gfRYp6SG3XCGQcUq83lYfXQNNbP50lzE5f381JJa/A+OPRd8Yqtvz2jZbhFtQ220Ahc46kcb45owxCtyjNjY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729321868; c=relaxed/simple; bh=UYR13zTpnsVdjyChblEe8JTdypBUsbR67lFCXkmUjXQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Gk2f50yb6PnbJiF6YwQ6oIVFZqjvzuX0tb7kQQgNRICRKDO+8BNh5GcuITjdLfSrxbHSe8DSGfDd5n7VY7rJoemY2wt4Xdqf6fJ8tPSVnc9Nk2U6BVPJM0tHPLuJMK+izRyvjsWbYz/MalA18PXyBTiuSN3sHWqIhnX4J7LiRJA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=mH0Fd7Po; arc=none smtp.client-ip=209.85.208.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mH0Fd7Po" Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-5c948c41edeso3055681a12.1; Sat, 19 Oct 2024 00:11:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729321865; x=1729926665; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MU2+3TuVWKSNcAj+UxUj5vL8IK8tlhYUuvDJAWOUIuo=; b=mH0Fd7PobWcqMud7m7z+QTbjJ+cQtmdTHSEJnCNx5/+3axXGAUc2JyNE2+0w4NEj3E QIR+FspwAn9sFpHuKExK760QRKC04bAZGrBPsiBjyUKG8VgdRBlNA9wrssYNxsiQMPtX VX0ghwsse3LP+paBU01eikjRX9HPOwuR3eKagRs5queHmJJnfzB05P11tWw3LF+4fW4+ oRBO32wFig1l/dJrcoq6wY/D0KR0pe3rj1SKFZBje4hvzafmZDlxl376DBf+bTadJGYi gehYGtPtLNii8odZP2VryTDkL1dZ2CGrXRgFNRaO9UGnUndlL4o0oAszFEIVJkVn/uYU SW8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729321865; x=1729926665; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MU2+3TuVWKSNcAj+UxUj5vL8IK8tlhYUuvDJAWOUIuo=; b=GMDAqptZCue7woMHp/3/ilc5oTJ8AEGGrAxLa1L+xKixO8QJyIeXUCVnwIIUJxaJJd I0Dk1DIjg09HwKbbuNUK9KQD5yV8wH2ApHmpigNGDsD5qCJCah+mgl7z+gAJ4TyLYLJW NXK5YHfNg7Y1VEK8DoCF7JcdsYYAD0czSf/UXjRki/JJaMocTOTSDP9bzb7bZcFAMnkC 4GrTEoKh269payXc6iKkKpuiLgB9Co4FllbC2Yp7QMpQlrf+n7Yk7omg1ilhUXeDJ7qC rckCZ0SS6Xv1aKia/6U88UYahnTP4TN0FgSTwnzLhqXZCGdf+al3FmmFSZlXpxYBrHhx 6nAg== X-Forwarded-Encrypted: i=1; AJvYcCVvYx9SC/5FbSRiaWBHVMOUgcigkwmUwOdzh7QSoq43BqrDrwgOnKmK83BM1abr3HQe6gjXpvAG+ZahKJQ=@vger.kernel.org, AJvYcCXjhKudUcno+0uE9ZgdNibovWCwngewL4P/JQAzzD9dnA0cMTdQHGXBi8Jt6HE+B/3gAX8SQOv34EeRKw==@vger.kernel.org X-Gm-Message-State: AOJu0YynH82dW04Ktr6c7msNN6P0COymClJtZR2NOwxYQX5h4eKogQ3O VRwVltKXB0OnjvvgDF3jOLXvTXIS151qr7ArgzIgzEmK8s+fGdIJ X-Google-Smtp-Source: AGHT+IFXMiII9k2Ah/EX3izTyqFCLgJcV85Yfj0DKVvorEzpjcpOTu8ppf3hVL1oWKEx3Wo/VF16FA== X-Received: by 2002:a17:907:3f9e:b0:a99:c075:6592 with SMTP id a640c23a62f3a-a9a69cd301fmr465581266b.56.1729321864593; Sat, 19 Oct 2024 00:11:04 -0700 (PDT) Received: from localhost.localdomain ([79.175.114.8]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a68c27841sm180566666b.192.2024.10.19.00.11.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Oct 2024 00:11:04 -0700 (PDT) From: Aleksandar Rikalo To: Thomas Bogendoerfer Cc: Aleksandar Rikalo , Chao-ying Fu , Daniel Lezcano , Geert Uytterhoeven , Greg Ungerer , Hauke Mehrtens , Ilya Lipnitskiy , Jiaxun Yang , linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, Marc Zyngier , Paul Burton , Peter Zijlstra , Serge Semin , Thomas Gleixner , Tiezhu Yang , Gregory CLEMENT Subject: [PATCH v7 11/12] MIPS: CPS: Support broken HCI for multicluster Date: Sat, 19 Oct 2024 09:10:36 +0200 Message-Id: <20241019071037.145314-12-arikalo@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241019071037.145314-1-arikalo@gmail.com> References: <20241019071037.145314-1-arikalo@gmail.com> Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Gregory CLEMENT Some CM3.5 devices incorrectly report that hardware cache initialization has completed, and also claim to support hardware cache initialization when they don't actually do so. This commit fixes this issue by retrieving the correct information from the device tree and allowing the system to bypass the hardware cache initialization step. Instead, it relies on manual operation. As a result, multi-user support is now possible for these CPUs. Signed-off-by: Gregory CLEMENT Signed-off-by: Aleksandar Rikalo --- arch/mips/kernel/smp-cps.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/arch/mips/kernel/smp-cps.c b/arch/mips/kernel/smp-cps.c index 4f344c890a23..265cf52c0dd1 100644 --- a/arch/mips/kernel/smp-cps.c +++ b/arch/mips/kernel/smp-cps.c @@ -39,6 +39,7 @@ UASM_L_LA(_not_nmi) static uint32_t core_entry_reg; static phys_addr_t cps_vec_pa; +static bool l2_hci_broken; struct cluster_boot_config *mips_cps_cluster_bootcfg; static void power_up_other_cluster(unsigned int cluster) @@ -254,6 +255,22 @@ static void __init cps_smp_setup(void) #endif /* CONFIG_MIPS_MT_FPAFF */ } +static void __init check_hci_quirk(void) +{ + struct device_node *np; + + np = of_cpu_device_node_get(0); + if (!np) { + pr_debug("%s: No cpu node in the device tree\n", __func__); + return; + } + + if (of_property_read_bool(np, "cm3-l2-config-hci-broken")) { + pr_info("HCI (Hardware Cache Init for the L2 cache) in GCR_L2_RAM_CONFIG from the CM3 is broken"); + l2_hci_broken = true; + } +} + static void __init cps_prepare_cpus(unsigned int max_cpus) { unsigned int nclusters, ncores, core_vpes, c, cl, cca; @@ -307,6 +324,9 @@ static void __init cps_prepare_cpus(unsigned int max_cpus) sizeof(*mips_cps_cluster_bootcfg), GFP_KERNEL); + if (nclusters > 1) + check_hci_quirk(); + for (cl = 0; cl < nclusters; cl++) { /* Allocate core boot configuration structs */ ncores = mips_cps_numcores(cl); @@ -368,7 +388,7 @@ static void init_cluster_l2(void) { u32 l2_cfg, l2sm_cop, result; - while (1) { + while (!l2_hci_broken) { l2_cfg = read_gcr_redir_l2_ram_config(); /* If HCI is not supported, use the state machine below */ From patchwork Sat Oct 19 07:10:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandar Rikalo X-Patchwork-Id: 13842585 Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41B921E00B9; Sat, 19 Oct 2024 07:11:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729321870; cv=none; b=ftYBLVYsARhavZ2ZMQ/e4UxFTWIWcymaQpjke7E4rtNfoC2mvEeNIPqZoBUunr6RyW/tl9Inh/SND3rXkjIrEMRKCTRtAh0iyZQWA6CFF/OjWKakN3Z+0d8DTki2LdlqbYx6MWl3LrY5w0UuULALf+YOJALBrb99ZqRMaU0xH/M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729321870; c=relaxed/simple; bh=8Rdvbq2qfDE7PP1NFqb9ER6XI8O/ncdkDxKnGaV5Ua8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=n3FkZuXxlt0YWBJ3LAVw/cQybp8GYiH4m8zIgHdMCCs6RIjdApkNcYFb24E7KbOdaS/qE8DYbSGsdYFvMqqPo28SfgCobFkCC//h4yt7Z5qgkRvV/c+2uBYz1k4qZ00Hmzg1gyi+yZwfSYeYkUYZdZBEyTyzAfy5kVOdQ8fa9h8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZgJWlyhW; arc=none smtp.client-ip=209.85.218.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZgJWlyhW" Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-a99eb8b607aso277572266b.2; Sat, 19 Oct 2024 00:11:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729321867; x=1729926667; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Kzy3+/mox2Buapv8j2OU8DMyaGI/RgG1tSMX4+L61bY=; b=ZgJWlyhWapXA7ILUY8hchK1uhKr8IzNYzMc9PLWrZUn25RKHV888KfDK48QSrP8ojP 1qs/83vxIMTo5JIdjU4gZcJTEocOT81g9tj+WgS71Tkm++bwj/d4rfIVF8NQmM3B5qpP PMTwdLb5L96O2JgNyijyQoVy456GACFz2mg7DIjgrLo7imAKr7R17k6LGS/WcGLNswom bidRQ9BMJHeG0PAI0/UL3QuJ+rpnDz+QYX8qQiUPGVC60xOSfjsQRBGvHo9rJlouUpwp 9Hi51dkZE8Bk+NMjI5sqRz3Tvxh4dodizAJiUV3UMTnl97KsFAShJJ1JD80yySsCLvZj YV9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729321867; x=1729926667; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Kzy3+/mox2Buapv8j2OU8DMyaGI/RgG1tSMX4+L61bY=; b=dPD/JOJ7GmTvJAV69wLr/hIS0X5wMYMU6g8BEcN4H6X4hJZkK1dQnLxI82xk73Ud2e c5HPEjMJKRqIYuDrbjyi4j1OQ4V4Y2QIM5IIAXgRAjaBxeBt/PMrDoYCLErP1T2kwpM1 +9GdWXSuvpCM4NpNZaR9Fbp4YoukJ9GOjrFUoWGIWxUKmSCH9BgFAuIOjnMheLCrZ84B crplunZdDRYkXqM9Dw78++O5dC6UAPW9f/vSS6d9TcB0NzlB+VF8aSc3CJ794MuxzoMT gedN7pDXVbeuxZsEr9c2m/VJX0DKA/qY1WIwDTzLx9/DJbMzJk3jzBe8NsCKgZ11S4n/ RVMw== X-Forwarded-Encrypted: i=1; AJvYcCWHc2zJlixGyaoP1JS3YgarTcIl5wP1NeVB3ouBhg1m+qNP5V1007dJfz3ez3v7yR8TWSqdcv4cJh6K9pc=@vger.kernel.org, AJvYcCWZND2WGmQ4+0LuJvAe5oPjDmtYTm39KYZUex5evzIHbADUSbEa8ha5SOIBztTcH6oD2pXUWyvnNMIaiw==@vger.kernel.org X-Gm-Message-State: AOJu0YyGS7c7GmsBw7Z5RIIFgvBiFai95tdyVqHQgP1ANYZ668mD71+Z xPNc3WVw/tb1x7W5mda2MKJGSsuVgy/ECcOoXXsg7XyG/yegV9+q X-Google-Smtp-Source: AGHT+IGZIRwgVgg1BdPksrFMh32OAbnzMG5ExBavQuLgkOmWN/ZJyj1zGihqDyRijK+wUugTMmXfag== X-Received: by 2002:a17:906:730e:b0:a99:e939:d69e with SMTP id a640c23a62f3a-a9a69c67624mr373039666b.51.1729321866457; Sat, 19 Oct 2024 00:11:06 -0700 (PDT) Received: from localhost.localdomain ([79.175.114.8]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a68c27841sm180566666b.192.2024.10.19.00.11.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Oct 2024 00:11:05 -0700 (PDT) From: Aleksandar Rikalo To: Thomas Bogendoerfer Cc: Aleksandar Rikalo , Chao-ying Fu , Daniel Lezcano , Geert Uytterhoeven , Greg Ungerer , Hauke Mehrtens , Ilya Lipnitskiy , Jiaxun Yang , linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, Marc Zyngier , Paul Burton , Peter Zijlstra , Serge Semin , Thomas Gleixner , Tiezhu Yang , Gregory CLEMENT Subject: [PATCH v7 12/12] MIPS: mobileye: dts: eyeq6h: Enable cluster support Date: Sat, 19 Oct 2024 09:10:37 +0200 Message-Id: <20241019071037.145314-13-arikalo@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241019071037.145314-1-arikalo@gmail.com> References: <20241019071037.145314-1-arikalo@gmail.com> Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Gregory CLEMENT The CM3.5 device used in EyeQ6H SoCs incorrectly reports the status for Hardware Cache Initialization (HCI). This commit adds a property to acknowledge this issue, which enables the use of the second CPU cluster. Signed-off-by: Gregory CLEMENT Signed-off-by: Aleksandar Rikalo --- arch/mips/boot/dts/mobileye/eyeq6h.dtsi | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/mips/boot/dts/mobileye/eyeq6h.dtsi b/arch/mips/boot/dts/mobileye/eyeq6h.dtsi index 1db3c3cda2e3..4ea85dfd4eed 100644 --- a/arch/mips/boot/dts/mobileye/eyeq6h.dtsi +++ b/arch/mips/boot/dts/mobileye/eyeq6h.dtsi @@ -18,6 +18,7 @@ cpu@0 { compatible = "img,i6500"; reg = <0>; clocks = <&occ_cpu>; + cm3-l2-config-hci-broken; }; };