Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3024174imm; Mon, 16 Jul 2018 20:00:06 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdC0L6kRfAzAWZ5qvQN8y08kforC8k7tEQ80AE+4Nuq6RS10YQvsXu/HzvZUOWrWDjDyOhN X-Received: by 2002:a62:3ece:: with SMTP id y75-v6mr20707048pfj.7.1531796406258; Mon, 16 Jul 2018 20:00:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531796406; cv=none; d=google.com; s=arc-20160816; b=gPixohQ182cH9stVDBL4RwE9sObQelk1iWx/W/xaUuZIhIsCycOOXrpmEYnTJmYhOB dacS6mPH/pFrYTsFreOhKNPMFVls89vBHrFaYFVXi68tM3XEGI4NbqXJCpwLFcY16DiP BuajymwYdQ78SHYGLzP7Q/lhcib/jdpjz5fRN+35QflYgYHu9D8TWQFzveTTAqRYoRke gtcnSQgua8Qx4YMsQhi1vS8gHUn/Xvgiz5qmBcjSHBdL6Abat+pWFGxSr/6iWs8nymQF cdzpbaGYET+GucMS3AesjURRB4j9i4u3WAI4pbX+ach0LMJQ3PRX9fVWgIoY85pj77Nr oWlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dmarc-filter :dkim-signature:dkim-signature:arc-authentication-results; bh=gtfaFXfLZNSUMM2etYGnKQazFSokGolIcrLbp5xbzrA=; b=r0I7Jf7jL6gU43yklo/0minqaByhbzNRwJWDy0yL+bPr1W3BK8mZKe7qpcdxXvHNI4 5xm6BBI/GTTaqN6wPkmxMgz+/esvBbI25gySz+jTEu4p8Dps2EziqcRPS9BGSVfVBPwy PL7LbKy6pRIXGZaLyRATeH5hWmxN26hF/H6n+k0y+sG4FST2S5L1tauKeQ21943eaVAl uSUfVPFJXX1ahVo05fBIa+64WqBYIHIoqDKm6InTAZFyS9YCPSWsQArRSLJFt8Q40dwH YKImyOGYwmkBOdx2OIdcCdbSUo9OXry8AB84NCVEMJchnz35vX3WZN36ayehDVZLJgbc a5ZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=lKHvyC4f; dkim=pass header.i=@codeaurora.org header.s=default header.b=gnPyJhUi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r14-v6si31975423pgl.490.2018.07.16.19.59.49; Mon, 16 Jul 2018 20:00:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=lKHvyC4f; dkim=pass header.i=@codeaurora.org header.s=default header.b=gnPyJhUi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729997AbeGQD3d (ORCPT + 99 others); Mon, 16 Jul 2018 23:29:33 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:40980 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729876AbeGQD3d (ORCPT ); Mon, 16 Jul 2018 23:29:33 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 7C4286060A; Tue, 17 Jul 2018 02:59:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1531796353; bh=zjaDhQu6d7hnVcUwMpjdprDMWZZfBNBYHCqoG9lHb2Q=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=lKHvyC4fe2L7VOCEbEYZLxYdO7QqRsu7VApZt+ywzHMQ06oW/94skoH8/yuPWOiOp skIgDBjNQE6glhx6cQlqjfXB9Qm0y1rM8qPG/ZOGa+C7nobiuGi/GqkYX4SajKcI/W W/p5Nflti+hwYhwVrpyrPGCmzCEZQeUDuLhA11J0= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from [10.4.34.47] (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: tdas@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 31A40603AF; Tue, 17 Jul 2018 02:59:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1531796352; bh=zjaDhQu6d7hnVcUwMpjdprDMWZZfBNBYHCqoG9lHb2Q=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=gnPyJhUilqn80MM/QJiywjeKg4v3ymBJdCg7SJ8HVF0EmCBI3cPQf70+U9eNiNofG F9N17IHzTsRc7gXq5Lg36kjBkGrRkqyFbIe30N/YbmmRdrDSDVgYKZgWUt8DEmog/D PpVHwr+6eaWndJbt4lLI+ZmCPm53JRkIQRiTPsD8= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 31A40603AF Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=tdas@codeaurora.org Subject: Re: [PATCH v5 2/2] cpufreq: qcom-hw: Add support for QCOM cpufreq HW driver To: Viresh Kumar Cc: "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Stephen Boyd , Rajendra Nayak , Amit Nischal , devicetree@vger.kernel.org, robh@kernel.org, skannan@codeaurora.org, amit.kucheria@linaro.org, evgreen@google.com References: <1531418745-19742-1-git-send-email-tdas@codeaurora.org> <1531418745-19742-3-git-send-email-tdas@codeaurora.org> <20180716051219.36rdvxux3lz3rjed@vireshk-i7> From: Taniya Das Message-ID: <3163a20a-31ca-15a0-56e2-38e977b21ae2@codeaurora.org> Date: Tue, 17 Jul 2018 08:29:06 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180716051219.36rdvxux3lz3rjed@vireshk-i7> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/16/2018 10:42 AM, Viresh Kumar wrote: > On 12-07-18, 23:35, Taniya Das wrote: >> +static int qcom_cpu_resources_init(struct platform_device *pdev, >> + struct device_node *np, unsigned int cpu) >> +{ >> + struct cpufreq_qcom *c; >> + struct resource res; >> + struct device *dev = &pdev->dev; >> + unsigned int offset, cpu_r; >> + int ret; >> + >> + c = devm_kzalloc(dev, sizeof(*c), GFP_KERNEL); >> + if (!c) >> + return -ENOMEM; >> + >> + c->reg_offset = of_device_get_match_data(&pdev->dev); >> + if (!c->reg_offset) >> + return -EINVAL; >> + >> + if (of_address_to_resource(np, 0, &res)) >> + return -ENOMEM; >> + >> + c->base = devm_ioremap(dev, res.start, resource_size(&res)); >> + if (!c->base) { >> + dev_err(dev, "Unable to map %s base\n", np->name); >> + return -ENOMEM; >> + } >> + >> + offset = c->reg_offset[REG_ENABLE]; >> + >> + /* HW should be in enabled state to proceed */ >> + if (!(readl_relaxed(c->base + offset) & 0x1)) { >> + dev_err(dev, "%s cpufreq hardware not enabled\n", np->name); >> + return -ENODEV; >> + } >> + >> + ret = qcom_get_related_cpus(np, &c->related_cpus); >> + if (ret) { >> + dev_err(dev, "%s failed to get related CPUs\n", np->name); >> + return ret; >> + } >> + >> + c->max_cores = cpumask_weight(&c->related_cpus); >> + if (!c->max_cores) >> + return -ENOENT; >> + >> + ret = qcom_read_lut(pdev, c); >> + if (ret) { >> + dev_err(dev, "%s failed to read LUT\n", np->name); >> + return ret; >> + } >> + >> + qcom_freq_domain_map[cpu] = c; >> + >> + /* Related CPUs to keep a single copy */ >> + cpu_r = cpumask_first(&c->related_cpus); >> + if (cpu != cpu_r) { >> + qcom_freq_domain_map[cpu] = qcom_freq_domain_map[cpu_r]; >> + devm_kfree(dev, c); >> + } > > Sorry about missing this, you have actually worked on my comments. > > But I think this isn't the clever way of doing it. You allocate the > structures, fill everything and then finally free them because we were > related. Why can't we have similar check at the top of this routine > and skip everything then ? > Thanks Viresh, I actually replied to all the reviewers with the changes I have made in v5 series, sorry for not replying individually to all reviewers. Yes, I agree I should have put this check at the beginning of the function. Please help review of the new series[v5] which takes care of the below. - Remove mapping different register regions of perf/lut/enable, instead map the entire HW region. - Add reg_offset/cpufreq_qcom_std_offsets to be supplied as device data. - Check of src == 0 during lut read. - Add of_node_put(cpu_np) in qcom_get_related_cpus - Update the qcom_cpu_resources_init for register offset data, and cleanup the related cpus to keep a single copy of CPUfreq. - Replace FW with HW, update Kconfig, rename filename qcom-cpufreq-hw.c -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation. --