From patchwork Sat Jun 26 02:38:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1497542 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=o6Z1Tub7; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GBdPF29Rcz9sWX for ; Sat, 26 Jun 2021 12:39:29 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4GBdPG0W1vz3c46 for ; Sat, 26 Jun 2021 12:39:30 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=o6Z1Tub7; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::1030; helo=mail-pj1-x1030.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=o6Z1Tub7; dkim-atps=neutral Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4GBdNf5pVwz3bwN for ; Sat, 26 Jun 2021 12:38:58 +1000 (AEST) Received: by mail-pj1-x1030.google.com with SMTP id h23so6488803pjv.2 for ; Fri, 25 Jun 2021 19:38:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xny0hztklULQCK4UozH+BnFszJxQZnYvrHREHvzmX2c=; b=o6Z1Tub7zlwlKTPVFxmxK9eCR7xNp1+Khdo7fX7+/vvp0ENAWGxYzUk1c5Q+bSoWSV 4KV9TU28SnP09XNykszYGJBb5L7CJeqGLMGpBee4F7SMy0z9WalYA0DaDJcBmYSvCu2D vxb760bbbcam5eg8pCkeadpuEX4F+a7yBPfXlB0UgwMCiAlx2Yv87L2TGOUOO02I5rSZ g58JaNgp4NTadybpBiQ/UOVCtHaQGdbOFfTtnG9LVd0W2vG5S5ftm4bN0BzwJw6KURkg T4srQ06ZHQweJB5VWNJf5z/7elfLQ5FEuiWazxyzubvKZr9ufOXgLev9XalE4tRILDgf asMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xny0hztklULQCK4UozH+BnFszJxQZnYvrHREHvzmX2c=; b=Sbi9VTBvxcSixDv2em0StsZl2NU56MkX0dv+dBlTpwMe6FBJrRGtYzwKqUuuKOqsUa zToMvDJBLTefmdeuaHFAw3zWNNUGywJ2FGdIq9WZwSShF3zBKEEJ59QvC4V2cU1J3bEn sGenj+XBnzeMxc8C3suHw+q+ydB0x8BXJRXohlQHfd6r+r/rtFHWuXFQ+xYL9SxZ57ip dx7cFFt/P5fPluHIGM6fNrVp8rlwJL9YvZwh4dk3QVC0CBeYNHP4diyqBRvua3NJO3x9 eYCjgHD3xNEcVYoPmXMyUMtuFxXdk88SxAr4wSviZUDL061vYQP/ttpydUcoAjaTfR2X ZWsA== X-Gm-Message-State: AOAM531kgF8PCfsFMPN7Qe6czcRSmlgb0WcIWfMyfTBrX+P5bDXlSa/a ZjWJx8BROS+qpB7G0/Fl/vg42jgNziw= X-Google-Smtp-Source: ABdhPJy3oJLqOnH1vbifh0+FdmGly97ZANLNMxPEglkF0UWwr8dG2T+tsNk9KsbcgAgh6314ryWzfw== X-Received: by 2002:a17:90a:1da3:: with SMTP id v32mr24762893pjv.192.1624675135435; Fri, 25 Jun 2021 19:38:55 -0700 (PDT) Received: from bobo.ozlabs.ibm.com (60-242-147-73.tpgi.com.au. [60.242.147.73]) by smtp.gmail.com with ESMTPSA id u10sm7010014pfh.123.2021.06.25.19.38.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 19:38:55 -0700 (PDT) From: Nicholas Piggin To: skiboot@lists.ozlabs.org Date: Sat, 26 Jun 2021 12:38:24 +1000 Message-Id: <20210626023824.1124164-11-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20210626023824.1124164-1-npiggin@gmail.com> References: <20210626023824.1124164-1-npiggin@gmail.com> MIME-Version: 1.0 Subject: [Skiboot] [PATCH 10/10] npu: Add CONFIG_NPU to optionally skip NPU code X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" From: Stewart Smith Saves a whopping 39kb of skiboot.lid.xz. Signed-off-by: Stewart Smith --- Makefile | 2 ++ Makefile.main | 4 ++++ core/hmi.c | 10 +++++++++- core/init.c | 2 +- core/platform.c | 1 - hw/Makefile.inc | 12 +++++++++--- hw/npu2.c | 1 + include/npu2.h | 6 ++++++ include/pci.h | 3 +++ platforms/astbmc/Makefile.inc | 16 +++++++++++----- 10 files changed, 46 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 625f212ea..ce61e3af0 100644 --- a/Makefile +++ b/Makefile @@ -61,6 +61,8 @@ DEAD_CODE_ELIMINATION ?= 0 CONFIG_FSP?=1 # Try to build without POWER8 support CONFIG_P8?=1 +# Try and build without any NPU support +CONFIG_NPU?=1 # # Where is the source directory, must be a full path (no ~) diff --git a/Makefile.main b/Makefile.main index ef8ee6289..9f523a789 100644 --- a/Makefile.main +++ b/Makefile.main @@ -168,6 +168,10 @@ ifeq ($(CONFIG_P8),1) CFLAGS += -DCONFIG_P8=1 endif +ifeq ($(CONFIG_NPU),1) +CFLAGS += -DCONFIG_NPU=1 +endif + CFLAGS += $(call try-cflag,$(CC),-Wjump-misses-init) \ $(call try-cflag,$(CC),-Wsuggest-attribute=const) \ $(call try-cflag,$(CC),-Wsuggest-attribute=noreturn) \ diff --git a/core/hmi.c b/core/hmi.c index ee4c168e3..446ceee96 100644 --- a/core/hmi.c +++ b/core/hmi.c @@ -561,6 +561,7 @@ static void find_nx_checkstop_reason(int flat_chip_id, queue_hmi_event(hmi_evt, 0, out_flags); } +#ifdef CONFIG_NPU static bool phb_is_npu2(struct dt_node *dn) { return (dt_node_is_compatible(dn, "ibm,power9-npu-pciex") || @@ -691,7 +692,7 @@ static void find_npu2_checkstop_reason(int flat_chip_id, npu2_hmi_verbose = true; if (npu2_hmi_verbose) { - npu2_dump_scoms(flat_chip_id); + phb->ops->dump_debug_data(flat_chip_id); prlog(PR_ERR, " _________________________ \n"); prlog(PR_ERR, "< It's Debug time! >\n"); prlog(PR_ERR, " ------------------------- \n"); @@ -779,6 +780,13 @@ static void find_npu_checkstop_reason(int flat_chip_id, /* The HMI is "recoverable" because it shouldn't crash the system */ queue_hmi_event(hmi_evt, 1, out_flags); } +#else +static void find_npu_checkstop_reason(int flat_chip_id __unused, + struct OpalHMIEvent *hmi_evt __unused, + uint64_t *out_flags __unused) +{ +} +#endif static void decode_malfunction(struct OpalHMIEvent *hmi_evt, uint64_t *out_flags) { diff --git a/core/init.c b/core/init.c index a3601d0c8..79baac27b 100644 --- a/core/init.c +++ b/core/init.c @@ -1316,7 +1316,7 @@ void __noreturn __nomcount main_cpu_entry(const void *fdt) /* Catalog decompression routine */ imc_decompress_catalog(); - /* Probe all HWPROBE hardware we have code linked for*/ + /* Probe all HWPROBE hardware we have code linked for */ probe_hardware(); /* Initialize PCI */ diff --git a/core/platform.c b/core/platform.c index 320fdea03..3f4c8bdd5 100644 --- a/core/platform.c +++ b/core/platform.c @@ -226,7 +226,6 @@ static struct platform generic_platform = { .start_preload_resource = generic_start_preload_resource, .resource_loaded = generic_resource_loaded, .ocapi = &generic_ocapi, - .npu2_device_detect = npu2_i2c_presence_detect, /* Assumes ZZ */ }; const struct bmc_platform *bmc_platform = &generic_bmc; diff --git a/hw/Makefile.inc b/hw/Makefile.inc index ebb9ca86a..8815f436b 100644 --- a/hw/Makefile.inc +++ b/hw/Makefile.inc @@ -5,15 +5,21 @@ HW_OBJS += homer.o slw.o occ.o fsi-master.o centaur.o imc.o HW_OBJS += nx.o nx-rng.o nx-crypto.o nx-compress.o nx-842.o nx-gzip.o HW_OBJS += sfc-ctrl.o fake-rtc.o bt.o p8-i2c.o prd.o HW_OBJS += dts.o lpc-rtc.o xive.o phb4.o -HW_OBJS += fake-nvram.o lpc-mbox.o npu2.o npu2-hw-procedures.o -HW_OBJS += npu2-common.o npu2-opencapi.o phys-map.o sbe-p9.o capp.o -HW_OBJS += occ-sensor.o vas.o sbe-p8.o dio-p9.o lpc-port80h.o cache-p9.o +HW_OBJS += fake-nvram.o lpc-mbox.o +ifeq ($(CONFIG_NPU),1) +HW_OBJS += npu2.o npu2-hw-procedures.o +HW_OBJS += npu2-common.o npu2-opencapi.o HW_OBJS += npu-opal.o npu3.o npu3-nvlink.o npu3-hw-procedures.o +endif +HW_OBJS += phys-map.o sbe-p9.o capp.o +HW_OBJS += occ-sensor.o vas.o sbe-p8.o dio-p9.o lpc-port80h.o cache-p9.o HW_OBJS += ocmb.o ifeq ($(CONFIG_P8),1) HW_OBJS += phb3.o +ifeq ($(CONFIG_NPU),1) HW_OBJS += npu.o npu-hw-procedures.o endif +endif HW=hw/built-in.a include $(SRC)/hw/fsp/Makefile.inc diff --git a/hw/npu2.c b/hw/npu2.c index cf57eeb0c..e18a1b7b1 100644 --- a/hw/npu2.c +++ b/hw/npu2.c @@ -1316,6 +1316,7 @@ static const struct phb_ops npu_ops = { .set_capi_mode = NULL, .set_capp_recovery = NULL, .tce_kill = npu2_tce_kill, + .dump_debug_data = npu2_dump_scoms, }; static void assign_mmio_bars(uint64_t gcid, uint32_t scom, uint64_t reg[2], uint64_t mm_win[2]) diff --git a/include/npu2.h b/include/npu2.h index eb7c45587..6ab33c702 100644 --- a/include/npu2.h +++ b/include/npu2.h @@ -212,7 +212,13 @@ static inline struct phb *npu2_dev_to_phb(struct npu2_dev *ndev) } } +#ifdef CONFIG_NPU void npu2_i2c_presence_detect(struct npu2 *npu); +#else +static inline void npu2_i2c_presence_detect(struct npu2 *npu __unused) +{ +} +#endif int npu2_opencapi_init_npu(struct npu2 *npu); int npu2_nvlink_init_npu(struct npu2 *npu); void npu2_nvlink_create_phb(struct npu2 *npu, struct dt_node *dn); diff --git a/include/pci.h b/include/pci.h index 05d02171b..c70a507dc 100644 --- a/include/pci.h +++ b/include/pci.h @@ -343,6 +343,9 @@ struct phb_ops { /* Currently only used by NPU HMI code */ void (*set_fence_state)(struct phb *phb, bool fence); + + /* The most terrible of situtions, dump debug data to console. */ + void (*dump_debug_data)(int flat_chip_id); }; enum phb_type { diff --git a/platforms/astbmc/Makefile.inc b/platforms/astbmc/Makefile.inc index bd0e578f0..4d24db579 100644 --- a/platforms/astbmc/Makefile.inc +++ b/platforms/astbmc/Makefile.inc @@ -1,16 +1,22 @@ SUBDIRS += $(PLATDIR)/astbmc ASTBMC_OBJS = pnor.o common.o slots.o \ - witherspoon.o zaius.o romulus.o p9dsu.o \ - nicole.o mihawk.o mowgli.o \ - talos.o blackbird.o \ - swift.o + witherspoon.o romulus.o p9dsu.o \ + nicole.o mowgli.o \ + talos.o blackbird.o + +ifeq ($(CONFIG_NPU),1) +ASTBMC_OBJS += zaius.o mihawk.o swift.o +endif ifeq ($(CONFIG_P8),1) ASTBMC_OBJS += palmetto.o habanero.o firestone.o \ p8dtu.o p8dnu.o \ - garrison.o barreleye.o \ + barreleye.o \ vesnin.o +ifeq ($(CONFIG_NPU),1) +ASTBMC_OBJS += garrison.o +endif endif ASTBMC = $(PLATDIR)/astbmc/built-in.a