Received: by 10.223.185.116 with SMTP id b49csp529100wrg; Fri, 23 Feb 2018 02:40:35 -0800 (PST) X-Google-Smtp-Source: AH8x225c/OMtj9Ja19v2OcIzLAbiEaF1lNXes6oUagaWAmPZjm/zJQ2XSMX1ff8tV6WyvNh6iWwr X-Received: by 10.98.147.156 with SMTP id r28mr1345814pfk.204.1519382435674; Fri, 23 Feb 2018 02:40:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519382435; cv=none; d=google.com; s=arc-20160816; b=VdDjnIZxmeRrZT8uDcG9EzL9ZYEcq3fwcmcqy3xEilrDB7lhY6/aVERAewG1dl9mlX fm73w+V/urlJMduIVjRNRJ5HMJAo/Pu8DaUIl2ey7QqcUJI7CWX8nZBaSnibJRU90gtc R4Ng7IoGFaGikex8va3Tno/qA0+P0BFDa0tJ0sikJtH+BA+msUL3nRahqAkXsh6UNOgm 3wzMHHoATSRskC5JPbehNIUaN7pwl2tlfuR0vAD/4cL/HkIwzpgsX9zHUzfqPnhS8WPG rEfE/+jftIvNfoFF6h0D2D/X5LwleAvGe+hzVfvVYYemUhFH7ecJA0k5yImlghe9KhWR YZoA== 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=+cUTUz562rN2+6B6NwOMrX3wg8nSvlROV/qwidXLZ2A=; b=WKIuildE+SZWKrke/tAbcZd9Jl2u8IA4t6Mj4bMNblDmQUHtdBE+GowMFooZPBzbWc 1XIJipdoeJKvNuZYggJbahN1SYyaDnpktSxSm11cKbFUp/cdIjKnbDMKSPfkfMj1wFuh CwxdeDfqiTE6OORuDIbh0p38ISAc3MbDPCAkri97KF7bgKaLgbqDgH4FnWR/1RWXB5ao kaAEs2ArGXQQ5ZGpvjXRCyV22M2TpggQbJ2Ls0H+TZloo3y0mJGFHLbRU0zsRXGdxpJJ eGoMDEaoAC+hN914V+0OlauKHrLTi1mWGKNpQWtpSTgzRXgXpzHVj7qerQNt+fseEg/i o8Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=QMm8pI03; 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 p14si1611337pfa.404.2018.02.23.02.40.21; Fri, 23 Feb 2018 02:40:35 -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=QMm8pI03; 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 S1751404AbeBWKjl (ORCPT + 99 others); Fri, 23 Feb 2018 05:39:41 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:53374 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750798AbeBWKji (ORCPT ); Fri, 23 Feb 2018 05:39:38 -0500 Received: by mail-wm0-f65.google.com with SMTP id t74so3791012wme.3 for ; Fri, 23 Feb 2018 02:39:38 -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=+cUTUz562rN2+6B6NwOMrX3wg8nSvlROV/qwidXLZ2A=; b=QMm8pI03FTRNgXCjbxKfJrOH8cS/BRHpccv3/HMk/txRaOj4Jky75Hb10KziWpfOys /cIvqxD1QmUAUs7LvvjVJ069+L+DE/Uxgh2GGZ+KoKuzal9DHTHsXFtg6zsn/7i9rQFm nc/epswUr9oDDaXPn9zqTRv96kRDFva+n59sE= 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=+cUTUz562rN2+6B6NwOMrX3wg8nSvlROV/qwidXLZ2A=; b=OuDva2TLIVx8vf7GBHCs4aCtWvw4kCtmwBTulw+aNcUg+o7pTRzYX2RmWv1U5OTU3Y Ncz1/vgp1k36X7suNjOOPZvzSCf5GBOMbLSf5Ikf2xJS4n3pO1vVRV3YpuaZz/NSBkIM lreALXdRzl1HPrwCtukcVGkWX5Gt2bFjfX65N0NlvhrbDXQ/11XtInyIiUJVJ4dgd7WB DM0uPFa6OcrQ5F1Bl42DH+QMMaFlqz4F3nX/sdKnc9nHOmT88lTPQa8pqA/svDbv8rnO VeG5wynFuU0/k3aFLWSYqrYBeCpBw00JIe39XYurZEEmRIdAuvmZDId5jr3NB9iP4Rnq 7bdg== X-Gm-Message-State: APf1xPBvo6XSUNiwAZtsjqT+cYSU9Nc5Sa+CORU/WdjPt4OMHQQem/eK qtn6r3pARs8+rR168TOFukvhsw== X-Received: by 10.80.168.227 with SMTP id k90mr2166264edc.249.1519382377577; Fri, 23 Feb 2018 02:39:37 -0800 (PST) Received: from [192.168.178.129] (f140230.upc-f.chello.nl. [80.56.140.230]) by smtp.gmail.com with ESMTPSA id f53sm2028589ede.49.2018.02.23.02.39.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 02:39:37 -0800 (PST) Subject: Re: [PATCH 2/3] mwifiex: support sysfs initiated device coredump To: Brian Norris 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> Cc: Kalle Valo , Marcel Holtmann , linux-wireless@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Johannes Berg From: Arend van Spriel Message-ID: <5A8FEF68.5080900@broadcom.com> Date: Fri, 23 Feb 2018 11:39:36 +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: <20180222193547.GA78462@rodete-desktop-imager.corp.google.com> Content-Type: text/plain; charset=windows-1252; 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 + Johannes (for devcoredump documentation question). On 2/22/2018 8:35 PM, Brian Norris wrote: > 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. Ok. I already agreed that the uevent behavior should be documented. The error handling you are bringing up below was something I realized as well. I am not familiar with mwifiex to determine what it can say about the coredump succeeding before scheduling the work. > 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 ;) I appreciate it. The documentation is not in the stable ABI folder yet so I welcome any and all improvements. Might learn a thing or two from it. >>> 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. Any other than the code itself you mean? I am not sure. Maybe Johannes knows. > 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? 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. Regards, Arend