From patchwork Thu Aug 23 03:47:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 961163 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41wr3s3W5yz9ryn for ; Thu, 23 Aug 2018 13:48:25 +1000 (AEST) 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="DTnSUa86"; 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 41wr3s0LMXzF2FQ for ; Thu, 23 Aug 2018 13:48:25 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="DTnSUa86"; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::444; helo=mail-pf1-x444.google.com; envelope-from=oohall@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="DTnSUa86"; dkim-atps=neutral Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41wr373l1xzDqnw for ; Thu, 23 Aug 2018 13:47:46 +1000 (AEST) Received: by mail-pf1-x444.google.com with SMTP id j8-v6so1984220pff.6 for ; Wed, 22 Aug 2018 20:47:45 -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; bh=Z2jw1gpspcA9ZkSFK3BlYt3FfCSdaa6Okn+93V8sYJw=; b=DTnSUa86jhAbdfax4O2pFaSWkRUTBktQ2QVbncVXUWItvz1D0qKIzzk+I1QCaBb9xF cZHpIsqEvMETGJit1pFn4krtFPAysAUqFy1xBYDcgX9ZhyetbzYottHUQ1SZVIOksklQ P5f/Z2d6kRFyu+HcBJkqcRS78qk+wUC26XZyNdlF1Fhi3aPB6BF5QVLvNufHFS1UANWA V0L/bBaMbEqeeO+PsVRv58g/LsfmaS1QO6Bcm0oIgJXBVwvaMrINUS+W9azbyexNn8ig LGk0e9kWMEWIf1g6JO+M1J15Brt9aq87X2VqaEwk33q40FzXJyIMKh5lEXPjXrkzML7i eU7Q== 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; bh=Z2jw1gpspcA9ZkSFK3BlYt3FfCSdaa6Okn+93V8sYJw=; b=dNilDMEkVQgaImKexvJuYa/B4Nt3kFCHHryCkOwPVnpbDK+9c0zPCM1dApkGv7/0W1 qEm4//ru+IzeNE5thyEpQJPvMLgA/OXeT/4eH124VPUMICbvtQviuHWGh3yUR75bbmNU bliuJWMjqLOFEx2VvfhWrS9CzuIS0USirY7CmlHvWwI8MGGjbsWpL+lc4qIH78bJI4Vz mDlJRX55A6Sv4+NSN97w3QF32CJtSN8L9Cw7beFoVdQK8qm4rZi7xqBbFGlfXZIUcRk4 Uq6Cb0KqadzmtFrkLn2Ab5hmKBKmvW2DQb7n9UNG2DSgjHyFYdtu/G/Tu1Sowdsp19sv fgWw== X-Gm-Message-State: APzg51BmCajP1GZ6bfSgIqrHJdmzISuilqMDdbei0n3l+57XqTiOSewp CsWZYab9nXbyxaT9zMU5nDNsqmBGQrs= X-Google-Smtp-Source: ANB0VdbD0d6kVMOLEAxDMv7qcie95gn1pZjx+IVRCcsJSxNbviUDjnY2hVrA5Pi7RH0Nqgx5zOerPA== X-Received: by 2002:a63:1426:: with SMTP id u38-v6mr3961269pgl.168.1534996063606; Wed, 22 Aug 2018 20:47:43 -0700 (PDT) Received: from flat-canetoad.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id l123-v6sm3652314pgl.82.2018.08.22.20.47.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Aug 2018 20:47:43 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Thu, 23 Aug 2018 13:47:30 +1000 Message-Id: <20180823034732.2467-1-oohall@gmail.com> X-Mailer: git-send-email 2.9.5 Subject: [Skiboot] [PATCH 1/3] core/i2c: Move the timeout field into i2c_request X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Currently to set a per-request timeout you need to use i2c_req_set_timeout() which is a wrapper for a per-bus method that sets the actual timeout. This design doesn't make a whole lot of sense, so move the timeout field into the generic i2c_request structure and set the timeout to be set using that. Signed-off-by: Oliver O'Halloran --- core/i2c.c | 3 ++- hw/p8-i2c.c | 28 ++++------------------------ include/i2c.h | 10 +--------- platforms/ibm-fsp/firenze-pci.c | 24 ++++++++++++------------ 4 files changed, 19 insertions(+), 46 deletions(-) diff --git a/core/i2c.c b/core/i2c.c index e83331057f96..b0d5d34bf692 100644 --- a/core/i2c.c +++ b/core/i2c.c @@ -208,12 +208,13 @@ int i2c_request_send(int bus_id, int dev_addr, int read_write, req->rw_buf = (void*) buf; req->rw_len = buflen; req->completion = i2c_sync_request_complete; + req->timeout = timeout; ud.done = false; req->user_data = &ud; for (retries = 0; retries <= MAX_NACK_RETRIES; retries++) { waited = 0; - i2c_set_req_timeout(req, timeout); + i2c_queue_req(req); do { diff --git a/hw/p8-i2c.c b/hw/p8-i2c.c index 905834b86e54..d3b383514186 100644 --- a/hw/p8-i2c.c +++ b/hw/p8-i2c.c @@ -378,12 +378,10 @@ static int p8_i2c_enable_irqs(struct p8_i2c_master *master) static void p8_i2c_reset_timeout(struct p8_i2c_master *master, struct i2c_request *req) { - struct p8_i2c_request *request; uint64_t now = mftb(); master->last_update = now; - request = container_of(req, struct p8_i2c_request, req); - schedule_timer_at(&master->timeout, now + request->timeout); + schedule_timer_at(&master->timeout, now + req->timeout); } static int p8_i2c_prog_watermark(struct p8_i2c_master *master) @@ -446,14 +444,10 @@ static int p8_i2c_prog_mode(struct p8_i2c_master_port *port, bool enhanced_mode) static void p8_i2c_complete_request(struct p8_i2c_master *master, struct i2c_request *req, int ret) { - struct p8_i2c_request *request = - container_of(req, struct p8_i2c_request, req); - /* We only complete the current top level request */ assert(req == list_top(&master->req_list, struct i2c_request, link)); cancel_timer_async(&master->timeout); - request->timeout = 0ul; list_del(&req->link); master->state = state_idle; @@ -830,7 +824,6 @@ static void p8_i2c_status_cmd_completion(struct p8_i2c_master *master, static void p8_i2c_check_status(struct p8_i2c_master *master) { struct p8_i2c_master_port *port; - struct p8_i2c_request *request; uint64_t status, deadline, now; struct i2c_request *req; int rc; @@ -872,8 +865,7 @@ static void p8_i2c_check_status(struct p8_i2c_master *master) port = container_of(req->bus, struct p8_i2c_master_port, bus); now = mftb(); - request = container_of(req, struct p8_i2c_request, req); - deadline = master->last_update + request->timeout; + deadline = master->last_update + req->timeout; if (status & I2C_STAT_ANY_ERR) p8_i2c_status_error(port, req, status & I2C_STAT_ANY_ERR, now); @@ -1060,8 +1052,6 @@ static int p8_i2c_start_request(struct p8_i2c_master *master, struct i2c_request *req) { struct p8_i2c_master_port *port; - struct p8_i2c_request *request = - container_of(req, struct p8_i2c_request, req); uint64_t cmd, poll_interval; int64_t rc; @@ -1203,8 +1193,8 @@ static int p8_i2c_start_request(struct p8_i2c_master *master, schedule_timer(&master->poller, poll_interval); /* If we don't have a user-set timeout then use the master's default */ - if (!request->timeout) - request->timeout = port->byte_timeout; + if (!req->timeout) + req->timeout = port->byte_timeout; /* Start the timeout */ p8_i2c_reset_timeout(master, req); @@ -1315,15 +1305,6 @@ static void p8_i2c_free_request(struct i2c_request *req) free(request); } -static void p8_i2c_set_request_timeout(struct i2c_request *req, - uint64_t duration) -{ - struct p8_i2c_request *request = - container_of(req, struct p8_i2c_request, req); - - request->timeout = msecs_to_tb(duration); -} - static uint64_t p8_i2c_run_request(struct i2c_request *req) { struct i2c_bus *bus = req->bus; @@ -1653,7 +1634,6 @@ static void p8_i2c_init_one(struct dt_node *i2cm, enum p8_i2c_master_type type) port->bus.queue_req = p8_i2c_queue_request; port->bus.alloc_req = p8_i2c_alloc_request; port->bus.free_req = p8_i2c_free_request; - port->bus.set_req_timeout = p8_i2c_set_request_timeout; port->bus.run_req = p8_i2c_run_request; timeout_ms = dt_prop_get_u32_def(i2cm_port, "timeout-ms", diff --git a/include/i2c.h b/include/i2c.h index 28c762891b70..f33c2d83c195 100644 --- a/include/i2c.h +++ b/include/i2c.h @@ -26,8 +26,6 @@ struct i2c_bus { int (*queue_req)(struct i2c_request *req); struct i2c_request *(*alloc_req)(struct i2c_bus *bus); void (*free_req)(struct i2c_request *req); - void (*set_req_timeout)(struct i2c_request *req, - uint64_t duration); uint64_t (*run_req)(struct i2c_request *req); int (*check_quirk)(void *data, struct i2c_request *req, int *rc); void *check_quirk_data; @@ -65,6 +63,7 @@ struct i2c_request { int rc, struct i2c_request *req); void *user_data; /* Client data */ int retries; + uint64_t timeout; }; /* Generic i2c */ @@ -86,13 +85,6 @@ static inline int i2c_queue_req(struct i2c_request *req) return req->bus->queue_req(req); } -static inline void i2c_set_req_timeout(struct i2c_request *req, - uint64_t duration) -{ - if (req->bus->set_req_timeout) - req->bus->set_req_timeout(req, duration); -} - static inline uint64_t i2c_run_req(struct i2c_request *req) { if (req->bus->run_req) diff --git a/platforms/ibm-fsp/firenze-pci.c b/platforms/ibm-fsp/firenze-pci.c index 50633998737b..44fa6b5f1532 100644 --- a/platforms/ibm-fsp/firenze-pci.c +++ b/platforms/ibm-fsp/firenze-pci.c @@ -428,6 +428,7 @@ static int64_t firenze_pci_slot_freset(struct pci_slot *slot) { struct firenze_pci_slot *plat_slot = slot->data; uint8_t *pval, presence = 1; + uint32_t timeout; switch (slot->state) { case FIRENZE_PCI_SLOT_NORMAL: @@ -461,10 +462,9 @@ static int64_t firenze_pci_slot_freset(struct pci_slot *slot) pci_slot_set_state(slot, FIRENZE_PCI_SLOT_FRESET_WAIT_RSP); if (pci_slot_has_flags(slot, PCI_SLOT_FLAG_BOOTUP)) - i2c_set_req_timeout(plat_slot->req, - FIRENZE_PCI_I2C_TIMEOUT); + plat_slot->req->timeout = FIRENZE_PCI_I2C_TIMEOUT; else - i2c_set_req_timeout(plat_slot->req, 0ul); + plat_slot->req->timeout = 0ul; i2c_queue_req(plat_slot->req); return pci_slot_set_sm_timeout(slot, msecs_to_tb(FIRENZE_PCI_SLOT_DELAY)); @@ -503,10 +503,11 @@ static int64_t firenze_pci_slot_freset(struct pci_slot *slot) FIRENZE_PCI_SLOT_FRESET_WAIT_RSP); if (pci_slot_has_flags(slot, PCI_SLOT_FLAG_BOOTUP)) - i2c_set_req_timeout(plat_slot->req, - FIRENZE_PCI_I2C_TIMEOUT); + timeout = FIRENZE_PCI_I2C_TIMEOUT; else - i2c_set_req_timeout(plat_slot->req, 0ul); + timeout = 0ul; + plat_slot->req->timeout = timeout; + i2c_queue_req(plat_slot->req); return pci_slot_set_sm_timeout(slot, msecs_to_tb(FIRENZE_PCI_SLOT_DELAY)); @@ -531,10 +532,9 @@ static int64_t firenze_pci_slot_freset(struct pci_slot *slot) FIRENZE_PCI_SLOT_FRESET_WAIT_RSP); if (pci_slot_has_flags(slot, PCI_SLOT_FLAG_BOOTUP)) - i2c_set_req_timeout(plat_slot->req, - FIRENZE_PCI_I2C_TIMEOUT); + plat_slot->req->timeout = FIRENZE_PCI_I2C_TIMEOUT; else - i2c_set_req_timeout(plat_slot->req, 0ul); + plat_slot->req->timeout = 0ul; i2c_queue_req(plat_slot->req); return pci_slot_set_sm_timeout(slot, msecs_to_tb(FIRENZE_PCI_SLOT_DELAY)); @@ -687,9 +687,9 @@ static int64_t firenze_pci_slot_set_power_state(struct pci_slot *slot, } if (pci_slot_has_flags(slot, PCI_SLOT_FLAG_BOOTUP)) - i2c_set_req_timeout(plat_slot->req, FIRENZE_PCI_I2C_TIMEOUT); + plat_slot->req->timeout = FIRENZE_PCI_I2C_TIMEOUT; else - i2c_set_req_timeout(plat_slot->req, 0ul); + plat_slot->req->timeout = 0ul; i2c_queue_req(plat_slot->req); return OPAL_ASYNC_COMPLETION; @@ -754,7 +754,7 @@ static int64_t firenze_pci_slot_fixup_one_reg(struct pci_slot *slot, *(uint8_t *)(req->rw_buf) = 0; } pci_slot_set_state(slot, FIRENZE_PCI_SLOT_FRESET_WAIT_RSP); - i2c_set_req_timeout(req, FIRENZE_PCI_I2C_TIMEOUT); + req->timeout = FIRENZE_PCI_I2C_TIMEOUT; i2c_queue_req(plat_slot->req); while (retries-- > 0) { From patchwork Thu Aug 23 03:47:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 961162 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.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41wr3K0FbHz9s0n for ; Thu, 23 Aug 2018 13:47:57 +1000 (AEST) 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="sL+KmNpi"; 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 41wr3J13k0zF2FK for ; Thu, 23 Aug 2018 13:47:56 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="sL+KmNpi"; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c01::243; helo=mail-pl0-x243.google.com; envelope-from=oohall@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="sL+KmNpi"; dkim-atps=neutral Received: from mail-pl0-x243.google.com (mail-pl0-x243.google.com [IPv6:2607:f8b0:400e:c01::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41wr373mzSzDrWY for ; Thu, 23 Aug 2018 13:47:47 +1000 (AEST) Received: by mail-pl0-x243.google.com with SMTP id s17-v6so1772874plp.7 for ; Wed, 22 Aug 2018 20:47:47 -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; bh=89mtnP++qK7Gj37QUvFp4I0ZOTiED9n6FtUwRnlRBfQ=; b=sL+KmNpid8KbT27Sh+0WIQVJkakE1MjGfyn6LqOVBcUt+MPeCtGGr9GWuRxsdaFTz5 rEHfftkwg3UuaGJbfIY+0IbEYKBM8/8ZeXBGfTYCxjpCOppNvYe46zQVL8txeinRUptj L6Liv21azv0SReb++DJ9kwhsXU6+w8HWvG547pGGMNta7KBS1uJMCozlA3ahu9XUyT0J 5X2TvKWTtqXsv1Dl7sbI0V3EJH95jjeuEHTLbSAQ8gTwecy4GGkEVwAm0+shqzpSIpuD Usc0S3k5hYe1+Iro73KRwJvTO+v4Fkp1dThRZiPfMZMyr80rv5kBx4xoHJZ6R3M+DPFT nayQ== 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; bh=89mtnP++qK7Gj37QUvFp4I0ZOTiED9n6FtUwRnlRBfQ=; b=g4R9WX4/F0gFk9eHK0w6ipiVLDUzahfPofyCevmJneVrSn63GVlq4Ul01HOnzJrGTT xojqFIPQXRnG6f3GGqwqoB4ZrxXN61F0TMtBblo0hiG1xXbSs80Pq+XkB4SsfthT3EY9 UAqGzWzWq0n7MTDVyRtVbyvicdDZeZR8tg/MJPQ10J8i6pwenswIcUxn0sA1Qp322Ncb gBvc0qTNEgGeo5kDeu52AmS8HXP1cKwFuv2QMhHTr6Zx5ZfHLqWl3EZvgtsv63ImkoV4 +IdukhM4rVV1p1cIbliVJGcNl4CnJ/7t9D/2beCLZvlnsWnamGvULd9+5x5rKrPWOfzF kKSw== X-Gm-Message-State: AOUpUlF/Oe8yGgJNwv97+cMP30QBl8ti6XYX9W0VMEi44csBAybZtl9A TsJFYjeazK9ef3uqZbZi2qtNbmRPijE= X-Google-Smtp-Source: AA+uWPyHHSAHayfdXCrEKWNsyi74oEIgI/vsi5mrVAbpgKoqltsau2vZs9IprsrkMZIrZZbd4vDTiw== X-Received: by 2002:a17:902:b595:: with SMTP id a21-v6mr56775654pls.23.1534996065462; Wed, 22 Aug 2018 20:47:45 -0700 (PDT) Received: from flat-canetoad.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id l123-v6sm3652314pgl.82.2018.08.22.20.47.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Aug 2018 20:47:45 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Thu, 23 Aug 2018 13:47:31 +1000 Message-Id: <20180823034732.2467-2-oohall@gmail.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20180823034732.2467-1-oohall@gmail.com> References: <20180823034732.2467-1-oohall@gmail.com> Subject: [Skiboot] [PATCH 2/3] hw/p8-i2c: Remove p8_i2c_request structure X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" The p8_i2c_request structure is barely used and the only useful data it contains (port_num) can be derived from the bus pointer. Remove it in preperation for removing the per-bus allocation and free methods. Signed-off-by: Oliver O'Halloran --- hw/p8-i2c.c | 34 +++------------------------------- 1 file changed, 3 insertions(+), 31 deletions(-) diff --git a/hw/p8-i2c.c b/hw/p8-i2c.c index d3b383514186..67a68cd2a6df 100644 --- a/hw/p8-i2c.c +++ b/hw/p8-i2c.c @@ -229,15 +229,8 @@ struct p8_i2c_master_port { struct list_node link; }; -struct p8_i2c_request { - struct i2c_request req; - uint32_t port_num; - uint64_t timeout; -}; - static int occ_i2c_unlock(struct p8_i2c_master *master); - static int64_t i2cm_read_reg(struct p8_i2c_master *m, int reg, uint64_t *val) { return xscom_read(m->chip_id, m->xscom_base + reg, val); @@ -410,10 +403,6 @@ static int p8_i2c_prog_watermark(struct p8_i2c_master *master) static int p8_i2c_prog_mode(struct p8_i2c_master_port *port, bool enhanced_mode) { struct p8_i2c_master *master = port->master; - struct i2c_request *req = list_top(&master->req_list, - struct i2c_request, link); - struct p8_i2c_request *request = - container_of(req, struct p8_i2c_request, req); uint64_t mode, omode; int rc; @@ -424,7 +413,7 @@ static int p8_i2c_prog_mode(struct p8_i2c_master_port *port, bool enhanced_mode) return rc; } omode = mode; - mode = SETFIELD(I2C_MODE_PORT_NUM, mode, request->port_num); + mode = SETFIELD(I2C_MODE_PORT_NUM, mode, port->port_num); mode = SETFIELD(I2C_MODE_BIT_RATE_DIV, mode, port->bit_rate_div); if (enhanced_mode) mode |= I2C_MODE_ENHANCED; @@ -1282,29 +1271,12 @@ static int p8_i2c_queue_request(struct i2c_request *req) static struct i2c_request *p8_i2c_alloc_request(struct i2c_bus *bus) { - struct p8_i2c_master_port *port = - container_of(bus, struct p8_i2c_master_port, bus); - struct p8_i2c_request *request; - - request = zalloc(sizeof(*request)); - if (!request) { - prlog(PR_ERR, "I2C: Failed to allocate i2c request\n"); - return NULL; - } - - request->port_num = port->port_num; - request->req.bus = bus; - - return &request->req; + return zalloc(sizeof(struct i2c_request)); } - static void p8_i2c_free_request(struct i2c_request *req) { - struct p8_i2c_request *request = - container_of(req, struct p8_i2c_request, req); - free(request); + free(req); } - static uint64_t p8_i2c_run_request(struct i2c_request *req) { struct i2c_bus *bus = req->bus; From patchwork Thu Aug 23 03:47:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 961164 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41wr4L3YKgz9ryn for ; Thu, 23 Aug 2018 13:48:50 +1000 (AEST) 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="hIkb+ctR"; 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 41wr4L1hdPzDqnw for ; Thu, 23 Aug 2018 13:48:50 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="hIkb+ctR"; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c01::242; helo=mail-pl0-x242.google.com; envelope-from=oohall@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="hIkb+ctR"; dkim-atps=neutral Received: from mail-pl0-x242.google.com (mail-pl0-x242.google.com [IPv6:2607:f8b0:400e:c01::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41wr395rX6zDqnw for ; Thu, 23 Aug 2018 13:47:49 +1000 (AEST) Received: by mail-pl0-x242.google.com with SMTP id w14-v6so1772492plp.6 for ; Wed, 22 Aug 2018 20:47:49 -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; bh=PYw4obOxL3IUIaLs3SpQoSbNsocYDa/3tmYNTcUYrCs=; b=hIkb+ctRnZ44xvkKvX2cHWD4Di5mPvMbvqdQ03RDaNkr3T5z/YBISvM1qLn4bpypnK 6KgjGQY0yXrfE40CbG2pYZw2nNWHIGBB3u2dbxXRa5Lz9PXGiYJIrpKvwsCh3rQHweGV Xk08IRR8s/9ZEwppt3RpyGFfglZ0lU6cUJ15eyB6wb5TXILsvJIrMY2O4jcvbnBGiABk 2t2CXB3j2naxkaLtpCVh3wRQFh8BUiF5w5vAinJq6HCLCClnBdJRZB8d+FwTqbXZM1eP fnVUXwvOjTghzL5b4YHxdVterJk0yUuYKLtBqW9ovSelzrV7WNpeKEkSow4bMUgkLGJ9 xkzQ== 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; bh=PYw4obOxL3IUIaLs3SpQoSbNsocYDa/3tmYNTcUYrCs=; b=iD1ta78/gXDodOEQJ5MBUeu2pEH/RidLwE57aBazjUKaKOwCoNzcZ/qZEocyX6Er/m gDcM37GdlAOWkvLy98/JRLEeeDwHtDqVbzJS/XmtAWQeHC//13a39prWEVjlSbKUlbM5 G5EWp/LCfEnXDUFVViJhGENledEOwM6f72sFoXQZgsIEhEie8zVBZm20tlkdnY3uTIk3 IryBXYTv9STzeeU3r3WF1mVCY1qH0CXN8i80MHlSP5Rb3J8vmqX2wjCGk42lt6zQV+// APneA7ejrIZMw+z0H3J2VPSLe2DcSiuPSzN4prNx+sGJbrcI4slE4X429q97pfKdVrY7 T5jA== X-Gm-Message-State: AOUpUlHt6T4wET64WLDEl43cSb4MTHJrlJ3zKQuPe1KFLtqc3g5a1Ijz Drf+8uswbSgnfVy2kDvnAwnsIq9PF9A= X-Google-Smtp-Source: AA+uWPybdP8u9kZ6A4TxSDhXHjHypel73jQ07DAPWpwwas/3zwvMfNQG5K8b0OYmb0KPJkqAKYOS6Q== X-Received: by 2002:a17:902:6b44:: with SMTP id g4-v6mr56674881plt.50.1534996067409; Wed, 22 Aug 2018 20:47:47 -0700 (PDT) Received: from flat-canetoad.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id l123-v6sm3652314pgl.82.2018.08.22.20.47.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Aug 2018 20:47:46 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Thu, 23 Aug 2018 13:47:32 +1000 Message-Id: <20180823034732.2467-3-oohall@gmail.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20180823034732.2467-1-oohall@gmail.com> References: <20180823034732.2467-1-oohall@gmail.com> Subject: [Skiboot] [PATCH 3/3] core/i2c: Remove bus specific alloc and free callbacks X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" These are now pointless and they can be replaced with zalloc() and free(). Signed-off-by: Oliver O'Halloran --- core/i2c.c | 17 +++++++++-------- hw/p8-i2c.c | 10 ---------- include/i2c.h | 12 ------------ platforms/ibm-fsp/firenze-pci.c | 2 +- 4 files changed, 10 insertions(+), 31 deletions(-) diff --git a/core/i2c.c b/core/i2c.c index b0d5d34bf692..26926fc28d17 100644 --- a/core/i2c.c +++ b/core/i2c.c @@ -51,7 +51,7 @@ 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); - i2c_free_req(req); + free(req); } static int opal_i2c_request(uint64_t async_token, uint32_t bus_id, @@ -80,7 +80,7 @@ static int opal_i2c_request(uint64_t async_token, uint32_t bus_id, return OPAL_PARAMETER; } - req = i2c_alloc_req(bus); + req = zalloc(sizeof(*req)); if (!req) { /** * @fwts-label I2CFailedAllocation @@ -110,7 +110,7 @@ static int opal_i2c_request(uint64_t async_token, uint32_t bus_id, req->offset_bytes = oreq->subaddr_sz; break; default: - bus->free_req(req); + free(req); return OPAL_PARAMETER; } req->dev_addr = oreq->addr; @@ -121,14 +121,14 @@ static int opal_i2c_request(uint64_t async_token, uint32_t bus_id, req->bus = bus; if (i2c_check_quirk(req, &rc)) { - i2c_free_req(req); + free(req); return rc; } /* Finally, queue the OPAL i2c request and return */ rc = i2c_queue_req(req); if (rc) { - i2c_free_req(req); + free(req); return rc; } @@ -189,7 +189,7 @@ int i2c_request_send(int bus_id, int dev_addr, int read_write, return OPAL_PARAMETER; } - req = i2c_alloc_req(bus); + req = zalloc(sizeof(*req)); if (!req) { /** * @fwts-label I2CAllocationFailed @@ -197,10 +197,11 @@ int i2c_request_send(int bus_id, int dev_addr, int read_write, * i2c_request. This points to an OPAL bug as OPAL run out of * memory and this should never happen. */ - prlog(PR_ERR, "I2C: i2c_alloc_req failed\n"); + prlog(PR_ERR, "I2C: allocating i2c_request failed\n"); return OPAL_INTERNAL_ERROR; } + req->bus = bus; req->dev_addr = dev_addr; req->op = read_write; req->offset = offset; @@ -239,7 +240,7 @@ int i2c_request_send(int bus_id, int dev_addr, int read_write, (rc) ? "!!!!" : "----", req->op, req->offset, *(uint64_t*) buf, req->rw_len, tb_to_msecs(waited), timeout, rc); - i2c_free_req(req); + free(req); if (rc) return OPAL_HARDWARE; diff --git a/hw/p8-i2c.c b/hw/p8-i2c.c index 67a68cd2a6df..fa5af7cc495f 100644 --- a/hw/p8-i2c.c +++ b/hw/p8-i2c.c @@ -1269,14 +1269,6 @@ static int p8_i2c_queue_request(struct i2c_request *req) return rc; } -static struct i2c_request *p8_i2c_alloc_request(struct i2c_bus *bus) -{ - return zalloc(sizeof(struct i2c_request)); -} -static void p8_i2c_free_request(struct i2c_request *req) -{ - free(req); -} static uint64_t p8_i2c_run_request(struct i2c_request *req) { struct i2c_bus *bus = req->bus; @@ -1604,8 +1596,6 @@ static void p8_i2c_init_one(struct dt_node *i2cm, enum p8_i2c_master_type type) p8_i2c_get_bit_rate_divisor(lb_freq, speed); port->bus.dt_node = i2cm_port; port->bus.queue_req = p8_i2c_queue_request; - port->bus.alloc_req = p8_i2c_alloc_request; - port->bus.free_req = p8_i2c_free_request; port->bus.run_req = p8_i2c_run_request; timeout_ms = dt_prop_get_u32_def(i2cm_port, "timeout-ms", diff --git a/include/i2c.h b/include/i2c.h index f33c2d83c195..67f8b995d5db 100644 --- a/include/i2c.h +++ b/include/i2c.h @@ -24,8 +24,6 @@ struct i2c_bus { struct dt_node *dt_node; uint32_t opal_id; int (*queue_req)(struct i2c_request *req); - struct i2c_request *(*alloc_req)(struct i2c_bus *bus); - void (*free_req)(struct i2c_request *req); uint64_t (*run_req)(struct i2c_request *req); int (*check_quirk)(void *data, struct i2c_request *req, int *rc); void *check_quirk_data; @@ -70,16 +68,6 @@ struct i2c_request { extern void i2c_add_bus(struct i2c_bus *bus); extern struct i2c_bus *i2c_find_bus_by_id(uint32_t opal_id); -static inline struct i2c_request *i2c_alloc_req(struct i2c_bus *bus) -{ - return bus->alloc_req(bus); -} - -static inline void i2c_free_req(struct i2c_request *req) -{ - req->bus->free_req(req); -} - static inline int i2c_queue_req(struct i2c_request *req) { return req->bus->queue_req(req); diff --git a/platforms/ibm-fsp/firenze-pci.c b/platforms/ibm-fsp/firenze-pci.c index 44fa6b5f1532..e075e37f378e 100644 --- a/platforms/ibm-fsp/firenze-pci.c +++ b/platforms/ibm-fsp/firenze-pci.c @@ -825,7 +825,7 @@ static void firenze_pci_setup_power_mgt(struct pci_slot *slot, if (!plat_slot->i2c_bus) return; - plat_slot->req = i2c_alloc_req(plat_slot->i2c_bus); + plat_slot->req = zalloc(sizeof(*plat_slot->req)); if (!plat_slot->req) return;