From patchwork Mon Sep 20 03:07:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sireesh Kodali X-Patchwork-Id: 12504525 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 996C2C433FE for ; Mon, 20 Sep 2021 03:08:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7BE4E61019 for ; Mon, 20 Sep 2021 03:08:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231562AbhITDKH (ORCPT ); Sun, 19 Sep 2021 23:10:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229626AbhITDKF (ORCPT ); Sun, 19 Sep 2021 23:10:05 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E67FDC061574; Sun, 19 Sep 2021 20:08:38 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id on12-20020a17090b1d0c00b001997c60aa29so11114061pjb.1; Sun, 19 Sep 2021 20:08:38 -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=zmMZOAHgTdh616hp06L3sF5WAAO2pLT5BUpQivYWsdg=; b=Nos1fs8WfPVA9K4ec57AGhj3TGrFCLXzxE17ag5vbX43KyJxhSUO+SwS3S0aErW+bG FyaNh16pPjKUFl1rwTenwJpqTi/+E5kpo86+oUWHTRhrldhSejRQNbwtOaWUPdMQicIp pgFWAu07E8hRGdq3vKzKLhWR2zvimM/mI8rsIErWdO6t9wFuxhWmBy6Hwo32kI6s6lO1 HEuw/Wt6LoDXeXGRtUccc37riJlYPqIcDXFfXJjHsMXWfLBOq/KesyP+rr0Tg8Oh5pnf 28kpFn1wDVnhiWeldCUAlrkK6qrrVzFoQ8iEbNW8a0GbXRV+jnDilfHBAUmcctvNM3rh d23w== 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=zmMZOAHgTdh616hp06L3sF5WAAO2pLT5BUpQivYWsdg=; b=CGqe0lC9/mFXLpKHBIkvmZC45Rw66vcb0Pts8jMNLZRna+WBSWFyoJxFFM6WJaQsrN YTRitBq0nIWD0uoCb+m0ZYVUeLDdOFEC0wEkU//Fn7hQkCh4PmjdmdTd/9nLZ+8XSbYn uwXx9pF57SHZ4MhFh1WUNRx+omTDqaxF9Z/g29fGHEvgrWgGtTD0fAlZGcYyyVzSLycY m1x26VnPrxEjxbZpstsCLe9lO0i4+YN6f/V9yp93zHLamht2iexMZ7fo4cKvw1+7rIYx PHPeq5cdG0TmXyl0DNwSDJR8ltk/X3Pp1OD1dmMVlX16o4u2tke5iBiLSAnBIz9BABxd nKRw== X-Gm-Message-State: AOAM530ISfbPg4Y1Jah9HLpL8aaaPFUO6N9ZZeqe4ioSAF8p7y8rEg5C m+Lr+kmHfP8KhhSDXpbdHM06jNiscynUX7Ot X-Google-Smtp-Source: ABdhPJwWZzgDwh6RqSj8/TuWxlcFs/Rq5lYyCOnoRVrwKswqHtJV4OWrbmKUvidSkEeTdQ0dMzVHWA== X-Received: by 2002:a17:90b:38cf:: with SMTP id nn15mr4677301pjb.81.1632107318285; Sun, 19 Sep 2021 20:08:38 -0700 (PDT) Received: from skynet-linux.local ([106.201.127.154]) by smtp.googlemail.com with ESMTPSA id l11sm16295065pjg.22.2021.09.19.20.08.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Sep 2021 20:08:38 -0700 (PDT) From: Sireesh Kodali To: phone-devel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, elder@kernel.org Cc: Vladimir Lypak , Sireesh Kodali , "David S. Miller" , Jakub Kicinski Subject: [RFC PATCH 01/17] net: ipa: Correct ipa_status_opcode enumeration Date: Mon, 20 Sep 2021 08:37:55 +0530 Message-Id: <20210920030811.57273-2-sireeshkodali1@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920030811.57273-1-sireeshkodali1@gmail.com> References: <20210920030811.57273-1-sireeshkodali1@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Vladimir Lypak The values in the enumaration were defined as bitmasks (base 2 exponents of actual opcodes). Meanwhile, it's used not as bitmask ipa_endpoint_status_skip and ipa_status_formet_packet functions (compared directly with opcode from status packet). This commit converts these values to actual hardware constansts. Signed-off-by: Vladimir Lypak Signed-off-by: Sireesh Kodali --- drivers/net/ipa/ipa_endpoint.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index 5528d97110d5..29227de6661f 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -41,10 +41,10 @@ /** enum ipa_status_opcode - status element opcode hardware values */ enum ipa_status_opcode { - IPA_STATUS_OPCODE_PACKET = 0x01, - IPA_STATUS_OPCODE_DROPPED_PACKET = 0x04, - IPA_STATUS_OPCODE_SUSPENDED_PACKET = 0x08, - IPA_STATUS_OPCODE_PACKET_2ND_PASS = 0x40, + IPA_STATUS_OPCODE_PACKET = 0, + IPA_STATUS_OPCODE_DROPPED_PACKET = 2, + IPA_STATUS_OPCODE_SUSPENDED_PACKET = 3, + IPA_STATUS_OPCODE_PACKET_2ND_PASS = 6, }; /** enum ipa_status_exception - status element exception type */ From patchwork Mon Sep 20 03:07:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sireesh Kodali X-Patchwork-Id: 12504527 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5916C433F5 for ; Mon, 20 Sep 2021 03:08:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CD97A60FBF for ; Mon, 20 Sep 2021 03:08:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231770AbhITDKO (ORCPT ); Sun, 19 Sep 2021 23:10:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231156AbhITDKN (ORCPT ); Sun, 19 Sep 2021 23:10:13 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 088C1C061766; Sun, 19 Sep 2021 20:08:47 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id n18so10093127plp.7; Sun, 19 Sep 2021 20:08:47 -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=l0RV9upSf8wGPcjVwJSGyhGah90Hq8k0EVM2Q6lwx6E=; b=N0HtU5lXTjygkZrS+geEd1RecpFbNG3anT3hTvAXky+XdazYyl5xqeNyczGRYiIQQF OyxTcQSjUEgAfpwXa9dFIQ+ZcaJ+lOPcW/ROrTfz5FhMpiH6lm/WqsfpglETdJ9pO6BW B36nL09zLOHc8jtctHcsLuNUSu4++yQQaOLR6SAzJXsz5AKSC7d7EGOszxzCjvcTexqH ISs3svHcJPAwXTiahqfvI4AZkyL9B4So33gettnoc1FXQVM5ZozWhfSBTNyiTeKostgs zzJl24qm0ap4mtaGTDjyRezfkG3a8vS3nRK6a119cj47Hb9vCShCpx8O0UyebmdZkmZS qNFQ== 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=l0RV9upSf8wGPcjVwJSGyhGah90Hq8k0EVM2Q6lwx6E=; b=AjnVOovWhJCIVZl+U70avuuo408xWize6iYNYNlviGMHyto9Nb8rtUU/HaSmQfq+WE wUI8JFwgKxmP1vnBTJu/fDpz3W/WGl0HvfnMKbf2jJmUmGgVaLzf/w9udtyX8GVmYUnO yMKmkFXsJ6f6JvXuhmR86gum0/o4eunf5RzmgsVI66VDsIR2MdVFRayZNTRX7NmB4gHA rrUentFvlEViwkghQxinJfDmiff/Gkx7QJND/uk+prJVlW46ZhdKiQgzwda9Tw9Wi7ko ujWe4Y6lq4/a8AuC+lzy5HTQ1Dw8uw5LFuoPtaMfGPgdZYtUbOHB5e6Z6bsi2xP3F0nE CY0Q== X-Gm-Message-State: AOAM5304s60db1pegtZFQau7qYNnUA6mFsEupO2gxbz5OWAczgSi6HPr fEXLnhov8FuFeRz4liQoBTxlLa4EBHwsAQDa X-Google-Smtp-Source: ABdhPJy0HxBfROYETdVWfX905Z8zz2lXrC812H4jf7f9v+P8jVycfvK0cx6QvNjOTvTaCVJchTrSXw== X-Received: by 2002:a17:90a:e7ca:: with SMTP id kb10mr35553804pjb.33.1632107326287; Sun, 19 Sep 2021 20:08:46 -0700 (PDT) Received: from skynet-linux.local ([106.201.127.154]) by smtp.googlemail.com with ESMTPSA id l11sm16295065pjg.22.2021.09.19.20.08.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Sep 2021 20:08:45 -0700 (PDT) From: Sireesh Kodali To: phone-devel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, elder@kernel.org Cc: Vladimir Lypak , Sireesh Kodali , "David S. Miller" , Jakub Kicinski Subject: [RFC PATCH 02/17] net: ipa: revert to IPA_TABLE_ENTRY_SIZE for 32-bit IPA support Date: Mon, 20 Sep 2021 08:37:56 +0530 Message-Id: <20210920030811.57273-3-sireeshkodali1@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920030811.57273-1-sireeshkodali1@gmail.com> References: <20210920030811.57273-1-sireeshkodali1@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Vladimir Lypak IPA v2.x is 32 bit. Having an IPA_TABLE_ENTRY size makes it easier to deal with supporting both 32 bit and 64 bit IPA versions Signed-off-by: Vladimir Lypak Signed-off-by: Sireesh Kodali --- drivers/net/ipa/ipa_qmi.c | 10 ++++++---- drivers/net/ipa/ipa_table.c | 29 +++++++++++++---------------- drivers/net/ipa/ipa_table.h | 4 ++++ 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/drivers/net/ipa/ipa_qmi.c b/drivers/net/ipa/ipa_qmi.c index 90f3aec55b36..7e2fe701cc4d 100644 --- a/drivers/net/ipa/ipa_qmi.c +++ b/drivers/net/ipa/ipa_qmi.c @@ -308,12 +308,12 @@ init_modem_driver_req(struct ipa_qmi *ipa_qmi) mem = ipa_mem_find(ipa, IPA_MEM_V4_ROUTE); req.v4_route_tbl_info_valid = 1; req.v4_route_tbl_info.start = ipa->mem_offset + mem->offset; - req.v4_route_tbl_info.count = mem->size / sizeof(__le64); + req.v4_route_tbl_info.count = mem->size / IPA_TABLE_ENTRY_SIZE(ipa->version); mem = ipa_mem_find(ipa, IPA_MEM_V6_ROUTE); req.v6_route_tbl_info_valid = 1; req.v6_route_tbl_info.start = ipa->mem_offset + mem->offset; - req.v6_route_tbl_info.count = mem->size / sizeof(__le64); + req.v6_route_tbl_info.count = mem->size / IPA_TABLE_ENTRY_SIZE(ipa->version); mem = ipa_mem_find(ipa, IPA_MEM_V4_FILTER); req.v4_filter_tbl_start_valid = 1; @@ -352,7 +352,8 @@ init_modem_driver_req(struct ipa_qmi *ipa_qmi) req.v4_hash_route_tbl_info_valid = 1; req.v4_hash_route_tbl_info.start = ipa->mem_offset + mem->offset; - req.v4_hash_route_tbl_info.count = mem->size / sizeof(__le64); + req.v4_hash_route_tbl_info.count = + mem->size / IPA_TABLE_ENTRY_SIZE(ipa->version); } mem = ipa_mem_find(ipa, IPA_MEM_V6_ROUTE_HASHED); @@ -360,7 +361,8 @@ init_modem_driver_req(struct ipa_qmi *ipa_qmi) req.v6_hash_route_tbl_info_valid = 1; req.v6_hash_route_tbl_info.start = ipa->mem_offset + mem->offset; - req.v6_hash_route_tbl_info.count = mem->size / sizeof(__le64); + req.v6_hash_route_tbl_info.count = + mem->size / IPA_TABLE_ENTRY_SIZE(ipa->version); } mem = ipa_mem_find(ipa, IPA_MEM_V4_FILTER_HASHED); diff --git a/drivers/net/ipa/ipa_table.c b/drivers/net/ipa/ipa_table.c index 1da334f54944..96c467c80a2e 100644 --- a/drivers/net/ipa/ipa_table.c +++ b/drivers/net/ipa/ipa_table.c @@ -118,7 +118,8 @@ * 32-bit all-zero rule list terminator. The "zero rule" is simply an * all-zero rule followed by the list terminator. */ -#define IPA_ZERO_RULE_SIZE (2 * sizeof(__le32)) +#define IPA_ZERO_RULE_SIZE(version) \ + (IPA_IS_64BIT(version) ? 2 * sizeof(__le32) : sizeof(__le32)) /* Check things that can be validated at build time. */ static void ipa_table_validate_build(void) @@ -132,12 +133,6 @@ static void ipa_table_validate_build(void) */ BUILD_BUG_ON(sizeof(dma_addr_t) > sizeof(__le64)); - /* A "zero rule" is used to represent no filtering or no routing. - * It is a 64-bit block of zeroed memory. Code in ipa_table_init() - * assumes that it can be written using a pointer to __le64. - */ - BUILD_BUG_ON(IPA_ZERO_RULE_SIZE != sizeof(__le64)); - /* Impose a practical limit on the number of routes */ BUILD_BUG_ON(IPA_ROUTE_COUNT_MAX > 32); /* The modem must be allotted at least one route table entry */ @@ -236,7 +231,7 @@ static dma_addr_t ipa_table_addr(struct ipa *ipa, bool filter_mask, u16 count) /* Skip over the zero rule and possibly the filter mask */ skip = filter_mask ? 1 : 2; - return ipa->table_addr + skip * sizeof(*ipa->table_virt); + return ipa->table_addr + skip * IPA_TABLE_ENTRY_SIZE(ipa->version); } static void ipa_table_reset_add(struct gsi_trans *trans, bool filter, @@ -255,8 +250,8 @@ static void ipa_table_reset_add(struct gsi_trans *trans, bool filter, if (filter) first++; /* skip over bitmap */ - offset = mem->offset + first * sizeof(__le64); - size = count * sizeof(__le64); + offset = mem->offset + first * IPA_TABLE_ENTRY_SIZE(ipa->version); + size = count * IPA_TABLE_ENTRY_SIZE(ipa->version); addr = ipa_table_addr(ipa, false, count); ipa_cmd_dma_shared_mem_add(trans, offset, size, addr, true); @@ -434,11 +429,11 @@ static void ipa_table_init_add(struct gsi_trans *trans, bool filter, count = 1 + hweight32(ipa->filter_map); hash_count = hash_mem->size ? count : 0; } else { - count = mem->size / sizeof(__le64); - hash_count = hash_mem->size / sizeof(__le64); + count = mem->size / IPA_TABLE_ENTRY_SIZE(ipa->version); + hash_count = hash_mem->size / IPA_TABLE_ENTRY_SIZE(ipa->version); } - size = count * sizeof(__le64); - hash_size = hash_count * sizeof(__le64); + size = count * IPA_TABLE_ENTRY_SIZE(ipa->version); + hash_size = hash_count * IPA_TABLE_ENTRY_SIZE(ipa->version); addr = ipa_table_addr(ipa, filter, count); hash_addr = ipa_table_addr(ipa, filter, hash_count); @@ -621,7 +616,8 @@ int ipa_table_init(struct ipa *ipa) * by dma_alloc_coherent() is guaranteed to be a power-of-2 number * of pages, which satisfies the rule alignment requirement. */ - size = IPA_ZERO_RULE_SIZE + (1 + count) * sizeof(__le64); + size = IPA_ZERO_RULE_SIZE(ipa->version) + + (1 + count) * IPA_TABLE_ENTRY_SIZE(ipa->version); virt = dma_alloc_coherent(dev, size, &addr, GFP_KERNEL); if (!virt) return -ENOMEM; @@ -653,7 +649,8 @@ void ipa_table_exit(struct ipa *ipa) struct device *dev = &ipa->pdev->dev; size_t size; - size = IPA_ZERO_RULE_SIZE + (1 + count) * sizeof(__le64); + size = IPA_ZERO_RULE_SIZE(ipa->version) + + (1 + count) * IPA_TABLE_ENTRY_SIZE(ipa->version); dma_free_coherent(dev, size, ipa->table_virt, ipa->table_addr); ipa->table_addr = 0; diff --git a/drivers/net/ipa/ipa_table.h b/drivers/net/ipa/ipa_table.h index b6a9a0d79d68..78a168ce6558 100644 --- a/drivers/net/ipa/ipa_table.h +++ b/drivers/net/ipa/ipa_table.h @@ -10,6 +10,10 @@ struct ipa; +/* The size of a filter or route table entry */ +#define IPA_TABLE_ENTRY_SIZE(version) \ + (IPA_IS_64BIT(version) ? sizeof(__le64) : sizeof(__le32)) + /* The maximum number of filter table entries (IPv4, IPv6; hashed or not) */ #define IPA_FILTER_COUNT_MAX 14 From patchwork Mon Sep 20 03:07:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sireesh Kodali X-Patchwork-Id: 12504537 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90E75C43219 for ; Mon, 20 Sep 2021 03:09:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 791DC60FBF for ; Mon, 20 Sep 2021 03:09:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232984AbhITDK3 (ORCPT ); Sun, 19 Sep 2021 23:10:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233280AbhITDK0 (ORCPT ); Sun, 19 Sep 2021 23:10:26 -0400 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1216C061574; Sun, 19 Sep 2021 20:08:59 -0700 (PDT) Received: by mail-pf1-x434.google.com with SMTP id q23so12820506pfs.9; Sun, 19 Sep 2021 20:08:59 -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=qrc1Tvu6RHZZL2LjE0JmimJdtTbThMCZQcoVeNYsf6A=; b=V2T8Uh2rKKSNmMibPGCS0e3qRV3u8fEaG4rkYdPeXaTWmffoakQr21FjGo5aIqk103 xolQ1BqEkh0wqrfMYUB9M8CjNXQhFhjffOTWu9tErCN5c88Ddy/VHANBL2QI9Z7x5K+4 k+iZWR7zcEgxYTm3Q9pvWAFDBIQDajEfOlcc92YNj4XTiHtxT4T7NqK1SacF54ByWVig yazMn20C1q3hqhBTRfK0PAATuTQyIQrZJ+yOhHfSPXyL56+5QhCZh2wIPau4FH1p6Y/g o0bIyrpynXbvPuRWeVU+hGUrLtprWLvRglkP1k6PTyQ/vNCjBoqLWfI+oMbvLbVve4Sd 8lzQ== 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=qrc1Tvu6RHZZL2LjE0JmimJdtTbThMCZQcoVeNYsf6A=; b=21vPBusXOARIgx3LwEPpLkppGuDRWjCkoVcz/j5quGRKbX7JPbqNTGpJS4CpbpEI+w 2QVFGLah2rqL0BsCezNpH42y9kqrer02SnVUgzGVuPeb78IX+KsTtPfJN69bQWnYplhz zo/lPIN/9pvBDWIUPoM0P8E+Ld6xp93ARtSh9ZYM0Pky+SUuWDX7HzyProxuF8IaVUdk cZNFPIPf+0xfuYB7VAPoE5mUU41VJqGuo4yatEoPmlId4pfFQKcgU645BlWtTg+6Uizr J/Oa5ecF4nYYl91yqC85doZ4+3pWT/R/VrPvIIxLI1JSEwPLkEp7LvsLE9JQ+MfIS2mO czyA== X-Gm-Message-State: AOAM531oNeS2clPhOp3daPBPvU4xmZxL/XZj81afv0n7GQ0dhUWI3xyC iLm1i9meqo5C3LuzjWPaJFvwjQGwMbxutvej X-Google-Smtp-Source: ABdhPJzltjh8yCcW9/fuTMJRSwsZfkyeIPLNwo5DEraaWS5/5qbpG+pQDxpwAs8vrOveudnhRQJ/dw== X-Received: by 2002:a62:36c6:0:b0:444:bdc4:3242 with SMTP id d189-20020a6236c6000000b00444bdc43242mr15769646pfa.3.1632107339013; Sun, 19 Sep 2021 20:08:59 -0700 (PDT) Received: from skynet-linux.local ([106.201.127.154]) by smtp.googlemail.com with ESMTPSA id l11sm16295065pjg.22.2021.09.19.20.08.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Sep 2021 20:08:58 -0700 (PDT) From: Sireesh Kodali To: phone-devel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, elder@kernel.org Cc: Vladimir Lypak , Sireesh Kodali , "David S. Miller" , Jakub Kicinski Subject: [RFC PATCH 04/17] net: ipa: Establish ipa_dma interface Date: Mon, 20 Sep 2021 08:37:58 +0530 Message-Id: <20210920030811.57273-5-sireeshkodali1@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920030811.57273-1-sireeshkodali1@gmail.com> References: <20210920030811.57273-1-sireeshkodali1@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Vladimir Lypak Establish callback-based interface to abstract GSI and BAM DMA differences. Interface is based on prototypes from ipa_dma.h (old gsi.h). Callbacks are stored in struct ipa_dma (old struct gsi) and assigned in gsi_init. Signed-off-by: Vladimir Lypak Signed-off-by: Sireesh Kodali --- drivers/net/ipa/gsi.c | 30 ++++++-- drivers/net/ipa/ipa_dma.h | 133 ++++++++++++++++++++++----------- drivers/net/ipa/ipa_endpoint.c | 28 +++---- drivers/net/ipa/ipa_main.c | 18 ++--- drivers/net/ipa/ipa_power.c | 4 +- drivers/net/ipa/ipa_trans.c | 2 +- 6 files changed, 138 insertions(+), 77 deletions(-) diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 74ae0d07f859..39d9ca620a9f 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -99,6 +99,10 @@ #define GSI_ISR_MAX_ITER 50 /* Detect interrupt storms */ +static u32 gsi_channel_tre_max(struct ipa_dma *gsi, u32 channel_id); +static u32 gsi_channel_trans_tre_max(struct ipa_dma *gsi, u32 channel_id); +static void gsi_exit(struct ipa_dma *gsi); + /* An entry in an event ring */ struct gsi_event { __le64 xfer_ptr; @@ -869,7 +873,7 @@ static int __gsi_channel_start(struct ipa_channel *channel, bool resume) } /* Start an allocated GSI channel */ -int gsi_channel_start(struct ipa_dma *gsi, u32 channel_id) +static int gsi_channel_start(struct ipa_dma *gsi, u32 channel_id) { struct ipa_channel *channel = &gsi->channel[channel_id]; int ret; @@ -924,7 +928,7 @@ static int __gsi_channel_stop(struct ipa_channel *channel, bool suspend) } /* Stop a started channel */ -int gsi_channel_stop(struct ipa_dma *gsi, u32 channel_id) +static int gsi_channel_stop(struct ipa_dma *gsi, u32 channel_id) { struct ipa_channel *channel = &gsi->channel[channel_id]; int ret; @@ -941,7 +945,7 @@ int gsi_channel_stop(struct ipa_dma *gsi, u32 channel_id) } /* Reset and reconfigure a channel, (possibly) enabling the doorbell engine */ -void gsi_channel_reset(struct ipa_dma *gsi, u32 channel_id, bool doorbell) +static void gsi_channel_reset(struct ipa_dma *gsi, u32 channel_id, bool doorbell) { struct ipa_channel *channel = &gsi->channel[channel_id]; @@ -1931,7 +1935,7 @@ int gsi_setup(struct ipa_dma *gsi) } /* Inverse of gsi_setup() */ -void gsi_teardown(struct ipa_dma *gsi) +static void gsi_teardown(struct ipa_dma *gsi) { gsi_channel_teardown(gsi); gsi_irq_teardown(gsi); @@ -2194,6 +2198,18 @@ int gsi_init(struct ipa_dma *gsi, struct platform_device *pdev, gsi->dev = dev; gsi->version = version; + gsi->setup = gsi_setup; + gsi->teardown = gsi_teardown; + gsi->exit = gsi_exit; + gsi->suspend = gsi_suspend; + gsi->resume = gsi_resume; + gsi->channel_tre_max = gsi_channel_tre_max; + gsi->channel_trans_tre_max = gsi_channel_trans_tre_max; + gsi->channel_start = gsi_channel_start; + gsi->channel_stop = gsi_channel_stop; + gsi->channel_reset = gsi_channel_reset; + gsi->channel_suspend = gsi_channel_suspend; + gsi->channel_resume = gsi_channel_resume; /* GSI uses NAPI on all channels. Create a dummy network device * for the channel NAPI contexts to be associated with. @@ -2250,7 +2266,7 @@ int gsi_init(struct ipa_dma *gsi, struct platform_device *pdev, } /* Inverse of gsi_init() */ -void gsi_exit(struct ipa_dma *gsi) +static void gsi_exit(struct ipa_dma *gsi) { mutex_destroy(&gsi->mutex); gsi_channel_exit(gsi); @@ -2277,7 +2293,7 @@ void gsi_exit(struct ipa_dma *gsi) * substantially reduce pool memory requirements. The number we * reduce it by matches the number added in ipa_trans_pool_init(). */ -u32 gsi_channel_tre_max(struct ipa_dma *gsi, u32 channel_id) +static u32 gsi_channel_tre_max(struct ipa_dma *gsi, u32 channel_id) { struct ipa_channel *channel = &gsi->channel[channel_id]; @@ -2286,7 +2302,7 @@ u32 gsi_channel_tre_max(struct ipa_dma *gsi, u32 channel_id) } /* Returns the maximum number of TREs in a single transaction for a channel */ -u32 gsi_channel_trans_tre_max(struct ipa_dma *gsi, u32 channel_id) +static u32 gsi_channel_trans_tre_max(struct ipa_dma *gsi, u32 channel_id) { struct ipa_channel *channel = &gsi->channel[channel_id]; diff --git a/drivers/net/ipa/ipa_dma.h b/drivers/net/ipa/ipa_dma.h index d053929ca3e3..1a23e6ac5785 100644 --- a/drivers/net/ipa/ipa_dma.h +++ b/drivers/net/ipa/ipa_dma.h @@ -163,64 +163,96 @@ struct ipa_dma { struct completion completion; /* for global EE commands */ int result; /* Negative errno (generic commands) */ struct mutex mutex; /* protects commands, programming */ + + int (*setup)(struct ipa_dma *dma_subsys); + void (*teardown)(struct ipa_dma *dma_subsys); + void (*exit)(struct ipa_dma *dma_subsys); + void (*suspend)(struct ipa_dma *dma_subsys); + void (*resume)(struct ipa_dma *dma_subsys); + u32 (*channel_tre_max)(struct ipa_dma *dma_subsys, u32 channel_id); + u32 (*channel_trans_tre_max)(struct ipa_dma *dma_subsys, u32 channel_id); + int (*channel_start)(struct ipa_dma *dma_subsys, u32 channel_id); + int (*channel_stop)(struct ipa_dma *dma_subsys, u32 channel_id); + void (*channel_reset)(struct ipa_dma *dma_subsys, u32 channel_id, bool doorbell); + int (*channel_suspend)(struct ipa_dma *dma_subsys, u32 channel_id); + int (*channel_resume)(struct ipa_dma *dma_subsys, u32 channel_id); + void (*trans_commit)(struct ipa_trans *trans, bool ring_db); }; /** - * gsi_setup() - Set up the GSI subsystem - * @gsi: Address of GSI structure embedded in an IPA structure + * ipa_dma_setup() - Set up the DMA subsystem + * @dma_subsys: Address of ipa_dma structure embedded in an IPA structure * * Return: 0 if successful, or a negative error code * - * Performs initialization that must wait until the GSI hardware is + * Performs initialization that must wait until the GSI/BAM hardware is * ready (including firmware loaded). */ -int gsi_setup(struct ipa_dma *dma_subsys); +static inline int ipa_dma_setup(struct ipa_dma *dma_subsys) +{ + return dma_subsys->setup(dma_subsys); +} /** - * gsi_teardown() - Tear down GSI subsystem - * @gsi: GSI address previously passed to a successful gsi_setup() call + * ipa_dma_teardown() - Tear down DMA subsystem + * @dma_subsys: ipa_dma address previously passed to a successful ipa_dma_setup() call */ -void gsi_teardown(struct ipa_dma *dma_subsys); +static inline void ipa_dma_teardown(struct ipa_dma *dma_subsys) +{ + dma_subsys->teardown(dma_subsys); +} /** - * gsi_channel_tre_max() - Channel maximum number of in-flight TREs - * @gsi: GSI pointer + * ipa_channel_tre_max() - Channel maximum number of in-flight TREs + * @dma_subsys: pointer to ipa_dma structure * @channel_id: Channel whose limit is to be returned * * Return: The maximum number of TREs oustanding on the channel */ -u32 gsi_channel_tre_max(struct ipa_dma *dma_subsys, u32 channel_id); +static inline u32 ipa_channel_tre_max(struct ipa_dma *dma_subsys, u32 channel_id) +{ + return dma_subsys->channel_tre_max(dma_subsys, channel_id); +} /** - * gsi_channel_trans_tre_max() - Maximum TREs in a single transaction - * @gsi: GSI pointer + * ipa_channel_trans_tre_max() - Maximum TREs in a single transaction + * @dma_subsys: pointer to ipa_dma structure * @channel_id: Channel whose limit is to be returned * * Return: The maximum TRE count per transaction on the channel */ -u32 gsi_channel_trans_tre_max(struct ipa_dma *dma_subsys, u32 channel_id); +static inline u32 ipa_channel_trans_tre_max(struct ipa_dma *dma_subsys, u32 channel_id) +{ + return dma_subsys->channel_trans_tre_max(dma_subsys, channel_id); +} /** - * gsi_channel_start() - Start an allocated GSI channel - * @gsi: GSI pointer + * ipa_channel_start() - Start an allocated DMA channel + * @dma_subsys: pointer to ipa_dma structure * @channel_id: Channel to start * * Return: 0 if successful, or a negative error code */ -int gsi_channel_start(struct ipa_dma *dma_subsys, u32 channel_id); +static inline int ipa_channel_start(struct ipa_dma *dma_subsys, u32 channel_id) +{ + return dma_subsys->channel_start(dma_subsys, channel_id); +} /** - * gsi_channel_stop() - Stop a started GSI channel - * @gsi: GSI pointer returned by gsi_setup() + * ipa_channel_stop() - Stop a started DMA channel + * @dma_subsys: pointer to ipa_dma structure returned by ipa_dma_setup() * @channel_id: Channel to stop * * Return: 0 if successful, or a negative error code */ -int gsi_channel_stop(struct ipa_dma *dma_subsys, u32 channel_id); +static inline int ipa_channel_stop(struct ipa_dma *dma_subsys, u32 channel_id) +{ + return dma_subsys->channel_stop(dma_subsys, channel_id); +} /** - * gsi_channel_reset() - Reset an allocated GSI channel - * @gsi: GSI pointer + * ipa_channel_reset() - Reset an allocated DMA channel + * @dma_subsys: pointer to ipa_dma structure * @channel_id: Channel to be reset * @doorbell: Whether to (possibly) enable the doorbell engine * @@ -230,41 +262,49 @@ int gsi_channel_stop(struct ipa_dma *dma_subsys, u32 channel_id); * GSI hardware relinquishes ownership of all pending receive buffer * transactions and they will complete with their cancelled flag set. */ -void gsi_channel_reset(struct ipa_dma *dma_subsys, u32 channel_id, bool doorbell); +static inline void ipa_channel_reset(struct ipa_dma *dma_subsys, u32 channel_id, bool doorbell) +{ + dma_subsys->channel_reset(dma_subsys, channel_id, doorbell); +} -/** - * gsi_suspend() - Prepare the GSI subsystem for suspend - * @gsi: GSI pointer - */ -void gsi_suspend(struct ipa_dma *dma_subsys); /** - * gsi_resume() - Resume the GSI subsystem following suspend - * @gsi: GSI pointer - */ -void gsi_resume(struct ipa_dma *dma_subsys); - -/** - * gsi_channel_suspend() - Suspend a GSI channel - * @gsi: GSI pointer + * ipa_channel_suspend() - Suspend a DMA channel + * @dma_subsys: pointer to ipa_dma structure * @channel_id: Channel to suspend * * For IPA v4.0+, suspend is implemented by stopping the channel. */ -int gsi_channel_suspend(struct ipa_dma *dma_subsys, u32 channel_id); +static inline int ipa_channel_suspend(struct ipa_dma *dma_subsys, u32 channel_id) +{ + return dma_subsys->channel_suspend(dma_subsys, channel_id); +} /** - * gsi_channel_resume() - Resume a suspended GSI channel - * @gsi: GSI pointer + * ipa_channel_resume() - Resume a suspended DMA channel + * @dma_subsys: pointer to ipa_dma structure * @channel_id: Channel to resume * * For IPA v4.0+, the stopped channel is started again. */ -int gsi_channel_resume(struct ipa_dma *dma_subsys, u32 channel_id); +static inline int ipa_channel_resume(struct ipa_dma *dma_subsys, u32 channel_id) +{ + return dma_subsys->channel_resume(dma_subsys, channel_id); +} + +static inline void ipa_dma_suspend(struct ipa_dma *dma_subsys) +{ + return dma_subsys->suspend(dma_subsys); +} + +static inline void ipa_dma_resume(struct ipa_dma *dma_subsys) +{ + return dma_subsys->resume(dma_subsys); +} /** - * gsi_init() - Initialize the GSI subsystem - * @gsi: Address of GSI structure embedded in an IPA structure + * ipa_dma_init() - Initialize the GSI subsystem + * @dma_subsys: Address of ipa_dma structure embedded in an IPA structure * @pdev: IPA platform device * @version: IPA hardware version (implies GSI version) * @count: Number of entries in the configuration data array @@ -275,14 +315,19 @@ int gsi_channel_resume(struct ipa_dma *dma_subsys, u32 channel_id); * Early stage initialization of the GSI subsystem, performing tasks * that can be done before the GSI hardware is ready to use. */ + int gsi_init(struct ipa_dma *dma_subsys, struct platform_device *pdev, enum ipa_version version, u32 count, const struct ipa_gsi_endpoint_data *data); /** - * gsi_exit() - Exit the GSI subsystem - * @gsi: GSI address previously passed to a successful gsi_init() call + * ipa_dma_exit() - Exit the DMA subsystem + * @dma_subsys: ipa_dma address previously passed to a successful gsi_init() call */ -void gsi_exit(struct ipa_dma *dma_subsys); +static inline void ipa_dma_exit(struct ipa_dma *dma_subsys) +{ + if (dma_subsys) + dma_subsys->exit(dma_subsys); +} #endif /* _GSI_H_ */ diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index 90d6880e8a25..dbef549c4537 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -1091,7 +1091,7 @@ static void ipa_endpoint_replenish(struct ipa_endpoint *endpoint, bool add_one) * try replenishing again if our backlog is *all* available TREs. */ gsi = &endpoint->ipa->dma_subsys; - if (backlog == gsi_channel_tre_max(gsi, endpoint->channel_id)) + if (backlog == ipa_channel_tre_max(gsi, endpoint->channel_id)) schedule_delayed_work(&endpoint->replenish_work, msecs_to_jiffies(1)); } @@ -1107,7 +1107,7 @@ static void ipa_endpoint_replenish_enable(struct ipa_endpoint *endpoint) atomic_add(saved, &endpoint->replenish_backlog); /* Start replenishing if hardware currently has no buffers */ - max_backlog = gsi_channel_tre_max(gsi, endpoint->channel_id); + max_backlog = ipa_channel_tre_max(gsi, endpoint->channel_id); if (atomic_read(&endpoint->replenish_backlog) == max_backlog) ipa_endpoint_replenish(endpoint, false); } @@ -1432,13 +1432,13 @@ static int ipa_endpoint_reset_rx_aggr(struct ipa_endpoint *endpoint) * active. We'll re-enable the doorbell (if appropriate) when * we reset again below. */ - gsi_channel_reset(gsi, endpoint->channel_id, false); + ipa_channel_reset(gsi, endpoint->channel_id, false); /* Make sure the channel isn't suspended */ suspended = ipa_endpoint_program_suspend(endpoint, false); /* Start channel and do a 1 byte read */ - ret = gsi_channel_start(gsi, endpoint->channel_id); + ret = ipa_channel_start(gsi, endpoint->channel_id); if (ret) goto out_suspend_again; @@ -1461,7 +1461,7 @@ static int ipa_endpoint_reset_rx_aggr(struct ipa_endpoint *endpoint) gsi_trans_read_byte_done(gsi, endpoint->channel_id); - ret = gsi_channel_stop(gsi, endpoint->channel_id); + ret = ipa_channel_stop(gsi, endpoint->channel_id); if (ret) goto out_suspend_again; @@ -1470,14 +1470,14 @@ static int ipa_endpoint_reset_rx_aggr(struct ipa_endpoint *endpoint) * complete the channel reset sequence. Finish by suspending the * channel again (if necessary). */ - gsi_channel_reset(gsi, endpoint->channel_id, true); + ipa_channel_reset(gsi, endpoint->channel_id, true); usleep_range(USEC_PER_MSEC, 2 * USEC_PER_MSEC); goto out_suspend_again; err_endpoint_stop: - (void)gsi_channel_stop(gsi, endpoint->channel_id); + (void)ipa_channel_stop(gsi, endpoint->channel_id); out_suspend_again: if (suspended) (void)ipa_endpoint_program_suspend(endpoint, true); @@ -1504,7 +1504,7 @@ static void ipa_endpoint_reset(struct ipa_endpoint *endpoint) if (special && ipa_endpoint_aggr_active(endpoint)) ret = ipa_endpoint_reset_rx_aggr(endpoint); else - gsi_channel_reset(&ipa->dma_subsys, channel_id, true); + ipa_channel_reset(&ipa->dma_subsys, channel_id, true); if (ret) dev_err(&ipa->pdev->dev, @@ -1537,7 +1537,7 @@ int ipa_endpoint_enable_one(struct ipa_endpoint *endpoint) struct ipa_dma *gsi = &ipa->dma_subsys; int ret; - ret = gsi_channel_start(gsi, endpoint->channel_id); + ret = ipa_channel_start(gsi, endpoint->channel_id); if (ret) { dev_err(&ipa->pdev->dev, "error %d starting %cX channel %u for endpoint %u\n", @@ -1576,7 +1576,7 @@ void ipa_endpoint_disable_one(struct ipa_endpoint *endpoint) } /* Note that if stop fails, the channel's state is not well-defined */ - ret = gsi_channel_stop(gsi, endpoint->channel_id); + ret = ipa_channel_stop(gsi, endpoint->channel_id); if (ret) dev_err(&ipa->pdev->dev, "error %d attempting to stop endpoint %u\n", ret, @@ -1598,7 +1598,7 @@ void ipa_endpoint_suspend_one(struct ipa_endpoint *endpoint) (void)ipa_endpoint_program_suspend(endpoint, true); } - ret = gsi_channel_suspend(gsi, endpoint->channel_id); + ret = ipa_channel_suspend(gsi, endpoint->channel_id); if (ret) dev_err(dev, "error %d suspending channel %u\n", ret, endpoint->channel_id); @@ -1617,7 +1617,7 @@ void ipa_endpoint_resume_one(struct ipa_endpoint *endpoint) if (!endpoint->toward_ipa) (void)ipa_endpoint_program_suspend(endpoint, false); - ret = gsi_channel_resume(gsi, endpoint->channel_id); + ret = ipa_channel_resume(gsi, endpoint->channel_id); if (ret) dev_err(dev, "error %d resuming channel %u\n", ret, endpoint->channel_id); @@ -1660,14 +1660,14 @@ static void ipa_endpoint_setup_one(struct ipa_endpoint *endpoint) if (endpoint->ee_id != GSI_EE_AP) return; - endpoint->trans_tre_max = gsi_channel_trans_tre_max(gsi, channel_id); + endpoint->trans_tre_max = ipa_channel_trans_tre_max(gsi, channel_id); if (!endpoint->toward_ipa) { /* RX transactions require a single TRE, so the maximum * backlog is the same as the maximum outstanding TREs. */ endpoint->replenish_enabled = false; atomic_set(&endpoint->replenish_saved, - gsi_channel_tre_max(gsi, endpoint->channel_id)); + ipa_channel_tre_max(gsi, endpoint->channel_id)); atomic_set(&endpoint->replenish_backlog, 0); INIT_DELAYED_WORK(&endpoint->replenish_work, ipa_endpoint_replenish_work); diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c index 026f5555fa7d..6ab691ff1faf 100644 --- a/drivers/net/ipa/ipa_main.c +++ b/drivers/net/ipa/ipa_main.c @@ -98,13 +98,13 @@ int ipa_setup(struct ipa *ipa) struct device *dev = &ipa->pdev->dev; int ret; - ret = gsi_setup(&ipa->dma_subsys); + ret = ipa_dma_setup(&ipa->dma_subsys); if (ret) return ret; ret = ipa_power_setup(ipa); if (ret) - goto err_gsi_teardown; + goto err_dma_teardown; ipa_endpoint_setup(ipa); @@ -153,8 +153,8 @@ int ipa_setup(struct ipa *ipa) err_endpoint_teardown: ipa_endpoint_teardown(ipa); ipa_power_teardown(ipa); -err_gsi_teardown: - gsi_teardown(&ipa->dma_subsys); +err_dma_teardown: + ipa_dma_teardown(&ipa->dma_subsys); return ret; } @@ -179,7 +179,7 @@ static void ipa_teardown(struct ipa *ipa) ipa_endpoint_disable_one(command_endpoint); ipa_endpoint_teardown(ipa); ipa_power_teardown(ipa); - gsi_teardown(&ipa->dma_subsys); + ipa_dma_teardown(&ipa->dma_subsys); } /* Configure bus access behavior for IPA components */ @@ -726,7 +726,7 @@ static int ipa_probe(struct platform_device *pdev) data->endpoint_data); if (!ipa->filter_map) { ret = -EINVAL; - goto err_gsi_exit; + goto err_dma_exit; } ret = ipa_table_init(ipa); @@ -780,8 +780,8 @@ static int ipa_probe(struct platform_device *pdev) ipa_table_exit(ipa); err_endpoint_exit: ipa_endpoint_exit(ipa); -err_gsi_exit: - gsi_exit(&ipa->dma_subsys); +err_dma_exit: + ipa_dma_exit(&ipa->dma_subsys); err_mem_exit: ipa_mem_exit(ipa); err_reg_exit: @@ -824,7 +824,7 @@ static int ipa_remove(struct platform_device *pdev) ipa_modem_exit(ipa); ipa_table_exit(ipa); ipa_endpoint_exit(ipa); - gsi_exit(&ipa->dma_subsys); + ipa_dma_exit(&ipa->dma_subsys); ipa_mem_exit(ipa); ipa_reg_exit(ipa); kfree(ipa); diff --git a/drivers/net/ipa/ipa_power.c b/drivers/net/ipa/ipa_power.c index b1c6c0fcb654..096cfb8ae9a5 100644 --- a/drivers/net/ipa/ipa_power.c +++ b/drivers/net/ipa/ipa_power.c @@ -243,7 +243,7 @@ static int ipa_runtime_suspend(struct device *dev) if (ipa->setup_complete) { __clear_bit(IPA_POWER_FLAG_RESUMED, ipa->power->flags); ipa_endpoint_suspend(ipa); - gsi_suspend(&ipa->gsi); + ipa_dma_suspend(&ipa->dma_subsys); } return ipa_power_disable(ipa); @@ -260,7 +260,7 @@ static int ipa_runtime_resume(struct device *dev) /* Endpoints aren't usable until setup is complete */ if (ipa->setup_complete) { - gsi_resume(&ipa->gsi); + ipa_dma_resume(&ipa->dma_subsys); ipa_endpoint_resume(ipa); } diff --git a/drivers/net/ipa/ipa_trans.c b/drivers/net/ipa/ipa_trans.c index b87936b18770..22755f3ce3da 100644 --- a/drivers/net/ipa/ipa_trans.c +++ b/drivers/net/ipa/ipa_trans.c @@ -747,7 +747,7 @@ int ipa_channel_trans_init(struct ipa_dma *gsi, u32 channel_id) * for transactions (including transaction structures) based on * this maximum number. */ - tre_max = gsi_channel_tre_max(channel->dma_subsys, channel_id); + tre_max = ipa_channel_tre_max(channel->dma_subsys, channel_id); /* Transactions are allocated one at a time. */ ret = ipa_trans_pool_init(&trans_info->pool, sizeof(struct ipa_trans), From patchwork Mon Sep 20 03:07:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sireesh Kodali X-Patchwork-Id: 12504539 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E420AC433EF for ; Mon, 20 Sep 2021 03:09:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CEEC060FC2 for ; Mon, 20 Sep 2021 03:09:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230448AbhITDKc (ORCPT ); Sun, 19 Sep 2021 23:10:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232850AbhITDK3 (ORCPT ); Sun, 19 Sep 2021 23:10:29 -0400 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE6A3C061574; Sun, 19 Sep 2021 20:09:03 -0700 (PDT) Received: by mail-pf1-x42d.google.com with SMTP id k17so567843pff.8; Sun, 19 Sep 2021 20:09:03 -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=ctuhPxo2Y0iKSYUTimNWhqKlTDvqm7Ayr46jrPBJu6k=; b=KliJfSEbbKrQCdSX8TcUqC90YAPcOe/jEe/PPPHlGam6QbEnWakxepoqpIyCGFflT+ cPlNgPMFjZ7a6EI7CWeiZYXOPRDigAroYqndIhdR+UOEvrXayjoAA05h8tO9DuG018jL UxgjZSWj4Vga0x7hMlmjeNX6QZMyyniKnFY9ibgykFzL9/WyeyfeSXiiJ7R0OsGE4Tah xg+Fuq9EODpFjfmtxKLrGcidlAW9vQrfb+kR/lU+NQlEnRO0SMbcL4OGGHSa56RKPcwY pFmcv+5Dv02aPjqf+0D4yMkVT7m8Hak14Yz/2KsOCg4z6lk41X2OzWMQu6ZGtf81RD2G Edhg== 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=ctuhPxo2Y0iKSYUTimNWhqKlTDvqm7Ayr46jrPBJu6k=; b=fOMRTLtMQEjssP9nTDyQSuj8yK0qLrhzXjEhWbbMiMv4SvLVtjaa1pF1bdmV6A6Zjk 7mZ0ag0WO9hpFwGXoqNOFAGN//5PJkU6OrH8aFMaXNpofKqz//z3r8YkGreKttzbtfdM dBNAfYEsmd4Mrtb7fy+QsyZkH1r1tM1wEaxQggPYdbwnQCtoKySvxV2O62PKQ6mgZikv l+hn4Y0Ts2wIzmyFo8J2gorTfql56Z+5nN0qzmrYzqahCUcKmuIssM9P+/ef8YmOAJfz 5wYA5girGvFkLbo6xNorzMralAkmilq5267ZBeNNDM5FqZwSVWQMYHrlla8Ooaj35zXO O2Wg== X-Gm-Message-State: AOAM531HXChfYq2JRgRxeCCOQhOcYfJNtufe8iZyRILpob/9E+mnX+WP qmiJyTv9Z/0/HEurhHnCX5ern/vjri8Mumzo X-Google-Smtp-Source: ABdhPJz5eNMjiIqtPtcMIFQqJ8fM4+8yM+jcjLGNLSj+c24mZc962gKniqMwwbCqPCcjdWekcoNbPg== X-Received: by 2002:a63:7784:: with SMTP id s126mr7988038pgc.264.1632107343232; Sun, 19 Sep 2021 20:09:03 -0700 (PDT) Received: from skynet-linux.local ([106.201.127.154]) by smtp.googlemail.com with ESMTPSA id l11sm16295065pjg.22.2021.09.19.20.09.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Sep 2021 20:09:02 -0700 (PDT) From: Sireesh Kodali To: phone-devel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, elder@kernel.org Cc: Vladimir Lypak , Sireesh Kodali , "David S. Miller" , Jakub Kicinski Subject: [RFC PATCH 05/17] net: ipa: Check interrupts for availability Date: Mon, 20 Sep 2021 08:37:59 +0530 Message-Id: <20210920030811.57273-6-sireeshkodali1@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920030811.57273-1-sireeshkodali1@gmail.com> References: <20210920030811.57273-1-sireeshkodali1@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Vladimir Lypak Make ipa_interrupt_add/ipa_interrupt_remove no-operation if requested interrupt is not supported by IPA hardware. Signed-off-by: Vladimir Lypak Signed-off-by: Sireesh Kodali --- drivers/net/ipa/ipa_interrupt.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/net/ipa/ipa_interrupt.c b/drivers/net/ipa/ipa_interrupt.c index b35170a93b0f..94708a23a597 100644 --- a/drivers/net/ipa/ipa_interrupt.c +++ b/drivers/net/ipa/ipa_interrupt.c @@ -48,6 +48,25 @@ static bool ipa_interrupt_uc(struct ipa_interrupt *interrupt, u32 irq_id) return irq_id == IPA_IRQ_UC_0 || irq_id == IPA_IRQ_UC_1; } +static bool ipa_interrupt_check_fixup(enum ipa_irq_id *irq_id, enum ipa_version version) +{ + switch (*irq_id) { + case IPA_IRQ_EOT_COAL: + return version < IPA_VERSION_3_5; + case IPA_IRQ_DCMP: + return version < IPA_VERSION_4_5; + case IPA_IRQ_TLV_LEN_MIN_DSM: + return version >= IPA_VERSION_4_5; + default: + break; + } + + if (*irq_id >= IPA_IRQ_DRBIP_PKT_EXCEED_MAX_SIZE_EN) + return version >= IPA_VERSION_4_9; + + return true; +} + /* Process a particular interrupt type that has been received */ static void ipa_interrupt_process(struct ipa_interrupt *interrupt, u32 irq_id) { @@ -191,6 +210,9 @@ void ipa_interrupt_add(struct ipa_interrupt *interrupt, struct ipa *ipa = interrupt->ipa; u32 offset; + if (!ipa_interrupt_check_fixup(&ipa_irq, ipa->version)) + return; + WARN_ON(ipa_irq >= IPA_IRQ_COUNT); interrupt->handler[ipa_irq] = handler; @@ -208,6 +230,9 @@ ipa_interrupt_remove(struct ipa_interrupt *interrupt, enum ipa_irq_id ipa_irq) struct ipa *ipa = interrupt->ipa; u32 offset; + if (!ipa_interrupt_check_fixup(&ipa_irq, ipa->version)) + return; + WARN_ON(ipa_irq >= IPA_IRQ_COUNT); /* Update the IPA interrupt mask to disable it */ From patchwork Mon Sep 20 03:08:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sireesh Kodali X-Patchwork-Id: 12504541 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75394C433F5 for ; Mon, 20 Sep 2021 03:09:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 54EED60FC0 for ; Mon, 20 Sep 2021 03:09:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234435AbhITDLC (ORCPT ); Sun, 19 Sep 2021 23:11:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234325AbhITDKr (ORCPT ); Sun, 19 Sep 2021 23:10:47 -0400 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A389AC0613D3; Sun, 19 Sep 2021 20:09:08 -0700 (PDT) Received: by mail-pf1-x434.google.com with SMTP id y8so14895790pfa.7; Sun, 19 Sep 2021 20:09:08 -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=pttii/mW6L03BPJ/XcL96bSG4P+EhN6sWLdnr6WQgkE=; b=P4RlnyNPwzpZpZLby8HCaQ2PZhLGLJ2R1Knb/HkWBzC7jD5FLopSZpZjalnWM39Kyu 9ozyF5y50LxMa3klP88pHGQnk28Of9hFqPR3ybqnerjf3he4UK9PcW2WLAbQIzEADsWo meoOGJvONfeERU2L4G9CqoaVWa0OjARayHULiRSFitV3kPezXAQ5gkFMzxQufclqXLqY 1982TL9Xn4l4ZipyrX73VpWHXh7ihz1KB6URnMcNbhdIr19RgqOJl9NpLTlNfICFzpOT ZtbTcKsN/9jvkLfwXnpfxthcOl9eSoi413NxF4I6gq67VN7wwoIqo3zNFb2DLbNlRfNh 85XA== 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=pttii/mW6L03BPJ/XcL96bSG4P+EhN6sWLdnr6WQgkE=; b=Ee3avpJfTfA/LEgWcUNVlm5Pl8s1ewzVOmNwRbEyBWbVT+d3zGrKCtslk9hJq/cVDZ aspOn3GKtvTFUzC/QXbAE8Wg+rPV3oVl4UpvcXkevAJ8R+lYZgTxLF+9PwrZ844Wacym FjojI3hLbvsvYffcABZwWsRPg7JNBK8CWD335IBA/Pxf7IvTjxqVV3PozRvbXfLSCHBQ NKsY8L/d8QhI0crhPexfsumrGLN1GVIQz0iECt6eiDEKPXQrLNdk7ea0Oy9L5cwW88sV FY8JZXaWTLzYyBAe24rrs6CGC6krsyvtyX3AFRym7msqv7RJmTUss/dKK5o9PLe2Hy65 27gw== X-Gm-Message-State: AOAM531rK4wUs9mGejIOelx6ZXFpYgIe7AFoMCckIgOOWlI/vKpTCUKf wYSPHSXTVUYd+mRVDLIRjazHaOIsmzVtkVa9 X-Google-Smtp-Source: ABdhPJylUqG7PdDwj6HinmG82rymQeeRmMboPG01+2R63sr/3W81JeAWc73OmldOQwfdqpAs/GGwQw== X-Received: by 2002:a63:4b4c:: with SMTP id k12mr21259895pgl.172.1632107347993; Sun, 19 Sep 2021 20:09:07 -0700 (PDT) Received: from skynet-linux.local ([106.201.127.154]) by smtp.googlemail.com with ESMTPSA id l11sm16295065pjg.22.2021.09.19.20.09.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Sep 2021 20:09:07 -0700 (PDT) From: Sireesh Kodali To: phone-devel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, elder@kernel.org Cc: Vladimir Lypak , Sireesh Kodali , "David S. Miller" , Jakub Kicinski Subject: [RFC PATCH 06/17] net: ipa: Add timeout for ipa_cmd_pipeline_clear_wait Date: Mon, 20 Sep 2021 08:38:00 +0530 Message-Id: <20210920030811.57273-7-sireeshkodali1@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920030811.57273-1-sireeshkodali1@gmail.com> References: <20210920030811.57273-1-sireeshkodali1@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Vladimir Lypak Sometimes the pipeline clear fails, and when it does, having a hang in kernel is ugly. The timeout gives us a nice error message. Note that this shouldn't actually hang, ever. It only hangs if there is a mistake in the config, and the timeout is only useful when debugging. Signed-off-by: Vladimir Lypak Signed-off-by: Sireesh Kodali --- drivers/net/ipa/ipa_cmd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/ipa/ipa_cmd.c b/drivers/net/ipa/ipa_cmd.c index 3db9e94e484f..0bdbc331fa78 100644 --- a/drivers/net/ipa/ipa_cmd.c +++ b/drivers/net/ipa/ipa_cmd.c @@ -658,7 +658,10 @@ u32 ipa_cmd_pipeline_clear_count(void) void ipa_cmd_pipeline_clear_wait(struct ipa *ipa) { - wait_for_completion(&ipa->completion); + unsigned long timeout_jiffies = msecs_to_jiffies(1000); + + if (!wait_for_completion_timeout(&ipa->completion, timeout_jiffies)) + dev_err(&ipa->pdev->dev, "%s time out\n", __func__); } void ipa_cmd_pipeline_clear(struct ipa *ipa) From patchwork Mon Sep 20 03:08:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sireesh Kodali X-Patchwork-Id: 12504545 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A29FDC4332F for ; Mon, 20 Sep 2021 03:09:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8765860FC1 for ; Mon, 20 Sep 2021 03:09:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234542AbhITDLJ (ORCPT ); Sun, 19 Sep 2021 23:11:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234397AbhITDK4 (ORCPT ); Sun, 19 Sep 2021 23:10:56 -0400 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFAE7C0613DE; Sun, 19 Sep 2021 20:09:13 -0700 (PDT) Received: by mail-pg1-x529.google.com with SMTP id f129so15934659pgc.1; Sun, 19 Sep 2021 20:09:13 -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=eYu3iQ+70DKrOlQDs8vVhcz5q6YvI8RnV/PzqvZ/Fi8=; b=Is/NNDwwxWpYywxdQx+gOoxv22J0PXfy99t+sPzFOG96bCSP5+83ktDspScP1gJ8rb s1lFX3t9y+3DT3w74UhAXK7bkPxMU1HmbOFmX1wkPKT5/nCiLjy5NXUWl+LaxL3zTPS1 SRvTHhTajVOikByPXKLsRw9UOd4Gz/JryCf3THePeUJFM1WGJNQp0nz4eR0kt1kCX33x rFBj7Zv9eClwcrS9pYetboo+VThwQ2pFZo8zT5OfFZ7/Wa/lW086r0ximgCa++XiHLab okNh0OAI8OGi+9EU3BItIsEc4ONNIzqiGsncYV5wLmXjgD5n8xkyUP3CLbBxZdXIKlzT PwGw== 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=eYu3iQ+70DKrOlQDs8vVhcz5q6YvI8RnV/PzqvZ/Fi8=; b=gjdYh4kna/MU6fUDVHsjVl9bTmBV81Xgl/q1qMHSUpnY2Z9B8RJDGd/2eMkZgMGwUr Q6qHO3Knfw28i30FnHHozfe5Y+l6YZWblqrwQpl7VbYP+0wSVOQEZ70R2yBTbiuCHUqR MnCuc0h/R6eIGJb0gQ+qP/HcXA3co2HMxziv36vfqrzzPJmXHNwTg6Abm10ivFyTRE56 vnMcG6yADA2FEpAgXgh+kPLskcL/ghgIyNIGhN3Om3z0NAOKp3koLCmpMj3W9TnQOVnQ z9y5iSoUu39Q7tGZCjV/h3pN/qoz1kIWzMDdo/gwIjpoZO4cKi6VdaJL4VRqKl2PR/jl S1VA== X-Gm-Message-State: AOAM531YH3NPbSY0eEaa7LN4Di4wVMXITHvYkmGZx37DLE2U8UoVJhzR ID7eQEggfcc9PF00praFLQ9j69NktU4wUdHu X-Google-Smtp-Source: ABdhPJy+9FAinwhLLt5pTdtm3NCCx+cbI+KmVwE0wQiZc3k7pFN7ImjfXkOuCVqcvO1YtGYfOvuz8Q== X-Received: by 2002:a63:68a:: with SMTP id 132mr21650093pgg.154.1632107352755; Sun, 19 Sep 2021 20:09:12 -0700 (PDT) Received: from skynet-linux.local ([106.201.127.154]) by smtp.googlemail.com with ESMTPSA id l11sm16295065pjg.22.2021.09.19.20.09.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Sep 2021 20:09:12 -0700 (PDT) From: Sireesh Kodali To: phone-devel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, elder@kernel.org Cc: Sireesh Kodali , "David S. Miller" , Jakub Kicinski Subject: [RFC PATCH 07/17] net: ipa: Add IPA v2.x register definitions Date: Mon, 20 Sep 2021 08:38:01 +0530 Message-Id: <20210920030811.57273-8-sireeshkodali1@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920030811.57273-1-sireeshkodali1@gmail.com> References: <20210920030811.57273-1-sireeshkodali1@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org IPA v2.x is an older version the IPA hardware, and is 32 bit. Most of the registers were just shifted in newer IPA versions, but the register fields have remained the same across IPA versions. This means that only the register addresses needed to be added to the driver. To handle the different IPA register addresses, static inline functions have been defined that return the correct register address. Signed-off-by: Sireesh Kodali --- drivers/net/ipa/ipa_cmd.c | 3 +- drivers/net/ipa/ipa_endpoint.c | 33 +++--- drivers/net/ipa/ipa_main.c | 8 +- drivers/net/ipa/ipa_mem.c | 5 +- drivers/net/ipa/ipa_reg.h | 184 +++++++++++++++++++++++++++------ drivers/net/ipa/ipa_version.h | 12 +++ 6 files changed, 195 insertions(+), 50 deletions(-) diff --git a/drivers/net/ipa/ipa_cmd.c b/drivers/net/ipa/ipa_cmd.c index 0bdbc331fa78..7a104540dc26 100644 --- a/drivers/net/ipa/ipa_cmd.c +++ b/drivers/net/ipa/ipa_cmd.c @@ -326,7 +326,8 @@ static bool ipa_cmd_register_write_valid(struct ipa *ipa) * worst case (highest endpoint number) offset of that endpoint * fits in the register write command field(s) that must hold it. */ - offset = IPA_REG_ENDP_STATUS_N_OFFSET(IPA_ENDPOINT_COUNT - 1); + offset = ipa_reg_endp_status_n_offset(ipa->version, + IPA_ENDPOINT_COUNT - 1); name = "maximal endpoint status"; if (!ipa_cmd_register_write_offset_valid(ipa, name, offset)) return false; diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index dbef549c4537..7d3ab61cd890 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -242,8 +242,8 @@ static struct ipa_trans *ipa_endpoint_trans_alloc(struct ipa_endpoint *endpoint, static bool ipa_endpoint_init_ctrl(struct ipa_endpoint *endpoint, bool suspend_delay) { - u32 offset = IPA_REG_ENDP_INIT_CTRL_N_OFFSET(endpoint->endpoint_id); struct ipa *ipa = endpoint->ipa; + u32 offset = ipa_reg_endp_init_ctrl_n_offset(ipa->version, endpoint->endpoint_id); bool state; u32 mask; u32 val; @@ -410,7 +410,7 @@ int ipa_endpoint_modem_exception_reset_all(struct ipa *ipa) if (!(endpoint->ee_id == GSI_EE_MODEM && endpoint->toward_ipa)) continue; - offset = IPA_REG_ENDP_STATUS_N_OFFSET(endpoint_id); + offset = ipa_reg_endp_status_n_offset(ipa->version, endpoint_id); /* Value written is 0, and all bits are updated. That * means status is disabled on the endpoint, and as a @@ -431,7 +431,8 @@ int ipa_endpoint_modem_exception_reset_all(struct ipa *ipa) static void ipa_endpoint_init_cfg(struct ipa_endpoint *endpoint) { - u32 offset = IPA_REG_ENDP_INIT_CFG_N_OFFSET(endpoint->endpoint_id); + struct ipa *ipa = endpoint->ipa; + u32 offset = ipa_reg_endp_init_cfg_n_offset(ipa->version, endpoint->endpoint_id); enum ipa_cs_offload_en enabled; u32 val = 0; @@ -523,8 +524,8 @@ ipa_qmap_header_size(enum ipa_version version, struct ipa_endpoint *endpoint) */ static void ipa_endpoint_init_hdr(struct ipa_endpoint *endpoint) { - u32 offset = IPA_REG_ENDP_INIT_HDR_N_OFFSET(endpoint->endpoint_id); struct ipa *ipa = endpoint->ipa; + u32 offset = ipa_reg_endp_init_hdr_n_offset(ipa->version, endpoint->endpoint_id); u32 val = 0; if (endpoint->data->qmap) { @@ -565,9 +566,9 @@ static void ipa_endpoint_init_hdr(struct ipa_endpoint *endpoint) static void ipa_endpoint_init_hdr_ext(struct ipa_endpoint *endpoint) { - u32 offset = IPA_REG_ENDP_INIT_HDR_EXT_N_OFFSET(endpoint->endpoint_id); - u32 pad_align = endpoint->data->rx.pad_align; struct ipa *ipa = endpoint->ipa; + u32 offset = ipa_reg_endp_init_hdr_ext_n_offset(ipa->version, endpoint->endpoint_id); + u32 pad_align = endpoint->data->rx.pad_align; u32 val = 0; val |= HDR_ENDIANNESS_FMASK; /* big endian */ @@ -609,6 +610,7 @@ static void ipa_endpoint_init_hdr_ext(struct ipa_endpoint *endpoint) static void ipa_endpoint_init_hdr_metadata_mask(struct ipa_endpoint *endpoint) { + enum ipa_version version = endpoint->ipa->version; u32 endpoint_id = endpoint->endpoint_id; u32 val = 0; u32 offset; @@ -616,7 +618,7 @@ static void ipa_endpoint_init_hdr_metadata_mask(struct ipa_endpoint *endpoint) if (endpoint->toward_ipa) return; /* Register not valid for TX endpoints */ - offset = IPA_REG_ENDP_INIT_HDR_METADATA_MASK_N_OFFSET(endpoint_id); + offset = ipa_reg_endp_init_hdr_metadata_mask_n_offset(version, endpoint_id); /* Note that HDR_ENDIANNESS indicates big endian header fields */ if (endpoint->data->qmap) @@ -627,7 +629,8 @@ static void ipa_endpoint_init_hdr_metadata_mask(struct ipa_endpoint *endpoint) static void ipa_endpoint_init_mode(struct ipa_endpoint *endpoint) { - u32 offset = IPA_REG_ENDP_INIT_MODE_N_OFFSET(endpoint->endpoint_id); + enum ipa_version version = endpoint->ipa->version; + u32 offset = ipa_reg_endp_init_mode_n_offset(version, endpoint->endpoint_id); u32 val; if (!endpoint->toward_ipa) @@ -716,8 +719,8 @@ static u32 aggr_sw_eof_active_encoded(enum ipa_version version, bool enabled) static void ipa_endpoint_init_aggr(struct ipa_endpoint *endpoint) { - u32 offset = IPA_REG_ENDP_INIT_AGGR_N_OFFSET(endpoint->endpoint_id); enum ipa_version version = endpoint->ipa->version; + u32 offset = ipa_reg_endp_init_aggr_n_offset(version, endpoint->endpoint_id); u32 val = 0; if (endpoint->data->aggregation) { @@ -853,7 +856,7 @@ static void ipa_endpoint_init_hol_block_timer(struct ipa_endpoint *endpoint, u32 offset; u32 val; - offset = IPA_REG_ENDP_INIT_HOL_BLOCK_TIMER_N_OFFSET(endpoint_id); + offset = ipa_reg_endp_init_hol_block_timer_n_offset(ipa->version, endpoint_id); val = hol_block_timer_val(ipa, microseconds); iowrite32(val, ipa->reg_virt + offset); } @@ -861,12 +864,13 @@ static void ipa_endpoint_init_hol_block_timer(struct ipa_endpoint *endpoint, static void ipa_endpoint_init_hol_block_enable(struct ipa_endpoint *endpoint, bool enable) { + enum ipa_version version = endpoint->ipa->version; u32 endpoint_id = endpoint->endpoint_id; u32 offset; u32 val; val = enable ? HOL_BLOCK_EN_FMASK : 0; - offset = IPA_REG_ENDP_INIT_HOL_BLOCK_EN_N_OFFSET(endpoint_id); + offset = ipa_reg_endp_init_hol_block_en_n_offset(version, endpoint_id); iowrite32(val, endpoint->ipa->reg_virt + offset); } @@ -887,7 +891,8 @@ void ipa_endpoint_modem_hol_block_clear_all(struct ipa *ipa) static void ipa_endpoint_init_deaggr(struct ipa_endpoint *endpoint) { - u32 offset = IPA_REG_ENDP_INIT_DEAGGR_N_OFFSET(endpoint->endpoint_id); + enum ipa_version version = endpoint->ipa->version; + u32 offset = ipa_reg_endp_init_deaggr_n_offset(version, endpoint->endpoint_id); u32 val = 0; if (!endpoint->toward_ipa) @@ -979,7 +984,7 @@ static void ipa_endpoint_status(struct ipa_endpoint *endpoint) u32 val = 0; u32 offset; - offset = IPA_REG_ENDP_STATUS_N_OFFSET(endpoint_id); + offset = ipa_reg_endp_status_n_offset(ipa->version, endpoint_id); if (endpoint->data->status_enable) { val |= STATUS_EN_FMASK; @@ -1384,7 +1389,7 @@ void ipa_endpoint_default_route_set(struct ipa *ipa, u32 endpoint_id) val |= u32_encode_bits(endpoint_id, ROUTE_FRAG_DEF_PIPE_FMASK); val |= ROUTE_DEF_RETAIN_HDR_FMASK; - iowrite32(val, ipa->reg_virt + IPA_REG_ROUTE_OFFSET); + iowrite32(val, ipa->reg_virt + ipa_reg_route_offset(ipa->version)); } void ipa_endpoint_default_route_clear(struct ipa *ipa) diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c index 6ab691ff1faf..ba06e3ad554c 100644 --- a/drivers/net/ipa/ipa_main.c +++ b/drivers/net/ipa/ipa_main.c @@ -191,7 +191,7 @@ static void ipa_hardware_config_comp(struct ipa *ipa) if (ipa->version < IPA_VERSION_4_0) return; - val = ioread32(ipa->reg_virt + IPA_REG_COMP_CFG_OFFSET); + val = ioread32(ipa->reg_virt + ipa_reg_comp_cfg_offset(ipa->version)); if (ipa->version == IPA_VERSION_4_0) { val &= ~IPA_QMB_SELECT_CONS_EN_FMASK; @@ -206,7 +206,7 @@ static void ipa_hardware_config_comp(struct ipa *ipa) val |= GSI_MULTI_INORDER_RD_DIS_FMASK; val |= GSI_MULTI_INORDER_WR_DIS_FMASK; - iowrite32(val, ipa->reg_virt + IPA_REG_COMP_CFG_OFFSET); + iowrite32(val, ipa->reg_virt + ipa_reg_comp_cfg_offset(ipa->version)); } /* Configure DDR and (possibly) PCIe max read/write QSB values */ @@ -355,7 +355,7 @@ static void ipa_hardware_config(struct ipa *ipa, const struct ipa_data *data) /* IPA v4.5+ has no backward compatibility register */ if (version < IPA_VERSION_4_5) { val = data->backward_compat; - iowrite32(val, ipa->reg_virt + IPA_REG_BCR_OFFSET); + iowrite32(val, ipa->reg_virt + ipa_reg_bcr_offset(ipa->version)); } /* Implement some hardware workarounds */ @@ -384,7 +384,7 @@ static void ipa_hardware_config(struct ipa *ipa, const struct ipa_data *data) /* Configure aggregation timer granularity */ granularity = ipa_aggr_granularity_val(IPA_AGGR_GRANULARITY); val = u32_encode_bits(granularity, AGGR_GRANULARITY_FMASK); - iowrite32(val, ipa->reg_virt + IPA_REG_COUNTER_CFG_OFFSET); + iowrite32(val, ipa->reg_virt + ipa_reg_counter_cfg_offset(ipa->version)); } else { ipa_qtime_config(ipa); } diff --git a/drivers/net/ipa/ipa_mem.c b/drivers/net/ipa/ipa_mem.c index 16e5fdd5bd73..8acc88070a6f 100644 --- a/drivers/net/ipa/ipa_mem.c +++ b/drivers/net/ipa/ipa_mem.c @@ -113,7 +113,8 @@ int ipa_mem_setup(struct ipa *ipa) mem = ipa_mem_find(ipa, IPA_MEM_MODEM_PROC_CTX); offset = ipa->mem_offset + mem->offset; val = proc_cntxt_base_addr_encoded(ipa->version, offset); - iowrite32(val, ipa->reg_virt + IPA_REG_LOCAL_PKT_PROC_CNTXT_OFFSET); + iowrite32(val, ipa->reg_virt + + ipa_reg_local_pkt_proc_cntxt_base_offset(ipa->version)); return 0; } @@ -316,7 +317,7 @@ int ipa_mem_config(struct ipa *ipa) u32 i; /* Check the advertised location and size of the shared memory area */ - val = ioread32(ipa->reg_virt + IPA_REG_SHARED_MEM_SIZE_OFFSET); + val = ioread32(ipa->reg_virt + ipa_reg_shared_mem_size_offset(ipa->version)); /* The fields in the register are in 8 byte units */ ipa->mem_offset = 8 * u32_get_bits(val, SHARED_MEM_BADDR_FMASK); diff --git a/drivers/net/ipa/ipa_reg.h b/drivers/net/ipa/ipa_reg.h index a5b355384d4a..fcae0296cfa4 100644 --- a/drivers/net/ipa/ipa_reg.h +++ b/drivers/net/ipa/ipa_reg.h @@ -65,7 +65,17 @@ struct ipa; * of valid bits for the register. */ -#define IPA_REG_COMP_CFG_OFFSET 0x0000003c +#define IPA_REG_COMP_SW_RESET_OFFSET 0x0000003c + +#define IPA_REG_V2_ENABLED_PIPES_OFFSET 0x000005dc + +static inline u32 ipa_reg_comp_cfg_offset(enum ipa_version version) +{ + if (version <= IPA_VERSION_2_6L) + return 0x38; + + return 0x3c; +} /* The next field is not supported for IPA v4.0+, not present for IPA v4.5+ */ #define ENABLE_FMASK GENMASK(0, 0) /* The next field is present for IPA v4.7+ */ @@ -124,6 +134,7 @@ static inline u32 full_flush_rsc_closure_en_encoded(enum ipa_version version, return u32_encode_bits(val, GENMASK(17, 17)); } +/* This register is only present on IPA v3.0 and above */ #define IPA_REG_CLKON_CFG_OFFSET 0x00000044 #define RX_FMASK GENMASK(0, 0) #define PROC_FMASK GENMASK(1, 1) @@ -164,7 +175,14 @@ static inline u32 full_flush_rsc_closure_en_encoded(enum ipa_version version, /* The next field is present for IPA v4.7+ */ #define DRBIP_FMASK GENMASK(31, 31) -#define IPA_REG_ROUTE_OFFSET 0x00000048 +static inline u32 ipa_reg_route_offset(enum ipa_version version) +{ + if (version <= IPA_VERSION_2_6L) + return 0x44; + + return 0x48; +} + #define ROUTE_DIS_FMASK GENMASK(0, 0) #define ROUTE_DEF_PIPE_FMASK GENMASK(5, 1) #define ROUTE_DEF_HDR_TABLE_FMASK GENMASK(6, 6) @@ -172,7 +190,14 @@ static inline u32 full_flush_rsc_closure_en_encoded(enum ipa_version version, #define ROUTE_FRAG_DEF_PIPE_FMASK GENMASK(21, 17) #define ROUTE_DEF_RETAIN_HDR_FMASK GENMASK(24, 24) -#define IPA_REG_SHARED_MEM_SIZE_OFFSET 0x00000054 +static inline u32 ipa_reg_shared_mem_size_offset(enum ipa_version version) +{ + if (version <= IPA_VERSION_2_6L) + return 0x50; + + return 0x54; +} + #define SHARED_MEM_SIZE_FMASK GENMASK(15, 0) #define SHARED_MEM_BADDR_FMASK GENMASK(31, 16) @@ -219,7 +244,13 @@ static inline u32 ipa_reg_state_aggr_active_offset(enum ipa_version version) } /* The next register is not present for IPA v4.5+ */ -#define IPA_REG_BCR_OFFSET 0x000001d0 +static inline u32 ipa_reg_bcr_offset(enum ipa_version version) +{ + if (IPA_VERSION_RANGE(version, 2_5, 2_6L)) + return 0x5b0; + + return 0x1d0; +} /* The next two fields are not present for IPA v4.2+ */ #define BCR_CMDQ_L_LACK_ONE_ENTRY_FMASK GENMASK(0, 0) #define BCR_TX_NOT_USING_BRESP_FMASK GENMASK(1, 1) @@ -236,7 +267,14 @@ static inline u32 ipa_reg_state_aggr_active_offset(enum ipa_version version) #define BCR_ROUTER_PREFETCH_EN_FMASK GENMASK(9, 9) /* The value of the next register must be a multiple of 8 (bottom 3 bits 0) */ -#define IPA_REG_LOCAL_PKT_PROC_CNTXT_OFFSET 0x000001e8 +static inline u32 ipa_reg_local_pkt_proc_cntxt_base_offset(enum ipa_version version) +{ + if (version <= IPA_VERSION_2_6L) + return 0x5e0; + + return 0x1e8; +} + /* Encoded value for LOCAL_PKT_PROC_CNTXT register BASE_ADDR field */ static inline u32 proc_cntxt_base_addr_encoded(enum ipa_version version, @@ -252,7 +290,14 @@ static inline u32 proc_cntxt_base_addr_encoded(enum ipa_version version, #define IPA_REG_AGGR_FORCE_CLOSE_OFFSET 0x000001ec /* The next register is not present for IPA v4.5+ */ -#define IPA_REG_COUNTER_CFG_OFFSET 0x000001f0 +static inline u32 ipa_reg_counter_cfg_offset(enum ipa_version version) +{ + if (IPA_VERSION_RANGE(version, 2_5, 2_6L)) + return 0x5e8; + + return 0x1f0; +} + /* The next field is not present for IPA v3.5+ */ #define EOT_COAL_GRANULARITY GENMASK(3, 0) #define AGGR_GRANULARITY_FMASK GENMASK(8, 4) @@ -349,15 +394,27 @@ enum ipa_pulse_gran { #define Y_MIN_LIM_FMASK GENMASK(21, 16) #define Y_MAX_LIM_FMASK GENMASK(29, 24) -#define IPA_REG_ENDP_INIT_CTRL_N_OFFSET(ep) \ - (0x00000800 + 0x0070 * (ep)) +static inline u32 ipa_reg_endp_init_ctrl_n_offset(enum ipa_version version, u16 ep) +{ + if (version <= IPA_VERSION_2_6L) + return 0x70 + 0x4 * ep; + + return 0x800 + 0x70 * ep; +} + /* Valid only for RX (IPA producer) endpoints (do not use for IPA v4.0+) */ #define ENDP_SUSPEND_FMASK GENMASK(0, 0) /* Valid only for TX (IPA consumer) endpoints */ #define ENDP_DELAY_FMASK GENMASK(1, 1) -#define IPA_REG_ENDP_INIT_CFG_N_OFFSET(ep) \ - (0x00000808 + 0x0070 * (ep)) +static inline u32 ipa_reg_endp_init_cfg_n_offset(enum ipa_version version, u16 ep) +{ + if (version <= IPA_VERSION_2_6L) + return 0xc0 + 0x4 * ep; + + return 0x808 + 0x70 * ep; +} + #define FRAG_OFFLOAD_EN_FMASK GENMASK(0, 0) #define CS_OFFLOAD_EN_FMASK GENMASK(2, 1) #define CS_METADATA_HDR_OFFSET_FMASK GENMASK(6, 3) @@ -383,8 +440,14 @@ enum ipa_nat_en { IPA_NAT_DST = 0x2, }; -#define IPA_REG_ENDP_INIT_HDR_N_OFFSET(ep) \ - (0x00000810 + 0x0070 * (ep)) +static inline u32 ipa_reg_endp_init_hdr_n_offset(enum ipa_version version, u16 ep) +{ + if (IPA_VERSION_RANGE(version, 2_0, 2_6L)) + return 0x170 + 0x4 * ep; + + return 0x810 + 0x70 * ep; +} + #define HDR_LEN_FMASK GENMASK(5, 0) #define HDR_OFST_METADATA_VALID_FMASK GENMASK(6, 6) #define HDR_OFST_METADATA_FMASK GENMASK(12, 7) @@ -440,8 +503,14 @@ static inline u32 ipa_metadata_offset_encoded(enum ipa_version version, return val; } -#define IPA_REG_ENDP_INIT_HDR_EXT_N_OFFSET(ep) \ - (0x00000814 + 0x0070 * (ep)) +static inline u32 ipa_reg_endp_init_hdr_ext_n_offset(enum ipa_version version, u16 ep) +{ + if (IPA_VERSION_RANGE(version, 2_0, 2_6L)) + return 0x1c0 + 0x4 * ep; + + return 0x814 + 0x70 * ep; +} + #define HDR_ENDIANNESS_FMASK GENMASK(0, 0) #define HDR_TOTAL_LEN_OR_PAD_VALID_FMASK GENMASK(1, 1) #define HDR_TOTAL_LEN_OR_PAD_FMASK GENMASK(2, 2) @@ -454,12 +523,23 @@ static inline u32 ipa_metadata_offset_encoded(enum ipa_version version, #define HDR_ADDITIONAL_CONST_LEN_MSB_FMASK GENMASK(21, 20) /* Valid only for RX (IPA producer) endpoints */ -#define IPA_REG_ENDP_INIT_HDR_METADATA_MASK_N_OFFSET(rxep) \ - (0x00000818 + 0x0070 * (rxep)) +static inline u32 ipa_reg_endp_init_hdr_metadata_mask_n_offset(enum ipa_version version, u16 rxep) +{ + if (version <= IPA_VERSION_2_6L) + return 0x220 + 0x4 * rxep; + + return 0x818 + 0x70 * rxep; +} /* Valid only for TX (IPA consumer) endpoints */ -#define IPA_REG_ENDP_INIT_MODE_N_OFFSET(txep) \ - (0x00000820 + 0x0070 * (txep)) +static inline u32 ipa_reg_endp_init_mode_n_offset(enum ipa_version version, u16 txep) +{ + if (IPA_VERSION_RANGE(version, 2_0, 2_6L)) + return 0x2c0 + 0x4 * txep; + + return 0x820 + 0x70 * txep; +} + #define MODE_FMASK GENMASK(2, 0) /* The next field is present for IPA v4.5+ */ #define DCPH_ENABLE_FMASK GENMASK(3, 3) @@ -480,8 +560,14 @@ enum ipa_mode { IPA_DMA = 0x3, }; -#define IPA_REG_ENDP_INIT_AGGR_N_OFFSET(ep) \ - (0x00000824 + 0x0070 * (ep)) +static inline u32 ipa_reg_endp_init_aggr_n_offset(enum ipa_version version, + u16 ep) +{ + if (IPA_VERSION_RANGE(version, 2_0, 2_6L)) + return 0x320 + 0x4 * ep; + return 0x824 + 0x70 * ep; +} + #define AGGR_EN_FMASK GENMASK(1, 0) #define AGGR_TYPE_FMASK GENMASK(4, 2) @@ -543,14 +629,27 @@ enum ipa_aggr_type { }; /* Valid only for RX (IPA producer) endpoints */ -#define IPA_REG_ENDP_INIT_HOL_BLOCK_EN_N_OFFSET(rxep) \ - (0x0000082c + 0x0070 * (rxep)) +static inline u32 ipa_reg_endp_init_hol_block_en_n_offset(enum ipa_version version, + u16 rxep) +{ + if (IPA_VERSION_RANGE(version, 2_0, 2_6L)) + return 0x3c0 + 0x4 * rxep; + + return 0x82c + 0x70 * rxep; +} + #define HOL_BLOCK_EN_FMASK GENMASK(0, 0) /* Valid only for RX (IPA producer) endpoints */ -#define IPA_REG_ENDP_INIT_HOL_BLOCK_TIMER_N_OFFSET(rxep) \ - (0x00000830 + 0x0070 * (rxep)) -/* The next two fields are present for IPA v4.2 only */ +static inline u32 ipa_reg_endp_init_hol_block_timer_n_offset(enum ipa_version version, u16 rxep) +{ + if (IPA_VERSION_RANGE(version, 2_0, 2_6L)) + return 0x420 + 0x4 * rxep; + + return 0x830 + 0x70 * rxep; +} + +/* The next fields are present for IPA v4.2 only */ #define BASE_VALUE_FMASK GENMASK(4, 0) #define SCALE_FMASK GENMASK(12, 8) /* The next two fields are present for IPA v4.5 */ @@ -558,8 +657,14 @@ enum ipa_aggr_type { #define GRAN_SEL_FMASK GENMASK(8, 8) /* Valid only for TX (IPA consumer) endpoints */ -#define IPA_REG_ENDP_INIT_DEAGGR_N_OFFSET(txep) \ - (0x00000834 + 0x0070 * (txep)) +static inline u32 ipa_reg_endp_init_deaggr_n_offset(enum ipa_version version, u16 txep) +{ + if (IPA_VERSION_RANGE(version, 2_0, 2_6L)) + return 0x470 + 0x4 * txep; + + return 0x834 + 0x70 * txep; +} + #define DEAGGR_HDR_LEN_FMASK GENMASK(5, 0) #define SYSPIPE_ERR_DETECTION_FMASK GENMASK(6, 6) #define PACKET_OFFSET_VALID_FMASK GENMASK(7, 7) @@ -629,8 +734,14 @@ enum ipa_seq_rep_type { IPA_SEQ_REP_DMA_PARSER = 0x08, }; -#define IPA_REG_ENDP_STATUS_N_OFFSET(ep) \ - (0x00000840 + 0x0070 * (ep)) +static inline u32 ipa_reg_endp_status_n_offset(enum ipa_version version, u16 ep) +{ + if (version <= IPA_VERSION_2_6L) + return 0x4c0 + 0x4 * ep; + + return 0x840 + 0x70 * ep; +} + #define STATUS_EN_FMASK GENMASK(0, 0) #define STATUS_ENDP_FMASK GENMASK(5, 1) /* The next field is not present for IPA v4.5+ */ @@ -662,6 +773,9 @@ enum ipa_seq_rep_type { static inline u32 ipa_reg_irq_stts_ee_n_offset(enum ipa_version version, u32 ee) { + if (version <= IPA_VERSION_2_6L) + return 0x00001008 + 0x1000 * ee; + if (version < IPA_VERSION_4_9) return 0x00003008 + 0x1000 * ee; @@ -675,6 +789,9 @@ static inline u32 ipa_reg_irq_stts_offset(enum ipa_version version) static inline u32 ipa_reg_irq_en_ee_n_offset(enum ipa_version version, u32 ee) { + if (version <= IPA_VERSION_2_6L) + return 0x0000100c + 0x1000 * ee; + if (version < IPA_VERSION_4_9) return 0x0000300c + 0x1000 * ee; @@ -688,6 +805,9 @@ static inline u32 ipa_reg_irq_en_offset(enum ipa_version version) static inline u32 ipa_reg_irq_clr_ee_n_offset(enum ipa_version version, u32 ee) { + if (version <= IPA_VERSION_2_6L) + return 0x00001010 + 0x1000 * ee; + if (version < IPA_VERSION_4_9) return 0x00003010 + 0x1000 * ee; @@ -776,6 +896,9 @@ enum ipa_irq_id { static inline u32 ipa_reg_irq_uc_ee_n_offset(enum ipa_version version, u32 ee) { + if (version <= IPA_VERSION_2_6L) + return 0x101c + 1000 * ee; + if (version < IPA_VERSION_4_9) return 0x0000301c + 0x1000 * ee; @@ -793,6 +916,9 @@ static inline u32 ipa_reg_irq_uc_offset(enum ipa_version version) static inline u32 ipa_reg_irq_suspend_info_ee_n_offset(enum ipa_version version, u32 ee) { + if (version <= IPA_VERSION_2_6L) + return 0x00001098 + 0x1000 * ee; + if (version == IPA_VERSION_3_0) return 0x00003098 + 0x1000 * ee; diff --git a/drivers/net/ipa/ipa_version.h b/drivers/net/ipa/ipa_version.h index 6c16c895d842..0d816de586ba 100644 --- a/drivers/net/ipa/ipa_version.h +++ b/drivers/net/ipa/ipa_version.h @@ -8,6 +8,9 @@ /** * enum ipa_version + * @IPA_VERSION_2_0: IPA version 2.0 + * @IPA_VERSION_2_5: IPA version 2.5/2.6 + * @IPA_VERSION_2_6: IPA version 2.6L * @IPA_VERSION_3_0: IPA version 3.0/GSI version 1.0 * @IPA_VERSION_3_1: IPA version 3.1/GSI version 1.1 * @IPA_VERSION_3_5: IPA version 3.5/GSI version 1.2 @@ -25,6 +28,9 @@ * new version is added. */ enum ipa_version { + IPA_VERSION_2_0, + IPA_VERSION_2_5, + IPA_VERSION_2_6L, IPA_VERSION_3_0, IPA_VERSION_3_1, IPA_VERSION_3_5, @@ -38,4 +44,10 @@ enum ipa_version { IPA_VERSION_4_11, }; +#define IPA_HAS_GSI(version) ((version) > IPA_VERSION_2_6L) +#define IPA_IS_64BIT(version) ((version) > IPA_VERSION_2_6L) +#define IPA_VERSION_RANGE(_version, _from, _to) \ + ((_version) >= (IPA_VERSION_##_from) && \ + (_version) <= (IPA_VERSION_##_to)) + #endif /* _IPA_VERSION_H_ */ From patchwork Mon Sep 20 03:08:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sireesh Kodali X-Patchwork-Id: 12504543 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D4B7C433F5 for ; Mon, 20 Sep 2021 03:09:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 03E4360FC0 for ; Mon, 20 Sep 2021 03:09:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234523AbhITDLI (ORCPT ); Sun, 19 Sep 2021 23:11:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234402AbhITDK7 (ORCPT ); Sun, 19 Sep 2021 23:10:59 -0400 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27F5FC0613E0; Sun, 19 Sep 2021 20:09:18 -0700 (PDT) Received: by mail-pg1-x52c.google.com with SMTP id q68so15891371pga.9; Sun, 19 Sep 2021 20:09:18 -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=SD6TUaTysMr9VbomNxG6XTtL1KVslrTC3ehz6KVrhuY=; b=PZAZufPgOPGU9cmaXjPnjuYiKgEQw0ng7Bh7KjKn6NgQmcYHLMeQfjiwUepm5yShq3 xuyjmXHpivpbMtI0wWFYzt7KBFPEzSQ90iFu5aO3tNCE/X5RFtWxw8usdBb2QfTaBOzi 8FxVOga6o8j+ROvnkfhlmpirTb2m4AQPay+LRzZS+qwYcXmUWrENLYU/9HXDMaoegPve fr5Lu709DHDMsBJXa0DiseuCWNRap1/UW9osJ/bfjKakqc2xBf8SQMyB07FRIFekzYqJ L8OzVJFWECEfeHRd4oH8Spp8Iu94mmM4RcHCKhZB32EGsp4fZq5ToxGWBQKTEAWzZqBa IHfw== 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=SD6TUaTysMr9VbomNxG6XTtL1KVslrTC3ehz6KVrhuY=; b=6F/6SwFr43IYo5hrIKO+at5GysZRzD6cjZYYQZuk26BJVNDlbtnRiPhLQaj/N7JLPN OS1eanigGOs+UDDu/EaTOtY5lFqsm+wMfR0GPcdfTYi9Ml1F2pxNa+CyXwSMHsX+PIF6 Rh+x8+kHm0V+rzJk7e69opeDU1x1I5vR11RoIxwOky7xIC1VqCNOIkHjcqGx8SlEpEBT C5oLEbdx4NPWmagRilYnifNO6+YZ06R2F8acnh+p0APCd2kT2anUE7e8tA+ovvvdnX4q 2/u/pCcwLSMlQRWmT/rqhd70f3PVtaVoZHXTwET02t1PY48Rl9AFMnV6ZcKVuJy4TRDp kT0g== X-Gm-Message-State: AOAM532+jOb944irDpK6CBPDqq43J4wsGm4a5N5MS1vjjlu0xVfFiXQS mTFBSxX0bMWjlpWqYHVSteJPlW3/CSvyEg6q X-Google-Smtp-Source: ABdhPJy9x8/tPXaq1b/8OZRU6zEejY00lLIS0HTHEdnEsE4Ib74Dw08ApXSEohvLDQSldOE7dkvUaA== X-Received: by 2002:a65:404d:: with SMTP id h13mr21649467pgp.130.1632107357415; Sun, 19 Sep 2021 20:09:17 -0700 (PDT) Received: from skynet-linux.local ([106.201.127.154]) by smtp.googlemail.com with ESMTPSA id l11sm16295065pjg.22.2021.09.19.20.09.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Sep 2021 20:09:17 -0700 (PDT) From: Sireesh Kodali To: phone-devel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, elder@kernel.org Cc: Vladimir Lypak , Sireesh Kodali , "David S. Miller" , Jakub Kicinski Subject: [RFC PATCH 08/17] net: ipa: Add support for IPA v2.x interrupts Date: Mon, 20 Sep 2021 08:38:02 +0530 Message-Id: <20210920030811.57273-9-sireeshkodali1@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920030811.57273-1-sireeshkodali1@gmail.com> References: <20210920030811.57273-1-sireeshkodali1@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Vladimir Lypak Interrupts on IPA v2.x have different numbers from the v3.x and above interrupts. IPA v2.x also doesn't support the TX_SUSPEND irq, like v3.0 Signed-off-by: Vladimir Lypak Signed-off-by: Sireesh Kodali --- drivers/net/ipa/ipa_interrupt.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/net/ipa/ipa_interrupt.c b/drivers/net/ipa/ipa_interrupt.c index 94708a23a597..37b5932253aa 100644 --- a/drivers/net/ipa/ipa_interrupt.c +++ b/drivers/net/ipa/ipa_interrupt.c @@ -63,6 +63,11 @@ static bool ipa_interrupt_check_fixup(enum ipa_irq_id *irq_id, enum ipa_version if (*irq_id >= IPA_IRQ_DRBIP_PKT_EXCEED_MAX_SIZE_EN) return version >= IPA_VERSION_4_9; + else if (*irq_id > IPA_IRQ_BAM_GSI_IDLE) + return version >= IPA_VERSION_3_0; + else if (version <= IPA_VERSION_2_6L && + *irq_id >= IPA_IRQ_PROC_UC_ACK_Q_NOT_EMPTY) + *irq_id += 2; return true; } @@ -152,8 +157,8 @@ static void ipa_interrupt_suspend_control(struct ipa_interrupt *interrupt, WARN_ON(!(mask & ipa->available)); - /* IPA version 3.0 does not support TX_SUSPEND interrupt control */ - if (ipa->version == IPA_VERSION_3_0) + /* IPA version <=3.0 does not support TX_SUSPEND interrupt control */ + if (ipa->version <= IPA_VERSION_3_0) return; offset = ipa_reg_irq_suspend_en_offset(ipa->version); @@ -190,7 +195,7 @@ void ipa_interrupt_suspend_clear_all(struct ipa_interrupt *interrupt) val = ioread32(ipa->reg_virt + offset); /* SUSPEND interrupt status isn't cleared on IPA version 3.0 */ - if (ipa->version == IPA_VERSION_3_0) + if (ipa->version <= IPA_VERSION_3_0) return; offset = ipa_reg_irq_suspend_clr_offset(ipa->version); From patchwork Mon Sep 20 03:08:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sireesh Kodali X-Patchwork-Id: 12504547 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A460C433F5 for ; Mon, 20 Sep 2021 03:09:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7910460FC0 for ; Mon, 20 Sep 2021 03:09:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234409AbhITDLP (ORCPT ); Sun, 19 Sep 2021 23:11:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234458AbhITDLC (ORCPT ); Sun, 19 Sep 2021 23:11:02 -0400 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6CCBC0613E8; Sun, 19 Sep 2021 20:09:25 -0700 (PDT) Received: by mail-pg1-x52f.google.com with SMTP id r2so15904863pgl.10; Sun, 19 Sep 2021 20:09:25 -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=hRVmMTtGuyY1wsNVuL+S9G6ldqnq3Q9n9vsyQio2irs=; b=ogL2l82FWgjaZJRB5uSKO+J3GSROOQezjmqysYw4BPr56pDQW2O5iQc1jPW4+xD4+s R9e07a3xBhEEG7fa5fER1VQ9oeSInNX5+L3OT34+yxZ6uiTiAJxtevTsokCmZAMHA8OW sQTdc7KuDvI8bOy3a/Xlvg3PZEUHJPEA47Jdr/nh5bhkfbK0Pm36N37ULo8AsQWZtFkD cKVtr+hyEUQERVjnv4RG1wO0h3Q3ihsMLu87aLyfGhBUTw3eGTSnW1QUMR8UalviT/Gk QOrhsWGPOGOkp6sYFxDgqP1A6qT5xQo1PlMDFKl56PotCR5X8Pwye11BU/zTLeO2UiLC uKcQ== 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=hRVmMTtGuyY1wsNVuL+S9G6ldqnq3Q9n9vsyQio2irs=; b=L/6OX5M8DCTyD7KDbkDbK0A/7S7g/wJsWwBJ3c+YfFxMsBbvYtt1zH5GsOIsmiMn99 isjicYIIRTGmcdTqTaPz2cYtuAuRDYXVj9mZ+FYUATgyQPZ7dyNOSRuDPqVUDM7YSDo4 +s11oes7R+nZh6Zo8RPLxkz5eGieDBE3Xlx+z9UHAxus6NracPbEyNTUMJyXnIBVATja lpkvnXUV/Qt43pu1tFrTjmJ8lkNPSGdo6ja0h0OLJRMM1U2yg56lLgRUdxg3rjQeXfFS lCyff480rHuJbscchKTCU9QZQgasKW+/rOZXNn5mv7w+WTiaojRn4H/JnYWqp4hHgD6B eJwQ== X-Gm-Message-State: AOAM533Wqb8P6fNE/gEzAa5fI9QLnAcdp2rqNV0EOft0g31fiobsqH6e WwarYcaHCeDMP/wT32H+JA62TPd0ediwEzCd X-Google-Smtp-Source: ABdhPJzC+RdP5kmzeP1RnDzEWJLkUZfQAS92951PHxUem4KrlWqQ+bATVDA41yfDvrEBM++U00BS7Q== X-Received: by 2002:a65:6213:: with SMTP id d19mr21617998pgv.110.1632107364789; Sun, 19 Sep 2021 20:09:24 -0700 (PDT) Received: from skynet-linux.local ([106.201.127.154]) by smtp.googlemail.com with ESMTPSA id l11sm16295065pjg.22.2021.09.19.20.09.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Sep 2021 20:09:24 -0700 (PDT) From: Sireesh Kodali To: phone-devel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, elder@kernel.org Cc: Sireesh Kodali , "David S. Miller" , Jakub Kicinski Subject: [RFC PATCH 09/17] net: ipa: Add support for using BAM as a DMA transport Date: Mon, 20 Sep 2021 08:38:03 +0530 Message-Id: <20210920030811.57273-10-sireeshkodali1@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920030811.57273-1-sireeshkodali1@gmail.com> References: <20210920030811.57273-1-sireeshkodali1@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org BAM is used on IPA v2.x. Since BAM already has a nice dmaengine driver, the IPA driver only makes calls the dmaengine API. Also add BAM transaction support to IPA's trasaction abstraction layer. BAM transactions should use NAPI just like GSI transactions, but just use callbacks on each transaction for now. Signed-off-by: Sireesh Kodali --- drivers/net/ipa/Makefile | 2 +- drivers/net/ipa/bam.c | 525 ++++++++++++++++++++++++++++++ drivers/net/ipa/gsi.c | 1 + drivers/net/ipa/ipa_data.h | 1 + drivers/net/ipa/ipa_dma.h | 18 +- drivers/net/ipa/ipa_dma_private.h | 2 + drivers/net/ipa/ipa_main.c | 20 +- drivers/net/ipa/ipa_trans.c | 14 +- drivers/net/ipa/ipa_trans.h | 4 + 9 files changed, 569 insertions(+), 18 deletions(-) create mode 100644 drivers/net/ipa/bam.c diff --git a/drivers/net/ipa/Makefile b/drivers/net/ipa/Makefile index 3cd021fb992e..4abebc667f77 100644 --- a/drivers/net/ipa/Makefile +++ b/drivers/net/ipa/Makefile @@ -2,7 +2,7 @@ obj-$(CONFIG_QCOM_IPA) += ipa.o ipa-y := ipa_main.o ipa_power.o ipa_reg.o ipa_mem.o \ ipa_table.o ipa_interrupt.o gsi.o ipa_trans.o \ - ipa_gsi.o ipa_smp2p.o ipa_uc.o \ + ipa_gsi.o ipa_smp2p.o ipa_uc.o bam.o \ ipa_endpoint.o ipa_cmd.o ipa_modem.o \ ipa_resource.o ipa_qmi.o ipa_qmi_msg.o \ ipa_sysfs.o diff --git a/drivers/net/ipa/bam.c b/drivers/net/ipa/bam.c new file mode 100644 index 000000000000..0726e385fee5 --- /dev/null +++ b/drivers/net/ipa/bam.c @@ -0,0 +1,525 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* Copyright (c) 2020, The Linux Foundation. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "ipa_gsi.h" +#include "ipa.h" +#include "ipa_dma.h" +#include "ipa_dma_private.h" +#include "ipa_gsi.h" +#include "ipa_trans.h" +#include "ipa_data.h" + +/** + * DOC: The IPA Smart Peripheral System Interface + * + * The Smart Peripheral System is a means to communicate over BAM pipes to + * the IPA block. The Modem also uses BAM pipes to communicate with the IPA + * core. + * + * Refer the GSI documentation, because BAM is a precursor to GSI and more or less + * the same, conceptually (maybe, IDK, I have no docs to go through). + * + * Each channel here corresponds to 1 BAM pipe configured in BAM2BAM mode + * + * IPA cmds are transferred one at a time, each in one BAM transfer. + */ + +/* Get and configure the BAM DMA channel */ +int bam_channel_init_one(struct ipa_dma *bam, + const struct ipa_gsi_endpoint_data *data, bool command) +{ + struct dma_slave_config bam_config; + u32 channel_id = data->channel_id; + struct ipa_channel *channel = &bam->channel[channel_id]; + int ret; + + /*TODO: if (!bam_channel_data_valid(bam, data)) + return -EINVAL;*/ + + channel->dma_subsys = bam; + channel->dma_chan = dma_request_chan(bam->dev, data->channel_name); + channel->toward_ipa = data->toward_ipa; + channel->tlv_count = data->channel.tlv_count; + channel->tre_count = data->channel.tre_count; + if (IS_ERR(channel->dma_chan)) { + dev_err(bam->dev, "failed to request BAM channel %s: %d\n", + data->channel_name, + (int) PTR_ERR(channel->dma_chan)); + return PTR_ERR(channel->dma_chan); + } + + ret = ipa_channel_trans_init(bam, data->channel_id); + if (ret) + goto err_dma_chan_free; + + if (data->toward_ipa) { + bam_config.direction = DMA_MEM_TO_DEV; + bam_config.dst_maxburst = channel->tlv_count; + } else { + bam_config.direction = DMA_DEV_TO_MEM; + bam_config.src_maxburst = channel->tlv_count; + } + + dmaengine_slave_config(channel->dma_chan, &bam_config); + + if (command) + ret = ipa_cmd_pool_init(channel, 256); + + if (!ret) + return 0; + +err_dma_chan_free: + dma_release_channel(channel->dma_chan); + return ret; +} + +static void bam_channel_exit_one(struct ipa_channel *channel) +{ + if (channel->dma_chan) { + dmaengine_terminate_sync(channel->dma_chan); + dma_release_channel(channel->dma_chan); + } +} + +/* Get channels from BAM_DMA */ +int bam_channel_init(struct ipa_dma *bam, u32 count, + const struct ipa_gsi_endpoint_data *data) +{ + int ret = 0; + u32 i; + + for (i = 0; i < count; ++i) { + bool command = i == IPA_ENDPOINT_AP_COMMAND_TX; + + if (!data[i].channel_name || data[i].ee_id == GSI_EE_MODEM) + continue; + + ret = bam_channel_init_one(bam, &data[i], command); + if (ret) + goto err_unwind; + } + + return ret; + +err_unwind: + while (i--) { + if (ipa_gsi_endpoint_data_empty(&data[i])) + continue; + + bam_channel_exit_one(&bam->channel[i]); + } + return ret; +} + +/* Inverse of bam_channel_init() */ +void bam_channel_exit(struct ipa_dma *bam) +{ + u32 channel_id = BAM_CHANNEL_COUNT_MAX - 1; + + do + bam_channel_exit_one(&bam->channel[channel_id]); + while (channel_id--); +} + +/* Inverse of bam_init() */ +static void bam_exit(struct ipa_dma *bam) +{ + mutex_destroy(&bam->mutex); + bam_channel_exit(bam); +} + +/* Return the channel id associated with a given channel */ +static u32 bam_channel_id(struct ipa_channel *channel) +{ + return channel - &channel->dma_subsys->channel[0]; +} + +static void +bam_channel_tx_update(struct ipa_channel *channel, struct ipa_trans *trans) +{ + u64 byte_count = trans->byte_count + trans->len; + u64 trans_count = trans->trans_count + 1; + + byte_count -= channel->compl_byte_count; + channel->compl_byte_count += byte_count; + trans_count -= channel->compl_trans_count; + channel->compl_trans_count += trans_count; + + ipa_gsi_channel_tx_completed(channel->dma_subsys, bam_channel_id(channel), + trans_count, byte_count); +} + +static void +bam_channel_rx_update(struct ipa_channel *channel, struct ipa_trans *trans) +{ + /* FIXME */ + u64 byte_count = trans->byte_count + trans->len; + + channel->byte_count += byte_count; + channel->trans_count++; +} + +/* Consult hardware, move any newly completed transactions to completed list */ +static void bam_channel_update(struct ipa_channel *channel) +{ + struct ipa_trans *trans; + + list_for_each_entry(trans, &channel->trans_info.pending, links) { + enum dma_status trans_status = + dma_async_is_tx_complete(channel->dma_chan, + trans->cookie, NULL, NULL); + if (trans_status == DMA_COMPLETE) + break; + } + /* Get the transaction for the latest completed event. Take a + * reference to keep it from completing before we give the events + * for this and previous transactions back to the hardware. + */ + refcount_inc(&trans->refcount); + + /* For RX channels, update each completed transaction with the number + * of bytes that were actually received. For TX channels, report + * the number of transactions and bytes this completion represents + * up the network stack. + */ + if (channel->toward_ipa) + bam_channel_tx_update(channel, trans); + else + bam_channel_rx_update(channel, trans); + + ipa_trans_move_complete(trans); + + ipa_trans_free(trans); +} + +/** + * bam_channel_poll_one() - Return a single completed transaction on a channel + * @channel: Channel to be polled + * + * Return: Transaction pointer, or null if none are available + * + * This function returns the first entry on a channel's completed transaction + * list. If that list is empty, the hardware is consulted to determine + * whether any new transactions have completed. If so, they're moved to the + * completed list and the new first entry is returned. If there are no more + * completed transactions, a null pointer is returned. + */ +static struct ipa_trans *bam_channel_poll_one(struct ipa_channel *channel) +{ + struct ipa_trans *trans; + + /* Get the first transaction from the completed list */ + trans = ipa_channel_trans_complete(channel); + if (!trans) { + bam_channel_update(channel); + trans = ipa_channel_trans_complete(channel); + } + + if (trans) + ipa_trans_move_polled(trans); + + return trans; +} + +/** + * bam_channel_poll() - NAPI poll function for a channel + * @napi: NAPI structure for the channel + * @budget: Budget supplied by NAPI core + * + * Return: Number of items polled (<= budget) + * + * Single transactions completed by hardware are polled until either + * the budget is exhausted, or there are no more. Each transaction + * polled is passed to ipa_trans_complete(), to perform remaining + * completion processing and retire/free the transaction. + */ +static int bam_channel_poll(struct napi_struct *napi, int budget) +{ + struct ipa_channel *channel; + int count = 0; + + channel = container_of(napi, struct ipa_channel, napi); + while (count < budget) { + struct ipa_trans *trans; + + count++; + trans = bam_channel_poll_one(channel); + if (!trans) + break; + ipa_trans_complete(trans); + } + + if (count < budget) + napi_complete(&channel->napi); + + return count; +} + +/* Setup function for a single channel */ +static void bam_channel_setup_one(struct ipa_dma *bam, u32 channel_id) +{ + struct ipa_channel *channel = &bam->channel[channel_id]; + + if (!channel->dma_subsys) + return; /* Ignore uninitialized channels */ + + if (channel->toward_ipa) { + netif_tx_napi_add(&bam->dummy_dev, &channel->napi, + bam_channel_poll, NAPI_POLL_WEIGHT); + } else { + netif_napi_add(&bam->dummy_dev, &channel->napi, + bam_channel_poll, NAPI_POLL_WEIGHT); + } + napi_enable(&channel->napi); +} + +static void bam_channel_teardown_one(struct ipa_dma *bam, u32 channel_id) +{ + struct ipa_channel *channel = &bam->channel[channel_id]; + + if (!channel->dma_subsys) + return; /* Ignore uninitialized channels */ + + netif_napi_del(&channel->napi); +} + +/* Setup function for channels */ +static int bam_channel_setup(struct ipa_dma *bam) +{ + u32 channel_id = 0; + int ret; + + mutex_lock(&bam->mutex); + + do + bam_channel_setup_one(bam, channel_id); + while (++channel_id < BAM_CHANNEL_COUNT_MAX); + + /* Make sure no channels were defined that hardware does not support */ + while (channel_id < BAM_CHANNEL_COUNT_MAX) { + struct ipa_channel *channel = &bam->channel[channel_id++]; + + if (!channel->dma_subsys) + continue; /* Ignore uninitialized channels */ + + dev_err(bam->dev, "channel %u not supported by hardware\n", + channel_id - 1); + channel_id = BAM_CHANNEL_COUNT_MAX; + goto err_unwind; + } + + mutex_unlock(&bam->mutex); + + return 0; + +err_unwind: + while (channel_id--) + bam_channel_teardown_one(bam, channel_id); + + mutex_unlock(&bam->mutex); + + return ret; +} + +/* Inverse of bam_channel_setup() */ +static void bam_channel_teardown(struct ipa_dma *bam) +{ + u32 channel_id; + + mutex_lock(&bam->mutex); + + channel_id = BAM_CHANNEL_COUNT_MAX; + do + bam_channel_teardown_one(bam, channel_id); + while (channel_id--); + + mutex_unlock(&bam->mutex); +} + +static int bam_setup(struct ipa_dma *bam) +{ + return bam_channel_setup(bam); +} + +static void bam_teardown(struct ipa_dma *bam) +{ + bam_channel_teardown(bam); +} + +static u32 bam_channel_tre_max(struct ipa_dma *bam, u32 channel_id) +{ + struct ipa_channel *channel = &bam->channel[channel_id]; + + /* Hardware limit is channel->tre_count - 1 */ + return channel->tre_count - (channel->tlv_count - 1); +} + +static u32 bam_channel_trans_tre_max(struct ipa_dma *bam, u32 channel_id) +{ + struct ipa_channel *channel = &bam->channel[channel_id]; + + return channel->tlv_count; +} + +static int bam_channel_start(struct ipa_dma *bam, u32 channel_id) +{ + return 0; +} + +static int bam_channel_stop(struct ipa_dma *bam, u32 channel_id) +{ + struct ipa_channel *channel = &bam->channel[channel_id]; + + return dmaengine_terminate_sync(channel->dma_chan); +} + +static void bam_channel_reset(struct ipa_dma *bam, u32 channel_id, bool doorbell) +{ + bam_channel_stop(bam, channel_id); +} + +static int bam_channel_suspend(struct ipa_dma *bam, u32 channel_id) +{ + struct ipa_channel *channel = &bam->channel[channel_id]; + + return dmaengine_pause(channel->dma_chan); +} + +static int bam_channel_resume(struct ipa_dma *bam, u32 channel_id) +{ + struct ipa_channel *channel = &bam->channel[channel_id]; + + return dmaengine_resume(channel->dma_chan); +} + +static void bam_suspend(struct ipa_dma *bam) +{ + /* No-op for now */ +} + +static void bam_resume(struct ipa_dma *bam) +{ + /* No-op for now */ +} + +static void bam_trans_callback(void *arg) +{ + ipa_trans_complete(arg); +} + +static void bam_trans_commit(struct ipa_trans *trans, bool unused) +{ + struct ipa_channel *channel = &trans->dma_subsys->channel[trans->channel_id]; + enum ipa_cmd_opcode opcode = IPA_CMD_NONE; + struct ipa_cmd_info *info; + struct scatterlist *sg; + u32 byte_count = 0; + u32 i; + enum dma_transfer_direction direction; + + if (channel->toward_ipa) + direction = DMA_MEM_TO_DEV; + else + direction = DMA_DEV_TO_MEM; + + /* assert(trans->used > 0); */ + + info = trans->info ? &trans->info[0] : NULL; + for_each_sg(trans->sgl, sg, trans->used, i) { + bool last_tre = i == trans->used - 1; + dma_addr_t addr = sg_dma_address(sg); + u32 len = sg_dma_len(sg); + u32 dma_flags = 0; + struct dma_async_tx_descriptor *desc; + + byte_count += len; + if (info) + opcode = info++->opcode; + + if (opcode != IPA_CMD_NONE) { + len = opcode; + dma_flags |= DMA_PREP_IMM_CMD; + } + + if (last_tre) + dma_flags |= DMA_PREP_INTERRUPT; + + desc = dmaengine_prep_slave_single(channel->dma_chan, addr, len, + direction, dma_flags); + + if (last_tre) { + desc->callback = bam_trans_callback; + desc->callback_param = trans; + } + + desc->cookie = dmaengine_submit(desc); + + if (last_tre) + trans->cookie = desc->cookie; + + if (direction == DMA_DEV_TO_MEM) + dmaengine_desc_attach_metadata(desc, &trans->len, sizeof(trans->len)); + } + + if (channel->toward_ipa) { + /* We record TX bytes when they are sent */ + trans->len = byte_count; + trans->trans_count = channel->trans_count; + trans->byte_count = channel->byte_count; + channel->trans_count++; + channel->byte_count += byte_count; + } + + ipa_trans_move_pending(trans); + + dma_async_issue_pending(channel->dma_chan); +} + +/* Initialize the BAM DMA channels + * Actual hw init is handled by the BAM_DMA driver + */ +int bam_init(struct ipa_dma *bam, struct platform_device *pdev, + enum ipa_version version, u32 count, + const struct ipa_gsi_endpoint_data *data) +{ + struct device *dev = &pdev->dev; + int ret; + + bam->dev = dev; + bam->version = version; + bam->setup = bam_setup; + bam->teardown = bam_teardown; + bam->exit = bam_exit; + bam->suspend = bam_suspend; + bam->resume = bam_resume; + bam->channel_tre_max = bam_channel_tre_max; + bam->channel_trans_tre_max = bam_channel_trans_tre_max; + bam->channel_start = bam_channel_start; + bam->channel_stop = bam_channel_stop; + bam->channel_reset = bam_channel_reset; + bam->channel_suspend = bam_channel_suspend; + bam->channel_resume = bam_channel_resume; + bam->trans_commit = bam_trans_commit; + + init_dummy_netdev(&bam->dummy_dev); + + ret = bam_channel_init(bam, count, data); + if (ret) + return ret; + + mutex_init(&bam->mutex); + + return 0; +} diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 39d9ca620a9f..ac0b9e748fa1 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -2210,6 +2210,7 @@ int gsi_init(struct ipa_dma *gsi, struct platform_device *pdev, gsi->channel_reset = gsi_channel_reset; gsi->channel_suspend = gsi_channel_suspend; gsi->channel_resume = gsi_channel_resume; + gsi->trans_commit = gsi_trans_commit; /* GSI uses NAPI on all channels. Create a dummy network device * for the channel NAPI contexts to be associated with. diff --git a/drivers/net/ipa/ipa_data.h b/drivers/net/ipa/ipa_data.h index 6d329e9ce5d2..7d62d49f414f 100644 --- a/drivers/net/ipa/ipa_data.h +++ b/drivers/net/ipa/ipa_data.h @@ -188,6 +188,7 @@ struct ipa_gsi_endpoint_data { u8 channel_id; u8 endpoint_id; bool toward_ipa; + const char *channel_name; /* used only for BAM DMA channels */ struct gsi_channel_data channel; struct ipa_endpoint_data endpoint; diff --git a/drivers/net/ipa/ipa_dma.h b/drivers/net/ipa/ipa_dma.h index 1a23e6ac5785..3000182ae689 100644 --- a/drivers/net/ipa/ipa_dma.h +++ b/drivers/net/ipa/ipa_dma.h @@ -17,7 +17,11 @@ /* Maximum number of channels and event rings supported by the driver */ #define GSI_CHANNEL_COUNT_MAX 23 +#define BAM_CHANNEL_COUNT_MAX 20 #define GSI_EVT_RING_COUNT_MAX 24 +#define IPA_CHANNEL_COUNT_MAX MAX(GSI_CHANNEL_COUNT_MAX, \ + BAM_CHANNEL_COUNT_MAX) +#define MAX(a, b) ((a > b) ? a : b) /* Maximum TLV FIFO size for a channel; 64 here is arbitrary (and high) */ #define GSI_TLV_MAX 64 @@ -119,6 +123,8 @@ struct ipa_channel { struct gsi_ring tre_ring; u32 evt_ring_id; + struct dma_chan *dma_chan; + u64 byte_count; /* total # bytes transferred */ u64 trans_count; /* total # transactions */ /* The following counts are used only for TX endpoints */ @@ -154,7 +160,7 @@ struct ipa_dma { u32 irq; u32 channel_count; u32 evt_ring_count; - struct ipa_channel channel[GSI_CHANNEL_COUNT_MAX]; + struct ipa_channel channel[IPA_CHANNEL_COUNT_MAX]; struct gsi_evt_ring evt_ring[GSI_EVT_RING_COUNT_MAX]; u32 event_bitmap; /* allocated event rings */ u32 modem_channel_bitmap; /* modem channels to allocate */ @@ -303,7 +309,7 @@ static inline void ipa_dma_resume(struct ipa_dma *dma_subsys) } /** - * ipa_dma_init() - Initialize the GSI subsystem + * ipa_init/bam_init() - Initialize the GSI/BAM subsystem * @dma_subsys: Address of ipa_dma structure embedded in an IPA structure * @pdev: IPA platform device * @version: IPA hardware version (implies GSI version) @@ -312,14 +318,18 @@ static inline void ipa_dma_resume(struct ipa_dma *dma_subsys) * * Return: 0 if successful, or a negative error code * - * Early stage initialization of the GSI subsystem, performing tasks - * that can be done before the GSI hardware is ready to use. + * Early stage initialization of the GSI/BAM subsystem, performing tasks + * that can be done before the GSI/BAM hardware is ready to use. */ int gsi_init(struct ipa_dma *dma_subsys, struct platform_device *pdev, enum ipa_version version, u32 count, const struct ipa_gsi_endpoint_data *data); +int bam_init(struct ipa_dma *dma_subsys, struct platform_device *pdev, + enum ipa_version version, u32 count, + const struct ipa_gsi_endpoint_data *data); + /** * ipa_dma_exit() - Exit the DMA subsystem * @dma_subsys: ipa_dma address previously passed to a successful gsi_init() call diff --git a/drivers/net/ipa/ipa_dma_private.h b/drivers/net/ipa/ipa_dma_private.h index 40148a551b47..1db53e597a61 100644 --- a/drivers/net/ipa/ipa_dma_private.h +++ b/drivers/net/ipa/ipa_dma_private.h @@ -16,6 +16,8 @@ struct ipa_channel; #define GSI_RING_ELEMENT_SIZE 16 /* bytes; must be a power of 2 */ +void gsi_trans_commit(struct ipa_trans *trans, bool ring_db); + /* Return the entry that follows one provided in a transaction pool */ void *ipa_trans_pool_next(struct ipa_trans_pool *pool, void *element); diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c index ba06e3ad554c..ea6c4347f2c6 100644 --- a/drivers/net/ipa/ipa_main.c +++ b/drivers/net/ipa/ipa_main.c @@ -60,12 +60,15 @@ * core. The GSI implements a set of "channels" used for communication * between the AP and the IPA. * - * The IPA layer uses GSI channels to implement its "endpoints". And while - * a GSI channel carries data between the AP and the IPA, a pair of IPA - * endpoints is used to carry traffic between two EEs. Specifically, the main - * modem network interface is implemented by two pairs of endpoints: a TX + * The IPA layer uses GSI channels or BAM pipes to implement its "endpoints". + * And while a GSI channel carries data between the AP and the IPA, a pair of + * IPA endpoints is used to carry traffic between two EEs. Specifically, the + * main modem network interface is implemented by two pairs of endpoints: a TX * endpoint on the AP coupled with an RX endpoint on the modem; and another * RX endpoint on the AP receiving data from a TX endpoint on the modem. + * + * For BAM based transport, a pair of BAM pipes are used for TX and RX between + * the AP and IPA, and between IPA and other EEs. */ /* The name of the GSI firmware file relative to /lib/firmware */ @@ -716,8 +719,13 @@ static int ipa_probe(struct platform_device *pdev) if (ret) goto err_reg_exit; - ret = gsi_init(&ipa->dma_subsys, pdev, ipa->version, data->endpoint_count, - data->endpoint_data); + if (IPA_HAS_GSI(ipa->version)) + ret = gsi_init(&ipa->dma_subsys, pdev, ipa->version, data->endpoint_count, + data->endpoint_data); + else + ret = bam_init(&ipa->dma_subsys, pdev, ipa->version, data->endpoint_count, + data->endpoint_data); + if (ret) goto err_mem_exit; diff --git a/drivers/net/ipa/ipa_trans.c b/drivers/net/ipa/ipa_trans.c index 22755f3ce3da..444f44846da8 100644 --- a/drivers/net/ipa/ipa_trans.c +++ b/drivers/net/ipa/ipa_trans.c @@ -254,7 +254,7 @@ struct ipa_trans *ipa_channel_trans_complete(struct ipa_channel *channel) } /* Move a transaction from the allocated list to the pending list */ -static void ipa_trans_move_pending(struct ipa_trans *trans) +void ipa_trans_move_pending(struct ipa_trans *trans) { struct ipa_channel *channel = &trans->dma_subsys->channel[trans->channel_id]; struct ipa_trans_info *trans_info = &channel->trans_info; @@ -539,7 +539,7 @@ static void gsi_trans_tre_fill(struct gsi_tre *dest_tre, dma_addr_t addr, * pending list. Finally, updates the channel ring pointer and optionally * rings the doorbell. */ -static void __gsi_trans_commit(struct ipa_trans *trans, bool ring_db) +void gsi_trans_commit(struct ipa_trans *trans, bool ring_db) { struct ipa_channel *channel = &trans->dma_subsys->channel[trans->channel_id]; struct gsi_ring *ring = &channel->tre_ring; @@ -604,9 +604,9 @@ static void __gsi_trans_commit(struct ipa_trans *trans, bool ring_db) /* Commit a GSI transaction */ void ipa_trans_commit(struct ipa_trans *trans, bool ring_db) { - if (trans->used) - __gsi_trans_commit(trans, ring_db); - else + if (trans->used) { + trans->dma_subsys->trans_commit(trans, ring_db); + } else ipa_trans_free(trans); } @@ -618,7 +618,7 @@ void ipa_trans_commit_wait(struct ipa_trans *trans) refcount_inc(&trans->refcount); - __gsi_trans_commit(trans, true); + trans->dma_subsys->trans_commit(trans, true); wait_for_completion(&trans->completion); @@ -638,7 +638,7 @@ int ipa_trans_commit_wait_timeout(struct ipa_trans *trans, refcount_inc(&trans->refcount); - __gsi_trans_commit(trans, true); + trans->dma_subsys->trans_commit(trans, true); remaining = wait_for_completion_timeout(&trans->completion, timeout_jiffies); diff --git a/drivers/net/ipa/ipa_trans.h b/drivers/net/ipa/ipa_trans.h index b93342414360..5f41e3e6f92a 100644 --- a/drivers/net/ipa/ipa_trans.h +++ b/drivers/net/ipa/ipa_trans.h @@ -10,6 +10,7 @@ #include #include #include +#include #include "ipa_cmd.h" @@ -61,6 +62,7 @@ struct ipa_trans { struct scatterlist *sgl; struct ipa_cmd_info *info; /* array of entries, or null */ enum dma_data_direction direction; + dma_cookie_t cookie; refcount_t refcount; struct completion completion; @@ -149,6 +151,8 @@ struct ipa_trans *ipa_channel_trans_alloc(struct ipa_dma *dma_subsys, u32 channe */ void ipa_trans_free(struct ipa_trans *trans); +void ipa_trans_move_pending(struct ipa_trans *trans); + /** * ipa_trans_cmd_add() - Add an immediate command to a transaction * @trans: Transaction From patchwork Mon Sep 20 03:08:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sireesh Kodali X-Patchwork-Id: 12504549 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A425C433EF for ; Mon, 20 Sep 2021 03:10:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2328E60FBF for ; Mon, 20 Sep 2021 03:10:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232491AbhITDLb (ORCPT ); Sun, 19 Sep 2021 23:11:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229626AbhITDLE (ORCPT ); Sun, 19 Sep 2021 23:11:04 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08AA9C061768; Sun, 19 Sep 2021 20:09:38 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id dw14so10966260pjb.1; Sun, 19 Sep 2021 20:09:38 -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=1caHAiJ9SxiolMVo0tDpQwItydCr3WRycqpH8grWAvs=; b=SG1WCJjIYx5CgeOV37IkvD5hfwHFlZyr/EdHK+hXme/IZ/G1gXh01tcu8UJfsRpxKO +Smks0Mh4LCPZLSB5LXCwsyn59P7QeqBMZkaT6fs5dpHo+ti7gV5cUoOO/hjl3hXJwRi 15USqzIC0SH2l2IEXohBg18hh0EjLm2BJ3iE79OUKvG6gswmI1KxJ/2pKb09QgY9V8eL 7W93FUDGxw/2W5yrRFpidrR1J9rkfsTfC38SThA80ZOtH+v97oBBOGYkUmulYn0bYbDR aonAREKGVWMv/pKeQXrxD5N+Up2cHTdHDMOpjcA5OoFOt22L2zunHvpMAZzoFxp1qNNa kjEw== 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=1caHAiJ9SxiolMVo0tDpQwItydCr3WRycqpH8grWAvs=; b=137AoyY++iKgGuTS55jM2fPzZo6Uc7+0pIx4h4CcVJ2Gz5F4K+5je6wEfqy8X5t723 ZK5rNK7ed03IfxdLhEBMujkB/ByX5dnS7FYXFeZlnBppAOCseVoV8InwWNvDSWWnjEQE hTh+qlyfBA4YZAO8l7DplECFsfkg8tvhjwQ2hC9SMXigu/0axdhHcfO+g9RYUkishWVo 0oMHixi/GPcckhNuktrtYOUiGmD3+2PArJfDWo28d8OoYw3guiY8LLqrsU82p3r+W1Fn m9yYOUYZhNbyEj1+7VgfdYKaLSutMQ/GIp5YIVUJsLS880Jg2n1I0HO73wylP9sFUJp4 Rm7Q== X-Gm-Message-State: AOAM532z3Tc/J5koKgIgGhokb8upa0Tb4K5abBGxB7ECli/6w+XA/trp Vj8t1y6iXFvA1IsQGSlkMXQfIfeiA3AIY5iu X-Google-Smtp-Source: ABdhPJyx8h8DuqcbdwHt0aV+2Faq4NsLFWjTzvIx6lMZuJVs6YE53hB73M3B8FVsG+hiyl1Oiq+cFQ== X-Received: by 2002:a17:90a:4097:: with SMTP id l23mr24844136pjg.37.1632107377132; Sun, 19 Sep 2021 20:09:37 -0700 (PDT) Received: from skynet-linux.local ([106.201.127.154]) by smtp.googlemail.com with ESMTPSA id l11sm16295065pjg.22.2021.09.19.20.09.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Sep 2021 20:09:36 -0700 (PDT) From: Sireesh Kodali To: phone-devel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, elder@kernel.org Cc: Sireesh Kodali , Vladimir Lypak , "David S. Miller" , Jakub Kicinski Subject: [PATCH 10/17] net: ipa: Add support for IPA v2.x commands and table init Date: Mon, 20 Sep 2021 08:38:04 +0530 Message-Id: <20210920030811.57273-11-sireeshkodali1@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920030811.57273-1-sireeshkodali1@gmail.com> References: <20210920030811.57273-1-sireeshkodali1@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org IPA v2.x commands are different from later IPA revisions mostly because of the fact that IPA v2.x is 32 bit. There are also other minor differences some of the command structs. The tables again are only different because of the fact that IPA v2.x is 32 bit. Signed-off-by: Sireesh Kodali Signed-off-by: Vladimir Lypak --- drivers/net/ipa/ipa.h | 2 +- drivers/net/ipa/ipa_cmd.c | 138 ++++++++++++++++++++++++++---------- drivers/net/ipa/ipa_table.c | 29 ++++++-- drivers/net/ipa/ipa_table.h | 2 +- 4 files changed, 125 insertions(+), 46 deletions(-) diff --git a/drivers/net/ipa/ipa.h b/drivers/net/ipa/ipa.h index 80a83ac45729..63b2b368b588 100644 --- a/drivers/net/ipa/ipa.h +++ b/drivers/net/ipa/ipa.h @@ -81,7 +81,7 @@ struct ipa { struct ipa_power *power; dma_addr_t table_addr; - __le64 *table_virt; + void *table_virt; struct ipa_interrupt *interrupt; bool uc_powered; diff --git a/drivers/net/ipa/ipa_cmd.c b/drivers/net/ipa/ipa_cmd.c index 7a104540dc26..58dae4b3bf87 100644 --- a/drivers/net/ipa/ipa_cmd.c +++ b/drivers/net/ipa/ipa_cmd.c @@ -25,8 +25,8 @@ * An immediate command is generally used to request the IPA do something * other than data transfer to another endpoint. * - * Immediate commands are represented by GSI transactions just like other - * transfer requests, represented by a single GSI TRE. Each immediate + * Immediate commands on IPA v3 are represented by GSI transactions just like + * other transfer requests, represented by a single GSI TRE. Each immediate * command has a well-defined format, having a payload of a known length. * This allows the transfer element's length field to be used to hold an * immediate command's opcode. The payload for a command resides in DRAM @@ -45,10 +45,16 @@ enum pipeline_clear_options { /* IPA_CMD_IP_V{4,6}_{FILTER,ROUTING}_INIT */ -struct ipa_cmd_hw_ip_fltrt_init { - __le64 hash_rules_addr; - __le64 flags; - __le64 nhash_rules_addr; +union ipa_cmd_hw_ip_fltrt_init { + struct { + __le32 nhash_rules_addr; + __le32 flags; + } v2; + struct { + __le64 hash_rules_addr; + __le64 flags; + __le64 nhash_rules_addr; + } v3; }; /* Field masks for ipa_cmd_hw_ip_fltrt_init structure fields */ @@ -56,13 +62,23 @@ struct ipa_cmd_hw_ip_fltrt_init { #define IP_FLTRT_FLAGS_HASH_ADDR_FMASK GENMASK_ULL(27, 12) #define IP_FLTRT_FLAGS_NHASH_SIZE_FMASK GENMASK_ULL(39, 28) #define IP_FLTRT_FLAGS_NHASH_ADDR_FMASK GENMASK_ULL(55, 40) +#define IP_V2_IPV4_FLTRT_FLAGS_SIZE_FMASK GENMASK_ULL(11, 0) +#define IP_V2_IPV4_FLTRT_FLAGS_ADDR_FMASK GENMASK_ULL(27, 12) +#define IP_V2_IPV6_FLTRT_FLAGS_SIZE_FMASK GENMASK_ULL(15, 0) +#define IP_V2_IPV6_FLTRT_FLAGS_ADDR_FMASK GENMASK_ULL(31, 16) /* IPA_CMD_HDR_INIT_LOCAL */ -struct ipa_cmd_hw_hdr_init_local { - __le64 hdr_table_addr; - __le32 flags; - __le32 reserved; +union ipa_cmd_hw_hdr_init_local { + struct { + __le32 hdr_table_addr; + __le32 flags; + } v2; + struct { + __le64 hdr_table_addr; + __le32 flags; + __le32 reserved; + } v3; }; /* Field masks for ipa_cmd_hw_hdr_init_local structure fields */ @@ -109,14 +125,37 @@ struct ipa_cmd_ip_packet_init { #define DMA_SHARED_MEM_OPCODE_SKIP_CLEAR_FMASK GENMASK(8, 8) #define DMA_SHARED_MEM_OPCODE_CLEAR_OPTION_FMASK GENMASK(10, 9) -struct ipa_cmd_hw_dma_mem_mem { - __le16 clear_after_read; /* 0 or DMA_SHARED_MEM_CLEAR_AFTER_READ */ - __le16 size; - __le16 local_addr; - __le16 flags; - __le64 system_addr; +union ipa_cmd_hw_dma_mem_mem { + struct { + __le16 reserved; + __le16 size; + __le32 system_addr; + __le16 local_addr; + __le16 flags; /* the least significant 14 bits are reserved */ + __le32 padding; + } v2; + struct { + __le16 clear_after_read; /* 0 or DMA_SHARED_MEM_CLEAR_AFTER_READ */ + __le16 size; + __le16 local_addr; + __le16 flags; + __le64 system_addr; + } v3; }; +#define CMD_FIELD(_version, _payload, _field) \ + *(((_version) > IPA_VERSION_2_6L) ? \ + &(_payload->v3._field) : \ + &(_payload->v2._field)) + +#define SET_DMA_FIELD(_ver, _payload, _field, _value) \ + do { \ + if ((_ver) >= IPA_VERSION_3_0) \ + (_payload)->v3._field = cpu_to_le64(_value); \ + else \ + (_payload)->v2._field = cpu_to_le32(_value); \ + } while (0) + /* Flag allowing atomic clear of target region after reading data (v4.0+)*/ #define DMA_SHARED_MEM_CLEAR_AFTER_READ GENMASK(15, 15) @@ -132,15 +171,16 @@ struct ipa_cmd_ip_packet_tag_status { __le64 tag; }; -#define IP_PACKET_TAG_STATUS_TAG_FMASK GENMASK_ULL(63, 16) +#define IPA_V2_IP_PACKET_TAG_STATUS_TAG_FMASK GENMASK_ULL(63, 32) +#define IPA_V3_IP_PACKET_TAG_STATUS_TAG_FMASK GENMASK_ULL(63, 16) /* Immediate command payload */ union ipa_cmd_payload { - struct ipa_cmd_hw_ip_fltrt_init table_init; - struct ipa_cmd_hw_hdr_init_local hdr_init_local; + union ipa_cmd_hw_ip_fltrt_init table_init; + union ipa_cmd_hw_hdr_init_local hdr_init_local; struct ipa_cmd_register_write register_write; struct ipa_cmd_ip_packet_init ip_packet_init; - struct ipa_cmd_hw_dma_mem_mem dma_shared_mem; + union ipa_cmd_hw_dma_mem_mem dma_shared_mem; struct ipa_cmd_ip_packet_tag_status ip_packet_tag_status; }; @@ -154,6 +194,7 @@ static void ipa_cmd_validate_build(void) * of entries. */ #define TABLE_SIZE (TABLE_COUNT_MAX * sizeof(__le64)) +// TODO #define TABLE_COUNT_MAX max_t(u32, IPA_ROUTE_COUNT_MAX, IPA_FILTER_COUNT_MAX) BUILD_BUG_ON(TABLE_SIZE > field_max(IP_FLTRT_FLAGS_HASH_SIZE_FMASK)); BUILD_BUG_ON(TABLE_SIZE > field_max(IP_FLTRT_FLAGS_NHASH_SIZE_FMASK)); @@ -405,15 +446,26 @@ void ipa_cmd_table_init_add(struct ipa_trans *trans, { struct ipa *ipa = container_of(trans->dma_subsys, struct ipa, dma_subsys); enum dma_data_direction direction = DMA_TO_DEVICE; - struct ipa_cmd_hw_ip_fltrt_init *payload; + union ipa_cmd_hw_ip_fltrt_init *payload; + enum ipa_version version = ipa->version; union ipa_cmd_payload *cmd_payload; dma_addr_t payload_addr; u64 val; /* Record the non-hash table offset and size */ offset += ipa->mem_offset; - val = u64_encode_bits(offset, IP_FLTRT_FLAGS_NHASH_ADDR_FMASK); - val |= u64_encode_bits(size, IP_FLTRT_FLAGS_NHASH_SIZE_FMASK); + + if (version >= IPA_VERSION_3_0) { + val = u64_encode_bits(offset, IP_FLTRT_FLAGS_NHASH_ADDR_FMASK); + val |= u64_encode_bits(size, IP_FLTRT_FLAGS_NHASH_SIZE_FMASK); + } else if (opcode == IPA_CMD_IP_V4_FILTER_INIT || + opcode == IPA_CMD_IP_V4_ROUTING_INIT) { + val = u64_encode_bits(offset, IP_V2_IPV4_FLTRT_FLAGS_ADDR_FMASK); + val |= u64_encode_bits(size, IP_V2_IPV4_FLTRT_FLAGS_SIZE_FMASK); + } else { /* IPA <= v2.6L IPv6 */ + val = u64_encode_bits(offset, IP_V2_IPV6_FLTRT_FLAGS_ADDR_FMASK); + val |= u64_encode_bits(size, IP_V2_IPV6_FLTRT_FLAGS_SIZE_FMASK); + } /* The hash table offset and address are zero if its size is 0 */ if (hash_size) { @@ -429,10 +481,10 @@ void ipa_cmd_table_init_add(struct ipa_trans *trans, payload = &cmd_payload->table_init; /* Fill in all offsets and sizes and the non-hash table address */ - if (hash_size) - payload->hash_rules_addr = cpu_to_le64(hash_addr); - payload->flags = cpu_to_le64(val); - payload->nhash_rules_addr = cpu_to_le64(addr); + if (hash_size && version >= IPA_VERSION_3_0) + payload->v3.hash_rules_addr = cpu_to_le64(hash_addr); + SET_DMA_FIELD(version, payload, flags, val); + SET_DMA_FIELD(version, payload, nhash_rules_addr, addr); ipa_trans_cmd_add(trans, payload, sizeof(*payload), payload_addr, direction, opcode); @@ -445,7 +497,7 @@ void ipa_cmd_hdr_init_local_add(struct ipa_trans *trans, u32 offset, u16 size, struct ipa *ipa = container_of(trans->dma_subsys, struct ipa, dma_subsys); enum ipa_cmd_opcode opcode = IPA_CMD_HDR_INIT_LOCAL; enum dma_data_direction direction = DMA_TO_DEVICE; - struct ipa_cmd_hw_hdr_init_local *payload; + union ipa_cmd_hw_hdr_init_local *payload; union ipa_cmd_payload *cmd_payload; dma_addr_t payload_addr; u32 flags; @@ -460,10 +512,10 @@ void ipa_cmd_hdr_init_local_add(struct ipa_trans *trans, u32 offset, u16 size, cmd_payload = ipa_cmd_payload_alloc(ipa, &payload_addr); payload = &cmd_payload->hdr_init_local; - payload->hdr_table_addr = cpu_to_le64(addr); + SET_DMA_FIELD(ipa->version, payload, hdr_table_addr, addr); flags = u32_encode_bits(size, HDR_INIT_LOCAL_FLAGS_TABLE_SIZE_FMASK); flags |= u32_encode_bits(offset, HDR_INIT_LOCAL_FLAGS_HDR_ADDR_FMASK); - payload->flags = cpu_to_le32(flags); + CMD_FIELD(ipa->version, payload, flags) = cpu_to_le32(flags); ipa_trans_cmd_add(trans, payload, sizeof(*payload), payload_addr, direction, opcode); @@ -509,8 +561,11 @@ void ipa_cmd_register_write_add(struct ipa_trans *trans, u32 offset, u32 value, } else { flags = 0; /* SKIP_CLEAR flag is always 0 */ - options = u16_encode_bits(clear_option, - REGISTER_WRITE_CLEAR_OPTIONS_FMASK); + if (ipa->version > IPA_VERSION_2_6L) + options = u16_encode_bits(clear_option, + REGISTER_WRITE_CLEAR_OPTIONS_FMASK); + else + options = 0; } cmd_payload = ipa_cmd_payload_alloc(ipa, &payload_addr); @@ -552,7 +607,8 @@ void ipa_cmd_dma_shared_mem_add(struct ipa_trans *trans, u32 offset, u16 size, { struct ipa *ipa = container_of(trans->dma_subsys, struct ipa, dma_subsys); enum ipa_cmd_opcode opcode = IPA_CMD_DMA_SHARED_MEM; - struct ipa_cmd_hw_dma_mem_mem *payload; + enum ipa_version version = ipa->version; + union ipa_cmd_hw_dma_mem_mem *payload; union ipa_cmd_payload *cmd_payload; enum dma_data_direction direction; dma_addr_t payload_addr; @@ -571,8 +627,8 @@ void ipa_cmd_dma_shared_mem_add(struct ipa_trans *trans, u32 offset, u16 size, /* payload->clear_after_read was reserved prior to IPA v4.0. It's * never needed for current code, so it's 0 regardless of version. */ - payload->size = cpu_to_le16(size); - payload->local_addr = cpu_to_le16(offset); + CMD_FIELD(version, payload, size) = cpu_to_le16(size); + CMD_FIELD(version, payload, local_addr) = cpu_to_le16(offset); /* payload->flags: * direction: 0 = write to IPA, 1 read from IPA * Starting at v4.0 these are reserved; either way, all zero: @@ -582,8 +638,8 @@ void ipa_cmd_dma_shared_mem_add(struct ipa_trans *trans, u32 offset, u16 size, * since both values are 0 we won't bother OR'ing them in. */ flags = toward_ipa ? 0 : DMA_SHARED_MEM_FLAGS_DIRECTION_FMASK; - payload->flags = cpu_to_le16(flags); - payload->system_addr = cpu_to_le64(addr); + CMD_FIELD(version, payload, flags) = cpu_to_le16(flags); + SET_DMA_FIELD(version, payload, system_addr, addr); direction = toward_ipa ? DMA_TO_DEVICE : DMA_FROM_DEVICE; @@ -599,11 +655,17 @@ static void ipa_cmd_ip_tag_status_add(struct ipa_trans *trans) struct ipa_cmd_ip_packet_tag_status *payload; union ipa_cmd_payload *cmd_payload; dma_addr_t payload_addr; + u64 tag_mask; + + if (trans->dma_subsys->version <= IPA_VERSION_2_6L) + tag_mask = IPA_V2_IP_PACKET_TAG_STATUS_TAG_FMASK; + else + tag_mask = IPA_V3_IP_PACKET_TAG_STATUS_TAG_FMASK; cmd_payload = ipa_cmd_payload_alloc(ipa, &payload_addr); payload = &cmd_payload->ip_packet_tag_status; - payload->tag = le64_encode_bits(0, IP_PACKET_TAG_STATUS_TAG_FMASK); + payload->tag = le64_encode_bits(0, tag_mask); ipa_trans_cmd_add(trans, payload, sizeof(*payload), payload_addr, direction, opcode); diff --git a/drivers/net/ipa/ipa_table.c b/drivers/net/ipa/ipa_table.c index d197959cc032..459fb4830244 100644 --- a/drivers/net/ipa/ipa_table.c +++ b/drivers/net/ipa/ipa_table.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -561,6 +562,19 @@ void ipa_table_config(struct ipa *ipa) ipa_route_config(ipa, true); } +static inline void *ipa_table_write(enum ipa_version version, + void *virt, u64 value) +{ + if (IPA_IS_64BIT(version)) { + __le64 *ptr = virt; + *ptr = cpu_to_le64(value); + } else { + __le32 *ptr = virt; + *ptr = cpu_to_le32(value); + } + return virt + IPA_TABLE_ENTRY_SIZE(version); +} + /* * Initialize a coherent DMA allocation containing initialized filter and * route table data. This is used when initializing or resetting the IPA @@ -602,10 +616,11 @@ void ipa_table_config(struct ipa *ipa) int ipa_table_init(struct ipa *ipa) { u32 count = max_t(u32, IPA_FILTER_COUNT_MAX, IPA_ROUTE_COUNT_MAX); + enum ipa_version version = ipa->version; struct device *dev = &ipa->pdev->dev; + u64 filter_map = ipa->filter_map << 1; dma_addr_t addr; - __le64 le_addr; - __le64 *virt; + void *virt; size_t size; ipa_table_validate_build(); @@ -626,19 +641,21 @@ int ipa_table_init(struct ipa *ipa) ipa->table_addr = addr; /* First slot is the zero rule */ - *virt++ = 0; + virt = ipa_table_write(version, virt, 0); /* Next is the filter table bitmap. The "soft" bitmap value * must be converted to the hardware representation by shifting * it left one position. (Bit 0 repesents global filtering, * which is possible but not used.) */ - *virt++ = cpu_to_le64((u64)ipa->filter_map << 1); + if (version <= IPA_VERSION_2_6L) + filter_map |= 1; + + virt = ipa_table_write(version, virt, filter_map); /* All the rest contain the DMA address of the zero rule */ - le_addr = cpu_to_le64(addr); while (count--) - *virt++ = le_addr; + virt = ipa_table_write(version, virt, addr); return 0; } diff --git a/drivers/net/ipa/ipa_table.h b/drivers/net/ipa/ipa_table.h index 78a168ce6558..6e12fc49e45b 100644 --- a/drivers/net/ipa/ipa_table.h +++ b/drivers/net/ipa/ipa_table.h @@ -43,7 +43,7 @@ bool ipa_filter_map_valid(struct ipa *ipa, u32 filter_mask); */ static inline bool ipa_table_hash_support(struct ipa *ipa) { - return ipa->version != IPA_VERSION_4_2; + return ipa->version != IPA_VERSION_4_2 && ipa->version > IPA_VERSION_2_6L; } /** From patchwork Mon Sep 20 03:08:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sireesh Kodali X-Patchwork-Id: 12504551 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8B07C433EF for ; Mon, 20 Sep 2021 03:10:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C13E260FC1 for ; Mon, 20 Sep 2021 03:10:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231731AbhITDMH (ORCPT ); Sun, 19 Sep 2021 23:12:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234341AbhITDLI (ORCPT ); Sun, 19 Sep 2021 23:11:08 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED389C0613D9; Sun, 19 Sep 2021 20:09:41 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id v19so10965134pjh.2; Sun, 19 Sep 2021 20:09:41 -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=Nx+Keww1ap7Q1GT99LR3K8AXWY7zLOL5OTsLA8UhvOM=; b=O7Pg5+Mj9+CJJEgeLJsP3vOjvtY5TlgsmPyvFP8OPYAe+E4o9WweXxU8K/q23Au5H4 K2ltUojHHp3H+nd05fkJGeBG22nVGiGvttsPPVBmDYnQwGCJHzHWq76H28LZyA0GNpvJ yqDPzQ6ezXfEj/d1jya5xt1hvehmL7rv/p2kPVDz1CTWFJ/kdftMJTnI06vtqcFUX9A/ N+AdFnC50JCXa6gm3bJtkT2usqJSd0zSNYB0aGdOf86YHK0motu48FnvxIBFEA6Laoit NSL9DMrIc/NrpQqiOUcdeCvP0XZgwhpsmeEshYGfgStP6vrwNYgitJlGIwkxXIq9U5Ct 6KZQ== 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=Nx+Keww1ap7Q1GT99LR3K8AXWY7zLOL5OTsLA8UhvOM=; b=arAujoHtzJFJQtW9gprzhah22B0AFHhvHui8E/upe64AaZCkyby9nongVb2TpDIV9q bCHn7IuGtDHdqwFH0nhg27mIUrOrXp7ewt3dfAQIySqPNqvxY1GxtJNatVhzOBuFCP9O Qk8aB8cBYFZ2W6eB0gYP6YtCIBySlANvYesNcFMlP5gKyzoVO5VonLlnINj3qsZFj3im 2xp5DZrYP4LBcuCXz6Bhy3PG9T/PJbSwzFOvh/uMrcJ35zGrY5+gx6QAP4az/268JyJi cDPiobR9oXdyE/L8RNdLSJ7gQrc8bAslmuhS064oMdmo09/urrGKp3I6KAFyAtXa62WK E6Tw== X-Gm-Message-State: AOAM532gNd/CYGkq8goAwoD/hF43GHkWAp4RD0Ht9VsEoNj85IV5SihF 2IspWdL4FGn5czOj2yi8SpU3xrUi3USxyvB8 X-Google-Smtp-Source: ABdhPJy7IKYgQd4ifNlNe5I7EgNBFHYZ2Mab5RFIe0QFow3MNwK8FXS48sQ+KrrjiN2sjKIqs5ifhA== X-Received: by 2002:a17:902:e153:b0:13b:63ba:7292 with SMTP id d19-20020a170902e15300b0013b63ba7292mr20776133pla.17.1632107381200; Sun, 19 Sep 2021 20:09:41 -0700 (PDT) Received: from skynet-linux.local ([106.201.127.154]) by smtp.googlemail.com with ESMTPSA id l11sm16295065pjg.22.2021.09.19.20.09.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Sep 2021 20:09:40 -0700 (PDT) From: Sireesh Kodali To: phone-devel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, elder@kernel.org Cc: Sireesh Kodali , "David S. Miller" , Jakub Kicinski Subject: [RFC PATCH 11/17] net: ipa: Add support for IPA v2.x endpoints Date: Mon, 20 Sep 2021 08:38:05 +0530 Message-Id: <20210920030811.57273-12-sireeshkodali1@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920030811.57273-1-sireeshkodali1@gmail.com> References: <20210920030811.57273-1-sireeshkodali1@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org IPA v2.x endpoints are the same as the endpoints on later versions. The only big change was the addition of the "skip_config" flag. The only other change is the backlog limit, which is a fixed number for IPA v2.6L Signed-off-by: Sireesh Kodali --- drivers/net/ipa/ipa_endpoint.c | 65 ++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 22 deletions(-) diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index 7d3ab61cd890..024cf3a0ded0 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -360,8 +360,10 @@ void ipa_endpoint_modem_pause_all(struct ipa *ipa, bool enable) { u32 endpoint_id; - /* DELAY mode doesn't work correctly on IPA v4.2 */ - if (ipa->version == IPA_VERSION_4_2) + /* DELAY mode doesn't work correctly on IPA v4.2 + * Pausing is not supported on IPA v2.6L + */ + if (ipa->version == IPA_VERSION_4_2 || ipa->version <= IPA_VERSION_2_6L) return; for (endpoint_id = 0; endpoint_id < IPA_ENDPOINT_MAX; endpoint_id++) { @@ -383,6 +385,7 @@ int ipa_endpoint_modem_exception_reset_all(struct ipa *ipa) { u32 initialized = ipa->initialized; struct ipa_trans *trans; + u32 value = 0, value_mask = ~0; u32 count; /* We need one command per modem TX endpoint. We can get an upper @@ -398,6 +401,11 @@ int ipa_endpoint_modem_exception_reset_all(struct ipa *ipa) return -EBUSY; } + if (ipa->version <= IPA_VERSION_2_6L) { + value = aggr_force_close_fmask(true); + value_mask = aggr_force_close_fmask(true); + } + while (initialized) { u32 endpoint_id = __ffs(initialized); struct ipa_endpoint *endpoint; @@ -416,7 +424,7 @@ int ipa_endpoint_modem_exception_reset_all(struct ipa *ipa) * means status is disabled on the endpoint, and as a * result all other fields in the register are ignored. */ - ipa_cmd_register_write_add(trans, offset, 0, ~0, false); + ipa_cmd_register_write_add(trans, offset, value, value_mask, false); } ipa_cmd_pipeline_clear_add(trans); @@ -1531,8 +1539,10 @@ static void ipa_endpoint_program(struct ipa_endpoint *endpoint) ipa_endpoint_init_mode(endpoint); ipa_endpoint_init_aggr(endpoint); ipa_endpoint_init_deaggr(endpoint); - ipa_endpoint_init_rsrc_grp(endpoint); - ipa_endpoint_init_seq(endpoint); + if (endpoint->ipa->version > IPA_VERSION_2_6L) { + ipa_endpoint_init_rsrc_grp(endpoint); + ipa_endpoint_init_seq(endpoint); + } ipa_endpoint_status(endpoint); } @@ -1592,7 +1602,6 @@ void ipa_endpoint_suspend_one(struct ipa_endpoint *endpoint) { struct device *dev = &endpoint->ipa->pdev->dev; struct ipa_dma *gsi = &endpoint->ipa->dma_subsys; - bool stop_channel; int ret; if (!(endpoint->ipa->enabled & BIT(endpoint->endpoint_id))) @@ -1613,7 +1622,6 @@ void ipa_endpoint_resume_one(struct ipa_endpoint *endpoint) { struct device *dev = &endpoint->ipa->pdev->dev; struct ipa_dma *gsi = &endpoint->ipa->dma_subsys; - bool start_channel; int ret; if (!(endpoint->ipa->enabled & BIT(endpoint->endpoint_id))) @@ -1750,23 +1758,33 @@ int ipa_endpoint_config(struct ipa *ipa) /* Find out about the endpoints supplied by the hardware, and ensure * the highest one doesn't exceed the number we support. */ - val = ioread32(ipa->reg_virt + IPA_REG_FLAVOR_0_OFFSET); - - /* Our RX is an IPA producer */ - rx_base = u32_get_bits(val, IPA_PROD_LOWEST_FMASK); - max = rx_base + u32_get_bits(val, IPA_MAX_PROD_PIPES_FMASK); - if (max > IPA_ENDPOINT_MAX) { - dev_err(dev, "too many endpoints (%u > %u)\n", - max, IPA_ENDPOINT_MAX); - return -EINVAL; - } - rx_mask = GENMASK(max - 1, rx_base); + if (ipa->version <= IPA_VERSION_2_6L) { + // FIXME Not used anywhere? + if (ipa->version == IPA_VERSION_2_6L) + val = ioread32(ipa->reg_virt + + IPA_REG_V2_ENABLED_PIPES_OFFSET); + /* IPA v2.6L supports 20 pipes */ + ipa->available = ipa->filter_map; + return 0; + } else { + val = ioread32(ipa->reg_virt + IPA_REG_FLAVOR_0_OFFSET); + + /* Our RX is an IPA producer */ + rx_base = u32_get_bits(val, IPA_PROD_LOWEST_FMASK); + max = rx_base + u32_get_bits(val, IPA_MAX_PROD_PIPES_FMASK); + if (max > IPA_ENDPOINT_MAX) { + dev_err(dev, "too many endpoints (%u > %u)\n", + max, IPA_ENDPOINT_MAX); + return -EINVAL; + } + rx_mask = GENMASK(max - 1, rx_base); - /* Our TX is an IPA consumer */ - max = u32_get_bits(val, IPA_MAX_CONS_PIPES_FMASK); - tx_mask = GENMASK(max - 1, 0); + /* Our TX is an IPA consumer */ + max = u32_get_bits(val, IPA_MAX_CONS_PIPES_FMASK); + tx_mask = GENMASK(max - 1, 0); - ipa->available = rx_mask | tx_mask; + ipa->available = rx_mask | tx_mask; + } /* Check for initialized endpoints not supported by the hardware */ if (ipa->initialized & ~ipa->available) { @@ -1865,6 +1883,9 @@ u32 ipa_endpoint_init(struct ipa *ipa, u32 count, filter_map |= BIT(data->endpoint_id); } + if (ipa->version <= IPA_VERSION_2_6L) + filter_map = 0x1fffff; + if (!ipa_filter_map_valid(ipa, filter_map)) goto err_endpoint_exit; From patchwork Mon Sep 20 03:08:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sireesh Kodali X-Patchwork-Id: 12504553 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA6C6C433EF for ; Mon, 20 Sep 2021 03:10:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9509961019 for ; Mon, 20 Sep 2021 03:10:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234554AbhITDML (ORCPT ); Sun, 19 Sep 2021 23:12:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234626AbhITDLM (ORCPT ); Sun, 19 Sep 2021 23:11:12 -0400 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0475EC061760; Sun, 19 Sep 2021 20:09:46 -0700 (PDT) Received: by mail-pg1-x536.google.com with SMTP id s11so15907852pgr.11; Sun, 19 Sep 2021 20:09:46 -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=7bDxZYlLAqGmaBzkkRsMvzIqKDwv3GsHECyBJPCm0Ds=; b=MLs12fOeQHD/Ee1ST0MDGakbpGAGOjRJFbwTzkGzZ6QHzBkPypkoACG6amUriG/DDP Nnw5bOPTsbkJCNRJKS9UC4ZMzlO7lVJbJKuHjdPJOmWwo/l2W92x2nE3pdpsv05oCeAL NCP7F6fgOKA5P86dlbMBFV8BBDkgXbloT4ciyYwSpuzg4tvTEh0YOcE73Tcqg1eLNeLO s7qIhOOo/WZm2qmolljkIVSROsHm7g9aPCEtNSJ7OjGJF5fPPe4qhBKtJvxHW2yJyOYQ u8lzF+sgJt1FAboehTRLwUVSaeDHNZLGpLoVFtvb0dH1o4pI4Cc0RKKg9zBQXee5gb2I B7IQ== 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=7bDxZYlLAqGmaBzkkRsMvzIqKDwv3GsHECyBJPCm0Ds=; b=NIQVuRQsYKbVCyXz3DR6k9gZ8sr9xUqLjk5k1pHVX5xH70kOZHBu5/SZEy3BcX8EfI dnCEZnEveppSBCbmnM8mWLuRnQBs5vA9Ri/iqXBmYi/A/i5W7mjzBcKFexeoyKdPC1EZ BxZUOD92Kff+ZWlfnoCiEn6mus9b3aGyzHSrxVov/OEHA6aQ682dqEkxU34EQpUmR1Ma 062hkC1F6GYFyPXT+IdcHe5IEvQ2Lv1HnjFZhrMX6jaaN25oeUvkqKXUQtuZRjjZgmes Ctypp/5LIJyc+WasD/f2DwTgI5O/gSSt2llL2Z47OS/yVcJol+lk0EoCrWLudjB8+OAv pzng== X-Gm-Message-State: AOAM532daFNWHT+Onna4iCM76hrza5tK6p/UJe5WxVx25nLXylAEcu3u A1ZRZjBwqWE+5y1EyHQFhUmhVGCOJh6IYQx2 X-Google-Smtp-Source: ABdhPJzFSwgSnCsH+xzF6nAco18Uzjqg/G2BtyFgPaTDYFrUrsj0x81Ev+YekR1gcNL/uUecuT8fjg== X-Received: by 2002:a62:750e:0:b0:446:d467:3620 with SMTP id q14-20020a62750e000000b00446d4673620mr9320885pfc.80.1632107385247; Sun, 19 Sep 2021 20:09:45 -0700 (PDT) Received: from skynet-linux.local ([106.201.127.154]) by smtp.googlemail.com with ESMTPSA id l11sm16295065pjg.22.2021.09.19.20.09.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Sep 2021 20:09:44 -0700 (PDT) From: Sireesh Kodali To: phone-devel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, elder@kernel.org Cc: Sireesh Kodali , "David S. Miller" , Jakub Kicinski Subject: [RFC PATCH 12/17] net: ipa: Add support for IPA v2.x memory map Date: Mon, 20 Sep 2021 08:38:06 +0530 Message-Id: <20210920030811.57273-13-sireeshkodali1@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920030811.57273-1-sireeshkodali1@gmail.com> References: <20210920030811.57273-1-sireeshkodali1@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org IPA v2.6L has an extra region to handle compression/decompression acceleration. This region is used by some modems during modem init. Signed-off-by: Sireesh Kodali --- drivers/net/ipa/ipa_mem.c | 36 ++++++++++++++++++++++++++++++------ drivers/net/ipa/ipa_mem.h | 5 ++++- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/drivers/net/ipa/ipa_mem.c b/drivers/net/ipa/ipa_mem.c index 8acc88070a6f..bfcdc7e08de2 100644 --- a/drivers/net/ipa/ipa_mem.c +++ b/drivers/net/ipa/ipa_mem.c @@ -84,7 +84,7 @@ int ipa_mem_setup(struct ipa *ipa) /* Get a transaction to define the header memory region and to zero * the processing context and modem memory regions. */ - trans = ipa_cmd_trans_alloc(ipa, 4); + trans = ipa_cmd_trans_alloc(ipa, 5); if (!trans) { dev_err(&ipa->pdev->dev, "no transaction for memory setup\n"); return -EBUSY; @@ -107,8 +107,14 @@ int ipa_mem_setup(struct ipa *ipa) ipa_mem_zero_region_add(trans, IPA_MEM_AP_PROC_CTX); ipa_mem_zero_region_add(trans, IPA_MEM_MODEM); + ipa_mem_zero_region_add(trans, IPA_MEM_ZIP); + ipa_trans_commit_wait(trans); + /* On IPA version <=2.6L (except 2.5) there is no PROC_CTX. */ + if (ipa->version != IPA_VERSION_2_5 && ipa->version <= IPA_VERSION_2_6L) + return 0; + /* Tell the hardware where the processing context area is located */ mem = ipa_mem_find(ipa, IPA_MEM_MODEM_PROC_CTX); offset = ipa->mem_offset + mem->offset; @@ -147,6 +153,11 @@ static bool ipa_mem_id_valid(struct ipa *ipa, enum ipa_mem_id mem_id) case IPA_MEM_END_MARKER: /* pseudo region */ break; + case IPA_MEM_ZIP: + if (version == IPA_VERSION_2_6L) + return true; + break; + case IPA_MEM_STATS_TETHERING: case IPA_MEM_STATS_DROP: if (version < IPA_VERSION_4_0) @@ -319,10 +330,15 @@ int ipa_mem_config(struct ipa *ipa) /* Check the advertised location and size of the shared memory area */ val = ioread32(ipa->reg_virt + ipa_reg_shared_mem_size_offset(ipa->version)); - /* The fields in the register are in 8 byte units */ - ipa->mem_offset = 8 * u32_get_bits(val, SHARED_MEM_BADDR_FMASK); - /* Make sure the end is within the region's mapped space */ - mem_size = 8 * u32_get_bits(val, SHARED_MEM_SIZE_FMASK); + if (IPA_VERSION_RANGE(ipa->version, 2_0, 2_6L)) { + /* The fields in the register are in 8 byte units */ + ipa->mem_offset = 8 * u32_get_bits(val, SHARED_MEM_BADDR_FMASK); + /* Make sure the end is within the region's mapped space */ + mem_size = 8 * u32_get_bits(val, SHARED_MEM_SIZE_FMASK); + } else { + ipa->mem_offset = u32_get_bits(val, SHARED_MEM_BADDR_FMASK); + mem_size = u32_get_bits(val, SHARED_MEM_SIZE_FMASK); + } /* If the sizes don't match, issue a warning */ if (ipa->mem_offset + mem_size < ipa->mem_size) { @@ -564,6 +580,10 @@ static int ipa_smem_init(struct ipa *ipa, u32 item, size_t size) return -EINVAL; } + /* IPA v2.6L does not use IOMMU */ + if (ipa->version <= IPA_VERSION_2_6L) + return 0; + domain = iommu_get_domain_for_dev(dev); if (!domain) { dev_err(dev, "no IOMMU domain found for SMEM\n"); @@ -591,6 +611,9 @@ static void ipa_smem_exit(struct ipa *ipa) struct device *dev = &ipa->pdev->dev; struct iommu_domain *domain; + if (ipa->version <= IPA_VERSION_2_6L) + return; + domain = iommu_get_domain_for_dev(dev); if (domain) { size_t size; @@ -622,7 +645,8 @@ int ipa_mem_init(struct ipa *ipa, const struct ipa_mem_data *mem_data) ipa->mem_count = mem_data->local_count; ipa->mem = mem_data->local; - ret = dma_set_mask_and_coherent(&ipa->pdev->dev, DMA_BIT_MASK(64)); + ret = dma_set_mask_and_coherent(&ipa->pdev->dev, IPA_IS_64BIT(ipa->version) ? + DMA_BIT_MASK(64) : DMA_BIT_MASK(32)); if (ret) { dev_err(dev, "error %d setting DMA mask\n", ret); return ret; diff --git a/drivers/net/ipa/ipa_mem.h b/drivers/net/ipa/ipa_mem.h index 570bfdd99bff..be91cb38b6a8 100644 --- a/drivers/net/ipa/ipa_mem.h +++ b/drivers/net/ipa/ipa_mem.h @@ -47,8 +47,10 @@ enum ipa_mem_id { IPA_MEM_UC_INFO, /* 0 canaries */ IPA_MEM_V4_FILTER_HASHED, /* 2 canaries */ IPA_MEM_V4_FILTER, /* 2 canaries */ + IPA_MEM_V4_FILTER_AP, /* 2 canaries (IPA v2.0) */ IPA_MEM_V6_FILTER_HASHED, /* 2 canaries */ IPA_MEM_V6_FILTER, /* 2 canaries */ + IPA_MEM_V6_FILTER_AP, /* 0 canaries (IPA v2.0) */ IPA_MEM_V4_ROUTE_HASHED, /* 2 canaries */ IPA_MEM_V4_ROUTE, /* 2 canaries */ IPA_MEM_V6_ROUTE_HASHED, /* 2 canaries */ @@ -57,7 +59,8 @@ enum ipa_mem_id { IPA_MEM_AP_HEADER, /* 0 canaries, optional */ IPA_MEM_MODEM_PROC_CTX, /* 2 canaries */ IPA_MEM_AP_PROC_CTX, /* 0 canaries */ - IPA_MEM_MODEM, /* 0/2 canaries */ + IPA_MEM_ZIP, /* 1 canary (IPA v2.6L) */ + IPA_MEM_MODEM, /* 0-2 canaries */ IPA_MEM_UC_EVENT_RING, /* 1 canary, optional */ IPA_MEM_PDN_CONFIG, /* 0/2 canaries (IPA v4.0+) */ IPA_MEM_STATS_QUOTA_MODEM, /* 2/4 canaries (IPA v4.0+) */ From patchwork Mon Sep 20 03:08:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sireesh Kodali X-Patchwork-Id: 12504555 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F4D8C433F5 for ; Mon, 20 Sep 2021 03:11:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3538C60FE6 for ; Mon, 20 Sep 2021 03:11:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234721AbhITDM3 (ORCPT ); Sun, 19 Sep 2021 23:12:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230253AbhITDMJ (ORCPT ); Sun, 19 Sep 2021 23:12:09 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0436FC061798; Sun, 19 Sep 2021 20:09:56 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id mv7-20020a17090b198700b0019c843e7233so7876400pjb.4; Sun, 19 Sep 2021 20:09:55 -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=nh3XAp4yGEAFhmmgYKLEpNxgx1mBq+le0G+MOLIox6Y=; b=RiWrRgv+VN1IBSUIUFpqImR8K+4kUQncOKSYTggIGooNriq9Yp/xFGgLpVKooswCcH bAlqZYCKgB5kQ1rYs9m/+nlaeJ+ghBBFn/wNszn/ROxhbnDWIca+uvboClkOWmEl+xTk utDm2RStAhU71zT9jJShWCZCfVhxlHpbOYXw1Kk2QMaDLWE0uvB2Mcit6xoai/dh7rBn pOnL9jk/oVrr7uy11e1LkQ3Z5QseRGkAaBhX6ZgMoRmVt1b68sbJeNLVIZB1gnVkyNs+ VpTzNV/4s9h972DdAmhrTWzpnAjrefLj1zW9Hh12wgQKX9p5Qthl/sRc2O2ae8iSPGTr CEGA== 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=nh3XAp4yGEAFhmmgYKLEpNxgx1mBq+le0G+MOLIox6Y=; b=b/mUmrkHdrqPj8jt+6bAJ0Ngf8InPl2DegSVLX7KSEsVIpxPcHfhFu6pwlm4z4qG5p VZYqpTWcifxRwXS6GsH2AAAjK8g3IqjToJQ64JXJ81qyOuAc1U69fd3h+UbYZ2xIe7Fb fRWYi9FkkbP5HOgS70OeqrJ0vbA6yCHB/8vsXiHoLUydKP+xO9t8P1jrqcSnpPVPlqg0 F2AidL6+BUjMuqucGr9gBWcMyA2FtPmgF7npHQ9IPTQKjgOqD1JR+qOGfwTYcW3SVBwj V1fSkylc7+Ls2wCppleQj5+pJdnGNrlodEA6hGqIA6UqbI1R2Kam1SsY/mg3RbOHXGzh DmtQ== X-Gm-Message-State: AOAM532CaI5W5YSduE3d2XXnbuyB3TZhe4XlCtLfwuoX4OUBKOPUoUzy KkZ2tqgyR7SnOY9CfWQtyxsgk1Km+MWXMa3Q X-Google-Smtp-Source: ABdhPJyfvcG6K8PJI3HqPAwreapMX2Ch2WSIsJscI8py2BOTkMABKsI904Ajs6anf10LfRuH5fy/UQ== X-Received: by 2002:a17:90a:e7ca:: with SMTP id kb10mr35558089pjb.33.1632107395273; Sun, 19 Sep 2021 20:09:55 -0700 (PDT) Received: from skynet-linux.local ([106.201.127.154]) by smtp.googlemail.com with ESMTPSA id l11sm16295065pjg.22.2021.09.19.20.09.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Sep 2021 20:09:54 -0700 (PDT) From: Sireesh Kodali To: phone-devel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, elder@kernel.org Cc: Sireesh Kodali , Vladimir Lypak , "David S. Miller" , Jakub Kicinski Subject: [RFC PATCH 13/17] net: ipa: Add support for IPA v2.x in the driver's QMI interface Date: Mon, 20 Sep 2021 08:38:07 +0530 Message-Id: <20210920030811.57273-14-sireeshkodali1@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920030811.57273-1-sireeshkodali1@gmail.com> References: <20210920030811.57273-1-sireeshkodali1@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org On IPA v2.x, the modem doesn't send a DRIVER_INIT_COMPLETED, so we have to rely on the uc's IPA_UC_RESPONSE_INIT_COMPLETED to know when its ready. We add a function here that marks uc_ready = true. This function is called by ipa_uc.c when IPA_UC_RESPONSE_INIT_COMPLETED is handled. Signed-off-by: Sireesh Kodali Signed-off-by: Vladimir Lypak --- drivers/net/ipa/ipa_qmi.c | 27 ++++++++++++++++++++++++++- drivers/net/ipa/ipa_qmi.h | 10 ++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/drivers/net/ipa/ipa_qmi.c b/drivers/net/ipa/ipa_qmi.c index 7e2fe701cc4d..876e2a004f70 100644 --- a/drivers/net/ipa/ipa_qmi.c +++ b/drivers/net/ipa/ipa_qmi.c @@ -68,6 +68,11 @@ * - The INDICATION_REGISTER request and INIT_COMPLETE indication are * optional for non-initial modem boots, and have no bearing on the * determination of when things are "ready" + * + * Note that on IPA v2.x, the modem doesn't send a DRIVER_INIT_COMPLETE + * request. Thus, we rely on the uc's IPA_UC_RESPONSE_INIT_COMPLETED to know + * when the uc is ready. The rest of the process is the same on IPA v2.x and + * later IPA versions */ #define IPA_HOST_SERVICE_SVC_ID 0x31 @@ -345,7 +350,12 @@ init_modem_driver_req(struct ipa_qmi *ipa_qmi) req.hdr_proc_ctx_tbl_info.start + mem->size - 1; } - /* Nothing to report for the compression table (zip_tbl_info) */ + mem = &ipa->mem[IPA_MEM_ZIP]; + if (mem->size) { + req.zip_tbl_info_valid = 1; + req.zip_tbl_info.start = ipa->mem_offset + mem->offset; + req.zip_tbl_info.end = ipa->mem_offset + mem->size - 1; + } mem = ipa_mem_find(ipa, IPA_MEM_V4_ROUTE_HASHED); if (mem->size) { @@ -525,6 +535,21 @@ int ipa_qmi_setup(struct ipa *ipa) return ret; } +/* With IPA v2 modem is not required to send DRIVER_INIT_COMPLETE request to AP. + * We start operation as soon as IPA_UC_RESPONSE_INIT_COMPLETED irq is triggered. + */ +void ipa_qmi_signal_uc_loaded(struct ipa *ipa) +{ + struct ipa_qmi *ipa_qmi = &ipa->qmi; + + /* This is needed only on IPA 2.x */ + if (ipa->version > IPA_VERSION_2_6L) + return; + + ipa_qmi->uc_ready = true; + ipa_qmi_ready(ipa_qmi); +} + /* Tear down IPA QMI handles */ void ipa_qmi_teardown(struct ipa *ipa) { diff --git a/drivers/net/ipa/ipa_qmi.h b/drivers/net/ipa/ipa_qmi.h index 856ef629ccc8..4962d88b0d22 100644 --- a/drivers/net/ipa/ipa_qmi.h +++ b/drivers/net/ipa/ipa_qmi.h @@ -55,6 +55,16 @@ struct ipa_qmi { */ int ipa_qmi_setup(struct ipa *ipa); +/** + * ipa_qmi_signal_uc_loaded() - Signal that the UC has been loaded + * @ipa: IPA pointer + * + * This is called when the uc indicates that it is ready. This exists, because + * on IPA v2.x, the modem does not send a DRIVER_INIT_COMPLETED. Thus we have + * to rely on the uc's INIT_COMPLETED response to know if it was initialized + */ +void ipa_qmi_signal_uc_loaded(struct ipa *ipa); + /** * ipa_qmi_teardown() - Tear down IPA QMI handles * @ipa: IPA pointer From patchwork Mon Sep 20 03:08:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sireesh Kodali X-Patchwork-Id: 12504557 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18AE9C433EF for ; Mon, 20 Sep 2021 03:11:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0145360FE6 for ; Mon, 20 Sep 2021 03:11:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234920AbhITDMi (ORCPT ); Sun, 19 Sep 2021 23:12:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232462AbhITDM0 (ORCPT ); Sun, 19 Sep 2021 23:12:26 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FC7FC061767; Sun, 19 Sep 2021 20:10:04 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id n2so7493192plk.12; Sun, 19 Sep 2021 20:10:04 -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=qgPrSEvlEz44qzOdjetk3jLjnDR/NPMtis3khQbjPjY=; b=QSU0Fojag+ORRG3vZsdqaZc8z0f7kn3YDKVmf7GVJBICbBnJGPhlHYcpE9jfsdmS57 zVtoE8oG1ptqZijvzKAEVuPDgSvdmJLP6w6tCOAqpSKjnKkdnC9Fq7z6gREktKEt/6fZ FhtcqtSXJLRHYzBvlNmqWIJca7tiuhy5cjESB6GCOaHlLMEX8fYPPqUwPQAruzXc94G2 czf0LFb43WEb3M2JnVj7ZN0BE5u9pBQ1ghf7fjbB60AN1vN5TFveKw3Eyd7DcSKCs1Fh qc0RDBspqK99gopzlZh+X4sY0UK4RW4PIFyejgf/8/8Vcr+mjVitqUpE5cystKvgl60A gYWA== 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=qgPrSEvlEz44qzOdjetk3jLjnDR/NPMtis3khQbjPjY=; b=eP87GlgRjDWkME46UmuXfxV2+EXfHHwujM2KbNFWRfRNAoi0nax7EqQgXCMnx9s8ss 3XfzgXFjK0zAvELPZkNLsd4+6vH6yavoN/QI0jS5+8kbpxNd2T4Po0+SVhrpxtfO32BC uKzMIUsvKGARTOhCWXTLzYEBZ1skerFc+OL9hbRZTvjgOZccq97IeaP9OX6QnAvCT5a4 1O6QHF9L36Ay0ibepdZCAY/G/Pf4vnDm505uY5QixXuHh82BWeIuaJ04ZfOlq3J7Q6n9 WJJ5fXYMnOynRIh9dt3cSv/F1VHzKOtAfXbWJqeYe4QqPxJBF/IRoYr4XE+rgB3pv9sc 4fyw== X-Gm-Message-State: AOAM533V3RYUAPNJ6jX3jaUQm5gNdYyjnP6u3c4+WQfaxbbKdA/ENwMy SrOpN9lnjWuBpfepbLBgzmi7M9+hS2vpISx/ X-Google-Smtp-Source: ABdhPJyqdxzplBi2n4+8amlnCBrq54Kkw0F2rSaSeZG6j6s5T7ppSkVMGWJmHBfZ359tvo1RekSshQ== X-Received: by 2002:a17:902:868c:b0:13c:8ce5:92b3 with SMTP id g12-20020a170902868c00b0013c8ce592b3mr21016732plo.13.1632107403494; Sun, 19 Sep 2021 20:10:03 -0700 (PDT) Received: from skynet-linux.local ([106.201.127.154]) by smtp.googlemail.com with ESMTPSA id l11sm16295065pjg.22.2021.09.19.20.10.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Sep 2021 20:10:03 -0700 (PDT) From: Sireesh Kodali To: phone-devel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, elder@kernel.org Cc: Sireesh Kodali , "David S. Miller" , Jakub Kicinski Subject: [RFC PATCH 14/17] net: ipa: Add support for IPA v2 microcontroller Date: Mon, 20 Sep 2021 08:38:08 +0530 Message-Id: <20210920030811.57273-15-sireeshkodali1@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920030811.57273-1-sireeshkodali1@gmail.com> References: <20210920030811.57273-1-sireeshkodali1@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org There are some minor differences between IPA v2.x and later revisions with regards to the uc. The biggeset difference is the shared memory's layout. There are also some changes to the command numbers, but these are not too important, since the mainline driver doesn't use them. Signed-off-by: Sireesh Kodali --- drivers/net/ipa/ipa_uc.c | 96 ++++++++++++++++++++++++++-------------- 1 file changed, 63 insertions(+), 33 deletions(-) diff --git a/drivers/net/ipa/ipa_uc.c b/drivers/net/ipa/ipa_uc.c index 856e55a080a7..bf6b25098301 100644 --- a/drivers/net/ipa/ipa_uc.c +++ b/drivers/net/ipa/ipa_uc.c @@ -39,11 +39,12 @@ #define IPA_SEND_DELAY 100 /* microseconds */ /** - * struct ipa_uc_mem_area - AP/microcontroller shared memory area + * union ipa_uc_mem_area - AP/microcontroller shared memory area * @command: command code (AP->microcontroller) * @reserved0: reserved bytes; avoid reading or writing * @command_param: low 32 bits of command parameter (AP->microcontroller) * @command_param_hi: high 32 bits of command parameter (AP->microcontroller) + * Available since IPA v3.0 * * @response: response code (microcontroller->AP) * @reserved1: reserved bytes; avoid reading or writing @@ -59,31 +60,58 @@ * @reserved3: reserved bytes; avoid reading or writing * @interface_version: hardware-reported interface version * @reserved4: reserved bytes; avoid reading or writing + * @reserved5: reserved bytes; avoid reading or writing * * A shared memory area at the base of IPA resident memory is used for * communication with the microcontroller. The region is 128 bytes in * size, but only the first 40 bytes (structured this way) are used. */ -struct ipa_uc_mem_area { - u8 command; /* enum ipa_uc_command */ - u8 reserved0[3]; - __le32 command_param; - __le32 command_param_hi; - u8 response; /* enum ipa_uc_response */ - u8 reserved1[3]; - __le32 response_param; - u8 event; /* enum ipa_uc_event */ - u8 reserved2[3]; - - __le32 event_param; - __le32 first_error_address; - u8 hw_state; - u8 warning_counter; - __le16 reserved3; - __le16 interface_version; - __le16 reserved4; +union ipa_uc_mem_area { + struct { + u8 command; /* enum ipa_uc_command */ + u8 reserved0[3]; + __le32 command_param; + u8 response; /* enum ipa_uc_response */ + u8 reserved1[3]; + __le32 response_param; + u8 event; /* enum ipa_uc_event */ + u8 reserved2[3]; + + __le32 event_param; + __le32 reserved3; + __le32 first_error_address; + u8 hw_state; + u8 warning_counter; + __le16 reserved4; + __le16 interface_version; + __le16 reserved5; + } v2; + struct { + u8 command; /* enum ipa_uc_command */ + u8 reserved0[3]; + __le32 command_param; + __le32 command_param_hi; + u8 response; /* enum ipa_uc_response */ + u8 reserved1[3]; + __le32 response_param; + u8 event; /* enum ipa_uc_event */ + u8 reserved2[3]; + + __le32 event_param; + __le32 first_error_address; + u8 hw_state; + u8 warning_counter; + __le16 reserved3; + __le16 interface_version; + __le16 reserved4; + } v3; }; +#define UC_FIELD(_ipa, _field) \ + *((_ipa->version >= IPA_VERSION_3_0) ? \ + &(ipa_uc_shared(_ipa)->v3._field) : \ + &(ipa_uc_shared(_ipa)->v2._field)) + /** enum ipa_uc_command - commands from the AP to the microcontroller */ enum ipa_uc_command { IPA_UC_COMMAND_NO_OP = 0x0, @@ -95,6 +123,7 @@ enum ipa_uc_command { IPA_UC_COMMAND_CLK_UNGATE = 0x6, IPA_UC_COMMAND_MEMCPY = 0x7, IPA_UC_COMMAND_RESET_PIPE = 0x8, + /* Next two commands are present for IPA v3.0+ */ IPA_UC_COMMAND_REG_WRITE = 0x9, IPA_UC_COMMAND_GSI_CH_EMPTY = 0xa, }; @@ -114,7 +143,7 @@ enum ipa_uc_event { IPA_UC_EVENT_LOG_INFO = 0x2, }; -static struct ipa_uc_mem_area *ipa_uc_shared(struct ipa *ipa) +static union ipa_uc_mem_area *ipa_uc_shared(struct ipa *ipa) { const struct ipa_mem *mem = ipa_mem_find(ipa, IPA_MEM_UC_SHARED); u32 offset = ipa->mem_offset + mem->offset; @@ -125,22 +154,22 @@ static struct ipa_uc_mem_area *ipa_uc_shared(struct ipa *ipa) /* Microcontroller event IPA interrupt handler */ static void ipa_uc_event_handler(struct ipa *ipa, enum ipa_irq_id irq_id) { - struct ipa_uc_mem_area *shared = ipa_uc_shared(ipa); struct device *dev = &ipa->pdev->dev; + u32 event = UC_FIELD(ipa, event); - if (shared->event == IPA_UC_EVENT_ERROR) + if (event == IPA_UC_EVENT_ERROR) dev_err(dev, "microcontroller error event\n"); - else if (shared->event != IPA_UC_EVENT_LOG_INFO) + else if (event != IPA_UC_EVENT_LOG_INFO) dev_err(dev, "unsupported microcontroller event %u\n", - shared->event); + event); /* The LOG_INFO event can be safely ignored */ } /* Microcontroller response IPA interrupt handler */ static void ipa_uc_response_hdlr(struct ipa *ipa, enum ipa_irq_id irq_id) { - struct ipa_uc_mem_area *shared = ipa_uc_shared(ipa); struct device *dev = &ipa->pdev->dev; + u32 response = UC_FIELD(ipa, response); /* An INIT_COMPLETED response message is sent to the AP by the * microcontroller when it is operational. Other than this, the AP @@ -150,20 +179,21 @@ static void ipa_uc_response_hdlr(struct ipa *ipa, enum ipa_irq_id irq_id) * We can drop the power reference taken in ipa_uc_power() once we * know the microcontroller has finished its initialization. */ - switch (shared->response) { + switch (response) { case IPA_UC_RESPONSE_INIT_COMPLETED: if (ipa->uc_powered) { ipa->uc_loaded = true; pm_runtime_mark_last_busy(dev); (void)pm_runtime_put_autosuspend(dev); ipa->uc_powered = false; + ipa_qmi_signal_uc_loaded(ipa); } else { dev_warn(dev, "unexpected init_completed response\n"); } break; default: dev_warn(dev, "unsupported microcontroller response %u\n", - shared->response); + response); break; } } @@ -216,16 +246,16 @@ void ipa_uc_power(struct ipa *ipa) /* Send a command to the microcontroller */ static void send_uc_command(struct ipa *ipa, u32 command, u32 command_param) { - struct ipa_uc_mem_area *shared = ipa_uc_shared(ipa); u32 offset; u32 val; /* Fill in the command data */ - shared->command = command; - shared->command_param = cpu_to_le32(command_param); - shared->command_param_hi = 0; - shared->response = 0; - shared->response_param = 0; + UC_FIELD(ipa, command) = command; + UC_FIELD(ipa, command_param) = cpu_to_le32(command_param); + if (ipa->version >= IPA_VERSION_3_0) + ipa_uc_shared(ipa)->v3.command_param_hi = 1; + UC_FIELD(ipa, response) = 0; + UC_FIELD(ipa, response_param) = 0; /* Use an interrupt to tell the microcontroller the command is ready */ val = u32_encode_bits(1, UC_INTR_FMASK); From patchwork Mon Sep 20 03:08:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sireesh Kodali X-Patchwork-Id: 12504559 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1A9DC433FE for ; Mon, 20 Sep 2021 03:11:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9977D60FC2 for ; Mon, 20 Sep 2021 03:11:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234926AbhITDMi (ORCPT ); Sun, 19 Sep 2021 23:12:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234266AbhITDM2 (ORCPT ); Sun, 19 Sep 2021 23:12:28 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFCB9C0617AD; Sun, 19 Sep 2021 20:10:08 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id j14so2972956plx.4; Sun, 19 Sep 2021 20:10:08 -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=A0xq/rLxDex9b8Ex71OL3CndFUoZBhsozJlG/ecmG+U=; b=bEaP/Bty1T5b11swdf7NIsbeXYscNiwie9ZRgawYGkP2bJe3cLEhBe0cyxp4GPj0GD tRmkZxPdD9VnXqzlGIs44r8fdMCCUBGnX4UYZgIlSQTkfR/mcnUDSBJY4jtP0vw0Oq/C Y3OTam3Atd0LZ1kHAUPyG7w0//Vee63V124ElhtQeV9G2Fr8aiW6HdxM2VQVkGEkjndD M9ZCeMpWPfogtnuWSTVW+H+YDgs4JqmcJvswJgSFzY2UH4UG8SSmXek3zVXl9xmXRG0k kAzp435nh0LhqGro89L8+65FxocVWWRDmJPJIXvTZv29TvoMmydRxE3teogtrx6BE4Pq aktg== 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=A0xq/rLxDex9b8Ex71OL3CndFUoZBhsozJlG/ecmG+U=; b=q+3HzMGVdkPir4unf10LDx7ltxXP7A6sRv+ikdzwgvGAtQXK2WHCseSSkp6MfnnWkf KQ+AoW672wVHvgo9DdTW5vCzlqCIjfSBN+IpWma//pIdCm3DABrF90RAPSX1JaNtZ+1Y 7vDxDWVSLbAB7z9ax4m0BVN2WLHjQXZIZCBsdTOCUN4MicwJnOVSGJfeB2+UDB7NYL/U DrbLl8MY2nplbPvg3s/DX8T0e0F7c7us+83J153dnyzEykA086LBbUb8R1XIKMr/lsnY 1j0Hzx8T3qexDTDBEDaLIye+QnMmqnUPxZULeUgpah3zn3Gm1YRax7e4kqJzjXMXDygU sNfw== X-Gm-Message-State: AOAM5332vTt/gqA6n1t7QGLTU5VZto8e7pX03c9as7s1UOF72Iwiazpp rsteVZ87Jd8wvk0uipzW81AZTMnksj/MJA9b X-Google-Smtp-Source: ABdhPJyCkqD8rMV7e2k2keBSezz9ogKpyjG+e0uThkJeZmQ8zZeIbQOJz2WfGIGxNLZiOvIbA84AeQ== X-Received: by 2002:a17:902:930c:b029:12c:d5c8:61c4 with SMTP id bc12-20020a170902930cb029012cd5c861c4mr20754678plb.73.1632107408204; Sun, 19 Sep 2021 20:10:08 -0700 (PDT) Received: from skynet-linux.local ([106.201.127.154]) by smtp.googlemail.com with ESMTPSA id l11sm16295065pjg.22.2021.09.19.20.10.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Sep 2021 20:10:07 -0700 (PDT) From: Sireesh Kodali To: phone-devel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, elder@kernel.org Cc: Sireesh Kodali , "David S. Miller" , Jakub Kicinski Subject: [RFC PATCH 15/17] net: ipa: Add IPA v2.6L initialization sequence support Date: Mon, 20 Sep 2021 08:38:09 +0530 Message-Id: <20210920030811.57273-16-sireeshkodali1@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920030811.57273-1-sireeshkodali1@gmail.com> References: <20210920030811.57273-1-sireeshkodali1@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The biggest changes are: - Make SMP2P functions no-operation - Make resource init no-operation - Skip firmware loading - Add reset sequence Signed-off-by: Sireesh Kodali --- drivers/net/ipa/ipa_main.c | 19 ++++++++++++++++--- drivers/net/ipa/ipa_resource.c | 3 +++ drivers/net/ipa/ipa_smp2p.c | 11 +++++++++-- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c index ea6c4347f2c6..b437fbf95edf 100644 --- a/drivers/net/ipa/ipa_main.c +++ b/drivers/net/ipa/ipa_main.c @@ -355,12 +355,22 @@ static void ipa_hardware_config(struct ipa *ipa, const struct ipa_data *data) u32 granularity; u32 val; + if (ipa->version <= IPA_VERSION_2_6L) { + iowrite32(1, ipa->reg_virt + IPA_REG_COMP_SW_RESET_OFFSET); + iowrite32(0, ipa->reg_virt + IPA_REG_COMP_SW_RESET_OFFSET); + + iowrite32(1, ipa->reg_virt + ipa_reg_comp_cfg_offset(ipa->version)); + } + /* IPA v4.5+ has no backward compatibility register */ - if (version < IPA_VERSION_4_5) { + if (version >= IPA_VERSION_2_5 && version < IPA_VERSION_4_5) { val = data->backward_compat; iowrite32(val, ipa->reg_virt + ipa_reg_bcr_offset(ipa->version)); } + if (ipa->version <= IPA_VERSION_2_6L) + return; + /* Implement some hardware workarounds */ if (version >= IPA_VERSION_4_0 && version < IPA_VERSION_4_5) { /* Disable PA mask to allow HOLB drop */ @@ -412,7 +422,8 @@ static void ipa_hardware_config(struct ipa *ipa, const struct ipa_data *data) static void ipa_hardware_deconfig(struct ipa *ipa) { /* Mostly we just leave things as we set them. */ - ipa_hardware_dcd_deconfig(ipa); + if (ipa->version > IPA_VERSION_2_6L) + ipa_hardware_dcd_deconfig(ipa); } /** @@ -765,8 +776,10 @@ static int ipa_probe(struct platform_device *pdev) /* Otherwise we need to load the firmware and have Trust Zone validate * and install it. If that succeeds we can proceed with setup. + * But on IPA v2.6L we don't need to do firmware loading :D */ - ret = ipa_firmware_load(dev); + if (ipa->version > IPA_VERSION_2_6L) + ret = ipa_firmware_load(dev); if (ret) goto err_deconfig; diff --git a/drivers/net/ipa/ipa_resource.c b/drivers/net/ipa/ipa_resource.c index e3da95d69409..36a72324d828 100644 --- a/drivers/net/ipa/ipa_resource.c +++ b/drivers/net/ipa/ipa_resource.c @@ -162,6 +162,9 @@ int ipa_resource_config(struct ipa *ipa, const struct ipa_resource_data *data) { u32 i; + if (ipa->version <= IPA_VERSION_2_6L) + return 0; + if (!ipa_resource_limits_valid(ipa, data)) return -EINVAL; diff --git a/drivers/net/ipa/ipa_smp2p.c b/drivers/net/ipa/ipa_smp2p.c index df7639c39d71..fa4a9f1c196a 100644 --- a/drivers/net/ipa/ipa_smp2p.c +++ b/drivers/net/ipa/ipa_smp2p.c @@ -233,6 +233,10 @@ int ipa_smp2p_init(struct ipa *ipa, bool modem_init) u32 valid_bit; int ret; + /* With IPA v2.6L and earlier SMP2P interrupts are used */ + if (ipa->version <= IPA_VERSION_2_6L) + return 0; + valid_state = qcom_smem_state_get(dev, "ipa-clock-enabled-valid", &valid_bit); if (IS_ERR(valid_state)) @@ -302,6 +306,9 @@ void ipa_smp2p_exit(struct ipa *ipa) { struct ipa_smp2p *smp2p = ipa->smp2p; + if (!smp2p) + return; + if (smp2p->setup_ready_irq) ipa_smp2p_irq_exit(smp2p, smp2p->setup_ready_irq); ipa_smp2p_panic_notifier_unregister(smp2p); @@ -317,7 +324,7 @@ void ipa_smp2p_disable(struct ipa *ipa) { struct ipa_smp2p *smp2p = ipa->smp2p; - if (!smp2p->setup_ready_irq) + if (!smp2p || !smp2p->setup_ready_irq) return; mutex_lock(&smp2p->mutex); @@ -333,7 +340,7 @@ void ipa_smp2p_notify_reset(struct ipa *ipa) struct ipa_smp2p *smp2p = ipa->smp2p; u32 mask; - if (!smp2p->notified) + if (!smp2p || !smp2p->notified) return; ipa_smp2p_power_release(ipa); From patchwork Mon Sep 20 03:08:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sireesh Kodali X-Patchwork-Id: 12504561 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C19A8C433F5 for ; Mon, 20 Sep 2021 03:11:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A7E0760FC1 for ; Mon, 20 Sep 2021 03:11:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234946AbhITDMk (ORCPT ); Sun, 19 Sep 2021 23:12:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234515AbhITDM3 (ORCPT ); Sun, 19 Sep 2021 23:12:29 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2753C0617BA; Sun, 19 Sep 2021 20:10:17 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id on12-20020a17090b1d0c00b001997c60aa29so11115847pjb.1; Sun, 19 Sep 2021 20:10:17 -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=TiVOZ2Q/tlFKYvHdNz90hwJpJvi2U953jPl9nmU6Kdo=; b=l6CL+t2GdHNaHgYvSAziVSAt9eN6B6pUFbx0amR+MdaEmSZMhTH5qL2oRUUaHUeVj3 gwdL8vuN/3aVI7Ja+YOVtfUwgavAwJnlnK5PDwidylZoOR3kATJl2zUisj4BWgdBXojL mrpOLlReJz3kgm7VxEx5+m7c5/td0CFOhX5dVADbgnPEU5BG3UBKaqu+QWSxVCaJbSzg Z1zgGMfK9E5u/8UHlDLUVwpA7Oz7pwlCMV7V3rMnVpp8Tnev08D9fOsYF+kleMd7h03n SxnNrReyAlD+8qP9GmH/cy4RwyCuzo6wfWjB/CXChcTsGk5+7R9tswPbIbD+GR94qjXd ykUw== 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=TiVOZ2Q/tlFKYvHdNz90hwJpJvi2U953jPl9nmU6Kdo=; b=yuJacLNuGnC0WS/OLnMiQmjNArWd55TLcMQyWzaYjHgY6E3kDXdgV3OU/+TII1oTgI uStFE16RDddFWXMrAQybe/qoZAnHGpc3jjRTjHJCeOr83oSHqfo5Zt+g/HXsKJ/0AXaC 4vFeoK9fnJL5Y9PHWWI2jn5d5QkV+dcTtfbQQsXZBoOifYsN+zgp2BvkjTwQjenZ0Q/f tjOWGno1k6+ze365PLtm/B1zFJNUuWZoPgDQpADbKuYO7q6whj6bopEFJTZsS+d6BcVM DwjhyzUlDxtF289bQ9SCtfCRVlIxn8FHethogkKY2ARI5GxFcnYXq8Ty6k8Ykipv9edL wvWA== X-Gm-Message-State: AOAM531FvGmgRWkXbFcwTIJMf92SNdl5zwlDInrwrg+DKEDUa9X08Lof xjou/CWsFKWfclBTcKYKtFbzCfsnVldEOL1n X-Google-Smtp-Source: ABdhPJzEp7WSBTpujmr4zlGxDju8VcySMROlcorxyx985uw5YX2iqhYeLnA/AMCA1cDLVuTDD6+8Ng== X-Received: by 2002:a17:902:d2c8:b0:13a:54b2:81c9 with SMTP id n8-20020a170902d2c800b0013a54b281c9mr20477803plc.21.1632107417124; Sun, 19 Sep 2021 20:10:17 -0700 (PDT) Received: from skynet-linux.local ([106.201.127.154]) by smtp.googlemail.com with ESMTPSA id l11sm16295065pjg.22.2021.09.19.20.10.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Sep 2021 20:10:16 -0700 (PDT) From: Sireesh Kodali To: phone-devel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, elder@kernel.org Cc: Sireesh Kodali , "David S. Miller" , Jakub Kicinski Subject: [RFC PATCH 16/17] net: ipa: Add hw config describing IPA v2.x hardware Date: Mon, 20 Sep 2021 08:38:10 +0530 Message-Id: <20210920030811.57273-17-sireeshkodali1@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920030811.57273-1-sireeshkodali1@gmail.com> References: <20210920030811.57273-1-sireeshkodali1@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org This commit adds the config for IPA v2.0, v2.5, v2.6L. IPA v2.5 is found on msm8996. IPA v2.6L hardware is found on following SoCs: msm8920, msm8940, msm8952, msm8953, msm8956, msm8976, sdm630, sdm660. No SoC-specific configuration in ipa driver is required. Signed-off-by: Sireesh Kodali --- drivers/net/ipa/Makefile | 7 +- drivers/net/ipa/ipa_data-v2.c | 369 ++++++++++++++++++++++++++++++++ drivers/net/ipa/ipa_data-v3.1.c | 2 +- drivers/net/ipa/ipa_data.h | 3 + drivers/net/ipa/ipa_main.c | 15 ++ drivers/net/ipa/ipa_sysfs.c | 6 + 6 files changed, 398 insertions(+), 4 deletions(-) create mode 100644 drivers/net/ipa/ipa_data-v2.c diff --git a/drivers/net/ipa/Makefile b/drivers/net/ipa/Makefile index 4abebc667f77..858fbf76cff3 100644 --- a/drivers/net/ipa/Makefile +++ b/drivers/net/ipa/Makefile @@ -7,6 +7,7 @@ ipa-y := ipa_main.o ipa_power.o ipa_reg.o ipa_mem.o \ ipa_resource.o ipa_qmi.o ipa_qmi_msg.o \ ipa_sysfs.o -ipa-y += ipa_data-v3.1.o ipa_data-v3.5.1.o \ - ipa_data-v4.2.o ipa_data-v4.5.o \ - ipa_data-v4.9.o ipa_data-v4.11.o +ipa-y += ipa_data-v2.o ipa_data-v3.1.o \ + ipa_data-v3.5.1.o ipa_data-v4.2.o \ + ipa_data-v4.5.o ipa_data-v4.9.o \ + ipa_data-v4.11.o diff --git a/drivers/net/ipa/ipa_data-v2.c b/drivers/net/ipa/ipa_data-v2.c new file mode 100644 index 000000000000..869b8a1a45d6 --- /dev/null +++ b/drivers/net/ipa/ipa_data-v2.c @@ -0,0 +1,369 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved. + * Copyright (C) 2019-2020 Linaro Ltd. + */ + +#include + +#include "ipa_data.h" +#include "ipa_endpoint.h" +#include "ipa_mem.h" + +/* Endpoint configuration for the IPA v2 hardware. */ +static const struct ipa_gsi_endpoint_data ipa_endpoint_data[] = { + [IPA_ENDPOINT_AP_COMMAND_TX] = { + .ee_id = GSI_EE_AP, + .channel_id = 3, + .endpoint_id = 3, + .channel_name = "cmd_tx", + .toward_ipa = true, + .channel = { + .tre_count = 256, + .event_count = 256, + .tlv_count = 20, + }, + .endpoint = { + .config = { + .dma_mode = true, + .dma_endpoint = IPA_ENDPOINT_AP_LAN_RX, + }, + }, + }, + [IPA_ENDPOINT_AP_LAN_RX] = { + .ee_id = GSI_EE_AP, + .channel_id = 2, + .endpoint_id = 2, + .channel_name = "ap_lan_rx", + .channel = { + .tre_count = 256, + .event_count = 256, + .tlv_count = 8, + }, + .endpoint = { + .config = { + .aggregation = true, + .status_enable = true, + .rx = { + .pad_align = ilog2(sizeof(u32)), + }, + }, + }, + }, + [IPA_ENDPOINT_AP_MODEM_TX] = { + .ee_id = GSI_EE_AP, + .channel_id = 4, + .endpoint_id = 4, + .channel_name = "ap_modem_tx", + .toward_ipa = true, + .channel = { + .tre_count = 256, + .event_count = 256, + .tlv_count = 8, + }, + .endpoint = { + .config = { + .qmap = true, + .status_enable = true, + .tx = { + .status_endpoint = + IPA_ENDPOINT_AP_LAN_RX, + }, + }, + }, + }, + [IPA_ENDPOINT_AP_MODEM_RX] = { + .ee_id = GSI_EE_AP, + .channel_id = 5, + .endpoint_id = 5, + .channel_name = "ap_modem_rx", + .toward_ipa = false, + .channel = { + .tre_count = 256, + .event_count = 256, + .tlv_count = 8, + }, + .endpoint = { + .config = { + .aggregation = true, + .qmap = true, + }, + }, + }, + [IPA_ENDPOINT_MODEM_LAN_TX] = { + .ee_id = GSI_EE_MODEM, + .channel_id = 6, + .endpoint_id = 6, + .channel_name = "modem_lan_tx", + .toward_ipa = true, + }, + [IPA_ENDPOINT_MODEM_COMMAND_TX] = { + .ee_id = GSI_EE_MODEM, + .channel_id = 7, + .endpoint_id = 7, + .channel_name = "modem_cmd_tx", + .toward_ipa = true, + }, + [IPA_ENDPOINT_MODEM_LAN_RX] = { + .ee_id = GSI_EE_MODEM, + .channel_id = 8, + .endpoint_id = 8, + .channel_name = "modem_lan_rx", + .toward_ipa = false, + }, + [IPA_ENDPOINT_MODEM_AP_RX] = { + .ee_id = GSI_EE_MODEM, + .channel_id = 9, + .endpoint_id = 9, + .channel_name = "modem_ap_rx", + .toward_ipa = false, + }, +}; + +static struct ipa_interconnect_data ipa_interconnect_data[] = { + { + .name = "memory", + .peak_bandwidth = 1200000, /* 1200 MBps */ + .average_bandwidth = 100000, /* 100 MBps */ + }, + { + .name = "imem", + .peak_bandwidth = 350000, /* 350 MBps */ + .average_bandwidth = 0, /* unused */ + }, + { + .name = "config", + .peak_bandwidth = 40000, /* 40 MBps */ + .average_bandwidth = 0, /* unused */ + }, +}; + +static struct ipa_power_data ipa_power_data = { + .core_clock_rate = 200 * 1000 * 1000, /* Hz */ + .interconnect_count = ARRAY_SIZE(ipa_interconnect_data), + .interconnect_data = ipa_interconnect_data, +}; + +/* IPA-resident memory region configuration for v2.0 */ +static const struct ipa_mem ipa_mem_local_data_v2_0[IPA_MEM_COUNT] = { + [IPA_MEM_UC_SHARED] = { + .offset = 0, + .size = 0x80, + .canary_count = 0, + }, + [IPA_MEM_V4_FILTER] = { + .offset = 0x0080, + .size = 0x0058, + .canary_count = 0, + }, + [IPA_MEM_V6_FILTER] = { + .offset = 0x00e0, + .size = 0x0058, + .canary_count = 2, + }, + [IPA_MEM_V4_ROUTE] = { + .offset = 0x0140, + .size = 0x002c, + .canary_count = 2, + }, + [IPA_MEM_V6_ROUTE] = { + .offset = 0x0170, + .size = 0x002c, + .canary_count = 1, + }, + [IPA_MEM_MODEM_HEADER] = { + .offset = 0x01a0, + .size = 0x0140, + .canary_count = 1, + }, + [IPA_MEM_AP_HEADER] = { + .offset = 0x02e0, + .size = 0x0048, + .canary_count = 0, + }, + [IPA_MEM_MODEM] = { + .offset = 0x032c, + .size = 0x0dcc, + .canary_count = 1, + }, + [IPA_MEM_V4_FILTER_AP] = { + .offset = 0x10fc, + .size = 0x0780, + .canary_count = 1, + }, + [IPA_MEM_V6_FILTER_AP] = { + .offset = 0x187c, + .size = 0x055c, + .canary_count = 0, + }, + [IPA_MEM_UC_INFO] = { + .offset = 0x1ddc, + .size = 0x0124, + .canary_count = 1, + }, +}; + +static struct ipa_mem_data ipa_mem_data_v2_0 = { + .local = ipa_mem_local_data_v2_0, + .smem_id = 497, + .smem_size = 0x00001f00, +}; + +/* Configuration data for IPAv2.0 */ +const struct ipa_data ipa_data_v2_0 = { + .version = IPA_VERSION_2_0, + .endpoint_count = ARRAY_SIZE(ipa_endpoint_data), + .endpoint_data = ipa_endpoint_data, + .mem_data = &ipa_mem_data_v2_0, + .power_data = &ipa_power_data, +}; + +/* IPA-resident memory region configuration for v2.5 */ +static const struct ipa_mem ipa_mem_local_data_v2_5[IPA_MEM_COUNT] = { + [IPA_MEM_UC_SHARED] = { + .offset = 0, + .size = 0x80, + .canary_count = 0, + }, + [IPA_MEM_UC_INFO] = { + .offset = 0x0080, + .size = 0x0200, + .canary_count = 0, + }, + [IPA_MEM_V4_FILTER] = { + .offset = 0x0288, + .size = 0x0058, + .canary_count = 2, + }, + [IPA_MEM_V6_FILTER] = { + .offset = 0x02e8, + .size = 0x0058, + .canary_count = 2, + }, + [IPA_MEM_V4_ROUTE] = { + .offset = 0x0348, + .size = 0x003c, + .canary_count = 2, + }, + [IPA_MEM_V6_ROUTE] = { + .offset = 0x0388, + .size = 0x003c, + .canary_count = 1, + }, + [IPA_MEM_MODEM_HEADER] = { + .offset = 0x03c8, + .size = 0x0140, + .canary_count = 1, + }, + [IPA_MEM_MODEM_PROC_CTX] = { + .offset = 0x0510, + .size = 0x0200, + .canary_count = 2, + }, + [IPA_MEM_AP_PROC_CTX] = { + .offset = 0x0710, + .size = 0x0200, + .canary_count = 0, + }, + [IPA_MEM_MODEM] = { + .offset = 0x0914, + .size = 0x16a8, + .canary_count = 1, + }, +}; + +static struct ipa_mem_data ipa_mem_data_v2_5 = { + .local = ipa_mem_local_data_v2_5, + .smem_id = 497, + .smem_size = 0x00002000, +}; + +/* Configuration data for IPAv2.5 */ +const struct ipa_data ipa_data_v2_5 = { + .version = IPA_VERSION_2_5, + .endpoint_count = ARRAY_SIZE(ipa_endpoint_data), + .endpoint_data = ipa_endpoint_data, + .mem_data = &ipa_mem_data_v2_5, + .power_data = &ipa_power_data, +}; + +/* IPA-resident memory region configuration for v2.6L */ +static const struct ipa_mem ipa_mem_local_data_v2_6L[IPA_MEM_COUNT] = { + { + .id = IPA_MEM_UC_SHARED, + .offset = 0, + .size = 0x80, + .canary_count = 0, + }, + { + .id = IPA_MEM_UC_INFO, + .offset = 0x0080, + .size = 0x0200, + .canary_count = 0, + }, + { + .id = IPA_MEM_V4_FILTER, + .offset = 0x0288, + .size = 0x0058, + .canary_count = 2, + }, + { + .id = IPA_MEM_V6_FILTER, + .offset = 0x02e8, + .size = 0x0058, + .canary_count = 2, + }, + { + .id = IPA_MEM_V4_ROUTE, + .offset = 0x0348, + .size = 0x003c, + .canary_count = 2, + }, + { + .id = IPA_MEM_V6_ROUTE, + .offset = 0x0388, + .size = 0x003c, + .canary_count = 1, + }, + { + .id = IPA_MEM_MODEM_HEADER, + .offset = 0x03c8, + .size = 0x0140, + .canary_count = 1, + }, + { + .id = IPA_MEM_ZIP, + .offset = 0x0510, + .size = 0x0200, + .canary_count = 2, + }, + { + .id = IPA_MEM_MODEM, + .offset = 0x0714, + .size = 0x18e8, + .canary_count = 1, + }, + { + .id = IPA_MEM_END_MARKER, + .offset = 0x2000, + .size = 0, + .canary_count = 1, + }, +}; + +static struct ipa_mem_data ipa_mem_data_v2_6L = { + .local = ipa_mem_local_data_v2_6L, + .smem_id = 497, + .smem_size = 0x00002000, +}; + +/* Configuration data for IPAv2.6L */ +const struct ipa_data ipa_data_v2_6L = { + .version = IPA_VERSION_2_6L, + /* Unfortunately we don't know what this BCR value corresponds to */ + .backward_compat = 0x1fff7f, + .endpoint_count = ARRAY_SIZE(ipa_endpoint_data), + .endpoint_data = ipa_endpoint_data, + .mem_data = &ipa_mem_data_v2_6L, + .power_data = &ipa_power_data, +}; diff --git a/drivers/net/ipa/ipa_data-v3.1.c b/drivers/net/ipa/ipa_data-v3.1.c index 06ddb85f39b2..12d231232756 100644 --- a/drivers/net/ipa/ipa_data-v3.1.c +++ b/drivers/net/ipa/ipa_data-v3.1.c @@ -6,7 +6,7 @@ #include -#include "gsi.h" +#include "ipa_dma.h" #include "ipa_data.h" #include "ipa_endpoint.h" #include "ipa_mem.h" diff --git a/drivers/net/ipa/ipa_data.h b/drivers/net/ipa/ipa_data.h index 7d62d49f414f..e7ce2e9388b6 100644 --- a/drivers/net/ipa/ipa_data.h +++ b/drivers/net/ipa/ipa_data.h @@ -301,6 +301,9 @@ struct ipa_data { const struct ipa_power_data *power_data; }; +extern const struct ipa_data ipa_data_v2_0; +extern const struct ipa_data ipa_data_v2_5; +extern const struct ipa_data ipa_data_v2_6L; extern const struct ipa_data ipa_data_v3_1; extern const struct ipa_data ipa_data_v3_5_1; extern const struct ipa_data ipa_data_v4_2; diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c index b437fbf95edf..3ae5c5c6734b 100644 --- a/drivers/net/ipa/ipa_main.c +++ b/drivers/net/ipa/ipa_main.c @@ -560,6 +560,18 @@ static int ipa_firmware_load(struct device *dev) } static const struct of_device_id ipa_match[] = { + { + .compatible = "qcom,ipa-v2.0", + .data = &ipa_data_v2_0, + }, + { + .compatible = "qcom,msm8996-ipa", + .data = &ipa_data_v2_5, + }, + { + .compatible = "qcom,msm8953-ipa", + .data = &ipa_data_v2_6L, + }, { .compatible = "qcom,msm8998-ipa", .data = &ipa_data_v3_1, @@ -632,6 +644,9 @@ static void ipa_validate_build(void) static bool ipa_version_valid(enum ipa_version version) { switch (version) { + case IPA_VERSION_2_0: + case IPA_VERSION_2_5: + case IPA_VERSION_2_6L: case IPA_VERSION_3_0: case IPA_VERSION_3_1: case IPA_VERSION_3_5: diff --git a/drivers/net/ipa/ipa_sysfs.c b/drivers/net/ipa/ipa_sysfs.c index ff61dbdd70d8..f5d159f6bc06 100644 --- a/drivers/net/ipa/ipa_sysfs.c +++ b/drivers/net/ipa/ipa_sysfs.c @@ -14,6 +14,12 @@ static const char *ipa_version_string(struct ipa *ipa) { switch (ipa->version) { + case IPA_VERSION_2_0: + return "2.0"; + case IPA_VERSION_2_5: + return "2.5"; + case IPA_VERSION_2_6L: + "return 2.6L"; case IPA_VERSION_3_0: return "3.0"; case IPA_VERSION_3_1: From patchwork Mon Sep 20 03:08:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sireesh Kodali X-Patchwork-Id: 12504563 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58296C433FE for ; Mon, 20 Sep 2021 03:11:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4197560FC2 for ; Mon, 20 Sep 2021 03:11:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232903AbhITDMu (ORCPT ); Sun, 19 Sep 2021 23:12:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231892AbhITDM3 (ORCPT ); Sun, 19 Sep 2021 23:12:29 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 192B1C0617BD; Sun, 19 Sep 2021 20:10:23 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id y8so14897803pfa.7; Sun, 19 Sep 2021 20:10:23 -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=kcXtoLmYt2phW1mwUUg+pkx0ARAiF/TyvXAFksE2SBQ=; b=pFlrtsqNO9qXwFt7kVRJc3jd1jIT/rtb8ePyXwe1f5FtWfdxdXDUNIrPR50+7rYSyo MfoiSV6RnhAsp7qzYXl7Ld1REg38NbZNBCfcbEfgH/KgDw5hE2i1MGbE0eQj6e7+XNhq f1m9hWdjFYTOYFV7Y8dAkfTk3HT+8WQLcRfJOBfHZ8sIsdRvzVUepchC03JmcJ+b86zm E7rM5LxE6urcvQBRCMITMWiuzvFDi62VwQUhhFqi5FfFd5xHsLdE8ARSPXmokNuKqXfO d5bN4p6nDH/RkpJUfoqQZchoFoHz9aW8tA8Mwkpc2NvpOmsSxVtvNHMDHmTETLoyhTQl TwGQ== 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=kcXtoLmYt2phW1mwUUg+pkx0ARAiF/TyvXAFksE2SBQ=; b=xBTmMptq3rdLWnuD/zKE1pqRmh/RDGiyjFlGfZSU7jo2Ltn8nwCIVgDYLmT1mOupZJ qSFSfaW/Ob5N4VMu4BOF+zUdobGkGl0zu5VQYpFsMcYVBSNgMI88OSKoOsdtq3fphrs1 Pwauohyl6maos8Yv7KOD0epo0SJi1Iyz3GJcr+zsvdVhs5ew55IVpxFdPZfItfEpHVKm kuYVAT6G6QYk7D7RAmoW/gQbf1iTkyQTzAYq3b3c9eICYh2jePuPV2jB2+mkZQCLlKtn PbBEa6F+3T/IW3ReZeE5yKAzYn1bQRH0XK+F24aE+qWxxTrqGk97cQCfBz2c57grLdBa 3T6g== X-Gm-Message-State: AOAM530/SX2DfVaT3wReLpxQ4vF1lxxfEo3rDrlJ3k9tc268sOfeA3/r dTY00NPQ8O/CAhWApWJibe5bSWSDPeVuS+Zi X-Google-Smtp-Source: ABdhPJy+NEw+sEBgIWaA+ZDckq/1cv/4xFeVi9rF+KOct7Jo17tYOoW1t+YKJqTU2FMS6+04RcQxJg== X-Received: by 2002:a63:dd51:: with SMTP id g17mr21385975pgj.47.1632107422430; Sun, 19 Sep 2021 20:10:22 -0700 (PDT) Received: from skynet-linux.local ([106.201.127.154]) by smtp.googlemail.com with ESMTPSA id l11sm16295065pjg.22.2021.09.19.20.10.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Sep 2021 20:10:22 -0700 (PDT) From: Sireesh Kodali To: phone-devel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, elder@kernel.org Cc: Sireesh Kodali , Andy Gross , Bjorn Andersson , "David S. Miller" , Jakub Kicinski , Rob Herring , devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS) Subject: [RFC PATCH 17/17] dt-bindings: net: qcom,ipa: Add support for MSM8953 and MSM8996 IPA Date: Mon, 20 Sep 2021 08:38:11 +0530 Message-Id: <20210920030811.57273-18-sireeshkodali1@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920030811.57273-1-sireeshkodali1@gmail.com> References: <20210920030811.57273-1-sireeshkodali1@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org MSM8996 uses IPA v2.5 and MSM8953 uses IPA v2.6l Signed-off-by: Sireesh Kodali Acked-by: Rob Herring --- Documentation/devicetree/bindings/net/qcom,ipa.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/net/qcom,ipa.yaml b/Documentation/devicetree/bindings/net/qcom,ipa.yaml index b8a0b392b24e..e857827bfa54 100644 --- a/Documentation/devicetree/bindings/net/qcom,ipa.yaml +++ b/Documentation/devicetree/bindings/net/qcom,ipa.yaml @@ -44,6 +44,8 @@ description: properties: compatible: enum: + - qcom,msm8953-ipa + - qcom,msm8996-ipa - qcom,msm8998-ipa - qcom,sc7180-ipa - qcom,sc7280-ipa