Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1351734imm; Wed, 25 Jul 2018 16:43:35 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdnAPV2D0u87RsrAH7+luCKNypzqgZobrrNM2TrVmEu76OBX5BTdBhlWhKg70tUXhvIiSwe X-Received: by 2002:a62:2f84:: with SMTP id v126-v6mr24146110pfv.115.1532562215027; Wed, 25 Jul 2018 16:43:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532562214; cv=none; d=google.com; s=arc-20160816; b=k+fK9rx5IXY4Rr1W3JKN7ecaBXAEDb3NV4RSJ+4xDy3CRtkn9Qxqs6KjEmyMNYi5kL 1o/AziU6aOqjuRfh9tPbz7msaAT3GPfe0EOM3joKtF1kQNXHX6cDfeDhOM7TBcI4HfD9 SJn8CXxIQPq+SQ+MRdCJa73X+DjRqLQ2lzJRcKN+/y1MoVv30v2XSCzVn3C1rfZHyYWf pl/crPb7eHXw9UTZGXeAfXCZ4gOhqS3ZpavJyoGAJhRh9BMYdO4pmU6qwuVbHP2zVL1A +zUve6AVl/SCPPudnqn6Ifs+06nOBxODzopKAYff9L/SUhWESksCNNLeY/TKaOmy6Na3 TqiQ== 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:cc:to:subject :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:dkim-signature:arc-authentication-results; bh=h9XasVh1/u4FHey7iDzy44Qal65mH4KHcfpPW1ebtAQ=; b=iIjtg/KsdPvaryKvAYyLG93CTs8Eag2XfVFgaTl5g0fgyWCIWOKnkBVtguRfTuamwg WvjkQ/MPaFDhZWeRw/qj7hDAQNhE/yBugxkGnQbNyMiR2euxALYl0LWIVUJEHxLb3KX/ SGB2RpnM1nBSw3Qkq5ptXLKEzJz21jvArKUsd+2QpNVseUzuPk5jMScnV7cwQNp5YDCA 5RiTLpV5JiGHYY5Tro8qto0ya4ggi48K5T27N1YMq0wi0rUyyz3DNevYedbdoTLOZK8x tsoqoTG4aGZNMvwxn7iezBiRf5v3a9F12O0I21Q6rZhfTLjUJivPqVI+5pCCeO+cef8C Ufyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@google.com header.s=20161025 header.b=iD8y8ins; dkim=fail header.i=@chromium.org header.s=google header.b=POvHaYM8; 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=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 16-v6si15912340pgr.325.2018.07.25.16.43.20; Wed, 25 Jul 2018 16:43:34 -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=fail header.i=@google.com header.s=20161025 header.b=iD8y8ins; dkim=fail header.i=@chromium.org header.s=google header.b=POvHaYM8; 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=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731675AbeGZAdy (ORCPT + 99 others); Wed, 25 Jul 2018 20:33:54 -0400 Received: from mail-ua0-f194.google.com ([209.85.217.194]:36471 "EHLO mail-ua0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731589AbeGZAdy (ORCPT ); Wed, 25 Jul 2018 20:33:54 -0400 Received: by mail-ua0-f194.google.com with SMTP id c12-v6so5804630uan.3 for ; Wed, 25 Jul 2018 16:19:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-transfer-encoding; bh=h9XasVh1/u4FHey7iDzy44Qal65mH4KHcfpPW1ebtAQ=; b=iD8y8ins8NX48vrZMfdhL3wTwDDNMubcB9agx6V4cxYWOd8RcBj+Qp1R94Ee3wr3J3 T603uhzCSUCyKkJUg0/7r+UbdoDdKcEsL6xuZgNzqpzMunZcK9yv1a5rGlL3WEynW8Fy tzD2gJmHoIU2NR59kyZNTXUAwLKRtzNhh0xQom6Si/kQqq+p/GAjesXDa/QVSmFOwTab Qcun/HTG3rE/o31YBZ5jJYceMrwa1BeRNVsRkitd9lQnY39TLgD4d9VTK6Rpc5YNLEEQ pX/1xbGqmkFsPO8My7AnjdVMshC2bhYPwCuJ2WjPjmi1IdTf4I6eAy+aeCudv/JG8ptS xtNg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-transfer-encoding; bh=h9XasVh1/u4FHey7iDzy44Qal65mH4KHcfpPW1ebtAQ=; b=POvHaYM8gC6qUWbS1OhF4ynA6Kg9V1i/YsjV2uxO8eg1kiBacgClzVaZOEna5+7EsL XkJJkZUDH7z5vteGIr4mK9b4DwE+wn78RLnNIjs37oCOq3JzGs9RfXiF9wI59HmQRIT+ +4onvS350y8kzSy5xs1QTbl8im93JXkCRbURk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc:content-transfer-encoding; bh=h9XasVh1/u4FHey7iDzy44Qal65mH4KHcfpPW1ebtAQ=; b=jaU6tifNGTJQewN8RHwcxrwmoXaXNg9c6evoaUZf5ad4coDxXo3JhUHoSj9Tc38f3s KVLCqKQLAaJ82Ch5XN/Chgv1L1Yezl6122OeGKwCYV/HSKTZC8DRa+wqhMGIvA97gszH XZXsEH7hZAAR5vZHerto21NBJ7rX20rqVky3FtrS0g8v3agDm9ZlPHspk57RO1+iBdc+ TQPak+to4zx+OAbe1rCCRD3lf1GlMChXpklGH2b2rXuVEDUAQR1BqUJYE0JBkcPsAUfv Uk09krATmVyS/vax/CFjuzuaU7VYYz1rtaXfugOOIZVafVOW34/YWQPE8U3SChLZqjVm UpCw== X-Gm-Message-State: AOUpUlF8Yr72xz4aeD52uMpEYAwggYpy1kseYDJptnneafUxPWA2vx2L evCJ17Ur8YZiGsDuRgxPC0Dk9kK7iFS+if5moxP6/w== X-Received: by 2002:ab0:11dd:: with SMTP id q29-v6mr16114410uac.191.1532560796965; Wed, 25 Jul 2018 16:19:56 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a1f:cd5:0:0:0:0:0 with HTTP; Wed, 25 Jul 2018 16:19:56 -0700 (PDT) In-Reply-To: <20180724234636.57137-1-mka@chromium.org> References: <20180724234636.57137-1-mka@chromium.org> From: Doug Anderson Date: Wed, 25 Jul 2018 16:19:56 -0700 X-Google-Sender-Auth: xnWkvGIk8jW6FCkFFgQwWkfDpCY Message-ID: Subject: Re: [PATCH v5 1/3] thermal: qcom-spmi: Use PMIC thermal stage 2 for critical trip points To: Matthias Kaehlcke Cc: Andy Gross , David Brown , Rob Herring , Mark Rutland , Catalin Marinas , Will Deacon , Zhang Rui , Eduardo Valentin , "open list:ARM/QUALCOMM SUPPORT" , linux-arm-msm , Linux ARM , LKML , devicetree@vger.kernel.org, linux-pm@vger.kernel.org, David Collins , Stephen Boyd Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Tue, Jul 24, 2018 at 4:46 PM, Matthias Kaehlcke wrote= : > +static int qpnp_tm_update_critical_trip_temp(struct qpnp_tm_chip *chip, > + int temp) > +{ > + u8 reg; > + bool disable_s2_shutdown =3D false; > + int ret; > + > + WARN_ON(!mutex_is_locked(&chip->lock)); > + > + /* > + * Default: S2 and S3 shutdown enabled, thresholds at > + * 105C/125C/145C, monitoring at 25Hz > + */ > + reg =3D SHUTDOWN_CTRL1_RATE_25HZ; > + > + if ((temp =3D=3D THERMAL_TEMP_INVALID) || > + (temp < STAGE2_THRESHOLD_MIN)) { > + chip->thresh =3D THRESH_MIN; > + goto skip; > + } > + > + if (temp <=3D STAGE2_THRESHOLD_MAX) { > + chip->thresh =3D THRESH_MAX - > + ((STAGE2_THRESHOLD_MAX - temp) / > + TEMP_THRESH_STEP); > + disable_s2_shutdown =3D true; > + } else { > + chip->thresh =3D THRESH_MAX; > + > + if (!IS_ERR(chip->adc)) > + disable_s2_shutdown =3D true; > + else > + dev_warn(chip->dev, > + "No ADC is configured and critical tempe= rature is above the maximum stage 2 threshold of 140=C2=B0C! Configuring st= age 2 shutdown at 140=C2=B0C.\n"); Putting a non-ASCII character (the degree symbol) in your commit message is one thing, but are you sure it's wise to put it in the kernel logs? > + } > + > +skip: > + reg |=3D chip->thresh; > + if (disable_s2_shutdown) > + reg |=3D SHUTDOWN_CTRL1_OVERRIDE_S2; > + > + ret =3D qpnp_tm_write(chip, QPNP_TM_REG_SHUTDOWN_CTRL1, reg); > + if (ret < 0) > + return ret; > + > + return ret; Simplify the above lines to: return qpnp_tm_write(chip, QPNP_TM_REG_SHUTDOWN_CTRL1, reg); > @@ -313,12 +441,7 @@ static int qpnp_tm_probe(struct platform_device *pde= v) > if (ret < 0) > return ret; > > - chip->tz_dev =3D devm_thermal_zone_of_sensor_register(&pdev->dev,= 0, chip, > - &qpnp_tm_sensor_o= ps); > - if (IS_ERR(chip->tz_dev)) { > - dev_err(&pdev->dev, "failed to register sensor\n"); > - return PTR_ERR(chip->tz_dev); > - } > + chip->initialized =3D true; Should we add "thermal_zone_device_update(chip->tz_dev, THERMAL_EVENT_UNSPECIFIED);" here ...also: do we care about any type of locking for chip->initialized? Technically we can be running on weakly ordered memory so if qpnp_tm_update_temp_no_adc() is running on a different processor then possibly it could still keep returning the default temperature for a little while. We could try to analyze whether there's some sort of implicit barrier or we could add manual memory barriers, but generally I try to avoid that and just do the simple locking... What about just setting chip-Initialized =3D true at the end of qpnp_tm_init() while the mutex is still held? I'd also love to hear from someone with more thermal framework experience to make sure it's legit to return a default value if someone calls us while we're initting. It seems sane to me but nice to confirm it's OK. Overall I like the idea of this patch so hopefully others do too. Thanks for sending it out! -Doug