From patchwork Fri Apr 8 15:31:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1614963 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=20210112 header.b=MaJL7kDW; dkim-atps=neutral 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=) 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) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KZj0p2hpPz9sFq for ; Sat, 9 Apr 2022 01:32:10 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KZj0m42p6z3bcr for ; Sat, 9 Apr 2022 01:32:08 +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=20210112 header.b=MaJL7kDW; 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::529; helo=mail-pg1-x529.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=20210112 header.b=MaJL7kDW; dkim-atps=neutral Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) (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 4KZj0V0XNBz2yJ9 for ; Sat, 9 Apr 2022 01:31:53 +1000 (AEST) Received: by mail-pg1-x529.google.com with SMTP id s137so5347405pgs.5 for ; Fri, 08 Apr 2022 08:31:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nUzCKJIxI0XSs7iak7hfBgSuMSnNThhMgJR9Yed1m0M=; b=MaJL7kDWAbZEKwB5UlcIyoiP0D7pldg1IAMINDkZzYIqzmHboviOooWgg+Rbn63Hyj 6vc0SZiGdyyQCsL19qj8iylfbT/nvuKd8zcghwxijx8PRQwIiZ0mBi2L8W6IDoyro6Ta hyGfl+gZ5OLCkwc3YoMO/QUGBpGTCluXMQ4xgJRKe3ufbHpIg01M6rJJsVckXsjZNZ2P V/yxM7RY8zEe8Wc3OBusOO7fONMOwCzDc095pZhu6LVxyyNJy2cUgBHNLWmBVxFgnLSM VSEAozUNzsDLeg7wKI0RGVHYFpmu5sQa9bruxq1j8YebKuZ2eRuibKqUvAbzSba48c9V tIeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nUzCKJIxI0XSs7iak7hfBgSuMSnNThhMgJR9Yed1m0M=; b=vVKJx43g++uoe+dHnOHHF+eLVTIFruPICWopMv2C6BVqqjwPsB77hhZwJ4vl5FcBE2 Sfg3ELi3Au0bWUx0KMchWDFBxhZ6TjRQYzm5ySCLyb6UxK8fcU4KbL+lYD755gbBD7D2 /zKnh+oiZ39SGB+O9thYfEB1NUT9678n9AAhYfw+F1QkCDzxjWYrZcumAsL2TqsfRvwt ugEfPmQkSH53F3xGAKPgLTvySGEAAIOXmMv1XGJRgIkcDGqFxzmXUsiwaUg7eGgeJll8 zCdRIWdS82xrWVbqFMb5FOKW/kIzClzQJoK4/VoyQJTTGgnB4N5200g2dFFF/ATT9qEd lVkQ== X-Gm-Message-State: AOAM533nWyt++B/vGNdCOPmkoutr0VhO3Ejzx78IJktTYrYVMWdVhMhH oyA9Np5dxj9YZQJ2ke8tr7LmRXV5u+U= X-Google-Smtp-Source: ABdhPJy+5F5UMXXuPGmOeqU7wRvCaKlbmqzPeDsGU338TBYVvcWoY0Afg1rs9ItXuLSBPEvQld5gkA== X-Received: by 2002:a63:6c8a:0:b0:398:5208:220a with SMTP id h132-20020a636c8a000000b003985208220amr16041848pgc.176.1649431911424; Fri, 08 Apr 2022 08:31:51 -0700 (PDT) Received: from bobo.ozlabs.ibm.com (220-235-208-104.tpgi.com.au. [220.235.208.104]) by smtp.gmail.com with ESMTPSA id y26-20020a056a00181a00b004fe3a6f02cesm14175172pfa.85.2022.04.08.08.31.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Apr 2022 08:31:51 -0700 (PDT) From: Nicholas Piggin To: skiboot@lists.ozlabs.org Date: Sat, 9 Apr 2022 01:31:35 +1000 Message-Id: <20220408153137.996621-3-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220408153137.996621-1-npiggin@gmail.com> References: <20220408153137.996621-1-npiggin@gmail.com> MIME-Version: 1.0 Subject: [Skiboot] [PATCH 2/4] npu/pau: endian fixes 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" Add endian annotations to NPU OPAL APIs, and fix warnings and bugs reported by sparse. Signed-off-by: Nicholas Piggin Reviewed-by: Frederic Barrat --- hw/npu-opal.c | 4 ++-- hw/npu2-opencapi.c | 2 +- hw/pau.c | 19 ++++++++++--------- include/npu2.h | 2 +- include/pau.h | 2 +- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/hw/npu-opal.c b/hw/npu-opal.c index 1b66857f4..943ac608c 100644 --- a/hw/npu-opal.c +++ b/hw/npu-opal.c @@ -241,7 +241,7 @@ static int64_t opal_npu_tl_set(uint64_t phb_id, uint32_t bdfn, opal_call(OPAL_NPU_TL_SET, opal_npu_tl_set, 5); static int64_t opal_npu_mem_alloc(uint64_t phb_id, uint32_t bdfn, - uint64_t size, uint64_t *bar) + uint64_t size, __be64 *bar) { struct phb *phb = pci_get_phb(phb_id); @@ -260,7 +260,7 @@ opal_call(OPAL_NPU_MEM_ALLOC, opal_npu_mem_alloc, 4); static int64_t opal_npu_mem_release(uint64_t phb_id, uint32_t bdfn) { - struct phb *phb = pci_get_phb(phb_id);; + struct phb *phb = pci_get_phb(phb_id); if (!phb) return OPAL_PARAMETER; diff --git a/hw/npu2-opencapi.c b/hw/npu2-opencapi.c index 8e7bcca93..8004d85b9 100644 --- a/hw/npu2-opencapi.c +++ b/hw/npu2-opencapi.c @@ -2296,7 +2296,7 @@ out: } int64_t npu2_opencapi_mem_alloc(struct phb *phb, uint32_t __unused bdfn, - uint64_t size, uint64_t *__bar) + uint64_t size, __be64 *__bar) { struct npu2_dev *dev; uint64_t bar; diff --git a/hw/pau.c b/hw/pau.c index 1a3fbfaf7..144e58456 100644 --- a/hw/pau.c +++ b/hw/pau.c @@ -444,7 +444,7 @@ int64_t pau_opencapi_tl_set(struct phb *phb, uint32_t __unused bdfn, static int64_t pau_opencapi_afu_memory_bars(struct pau_dev *dev, uint64_t size, - uint64_t *bar) + __be64 *bar) { struct pau *pau = dev->pau; uint64_t addr, psize; @@ -492,12 +492,13 @@ static int64_t pau_opencapi_afu_memory_bars(struct pau_dev *dev, reg = PAU_XSL_GPU_MEM_BAR(dev->index); pau_write(pau, reg, val); - *bar = addr; + *bar = cpu_to_be64(addr); + return OPAL_SUCCESS; } int64_t pau_opencapi_mem_alloc(struct phb *phb, uint32_t __unused bdfn, - uint64_t size, uint64_t *bar) + uint64_t size, __be64 *bar) { struct pau_dev *dev = pau_phb_to_opencapi_dev(phb); int64_t rc; @@ -1302,7 +1303,7 @@ static int64_t pau_opencapi_pcicfg_read(struct phb *phb, uint32_t bdfn, cfg_addr = SETFIELD(PAU_CTL_MISC_CFG_ADDR_REGISTER_NBR, cfg_addr, offset & ~3u); - out_be64((uint64_t *)genid_base, cfg_addr); + out_be64((__be64 *)genid_base, cfg_addr); sync(); switch (size) { @@ -1312,10 +1313,10 @@ static int64_t pau_opencapi_pcicfg_read(struct phb *phb, uint32_t bdfn, break; case 2: *((uint16_t *)data) = - in_le16((uint16_t *)(genid_base + 128 + (offset & 2))); + in_le16((__le16 *)(genid_base + 128 + (offset & 2))); break; case 4: - *((uint32_t *)data) = in_le32((uint32_t *)(genid_base + 128)); + *((uint32_t *)data) = in_le32((__le32 *)(genid_base + 128)); break; default: return OPAL_PARAMETER; @@ -1358,7 +1359,7 @@ static int64_t pau_opencapi_pcicfg_write(struct phb *phb, uint32_t bdfn, cfg_addr = SETFIELD(PAU_CTL_MISC_CFG_ADDR_REGISTER_NBR, cfg_addr, offset & ~3u); - out_be64((uint64_t *)genid_base, cfg_addr); + out_be64((__be64 *)genid_base, cfg_addr); sync(); switch (size) { @@ -1366,10 +1367,10 @@ static int64_t pau_opencapi_pcicfg_write(struct phb *phb, uint32_t bdfn, out_8((uint8_t *)(genid_base + 128 + (offset & 3)), data); break; case 2: - out_le16((uint16_t *)(genid_base + 128 + (offset & 2)), data); + out_le16((__le16 *)(genid_base + 128 + (offset & 2)), data); break; case 4: - out_le32((uint32_t *)(genid_base + 128), data); + out_le32((__le32 *)(genid_base + 128), data); break; default: return OPAL_PARAMETER; diff --git a/include/npu2.h b/include/npu2.h index b302108b9..bc1a74ea1 100644 --- a/include/npu2.h +++ b/include/npu2.h @@ -278,7 +278,7 @@ int64_t npu2_opencapi_spa_clear_cache(struct phb *phb, uint32_t __unused bdfn, int64_t npu2_opencapi_tl_set(struct phb *phb, uint32_t __unused bdfn, long capabilities, char *rate); int64_t npu2_opencapi_mem_alloc(struct phb *phb, uint32_t __unused bdfn, - uint64_t size, uint64_t *bar); + uint64_t size, __be64 *bar); int64_t npu2_opencapi_mem_release(struct phb *phb, uint32_t __unused bdfn); #endif /* __NPU2_H */ diff --git a/include/pau.h b/include/pau.h index 4a6087cbf..8d5e32071 100644 --- a/include/pau.h +++ b/include/pau.h @@ -211,7 +211,7 @@ int64_t pau_opencapi_spa_clear_cache(struct phb *phb, int64_t pau_opencapi_tl_set(struct phb *phb, uint32_t __unused bdfn, long capabilities, char *rate_buf); int64_t pau_opencapi_mem_alloc(struct phb *phb, uint32_t __unused bdfn, - uint64_t size, uint64_t *bar); + uint64_t size, __be64 *bar); int64_t pau_opencapi_mem_release(struct phb *phb, uint32_t __unused bdfn); /* PHY */