From nobody Thu Apr 2 15:02:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9E9DC6FA8B for ; Thu, 22 Sep 2022 22:21:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231387AbiIVWVQ (ORCPT ); Thu, 22 Sep 2022 18:21:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230482AbiIVWVJ (ORCPT ); Thu, 22 Sep 2022 18:21:09 -0400 Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96F4110D0F4 for ; Thu, 22 Sep 2022 15:21:05 -0700 (PDT) Received: by mail-io1-xd33.google.com with SMTP id z191so8929512iof.10 for ; Thu, 22 Sep 2022 15:21:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=lSdeMmKOatLt1HIEIx6J8l8o81Ep3DSqpQTV4HSGmjQ=; b=BLrB/OURumYJfvjcJAgrrvjpSokfJ/yHuaEheiKd201cRLgLBU2mKAmzUVxzCkuHXS U66diQmI5s64GPFTfjtx30gWBdboZzOkHsyPB/l5jJlJ5WNI1+CuUVZVnJeiO+qpMBwD 1GgbSkLM5Ft6jXzYf1GpK43+7UoX/PkiuRJJ8KISJDq643R26c1TeYxi39YLfVXzptCH 4gNHWI2M9x+3spV3K3i/WnWKtgzSij7A9YUg2QFoei2nuFp9ZuzS+B35VjGT3F8pijwF WLatGGtE/dO5dpY1uOdQqE/1CrurIdCxgCtdj2YYWr+7z+F1Efao4dqHTbTEy2ulsMOs 098Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=lSdeMmKOatLt1HIEIx6J8l8o81Ep3DSqpQTV4HSGmjQ=; b=qUGpfG3duFnOcW3BSHE56MM2IV4ebVlU1geR9DOHPO2JU3JULD88EJe8QgmMTVKqtI lSPF3Lvkyw+qjZsJWE36/zSshO2JoycgL+/OTocK2FQ3JfjUfj5vje1GBvtE7n62TpH5 w+KaavdjWfq5ouXsM6G/hh02YwF4clW9tZvpXU2pwfRcXyRvPiPfW45+0SRNDKBtJJYR BnnYIWDKOBSNJwFHI5Ixpn/GCD5OkIc0P7uDh6wrv4aVHJajH1wz+pga6LaG0x6SDnTS o6nKtWnsOJItcXFb5yoJeTWZxvhrRrxB6yeJazC4dkTTORmpkyZPKu9hKxiRxrsmnzAL hHFg== X-Gm-Message-State: ACrzQf0MLZg+2uigmot/qjZdRn4bmtpB1xBPIXaknbC35OWVsQgTiTFd xINPwdJCUuVwf5+HNZxG5wX/OQ== X-Google-Smtp-Source: AMsMyM49ojpZ4NtZ85F+TDgqbi78KCnusmOwNYbyav9onsrplQqsvWMs9fDUxMB0WWpzSU7jT/Hz2A== X-Received: by 2002:a05:6638:3286:b0:349:fd14:7af6 with SMTP id f6-20020a056638328600b00349fd147af6mr3165876jav.48.1663885265001; Thu, 22 Sep 2022 15:21:05 -0700 (PDT) Received: from localhost.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id g12-20020a92d7cc000000b002f592936fbfsm2483332ilq.41.2022.09.22.15.21.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Sep 2022 15:21:04 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: mka@chromium.org, evgreen@chromium.org, andersson@kernel.org, quic_cpratapa@quicinc.com, quic_avuyyuru@quicinc.com, quic_jponduru@quicinc.com, quic_subashab@quicinc.com, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 1/8] net: ipa: don't use u32p_replace_bits() Date: Thu, 22 Sep 2022 17:20:53 -0500 Message-Id: <20220922222100.2543621-2-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220922222100.2543621-1-elder@linaro.org> References: <20220922222100.2543621-1-elder@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In two spots we use u32_replace_bits() to replace a set of bits in a register while preserving the rest. Both of those cases just zero the bits being replaced, and this can be done more simply without using that function. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_table.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ipa/ipa_table.c b/drivers/net/ipa/ipa_table.c index 69efe672ca528..037cec2fd5942 100644 --- a/drivers/net/ipa/ipa_table.c +++ b/drivers/net/ipa/ipa_table.c @@ -524,7 +524,7 @@ static void ipa_filter_tuple_zero(struct ipa_endpoint *= endpoint) val =3D ioread32(endpoint->ipa->reg_virt + offset); =20 /* Zero all filter-related fields, preserving the rest */ - u32p_replace_bits(&val, 0, IPA_REG_ENDP_FILTER_HASH_MSK_ALL); + val &=3D ~IPA_REG_ENDP_FILTER_HASH_MSK_ALL; =20 iowrite32(val, endpoint->ipa->reg_virt + offset); } @@ -571,7 +571,7 @@ static void ipa_route_tuple_zero(struct ipa *ipa, u32 r= oute_id) val =3D ioread32(ipa->reg_virt + offset); =20 /* Zero all route-related fields, preserving the rest */ - u32p_replace_bits(&val, 0, IPA_REG_ENDP_ROUTER_HASH_MSK_ALL); + val &=3D ~IPA_REG_ENDP_ROUTER_HASH_MSK_ALL; =20 iowrite32(val, ipa->reg_virt + offset); } --=20 2.34.1 From nobody Thu Apr 2 15:02:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE913ECAAD8 for ; Thu, 22 Sep 2022 22:21:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229901AbiIVWVV (ORCPT ); Thu, 22 Sep 2022 18:21:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230475AbiIVWVJ (ORCPT ); Thu, 22 Sep 2022 18:21:09 -0400 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA5FC10D65C for ; Thu, 22 Sep 2022 15:21:06 -0700 (PDT) Received: by mail-io1-xd34.google.com with SMTP id r134so8955739iod.8 for ; Thu, 22 Sep 2022 15:21:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=fOJuWqvAnwdqxCGdTOZjQMpso1NiM0QWWLIjlpoN+6A=; b=X4dwlDiBTpCjHyEP+isay760jMKIQNVLRCK/TCTHNXBq/pSvWGHr/2bAOfDG09UWVt jduT5Dh0VTNoVz7NxirfDrYW7qg+6XJyPxRPqtiIaGBDiUVhd2hbg48Q7aLy/sNNiTIx KtUM1lUnA62uSAIEH4RWvmaUhuxC7xCcysdGQKMv9WjNJWMzzLpgjTJnIPsnI5u0aeG0 wOct/PFsjmKRDmegnOvpQMBSGiJYenuqxw2kbMRGpFsDs613bAYGpLi+8YyHMlUxRbkM bXQuG0CFHlLtQzUa2KLYqQ+kPVAYk5vQhyH2yMo/08xmCcyVULot3+2m8HkGGLuNKLS4 4t7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=fOJuWqvAnwdqxCGdTOZjQMpso1NiM0QWWLIjlpoN+6A=; b=hSivbvQUl2qmZG9oENElfVeWqgETvrG/EQjmG6RO31Vlg+Zx3TneCOwLC1nvR/UVbX GNAk2wPdCjVncXZzTh7A/TPOcw+wgtbQToOu1S+yrUkabgIIfYOitaHrNWMZK4fI2X0P rkWiE+4wJUBBXGHyBy/x8Q3+mPVjMWsWvgGjT5FhtVLbHFi2Zb69OuwlSZmNlXq/FrIg g9rmb+u26hWxWnZMbmsznfRfOkOr8BtHtr/W9R53niug+d8iAbCjCHbqW0rxUKCV5SXU QWwHO2oR4O70YF29S+33innOnJ8wLwplBLwO1PbXQ9x55dUL/2SdvmINWAxJd98p2PST PSsw== X-Gm-Message-State: ACrzQf1bENakVor6Ld6tQOtm9gzHomcPl45XJEr/l6N2UR05JoCsqFl5 eQw3bD2GXtve0aTfQVUH+GFSow== X-Google-Smtp-Source: AMsMyM5PHtyZKk/jZ5bXHhlQmYH/5oF2MoMvcVRqC2j9oJ2D1U0AQOz4HOQ7q55j4k+WM+K+fsn0aQ== X-Received: by 2002:a05:6638:26f:b0:35a:bc20:41f2 with SMTP id x15-20020a056638026f00b0035abc2041f2mr3229899jaq.121.1663885266030; Thu, 22 Sep 2022 15:21:06 -0700 (PDT) Received: from localhost.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id g12-20020a92d7cc000000b002f592936fbfsm2483332ilq.41.2022.09.22.15.21.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Sep 2022 15:21:05 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: mka@chromium.org, evgreen@chromium.org, andersson@kernel.org, quic_cpratapa@quicinc.com, quic_avuyyuru@quicinc.com, quic_jponduru@quicinc.com, quic_subashab@quicinc.com, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 2/8] net: ipa: introduce ipa_qtime_val() Date: Thu, 22 Sep 2022 17:20:54 -0500 Message-Id: <20220922222100.2543621-3-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220922222100.2543621-1-elder@linaro.org> References: <20220922222100.2543621-1-elder@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Create a new function ipa_qtime_val() which returns a value that indicates what should be encoded for a register with a time field expressed using Qtime. Use it to factor out common code in aggr_time_limit_encoded() and hol_block_timer_qtime_val(). Rename aggr_time_limit_encoded() and hol_block_timer_qtime_val() so their names are both verbs ending in "encode". Rename the "limit" argument to the former to be "milliseconds" for consistency. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_endpoint.c | 80 +++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 36 deletions(-) diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index fe0eb882104ee..7d91b423a1be7 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -725,17 +725,42 @@ static u32 aggr_byte_limit_encoded(enum ipa_version v= ersion, u32 limit) return u32_encode_bits(limit, aggr_byte_limit_fmask(false)); } =20 +/* For IPA v4.5+, times are expressed using Qtime. The AP uses one of two + * pulse generators (0 and 1) to measure elapsed time. In ipa_qtime_confi= g() + * they're configured to have granularity 100 usec and 1 msec, respectivel= y. + * + * The return value is the positive or negative Qtime value to use to + * express the (microsecond) time provided. A positive return value + * means pulse generator 0 can be used; otherwise use pulse generator 1. + */ +static int ipa_qtime_val(u32 microseconds, u32 max) +{ + u32 val; + + /* Use 100 microsecond granularity if possible */ + val =3D DIV_ROUND_CLOSEST(microseconds, 100); + if (val <=3D max) + return (int)val; + + /* Have to use pulse generator 1 (millisecond granularity) */ + val =3D DIV_ROUND_CLOSEST(microseconds, 1000); + WARN_ON(val > max); + + return (int)-val; +} + /* Encode the aggregation timer limit (microseconds) based on IPA version = */ -static u32 aggr_time_limit_encoded(enum ipa_version version, u32 limit) +static u32 aggr_time_limit_encode(enum ipa_version version, u32 microsecon= ds) { u32 gran_sel; u32 fmask; u32 val; + int ret; =20 if (version < IPA_VERSION_4_5) { /* We set aggregation granularity in ipa_hardware_config() */ fmask =3D aggr_time_limit_fmask(true); - val =3D DIV_ROUND_CLOSEST(limit, IPA_AGGR_GRANULARITY); + val =3D DIV_ROUND_CLOSEST(microseconds, IPA_AGGR_GRANULARITY); WARN(val > field_max(fmask), "aggr_time_limit too large (%u > %u usec)\n", val, field_max(fmask) * IPA_AGGR_GRANULARITY); @@ -743,23 +768,14 @@ static u32 aggr_time_limit_encoded(enum ipa_version v= ersion, u32 limit) return u32_encode_bits(val, fmask); } =20 - /* IPA v4.5 expresses the time limit using Qtime. The AP has - * pulse generators 0 and 1 available, which were configured - * in ipa_qtime_config() to have granularity 100 usec and - * 1 msec, respectively. Use pulse generator 0 if possible, - * otherwise fall back to pulse generator 1. - */ + /* Compute the Qtime limit value to use */ fmask =3D aggr_time_limit_fmask(false); - val =3D DIV_ROUND_CLOSEST(limit, 100); - if (val > field_max(fmask)) { - /* Have to use pulse generator 1 (millisecond granularity) */ + ret =3D ipa_qtime_val(microseconds, field_max(fmask)); + if (ret < 0) { + val =3D -ret; gran_sel =3D AGGR_GRAN_SEL_FMASK; - val =3D DIV_ROUND_CLOSEST(limit, 1000); - WARN(val > field_max(fmask), - "aggr_time_limit too large (%u > %u usec)\n", - limit, field_max(fmask) * 1000); } else { - /* We can use pulse generator 0 (100 usec granularity) */ + val =3D ret; gran_sel =3D 0; } =20 @@ -799,7 +815,7 @@ static void ipa_endpoint_init_aggr(struct ipa_endpoint = *endpoint) val |=3D aggr_byte_limit_encoded(version, limit); =20 limit =3D rx_config->aggr_time_limit; - val |=3D aggr_time_limit_encoded(version, limit); + val |=3D aggr_time_limit_encode(version, limit); =20 /* AGGR_PKT_LIMIT is 0 (unlimited) */ =20 @@ -825,24 +841,18 @@ static void ipa_endpoint_init_aggr(struct ipa_endpoin= t *endpoint) * represents the given number of microseconds. The result * includes both the timer value and the selected timer granularity. */ -static u32 hol_block_timer_qtime_val(struct ipa *ipa, u32 microseconds) +static u32 hol_block_timer_qtime_encode(struct ipa *ipa, u32 microseconds) { u32 gran_sel; u32 val; + int ret; =20 - /* IPA v4.5 expresses time limits using Qtime. The AP has - * pulse generators 0 and 1 available, which were configured - * in ipa_qtime_config() to have granularity 100 usec and - * 1 msec, respectively. Use pulse generator 0 if possible, - * otherwise fall back to pulse generator 1. - */ - val =3D DIV_ROUND_CLOSEST(microseconds, 100); - if (val > field_max(TIME_LIMIT_FMASK)) { - /* Have to use pulse generator 1 (millisecond granularity) */ + ret =3D ipa_qtime_val(microseconds, field_max(TIME_LIMIT_FMASK)); + if (ret < 0) { + val =3D -ret; gran_sel =3D GRAN_SEL_FMASK; - val =3D DIV_ROUND_CLOSEST(microseconds, 1000); } else { - /* We can use pulse generator 0 (100 usec granularity) */ + val =3D ret; gran_sel =3D 0; } =20 @@ -854,12 +864,10 @@ static u32 hol_block_timer_qtime_val(struct ipa *ipa,= u32 microseconds) * derived from the 19.2 MHz SoC XO clock. For older IPA versions * each tick represents 128 cycles of the IPA core clock. * - * Return the encoded value that should be written to that register - * that represents the timeout period provided. For IPA v4.2 this - * encodes a base and scale value, while for earlier versions the - * value is a simple tick count. + * Return the encoded value representing the timeout period provided + * that should be written to the ENDP_INIT_HOL_BLOCK_TIMER register. */ -static u32 hol_block_timer_val(struct ipa *ipa, u32 microseconds) +static u32 hol_block_timer_encode(struct ipa *ipa, u32 microseconds) { u32 width; u32 scale; @@ -872,7 +880,7 @@ static u32 hol_block_timer_val(struct ipa *ipa, u32 mic= roseconds) return 0; /* Nothing to compute if timer period is 0 */ =20 if (ipa->version >=3D IPA_VERSION_4_5) - return hol_block_timer_qtime_val(ipa, microseconds); + return hol_block_timer_qtime_encode(ipa, microseconds); =20 /* Use 64 bit arithmetic to avoid overflow... */ rate =3D ipa_core_clock_rate(ipa); @@ -920,7 +928,7 @@ static void ipa_endpoint_init_hol_block_timer(struct ip= a_endpoint *endpoint, =20 /* This should only be changed when HOL_BLOCK_EN is disabled */ offset =3D IPA_REG_ENDP_INIT_HOL_BLOCK_TIMER_N_OFFSET(endpoint_id); - val =3D hol_block_timer_val(ipa, microseconds); + val =3D hol_block_timer_encode(ipa, microseconds); iowrite32(val, ipa->reg_virt + offset); } =20 --=20 2.34.1 From nobody Thu Apr 2 15:02:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A578AC6FA8B for ; Thu, 22 Sep 2022 22:21:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231506AbiIVWV0 (ORCPT ); Thu, 22 Sep 2022 18:21:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231244AbiIVWVJ (ORCPT ); Thu, 22 Sep 2022 18:21:09 -0400 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A4D510E5DB for ; Thu, 22 Sep 2022 15:21:08 -0700 (PDT) Received: by mail-io1-xd2d.google.com with SMTP id q83so8964318iod.7 for ; Thu, 22 Sep 2022 15:21:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=xmsMzMwZV5ZOovBFH/X4I+q5eM58vu3t0RCGdrrJ4lo=; b=lwk5GNqrV4OxPP8qp73gshHXz55xffiQpviZS/ZOTCHHSNl65LvN3ggIYjmO5dCpLr Fs1n4D/MTlA9unQWakS2OsQZLJmgrDzJlQuYZwJ1a0+EFAVmYQ7HYjS6FbCFrUArfl8X CMqugiEzrmfX607XfSUB+NyuToRFg6KRA9OZ/ccE6GfqynlnZVkyhZA8Q0dsmDRaZ5kf m6GsxFiPKivasjIfTp65t4GxlIIZFMawNtLhYaV53HxpcCIBdCrSuVKmkeyedfxLqJ8j rl1kTPr6Ju25tooQeuv9p+vESpBHaWcPAsbikY3DWOzNUVMV7IiKd/wShKcDGbI5pKro psuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=xmsMzMwZV5ZOovBFH/X4I+q5eM58vu3t0RCGdrrJ4lo=; b=mlhnzLQ45DYELt52sP01FTwjwSdbzK3HsI5xFaPZvqNFD//p2jnqqefPS2Owti5H4D tw25IAL9iUJgdnZfnLcJpY/iAl5ESMvckHHXJasafvcseNezUyG0TmGHsizGyoizdJDy tnafE4h1FdGPTYeG9lMi8RXlI9gmDZkjDTcOsSTXQRUoSRs7XsK+Ns32/eytHjLvf5G6 i3LnIFy40lVf1hQvCZSEjItPkOlOATmeqPMEVJLB3k5xZV0qz6IkRohn720lhN3zFJ3a XrV0UZDR/hjxeQcpg3vWqVyo3rwM1Knrn/bP4ShXMhXlnt/5XARva12iaz3RemEntbiR CcUg== X-Gm-Message-State: ACrzQf3X4soXbbZValqkQWef8AbwY/TAfbJkg8JG1ySk+cfj6G1w0DEM 8O90+nQFESzhyyDFIu2TK5jHMQ== X-Google-Smtp-Source: AMsMyM7C9xX0hkqYnTdMkfO0HNRWwamhjwDGRl38P9k/ct9i5H95W9s0SYARVEP+o9wrJgr8JAKAuA== X-Received: by 2002:a6b:b28b:0:b0:6a1:eb9e:bf62 with SMTP id b133-20020a6bb28b000000b006a1eb9ebf62mr2577093iof.87.1663885267395; Thu, 22 Sep 2022 15:21:07 -0700 (PDT) Received: from localhost.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id g12-20020a92d7cc000000b002f592936fbfsm2483332ilq.41.2022.09.22.15.21.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Sep 2022 15:21:06 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: mka@chromium.org, evgreen@chromium.org, andersson@kernel.org, quic_cpratapa@quicinc.com, quic_avuyyuru@quicinc.com, quic_jponduru@quicinc.com, quic_subashab@quicinc.com, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 3/8] net: ipa: rearrange functions for similarity Date: Thu, 22 Sep 2022 17:20:55 -0500 Message-Id: <20220922222100.2543621-4-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220922222100.2543621-1-elder@linaro.org> References: <20220922222100.2543621-1-elder@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Both aggr_time_limit_encode() and hol_block_timer_encode() figure out how to encode a millisecond time value so it can be programmed into a register. Rearranging them a bit can make their similarity more obvious, with both taking essentially the same form. To do this: - Return 0 immediately in aggr_time_limit_encode() if the microseconds value supplied is zero. - Reverse the test at top of aggr_time_limit_encode(), so we compute and return the Qtime value in the "true" block, and compute the result the old way otherwise. - Open-code (and eliminate) hol_block_timer_qtime_encode() at the top of hol_block_timer_encode() in the case we use Qtimer. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_endpoint.c | 86 ++++++++++++++++------------------ 1 file changed, 41 insertions(+), 45 deletions(-) diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index 7d91b423a1be7..6db62b6fb6632 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -752,34 +752,38 @@ static int ipa_qtime_val(u32 microseconds, u32 max) /* Encode the aggregation timer limit (microseconds) based on IPA version = */ static u32 aggr_time_limit_encode(enum ipa_version version, u32 microsecon= ds) { - u32 gran_sel; u32 fmask; u32 val; - int ret; =20 - if (version < IPA_VERSION_4_5) { - /* We set aggregation granularity in ipa_hardware_config() */ - fmask =3D aggr_time_limit_fmask(true); - val =3D DIV_ROUND_CLOSEST(microseconds, IPA_AGGR_GRANULARITY); - WARN(val > field_max(fmask), - "aggr_time_limit too large (%u > %u usec)\n", - val, field_max(fmask) * IPA_AGGR_GRANULARITY); + if (!microseconds) + return 0; /* Nothing to compute if time limit is 0 */ =20 - return u32_encode_bits(val, fmask); - } + if (version >=3D IPA_VERSION_4_5) { + u32 gran_sel; + int ret; + + /* Compute the Qtime limit value to use */ + fmask =3D aggr_time_limit_fmask(false); + ret =3D ipa_qtime_val(microseconds, field_max(fmask)); + if (ret < 0) { + val =3D -ret; + gran_sel =3D AGGR_GRAN_SEL_FMASK; + } else { + val =3D ret; + gran_sel =3D 0; + } =20 - /* Compute the Qtime limit value to use */ - fmask =3D aggr_time_limit_fmask(false); - ret =3D ipa_qtime_val(microseconds, field_max(fmask)); - if (ret < 0) { - val =3D -ret; - gran_sel =3D AGGR_GRAN_SEL_FMASK; - } else { - val =3D ret; - gran_sel =3D 0; + return gran_sel | u32_encode_bits(val, fmask); } =20 - return gran_sel | u32_encode_bits(val, fmask); + /* We set aggregation granularity in ipa_hardware_config() */ + fmask =3D aggr_time_limit_fmask(true); + val =3D DIV_ROUND_CLOSEST(microseconds, IPA_AGGR_GRANULARITY); + WARN(val > field_max(fmask), + "aggr_time_limit too large (%u > %u usec)\n", + val, field_max(fmask) * IPA_AGGR_GRANULARITY); + + return u32_encode_bits(val, fmask); } =20 static u32 aggr_sw_eof_active_encoded(enum ipa_version version, bool enabl= ed) @@ -837,28 +841,6 @@ static void ipa_endpoint_init_aggr(struct ipa_endpoint= *endpoint) iowrite32(val, endpoint->ipa->reg_virt + offset); } =20 -/* Return the Qtime-based head-of-line blocking timer value that - * represents the given number of microseconds. The result - * includes both the timer value and the selected timer granularity. - */ -static u32 hol_block_timer_qtime_encode(struct ipa *ipa, u32 microseconds) -{ - u32 gran_sel; - u32 val; - int ret; - - ret =3D ipa_qtime_val(microseconds, field_max(TIME_LIMIT_FMASK)); - if (ret < 0) { - val =3D -ret; - gran_sel =3D GRAN_SEL_FMASK; - } else { - val =3D ret; - gran_sel =3D 0; - } - - return gran_sel | u32_encode_bits(val, TIME_LIMIT_FMASK); -} - /* The head-of-line blocking timer is defined as a tick count. For * IPA version 4.5 the tick count is based on the Qtimer, which is * derived from the 19.2 MHz SoC XO clock. For older IPA versions @@ -879,8 +861,22 @@ static u32 hol_block_timer_encode(struct ipa *ipa, u32= microseconds) if (!microseconds) return 0; /* Nothing to compute if timer period is 0 */ =20 - if (ipa->version >=3D IPA_VERSION_4_5) - return hol_block_timer_qtime_encode(ipa, microseconds); + if (ipa->version >=3D IPA_VERSION_4_5) { + u32 gran_sel; + int ret; + + /* Compute the Qtime limit value to use */ + ret =3D ipa_qtime_val(microseconds, field_max(TIME_LIMIT_FMASK)); + if (ret < 0) { + val =3D -ret; + gran_sel =3D GRAN_SEL_FMASK; + } else { + val =3D ret; + gran_sel =3D 0; + } + + return gran_sel | u32_encode_bits(val, TIME_LIMIT_FMASK); + } =20 /* Use 64 bit arithmetic to avoid overflow... */ rate =3D ipa_core_clock_rate(ipa); --=20 2.34.1 From nobody Thu Apr 2 15:02:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C9FEECAAD8 for ; Thu, 22 Sep 2022 22:21:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230220AbiIVWVa (ORCPT ); Thu, 22 Sep 2022 18:21:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231462AbiIVWVL (ORCPT ); Thu, 22 Sep 2022 18:21:11 -0400 Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5071010CA43 for ; Thu, 22 Sep 2022 15:21:09 -0700 (PDT) Received: by mail-il1-x130.google.com with SMTP id g6so5660033ild.6 for ; Thu, 22 Sep 2022 15:21:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=DxN4skl57Ip6n+jQkYaK3Z/OC9a58fagmXeHv9SstKE=; b=f0OWnnq6haiADOzRDBqpglUAw/QpO4xOSvS3uO0z1+eiKD+5DAD3rZnm/JJk59CXRm X6xN/ft/h8HudpguVdNk2QVteTUI6i8v8JMR+QtxwczYFdjLtq5gZhsDmPrTa9G765/t Ml7/fJl1fRpeJX5ZLKbtnVuUrNlhy6VZTn4t1yyc0MwK6CEGy44OmNCazBi3amkgrvBt FKstrxkA9mPmpUmc2k++YqQXqcbaY7G6QbalvnPQAWG3/aME/dKu20T+rnSUtHGL3K5I WLH3k6YKaayPZbhryrz7ZFuUrcQcuR+kgo/oDe3aQt1mlUS2QjX7vTHICmpmOIgtIcF/ 7Q9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=DxN4skl57Ip6n+jQkYaK3Z/OC9a58fagmXeHv9SstKE=; b=T2AwAzUs7+3Oys8HwKc1ovOIQZj9on6EciVbZhb080Jk5Lx3E5/y5gAm7JiEBmuzf5 AVm0K56rDQkfRefQ/hhecNadAqy3DAKYtvFLuWNQ3yGTSOdteth77ShSX22vv3o/5Qv4 yOLMFPFPO+oomFnbuuef7mM025Fw4B2Znq2OaeoOQQsAod5M0Tkg/4f6TNb9Bphu7hjZ QjXLK/4RgqMqyOD/IL+Vso1I/4UaHbgZ19qqI2Sd8vURglOZR90i5Qi8i85dkAncAcFa 07fyxFKnUH6qq5GfBwsyQY7rjOboZDafWesG0nUVApO4mbFpdlVEcYjeGwUKFqikzReK QIkg== X-Gm-Message-State: ACrzQf3+TW5K5DO6GFZqFxgY7tN02WQnq5g9/au4LG7dt08qXNBeq5cQ rILnsdCCm/nT94F6JvITsbOaMw== X-Google-Smtp-Source: AMsMyM55tKcBQjxn0AOH07fVF51W4vb3otwirDCFcdPawDCpeJ6Vc4rJGLjSXT1CSbwHYRmVRlqQrw== X-Received: by 2002:a05:6e02:1c24:b0:2f6:2fae:a4b with SMTP id m4-20020a056e021c2400b002f62fae0a4bmr2929727ilh.131.1663885268500; Thu, 22 Sep 2022 15:21:08 -0700 (PDT) Received: from localhost.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id g12-20020a92d7cc000000b002f592936fbfsm2483332ilq.41.2022.09.22.15.21.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Sep 2022 15:21:08 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: mka@chromium.org, evgreen@chromium.org, andersson@kernel.org, quic_cpratapa@quicinc.com, quic_avuyyuru@quicinc.com, quic_jponduru@quicinc.com, quic_subashab@quicinc.com, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 4/8] net: ipa: define BCR values using an enum Date: Thu, 22 Sep 2022 17:20:56 -0500 Message-Id: <20220922222100.2543621-5-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220922222100.2543621-1-elder@linaro.org> References: <20220922222100.2543621-1-elder@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The backward compatibility register (BCR) has a set of bit flags that indicate ways in which the IPA hardware should operate in a backward compatible way. The register is not supported starting with IPA v4.5, and where it is supported, defined bits all have the same numeric value. Redefine these flags using an enumerated type, with each member's value representing the bit position that encodes it in the BCR. This replaces all of the single-bit field masks previously defined. Signed-off-by: Alex Elder --- drivers/net/ipa/data/ipa_data-v3.1.c | 2 +- drivers/net/ipa/data/ipa_data-v3.5.1.c | 10 +++++----- drivers/net/ipa/ipa_reg.h | 26 ++++++++++++-------------- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/drivers/net/ipa/data/ipa_data-v3.1.c b/drivers/net/ipa/data/ip= a_data-v3.1.c index 1c1895aea8118..e0d71f6092729 100644 --- a/drivers/net/ipa/data/ipa_data-v3.1.c +++ b/drivers/net/ipa/data/ipa_data-v3.1.c @@ -526,7 +526,7 @@ static const struct ipa_power_data ipa_power_data =3D { /* Configuration data for an SoC having IPA v3.1 */ const struct ipa_data ipa_data_v3_1 =3D { .version =3D IPA_VERSION_3_1, - .backward_compat =3D BCR_CMDQ_L_LACK_ONE_ENTRY_FMASK, + .backward_compat =3D BIT(BCR_CMDQ_L_LACK_ONE_ENTRY), .qsb_count =3D ARRAY_SIZE(ipa_qsb_data), .qsb_data =3D ipa_qsb_data, .endpoint_count =3D ARRAY_SIZE(ipa_gsi_endpoint_data), diff --git a/drivers/net/ipa/data/ipa_data-v3.5.1.c b/drivers/net/ipa/data/= ipa_data-v3.5.1.c index 58b708d2fc75d..383ef18900654 100644 --- a/drivers/net/ipa/data/ipa_data-v3.5.1.c +++ b/drivers/net/ipa/data/ipa_data-v3.5.1.c @@ -407,11 +407,11 @@ static const struct ipa_power_data ipa_power_data =3D= { /* Configuration data for an SoC having IPA v3.5.1 */ const struct ipa_data ipa_data_v3_5_1 =3D { .version =3D IPA_VERSION_3_5_1, - .backward_compat =3D BCR_CMDQ_L_LACK_ONE_ENTRY_FMASK | - BCR_TX_NOT_USING_BRESP_FMASK | - BCR_SUSPEND_L2_IRQ_FMASK | - BCR_HOLB_DROP_L2_IRQ_FMASK | - BCR_DUAL_TX_FMASK, + .backward_compat =3D BIT(BCR_CMDQ_L_LACK_ONE_ENTRY) | + BIT(BCR_TX_NOT_USING_BRESP) | + BIT(BCR_SUSPEND_L2_IRQ) | + BIT(BCR_HOLB_DROP_L2_IRQ) | + BIT(BCR_DUAL_TX), .qsb_count =3D ARRAY_SIZE(ipa_qsb_data), .qsb_data =3D ipa_qsb_data, .endpoint_count =3D ARRAY_SIZE(ipa_gsi_endpoint_data), diff --git a/drivers/net/ipa/ipa_reg.h b/drivers/net/ipa/ipa_reg.h index 3e24bddc682ef..2aa1d1dd0adf5 100644 --- a/drivers/net/ipa/ipa_reg.h +++ b/drivers/net/ipa/ipa_reg.h @@ -220,20 +220,18 @@ static inline u32 ipa_reg_state_aggr_active_offset(en= um ipa_version version) =20 /* The next register is not present for IPA v4.5+ */ #define IPA_REG_BCR_OFFSET 0x000001d0 -/* 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) -/* The next field is invalid for IPA v4.0+ */ -#define BCR_TX_SUSPEND_IRQ_ASSERT_ONCE_FMASK GENMASK(2, 2) -/* The next two fields are not present for IPA v4.2+ */ -#define BCR_SUSPEND_L2_IRQ_FMASK GENMASK(3, 3) -#define BCR_HOLB_DROP_L2_IRQ_FMASK GENMASK(4, 4) -/* The next five fields are present for IPA v3.5+ */ -#define BCR_DUAL_TX_FMASK GENMASK(5, 5) -#define BCR_ENABLE_FILTER_DATA_CACHE_FMASK GENMASK(6, 6) -#define BCR_NOTIF_PRIORITY_OVER_ZLT_FMASK GENMASK(7, 7) -#define BCR_FILTER_PREFETCH_EN_FMASK GENMASK(8, 8) -#define BCR_ROUTER_PREFETCH_EN_FMASK GENMASK(9, 9) +enum ipa_bcr_compat { + BCR_CMDQ_L_LACK_ONE_ENTRY =3D 0x0, /* Not IPA v4.2+ */ + BCR_TX_NOT_USING_BRESP =3D 0x1, /* Not IPA v4.2+ */ + BCR_TX_SUSPEND_IRQ_ASSERT_ONCE =3D 0x2, /* Not IPA v4.0+ */ + BCR_SUSPEND_L2_IRQ =3D 0x3, /* Not IPA v4.2+ */ + BCR_HOLB_DROP_L2_IRQ =3D 0x4, /* Not IPA v4.2+ */ + BCR_DUAL_TX =3D 0x5, /* IPA v3.5+ */ + BCR_ENABLE_FILTER_DATA_CACHE =3D 0x6, /* IPA v3.5+ */ + BCR_NOTIF_PRIORITY_OVER_ZLT =3D 0x7, /* IPA v3.5+ */ + BCR_FILTER_PREFETCH_EN =3D 0x8, /* IPA v3.5+ */ + BCR_ROUTER_PREFETCH_EN =3D 0x9, /* IPA v3.5+ */ +}; =20 /* 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 --=20 2.34.1 From nobody Thu Apr 2 15:02:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 160FDC54EE9 for ; Thu, 22 Sep 2022 22:21:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230475AbiIVWVg (ORCPT ); Thu, 22 Sep 2022 18:21:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231322AbiIVWVL (ORCPT ); Thu, 22 Sep 2022 18:21:11 -0400 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04A5610D0F0 for ; Thu, 22 Sep 2022 15:21:10 -0700 (PDT) Received: by mail-io1-xd34.google.com with SMTP id e205so8983553iof.1 for ; Thu, 22 Sep 2022 15:21:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=ybkiqrZQo1QQIIoJIKPprmgORGixQ/ko91UWMUF73QQ=; b=xl+nH3bUaprBGonS7kXU93KnO2b7BCackcckjSOJRZcmqJAbaeTG8ZW86oMIPTecaV MRqmdCMhfsqZeiPHL1tTo3H4NdZb7Segq+s/qzVE34mGNQ21285Jq2uHqbzJ9mhkft48 xBLncLgFx0jLAGAQs9rRIo0wjFSyO8+E7uZmMZHCymMfHkuM7PnRC5j+N1rgwSuQW73I eMgYQR/n6vf+6vO5nhMMyIcUSEOJdN6J+n4FvGTpi0jlzl+nrZOgPY5/kOV88NyWxIEM oIB4fVmlvXEL8CHdAI7kM3RRdH5T7xYkwRHb2jn3lxsUsrA3yM5KseOXyxDqnkIX5sFI z/Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=ybkiqrZQo1QQIIoJIKPprmgORGixQ/ko91UWMUF73QQ=; b=pcmKoU5npqWVk1mZyUglFxdPd2jabYS40DR0DbHW2LHeDzaUMFLJfRuY8hhhP3Fq/d 0y/B4W9mmezumhqZhCDwO8TRpuObuVfNXWrjxweWd+S1gz0mYuFjDxJCIHpD6Z+OJY3M lnDBuP0fQ9qIFn5qWaDtLLmcAsR/9JtuThAs8iVuZZmeExMdQDc5cylsZTikmp7+q9q7 y2J6b/Dgos7gbJ0aScBdTm7fHEwWstr5wrBo9aIuTdeK0LpxuXFF89UvIz/TI9krf1XL 5lgZG/488H/0VbMdcN6xGElr0601cA+jOeL3saY5ihDh5Vld9Q90HxTV5kAGZqJoM/1S 2syw== X-Gm-Message-State: ACrzQf2iQWYRSe6mAE0SFD0RRhGtCbKAlr67SMBMgkzzoUiErQgC/Z0T hI0ih/eZcBycInJD3tBxmBWwzA== X-Google-Smtp-Source: AMsMyM5XuMdSWispqeU7nZFRD2uSSOXQmr3nsXfL3q/EZwlHAFlAMFgMgQYR16/dHVeKj4SCDtDPTQ== X-Received: by 2002:a05:6602:1551:b0:6a1:6852:baa7 with SMTP id h17-20020a056602155100b006a16852baa7mr2607864iow.48.1663885269717; Thu, 22 Sep 2022 15:21:09 -0700 (PDT) Received: from localhost.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id g12-20020a92d7cc000000b002f592936fbfsm2483332ilq.41.2022.09.22.15.21.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Sep 2022 15:21:09 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: mka@chromium.org, evgreen@chromium.org, andersson@kernel.org, quic_cpratapa@quicinc.com, quic_avuyyuru@quicinc.com, quic_jponduru@quicinc.com, quic_subashab@quicinc.com, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 5/8] net: ipa: tidy up register enum definitions Date: Thu, 22 Sep 2022 17:20:57 -0500 Message-Id: <20220922222100.2543621-6-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220922222100.2543621-1-elder@linaro.org> References: <20220922222100.2543621-1-elder@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Update a few enumerated type definitions in "ipa_reg.h" so that the values assigned to each member align on the same column. Where a "TX" or "RX" (or both) comment is present, move that annotation into a separate comment between the member name and its value. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_reg.h | 42 +++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/net/ipa/ipa_reg.h b/drivers/net/ipa/ipa_reg.h index 2aa1d1dd0adf5..f593cf3187950 100644 --- a/drivers/net/ipa/ipa_reg.h +++ b/drivers/net/ipa/ipa_reg.h @@ -363,10 +363,10 @@ enum ipa_pulse_gran { =20 /** enum ipa_cs_offload_en - ENDP_INIT_CFG register CS_OFFLOAD_EN field va= lue */ enum ipa_cs_offload_en { - IPA_CS_OFFLOAD_NONE =3D 0x0, - IPA_CS_OFFLOAD_UL =3D 0x1, /* Before IPA v4.5 (TX) */ - IPA_CS_OFFLOAD_DL =3D 0x2, /* Before IPA v4.5 (RX) */ - IPA_CS_OFFLOAD_INLINE =3D 0x1, /* IPA v4.5 (TX and RX) */ + IPA_CS_OFFLOAD_NONE =3D 0x0, + IPA_CS_OFFLOAD_UL /* TX */ =3D 0x1, /* Not IPA v4.5+ */ + IPA_CS_OFFLOAD_DL /* RX */ =3D 0x2, /* Not IPA v4.5+ */ + IPA_CS_OFFLOAD_INLINE /* TX and RX */ =3D 0x1, /* IPA v4.5+ */ }; =20 /* Valid only for TX (IPA consumer) endpoints */ @@ -376,9 +376,9 @@ enum ipa_cs_offload_en { =20 /** enum ipa_nat_en - ENDP_INIT_NAT register NAT_EN field value */ enum ipa_nat_en { - IPA_NAT_BYPASS =3D 0x0, - IPA_NAT_SRC =3D 0x1, - IPA_NAT_DST =3D 0x2, + IPA_NAT_BYPASS =3D 0x0, + IPA_NAT_SRC =3D 0x1, + IPA_NAT_DST =3D 0x2, }; =20 #define IPA_REG_ENDP_INIT_HDR_N_OFFSET(ep) \ @@ -472,10 +472,10 @@ static inline u32 ipa_metadata_offset_encoded(enum ip= a_version version, =20 /** enum ipa_mode - ENDP_INIT_MODE register MODE field value */ enum ipa_mode { - IPA_BASIC =3D 0x0, - IPA_ENABLE_FRAMING_HDLC =3D 0x1, - IPA_ENABLE_DEFRAMING_HDLC =3D 0x2, - IPA_DMA =3D 0x3, + IPA_BASIC =3D 0x0, + IPA_ENABLE_FRAMING_HDLC =3D 0x1, + IPA_ENABLE_DEFRAMING_HDLC =3D 0x2, + IPA_DMA =3D 0x3, }; =20 #define IPA_REG_ENDP_INIT_AGGR_N_OFFSET(ep) \ @@ -524,20 +524,20 @@ static inline u32 aggr_hard_byte_limit_enable_fmask(b= ool legacy) =20 /** enum ipa_aggr_en - ENDP_INIT_AGGR register AGGR_EN field value */ enum ipa_aggr_en { - IPA_BYPASS_AGGR =3D 0x0, /* (TX, RX) */ - IPA_ENABLE_AGGR =3D 0x1, /* (RX) */ - IPA_ENABLE_DEAGGR =3D 0x2, /* (TX) */ + IPA_BYPASS_AGGR /* TX and RX */ =3D 0x0, + IPA_ENABLE_AGGR /* RX */ =3D 0x1, + IPA_ENABLE_DEAGGR /* TX */ =3D 0x2, }; =20 /** enum ipa_aggr_type - ENDP_INIT_AGGR register AGGR_TYPE field value */ enum ipa_aggr_type { - IPA_MBIM_16 =3D 0x0, - IPA_HDLC =3D 0x1, - IPA_TLP =3D 0x2, - IPA_RNDIS =3D 0x3, - IPA_GENERIC =3D 0x4, - IPA_COALESCE =3D 0x5, - IPA_QCMAP =3D 0x6, + IPA_MBIM_16 =3D 0x0, + IPA_HDLC =3D 0x1, + IPA_TLP =3D 0x2, + IPA_RNDIS =3D 0x3, + IPA_GENERIC =3D 0x4, + IPA_COALESCE =3D 0x5, + IPA_QCMAP =3D 0x6, }; =20 /* Valid only for RX (IPA producer) endpoints */ --=20 2.34.1 From nobody Thu Apr 2 15:02:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3CABDC54EE9 for ; Thu, 22 Sep 2022 22:21:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230461AbiIVWVk (ORCPT ); Thu, 22 Sep 2022 18:21:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230484AbiIVWVN (ORCPT ); Thu, 22 Sep 2022 18:21:13 -0400 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28F8C10CA43 for ; Thu, 22 Sep 2022 15:21:12 -0700 (PDT) Received: by mail-il1-x12c.google.com with SMTP id g12so5661393ilj.5 for ; Thu, 22 Sep 2022 15:21:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=yoUX0GhCusB6CNDn4OYWjlHzOJOv1pFoq/cJVsEvPYM=; b=I54/mvygyIGdqu6c4LWKn1jWV8BxXPuVkcj0rY4vEe9Qm8Uh2RY1xqOe1H/x04ah6A 7zEk6rsprt3x6AjcbQ+4ttgho0IwacwbF8ttSZrq3jxINCXcWCIzO9zLRtgsMI37adpd 9oz15a66qblhpQBP/Eq8X60/cjx+oWyn/HlHsrHi/qfZqNvCjSZ5SVMCP/rtzbN2j418 ri6wAmyDv/4BjTfHr92GUMN6gBHD+GC7rWq/VcPaGNkxWgQTpgMfrw/ZV2QuC4N2xKfy nNQ2eRq7RmIlC9Tu3a0U0mf9YuzFjgkjVhTF2HahNQZsHeEwtY8zGREoASodn1/BkHbL Wf0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=yoUX0GhCusB6CNDn4OYWjlHzOJOv1pFoq/cJVsEvPYM=; b=kRtDMoAvLjOCNBX+2VhXDCIhIUWeEPrq7M8/mqcYTRpCROe1FfjmiAj9MCoa6kEuSk YHwfelwpAFQWThvOtJeD/M/I/OXtXSkSLBNo98Me3YqmZdNTZmPwoxOdftoGcHJAlSuY 93lc0rqH5GfjGEICr50BolFftbLxP5y7Yd8US4+5xbEGqEBYs82QJBPUstgfoucwjo6s HCGov32Icnsgcx2izLKzcwqy2pGn2kvwgnb3aNU/HHiptb5mQtWs1VcN5dXRlDFHB0J3 n0N07Hl6FlQ3syCS00N1u8hVjVRyaq10KorSjSYfpr9Z8Yt7xIEf78vTnrJ9KR2IjZ3z cuTg== X-Gm-Message-State: ACrzQf2o2w/wfIKekvBYgAn+aVm+hTQ9zykuWeCpN30Rrptnvz4woo4Y +4ivL/pe+QQbd94sKRtdOQJRGA== X-Google-Smtp-Source: AMsMyM6ZT6nXW8d75G+vfBKw4P5MlCoHEVtM6ZW3CBaJwFZKFsiju3RuTVkwsb2SX1590aMH1kA7lA== X-Received: by 2002:a05:6e02:1909:b0:2f6:acd5:7e9b with SMTP id w9-20020a056e02190900b002f6acd57e9bmr2257844ilu.190.1663885270890; Thu, 22 Sep 2022 15:21:10 -0700 (PDT) Received: from localhost.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id g12-20020a92d7cc000000b002f592936fbfsm2483332ilq.41.2022.09.22.15.21.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Sep 2022 15:21:10 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: mka@chromium.org, evgreen@chromium.org, andersson@kernel.org, quic_cpratapa@quicinc.com, quic_avuyyuru@quicinc.com, quic_jponduru@quicinc.com, quic_subashab@quicinc.com, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 6/8] net: ipa: encapsulate setting the FILT_ROUT_HASH_EN register Date: Thu, 22 Sep 2022 17:20:58 -0500 Message-Id: <20220922222100.2543621-7-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220922222100.2543621-1-elder@linaro.org> References: <20220922222100.2543621-1-elder@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Create a new function that encapsulates setting the register flag that disables filter and routing table hashing for IPA v4.2. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_main.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c index 9dfa7f58a207f..cca270d2d9a68 100644 --- a/drivers/net/ipa/ipa_main.c +++ b/drivers/net/ipa/ipa_main.c @@ -306,6 +306,18 @@ static void ipa_qtime_config(struct ipa *ipa) iowrite32(val, ipa->reg_virt + IPA_REG_TIMERS_XO_CLK_DIV_CFG_OFFSET); } =20 +static void ipa_hardware_config_hashing(struct ipa *ipa) +{ + u32 offset; + + if (ipa->version !=3D IPA_VERSION_4_2) + return; + + /* IPA v4.2 does not support hashed tables, so disable them */ + offset =3D ipa_reg_filt_rout_hash_en_offset(IPA_VERSION_4_2); + iowrite32(0, ipa->reg_virt + offset); +} + static void ipa_idle_indication_cfg(struct ipa *ipa, u32 enter_idle_debounce_thresh, bool const_non_idle_enable) @@ -390,14 +402,7 @@ static void ipa_hardware_config(struct ipa *ipa, const= struct ipa_data *data) ipa_qtime_config(ipa); } =20 - /* IPA v4.2 does not support hashed tables, so disable them */ - if (version =3D=3D IPA_VERSION_4_2) { - u32 offset =3D ipa_reg_filt_rout_hash_en_offset(version); - - iowrite32(0, ipa->reg_virt + offset); - } - - /* Enable dynamic clock division */ + ipa_hardware_config_hashing(ipa); ipa_hardware_dcd_config(ipa); } =20 --=20 2.34.1 From nobody Thu Apr 2 15:02:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70014ECAAD8 for ; Thu, 22 Sep 2022 22:21:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229797AbiIVWVp (ORCPT ); Thu, 22 Sep 2022 18:21:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230284AbiIVWVW (ORCPT ); Thu, 22 Sep 2022 18:21:22 -0400 Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD97F10F71C for ; Thu, 22 Sep 2022 15:21:13 -0700 (PDT) Received: by mail-il1-x12a.google.com with SMTP id d14so4594367ilf.2 for ; Thu, 22 Sep 2022 15:21:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=NCabapcdQgwE6CLB04s1D40oIHNART3RkqR4ORWuTYM=; b=C8QtmTTq1lEIw3FbtAgMnhpXm0pRbKb7lcax9DgywqyyxX0nASCiYorzNfHgQJUiuZ 2dMSNnCwtHkqwujNlTLUp3LEvbv2qySgOn6Sm26jzUtyVV11sP3oVAMoDVqb9hT9j8yX aD8v6Q4UoF6NGf2xF6a1df1xts7UDIC5nSRFaFZhjLWhtKMGFT4A51GaxVn7/G16HbWu ASDNAUNcBVvPXtnuaD6Q7ZGNWzTZ/O1ggBI+Au0IEAd07ChikhUC+Qyx3dHzXTklV9AR zngBVtJrcPFIW8MmSdvq821KRVE8qK84RxtZ4yA+zgd8qgHF5i14Z74SExSdPN+soECk y/gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=NCabapcdQgwE6CLB04s1D40oIHNART3RkqR4ORWuTYM=; b=n/DWRu7UVVPNX8bR+UAmP64YuILnPMyGqqGPcBLzpLBn3wCY5ho9T7ka+U5rd288pw 00gsSqqdrLt9z9xu9OmlEF84WFdCkNV56ty4Qpn3JRpO5UtUALGpMvnAPdwYyTqjTi8I tr4PWEFeVXu/wl6zxL14twVgI5tBe7cdYT6TAu7O/HGEdBJsi09wCCVK7AOZTS/wbjej RL+oV617mn7fay151AwsYPnNwmEnWlLzfSdyHBP/v4FhsCLREzWxISQ1exAaFVVLSWnK te3mitK1b8AzsenBbdz+QR+1YWDArL98A5a3YXXIpV5UHK2gMAK8TXLG1YutP0VxuJ3w G9/Q== X-Gm-Message-State: ACrzQf1xqagT3CJexeNOxbhsmDvbF15U1+vBpUVLWI7DOAx/1dG4vrPe rsA7Izhzo6emK6v0CB0tdOw8Qg== X-Google-Smtp-Source: AMsMyM6kwM8gczzmLCpPGAjI0qa1oHtSBDZwPWfpvUUaIIduK03l3xrAUgbsx6huiePa3/M5JtzykA== X-Received: by 2002:a05:6e02:78a:b0:2f6:9f8b:e70c with SMTP id q10-20020a056e02078a00b002f69f8be70cmr2728962ils.111.1663885272288; Thu, 22 Sep 2022 15:21:12 -0700 (PDT) Received: from localhost.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id g12-20020a92d7cc000000b002f592936fbfsm2483332ilq.41.2022.09.22.15.21.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Sep 2022 15:21:11 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: mka@chromium.org, evgreen@chromium.org, andersson@kernel.org, quic_cpratapa@quicinc.com, quic_avuyyuru@quicinc.com, quic_jponduru@quicinc.com, quic_subashab@quicinc.com, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 7/8] net: ipa: encapsulate updating the COUNTER_CFG register Date: Thu, 22 Sep 2022 17:20:59 -0500 Message-Id: <20220922222100.2543621-8-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220922222100.2543621-1-elder@linaro.org> References: <20220922222100.2543621-1-elder@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Create a new function that encapsulates setting the counter configuration register value for versions prior to IPA v4.5. Create another small function to represent configuring hardware timing regardless of version. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_main.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c index cca270d2d9a68..8bb4b036df2b4 100644 --- a/drivers/net/ipa/ipa_main.c +++ b/drivers/net/ipa/ipa_main.c @@ -306,6 +306,27 @@ static void ipa_qtime_config(struct ipa *ipa) iowrite32(val, ipa->reg_virt + IPA_REG_TIMERS_XO_CLK_DIV_CFG_OFFSET); } =20 +/* Before IPA v4.5 timing is controlled by a counter register */ +static void ipa_hardware_config_counter(struct ipa *ipa) +{ + u32 granularity; + u32 val; + + granularity =3D ipa_aggr_granularity_val(IPA_AGGR_GRANULARITY); + + val =3D u32_encode_bits(granularity, AGGR_GRANULARITY_FMASK); + + iowrite32(val, ipa->reg_virt + IPA_REG_COUNTER_CFG_OFFSET); +} + +static void ipa_hardware_config_timing(struct ipa *ipa) +{ + if (ipa->version < IPA_VERSION_4_5) + ipa_hardware_config_counter(ipa); + else + ipa_qtime_config(ipa); +} + static void ipa_hardware_config_hashing(struct ipa *ipa) { u32 offset; @@ -362,7 +383,6 @@ static void ipa_hardware_dcd_deconfig(struct ipa *ipa) static void ipa_hardware_config(struct ipa *ipa, const struct ipa_data *da= ta) { enum ipa_version version =3D ipa->version; - u32 granularity; u32 val; =20 /* IPA v4.5+ has no backward compatibility register */ @@ -389,19 +409,8 @@ static void ipa_hardware_config(struct ipa *ipa, const= struct ipa_data *data) iowrite32(val, ipa->reg_virt + IPA_REG_CLKON_CFG_OFFSET); =20 ipa_hardware_config_comp(ipa); - - /* Configure system bus limits */ ipa_hardware_config_qsb(ipa, data); - - if (version < IPA_VERSION_4_5) { - /* Configure aggregation timer granularity */ - granularity =3D ipa_aggr_granularity_val(IPA_AGGR_GRANULARITY); - val =3D u32_encode_bits(granularity, AGGR_GRANULARITY_FMASK); - iowrite32(val, ipa->reg_virt + IPA_REG_COUNTER_CFG_OFFSET); - } else { - ipa_qtime_config(ipa); - } - + ipa_hardware_config_timing(ipa); ipa_hardware_config_hashing(ipa); ipa_hardware_dcd_config(ipa); } --=20 2.34.1 From nobody Thu Apr 2 15:02:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 925F9ECAAD8 for ; Thu, 22 Sep 2022 22:21:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231749AbiIVWVt (ORCPT ); Thu, 22 Sep 2022 18:21:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231244AbiIVWV3 (ORCPT ); Thu, 22 Sep 2022 18:21:29 -0400 Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E220310F72B for ; Thu, 22 Sep 2022 15:21:14 -0700 (PDT) Received: by mail-io1-xd33.google.com with SMTP id y141so8965073iof.5 for ; Thu, 22 Sep 2022 15:21:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=8NQbcO3RxX3i66zbcp0uk7GFHnQ5dOAsJhkZ2O3/nY8=; b=rnQS6/cvRAD9ElWGu7c5+xdFhhhEaPl2HOtLmQIWAmE80cjQmlE8xvf2VIywl0eWGH 3r0KTxEr/8Lgrz8h/DeiI0WEZYzzQnfihyXpCXgzUMK0ghe6xylHP8YG+g7jRIzklO84 kRo5rSA/C9mcfr0Sbl5dZCikTnUb4lFETe88LLFX9yI1MjEwd2OpVeuw1wuVtHiEP7vZ 7HZ48psm0QbchBMTB7J/hqT+wn7RHupQ8WCA83BPk1EXEydqMTC6vzhkesQd2OqGc5kS An9aNx4khHwnLof6Qt0vAg0RtGUlXmcO8woYUqzWKmiUpGGFpVs0Kp3cDRV5knVFtOsp uqcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=8NQbcO3RxX3i66zbcp0uk7GFHnQ5dOAsJhkZ2O3/nY8=; b=6eykWsP/Im1gFABsAMSMEEDake8Go+oFh6nOy+2mClAZp4IivOUxAI90wHjePYTonE cGWjZ8QE2YCizvlfZS0IVvxsFlCy0FYQAR0p6Zp+Ww9anLIfcuNYzrcDmbNVgJ8DV44f qWfA2el6mJYkQuvvMJnfqXbQLG9dvzSdMpSpWuJBTFtThJc4ALKLuVRq1664WlmAtRLP M+EnIl4OPSyu9Gi5Mw+EswUpKHUzzyLKMDfMreUHZSBXMPJI/1pcObt7qNsFKxih0q3w 3f/AyPhQb4zz4vgyDN3AyXuZIbNXMnW8ay4JYn+i201h/WbFF8bcy2bITQvbOQu8IsmT ++UQ== X-Gm-Message-State: ACrzQf2BYYUz5hBjSm0U7TBkKQfjWDQLPF7UaCfZfCaNnLuMHfagXrI1 Ke/Afj/KWVvXqTlKxPXejhcn+g== X-Google-Smtp-Source: AMsMyM5fqKzWRTm7+LT3vDYZIt2jxEYb4IH+OAshM0Jr14dPUohaWszSwwX80LoYbg/I4QyFzOdk1Q== X-Received: by 2002:a05:6638:430c:b0:35a:1c37:a343 with SMTP id bt12-20020a056638430c00b0035a1c37a343mr3167198jab.183.1663885274263; Thu, 22 Sep 2022 15:21:14 -0700 (PDT) Received: from localhost.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id g12-20020a92d7cc000000b002f592936fbfsm2483332ilq.41.2022.09.22.15.21.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Sep 2022 15:21:13 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: mka@chromium.org, evgreen@chromium.org, andersson@kernel.org, quic_cpratapa@quicinc.com, quic_avuyyuru@quicinc.com, quic_jponduru@quicinc.com, quic_subashab@quicinc.com, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 8/8] net: ipa: encapsulate updating three more registers Date: Thu, 22 Sep 2022 17:21:00 -0500 Message-Id: <20220922222100.2543621-9-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220922222100.2543621-1-elder@linaro.org> References: <20220922222100.2543621-1-elder@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Create a new function that encapsulates setting the BCR, TX_CFG, and CLKON_CFG register values during hardware configuration. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_main.c | 79 +++++++++++++++++++++++++------------- 1 file changed, 53 insertions(+), 26 deletions(-) diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c index 8bb4b036df2b4..a552d6edb702d 100644 --- a/drivers/net/ipa/ipa_main.c +++ b/drivers/net/ipa/ipa_main.c @@ -183,6 +183,56 @@ static void ipa_teardown(struct ipa *ipa) gsi_teardown(&ipa->gsi); } =20 +static void +ipa_hardware_config_bcr(struct ipa *ipa, const struct ipa_data *data) +{ + u32 val; + + /* IPA v4.5+ has no backward compatibility register */ + if (ipa->version >=3D IPA_VERSION_4_5) + return; + + val =3D data->backward_compat; + iowrite32(val, ipa->reg_virt + IPA_REG_BCR_OFFSET); +} + +static void ipa_hardware_config_tx(struct ipa *ipa) +{ + enum ipa_version version =3D ipa->version; + u32 val; + + if (version <=3D IPA_VERSION_4_0 || version >=3D IPA_VERSION_4_5) + return; + + /* Disable PA mask to allow HOLB drop */ + val =3D ioread32(ipa->reg_virt + IPA_REG_TX_CFG_OFFSET); + + val &=3D ~PA_MASK_EN_FMASK; + + iowrite32(val, ipa->reg_virt + IPA_REG_TX_CFG_OFFSET); +} + +static void ipa_hardware_config_clkon(struct ipa *ipa) +{ + enum ipa_version version =3D ipa->version; + u32 val; + + if (version < IPA_VERSION_3_1 || version >=3D IPA_VERSION_4_5) + return; + + /* Implement some hardware workarounds */ + if (version >=3D IPA_VERSION_4_0) { + /* Enable open global clocks in the CLKON configuration */ + val =3D GLOBAL_FMASK | GLOBAL_2X_CLK_FMASK; + } else if (version =3D=3D IPA_VERSION_3_1) { + val =3D MISC_FMASK; /* Disable MISC clock gating */ + } else { + return; + } + + iowrite32(val, ipa->reg_virt + IPA_REG_CLKON_CFG_OFFSET); +} + /* Configure bus access behavior for IPA components */ static void ipa_hardware_config_comp(struct ipa *ipa) { @@ -382,32 +432,9 @@ static void ipa_hardware_dcd_deconfig(struct ipa *ipa) */ static void ipa_hardware_config(struct ipa *ipa, const struct ipa_data *da= ta) { - enum ipa_version version =3D ipa->version; - u32 val; - - /* IPA v4.5+ has no backward compatibility register */ - if (version < IPA_VERSION_4_5) { - val =3D data->backward_compat; - iowrite32(val, ipa->reg_virt + IPA_REG_BCR_OFFSET); - } - - /* Implement some hardware workarounds */ - if (version >=3D IPA_VERSION_4_0 && version < IPA_VERSION_4_5) { - /* Disable PA mask to allow HOLB drop */ - val =3D ioread32(ipa->reg_virt + IPA_REG_TX_CFG_OFFSET); - val &=3D ~PA_MASK_EN_FMASK; - iowrite32(val, ipa->reg_virt + IPA_REG_TX_CFG_OFFSET); - - /* Enable open global clocks in the CLKON configuration */ - val =3D GLOBAL_FMASK | GLOBAL_2X_CLK_FMASK; - } else if (version =3D=3D IPA_VERSION_3_1) { - val =3D MISC_FMASK; /* Disable MISC clock gating */ - } else { - val =3D 0; /* No CLKON configuration needed */ - } - if (val) - iowrite32(val, ipa->reg_virt + IPA_REG_CLKON_CFG_OFFSET); - + ipa_hardware_config_bcr(ipa, data); + ipa_hardware_config_tx(ipa); + ipa_hardware_config_clkon(ipa); ipa_hardware_config_comp(ipa); ipa_hardware_config_qsb(ipa, data); ipa_hardware_config_timing(ipa); --=20 2.34.1