Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4075621imm; Mon, 11 Jun 2018 06:39:47 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK19oXPPdDNRxKvklUTx6BGV75xVTtxvcYGNvpN0JhgjDN6azHc6pVHSnm/hIU9GGqSoIJj X-Received: by 2002:a62:d453:: with SMTP id u19-v6mr17642165pfl.203.1528724387725; Mon, 11 Jun 2018 06:39:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528724387; cv=none; d=google.com; s=arc-20160816; b=BiHSBhuSuidAbbdycecB6dYKldg2NJr2jj4fb/jNuHvr7Wy3v0tqHme/EZRJ/zzKc4 Y0m0ySbo8fFPBmiCrZccHGdH17VZitAYD6TUbhO9aTHLUMWTUaXJ8f1vYszJpLAg4Dry H1zQ36/AC6AUC//dGFM3hS3gfE2FbseWLo9Az06nc0zCRzfRi6v+QAUZe+8GfapxGXH/ t0D9eFr3mJcXMdDl016KD1nJ7PYQNSOTeWxtYctCiasLtv6TKRinRpBKPD58HtQlpYEp U0zZ11I8wZAHW5LV5sbBhFs6nEf7S3H6kxhQ7BVXeLTEIIGKPmYse2Yfw32Mk8RoEPH/ P/tQ== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=PDaNw6ymM7t/oY+Us1HVnl14viFZBnctTSAi1qIGX7k=; b=n3Ty4KtOqkCtry/E6+wfvZrMtzlUNJnZ+pKrpYXqLtJKnLKi/6Zpu4Kdr0mSGUeuG9 bQCQDAlFxbV4e0FdB2uoRTbX2HznR9Vu8eKcxrtuC4L4HKqtKHfK6KHRZEN4Xn3ZMkEJ 8mBRC2mHgMjoTqFcUqb4iewR3ROM8BB16uq0cFXx84ZbvQu16iG4V9G8iNoVIL28WGRi D0FOs8+sFA1KFevU9c0bLKpsSx9Be36F6CX6SJvpE/OU9YO9lYRctuAPmz3QSiPSiChF yDMrPuI1TGpX1G+asMSRb5AnCqm8kIdZvEBdgXXYBiT3LnCuu7I9lc4gNQdvwkUimMRo ISzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Q//KOPOK; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h189-v6si33734808pge.266.2018.06.11.06.39.33; Mon, 11 Jun 2018 06:39:47 -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=@gmail.com header.s=20161025 header.b=Q//KOPOK; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933358AbeFKNjF (ORCPT + 99 others); Mon, 11 Jun 2018 09:39:05 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:52628 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932917AbeFKNjD (ORCPT ); Mon, 11 Jun 2018 09:39:03 -0400 Received: by mail-wm0-f68.google.com with SMTP id p126-v6so14781437wmb.2; Mon, 11 Jun 2018 06:39:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PDaNw6ymM7t/oY+Us1HVnl14viFZBnctTSAi1qIGX7k=; b=Q//KOPOKI+GdnfC93+K6e/pgfA+IDtGrYItMHrWIRsaouI3bV5mbcfNW+wcIaxOKPG DmZVOoc3J3UNdv8+BaFzHpJlrRbnCR/3ppzfTqKk5XvPQSHf2Y+z+/xTnal61egTCqqB Saqlsc/c5v/eQC/l/BfFwMxI3v7IzF3thid7/gnWjDAlboFR3SYG2wKhPvUxpFuOT9Th ic2iaJ2ABErhskAY6gcgFJ2hOoaPf5Vmuk9K9Kk6lO4zbNR+lTM1d5NUZhxI+D4X2LHj KKUPOHAy/ponzfuAAqvWJx7Q4xgMDFhZuUAI7NpnC/y3dVR5tXHzLJexrgZviW/DN25p F1VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PDaNw6ymM7t/oY+Us1HVnl14viFZBnctTSAi1qIGX7k=; b=DySqfU97xRK5c/bNlUrVdwkj/7U8WP6rA5fADLF0zxy1PPtmFLkaGG97h3k+eMnTyN aJMk+j4aZtxSXz4rltle4FqSTQx1DFYMoDTcWHW55m46N8rPivBKAEUYPnDpo8ocJtdv f8YtYHPCDzMBd5YnRfUW7ZE3sY6rVq/u9daB2i1K/KTntR2RGwjKHGKLCo0PZlCE5VF+ NuTVagcSmj8mZyFzFvmwLF0fU1tI83O4BwZCBPcnBhcR/IZBNkcn4j5ScgsE4Sw4LH4g dw8fS5dWMXcXD1AIgIIboP1C/390SNOBbrgt4Gg0Kxp55rPrgCOP7lRlRZkPIVerCHOt 0pHw== X-Gm-Message-State: APt69E2X62NflCEKO0tBsXsGfsFsIERBR0qgFg9ztppa/jKzA7TmsaBB Wv+P4UWyrbGanI+ZtAwOsO8= X-Received: by 2002:a1c:4203:: with SMTP id p3-v6mr9127557wma.111.1528724341412; Mon, 11 Jun 2018 06:39:01 -0700 (PDT) Received: from dimapc.localnet (109-252-55-168.nat.spd-mgts.ru. [109.252.55.168]) by smtp.gmail.com with ESMTPSA id 84-v6sm8897764wme.16.2018.06.11.06.38.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jun 2018 06:39:00 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding Cc: Peter De Schrijver , Jonathan Hunter , Prashant Gaikwad , Michael Turquette , Stephen Boyd , Rob Herring , Mark Rutland , linux-tegra@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 5/5] memory: tegra: Introduce Tegra20 EMC driver Date: Mon, 11 Jun 2018 16:38:52 +0300 Message-ID: <2038303.qe2mJgr7in@dimapc> In-Reply-To: <20180611114133.GD31977@ulmo> References: <20180603223654.23324-1-digetx@gmail.com> <20180611113503.GC31977@ulmo> <20180611114133.GD31977@ulmo> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Monday, 11 June 2018 14:41:33 MSK Thierry Reding wrote: > On Mon, Jun 11, 2018 at 01:35:03PM +0200, Thierry Reding wrote: > > On Wed, Jun 06, 2018 at 04:42:01PM +0300, Dmitry Osipenko wrote: > > > On 06.06.2018 14:02, Thierry Reding wrote: > > > > On Mon, Jun 04, 2018 at 01:36:54AM +0300, Dmitry Osipenko wrote: > [...] > > > > >> + if (!child_count) { > > > >> + dev_err(emc->dev, "no memory timings in DT node\n"); > > > >> + return -ENOENT; > > > >> + } > > > >> + > > > >> + emc->timings = devm_kcalloc(emc->dev, child_count, sizeof(*timing), > > > >> + GFP_KERNEL); > > > >> + if (!emc->timings) > > > >> + return -ENOMEM; > > > >> + > > > >> + emc->num_timings = child_count; > > > >> + timing = emc->timings; > > > >> + > > > >> + for_each_child_of_node(node, child) { > > > >> + err = load_one_timing_from_dt(emc, timing++, child); > > > >> + if (err) { > > > >> + of_node_put(child); > > > >> + return err; > > > >> + } > > > >> + } > > > >> + > > > >> + sort(emc->timings, emc->num_timings, sizeof(*timing), cmp_timings, > > > >> + NULL); > > > >> + > > > >> + return 0; > > > >> +} > > > >> + > > > >> +static struct device_node * > > > >> +tegra_emc_find_node_by_ram_code(struct tegra_emc *emc, u32 ram_code) > > > >> +{ > > > >> + struct device_node *np; > > > >> + int err; > > > >> + > > > >> + for_each_child_of_node(emc->dev->of_node, np) { > > > >> + u32 value; > > > >> + > > > >> + err = of_property_read_u32(np, "nvidia,ram-code", &value); > > > >> + if (err || value != ram_code) > > > >> + continue; > > > >> + > > > >> + return np; > > > >> + } > > > >> + > > > >> + dev_info(emc->dev, "no memory timings for RAM code %u found in > > > >> DT\n", > > > >> + ram_code); > > > > > > > > This seems like it should be dev_warn() or perhaps even dev_err() > > > > given > > > > that the result of it is the driver failing to probe. dev_info() may > > > > go > > > > unnoticed. > > > > > > Absence of memory timings is a valid case, hence dev_info() suit well > > > here. > > > > > > I can't see anything wrong with returning a errno if driver has nothing > > > to do and prefer to keep it because in that case managed resources > > > would be free'd by the driver core, though returning '0' also would > > > work. > > > > I disagree. A driver failing to probe will show up as a kernel log entry > > and is something that people will have to whitelist if they're filtering > > for error messages in the boot log. > > > > I think it's more user-friendly to just let the driver succeed the probe > > in an expected case, even if that means there's really nothing to do. If > > you're really concerned about the managed resources staying around, I > > think you could probably get rid of them explicitly. By the looks of it > > devres_release_all() isn't an exported symbol, so it can't be called > > from driver code, but perhaps that's something that we can change. > > Maybe an easier way to avoid keeping the managed resources around would > be to move the check a little further up. That way, we can abort earlier > if no EMC timings are available, before any resources are even > allocated. > > The tegra_emc_find_node_by_ram_code() function would need to take a > struct device * instead of struct tegra_emc *, but otherwise it should > work fine. Good point, thank you!