From patchwork Mon Feb 19 18:58:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 203219 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1475255dyc; Mon, 19 Feb 2024 10:59:32 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXbmvdzt6j/3vXR2v8sDUy8XRyFx0x61wx/hU6hUgJm6KUdjkaBqplp9eyIpzS0Rm4go6jt9ORDRGwyMeO1OWgllet0ug== X-Google-Smtp-Source: AGHT+IFYg30QJArHd4Pbpa1r9qu8XqIqNqe7Gh0RqTLRN3BXbJRhEo2ARKQYlx8mZkJultVqZ1rX X-Received: by 2002:a17:906:e58:b0:a3e:dfce:dae8 with SMTP id q24-20020a1709060e5800b00a3edfcedae8mr628400eji.42.1708369172329; Mon, 19 Feb 2024 10:59:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708369172; cv=pass; d=google.com; s=arc-20160816; b=QmFS7JZzUoBkJ4iaigBVnhNt+njA9PmXQPxl4ws3kiTKVF8v1d2lTOhNCuNAk1og/E BWsRmzo/NkcDn3DGn3SV6wWnbL/1W5ShOkabL0TFK89oXsOrOayCHmtNPpuuHyFZMZPD Be8UJfyt6pD8Qfft8BtA0b4PP463ikTR/k1ldcGAxuXbRTK9UnFxZwL8H6cdd2FMfzRT rd2g0khfMVZUhWwZl7/xb+EkJaL9OmtZ2/rDMbEgnY2cVhNaPp3OWPpn6e94uHbi9pKR +OVIdcDkEKb2v6az4QEbYdU1xALg/q5jlsqFoVlRCC2L9pXQbTghAb7PRbWGz1EfLN1s 8rgQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=n0uvz70joVA5h7nCkx+6qjmdsOAE7FpYRNnHlS3lny0=; fh=fgV4Kp0ZgGkINw9PbGnSyYl5n9Uaijr/GJFF1V5tx/4=; b=EfGWqopDiih41zP5+kpA1/61jRKYKAHtTfDK3WWdjrBrCvg2+W9wCzCxhk0SMmeN1X KnDD6RBv+ciCeXX27RF0XO4RTwO1MLGxHzy3LmkHd3EJVE3dV6/ZMfqD/V8DY6ORlSs+ 26wLBbXck5G9ocfzu8XJSSl40Kk4Y65+Xqa0Zpwt8cHvSvd19Hpv/TTlpdWlTdbPhVtK vTCUmMRrlypPW5xIp713gbeCUtv3QazbwR8Q498puk0XhN7dLnf/zD39iLqHbGco7tpP pwtKi8L86KYVTpIpWxw1HyqTcVVkOvzdiL6Y+6VmkCnlDky7DR5Qpyn1AP+R26acckKu WHvw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=MRaf230x; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-71848-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71848-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id k16-20020a170906579000b00a3e8a693317si1138729ejq.344.2024.02.19.10.59.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 10:59:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71848-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=MRaf230x; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-71848-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71848-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D24B81F236A7 for ; Mon, 19 Feb 2024 18:59:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CD4314F21B; Mon, 19 Feb 2024 18:58:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="MRaf230x" Received: from out-188.mta0.migadu.com (out-188.mta0.migadu.com [91.218.175.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 87D61487B8 for ; Mon, 19 Feb 2024 18:58:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.188 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708369109; cv=none; b=uQfIsX+wZMS8JLUfh/mZifPGgfRoSgoh4ojjv8bl6QLLb/aK7pkWI9r0/e9ZfYZ67CJn9MK0615jM0oQJqlHgH1d5sROMJhONVjn+Opbkbpo8vsNJ+KaEXUfYnjLmvkmMltc/UYpPxtE/B+WywUZ+xBkTdAqQakO7/fgBN+br8E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708369109; c=relaxed/simple; bh=sQ09ukYCJMs0FVbHxpjJQwqr/OlvaGUdTVWxvm0dbCw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pvAM40z7/Jz4RUdwYOYkGdX96x7duDtQvoXcl2h0kFWn7iE8m176SxFaVdl5lQ/Ir4IhVrh2vDz8JRTCtpmvRDj+NaYNujf4Wz2hbHrHbIClQ4G5mrPHpumGGMcAsO47K662CSQjpOvMldqPs82/b7lku8TvrBU7j1R5EUarkf4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=MRaf230x; arc=none smtp.client-ip=91.218.175.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1708369105; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n0uvz70joVA5h7nCkx+6qjmdsOAE7FpYRNnHlS3lny0=; b=MRaf230xQXz2XUHhNl+qaNg7U148naafFkbpIjvX5ofDIryb/ebMbKl5AfD5yIdB2kC01m TSiy2qQWMMmXuqWaBa+9n70/T2Rb0eTsoKGEIAtME5P0eyHqLqsVN+VLPwaNManRBOUCU+ QyOgXYqz7O7W3v3Lo+/zZnKrDywl9lU= From: Oliver Upton To: Thomas Gleixner Cc: Marc Zyngier , Zenghui Yu , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, Jing Zhang , Oliver Upton Subject: [PATCH 2/3] irqchip/gic-v3-its: Spin off GICv4 init into a separate function Date: Mon, 19 Feb 2024 18:58:07 +0000 Message-ID: <20240219185809.286724-3-oliver.upton@linux.dev> In-Reply-To: <20240219185809.286724-1-oliver.upton@linux.dev> References: <20240219185809.286724-1-oliver.upton@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791354912892986933 X-GMAIL-MSGID: 1791354912892986933 Burying the GICv4 redistributor initialization into the routine for LPIs is a bit confusing, and can lead to sillies where unexpected codepaths may not fully initialize the RD. Hoist it out of its_cpu_init_lpis() into a dedicated function. Signed-off-by: Oliver Upton --- drivers/irqchip/irq-gic-v3-its.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 0022852ce494..63d1743f08cc 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -3173,8 +3173,25 @@ static void its_cpu_init_lpis(void) writel_relaxed(val, rbase + GICR_CTLR); out: - if (gic_rdists->has_vlpis && !gic_rdists->has_rvpeid) { + /* Make sure the GIC has seen the above */ + dsb(sy); + gic_data_rdist()->flags |= RD_LOCAL_LPI_ENABLED; + pr_info("GICv3: CPU%d: using %s LPI pending table @%pa\n", + smp_processor_id(), + gic_data_rdist()->flags & RD_LOCAL_PENDTABLE_PREALLOCATED ? + "reserved" : "allocated", + &paddr); +} + +static void its_cpu_init_vlpis(void) +{ + /* No vLPIs? No problem. */ + if (!gic_rdists->has_vlpis) + return; + + if (!gic_rdists->has_rvpeid) { void __iomem *vlpi_base = gic_data_rdist_vlpi_base(); + u64 val; /* * It's possible for CPU to receive VLPIs before it is @@ -3193,7 +3210,8 @@ static void its_cpu_init_lpis(void) * ancient programming gets left in and has possibility of * corrupting memory. */ - val = its_clear_vpend_valid(vlpi_base, 0, 0); + its_clear_vpend_valid(vlpi_base, 0, 0); + return; } if (allocate_vpe_l1_table()) { @@ -3205,15 +3223,6 @@ static void its_cpu_init_lpis(void) gic_rdists->has_rvpeid = false; gic_rdists->has_vlpis = false; } - - /* Make sure the GIC has seen the above */ - dsb(sy); - gic_data_rdist()->flags |= RD_LOCAL_LPI_ENABLED; - pr_info("GICv3: CPU%d: using %s LPI pending table @%pa\n", - smp_processor_id(), - gic_data_rdist()->flags & RD_LOCAL_PENDTABLE_PREALLOCATED ? - "reserved" : "allocated", - &paddr); } static void its_cpu_init_collection(struct its_node *its) @@ -5265,6 +5274,7 @@ int its_cpu_init(void) return ret; its_cpu_init_lpis(); + its_cpu_init_vlpis(); its_cpu_init_collections(); }