[Skiboot] [PATCH 7/7] Add CONFIG_NPU to optionally skip NPU code

Stewart Smith stewart at flamingspork.com
Mon Jan 25 11:58:07 AEDT 2021


Can save a whopping 39kb of skiboot.lid.xz

Signed-off-by: Stewart Smith <stewart at flamingspork.com>
---
 Makefile                      |  2 ++
 core/hmi.c                    |  2 +-
 core/platform.c               |  1 -
 hw/Makefile.inc               | 12 +++++++++---
 hw/npu2.c                     |  1 +
 include/pci.h                 |  3 +++
 platforms/astbmc/Makefile.inc | 16 +++++++++++-----
 7 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/Makefile b/Makefile
index 625f212e..ce61e3af 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/core/hmi.c b/core/hmi.c
index ee4c168e..6d83e060 100644
--- a/core/hmi.c
+++ b/core/hmi.c
@@ -691,7 +691,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");
diff --git a/core/platform.c b/core/platform.c
index 320fdea0..3f4c8bdd 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 ebb9ca86..8815f436 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 cf57eeb0..e18a1b7b 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/pci.h b/include/pci.h
index 05d02171..c70a507d 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 bd0e578f..4d24db57 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
-- 
2.29.2



More information about the Skiboot mailing list