Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp2367190rwr; Fri, 21 Apr 2023 08:01:29 -0700 (PDT) X-Google-Smtp-Source: AKy350bIHls9YYVHtqHiqc/AkwhG337Qm4jLB3XqZGzN+icVNer/cqyG2TxEofCRRMIxKloC6iQq X-Received: by 2002:a17:902:dad2:b0:1a4:f4e6:b68 with SMTP id q18-20020a170902dad200b001a4f4e60b68mr6572311plx.3.1682089289160; Fri, 21 Apr 2023 08:01:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682089289; cv=none; d=google.com; s=arc-20160816; b=vGpw+dd965OhdNP4J8Imkz46XhLSZvjme0M6nR1sd3w2dDpC9zVVhyDHidP1PrHbd7 C+Oqzqpzge2qzEAx79Szy16WSAOFs1bTOzkYJkqdTuZF/sbCqNCAp2k3q/Q4L4peKNMM J0OV2zT1gJHQRFZlpKTMr1EzvBf6wB82HjI3Izb5zjSbw5v2rRr8oPxBbZra3PfUQeM7 p1Rdx+pT/Aqbg4ltsGSHJmiqu9v0RN9HBlcQAsvzp6mwpC05KsSmctixXHzLOUPmbOtp aoIaUwVXZZoDM+egJHj9dAlqoneomvzwywRRQIv/KL86kFP3swOR6e4Mflyjfd4m9NPt qGKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=wywWnhOuE+0DcIU4ueBcvpTkOXGVmA0wp8sn1mo73kY=; b=oV3zoRdEjvJ123kd38RucTKrDbBIzXumXADg+ao8Y96XvUFudpcPiUbj7yPwWJZCUt BT3B23dHTbK13vnGC2DxYwHa6ToFf0IgI6QlA1+5OMT+03FfQxB6rpgsTcSe2RZeHx34 kULFXJAzTt3PUTrTYp0nuEGsP47ZWkDcTAGHQjGA3cNeOrsKRnGwmXuNW781HWhMFBDU zXCvJsEdb1Rwg8qo5oiMc++objCxO2RV019SR8Vz+KgUb9epEALCLonadF8rsAcfG17a yqhtJafPrZLpVYyiMRs7fmpEn0vUgi/pDzZWAmbbEMzlu4JyZGbnwJLy7IeJiMzo80YR bBww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chrisdown.name header.s=google header.b=JHPN1tlN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chrisdown.name Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e19-20020a17090ac21300b0024742007433si4795295pjt.19.2023.04.21.08.00.50; Fri, 21 Apr 2023 08:01:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chrisdown.name header.s=google header.b=JHPN1tlN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chrisdown.name Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232725AbjDUOlj (ORCPT + 99 others); Fri, 21 Apr 2023 10:41:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233023AbjDUOlY (ORCPT ); Fri, 21 Apr 2023 10:41:24 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A50B15613 for ; Fri, 21 Apr 2023 07:40:21 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-3f191c1a8a7so5550235e9.1 for ; Fri, 21 Apr 2023 07:40:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisdown.name; s=google; t=1682087922; x=1684679922; h=user-agent:content-disposition:mime-version:message-id:subject:cc :to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=wywWnhOuE+0DcIU4ueBcvpTkOXGVmA0wp8sn1mo73kY=; b=JHPN1tlNTN2wco5YysAMlww7I2VPprMyPlat9vVd5y9RjtQAthg5h62tLTT48gidC0 wG4QYINpbTbiiVWd0SHKroZk73Hrqb02/w69C4zKa8rcSbtP77Blz0mts+h4eyy+z5ZG a9WXf4A3zroXWeKuMPvILGbWw7J+L9vIwBGBk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682087922; x=1684679922; h=user-agent:content-disposition:mime-version:message-id:subject:cc :to:from:date:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=wywWnhOuE+0DcIU4ueBcvpTkOXGVmA0wp8sn1mo73kY=; b=hKCpZnEl8jHEf218rshnfbwYSKxbmAcqwA2S9jIoU4f3eNyaRMw2AjUOfg54O2CYBU DBbZb7Psu7NjeXgQQZB0jfzPESPFP04bC/bO8dtkcTo5Is/g0qZT005iUFHo2qWO6k7z TUvZGz5qBqo05gyn9KZ82HI4ZkCsoflYQpOIYXmiJc/Jk6JwWCeDguqg116K3Y0wCKXw C+diMKN9169shs9KRTTiK70D/avJjtG7S2BqWWprdg1xKFkh83dG5q+Z34GOJE2dZKPU wqmgThQkV5F752iJiNBXkOWvhLLbACW1M/3oS2wXjpHnw0uSApHDQbDq0cZLX4sbCYpS YY+A== X-Gm-Message-State: AAQBX9endR/1yW7fwM5ujZcv3JChHmvTpAwvdxXv5VXFb8R8s4x6Woy2 ywh+W2pg6ac4k8BOnGqcie3zsHXvu6l1Dv0A5LU= X-Received: by 2002:a7b:cbd9:0:b0:3f1:94fe:65e0 with SMTP id n25-20020a7bcbd9000000b003f194fe65e0mr1484021wmi.26.1682087922446; Fri, 21 Apr 2023 07:38:42 -0700 (PDT) Received: from localhost ([2a01:4b00:8432:8600:5ee4:2aff:fe50:f48d]) by smtp.gmail.com with ESMTPSA id y32-20020a05600c342000b003f173956a82sm8268375wmp.21.2023.04.21.07.38.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Apr 2023 07:38:41 -0700 (PDT) Date: Fri, 21 Apr 2023 15:38:41 +0100 From: Chris Down To: linux-kernel@vger.kernel.org Cc: alsa-devel@alsa-project.org, Jaroslav Kysela , Takashi Iwai Subject: [PATCH] usb-audio: Rate limit usb_set_interface error reporting Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/2.2.10 (2023-03-25) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When an error occurs during USB disconnection sometimes things can go wrong as endpoint_set_interface may end up being called repeatedly. For example: % dmesg --notime | grep 'usb 3-7.1.4' | sort | uniq -c | head -2 3069 usb 3-7.1.4: 1:1: usb_set_interface failed (-19) 908 usb 3-7.1.4: 1:1: usb_set_interface failed (-71) In my case, there sometimes are hundreds of these usb_set_interface failure messages a second when I disconnect the hub that has my USB audio device. These messages can take a huge amount of the kmsg ringbuffer and don't provide any extra information over the previous ones, so ratelimit them. Signed-off-by: Chris Down --- sound/usb/endpoint.c | 5 +++-- sound/usb/usbaudio.h | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index 647fa054d8b1..2cd99cc8c360 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c @@ -916,8 +916,9 @@ static int endpoint_set_interface(struct snd_usb_audio *chip, ep->iface, altset, ep->ep_num); err = usb_set_interface(chip->dev, ep->iface, altset); if (err < 0) { - usb_audio_err(chip, "%d:%d: usb_set_interface failed (%d)\n", - ep->iface, altset, err); + usb_audio_err_ratelimited( + chip, "%d:%d: usb_set_interface failed (%d)\n", + ep->iface, altset, err); return err; } diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h index f5a8dca66457..38a85b2c9a73 100644 --- a/sound/usb/usbaudio.h +++ b/sound/usb/usbaudio.h @@ -67,6 +67,8 @@ struct snd_usb_audio { #define usb_audio_err(chip, fmt, args...) \ dev_err(&(chip)->dev->dev, fmt, ##args) +#define usb_audio_err_ratelimited(chip, fmt, args...) \ + dev_err_ratelimited(&(chip)->dev->dev, fmt, ##args) #define usb_audio_warn(chip, fmt, args...) \ dev_warn(&(chip)->dev->dev, fmt, ##args) #define usb_audio_info(chip, fmt, args...) \ -- 2.40.0