Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3196261rwi; Fri, 21 Oct 2022 12:57:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6LLlYQ88X/xC22BDPe+bTkAzFcIjVzy8CJn8IjY9TFcO1v/+p6cmb6vunVzFLF5GLMoUQZ X-Received: by 2002:a17:906:8447:b0:78d:776f:c544 with SMTP id e7-20020a170906844700b0078d776fc544mr17274669ejy.405.1666382244445; Fri, 21 Oct 2022 12:57:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666382244; cv=none; d=google.com; s=arc-20160816; b=A/YXU9mGfG1tIgJJ5HzeM5L9LC4GOTL9S0ERYvvDjnOudlWe6cQGPgzddpwXPWNTQL 0zcCgXSkrrVQL/KxBit3Vo/iHK1fTUX3R2+gNbFyxflZiYFR3Txgh2OiZjypUNJCwKuP gLTE6t5Y/o9KsCGygIjJtozdAxsy2/YI03gG2sSlY3no9gNxb36lGQZ83KKDnG8EPqPU 0YFISp5anOBOl4mrkojA3+Aeg0jwCfFYBHGrP//rtlTsmmryP1EtffaC2NNuK1tI+0m7 EEcStrUrA+S7zif67+iehf5mWNyKxaLSMWgPFEhpwJ1m0IcyWyGXCPfIgx8IfIxO0LrD 9hdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ffjwyYuCoS/NvlnxXJbOzVeqq5rZ9fCi3nXlY5yNU50=; b=k5cKKrUEkujBEzOXK+mdytMkLzGj4JA17KratgYM+EvzLQGy+Lw7qVFAORCUCJvz06 KTvjmvxsVR7J6D/TeKjnqHnLqlCuxUZfy23D3dUKQEQgHkVHWuo5Dzps5rPA04sznsp8 /xw+G+CQG/WkG68CZ/OK0wXOvU21SRXsf5C1Zx14nKI1rTFZu6LXGRDi4lbFUfpVc4oW Xfnks5OWNsX3JbQUvu8gQbVqUnK1MWRQa66fpYNcv+uygnbt6jWiV4TNfRRXIFCh0ST8 TyTa23Ghlo1oPJufPFOnwnrCgLrwliObB15YXRNFDJBTFMcX+Zw0U5rTfnZ4n3oBHFxl AyDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="PS/Wz4BQ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g12-20020a056402114c00b00451e0d930dfsi18236844edw.497.2022.10.21.12.56.58; Fri, 21 Oct 2022 12:57:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="PS/Wz4BQ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230390AbiJUTOL (ORCPT + 99 others); Fri, 21 Oct 2022 15:14:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230378AbiJUTN6 (ORCPT ); Fri, 21 Oct 2022 15:13:58 -0400 Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA10215A8FD for ; Fri, 21 Oct 2022 12:13:53 -0700 (PDT) Received: by mail-il1-x131.google.com with SMTP id g13so2190137ile.0 for ; Fri, 21 Oct 2022 12:13:53 -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 :message-id:reply-to; bh=ffjwyYuCoS/NvlnxXJbOzVeqq5rZ9fCi3nXlY5yNU50=; b=PS/Wz4BQtvKmYXcEWIIMLP5lDWgUD+5jUBKHAwjBS8EZnQb5ieqXPwP90BrS9c/wGj EZrDcvMyvjQZAxHTVufBLSIqaFLp7l1tFdTEsKtOwhBMjejiX66CybROw9TycWE0mbnq o2lp1bB21+uxwlziKnlp3804hAlPyPr50u+eQ7ZrLqcyyuvdbrXayeQmiWEPduyzQUbE vFijDPYKo0XqvIwlaP/7V3zRkcvzowf2fvjH7BreI09Cqlu7r/aLjX3M+dbsBvOIZ5xn bQv35q4+RG0fkshuj92Ppn/BSO2VErX11J7KToQobkZEx6r///A3Hc+shIQYXw5aOmYZ DB0A== 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:message-id:reply-to; bh=ffjwyYuCoS/NvlnxXJbOzVeqq5rZ9fCi3nXlY5yNU50=; b=H2LQlvNAiSVeDY6JOh0KcZ0fbj7PozyEKLMQX7wFhlLBYWkFYlXgRdW6biBiK6ZjRu vCkgfz9AQeTAK1d5MTC2K23mfbxmr91qw/Gk2aaqGMiC6biTVmR8gxbue9ArNPCL+P4B pQa5X4ZDTGhgChJWf8ZudtQGJ0K8fyuUz616JdOCA6IKgBi9RVl7vCbt7fHamT2fu6+e kDC6KcNkYqbOuopWtmsNhRemY4h0V+WvkSOsfEjdnb+7BkJZttNmsYQYrUB/QWXK6bTj HlFp91VnKWGRAByEDq4HwlBrNo4KIKQBA6Wwfu5jip9cQVMxCeC9CKL4RC5wfgsMXgHt a0oQ== X-Gm-Message-State: ACrzQf38kzqku8gLf+M3UBrzH3jLLD32mJR90/YDL5gRcLQG2BQUA+pD hMYkULZaQ0gKGGVXkuvepxvmzw== X-Received: by 2002:a92:4449:0:b0:2de:95f1:8b80 with SMTP id a9-20020a924449000000b002de95f18b80mr14985942ilm.232.1666379632612; Fri, 21 Oct 2022 12:13:52 -0700 (PDT) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id e3-20020a022103000000b00363c68aa348sm4439362jaa.72.2022.10.21.12.13.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 12:13:51 -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/7] net: ipa: introduce ipa_cmd_init() Date: Fri, 21 Oct 2022 14:13:38 -0500 Message-Id: <20221021191340.4187935-6-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021191340.4187935-1-elder@linaro.org> References: <20221021191340.4187935-1-elder@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, ipa_cmd_data_valid() is called by ipa_mem_config(). Nothing it does requires access to hardware though, so it can be done during the init phase of IPA driver startup. Create a new function ipa_cmd_init(), whose purpose is to do early initialization related to IPA immediate commands. It will call the build-time validation function, then will make the two calls made previously by ipa_cmd_data_valid(). This make ipa_cmd_data_valid() unnecessary, so get rid of it. Rename ipa_cmd_header_valid() to be ipa_cmd_header_init_local_valid(), so its name is clearer about which IPA immediate command it is associated with. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_cmd.c | 31 +++++++++++++++---------------- drivers/net/ipa/ipa_cmd.h | 10 ++++++++++ drivers/net/ipa/ipa_mem.c | 4 ---- 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/drivers/net/ipa/ipa_cmd.c b/drivers/net/ipa/ipa_cmd.c index abee6cc018a27..de2cd86aa9e28 100644 --- a/drivers/net/ipa/ipa_cmd.c +++ b/drivers/net/ipa/ipa_cmd.c @@ -202,7 +202,7 @@ bool ipa_cmd_table_init_valid(struct ipa *ipa, const struct ipa_mem *mem, } /* Validate the memory region that holds headers */ -static bool ipa_cmd_header_valid(struct ipa *ipa) +static bool ipa_cmd_header_init_local_valid(struct ipa *ipa) { struct device *dev = &ipa->pdev->dev; const struct ipa_mem *mem; @@ -318,26 +318,11 @@ static bool ipa_cmd_register_write_valid(struct ipa *ipa) return true; } -bool ipa_cmd_data_valid(struct ipa *ipa) -{ - if (!ipa_cmd_header_valid(ipa)) - return false; - - if (!ipa_cmd_register_write_valid(ipa)) - return false; - - return true; -} - - int ipa_cmd_pool_init(struct gsi_channel *channel, u32 tre_max) { struct gsi_trans_info *trans_info = &channel->trans_info; struct device *dev = channel->gsi->dev; - /* This is as good a place as any to validate build constants */ - ipa_cmd_validate_build(); - /* Command payloads are allocated one at a time, but a single * transaction can require up to the maximum supported by the * channel; treat them as if they were allocated all at once. @@ -637,3 +622,17 @@ struct gsi_trans *ipa_cmd_trans_alloc(struct ipa *ipa, u32 tre_count) return gsi_channel_trans_alloc(&ipa->gsi, endpoint->channel_id, tre_count, DMA_NONE); } + +/* Init function for immediate commands; there is no ipa_cmd_exit() */ +int ipa_cmd_init(struct ipa *ipa) +{ + ipa_cmd_validate_build(); + + if (!ipa_cmd_header_init_local_valid(ipa)) + return -EINVAL; + + if (!ipa_cmd_register_write_valid(ipa)) + return -EINVAL; + + return 0; +} diff --git a/drivers/net/ipa/ipa_cmd.h b/drivers/net/ipa/ipa_cmd.h index d03cc619e2c31..e2cf1c2b0ef24 100644 --- a/drivers/net/ipa/ipa_cmd.h +++ b/drivers/net/ipa/ipa_cmd.h @@ -162,4 +162,14 @@ void ipa_cmd_pipeline_clear_wait(struct ipa *ipa); */ struct gsi_trans *ipa_cmd_trans_alloc(struct ipa *ipa, u32 tre_count); +/** + * ipa_cmd_init() - Initialize IPA immediate commands + * @ipa: - IPA pointer + * + * Return: 0 if successful, or a negative error code + * + * There is no need for a matching ipa_cmd_exit() function. + */ +int ipa_cmd_init(struct ipa *ipa); + #endif /* _IPA_CMD_H_ */ diff --git a/drivers/net/ipa/ipa_mem.c b/drivers/net/ipa/ipa_mem.c index f84c6830495a4..2238dac2af07e 100644 --- a/drivers/net/ipa/ipa_mem.c +++ b/drivers/net/ipa/ipa_mem.c @@ -370,10 +370,6 @@ int ipa_mem_config(struct ipa *ipa) if (!ipa_table_valid(ipa)) goto err_dma_free; - /* Validate memory-related properties relevant to immediate commands */ - if (!ipa_cmd_data_valid(ipa)) - goto err_dma_free; - /* Verify the microcontroller ring alignment (if defined) */ mem = ipa_mem_find(ipa, IPA_MEM_UC_EVENT_RING); if (mem && mem->offset % 1024) { -- 2.34.1