From patchwork Sun Dec 8 12:22:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1205619 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (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 47W5Dj4Z8hz9sP3 for ; Sun, 8 Dec 2019 23:27:17 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="iTNqLncU"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 47W5Dj3TKwzDqPk for ; Sun, 8 Dec 2019 23:27:17 +1100 (AEDT) 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::542; helo=mail-pg1-x542.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="iTNqLncU"; dkim-atps=neutral Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) (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 47W58P6w26zDqDV for ; Sun, 8 Dec 2019 23:23:33 +1100 (AEDT) Received: by mail-pg1-x542.google.com with SMTP id b137so5669352pga.6 for ; Sun, 08 Dec 2019 04:23:33 -0800 (PST) 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=0Hy/eDJxQwT6dfoi0aVE6cgqTtZqOVr9MHsBZfpvSxg=; b=iTNqLncUJKNzZkWH/3S6wz5+AflPzpjKzfa0nAuRtlRARedX76rP09Sm6b02Dgh/Fh ktEyb1yz2XzOd8Tgmdz9BEWFviJDQbSqmZqPzCL+0PEn2CrPpY6Po+qJDwIBgFzyrAV5 6x/r7fnUWPLk1AN3JYuLf40Wzx0SZUBONaBh7dQDmWa3sodwPFeBEyHc7hnX8HWu7YnS itj+YqPTobQUJPg5JMJvKrumgqc6xBGiU6NGeJ7WwbK0PaQFINuRY/DGs1czL5XFw958 H2v1uBb3IaV5q2BwPmcYx2rcKEwa4BmUdQhHqN7Igr8YhKTbNETLb5B6M6Nir0kq6a1l WAow== 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=0Hy/eDJxQwT6dfoi0aVE6cgqTtZqOVr9MHsBZfpvSxg=; b=pM3Yayhap6eAuIZxyfMJOtU++GE5XRSMXUt8ut3Kt+waCoIERGeANd6tWLgNwZOXsK W3tW2P/TLP1mc9f/bqtL1+fSSdnbmIjgOSem58WcB9Hu9DkJHax+giUAIBr6o4Q6yBPJ fIVx7U3K7bt8zRC+14VBSkJld8RTjdQ1VBS4Kuq0EH4hNmc75759yo/KzZ2pagdQ3l+T 5OEHc0VmfGF93N4hEDVEMghb1BJB13U2I60stB9hMcyCAgime/HNH4O94zNiMq+6sraY w1L5LLOoDJodJsC2BEHkvnp7f/iI3hCR41HWONzY/Dy4Ble84P+/kwNL04JwwEwbqcha upXw== X-Gm-Message-State: APjAAAXxoZyBLkyaCPCWmgdew7iW68+IAUU1kvDXN+DnRYi0gAxsJidH Qrw17oOjKOR46gcFnlHFXH4itj2A X-Google-Smtp-Source: APXvYqyffkoHdLtu2BwGobhYkwaBsqaUY5VeCkrJc1fxVLrigZEMoKwoYedB/h0A9ol/nDe2ZHMO0g== X-Received: by 2002:a63:e30a:: with SMTP id f10mr13329536pgh.331.1575807810992; Sun, 08 Dec 2019 04:23:30 -0800 (PST) Received: from bobo.local0.net ([202.21.15.182]) by smtp.gmail.com with ESMTPSA id i9sm23741866pfk.24.2019.12.08.04.23.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2019 04:23:30 -0800 (PST) From: Nicholas Piggin To: skiboot@lists.ozlabs.org Date: Sun, 8 Dec 2019 22:22:46 +1000 Message-Id: <20191208122312.12837-6-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191208122312.12837-1-npiggin@gmail.com> References: <20191208122312.12837-1-npiggin@gmail.com> MIME-Version: 1.0 Subject: [Skiboot] [PATCH v10 05/31] opal-msg: endian fixes for opal-msg.c and opal_queue_msg callers 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" Reported-by: Vasant Hegde Reviewed-by: Vasant Hegde Signed-off-by: Nicholas Piggin --- core/flash.c | 5 ++++- core/i2c.c | 4 +++- core/opal-msg.c | 2 +- core/pci-opal.c | 25 ++++++++++++++++--------- hw/dts.c | 4 +++- hw/fsp/fsp-leds.c | 4 +++- hw/fsp/fsp-mem-err.c | 9 +++++---- hw/fsp/fsp-op-panel.c | 4 +++- hw/fsp/fsp-rtc.c | 3 ++- hw/fsp/fsp-sensor.c | 3 ++- hw/fsp/fsp-sysparam.c | 6 ++++-- hw/ipmi/ipmi-sel.c | 6 ++++-- hw/occ.c | 6 ++++-- include/opal-msg.h | 4 ++-- 14 files changed, 56 insertions(+), 29 deletions(-) diff --git a/core/flash.c b/core/flash.c index 7fbfca22b..4e10229d5 100644 --- a/core/flash.c +++ b/core/flash.c @@ -470,7 +470,10 @@ static int64_t opal_flash_op(enum flash_op op, uint64_t id, uint64_t offset, unlock(&flash_lock); - opal_queue_msg(OPAL_MSG_ASYNC_COMP, NULL, NULL, token, rc); + opal_queue_msg(OPAL_MSG_ASYNC_COMP, NULL, NULL, + cpu_to_be64(token), + cpu_to_be64(rc)); + return OPAL_ASYNC_COMPLETION; err: diff --git a/core/i2c.c b/core/i2c.c index 6bae83b42..f33028743 100644 --- a/core/i2c.c +++ b/core/i2c.c @@ -42,7 +42,9 @@ static void opal_i2c_request_complete(int rc, struct i2c_request *req) { uint64_t token = (uint64_t)(unsigned long)req->user_data; - opal_queue_msg(OPAL_MSG_ASYNC_COMP, NULL, NULL, token, rc); + opal_queue_msg(OPAL_MSG_ASYNC_COMP, NULL, NULL, + cpu_to_be64(token), + cpu_to_be64(rc)); free(req); } diff --git a/core/opal-msg.c b/core/opal-msg.c index c393be7ef..dbe75e14a 100644 --- a/core/opal-msg.c +++ b/core/opal-msg.c @@ -143,7 +143,7 @@ static int64_t opal_check_completion(uint64_t *buffer, uint64_t size, lock(&opal_msg_lock); list_for_each_safe(&msg_pending_list, entry, next_entry, link) { - if (entry->msg.msg_type == OPAL_MSG_ASYNC_COMP && + if (be32_to_cpu(entry->msg.msg_type) == OPAL_MSG_ASYNC_COMP && be64_to_cpu(entry->msg.params[0]) == token) { list_del(&entry->link); callback = entry->consumed; diff --git a/core/pci-opal.c b/core/pci-opal.c index 4dc5237cc..292f1006e 100644 --- a/core/pci-opal.c +++ b/core/pci-opal.c @@ -804,8 +804,10 @@ static void link_up_timer(struct timer *t, void *data, rescan_slot_devices(slot); out: opal_queue_msg(OPAL_MSG_ASYNC_COMP, NULL, NULL, - slot->async_token, get_slot_phandle(slot), - slot->power_state, rc <= 0 ? rc : OPAL_BUSY); + cpu_to_be64(slot->async_token), + cpu_to_be64(get_slot_phandle(slot)), + cpu_to_be64(slot->power_state), + rc <= 0 ? cpu_to_be64(rc) : cpu_to_be64(OPAL_BUSY)); phb_unlock(phb); } @@ -834,9 +836,10 @@ static void wait_for_link_up_and_rescan(struct pci_slot *slot) rc = slot->ops.freset(slot); if (rc < 0) { opal_queue_msg(OPAL_MSG_ASYNC_COMP, NULL, NULL, - slot->async_token, - get_slot_phandle(slot), - slot->power_state, rc); + cpu_to_be64(slot->async_token), + cpu_to_be64(get_slot_phandle(slot)), + cpu_to_be64(slot->power_state), + cpu_to_be64(rc)) return; } } else { @@ -863,8 +866,10 @@ static void set_power_timer(struct timer *t __unused, void *data, if (slot->retries-- == 0) { pci_slot_set_state(slot, PCI_SLOT_STATE_NORMAL); opal_queue_msg(OPAL_MSG_ASYNC_COMP, NULL, NULL, - slot->async_token, get_slot_phandle(slot), - slot->power_state, OPAL_BUSY); + cpu_to_be64(slot->async_token), + cpu_to_be64(get_slot_phandle(slot)), + cpu_to_be64(slot->power_state), + cpu_to_be64(OPAL_BUSY)); } else { schedule_timer(&slot->timer, msecs_to_tb(10)); } @@ -875,8 +880,10 @@ static void set_power_timer(struct timer *t __unused, void *data, remove_slot_devices(slot); pci_slot_set_state(slot, PCI_SLOT_STATE_NORMAL); opal_queue_msg(OPAL_MSG_ASYNC_COMP, NULL, NULL, - slot->async_token, get_slot_phandle(slot), - OPAL_PCI_SLOT_POWER_OFF, OPAL_SUCCESS); + cpu_to_be64(slot->async_token), + cpu_to_be64(get_slot_phandle(slot)), + cpu_to_be64(OPAL_PCI_SLOT_POWER_OFF), + cpu_to_be64(OPAL_SUCCESS)); break; } diff --git a/hw/dts.c b/hw/dts.c index c21c5c779..b72516ab2 100644 --- a/hw/dts.c +++ b/hw/dts.c @@ -183,7 +183,9 @@ static void dts_async_read_temp(struct timer *t __unused, void *data, dctl_clear_special_wakeup(cpu); check_sensor_read(cpu->token); - rc = opal_queue_msg(OPAL_MSG_ASYNC_COMP, NULL, NULL, cpu->token, rc); + rc = opal_queue_msg(OPAL_MSG_ASYNC_COMP, NULL, NULL, + cpu_to_be64(cpu->token), + cpu_to_be64(rc)); if (rc) prerror("Failed to queue async message\n"); diff --git a/hw/fsp/fsp-leds.c b/hw/fsp/fsp-leds.c index 7d234a81c..9e89f20d0 100644 --- a/hw/fsp/fsp-leds.c +++ b/hw/fsp/fsp-leds.c @@ -186,7 +186,9 @@ static bool is_enclosure_led(char *loc_code) static inline void opal_led_update_complete(u64 async_token, u64 result) { - opal_queue_msg(OPAL_MSG_ASYNC_COMP, NULL, NULL, async_token, result); + opal_queue_msg(OPAL_MSG_ASYNC_COMP, NULL, NULL, + cpu_to_be64(async_token), + cpu_to_be64(result)); } static inline bool is_sai_loc_code(const char *loc_code) diff --git a/hw/fsp/fsp-mem-err.c b/hw/fsp/fsp-mem-err.c index ffafb96b9..01b1e55ab 100644 --- a/hw/fsp/fsp-mem-err.c +++ b/hw/fsp/fsp-mem-err.c @@ -96,10 +96,11 @@ static void queue_event_for_delivery(void *data __unused, int staus __unused) merr_data = (uint64_t *)&entry->data; /* queue up for delivery */ - rc = opal_queue_msg(OPAL_MSG_MEM_ERR, NULL, - queue_event_for_delivery, - merr_data[0], merr_data[1], - merr_data[2], merr_data[3]); + rc = opal_queue_msg(OPAL_MSG_MEM_ERR, NULL, queue_event_for_delivery, + cpu_to_be64(merr_data[0]), + cpu_to_be64(merr_data[1]), + cpu_to_be64(merr_data[2]), + cpu_to_be64(merr_data[3])); lock(&mem_err_lock); if (rc) { /* diff --git a/hw/fsp/fsp-op-panel.c b/hw/fsp/fsp-op-panel.c index 320da241f..00d275131 100644 --- a/hw/fsp/fsp-op-panel.c +++ b/hw/fsp/fsp-op-panel.c @@ -155,7 +155,9 @@ static void op_panel_write_complete(struct fsp_msg *msg) __op_panel_write_complete(msg); - opal_queue_msg(OPAL_MSG_ASYNC_COMP, NULL, NULL, 1, op_async_token); + opal_queue_msg(OPAL_MSG_ASYNC_COMP, NULL, NULL, + cpu_to_be64(1), + cpu_to_be64(op_async_token)); } static int64_t __opal_write_oppanel(oppanel_line_t *lines, uint64_t num_lines, diff --git a/hw/fsp/fsp-rtc.c b/hw/fsp/fsp-rtc.c index e68836e66..ac12ddf22 100644 --- a/hw/fsp/fsp-rtc.c +++ b/hw/fsp/fsp-rtc.c @@ -139,7 +139,8 @@ static void fsp_tpo_req_complete(struct fsp_msg *read_resp) break; } opal_queue_msg(OPAL_MSG_ASYNC_COMP, NULL, NULL, - attr->tpo_async_token, rc); + cpu_to_be64(attr->tpo_async_token), + cpu_to_be64(rc)); free(attr); fsp_freemsg(read_resp); } diff --git a/hw/fsp/fsp-sensor.c b/hw/fsp/fsp-sensor.c index 74deac7a7..46385b0a6 100644 --- a/hw/fsp/fsp-sensor.c +++ b/hw/fsp/fsp-sensor.c @@ -293,7 +293,8 @@ static void queue_msg_for_delivery(int rc, struct opal_sensor_data *attr) __func__, rc, *(attr->sensor_data)); check_sensor_read(attr->async_token); opal_queue_msg(OPAL_MSG_ASYNC_COMP, NULL, NULL, - attr->async_token, rc); + cpu_to_be64(attr->async_token), + cpu_to_be64(rc)); spcn_mod_data[attr->mod_index].entry_count = 0; free(attr); prev_msg_consumed = true; diff --git a/hw/fsp/fsp-sysparam.c b/hw/fsp/fsp-sysparam.c index 0e1e8181f..c7ed36e43 100644 --- a/hw/fsp/fsp-sysparam.c +++ b/hw/fsp/fsp-sysparam.c @@ -194,7 +194,8 @@ static void fsp_opal_getparam_complete(uint32_t param_id __unused, int err_len, rc = OPAL_INTERNAL_ERROR; opal_queue_msg(OPAL_MSG_ASYNC_COMP, NULL, NULL, - comp_data->async_token, rc); + cpu_to_be64(comp_data->async_token), + cpu_to_be64(rc)); free(comp_data); } @@ -242,7 +243,8 @@ static void fsp_opal_setparam_complete(struct fsp_msg *msg) out: opal_queue_msg(OPAL_MSG_ASYNC_COMP, NULL, NULL, - comp_data->async_token, rc); + cpu_to_be64(comp_data->async_token), + cpu_to_be64(rc)); free(comp_data); fsp_freemsg(msg); } diff --git a/hw/ipmi/ipmi-sel.c b/hw/ipmi/ipmi-sel.c index 794aa3801..60df9d927 100644 --- a/hw/ipmi/ipmi-sel.c +++ b/hw/ipmi/ipmi-sel.c @@ -496,7 +496,8 @@ static void sel_power(uint8_t power, void *context __unused) prlog(PR_NOTICE, "Host not up, shutting down now\n"); platform.cec_power_down(IPMI_CHASSIS_PWR_DOWN); } else { - opal_queue_msg(OPAL_MSG_SHUTDOWN, NULL, NULL, SOFT_OFF); + opal_queue_msg(OPAL_MSG_SHUTDOWN, NULL, NULL, + cpu_to_be64(SOFT_OFF)); } break; @@ -506,7 +507,8 @@ static void sel_power(uint8_t power, void *context __unused) prlog(PR_NOTICE, "Host not up, rebooting now\n"); platform.cec_reboot(); } else { - opal_queue_msg(OPAL_MSG_SHUTDOWN, NULL, NULL, SOFT_REBOOT); + opal_queue_msg(OPAL_MSG_SHUTDOWN, NULL, NULL, + cpu_to_be64(SOFT_REBOOT)); } break; diff --git a/hw/occ.c b/hw/occ.c index 2c989a616..46210ba20 100644 --- a/hw/occ.c +++ b/hw/occ.c @@ -1126,7 +1126,9 @@ static inline void queue_occ_rsp_msg(int token, int rc) { int ret; - ret = opal_queue_msg(OPAL_MSG_ASYNC_COMP, NULL, NULL, token, rc); + ret = opal_queue_msg(OPAL_MSG_ASYNC_COMP, NULL, NULL, + cpu_to_be64(token), + cpu_to_be64(rc)); if (ret) prerror("OCC: Failed to queue OCC response status message\n"); } @@ -1877,7 +1879,7 @@ int find_master_and_slave_occ(uint64_t **master, uint64_t **slave, int occ_msg_queue_occ_reset(void) { - struct opal_occ_msg occ_msg = { OCC_RESET, 0, 0 }; + struct opal_occ_msg occ_msg = { CPU_TO_BE64(OCC_RESET), 0, 0 }; struct proc_chip *chip; int rc; diff --git a/include/opal-msg.h b/include/opal-msg.h index 036183343..df605b3b6 100644 --- a/include/opal-msg.h +++ b/include/opal-msg.h @@ -27,8 +27,8 @@ int _opal_queue_msg(enum opal_msg_type msg_type, void *data, #define opal_queue_msg(msg_type, data, cb, ...) \ _opal_queue_msg(msg_type, data, cb, \ - sizeof((u64[]) {__VA_ARGS__}), \ - (u64[]) {__VA_ARGS__}); + sizeof((__be64[]) {__VA_ARGS__}), \ + (__be64[]) {__VA_ARGS__}); void opal_init_msg(void);