Received: by 10.223.185.116 with SMTP id b49csp4269850wrg; Mon, 26 Feb 2018 14:28:07 -0800 (PST) X-Google-Smtp-Source: AH8x224kmXQFG0jrMEqXQrKMPk3EMmyKZX3TIbKLNbKyiyb4fXk7CHsSldTzuj/ca1GjnEng9UGT X-Received: by 2002:a17:902:b109:: with SMTP id q9-v6mr12274465plr.340.1519684087393; Mon, 26 Feb 2018 14:28:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519684087; cv=none; d=google.com; s=arc-20160816; b=zki9CWmUBWO34oypHQFIT7YZIm98XdsTDhihUJnmVxJaZ8cLoqTX0ZOTANs0GM8xaX Q3oslI5amgtCfssP4wmYZQMQ8Nex5RhnCupSFBx5tEB6xCeFjToCYKfYCdUIpHgW5lqn h7lTAydkbtCVJFmV3pa/pqNpe7E2JclNRVW7FrnRECZMgmYhO0d3EcVDBH3YIbyx+2PW JXPSrddAjxpv2K/hWfpjUic1d98mMsA7Bc8owgcZKkU6+2rGpzhihNJwbKbxDMDRSopH 02ZDHOEEslaAJh24LIfWoRjx+l0PM/Uk6zv923A9s32Pr1MMgibpHrZyucOQ958pNIAx tr9g== 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:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:dkim-signature:arc-authentication-results; bh=OMa4u6TI8pxoCnXEOAyTxfxNIg2TiOlKWmEb59rDz7E=; b=LTF30uMBjnq+TLD+kAQlq5buhsQnDoCuA8cgdKHh1jib3UOFXIxiyyUgOJJHpM6+cr naNy4Pi/en6WEDWzlkl4kD+9VF9Ld2yzvLXdhpGG5fRxbUsRQNnabuG+hgn2JeyacxxV +rFDxKnq7dcJUvz8N2aJV19Wf9FsLOruL8KZ6JXEtKuSy1uMeuH5UYqbJbtFiYPbHJ15 jYbxkZaW8YunNhfu/ZLBXNnBcW10rgCbFyzvEXSABCGeN6tspvRLPsDRBMifM08B4Ci2 OYiRpu3My2Wei2Vuhyf4tpbj+eJVc69JRlViWAUfc7gTQNh37hLW6GcPSThjFk4iiQlD zT2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=ZSpDFY92; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 68si7378796pff.141.2018.02.26.14.27.50; Mon, 26 Feb 2018 14:28:07 -0800 (PST) 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=@broadcom.com header.s=google header.b=ZSpDFY92; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751891AbeBZWZJ (ORCPT + 99 others); Mon, 26 Feb 2018 17:25:09 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:55198 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751853AbeBZWZH (ORCPT ); Mon, 26 Feb 2018 17:25:07 -0500 Received: by mail-wm0-f67.google.com with SMTP id z81so20387290wmb.4 for ; Mon, 26 Feb 2018 14:25:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=OMa4u6TI8pxoCnXEOAyTxfxNIg2TiOlKWmEb59rDz7E=; b=ZSpDFY92z0xfCHHIoUKvJPn5inqo+nW+ClP7rh9aIeZ3LW1Wcw0ZPRGz/DKMYRwkyo u7EnRN60gRA9f8rTSTFwcSTcGH7eaoYk6c/AC76lV7j1DqlrrpFDw0Gfd9W7pZLbi3o5 gryJ7/dY1hFKCZFReFash5YTug/CbgqBsjKes= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=OMa4u6TI8pxoCnXEOAyTxfxNIg2TiOlKWmEb59rDz7E=; b=iLNS5ZbqJRANwTUFY+ajXfXnfFHCVFB9SFLQJuTYq6nKfjf5N8F3saDeHq/wsgOKVk nnmbEaWaCPTAoPTPvAK2O+S31kllqN8PksNTpsDjQtLCUbD2U/pDUOs86hPup4n9JggY s6C+MkDlmlcqauZJwN1+AK/YdiEYNjzqXolRrl5MSYYIDWbzBu1h1iV2bSFI/g4P77Jb laUq+wozyDwWrC1Hjum058xCfwuz+Qj+sfeqZoiq0HXUZpbWQLEjjAAF7gmbXTZImv0M wGmJQSVj2wPT3DW5yLAbzGMwDd1aUSHSJ8r/mX6pH/yVZP+WuBXYhELU9pEFl73JvtbQ LAvQ== X-Gm-Message-State: APf1xPA+Rb2iWpPblbw1XgZbZ9R6VQITD1s5eppW/GHPzBgbszcqPY58 vDZygzseIzZHEqnsqN0/G/W90A== X-Received: by 10.80.219.139 with SMTP id p11mr16619820edk.192.1519683906282; Mon, 26 Feb 2018 14:25:06 -0800 (PST) Received: from [192.168.178.129] (f140230.upc-f.chello.nl. [80.56.140.230]) by smtp.gmail.com with ESMTPSA id t19sm8283765edh.22.2018.02.26.14.25.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Feb 2018 14:25:05 -0800 (PST) Subject: Re: [PATCH 2/3] mwifiex: support sysfs initiated device coredump To: Brian Norris , Johannes Berg References: <1519210220-22437-1-git-send-email-arend.vanspriel@broadcom.com> <1519210220-22437-3-git-send-email-arend.vanspriel@broadcom.com> <20180221225903.GA42395@rodete-desktop-imager.corp.google.com> <5A8EB4F4.2030103@broadcom.com> <20180222193547.GA78462@rodete-desktop-imager.corp.google.com> <5A8FEF68.5080900@broadcom.com> <1519383062.2231.5.camel@sipsolutions.net> Cc: Kalle Valo , Marcel Holtmann , linux-wireless@vger.kernel.org, Linux Bluetooth mailing list , Linux Kernel , Greg Kroah-Hartman From: Arend van Spriel Message-ID: <5A948942.6090102@broadcom.com> Date: Mon, 26 Feb 2018 23:25:06 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/26/2018 11:06 PM, Brian Norris wrote: > Hi, > > On Fri, Feb 23, 2018 at 2:51 AM, Johannes Berg > wrote: >> On Fri, 2018-02-23 at 11:39 +0100, Arend van Spriel wrote: >> >>>>> Well, that depends on the eye of the beholder I guess. From user-space >>>>> perspective it is asynchronous regardless. A write access to the coredump >>>>> sysfs file eventually results in a uevent when the devcoredump entry is >>>>> created, ie. after driver has made a dev_coredump API call. Whether the >>>>> driver does that synchronously or asynchronously is irrelevant as far as >>>>> user-space is concerned. >>>> >>>> Is it really? The driver infrastructure seems to guarantee that the >>>> entirety of a driver's ->coredump() will complete before returning from >>>> the write. So it might be reasonable for some user to assume (based on >>>> implementation details, e.g., of brcmfmac) that the devcoredump will be >>>> ready by the time the write() syscall returns, absent documentation that >>>> says otherwise. But then, that's not how mwifiex works right now, so >>>> they might be surprised if they switch drivers. >> >> I can see how you might want to have that kind of behaviour, but you'd >> have to jump through some hoops to see if the coredump you saw is >> actually the right one - you probably want an asynchronous coredump >> "collector" and then wait for it to show up (with some reasonable >> timeout) on the actual filesystem, not on sysfs? >> >> Otherwise you have to trawl sysfs for the right coredump I guess, which >> too is possible. > > It's not that I want that interface. It's that I want the *lack* of > such an interface to be guaranteed in the documentation. When the > questions like "where? when?" are not answered in the doc, users are > totally allowed to speculate ;) Perhaps the "where" can be deferred to > other documentation (which should probably exist someday), but the > "when" should be listed as "eventually; or not at all; listen for a > uevent." Agree. Will extend/improve the ABI documentation. >>>>> You are right. Clearly I did not reach the end my learning curve here. I >>>>> assumed referring to the existing dev_coredump facility was sufficient, but >>>>> maybe it is worth a patch to be more explicit and mention the uevent >>>>> behavior. Also dev_coredump facility may be disabled upon which the trigger >>>>> will have no effect in sysfs. In the kernel the data passed by the driver is >>>>> simply freed by dev_coredump facility. >>>> >>>> Is there any other documentation for the coredump feature? I don't >>>> really see much. >>> >>> Any other than the code itself you mean? I am not sure. Maybe Johannes >>> knows. >> >> There isn't really, it originally was really simple, but then somebody >> (Kees perhaps?) requested a way to turn it off forever for security or >> privacy concerns and it became more complicated. > > Then I don't think when adding a new sysfs ABI, we should be deferring > to "existing dev_coredump facility [documentation]" (which doesn't > exist). And just a few words about the user-facing interface would be > nice for the documentation. There previously wasn't any official way > to trigger a dump from userspace -- only from random debugfs files, I > think, or from unspecified device failures. That was my main motivation to have this. The debugfs method did not feel quite right as there is no kconfig dependency between dev_coredump and debugfs. Now I discussed with Johannes about adding code into the dev_coredump facility, but that seemed to add a lot of complexity. So I looking into the device driver core and found it to be the simpler solution. >>>> static ssize_t coredump_store(struct device *dev, struct device_attribute *attr, >>>> const char *buf, size_t count) >>>> { >>>> device_lock(dev); >>>> if (dev->driver->coredump) >>>> dev->driver->coredump(dev); >>>> device_unlock(dev); >>>> >>>> return count; >>>> } >>>> static DEVICE_ATTR_WO(coredump); >>>> >>>> Is that a bug or a feature? >>> >>> Yeah. Let's call it a bug. Just not sure what to go for. Return the >>> error or change coredump callback to void return type. >> >> I'm not sure it matters all that much - the underlying devcoredump >> calls all have no return value (void), and given the above complexities >> with the ability to turn off devcoredumping entirely you cannot rely on >> this return value to tell you if a dump was created or not, at least >> not without much more infrastructure work. > > Then perhaps it makes sense to remove the return code before you > create users of it. Yup. Will sent out a patch for that as well. Thanks, Arend