From patchwork Mon Aug 5 18:30:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 13753945 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-il1-f172.google.com (mail-il1-f172.google.com [209.85.166.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8043B165EF6 for ; Mon, 5 Aug 2024 18:31:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722882675; cv=none; b=cPLgfWp5QeQ3/GUe1GAlqE+774duXJPnzJ7dgzH3hJLNulnhFwnBhE1YyNhB9EX9tISHbqVgUyumtSyFEcyT9btXrVozDN6nOko3vK+oj0VJP28M13LqelnPW9iWtIa41lLP6keKCLP9ZSUMBeVZPAvvzdB0CmTkndCPYw2lb58= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722882675; c=relaxed/simple; bh=umTkgL20LJJ5BJ5TMY3wbVVZSYY4K2TQqLUKPlJzF6M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cftRp9IIvlRr2u5yLAKNnnjp/0oIqRAUlw7c+5k0b01GlFjVwuVK8Eu5uaDMAPVdUQtwjfTIAxMhCD4WzK+TJw7kT1MSKy9j4PemuSJhXRmYTSUyx9qM54lyOnObe66ffSqEdTRNJy76mKAjIAtootJzbOzV997pqvjT8CEMgL4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=PyBQM30F; arc=none smtp.client-ip=209.85.166.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="PyBQM30F" Received: by mail-il1-f172.google.com with SMTP id e9e14a558f8ab-39834949f27so49515165ab.2 for ; Mon, 05 Aug 2024 11:31:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1722882672; x=1723487472; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0rRANtn5FFSQpIi4AkDQO6AI/rum9i8w5k7JfryoiRY=; b=PyBQM30FVh81u26deIUXzTEP3TayrqVtrQQwzT4xEK42fQcy9zzaSrbDc3ApfPGndq MrynKJ7NSvlx3oWczZFjM4T83VDLiaV/F9vpJorhb9MY4l2dIKpY74ZS9AN97WuRWhzE X5+NpyOn81fTFOeboNzsfb6DaKqYvXJwyHxzCj2+eHuW8dWluYuuHcxp7xK078TSl+Bi 76Q8dz63/FXAjCIxDZcdE8dTadnnsOuh3LUUrhNHcOKYfrnqHka9J8zLmGBAY5usB0Ew TrNRV3XaM4t2czpUDKvc8+FUWSTh2JsM3oGY5PeucZLcFn23Lx4ZIBtd+tetMoQcDeda hRpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722882672; x=1723487472; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0rRANtn5FFSQpIi4AkDQO6AI/rum9i8w5k7JfryoiRY=; b=G7rfLVflF7mucY9f+2mLMCHyPLAHXjKknaqxaISNxBp4rTRdd32kVCuYw5PpN8FlY5 8Wf9cWVT+Luj3L3CNDFifsiOqHRYjbGh9Gd5JHwlqZ1Vwz+j0o2pkHceNQRSqV73YXjC oJ2y+Kp0X0X6kxryS03MH9blZ3jF2cVO8sjXpDjT6mXoVZs2YInvNqIeqF1hYHHea5rW WiOjJ9vx/2YM64CbSBnAzW7PUYiqXwOx8OYB34aMhCK3t1q5OYRLBgVUEz5DX7RFDUfB 2vnDsNinBTyWC05jpzGgNCtZ1UDR1BV9eVwq2Vg84kKw8/A/Fz9h+iQ6PXOErKIg9guT UAeA== X-Forwarded-Encrypted: i=1; AJvYcCWntGAKbe64pgmRGrP7UAk2dtsEFwYyhQ94Is+FTGTpGcsdImkxWu9xRvBq9VdEgLZTHCjYql9IyGX5jGR4+2XxHZ14O/Il X-Gm-Message-State: AOJu0YzWvmo7yDbbtp0+vRZlaWEYREP1NI9WNc2YDU4Vp70gDrgWlv0u wN2eK/odCBVgp3l1pS4hqtfoqKs9JIIsRdx2YT+pmTa07+WWQGB692k68reaF50= X-Google-Smtp-Source: AGHT+IHeeRmQwv4+q4ju/q0myu9Z6P6bR4evc/LRLY+BIe9M6etkllpDA/qldggtU/65E/yLphVmjw== X-Received: by 2002:a05:6e02:1a24:b0:39b:3635:e3a with SMTP id e9e14a558f8ab-39b36350f02mr116839525ab.22.1722882672647; Mon, 05 Aug 2024 11:31:12 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4091:a245:8609:c1c4:a4f8:94c8:31f2]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-39b20a9af29sm30867925ab.13.2024.08.05.11.31.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Aug 2024 11:31:11 -0700 (PDT) From: Markus Schneider-Pargmann To: Chandrasekar Ramakrishnan , Marc Kleine-Budde , Vincent Mailhol , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?q?Martin_Hundeb=C3=B8ll?= , Markus Schneider-Pargmann , Judith Mendez , Tony Lindgren , Simon Horman Cc: Matthias Schiffer , Linux regression tracking , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/7] can: m_can: Reset coalescing during suspend/resume Date: Mon, 5 Aug 2024 20:30:41 +0200 Message-ID: <20240805183047.305630-2-msp@baylibre.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240805183047.305630-1-msp@baylibre.com> References: <20240805183047.305630-1-msp@baylibre.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org During resume the interrupts are limited to IR_RF0N and the chip keeps running. In this case if coalescing is enabled and active we may miss waterlevel interrupts during suspend. It is safer to reset the coalescing by stopping the timer and adding IR_RF0N | IR_TEFN to the interrupts. This is a theoratical issue and probably extremely rare. Cc: Martin Hundebøll Fixes: 4a94d7e31cf5 ("can: m_can: allow keeping the transceiver running in suspend") Signed-off-by: Markus Schneider-Pargmann --- drivers/net/can/m_can/m_can.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 7f63f866083e..9d7d551e3534 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -2427,12 +2427,15 @@ int m_can_class_suspend(struct device *dev) netif_device_detach(ndev); /* leave the chip running with rx interrupt enabled if it is - * used as a wake-up source. + * used as a wake-up source. Coalescing needs to be reset then, + * the timer is cancelled here, interrupts are done in resume. */ - if (cdev->pm_wake_source) + if (cdev->pm_wake_source) { + hrtimer_cancel(&cdev->hrtimer); m_can_write(cdev, M_CAN_IE, IR_RF0N); - else + } else { m_can_stop(ndev); + } m_can_clk_stop(cdev); } @@ -2462,6 +2465,13 @@ int m_can_class_resume(struct device *dev) return ret; if (cdev->pm_wake_source) { + /* Restore active interrupts but disable coalescing as + * we may have missed important waterlevel interrupts + * between suspend and resume. Timers are already + * stopped in suspend. Here we enable all interrupts + * again. + */ + cdev->active_interrupts |= IR_RF0N | IR_TEFN; m_can_write(cdev, M_CAN_IE, cdev->active_interrupts); } else { ret = m_can_start(ndev); From patchwork Mon Aug 5 18:30:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 13753946 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-il1-f173.google.com (mail-il1-f173.google.com [209.85.166.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 342EC166F03 for ; Mon, 5 Aug 2024 18:31:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722882678; cv=none; b=tf7UcGmnGHIpX0ytflrHdUl13CpJ2Sd1Ndrh96i+DjymBuuHuHFFtFxwHD/uPKhwzNNW5CnVpV4UN/YK3X22ggYe6/f8ZsTocgaSK7w1vnf+aMtWy017+Mi6Y7QHs6pRkadskcTusvTb2vyTqQMTwmM7dTwkYvH8XiCFq1yQTw8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722882678; c=relaxed/simple; bh=X0Lb8mIRnjkJhheZaa1C9/ChMOXWk5LNcIzDjYItBcU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WGfilLBwEDZ38Xa3At2ccFrtv9z8orRMjSNKG42OdLsBZIXUrvrVEyscxBKvbtbB8E0bhQZepqvcidniC1XRSryBjLOVIi6xie0hTgdCCaefQsfFrSMcKWiFF8cg3urib4wOwyA9oGsoMCUdZbDUFA7wJX45cribW5xTWQLABes= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=HN7DwQpf; arc=none smtp.client-ip=209.85.166.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="HN7DwQpf" Received: by mail-il1-f173.google.com with SMTP id e9e14a558f8ab-39b3e127718so6204705ab.3 for ; Mon, 05 Aug 2024 11:31:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1722882676; x=1723487476; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RujnloDbg8cFq7uk55+LRxz/Crsv4ySF/ZqdPlHzEpI=; b=HN7DwQpflzpLuyP5NygpOyO7QqkBpC4FVYuyDb8ZrCNP/dmaqkiTb1/a/wndCCmV4V Jikb0MF78zkhUw08Cesz/UIOSa9GVbbWioHlJoy4xL5ZGRp4fri93KujXiAbwcsXDSwX dO9q05hGqsvqCt64G8cAoGqgc7KQPm/aDW50RYDtaEbIrS9q/l3J7/lYZPp4aJC7cqLN jnmIFHSoMfLQXscaKRdrlwYM/1UYsdDDFPxWNWD4DcgeDS7wz9Qlu8EErLU12FhvpN7o a6/Pkq3Y/X9MklUJy8jXnL66ZZr3P2jMPqwiaap2phRs/XVlIDNZDVdZFV54SDCmZIvQ H6Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722882676; x=1723487476; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RujnloDbg8cFq7uk55+LRxz/Crsv4ySF/ZqdPlHzEpI=; b=qmKV/yUm3V+olYvM9gupib71yZVsC5y0rwdCY0KDfIQ26QaaXNfv68D2GVCC4ItwYT IZ+CdIA/qRT2pkWBF+9cKDQ/ZW8sRIb6BYH5zsR0UihoSZ5AToBApQphcjRkd0zeOb9E SL1NgOK/fWxlck+o3ZgHSoK82PIi1Krg/CrQ61sQWsjGURITO/Znqxb1yZfS/PB0Y4oR Rp3o+drP5kvHM7p0cMM9+JH/MXvNPLxyU2kWaVfqH0Oi2pNSviZoGw4EcUe15hG3IbaE SnpoMdmoszqLR3lOqCRRjoYhGy7UyNkZEFma3Q6m5w4lB7TxzqG32Cg4ifLgB1HWnzkg H7Vg== X-Forwarded-Encrypted: i=1; AJvYcCVH175EqzT5627ieJg8CD2PJKuziPPh6Y3HSxNwJHmZ0ID4hbnMWmVsRht982IF0YOW84g6eHNvbibpKiyv3SOhTRKMhZWK X-Gm-Message-State: AOJu0YyvAAculejY1ESrWRaFRfMsdh5ZkRTuuj5n3nKOgiVXZEGVlYJQ j1FKIsk7G1lsHQV2hAjRtlWQdLiLFZvslY7jciQ9vrCOTDlbqh4Lh0rUeGNjW2I= X-Google-Smtp-Source: AGHT+IGK/3ryl1QS+GGbx6p/ssfqROsmqw17pu1CF1Hk361QOM09xOIdr+6PvE5wAmPwTPNRUkFcmA== X-Received: by 2002:a92:cd8e:0:b0:39b:3649:1b68 with SMTP id e9e14a558f8ab-39b36491d25mr111508215ab.13.1722882676415; Mon, 05 Aug 2024 11:31:16 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4091:a245:8609:c1c4:a4f8:94c8:31f2]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-39b20a9af29sm30867925ab.13.2024.08.05.11.31.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Aug 2024 11:31:15 -0700 (PDT) From: Markus Schneider-Pargmann To: Chandrasekar Ramakrishnan , Marc Kleine-Budde , Vincent Mailhol , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?q?Martin_Hundeb=C3=B8ll?= , Markus Schneider-Pargmann , Judith Mendez , Tony Lindgren , Simon Horman Cc: Matthias Schiffer , Linux regression tracking , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/7] can: m_can: Remove coalesing disable in isr during suspend Date: Mon, 5 Aug 2024 20:30:42 +0200 Message-ID: <20240805183047.305630-3-msp@baylibre.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240805183047.305630-1-msp@baylibre.com> References: <20240805183047.305630-1-msp@baylibre.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org We don't need to disable coalescing when the interrupt handler executes while the chip is suspended. The coalescing is already reset during suspend. Fixes: 07f25091ca02 ("can: m_can: Implement receive coalescing") Signed-off-by: Markus Schneider-Pargmann --- drivers/net/can/m_can/m_can.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 9d7d551e3534..fd600ab93218 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1223,10 +1223,8 @@ static irqreturn_t m_can_isr(int irq, void *dev_id) struct m_can_classdev *cdev = netdev_priv(dev); u32 ir; - if (pm_runtime_suspended(cdev->dev)) { - m_can_coalescing_disable(cdev); + if (pm_runtime_suspended(cdev->dev)) return IRQ_NONE; - } ir = m_can_read(cdev, M_CAN_IR); m_can_coalescing_update(cdev, ir); From patchwork Mon Aug 5 18:30:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 13753947 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-il1-f174.google.com (mail-il1-f174.google.com [209.85.166.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C126166F32 for ; Mon, 5 Aug 2024 18:31:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722882681; cv=none; b=bff2tAKF8mxvklILpRWPI+fCTfxsAZ0wl5zCKKa56c44Dj2DhTOTbpD0c2UlIrECg02Fp8C91GSr7YmfUhbheJYrfCMZptC5JcXA+h8x2ODEOjcplW+3PhUp8jN+5UKhHFfrOIV4rUyxrnBJQgaB9yP7olixppceHqFwSVQD7+g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722882681; c=relaxed/simple; bh=EbgGe2gsLdH2biBweP1nqPyr3Zg50Y1HA4LdIiHtm3k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dWp3/cZadGDgRfFx5bR0zl7na98CPaund5ksyFEZFEiNbAwBdrdy+oKEUqpl2N6kbL8Qnc4G6xuElX1HsdD7pQFq327+STsm9JA7kE0zxEZ7e8JYsJWOkzbjNIkOoKCwjfeRceZTMU/nE8XmIMtB5/7LP/r6a92cWOtv7yn2Jmg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=i/lLdj71; arc=none smtp.client-ip=209.85.166.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="i/lLdj71" Received: by mail-il1-f174.google.com with SMTP id e9e14a558f8ab-39641271f2aso39399295ab.3 for ; Mon, 05 Aug 2024 11:31:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1722882679; x=1723487479; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=POgjzXRrZKTYuk9IJwxX6t4KWtvdb6O1DoH7Fypmtpc=; b=i/lLdj71LDY6I/w47n1L5qsJ0hwunKsDG//hiUHjMxXXt5VfKmEUB1KI9naXh4xYyn P5NGl+jVpm7yJIcwJE2xYNSIlAocwSV7N+sWWKfZPXoevywXlBs6GrDWH4ZVkr3lvXRX g0yHGKFfarFwVLSW99vgu6kHDMBfjy0sa+qBCOTP2aePylQOKgeKK+FyE7tu8RnIDHAm SSMvYH6sj8YpER/xUkZiXa12nBJzjzm3lkdrncR2a6kN4DMchqjomt2SjAebasXWfMKf NCZk1mWbQ3SX+DcSJva5Ng19jcVvYgIT/5MTmjTPOhP6G2igDu2ZT2ON9AWWIB2rGq+o 0MKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722882679; x=1723487479; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=POgjzXRrZKTYuk9IJwxX6t4KWtvdb6O1DoH7Fypmtpc=; b=PdMu8/1PrmU7rKy42r2PnNL9Cq0WQgTQ8Jtj5NKTVpERKpNkST+nn/g4xm7hRlrZTg pIm5ush0rlaExSmwCMwUGxQjLdb1ilxTuvs+rm/nHvNVZroOuoFAHIkikxhlvqS48vqX 9DPPPBheki0dVhiakBR5T+riPtFfYcKDagMQQD1utm6AP4M8m7swnq9NhLL6cVU/YTVm AjmEzsUMMWJFfgVkFHeBzan/K0MLBy1C2MysY0DsAKYrMmi1WJCSD2sSSuiYtke6ruqT +aipgQQB4nwn0GLQkpmlpVRpxtNJYryQPn+oQx8Dns1/yFAhLoR4dhaiWJbrfNHAbz02 X4Kw== X-Forwarded-Encrypted: i=1; AJvYcCW/mCJbz84eT2PiGxW7PBvm+5Z+rCDn9rbo/g7Nw6sh30lQNZvPIVMMaA0YzYT3OxcIfZHnGVv2U7auJzEC360uC1hBrQ2Z X-Gm-Message-State: AOJu0Yye4toybXUQPiIj4I7fUIEN1w8yvpeby189gpdh95I0zOl06c7i GBVJj9QlBFG00I8nCowfre5N8rDmNyWNfz/ITa9oKrwrUj/GLItn1xQ7hg8dBvI= X-Google-Smtp-Source: AGHT+IGMnS1rb3UU6bj+V6bpqO+qUs1ylLOBvntJW8Xy8XScEgNEkHRyzpbGdB5iBFzFgK7uWf5xgw== X-Received: by 2002:a05:6e02:52d:b0:39b:369e:ae4e with SMTP id e9e14a558f8ab-39b369eafedmr78788705ab.2.1722882679509; Mon, 05 Aug 2024 11:31:19 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4091:a245:8609:c1c4:a4f8:94c8:31f2]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-39b20a9af29sm30867925ab.13.2024.08.05.11.31.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Aug 2024 11:31:19 -0700 (PDT) From: Markus Schneider-Pargmann To: Chandrasekar Ramakrishnan , Marc Kleine-Budde , Vincent Mailhol , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?q?Martin_Hundeb=C3=B8ll?= , Markus Schneider-Pargmann , Judith Mendez , Tony Lindgren , Simon Horman Cc: Matthias Schiffer , Linux regression tracking , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/7] can: m_can: Remove m_can_rx_peripheral indirection Date: Mon, 5 Aug 2024 20:30:43 +0200 Message-ID: <20240805183047.305630-4-msp@baylibre.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240805183047.305630-1-msp@baylibre.com> References: <20240805183047.305630-1-msp@baylibre.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org m_can_rx_peripheral() is a wrapper around m_can_rx_handler() that calls m_can_disable_all_interrupts() on error. The same handling for the same error path is done in m_can_isr() as well. So remove m_can_rx_peripheral() and do the call from m_can_isr() directly. Signed-off-by: Markus Schneider-Pargmann --- drivers/net/can/m_can/m_can.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index fd600ab93218..42ed7f0fea78 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1037,22 +1037,6 @@ static int m_can_rx_handler(struct net_device *dev, int quota, u32 irqstatus) return work_done; } -static int m_can_rx_peripheral(struct net_device *dev, u32 irqstatus) -{ - struct m_can_classdev *cdev = netdev_priv(dev); - int work_done; - - work_done = m_can_rx_handler(dev, NAPI_POLL_WEIGHT, irqstatus); - - /* Don't re-enable interrupts if the driver had a fatal error - * (e.g., FIFO read failure). - */ - if (work_done < 0) - m_can_disable_all_interrupts(cdev); - - return work_done; -} - static int m_can_poll(struct napi_struct *napi, int quota) { struct net_device *dev = napi->dev; @@ -1250,7 +1234,7 @@ static irqreturn_t m_can_isr(int irq, void *dev_id) } else { int pkts; - pkts = m_can_rx_peripheral(dev, ir); + pkts = m_can_rx_handler(dev, NAPI_POLL_WEIGHT, ir); if (pkts < 0) goto out_fail; } From patchwork Mon Aug 5 18:30:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 13753948 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-il1-f173.google.com (mail-il1-f173.google.com [209.85.166.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7ADF316ABF3 for ; Mon, 5 Aug 2024 18:31:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722882685; cv=none; b=s8APRBf/HfpXIz/Nd2tHbQHc4A6SP2d0Ds3lnZurl8wT8CiROjSucUsXefJ39sHkPs48xZpjVTCkAEwNr8wqs8OO7D3siW82qTlhwZ16mVGsgxFQPTnDc1ylBXBuO4NC1tDj3E04pKQmCkDqF8w74PYMRQT9nIs+PUg/+iW9ZHY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722882685; c=relaxed/simple; bh=1sCAMwHlLhrTJzQWswIXJnmmANEP5KJsAtG838cx+CU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fgxGhbsLRUDIZCXRJfqdnxTeqKcVLHaszULklX04IqD/ni0e1gjwc0mhV0yq3HfPh8WHhjghRRxapzQ1/rVxYw2tgvW67BLO+iMSgO3P1m01VotHAJO7GjH7g2d0NgaHB441yIl2uKB2oxw+I5MJ10QbSHUjYc/KAi7G1Ktl2NQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=Dhj8A0l1; arc=none smtp.client-ip=209.85.166.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="Dhj8A0l1" Received: by mail-il1-f173.google.com with SMTP id e9e14a558f8ab-39b2da8537dso6076705ab.0 for ; Mon, 05 Aug 2024 11:31:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1722882683; x=1723487483; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+JGlrEXu3NtOZu5ryCLf4wFhjQ6Lr9D+AY1HpLPHozk=; b=Dhj8A0l1T2+6XVR7ZfoX51L4Chh/K7x8xlxr0f3spvHa8A35r1tnxuP17OfwXTV2uj tdz9dWaHJNf/2XRE7kzMxOWSukXl1EwsHqFE8lx9q9JQfhpLgPsGCGDghgVmU3JUj+9M h+7vUbIvZUWtZJZr/Id+o054jiSFq8jDZ7W9/ZVIogYFWlCWbnqWQWzJhUdDe7UKwLcb 23r+qK/5hcgjnb/m6gAN7O1Um8idcFp7UDG9/CKB6KkzcVCGfRxUDq0LEACQ1W5pPzbi GC9TEqPe27Eecb9f0qbCVvGJkMkBq34M7xlPN5f0U9RyWZRZM0BMtRZdpn1jPIwReORq 6YRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722882683; x=1723487483; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+JGlrEXu3NtOZu5ryCLf4wFhjQ6Lr9D+AY1HpLPHozk=; b=WvWLMn/rKQHVNnfRCqhLHQvovDxyKs+7ljxfq2tt28RTcWINd02iT2+2tmxhfUaUfI +KCq5vsnfOYTE/a/F89o+FFMWoRl+KGNw0x6gQNOK/E7FDWEmvDujzGcItKO0Lxstgkn BpQsP/jpfmhGcBkNf93lZb1Agvbbvl3TL2JPXi9Fl6r0sqFXfIEP9EVFlM405XCLDQiC lB4LLTqv6UZv3c/ueCkp1BpLjjzJYKL5STutzycLedBIEWICeHJPm0AfEsmyFELuE/hV CxfDQh3+cQyPp8h5SSPMAXz85m3HVfGE/jmJCMAM21t9wX6Inl+OY77LabZD9amm8ZcS G8VA== X-Forwarded-Encrypted: i=1; AJvYcCV5GxjYQDOBy30kAzho4fIuNIxP6klfEkYvX62fFh9vLlaZQum8emoJs2eALCjzwKV5eB2hSY9hB/J6T1huW/rzQMfiOtl0 X-Gm-Message-State: AOJu0YzlNSHTteHIsyAH8voz/x9WK/NewOKRgp0vwX3QkPCxpnTCOXzo djoeEu7pxEpFoZAIi2ffKvICkkUAw6sWXo4QrPSoyIL1XMJZ7LWFupwe7mC55QA= X-Google-Smtp-Source: AGHT+IHksmBssQdErDi7l3d3mDIMU7STM/GX8eeApV/gOKjo26laMPcbWqj8OJnsZcu3YNThhvyYJw== X-Received: by 2002:a92:c52e:0:b0:39a:16b2:7290 with SMTP id e9e14a558f8ab-39b201c25d2mr98433625ab.9.1722882682647; Mon, 05 Aug 2024 11:31:22 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4091:a245:8609:c1c4:a4f8:94c8:31f2]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-39b20a9af29sm30867925ab.13.2024.08.05.11.31.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Aug 2024 11:31:22 -0700 (PDT) From: Markus Schneider-Pargmann To: Chandrasekar Ramakrishnan , Marc Kleine-Budde , Vincent Mailhol , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?q?Martin_Hundeb=C3=B8ll?= , Markus Schneider-Pargmann , Judith Mendez , Tony Lindgren , Simon Horman Cc: Matthias Schiffer , Linux regression tracking , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/7] can: m_can: Do not cancel timer from within timer Date: Mon, 5 Aug 2024 20:30:44 +0200 Message-ID: <20240805183047.305630-5-msp@baylibre.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240805183047.305630-1-msp@baylibre.com> References: <20240805183047.305630-1-msp@baylibre.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org On setups without interrupts, the interrupt handler is called from a timer callback. For non-peripheral receives napi is scheduled, interrupts are disabled and the timer is canceled with a blocking call. In case of an error this can happen as well. Check if napi is scheduled in the timer callback after the interrupt handler executed. If napi is scheduled, the timer is disabled. It will be reenabled by m_can_poll(). Return error values from the interrupt handler so that interrupt threads and timer callback can deal differently with it. In case of the timer we only disable the timer. The rest will be done when stopping the interface. Fixes: b382380c0d2d ("can: m_can: Add hrtimer to generate software interrupt") Fixes: a163c5761019 ("can: m_can: Start/Cancel polling timer together with interrupts") Signed-off-by: Markus Schneider-Pargmann --- drivers/net/can/m_can/m_can.c | 57 ++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 15 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 42ed7f0fea78..f2fc862fb21c 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -487,7 +487,7 @@ static inline void m_can_disable_all_interrupts(struct m_can_classdev *cdev) if (!cdev->net->irq) { dev_dbg(cdev->dev, "Stop hrtimer\n"); - hrtimer_cancel(&cdev->hrtimer); + hrtimer_try_to_cancel(&cdev->hrtimer); } } @@ -1201,11 +1201,15 @@ static void m_can_coalescing_update(struct m_can_classdev *cdev, u32 ir) HRTIMER_MODE_REL); } -static irqreturn_t m_can_isr(int irq, void *dev_id) +/* This interrupt handler is called either from the interrupt thread or a + * hrtimer. This has implications like cancelling a timer won't be possible + * blocking. + */ +static int m_can_interrupt_handler(struct m_can_classdev *cdev) { - struct net_device *dev = (struct net_device *)dev_id; - struct m_can_classdev *cdev = netdev_priv(dev); + struct net_device *dev = cdev->net; u32 ir; + int ret; if (pm_runtime_suspended(cdev->dev)) return IRQ_NONE; @@ -1232,11 +1236,9 @@ static irqreturn_t m_can_isr(int irq, void *dev_id) m_can_disable_all_interrupts(cdev); napi_schedule(&cdev->napi); } else { - int pkts; - - pkts = m_can_rx_handler(dev, NAPI_POLL_WEIGHT, ir); - if (pkts < 0) - goto out_fail; + ret = m_can_rx_handler(dev, NAPI_POLL_WEIGHT, ir); + if (ret < 0) + return ret; } } @@ -1254,8 +1256,9 @@ static irqreturn_t m_can_isr(int irq, void *dev_id) } else { if (ir & (IR_TEFN | IR_TEFW)) { /* New TX FIFO Element arrived */ - if (m_can_echo_tx_event(dev) != 0) - goto out_fail; + ret = m_can_echo_tx_event(dev); + if (ret != 0) + return ret; } } @@ -1263,16 +1266,31 @@ static irqreturn_t m_can_isr(int irq, void *dev_id) can_rx_offload_threaded_irq_finish(&cdev->offload); return IRQ_HANDLED; +} -out_fail: - m_can_disable_all_interrupts(cdev); - return IRQ_HANDLED; +static irqreturn_t m_can_isr(int irq, void *dev_id) +{ + struct net_device *dev = (struct net_device *)dev_id; + struct m_can_classdev *cdev = netdev_priv(dev); + int ret; + + ret = m_can_interrupt_handler(cdev); + if (ret < 0) { + m_can_disable_all_interrupts(cdev); + return IRQ_HANDLED; + } + + return ret; } static enum hrtimer_restart m_can_coalescing_timer(struct hrtimer *timer) { struct m_can_classdev *cdev = container_of(timer, struct m_can_classdev, hrtimer); + if (cdev->can.state == CAN_STATE_BUS_OFF || + cdev->can.state == CAN_STATE_STOPPED) + return HRTIMER_NORESTART; + irq_wake_thread(cdev->net->irq, cdev->net); return HRTIMER_NORESTART; @@ -1973,8 +1991,17 @@ static enum hrtimer_restart hrtimer_callback(struct hrtimer *timer) { struct m_can_classdev *cdev = container_of(timer, struct m_can_classdev, hrtimer); + int ret; - m_can_isr(0, cdev->net); + if (cdev->can.state == CAN_STATE_BUS_OFF || + cdev->can.state == CAN_STATE_STOPPED) + return HRTIMER_NORESTART; + + ret = m_can_interrupt_handler(cdev); + + /* On error or if napi is scheduled to read, stop the timer */ + if (ret < 0 || napi_is_scheduled(&cdev->napi)) + return HRTIMER_NORESTART; hrtimer_forward_now(timer, ms_to_ktime(HRTIMER_POLL_INTERVAL_MS)); From patchwork Mon Aug 5 18:30:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 13753949 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-il1-f181.google.com (mail-il1-f181.google.com [209.85.166.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B3B9816BE06 for ; Mon, 5 Aug 2024 18:31:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722882688; cv=none; b=Wu2iFNJH3NOal0RMWS2YQ8QdurPL1O0w/VAo+/RjsFnEDCoGV28G/GtuwuMPo3nkmBdRJbk00k4jrJgxZoGLBGrba3uFreI7hQvgdnobz30kQl5Gats3Pz7//NFHvObR1TXwLPheNaXWFtedr1UZoN1yW+WzOQzaQh6xeXsr388= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722882688; c=relaxed/simple; bh=9IXfsH20XvSwQIie4Zhn+/T6EtzkHPcaklqjFILszaQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lb5zgBRJGcr5OSU5e5vwTUwILKXPoEtcCAiAl0aXPAqpJqPivprXtgz0glMUleU9bAK/Wara/xx6h6tukzQ6DO8ryOtkH4+S7qpw1U8cPlwSRl6euhx2OAowN1oTEmD2rn0ZUFCkVToDTBdbpNV/IkTAJxA8/3OlJHBl3PH7fCU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=KMWVr5d8; arc=none smtp.client-ip=209.85.166.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="KMWVr5d8" Received: by mail-il1-f181.google.com with SMTP id e9e14a558f8ab-397ba4f7387so56571885ab.0 for ; Mon, 05 Aug 2024 11:31:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1722882686; x=1723487486; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GxGzwj10hbPoGUDFHjUigzECxz7Emr4gq2Vxs8apx1I=; b=KMWVr5d81ns6yMHyjRDRzC7XAfkhwW6RNwK3aFys4i0PYzoF2J83ubhqAyGUDIpqG3 PVmjeYgSRQasIIWr4BkoR4KPL4Jstl952HDmY1oQqWjdw0nU1Bqk7pu7KBuiKv27PCuH LskDYJgnUXASids/YPfIAqIJ3sXzg3K1pPPm9hwC1ju4tCH6dCqSsYKO/uynJ/jaxvcs y+EZj0c9ScBL1NofsUypnFM8rrjYp3FIu9mXSikV5NJczi/qhlg8GNcKdlOL7wt8cDvG aOaKSDdLWs2R/YltMPEQ9DIM0Q/IeL2ah/Yt48zPo0LLw681Km2ImAuxkJgGT85tOjtV +kvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722882686; x=1723487486; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GxGzwj10hbPoGUDFHjUigzECxz7Emr4gq2Vxs8apx1I=; b=Irs5UNPtJ4dkFy1Etmem0C+QWWdVktaqzyPGOlIR2fHdFikr1Y8yyYyZeSuAGdsKyt XkeYVLpmV+vMX+V0Ok/QxbF9GVOKdeUydeMuQ/qDA/N3j5eX4gMJPSD4EQOrY2fxA0SJ LrJr8yWY7Jys2hWRXGTdGH53c22m1Ik2lYjEmABetSLUDoEOt0r7L4RVphj4C4/lehM5 R1GIig0B4cn5PeDAmNnUaUaBIKzLLEBZ+seCv1lit0Bz1zSKCqx56Psf/FU7VcnHvw91 8xm7GjGUwy7lhNwziwrclVPlxd4KD2JzixXXoRHqOlA/hNI8dqXqYyw0g9q2aR0tc21o K8zg== X-Forwarded-Encrypted: i=1; AJvYcCUHLGk8lRU+gQSIEEZGN0aNWsvtk4TZXyue8oo6eMa3liYgtDZo2z69sOT3LotCe5KwCIwm2lsriayqIgseyM/F6A/nUm/v X-Gm-Message-State: AOJu0YxNYS5OhlSXOqj3KfzVaRnL2mbzc7k+R9ziGKtB1SDyD8+NWwzG F9tGm10DPZH5z7mkvukCVFNH4qc/L6Ysk17+GezA8PaPL5mwfSCdzSgwNe9fbds= X-Google-Smtp-Source: AGHT+IHbUX5iMkWxY0jz/xH/juQai5lNjO2y87fBuXrzbN7VDYTkNYag15NCr2K+gsamtX8MhFXyAw== X-Received: by 2002:a05:6e02:218f:b0:39b:2ca4:e391 with SMTP id e9e14a558f8ab-39b2ca4e898mr107173745ab.1.1722882685753; Mon, 05 Aug 2024 11:31:25 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4091:a245:8609:c1c4:a4f8:94c8:31f2]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-39b20a9af29sm30867925ab.13.2024.08.05.11.31.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Aug 2024 11:31:25 -0700 (PDT) From: Markus Schneider-Pargmann To: Chandrasekar Ramakrishnan , Marc Kleine-Budde , Vincent Mailhol , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?q?Martin_Hundeb=C3=B8ll?= , Markus Schneider-Pargmann , Judith Mendez , Tony Lindgren , Simon Horman Cc: Matthias Schiffer , Linux regression tracking , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 5/7] can: m_can: disable_all_interrupts, not clear active_interrupts Date: Mon, 5 Aug 2024 20:30:45 +0200 Message-ID: <20240805183047.305630-6-msp@baylibre.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240805183047.305630-1-msp@baylibre.com> References: <20240805183047.305630-1-msp@baylibre.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org active_interrupts is a cache for the enabled interrupts and not the global masking of interrupts. Do not clear this variable otherwise we may loose the state of the interrupts. Fixes: 07f25091ca02 ("can: m_can: Implement receive coalescing") Signed-off-by: Markus Schneider-Pargmann --- drivers/net/can/m_can/m_can.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index f2fc862fb21c..7910ee5c5797 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -483,7 +483,6 @@ static inline void m_can_disable_all_interrupts(struct m_can_classdev *cdev) { m_can_coalescing_disable(cdev); m_can_write(cdev, M_CAN_ILE, 0x0); - cdev->active_interrupts = 0x0; if (!cdev->net->irq) { dev_dbg(cdev->dev, "Stop hrtimer\n"); From patchwork Mon Aug 5 18:30:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 13753950 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-il1-f176.google.com (mail-il1-f176.google.com [209.85.166.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A4C8A16C426 for ; Mon, 5 Aug 2024 18:31:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722882691; cv=none; b=LmxJB5jnAA21yHc99EvE4VwBe8a7aRcJ8EDphc5z87Lh8YZWLD3oUI+8Uw/OUZek7G9VMKgcLlFvEhtX93/cxf7rEUgykNvsVEeHRA3fuHQH2TNdVzwnKR8wLXMOYjiyDMm/yp9fUHLkigtR3XKKj+0s4ILK+sRojug1AF/cbDc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722882691; c=relaxed/simple; bh=J1n8p9ZiV4NPzCCG4igoxgIPW/lPHOV2bvu8WbY9M3Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eqJSNuLjitGFwwRLnCjPdAwYQqXkzxutXIFNy682uz3mAtGiyZwzJ6qN72Wn74G9vF5vRlf/jsihheCnX8WojTpg5H4VC4f8ua9TMDl3Gc3QpdJzFS2kK5Dbzxi6fAF/EdR92ajuJO1p7JzruGjyPFQNsLIqjzHFgIWHiwwrOUA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=jdVMrfqB; arc=none smtp.client-ip=209.85.166.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="jdVMrfqB" Received: by mail-il1-f176.google.com with SMTP id e9e14a558f8ab-3737dc4a669so47362375ab.0 for ; Mon, 05 Aug 2024 11:31:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1722882689; x=1723487489; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=f+HPjuz5W8Yx1DVIjzCZ4+iLii+dpzxtWHgPSNE/Bhk=; b=jdVMrfqBh500qkvXX/UaWRDgiM6YyHIoH32SOabGtu+JLyRa7+eocaSpSb8pddaMvq nBLjwVZkzqebwaUjylZA+nKCy6E3xA3/JmOY+yI/Mky9vbTh0jFUalpMXrlJ7UrWOwr2 CDQ/7cntU+SD9lRAsi7bz9CxtcFYpKgfd3/J+Y+MIeHF0StI+bb7mdAVVO0MCukdcIEZ SYuUaTaeT/86+s+fD8mxyDmZDp6Q615EjDU/rxPR2VITH0miHlSjD39UR4oktExVgWxb jaSVTyVD0SpikPotCYlFZwBeP4WezB14RxRAK18+rPreb2mfjFHJhCnCUhnFtOCM2REF HOhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722882689; x=1723487489; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=f+HPjuz5W8Yx1DVIjzCZ4+iLii+dpzxtWHgPSNE/Bhk=; b=QpT/ZYtK9Ma2HTpuqblAjWcx33K1RcMVySD9BIix2uO4MKO/OxzHvs2nAVQpHylst9 pJCJl1mEacUVm7kV0hX6eNC19CS1xrgusre800ckkwln1WV7PVokYXoZJYcac2lRQ2BG uUrradQwmlJm1fyJ7DuEt3j/cTkO9I1kcXZIJHkB6ejyN50y4U44HxDTNEMzDCOWAT6j W0zxt+T2O28mXGhqxzfzrhuFQo7nutDRKn5Q4tRANakY2XBApqDMXl37ykXaMe8cm++t Hh+PwQv9Bai8P5wL4OJjcSOrIpZgBiq3FN6RVxsgEzwulCeD+AFJyDmZXksZ+GIvwMeM 65fQ== X-Forwarded-Encrypted: i=1; AJvYcCWrIoRsof9A/CKPi9vkUtaX2zgSkunbkUm1m3CBH7Tx5FsnEh5aTkdUQMOawqT67bQ0tYSIH469Qj31Wv5ez97wAVvsHDOE X-Gm-Message-State: AOJu0YyBt3BO2LyCJS3IHBku7z41z91Z410nedA/L0L80cGgTJ91s1wE ob0Qi+UHyyFcfHY39Ttmw75nBtuEdzSANzkuH9AnykR39kI6T8k2GJLtr++7X/E= X-Google-Smtp-Source: AGHT+IEq6598CGYDXwUJlEvoWxu+/g6kFoPjvVucBrR7owowbQb3f7jYWmpb4FTOuABE7Ovcpsxrdw== X-Received: by 2002:a92:c988:0:b0:39b:393e:28ca with SMTP id e9e14a558f8ab-39b393e29c4mr71466915ab.12.1722882688825; Mon, 05 Aug 2024 11:31:28 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4091:a245:8609:c1c4:a4f8:94c8:31f2]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-39b20a9af29sm30867925ab.13.2024.08.05.11.31.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Aug 2024 11:31:28 -0700 (PDT) From: Markus Schneider-Pargmann To: Chandrasekar Ramakrishnan , Marc Kleine-Budde , Vincent Mailhol , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?q?Martin_Hundeb=C3=B8ll?= , Markus Schneider-Pargmann , Judith Mendez , Tony Lindgren , Simon Horman Cc: Matthias Schiffer , Linux regression tracking , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 6/7] can: m_can: Reset cached active_interrupts on start Date: Mon, 5 Aug 2024 20:30:46 +0200 Message-ID: <20240805183047.305630-7-msp@baylibre.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240805183047.305630-1-msp@baylibre.com> References: <20240805183047.305630-1-msp@baylibre.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org To force writing the enabled interrupts, reset the active_interrupts cache. Fixes: 07f25091ca02 ("can: m_can: Implement receive coalescing") Signed-off-by: Markus Schneider-Pargmann --- drivers/net/can/m_can/m_can.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 7910ee5c5797..69a7cbce19b4 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1541,6 +1541,7 @@ static int m_can_chip_config(struct net_device *dev) else interrupts &= ~(IR_ERR_LEC_31X); } + cdev->active_interrupts = 0; m_can_interrupt_enable(cdev, interrupts); /* route all interrupts to INT0 */ From patchwork Mon Aug 5 18:30:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 13753951 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-il1-f175.google.com (mail-il1-f175.google.com [209.85.166.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F22B716CD00 for ; Mon, 5 Aug 2024 18:31:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722882695; cv=none; b=LK8LJWm++iAuvXYLcZZ2/hf/E3TKxeQnNjV3Z++PTzdeSNVryl4NBCpxvbWGjl9y0Lk9rKXZoquZNQnOgd1xgNg4dqmBlUmWUSA7dhejdsSr9LzKKhL4kLf8GcxfxlWMmYdw2hB2Z7lxprOWVM8CN6sQcamE4r4/mcxzDbwBrH8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722882695; c=relaxed/simple; bh=ChE2g8Bo15dbwXQCCELmyUPyayPuAqr/37EK4Q7ZpbM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mRipgyWuLEbfWPHArI8XjfU1VV4pwkeDcU+o4lB2rflqWNPq9CYx+YhbDSRY4wKxWB2TloE93g/pUk8OUYblKS0IoV3xQ5lCu4TPcgLvIgFp+nZDyDjRt1X1xjvf6BT7VSWa1g1zfOqiANdftcoLYhEGjPkjedmdhL/Fg242QlU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=MGgdwHrj; arc=none smtp.client-ip=209.85.166.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="MGgdwHrj" Received: by mail-il1-f175.google.com with SMTP id e9e14a558f8ab-39b3754468eso8011715ab.2 for ; Mon, 05 Aug 2024 11:31:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1722882692; x=1723487492; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Jt7QmiC+1K2MGxeb2j6VpzaOIs10RnCuQP9HHad9ocQ=; b=MGgdwHrjvjGji3glD5U++0SrVoXTlB2Dl3dc3MSCu1tPObTpuhxJXWBlElVZ4/XKEf 7ICWR+SsD+cEICW00mUpVCqbgmoyRjPoMki2KGO4j3SqB5VUJVhE7u/bBEfvZVEoIF70 hFQukWnI9b8wRevPfKaSb9RnFjtMevXNVrdjKe4M13oWL77lyfbnOKlr33P97taeE3w9 5omJ194jLesJBiKQoiGCHek7NCVZIuLvK5tGQPUM9X5jUEC8C33NjHoR02hgBCQrtGQz 9yDtqxY78L2IAZRrSo1reXF0KPpSTJjNkXC/drQYr+94XK9368y0e3h9QP5JjrGU8A2T pMUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722882692; x=1723487492; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Jt7QmiC+1K2MGxeb2j6VpzaOIs10RnCuQP9HHad9ocQ=; b=OJqvZx0Q0jDhcVUHT6Rrupz046V+ySq5vbgrnqi8kuNXstBOiOsTNDpuAoxWI70c5l cBT11N6IP4mQ9/lotLgweZ2zQwJTpk5GivOSgGhMm31N8Zb70k/D/GA08yHUdzXEsAbI T13lt2Qz9x6G4W0/uZKJQoeF5Wb9eJY28xJbcFygQOVB1fSwRc9E4AZSQ6j1z8VGfBgJ ueL72Z3gDxgHqRYCtoos+zggXMMj4HEROtgbs6AwOleLmRuGk62mBTq0PVTTvJ8BjdBY gSPq0OaFtgYJ3psUWKDZP1a3SGDzAhvdUCOI4cj4aA7scNshgE5iczuYhITVAOLiqmTF psKA== X-Forwarded-Encrypted: i=1; AJvYcCWzXl2AELavdmj4tvKjFY7cCdjpQ2z6rtPM14UzWfhZHcQsDzWd3xOUNsvqAdQnNXcw0nwiSj5OJuuoFqSFgp2MvNG1TAY7 X-Gm-Message-State: AOJu0YxvgVADIgpLZyzeCv+eEAhfFUltmIVywnQSjMUHXAceozFHRepr AE+LzuMnU8fxGQrWqMxLNJJNd7o7YfqXHenHYndn6WgqjxAJCgtsr8mDtD+S2bo= X-Google-Smtp-Source: AGHT+IFsYDvT/ScJTO38P4uPEY7MfcyBrpm0xyFckk7S5UPZJYPzTYR+VYnkh8TLJZtvjqPo5U1Jew== X-Received: by 2002:a05:6e02:214b:b0:39b:32f6:5e90 with SMTP id e9e14a558f8ab-39b32f65ed5mr87967485ab.15.1722882692118; Mon, 05 Aug 2024 11:31:32 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4091:a245:8609:c1c4:a4f8:94c8:31f2]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-39b20a9af29sm30867925ab.13.2024.08.05.11.31.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Aug 2024 11:31:31 -0700 (PDT) From: Markus Schneider-Pargmann To: Chandrasekar Ramakrishnan , Marc Kleine-Budde , Vincent Mailhol , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?q?Martin_Hundeb=C3=B8ll?= , Markus Schneider-Pargmann , Judith Mendez , Tony Lindgren , Simon Horman Cc: Matthias Schiffer , Linux regression tracking , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 7/7] can: m_can: Limit coalescing to peripheral instances Date: Mon, 5 Aug 2024 20:30:47 +0200 Message-ID: <20240805183047.305630-8-msp@baylibre.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240805183047.305630-1-msp@baylibre.com> References: <20240805183047.305630-1-msp@baylibre.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The use of coalescing for non-peripheral chips in the current implementation is limited to non-existing. Disable the possibility to set coalescing through ethtool. Signed-off-by: Markus Schneider-Pargmann --- drivers/net/can/m_can/m_can.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 69a7cbce19b4..5fd1af75682c 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -2181,7 +2181,7 @@ static int m_can_set_coalesce(struct net_device *dev, return 0; } -static const struct ethtool_ops m_can_ethtool_ops = { +static const struct ethtool_ops m_can_ethtool_ops_coalescing = { .supported_coalesce_params = ETHTOOL_COALESCE_RX_USECS_IRQ | ETHTOOL_COALESCE_RX_MAX_FRAMES_IRQ | ETHTOOL_COALESCE_TX_USECS_IRQ | @@ -2192,18 +2192,20 @@ static const struct ethtool_ops m_can_ethtool_ops = { .set_coalesce = m_can_set_coalesce, }; -static const struct ethtool_ops m_can_ethtool_ops_polling = { +static const struct ethtool_ops m_can_ethtool_ops = { .get_ts_info = ethtool_op_get_ts_info, }; -static int register_m_can_dev(struct net_device *dev) +static int register_m_can_dev(struct m_can_classdev *cdev) { + struct net_device *dev = cdev->net; + dev->flags |= IFF_ECHO; /* we support local echo */ dev->netdev_ops = &m_can_netdev_ops; - if (dev->irq) - dev->ethtool_ops = &m_can_ethtool_ops; + if (dev->irq && cdev->is_peripheral) + dev->ethtool_ops = &m_can_ethtool_ops_coalescing; else - dev->ethtool_ops = &m_can_ethtool_ops_polling; + dev->ethtool_ops = &m_can_ethtool_ops; return register_candev(dev); } @@ -2389,7 +2391,7 @@ int m_can_class_register(struct m_can_classdev *cdev) if (ret) goto rx_offload_del; - ret = register_m_can_dev(cdev->net); + ret = register_m_can_dev(cdev); if (ret) { dev_err(cdev->dev, "registering %s failed (err=%d)\n", cdev->net->name, ret);