Received: by 10.223.185.116 with SMTP id b49csp2312472wrg; Thu, 22 Feb 2018 11:36:49 -0800 (PST) X-Google-Smtp-Source: AH8x226og9QtxWT3iEQzVRSoAbhMXWe6GI/YOGJaCb51zHWkmZ16BaCMCVaPuAz/gWX3tCuCcSvw X-Received: by 2002:a17:902:4c88:: with SMTP id b8-v6mr7568324ple.0.1519328209556; Thu, 22 Feb 2018 11:36:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519328209; cv=none; d=google.com; s=arc-20160816; b=nv5EsHj/rJHQ1jqAkazoo1Aq5Q7tgdfQ71NU05VgXL7tyEPWZvpTToq0QS0D4e51Gb qDEX9l0YDXNYWhoeBhhl5ErMGwgQTotJZM29T1jBWKLDI+fNOquDUbzkdD7CXq7NflNT 4J9igC0IbWCsHsSsUKVH6B2+CjopL2JqxSg5gHqYdZnA0TbUQ3Pqna38rsVww5dGUS5e /1tiKjHN1yHEJlepZ9HSOa4HIukNL9Zd0ojVofXh++vcAUiBZdrbLfCNST37Fu3P41Jk gUybzONPzW/grC3oQdFwt+faTNAVngJTNhxQmL7tSUpMEna7++RUN8mJo0Tp7STNsJ7F KDuQ== 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=TQNlkDg1N+ZM64dEGmQOkSTC+5SDaD6TX976vkVuurs=; b=jHaxeSJSgbPMrkKt6hLPAHQj0VDoBCNygnmUMkMN5YKRj23Lui+DAA2qSutbvBt3B2 edBxbeezy8Lgxf5nDAecN1NLxnxT0AWYwP4QAzd2brWSCBmLuBpMtPtiBfT0Tvw3Oajz U2XFFhbov2+i2CxDEFpa2tBgD7bJI1HiN+ONj6WQd4KSTiy6OBSMImqW26zTepKM0OWS UUftRssSasgjGsKGxR+7dVXrTTDCcHepMn4kIAASEhOGZv+uyhI0UMgndIIy8Ft/S+op UIWk9gxiw5+4iS3DqYRllVciSJmvJ26vWwY4/YqgwvnHQE3dV6QR/xFLvuRBuJyPDrjT dlew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=LyiM1BWZ; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p12-v6si494574pls.66.2018.02.22.11.36.34; Thu, 22 Feb 2018 11:36:49 -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=@chromium.org header.s=google header.b=LyiM1BWZ; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751351AbeBVTfy (ORCPT + 99 others); Thu, 22 Feb 2018 14:35:54 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:43659 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750995AbeBVTfw (ORCPT ); Thu, 22 Feb 2018 14:35:52 -0500 Received: by mail-pf0-f194.google.com with SMTP id z14so2483703pfe.10 for ; Thu, 22 Feb 2018 11:35:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=TQNlkDg1N+ZM64dEGmQOkSTC+5SDaD6TX976vkVuurs=; b=LyiM1BWZl9fvDqj4OFqFO/Cuo/FP5mWX1XdENWVI8WUs+QDHdFUaL5IYqCAtM7BLmM Xv2Q05b7s8OACNz9WS0/ycbcUPbW8Cv7fY8/t3EtwY3BsEjMBIPRyNvntFwkFJAMwhxR +7pi4IoBnnxbWGMQFlcjI1rlwoY9GiJIDJHGc= 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=TQNlkDg1N+ZM64dEGmQOkSTC+5SDaD6TX976vkVuurs=; b=H0sjgR/8oivssXDmFgqdlPVN8aAK37DR7dAez34NZoIjqzmDGURjiCkdLIQVrUMthg VR5Q97a0Vv0+SouzQvXcn2ievyXBtd9UboM3srzs5g88xwLSBHxdNKJDhOVoH3G/P45B lFg+XaTBnMpAZcgXF7ozW4PqkE1YMiOIJwONnKP733J+dJ/6lITfqAhfW7yzfkQh69qi N2QrFSb6B79hZ7LlYG4xnWLt04GTpfY2+buQ2O4LtuxiQ//G7AZYPq+1bk9/QkJMoHEL GzdWxYjjPFKn7egfFReZTDgyIjWxYpnAZ9NsbOYrO09gWIltUZN/XcCCcJOC+e1ApzDE TdVg== X-Gm-Message-State: APf1xPBcXpTMwZM4BBh++G/jo2ZWr+PjD1AF4guGeB1TBCON+sZW4ERH 76Jn2p6DaAxi7JG6SkDk57umHQ== X-Received: by 10.99.171.10 with SMTP id p10mr6458636pgf.176.1519328151946; Thu, 22 Feb 2018 11:35:51 -0800 (PST) Received: from rodete-desktop-imager.corp.google.com ([172.22.102.85]) by smtp.gmail.com with ESMTPSA id x188sm1181252pfb.138.2018.02.22.11.35.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Feb 2018 11:35:51 -0800 (PST) Date: Thu, 22 Feb 2018 11:35:49 -0800 From: Brian Norris To: Arend van Spriel Cc: Kalle Valo , Marcel Holtmann , linux-wireless@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman Subject: Re: [PATCH 2/3] mwifiex: support sysfs initiated device coredump Message-ID: <20180222193547.GA78462@rodete-desktop-imager.corp.google.com> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5A8EB4F4.2030103@broadcom.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Arend, On Thu, Feb 22, 2018 at 01:17:56PM +0100, Arend van Spriel wrote: > On 2/21/2018 11:59 PM, Brian Norris wrote: > > On Wed, Feb 21, 2018 at 11:50:19AM +0100, Arend van Spriel wrote: > > > Since commit 3c47d19ff4dc ("drivers: base: add coredump driver ops") > > > it is possible to initiate a device coredump from user-space. This > > > patch adds support for it adding the .coredump() driver callback. > > > As there is no longer a need to initiate it through debugfs remove > > > that code. > > > > > > Signed-off-by: Arend van Spriel > > > --- > > > drivers/net/wireless/marvell/mwifiex/debugfs.c | 31 +------------------------- > > > drivers/net/wireless/marvell/mwifiex/pcie.c | 19 ++++++++++++++-- > > > drivers/net/wireless/marvell/mwifiex/sdio.c | 13 +++++++++++ > > > drivers/net/wireless/marvell/mwifiex/usb.c | 14 ++++++++++++ > > > 4 files changed, 45 insertions(+), 32 deletions(-) > > > > The documentation doesn't really say [1], but is the coredump supposed > > to happen synchronously? Because the mwifiex implementation is > > asynchronous, whereas it looks like the brcmfmac one is synchronous. > > 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. Anyway, *I'm* already personally used to these dumps being asynchronous, and writing tooling to listen for the uevent instead. But that doesn't mean everyone will be. Also, due to the differences in async/sync, mwifiex doesn't really provide you much chance for error handling, because most errors would be asynchronous. So brcmfmac's "coredump" has more chance for user programs to error-check than mwifiex's (due to the asynchronous nature) [1]. BTW, I push on this mostly because this is migrating from a debugfs feature (that is easy to hand-wave off as not really providing a consistent/stable API, etc., etc.) to a documented sysfs feature. If it were left to rot in debugfs, I probably wouldn't be as bothered ;) > > Brian > > > > [1] In fact, the ABI documentation really just describes kernel > > internals, rather than documenting any user-facing details, from what I > > can tell. > > 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. Brian [1] Oh wait, but I see that while ->coredump() has an integer return code...the caller ignores it: 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?