Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp278268rwb; Tue, 15 Nov 2022 23:53:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf5TEwJQIq4i3a7vUhWKQBYMADxXyCQ8s2qfBC6HZ96FRIZlbloFBnJwBPyS75H1xCQKn9Km X-Received: by 2002:a17:906:3fd1:b0:7a6:a48b:5e2a with SMTP id k17-20020a1709063fd100b007a6a48b5e2amr16597844ejj.338.1668585194139; Tue, 15 Nov 2022 23:53:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668585194; cv=none; d=google.com; s=arc-20160816; b=XI6q0HRi7zBIoshiNsGYsLi/UK3YagnJ2FnrSwE3k21CRT192RS8amqcTtf37g5HZo fKVwXcgKS2uo14v/E4NNZsbA5RlRYnidynX0m1CYrLFMePu9XoLYQitUt3MIpMgjvAto KPU+iIYwQQFbLa9R6biY4qj6PiI9EaC08xNMDa0EGJdCZnUdC5hZEUtUzO7WjNFojHyO +1cT9gsQE0zeqoi97naOfNRsg1l3bPAj6T7a1A5bv3ltCKLkNAnXpPb8s8CGGE7wf0FP V91Ur+llxzNgQeXzdHarKUmBMvQ5YPLWhXvMj+nf84JxP6hsEzckmSI+C/lpRoaNPyNQ g2Mg== 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=IbFCvRl1cs7XC6NWdvqbuTmw/rqE6VsOAXoQYLExO5Q=; b=POxUZYiqcJ6e9oE/o8sUwS2AMDE+eTCJGieQgkhD2A/32fCPyVaOaWXTOHrNaOavMl QJUR1B88+aXHY1R9l8hqAXOeo85t8NrycMFZWK+Oehdxpis1jJ0h33W5wStCBWOg3lSy pGpMirnwUPXiSEDkIFA06V6/R3+EcQByJH89L+OSBd1DNhVyYpawIm6ji9Xq56Wtu6IR au7Uyb+9VgBFpKt2oxPibaIEvGHT8jKuYROX08Q0IEQQYZh5KfBmBqGWqHeTq0rlUQWb i3HOFHUmRkkupGI9yuJznxakAq4c0AFohMmzx2Gt6g8Nkd2xc0VW7cCjh0dgeTAl8Ubk 1OLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DU7zoibq; 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 10-20020a170906318a00b007ad8bd5a3b2si10561629ejy.263.2022.11.15.23.52.52; Tue, 15 Nov 2022 23:53:14 -0800 (PST) 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=DU7zoibq; 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 S232847AbiKPHdN (ORCPT + 90 others); Wed, 16 Nov 2022 02:33:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232734AbiKPHdG (ORCPT ); Wed, 16 Nov 2022 02:33:06 -0500 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6DE6C2E for ; Tue, 15 Nov 2022 23:33:05 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id w14so28434183wru.8 for ; Tue, 15 Nov 2022 23:33:05 -0800 (PST) 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=IbFCvRl1cs7XC6NWdvqbuTmw/rqE6VsOAXoQYLExO5Q=; b=DU7zoibqF3VBeTWDB1vEVwMsv4KlatyI3tqd0l3rYwWf91OWuP87YxY4SgVZW5bSja P/AuW06El34WSS9tvrxvmpqlp+Iu7W/jCxl/UUk9jczg1+LrryegvgjlQ92BF7QN8m7E yymio/ffeYE8OJuEs9x2SWrTUyDYP6TgfYL3LtfA6PmSmnPVgvgCNmvrfIRbAbC1+d3D mb2qWhHHyUgmEBaBBEO6OsdRKR4iPwe9qZN3jHsmKu9t4x4HHiICUE/l5ZoMmwnD+q0s caM5y++t4iivpSWgOlOnjFS1OXBeQy67ZtcG9aK4ni7NUIqc6kzCLWRwqYI7cfW+w4RL 3DeQ== 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=IbFCvRl1cs7XC6NWdvqbuTmw/rqE6VsOAXoQYLExO5Q=; b=osfywiyJcuYkILcMr6zP/7c79csAEKq79wY09jTbLsB615uHddwtgM4YXLV6URAZyA 1YZXxx3LbvHReFzkVuLzPouc5VgiRpCCG6Z84fuPU5qry/To+fPsPfH9x6nWHAK9h8rG q7znXIU6BBJAmvetDpwVJvHdJRqkPy9KmJJnsJwdZbGZJAXHNhSJk/CSYc2KohL5w+Nz eNUjm+17BVdXvPGDXVhO/oY0fkkUqdTddr77FQFxzlmGyb+cJUsEpGPTdvMN0DssGreo 74dvAwtdqnXs0gbUABUtAibLeqeS754Ydyjf/xsWZXqMD5riPWss8hg8s/kEgl6/rWRb 9YNw== X-Gm-Message-State: ANoB5pl8yAiOGIzzFzZkOwKNSFznGqP2P6k5gyffKf/qePjFUGNh93Vc rfxlzO04tLYOi369/6i+BZhUxQ== X-Received: by 2002:a5d:5446:0:b0:236:6442:3a65 with SMTP id w6-20020a5d5446000000b0023664423a65mr13222982wrv.84.1668583984173; Tue, 15 Nov 2022 23:33:04 -0800 (PST) Received: from zoltan.localdomain ([167.98.215.174]) by smtp.gmail.com with ESMTPSA id g34-20020a05600c4ca200b003cfd4e6400csm1058823wmp.19.2022.11.15.23.33.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Nov 2022 23:33:03 -0800 (PST) From: Alex Elder To: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: andersson@kernel.org, konrad.dybcio@linaro.org, agross@kernel.org, elder@kernel.org, linux-arm-msm@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v3 2/5] net: ipa: encapsulate decision about firmware load Date: Wed, 16 Nov 2022 01:32:53 -0600 Message-Id: <20221116073257.34010-3-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221116073257.34010-1-elder@linaro.org> References: <20221116073257.34010-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 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 The GSI layer used for IPA requires firmware to be loaded. Currently either the AP or the modem loads the firmware, distinguished by whether the "modem-init" Device Tree property is defined. Some newer systems implement a third option. In preparation for that, encapsulate the code that determines how the GSI firmware gets loaded in a new function, ipa_firmware_loader(). Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_main.c | 39 ++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c index ebb6c9b311eb9..9e43b79d233e9 100644 --- a/drivers/net/ipa/ipa_main.c +++ b/drivers/net/ipa/ipa_main.c @@ -81,6 +81,19 @@ /* Divider for 19.2 MHz crystal oscillator clock to get common timer clock */ #define IPA_XO_CLOCK_DIVIDER 192 /* 1 is subtracted where used */ +/** + * enum ipa_firmware_loader: How GSI firmware gets loaded + * + * @IPA_LOADER_DEFER: System not ready; try again later + * @IPA_LOADER_SELF: AP loads GSI firmware + * @IPA_LOADER_MODEM: Modem loads GSI firmware, signals when done + */ +enum ipa_firmware_loader { + IPA_LOADER_DEFER, + IPA_LOADER_SELF, + IPA_LOADER_MODEM, +}; + /** * ipa_setup() - Set up IPA hardware * @ipa: IPA pointer @@ -696,6 +709,18 @@ static void ipa_validate_build(void) BUILD_BUG_ON(!ipa_aggr_granularity_val(IPA_AGGR_GRANULARITY)); } +static enum ipa_firmware_loader ipa_firmware_loader(struct device *dev) +{ + if (of_property_read_bool(dev->of_node, "modem-init")) + return IPA_LOADER_MODEM; + + /* We need Trust Zone to load firmware; make sure it's available */ + if (qcom_scm_is_available()) + return IPA_LOADER_SELF; + + return IPA_LOADER_DEFER; +} + /** * ipa_probe() - IPA platform driver probe function * @pdev: Platform device pointer @@ -722,9 +747,9 @@ static void ipa_validate_build(void) static int ipa_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; + enum ipa_firmware_loader loader; const struct ipa_data *data; struct ipa_power *power; - bool modem_init; struct ipa *ipa; int ret; @@ -747,11 +772,9 @@ static int ipa_probe(struct platform_device *pdev) return -EINVAL; } - /* If we need Trust Zone, make sure it's available */ - modem_init = of_property_read_bool(dev->of_node, "modem-init"); - if (!modem_init) - if (!qcom_scm_is_available()) - return -EPROBE_DEFER; + loader = ipa_firmware_loader(dev); + if (loader == IPA_LOADER_DEFER) + return -EPROBE_DEFER; /* The clock and interconnects might not be ready when we're * probed, so might return -EPROBE_DEFER. @@ -796,7 +819,7 @@ static int ipa_probe(struct platform_device *pdev) if (ret) goto err_endpoint_exit; - ret = ipa_smp2p_init(ipa, modem_init); + ret = ipa_smp2p_init(ipa, loader == IPA_LOADER_MODEM); if (ret) goto err_table_exit; @@ -815,7 +838,7 @@ static int ipa_probe(struct platform_device *pdev) * call to ipa_setup() when it has finished. In that case we're * done here. */ - if (modem_init) + if (loader == IPA_LOADER_MODEM) goto done; /* Otherwise we need to load the firmware and have Trust Zone validate -- 2.34.1