Received: by 10.192.165.156 with SMTP id m28csp652226imm; Fri, 13 Apr 2018 05:42:53 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+Ro+0OgGBb00APyEwKs1ozwjXbGyGRRZx8SvOCxRKYXWldZimzwpL2ptdXoRuGpra704h3 X-Received: by 2002:a17:902:6689:: with SMTP id e9-v6mr5206256plk.176.1523623373656; Fri, 13 Apr 2018 05:42:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523623373; cv=none; d=google.com; s=arc-20160816; b=MSqWRC7L6nTgQIwPCQ9zOSpHdwwT6J8foP7YhOv4MA3ECCxv3UKqXl9lP7F7z3aPxk Ia3x938HnV98BJB8Ur000zGloWtOzmSns1VB47igRwkPPIGbX3Y6JHFK+x98bBy/kc4J aF8/9YRHLJr2G70y6z4lWR0o84Jv9Y+EMUgaRhJQ1j55392OpaRnYFrpJgM/QWdEi0d/ qo/feHkV1sMrk3//CMy9Q+LoJ5IcUQqZCt3oYFmFI2pS5hcjqHU77D+GHX1YwyX8S7hL 3/JEjXeSXRYmS6PmYclVltUHu80dEbjc+5D1ATkbjxnzUlg7oyq44yhsjkkzRFTHHhFo 8yFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=OR9u+GKlg7aCkt0/tNft591d1nsJxXISNV+R8fYNqDY=; b=H3scS3/pGJ0Oqs1ClJkoinp12FRW8jc/12nsD6k2NU0gtoyyOqjfF9kF9oQZXD0Yyd 02UYnRbmKd6RbVJ0SXkxVB7bmhkGNqm56VOyyQgcNvydkp+5v0sUYyv58jeXrdeSdSpF O68JR0lMiAudueSwBVGZe0fuAb0gUuVY4y7X77c7Nccsju81IkL+Bb8QY7uIhF184mt4 7CYvCKMQDmnkch+t7STvbuRvMK4RzQI8esfAbi9WPYfIRW0bAqPEENS2UU+7UalkLQ0Q DSYbvTk0+FCA4T5ncATweN0ooTGb7sykxW5hH2hG0Z7EHi72ovcRpO6c072qUvuIF6kQ qlgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HYtBPZHq; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d127si3929468pga.201.2018.04.13.05.42.39; Fri, 13 Apr 2018 05:42:53 -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=@linaro.org header.s=google header.b=HYtBPZHq; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754762AbeDMLiz (ORCPT + 99 others); Fri, 13 Apr 2018 07:38:55 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:51294 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754752AbeDMLix (ORCPT ); Fri, 13 Apr 2018 07:38:53 -0400 Received: by mail-wm0-f66.google.com with SMTP id u189so4559196wmd.1 for ; Fri, 13 Apr 2018 04:38:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=OR9u+GKlg7aCkt0/tNft591d1nsJxXISNV+R8fYNqDY=; b=HYtBPZHqED79lX97Ua+May988zEIxWPhpc7n5jt04LZI5g9123SnN4soCCBlw/d5xK AguN81FgOj6mqigmn+RYcLgXAzqYbU66whTsN7nz3SeL8kKHy9GKby+QhxX2U8Mj8GKF TC7atSeyIRz52f36gaXeEIpY7lN63whSzZGq8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=OR9u+GKlg7aCkt0/tNft591d1nsJxXISNV+R8fYNqDY=; b=VbWcPRZqD6b7Ok01Dlp+IJTniCdyLcJD/0dNu+7vhVGAPH5o+Idv6qGGmzlgMJPD2/ WQqlzxulpktwbXQCl0DmgaiHkNxj9ynPjI3yn3AjWGyLfb/DI3JS6ndGmOQRfBd5mI9g MJmTADEiPAQ1vs8xELfJ4eHKSA7aJfelg0P1gqGsxHIKjbl6sz+AYpGJ9r6Jw9IoMV9U 4ZhQy50S7Kjf7+ZqJgsSQ2VGO0YHi4RxgbS4JUQk8d01DcVbGRFa98bpnMS1gFrAjv9A JQr0qtlUdqHclI+D16j3bGU1lZXT0JALBC5YZJAev7TAtOUqwU0CmdvSIngoqcPnKgWd DYvw== X-Gm-Message-State: ALQs6tAbV6uZ34ej79STcSW06jyvctTVf6TGUj6GuYDx2fPRAZvhBbmE jZQdNiysRE+G0Sk+tW9GBSWYxw== X-Received: by 10.28.170.205 with SMTP id t196mr3601823wme.42.1523619531752; Fri, 13 Apr 2018 04:38:51 -0700 (PDT) Received: from holly.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id y191sm2591290wme.14.2018.04.13.04.38.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Apr 2018 04:38:50 -0700 (PDT) Date: Fri, 13 Apr 2018 12:38:48 +0100 From: Daniel Thompson To: Daniel Lezcano Cc: viresh.kumar@linaro.org, edubezval@gmail.com, kevin.wangtao@linaro.org, leo.yan@linaro.org, vincent.guittot@linaro.org, linux-kernel@vger.kernel.org, javi.merino@kernel.org, rui.zhang@intel.com, linux-pm@vger.kernel.org, Amit Daniel Kachhap Subject: Re: [PATCH v3 6/7] thermal/drivers/cpu_cooling: Introduce the cpu idle cooling driver Message-ID: <20180413113848.xj7hg7gsbxpxekbo@holly.lan> References: <1522945005-7165-1-git-send-email-daniel.lezcano@linaro.org> <1522945005-7165-7-git-send-email-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1522945005-7165-7-git-send-email-daniel.lezcano@linaro.org> User-Agent: NeoMutt/20180323 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 05, 2018 at 06:16:43PM +0200, Daniel Lezcano wrote: > +/** > + * cpuidle_cooling_register - Idle cooling device initialization function > + * > + * This function is in charge of creating a cooling device per cluster > + * and register it to thermal framework. For this we rely on the > + * topology as there is nothing yet describing better the idle state > + * power domains. > + * > + * We create a cpuidle cooling device per cluster. For this reason we > + * must, for each cluster, allocate and initialize the cooling device > + * and for each cpu belonging to this cluster, do the initialization > + * on a cpu basis. > + * > + * This approach for creating the cooling device is needed as we don't > + * have the guarantee the CPU numbering is sequential. > + * > + * Unfortunately, there is no API to browse from top to bottom the > + * topology, cluster->cpu, only the usual for_each_possible_cpu loop. > + * In order to solve that, we use a cpumask to flag the cluster_id we > + * already processed. The cpumask will always have enough room for all > + * the cluster because it is based on NR_CPUS and it is not possible > + * to have more clusters than cpus. > + * > + */ > +void __init cpuidle_cooling_register(void) > +{ > + struct cpuidle_cooling_device *idle_cdev = NULL; > + struct thermal_cooling_device *cdev; > + struct device_node *np; > + cpumask_var_t cpumask; > + char dev_name[THERMAL_NAME_LENGTH]; > + int ret = -ENOMEM, cpu; > + int cluster_id; > + > + if (!zalloc_cpumask_var(&cpumask, GFP_KERNEL)) > + return; > + > + for_each_possible_cpu(cpu) { > + > + cluster_id = topology_physical_package_id(cpu); > + if (cpumask_test_cpu(cluster_id, cpumask)) > + continue; > + > + /* > + * Allocate the cpuidle cooling device with the list > + * of the cpus belonging to the cluster. > + */ > + idle_cdev = cpuidle_cooling_alloc(topology_core_cpumask(cpu)); > + if (!idle_cdev) > + goto out; Perhaps nitpicking but it might be better to set ret to -ENOMEM here and avoid initializing it during the declarations. There's no bug in the current form since ret is never assigned to outside of the error paths, but the unwritten assumption that ret keeps its original value throughout the loop seems like a bit of a landmine w.r.t. future maintainance. Daniel.