Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp5197862imm; Tue, 16 Oct 2018 06:44:19 -0700 (PDT) X-Google-Smtp-Source: ACcGV63Vj9CIq18vcQaEzOjQFeoOSfOoTKYTLogsQfZ+xKEPGqdsjXwV6rfO7pV5gJAFeR7gIJ6S X-Received: by 2002:a17:902:8d85:: with SMTP id v5-v6mr1028552plo.33.1539697459648; Tue, 16 Oct 2018 06:44:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539697459; cv=none; d=google.com; s=arc-20160816; b=dQ/knt/JgmCor/Zaxoy/XdDhgm9Dxsaczl8mQf9+JJEVyKi23pE0Jsz+3i+I/Es/H0 Az6w5Sifoe0kd8sS5UW7ShpATb+3OwRKsykr4IirRMaWgzqYDgCxCexvN5JGXq2outkR O1ZYFVYthAXheRt7keO5KOTelPRNPfMyateTXJCDdKQERHDOF34YKMK2yN+hsMGW9DuK 9hxAgeU+UcUq8YYBPTv5/qr8kv/ww9QFKVS5KP8WSoz5tDh24djTrEPS3eNFSBeDfenb UpqIn7TzMmz5LuT3D2LBsY8nanRlp2qzAInpnnIE8OBtY7ha0iuuP/K5awHqbUVbvPAv dacw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=ew/LKuRyPRsNQImcIzn1HrgKz5B1mML4J0IHGOGkhyY=; b=0ICmMlbcRe+IzYa8Ntai0Is4pAMtn47FweA0ar8cSPz1rzFosPdDKoQWI/BK9fBs0l YMDa5aPA0JF3BndxoRDr38UPtTCifspD9LNB0FZYOHiZTpAeMQXuSld1SxhEQPK91sNd iRTtzQTllauZ2DvqEun/RRDIHYf8JnejCK8Fkv04uC7XVJ7iwRtoobzUZkfAM+dkOmZ+ BbFHird4XGs/DVIGfjymjia2WKvFlzXAACeIL0RrKRfa9T6ouqtCSiFXfCtk5Cl+18C8 egjrbvfPETTJsTIKYdl8DSwEE+7hrdPZOjQ+bTfPiJPpO2UlKhoFAG6DTf7Fu5JggoJR HlJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=G4geUWXU; 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 l12-v6si13697596pgj.76.2018.10.16.06.44.03; Tue, 16 Oct 2018 06:44:19 -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=G4geUWXU; 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 S1727270AbeJPVd1 (ORCPT + 99 others); Tue, 16 Oct 2018 17:33:27 -0400 Received: from mail-qk1-f193.google.com ([209.85.222.193]:36779 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727002AbeJPVd1 (ORCPT ); Tue, 16 Oct 2018 17:33:27 -0400 Received: by mail-qk1-f193.google.com with SMTP id a85-v6so14111272qkg.3 for ; Tue, 16 Oct 2018 06:42:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ew/LKuRyPRsNQImcIzn1HrgKz5B1mML4J0IHGOGkhyY=; b=G4geUWXUmd2BhaBGuSEl26RJpQPn8MXJlcCVbqfRVU085dAdQ/EYkJiAJtqWm+ybjD 7J89Zogcc1XAVwmFjiqqN0mPfVlur7UWkec/UDfZJavC0wWbDsRvw1vUVrTnpuXbGy9x 8f3J2YXFfbYkOSz4+jHEKu0n5onmT4+xy9EUE9UoAJv/W58b4QJP2fEz1LdDMjTOp+Xb bWjLTXVFacoXPfovXUiZvEfnd9pAOJKd3q1ZYCMpXYTtAi4Uuoc64SVVQwqDNYdSv3ay gXriRL9roLH05qDJlBjy6ChT4L8kB9dE05knN09gjqGaHEGdS8CbryDiaoNFLLYb167b IVPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ew/LKuRyPRsNQImcIzn1HrgKz5B1mML4J0IHGOGkhyY=; b=X2NrRvmqay1evjHbFyJaW2GvS0yMJmUeldAkAWmgCmu9DC4IpSHVXqrTJ7iMo+Gh3b 2fMcYp0+BuQloo42wFANZqaFD9hIJ6Fz76TWeDmfPzQbnwlHK4S91wcugXmVjyM/EdOt EqbkvSbDMeE28gg4K45HhqQ6FnU42JJx6TRyqulqg/9zS9RSbHiRdIIueQk4GUir7FN2 8L5OWFEyUS/hk6D2lx+N/Y/MGLgFZUlrVrRxhPb+ypjfw/6GJZTFgxt4EM09vRH0d1/m Lz35y2f+DJshPUmcmxapi6Txb5GqOax4T4sCxb3433w0C3wlqu4e0QOcdPn7B/zR/APf nQZA== X-Gm-Message-State: ABuFfogqVkRM7iebPJDE503V2WSxQpwVQ+vywJx6ccffVAfZlTmiV301 +xOEPsPmOkWECPatnLWnnqMGJOFOie8fTH0MfNN42hQbc5U= X-Received: by 2002:ae9:f40b:: with SMTP id y11-v6mr20915015qkl.137.1539697373775; Tue, 16 Oct 2018 06:42:53 -0700 (PDT) MIME-Version: 1.0 References: <20181016072244.1216-1-a.hajda@samsung.com> <20181016072244.1216-3-a.hajda@samsung.com> In-Reply-To: <20181016072244.1216-3-a.hajda@samsung.com> From: Andy Shevchenko Date: Tue, 16 Oct 2018 16:42:41 +0300 Message-ID: Subject: Re: [PATCH 2/3] driver core: add deferring probe reason to devices_deferred property To: Andrzej Hajda Cc: Greg Kroah-Hartman , Bartlomiej Zolnierkiewicz , Marek Szyprowski , "Rafael J. Wysocki" , Linux Kernel Mailing List , Javier Martinez Canillas , linux-arm Mailing List , Mark Brown Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 16, 2018 at 10:22 AM Andrzej Hajda wrote: > > /sys/kernel/debug/devices_deferred property contains list of deferred devices. > This list does not contain reason why the driver deferred probe, the patch > improves it. > The natural place to set the reason is probe_err function introduced recently, > ie. if probe_err will be called with -EPROBE_DEFER instead of printk the message > will be attached to deferred device and printed when user read devices_deferred > property. > - if (err != -EPROBE_DEFER) { > - va_start(args, fmt); > + va_start(args, fmt); > > - vaf.fmt = fmt; > - vaf.va = &args; > + vaf.fmt = fmt; > + vaf.va = &args; > > + if (err != -EPROBE_DEFER) > __dev_printk(KERN_ERR, dev, &vaf); > - va_end(args); > - } > + else > + __deferred_probe_set_msg(dev, fmt, args); > + > + va_end(args); Yeah, ping-pong style of programming (one patch "amends" something which had been introduced by another). That's why better to follow my comment for the patch 1. > +/* > + * __deferred_probe_set_msg() - Set defer probe reason message for device > + */ > +void __deferred_probe_set_msg(const struct device *dev, const char *fmt, > + va_list args) > +{ > + const int size = 128; > + char **p; > + int n; > + > + mutex_lock(&deferred_probe_mutex); > + > + p = &dev->p->deferred_probe_msg; > + if (!*p) { > + *p = kmalloc(size, GFP_KERNEL); > + if (!*p) > + goto end; > + } > + n = snprintf(*p, size, "%s %s: ", dev_driver_string(dev), dev_name(dev)); > + if (n < size) > + vsnprintf(*p + n, size - n, fmt, args); Perhaps kasprintf() instead of this huge plays around the size and allocation? > list_for_each_entry(curr, &deferred_probe_pending_list, deferred_probe) > - seq_printf(s, "%s\n", dev_name(curr->device)); > + if (curr->device->p->deferred_probe_msg) > + seq_puts(s, curr->device->p->deferred_probe_msg); > + else > + seq_printf(s, "%s\n", dev_name(curr->device)); I wouldn't care (much) about debugfs, though better to keep some order here, i.e. always print device name. Something like seq_printf(s, "%s\t%s\n", dev_name(), deferred_probe_msg ?: ""); and remove that part from above __deferred_probe_set_msg(). -- With Best Regards, Andy Shevchenko