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 8E0DAC7EE2D for ; Tue, 9 May 2023 07:11:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235223AbjEIHLk (ORCPT ); Tue, 9 May 2023 03:11:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235229AbjEIHLi (ORCPT ); Tue, 9 May 2023 03:11:38 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D617AD0A for ; Tue, 9 May 2023 00:11:36 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-50bc25f0c7dso10285535a12.3 for ; Tue, 09 May 2023 00:11:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683616295; x=1686208295; 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=APH4uf0HQ8cOpTtx4oEH1mlDXvsjwJke9jk7vwtuN80=; b=e7j6qkllm/T/2M2c1EkqE/Qd/638PextIBR0EfhntkXwIPUhY6InG0cTEP19Pl6rJX tzpjvB4ljG1Wpv06IP8v0iJEsTwM4pF4IdAbZvRdo2cjs5Wv4t8ffGIy4i89YSSwoyZY QIWbShgowuM5OzwGJdJ1FxIYWJO8yENJsZnyGyyMcDCnf5X/AfB0a4iDpCyXAzK5kv83 YhQ2A8UNHBgzd9cPjbCi7+0ZFJkOowMKZg7uOa2zCrr9/kDcXodhAZYIk727px/1eZA4 D+/Wf5n6mnlx2gWnDoJQyYp8xv+TH0psqoE9I70jPYNednkYtru0ZwjFHM60MdO5DDQg WJ8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683616295; x=1686208295; 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=APH4uf0HQ8cOpTtx4oEH1mlDXvsjwJke9jk7vwtuN80=; b=VT9sx/QWPPA7I/KLM4yu6meAsefduv5VnfZtuQG9T3/Ug9U2j0els1j01ujtmsvjx7 KETqrrvqgemqnJXTJKqyfQUqsj6nS7qLeQbs6SWHFji4AdRJiRyRo3DpGz3vgP9p3tMP pk2cnsRMh8kQ9eyDsA2ZdE2sBJYJ7ikVPIPHlbqp0O0P1QJ1OOb1Ik9Fk+7fqydgLjU0 b41d6g296qEmJUH/KQVCrET4bzRkHf347idnWtxpkj81tdmSPeCMn16y0LfqFyVQkWg8 idiMT0NaOcY1cWI4DLpGNkK1t0RxSorZP2Ep/yisU9m0fwnela9ayaaGgJ0yiPyRRtu+ YNBQ== X-Gm-Message-State: AC+VfDw49Zghh5EE5BxNc9ltod1zbc6Hut6UDQZ4uEjI9dyP6oIBgG2X rrQKZ3GKRSuSgcu4asEwTjceHw== X-Google-Smtp-Source: ACHHUZ4NTgyfxBlvxeFNFcg9A0+pojhfwrdDKrGACJsSCpzT73/PLN82DOw9k/K7FMCu1mximsVIng== X-Received: by 2002:a05:6402:8c3:b0:506:7d3e:ade5 with SMTP id d3-20020a05640208c300b005067d3eade5mr9710332edz.33.1683616294764; Tue, 09 May 2023 00:11:34 -0700 (PDT) Received: from ?IPV6:2a02:810d:15c0:828:d0d5:7818:2f46:5e76? ([2a02:810d:15c0:828:d0d5:7818:2f46:5e76]) by smtp.gmail.com with ESMTPSA id n7-20020aa7d047000000b004fbdfbb5acesm415192edo.89.2023.05.09.00.11.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 May 2023 00:11:34 -0700 (PDT) Message-ID: <7777c016-4875-a6c9-cd5e-78c2ac686448@linaro.org> Date: Tue, 9 May 2023 09:11:32 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH v3 04/18] soc: qcom: Add Qualcomm minidump kernel driver Content-Language: en-US To: Mukesh Ojha , agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, corbet@lwn.net, keescook@chromium.org, tony.luck@intel.com, gpiccoli@igalia.com, catalin.marinas@arm.com, will@kernel.org, krzysztof.kozlowski+dt@linaro.org, robh+dt@kernel.org, linus.walleij@linaro.org, linux-gpio@vger.kernel.org, srinivas.kandagatla@linaro.org Cc: linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org References: <1683133352-10046-1-git-send-email-quic_mojha@quicinc.com> <1683133352-10046-5-git-send-email-quic_mojha@quicinc.com> <23b493f4-1a01-8d03-fc12-d588b2c6fd74@quicinc.com> <575a422d-6224-06b7-628c-8487b47882e9@linaro.org> <500e5abc-fb71-8468-a6b0-3ced2676b57c@linaro.org> From: Krzysztof Kozlowski In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org On 08/05/2023 09:10, Mukesh Ojha wrote: > > > On 5/4/2023 10:04 PM, Krzysztof Kozlowski wrote: >> On 04/05/2023 17:21, Krzysztof Kozlowski wrote: >>>>> >>>>>> + ret = qcom_minidump_init_apss_subsystem(md); >>>>>> + if (ret) { >>>>>> + dev_err(&pdev->dev, "apss minidump initialization failed: %d\n", ret); >>>>>> + goto unlock; >>>>>> + } >>>>>> + >>>>>> + __md = md; >>>>> >>>>> No. This is a platform device, so it can have multiple instances. >>>> >>>> It can have only one instance that is created from SMEM driver probe. >>> >>> Anyone can instantiate more of them.... how did you solve it? >> >> To clarify - sprinkling more of singletons makes everything tightly >> coupled, difficult to debug and non-portable. You cannot have two >> instances, you have to control concurrent initialization by yourself in >> each of such singletons. >> >> I understand sometimes they are unavoidable, for example when this does >> not map to hardware property. However here you have the parent - smem - >> which can return you valid instance. Thus you avoid entire problem of >> file-scope variables. > > I get your point, why one's should avoid file scope variables. > > > This is infrastructure driver and will not have multiple instances and > even if it happens could be avoided with with the help of global mutex > and protect below function which i am already doing at the moment and But we do not want global mutexes... so incorrect design is being improved by more incorrect design. > fail the other probe if it is already initialized with proper logging..e.g > > "already initialized..." > > > ret = qcom_minidump_init_apss_subsystem(md); > > > And this will be in-lined with > > /* Pointer to the one and only smem handle */ > static struct qcom_smem *__smem; > > Let me know if you still disagree...and have some other way ? Why the parent - smem - cannot return every consumer the instance it has? There will be one smem having only one minidump, so all problems solved? Best regards, Krzysztof