From mboxrd@z Thu Jan 1 00:00:00 1970 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 2BD06C6FD20 for ; Fri, 24 Mar 2023 08:57:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231956AbjCXI5M (ORCPT ); Fri, 24 Mar 2023 04:57:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231940AbjCXI45 (ORCPT ); Fri, 24 Mar 2023 04:56:57 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94C492821D for ; Fri, 24 Mar 2023 01:56:26 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id t10so4894471edd.12 for ; Fri, 24 Mar 2023 01:56:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1679648177; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=Um8TbgrwhTbkEwzBW9OgNTPHsSW0JHe7bi80kPf/8AM=; b=tv9rIy9Uxu3qQtgXFh+rGg9UcyLX/MSBomBeUuea9AyNItUKVcnbXFLlYIaTPV0LDB CQQugLqK7FP4jB7h+4rmxx5LAtCnyIpxToRHnyTKgJOrQW4OUHW9a4q5nQ2JdfnTYBJb EsLCIF1w/ZBjnQD3Du69SsSYV2vCMp9LIUEiy2nHce7dBotl/YoYpxCrbQEp7fMwi4mO cjS9PD/yx1wDYidaGNYm0jfQHbOQ224kh+Pdm08SgNvQEeXq/yIQndaa9wJ8wvmLshGf TSYFnFj5kEUJUR55YMQ84OTOhr5K8XYpjB0mNaoGBOpcdsM/yXBnTxzDlByaF7Ju1pAS Oeew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679648177; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Um8TbgrwhTbkEwzBW9OgNTPHsSW0JHe7bi80kPf/8AM=; b=LbGwkYesDjGGLuOLe4XlWxT6XcYERLaHWP69SnPM24sZyAI/tZNzQ0Juk1yMBH3lR5 wEFEuCjoCP6v6zOv8npafvvvYovEqk1layToNO0HvXmnf97eEVmdSQLU4iA/lU4GgoPF jM3yD1cNW9aWNduo2WsWiMsaI8hm7UKYIFkWN++D7SfdnBbu1hNDfziscpQKfyLvoSrJ IswH2fw/4U2jwU7VE/N9z5/geFfig/W1ukzwjKEdTclRIMz9aAUQe30qbYItl+tr3vXS Gsfrdxb/4r2RDhfcK2hNo3K6pvn2ga3Y6zkyhb+2C3jeyxsCXve+3AVaIiGGGiD3N/vw 6T7w== X-Gm-Message-State: AAQBX9d+mzoFy9GnnZuAp9E1UcQrnAkxQywPl1Y2Q9h88KowW1Z6xT9U hsVAl47DpOO5+VUNZN5S+bAHHA== X-Google-Smtp-Source: AKy350Z722g5hPv9Mo9UlX7Q2mEg4+ITEw0ynPSM2C2jUm30y/pXKOFomdKzmH7x/14WP6tJRKidxg== X-Received: by 2002:a17:906:3607:b0:92d:44ca:1137 with SMTP id q7-20020a170906360700b0092d44ca1137mr2162491ejb.43.1679648176715; Fri, 24 Mar 2023 01:56:16 -0700 (PDT) Received: from ?IPV6:2a02:810d:15c0:828:ce50:243f:54cc:5373? ([2a02:810d:15c0:828:ce50:243f:54cc:5373]) by smtp.gmail.com with ESMTPSA id wy8-20020a170906fe0800b0093e261cc8bcsm612167ejb.58.2023.03.24.01.56.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Mar 2023 01:56:16 -0700 (PDT) Message-ID: <58316fc3-1ee1-b530-e783-ccd8225e07d6@linaro.org> Date: Fri, 24 Mar 2023 09:56:15 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH V1 3/4] soc: qcom: boot_stat: Add Driver Support for Boot Stats Content-Language: en-US To: Souradeep Chowdhury , Andy Gross , Konrad Dybcio , Krzysztof Kozlowski , Bjorn Andersson , Rob Herring Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, Sibi Sankar , Rajendra Nayak References: <3f385562845ae26d519940ca8098fde89282991b.1679403696.git.quic_schowdhu@quicinc.com> <611ea918-64a6-f306-b5ec-db55e41abda2@linaro.org> <321005fc-1bfd-c04d-b2b5-d85d213ac00a@quicinc.com> <7b939818-993a-e849-e7e0-ae9ea74ea52b@linaro.org> <5c4df95e-fb44-e873-7ecc-dec381a42aff@quicinc.com> From: Krzysztof Kozlowski In-Reply-To: <5c4df95e-fb44-e873-7ecc-dec381a42aff@quicinc.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org On 23/03/2023 14:45, Souradeep Chowdhury wrote: > > > On 3/22/2023 8:23 PM, Krzysztof Kozlowski wrote: >> On 22/03/2023 14:54, Souradeep Chowdhury wrote: >>> >>> >>> On 3/21/2023 11:07 PM, Krzysztof Kozlowski wrote: >>>> On 21/03/2023 14:51, Souradeep Chowdhury wrote: >>>>> All of Qualcomm's proprietary Android boot-loaders capture boot time >>>>> stats, like the time when the bootloader started execution and at what >>>>> point the bootloader handed over control to the kernel etc. in the IMEM >>>>> region. This information is captured in a specific format by this driver >>>>> by mapping a structure to the IMEM memory region and then accessing the >>>>> members of the structure to print the information. This information is >>>>> useful in verifying if the existing boot KPIs have regre >>>> >>>> >>>>> +/** >>>>> + * struct boot_stats - timestamp information related to boot stats >>>>> + * @bootloader_start: Time for the starting point of the abl bootloader >>>>> + * @bootloader_end: Time when the kernel starts loading from abl bootloader >>>>> + */ >>>>> +struct boot_stats { >>>>> + u32 bootloader_start; >>>>> + u32 bootloader_end; >>>>> +} __packed; >>>>> + >>>>> +static struct boot_stats __iomem *boot_stats; >>>>> +static void __iomem *mpm_counter_base; >>>>> +static u32 mpm_counter_freq; >>>> >>>> No file-scope variables. Does not scale, not easy for review and >>>> maintenance. Avoid such code. >>> >>> Ack >>>> >>>>> + >>>>> +static int mpm_parse_dt(void) >>>>> +{ >>>>> + struct device_node *np_imem, *np_mpm2; >>>>> + >>>>> + np_imem = of_find_compatible_node(NULL, NULL, >>>>> + "qcom,imem-boot_stats"); >>>>> + if (!np_imem) { >>>>> + pr_err("can't find qcom,imem node\n"); >>>> >>>> So you are printing errors everywhere, on every soc and with compile >>>> test on every platform there is in the world... sorry, it does not work >>>> like that. >>> >>> Ack >>>> >>>>> + return -ENODEV; >>>>> + } >>>>> + boot_stats = of_iomap(np_imem, 0); >>>>> + if (!boot_stats) { >>>>> + pr_err("boot_stats: Can't map imem\n"); >>>>> + goto err1; >>>>> + } >>>> >>>> >>>>> + >>>>> +static void __exit boot_stats_exit(void) >>>>> +{ >>>>> +} >>>>> +module_exit(boot_stats_exit) >>>> >>>> >>>> I don't think this is some special code which deserves init calls. Make >>>> it module_platform_driver(). >>> >>> Since this just reads some values from the Imem region and prints it to >>> the user and doesn't have a specific device associated with it, a >> >> Which is not really an argument for such antipattern, but okay... >> >>> generic module code is written for it and not a module_platform_driver(). >> >> ... so how do you handle deferred probe? > > This has no dependency on other resources except that it parses some > information from DT nodes, so deferred probe handling is not needed > in this case. Yes, I know, but if we would ever add it how this driver can handle it? This is antipattern. Best regards, Krzysztof From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D7B4BC6FD1C for ; Fri, 24 Mar 2023 08:57:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=N5zGHeIz82td6aonmpiBOEKa9+D0wcCK1qZ+oX8BEA4=; b=szZJX6brsv+vVk nCZlfH6CKdcP3Kl3x1sLJcnAPKLl1GzPlQeRo/BrK/pyntb0QS5HHBtKaqVwoePYbym+HW0XWuRhe tfsB7mzgcKzKoy5Jij4KpC26UMlTRu6/A60mgDN4Yusq8h/M7C5KeY4r7omHR/n41K8+FbIklft27 UBv0kbs5Xu7RsaKFdQbppmQEyTpjR2FRSVCrlM0gRKSCs2JeYT0nkmDu60X6Kd2CZceWmUFz6rrU5 pWaXh7e8RsNZcW3mb5f7rFUvJhqhOvl2vGT1/n24oLKukHrBlmhAefVfRZwIhNGl2yNHtPJ+9srtC jRsgpJCwuJwpSmqWLb2Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pfdE5-003wWR-1i; Fri, 24 Mar 2023 08:56:45 +0000 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pfdDg-003wIC-0B for linux-arm-kernel@lists.infradead.org; Fri, 24 Mar 2023 08:56:21 +0000 Received: by mail-ed1-x52c.google.com with SMTP id eh3so4901926edb.11 for ; Fri, 24 Mar 2023 01:56:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1679648177; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=Um8TbgrwhTbkEwzBW9OgNTPHsSW0JHe7bi80kPf/8AM=; b=tv9rIy9Uxu3qQtgXFh+rGg9UcyLX/MSBomBeUuea9AyNItUKVcnbXFLlYIaTPV0LDB CQQugLqK7FP4jB7h+4rmxx5LAtCnyIpxToRHnyTKgJOrQW4OUHW9a4q5nQ2JdfnTYBJb EsLCIF1w/ZBjnQD3Du69SsSYV2vCMp9LIUEiy2nHce7dBotl/YoYpxCrbQEp7fMwi4mO cjS9PD/yx1wDYidaGNYm0jfQHbOQ224kh+Pdm08SgNvQEeXq/yIQndaa9wJ8wvmLshGf TSYFnFj5kEUJUR55YMQ84OTOhr5K8XYpjB0mNaoGBOpcdsM/yXBnTxzDlByaF7Ju1pAS Oeew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679648177; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Um8TbgrwhTbkEwzBW9OgNTPHsSW0JHe7bi80kPf/8AM=; b=H3PW0bNXk0XY/j8Tm9VdLys7RGyJ+AaU4YLt46zY6SKSjZznO3M0jHEWFuJlfqY+fo TfHPgtEyXpZAnMNDF+nG7feLK51YxqiNgGL5OTzH+/HWf6MPMKOCobB4UD/mkkD5DvYE GLKDXJVJcmrNy45FTDETUIRSdDj0nCMyB8iXlof99EYLvZKHACZYYCxfAARt815vEKah V3MxvH7xsqKpmKFuSlMW2ymyBKisHH+o1BuMH/Vn1F6mzvH8P/JBfwg0GuxG9EjDXVg2 5CO92b2JeyGV1AOExGFIB3XYMYQLGY4HKutTRUG3OswNOoFZM0JJILL2XHi7zu3whzX/ T0sQ== X-Gm-Message-State: AAQBX9fZJcPabB5a4yjTEW3PkIC9JpkTcoHm/igltRwG7BTd1Vy2qAi8 LjiBE+h4MaZNjLq9AyyB0REyNA== X-Google-Smtp-Source: AKy350Z722g5hPv9Mo9UlX7Q2mEg4+ITEw0ynPSM2C2jUm30y/pXKOFomdKzmH7x/14WP6tJRKidxg== X-Received: by 2002:a17:906:3607:b0:92d:44ca:1137 with SMTP id q7-20020a170906360700b0092d44ca1137mr2162491ejb.43.1679648176715; Fri, 24 Mar 2023 01:56:16 -0700 (PDT) Received: from ?IPV6:2a02:810d:15c0:828:ce50:243f:54cc:5373? ([2a02:810d:15c0:828:ce50:243f:54cc:5373]) by smtp.gmail.com with ESMTPSA id wy8-20020a170906fe0800b0093e261cc8bcsm612167ejb.58.2023.03.24.01.56.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Mar 2023 01:56:16 -0700 (PDT) Message-ID: <58316fc3-1ee1-b530-e783-ccd8225e07d6@linaro.org> Date: Fri, 24 Mar 2023 09:56:15 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH V1 3/4] soc: qcom: boot_stat: Add Driver Support for Boot Stats Content-Language: en-US To: Souradeep Chowdhury , Andy Gross , Konrad Dybcio , Krzysztof Kozlowski , Bjorn Andersson , Rob Herring Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, Sibi Sankar , Rajendra Nayak References: <3f385562845ae26d519940ca8098fde89282991b.1679403696.git.quic_schowdhu@quicinc.com> <611ea918-64a6-f306-b5ec-db55e41abda2@linaro.org> <321005fc-1bfd-c04d-b2b5-d85d213ac00a@quicinc.com> <7b939818-993a-e849-e7e0-ae9ea74ea52b@linaro.org> <5c4df95e-fb44-e873-7ecc-dec381a42aff@quicinc.com> From: Krzysztof Kozlowski In-Reply-To: <5c4df95e-fb44-e873-7ecc-dec381a42aff@quicinc.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230324_015620_098157_46719B5D X-CRM114-Status: GOOD ( 23.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 23/03/2023 14:45, Souradeep Chowdhury wrote: > > > On 3/22/2023 8:23 PM, Krzysztof Kozlowski wrote: >> On 22/03/2023 14:54, Souradeep Chowdhury wrote: >>> >>> >>> On 3/21/2023 11:07 PM, Krzysztof Kozlowski wrote: >>>> On 21/03/2023 14:51, Souradeep Chowdhury wrote: >>>>> All of Qualcomm's proprietary Android boot-loaders capture boot time >>>>> stats, like the time when the bootloader started execution and at what >>>>> point the bootloader handed over control to the kernel etc. in the IMEM >>>>> region. This information is captured in a specific format by this driver >>>>> by mapping a structure to the IMEM memory region and then accessing the >>>>> members of the structure to print the information. This information is >>>>> useful in verifying if the existing boot KPIs have regre >>>> >>>> >>>>> +/** >>>>> + * struct boot_stats - timestamp information related to boot stats >>>>> + * @bootloader_start: Time for the starting point of the abl bootloader >>>>> + * @bootloader_end: Time when the kernel starts loading from abl bootloader >>>>> + */ >>>>> +struct boot_stats { >>>>> + u32 bootloader_start; >>>>> + u32 bootloader_end; >>>>> +} __packed; >>>>> + >>>>> +static struct boot_stats __iomem *boot_stats; >>>>> +static void __iomem *mpm_counter_base; >>>>> +static u32 mpm_counter_freq; >>>> >>>> No file-scope variables. Does not scale, not easy for review and >>>> maintenance. Avoid such code. >>> >>> Ack >>>> >>>>> + >>>>> +static int mpm_parse_dt(void) >>>>> +{ >>>>> + struct device_node *np_imem, *np_mpm2; >>>>> + >>>>> + np_imem = of_find_compatible_node(NULL, NULL, >>>>> + "qcom,imem-boot_stats"); >>>>> + if (!np_imem) { >>>>> + pr_err("can't find qcom,imem node\n"); >>>> >>>> So you are printing errors everywhere, on every soc and with compile >>>> test on every platform there is in the world... sorry, it does not work >>>> like that. >>> >>> Ack >>>> >>>>> + return -ENODEV; >>>>> + } >>>>> + boot_stats = of_iomap(np_imem, 0); >>>>> + if (!boot_stats) { >>>>> + pr_err("boot_stats: Can't map imem\n"); >>>>> + goto err1; >>>>> + } >>>> >>>> >>>>> + >>>>> +static void __exit boot_stats_exit(void) >>>>> +{ >>>>> +} >>>>> +module_exit(boot_stats_exit) >>>> >>>> >>>> I don't think this is some special code which deserves init calls. Make >>>> it module_platform_driver(). >>> >>> Since this just reads some values from the Imem region and prints it to >>> the user and doesn't have a specific device associated with it, a >> >> Which is not really an argument for such antipattern, but okay... >> >>> generic module code is written for it and not a module_platform_driver(). >> >> ... so how do you handle deferred probe? > > This has no dependency on other resources except that it parses some > information from DT nodes, so deferred probe handling is not needed > in this case. Yes, I know, but if we would ever add it how this driver can handle it? This is antipattern. Best regards, Krzysztof _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel