From patchwork Fri Jul 26 19:59:38 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: 13743133 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (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 EF324132492 for ; Fri, 26 Jul 2024 20:00:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722024003; cv=none; b=r4jRC9lyPeSC3QrVB6xD/rEOVK6rg0wnFZ1lgStGXBuMu5Zw7aAk+E3XNFGihAx61gMb6ZCEmu8/PxG6h/htGpLGbW6EVkY2VNi7c5CGGiD+7dJYhuJQmoz0SkBIh/NevSP2JOKP0HHiDtu5+XfY+uFaboHXEUwnbulS/5slzpo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722024003; c=relaxed/simple; bh=umTkgL20LJJ5BJ5TMY3wbVVZSYY4K2TQqLUKPlJzF6M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=H/x2N1W8sR8486Pg9f5Fr30TDs8ShPfDlbkmWmn1nEQcNbf6xe1YnTwKiRRZ1HKflr6aHDTcYeXflzui/o4qEd7v7vnBw1GRoKE3O+sE8yOt3/jbgmeO1q3+Kt2bYSy1vGTvCMs6+pQYs5MvUoETXzG0cYEalO9OgUyiOGK67mM= 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=XeGNwk76; arc=none smtp.client-ip=209.85.167.44 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="XeGNwk76" Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-52f04b3cb33so3672135e87.0 for ; Fri, 26 Jul 2024 13:00:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1722024000; x=1722628800; 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=XeGNwk76gxDVusoj/Y2TjLDt1/jG130lyY33Z7QsYOFtFv6quscWEU1Kq2TSR2zPTk DsxWKSn3JPj6FgaRW1gMmLmlyFP8XMc02jJvNkzWF06Q2qWrhLZhgC3NLgyjoUrqCTwl xJV6v3dTJXtX3u6rBT9PLD1Z8khP/p/FiRfsrpUt8SFsvS8vflYbn8fV7cvW8cTaNXUE uTCOQef5XDrBA+Rp/XrTmDSGnOyF1ZSxLz3p6quvyAAzalbrnfCZ5t9avdsSCQ4uWCh3 7JD+hcrpJfyNtRw80aO7w1U7lMkydX1EqAHTd4LiqkrCnqWetqlnUhVt16TdW/4vCwjk ESQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722024000; x=1722628800; 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=bLSVud/3q+7kk8CVXdVQ2lbH2FU7AN7LPuUM/iEwOY0+/B388Fb2WppkMyZKinZLlz D1n+NQT856rTPSDTJjZ7EziYcnxbqh3Jb+IyoXvmusoINay3f2yHsjCdPS87szSbSn4d PIs9cis47t6zDncoWq439g8+wYEjLAZoNhjfefeNYOpXUX3H5FRmHnd7cwEA1EcHIEQS IJnQb5Wg6Qno79PelV7Vo3F58X323ROTqTJa8OgD1uUDgAa+mpar8hWFVxO5O+CwZgbS nZXct0y/MT6gMNQv+CAlHIxlc6HjL5vYlYM817GcEH/eW4noM/JB61j6KqzyrBBupY7F Za2Q== X-Forwarded-Encrypted: i=1; AJvYcCXYegVrgOf1sej8GuLUF7Waj0kxB17ntSFwSYBF9LAlFB4hUJUiDynsumxBk1T2IbBzowUFmQiNj9uML2LIapMA9o99BfGM X-Gm-Message-State: AOJu0Yx+ytl0l66Vym/ww2uojpA/NrIL4ktE9lUEEsnHU4xx5ytjaX05 Rgy3Ogeg/nLNpvLjONQVaoHt/3uu/jh9pfzl3KgyJNZvbSuq+T9n2dmghXxxBJKvwG8sd7n4XGX b X-Google-Smtp-Source: AGHT+IFqyJeT7Bd3hBXayuB7ciuhZR22Sas07xipqxPU0HZelY0F87AGXarcmLjhetiEv/Y3obpt/A== X-Received: by 2002:a05:6512:2c96:b0:52f:d6d0:fc52 with SMTP id 2adb3069b0e04-5309b269222mr656156e87.6.1722023999888; Fri, 26 Jul 2024 12:59:59 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4091:a245:8609:c1c4:a4f8:94c8:31f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7acad90e1esm209999166b.151.2024.07.26.12.59.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:59:59 -0700 (PDT) From: Markus Schneider-Pargmann To: Chandrasekar Ramakrishnan , Marc Kleine-Budde , Vincent Mailhol , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Markus Schneider-Pargmann , =?utf-8?q?Martin_Hundeb=C3=B8?= =?utf-8?q?ll?= , Michal Kubiak , Simon Horman , Tony Lindgren , Judith Mendez Cc: Matthias Schiffer , Linux regression tracking , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/7] can: m_can: Reset coalescing during suspend/resume Date: Fri, 26 Jul 2024 21:59:38 +0200 Message-ID: <20240726195944.2414812-2-msp@baylibre.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240726195944.2414812-1-msp@baylibre.com> References: <20240726195944.2414812-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 Fri Jul 26 19:59:39 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: 13743134 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) (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 B2D48143759 for ; Fri, 26 Jul 2024 20:00:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722024004; cv=none; b=gfej2DuLwyDfB6xxCINLKfuViLSQxueo+8dfaJXDGxHDhqkmsjfUivg4h6GvbjO1eIYKCBZQxdzy3tgoAV4iqTTdksxEkUrjlDQkpcNdsP4wFuholcdTuLJSEG14U1z6y1PUR1RKg8Pv0ERRH59TcclLKj9tyFKtoONeOIOskvw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722024004; c=relaxed/simple; bh=X0Lb8mIRnjkJhheZaa1C9/ChMOXWk5LNcIzDjYItBcU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p73zmL4OyMNMnFfZtPSMFyNzVu10tKDjoAzfoSHONqLUpGmDqf53pr9oU+kr806IE3aLyNNEiQ2HEBk0Nj8N7+TiyP4x3iz+icjze8xyQ9sjks31njbSl9QGT8cG6lYFjbbOnDvKUcDs3185DX5YQ+RADsCf4UTrgXmIhnNBMW8= 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=UnJcUbJr; arc=none smtp.client-ip=209.85.208.43 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="UnJcUbJr" Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-5a79df5af51so6321816a12.0 for ; Fri, 26 Jul 2024 13:00:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1722024001; x=1722628801; 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=UnJcUbJrDG9Cq804yVbehwjGAd++KrMBOQzz716Pwcnv2sym3XrA7RBcmayl3k23cg vMQhICD4s+3vEUxb9aUAyDpJrAkQVB8rdJgqUGaYZmVyjxg6W74kTpM8c/ysgNJmK2bW 95aGCuNTw6nVqAFvvfRHF44wWPcd/ejbxP0XEDWNzYS3HrLt0s3YjajH3NPktFKkGINP xejpMzWqF+zG/Wdz3P8g6AoXkGdbWurp+mRQM2tRWa8Po1K3/fER+akwyvplj1C6K1qg 5kD14gKfLDLB1JKgcfk5+CtiYDCj/++PoUAHuI7r4Dh+9hTGnwfyESrVP3WezvKWGqoI fgtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722024001; x=1722628801; 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=ShRSc0jcRn/O9UdoC+6zv8FfEbI+VhUE1TXt3Wroq2f88b4jt6qtmmG39iI3ptSyrw mG1Dt4wHzCFkdkWGoSDPo7HLim+Fp3VHd2qOdy48cHNk7PwTs1pdz7NEB0z8mlNmNNb3 88bG5XizueJ+W81ZUEEiBK0zfeq51bDex4vbaF55XIVFXMtb16FxrUmooW2Rs4jGBstc jD+L5xCKLy0WpxQCUcULlqiESGBVB+DeuCFPKfRd1/nwrmsAPXowRKqRamgu58EZUQOm XhuypGEi1xBQQM3eRYBHMywT+ZYrXyRXGqPXTZ6M0ELQ8x9KEssuEPYN/fopvqSqNdxW Ugxw== X-Forwarded-Encrypted: i=1; AJvYcCW5Z+5u5Ry+TCXC2mUSNaSlD8pb+mxuXTIJkKdzsAbQP77UcAdsxBGgHj9304iwuNk0ypUhVrSjEtyPPsEDetM2vwR719SM X-Gm-Message-State: AOJu0Ywrx8PtBi2bvbsNpUlEvJZspjWdfQaxJFtqDOkgsK5rFK+pbZdB eTNF4D5xGdoBEdqAhuMwv1F791aD6FTJDs36W2dpCOdP+V9L23v/6BLnguQxayw= X-Google-Smtp-Source: AGHT+IGLTeby7IgSps+WCZxoecp8rEY41Qs9z/KH8R39SBVZDRYsG+VUFkY5AJGG2wUOq14cKvVarA== X-Received: by 2002:a17:907:7f88:b0:a7d:2772:6d5f with SMTP id a640c23a62f3a-a7d3fa3f8bemr56915366b.23.1722024000997; Fri, 26 Jul 2024 13:00:00 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4091:a245:8609:c1c4:a4f8:94c8:31f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7acad90e1esm209999166b.151.2024.07.26.13.00.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 13:00:00 -0700 (PDT) From: Markus Schneider-Pargmann To: Chandrasekar Ramakrishnan , Marc Kleine-Budde , Vincent Mailhol , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Markus Schneider-Pargmann , =?utf-8?q?Martin_Hundeb=C3=B8?= =?utf-8?q?ll?= , Michal Kubiak , Simon Horman , Tony Lindgren , Judith Mendez Cc: Matthias Schiffer , Linux regression tracking , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/7] can: m_can: Remove coalesing disable in isr during suspend Date: Fri, 26 Jul 2024 21:59:39 +0200 Message-ID: <20240726195944.2414812-3-msp@baylibre.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240726195944.2414812-1-msp@baylibre.com> References: <20240726195944.2414812-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 Fri Jul 26 19:59:40 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: 13743135 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (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 ED017149E1E for ; Fri, 26 Jul 2024 20:00:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722024006; cv=none; b=OAV9M29j11yw74MQbseM57/RMuZFr1E/JfbubERn34gEERGWbZXYDsKml4EoSqqsqs6M5lfXiIZ1ZzdFkez6L13nMDA/I7eEVkxIe2+VXR7jrTNWsjEP2eGN/ZEPn5Osj34ctoilHYS/Or34uATgGZaer1V8rw9yrjGlXvrIVYg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722024006; c=relaxed/simple; bh=EbgGe2gsLdH2biBweP1nqPyr3Zg50Y1HA4LdIiHtm3k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=E+TXX8VFA/jPOn5Sa6n+wVycwwZfr7GyXg/tb5VEV6FxuZ33Yp7mCttY/TIAr4AobrDMgV+aoblwo+IALWxGLZI6slD61wMHFMP53R+xE01Jkzx9ejE6kjxq9hHg7M6N7fRTDa15hVKK1tuoyKrG7azUr4L3jncWvXcCajBMDbw= 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=vE8wLO46; arc=none smtp.client-ip=209.85.218.45 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="vE8wLO46" Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a7a9a7af0d0so256508366b.3 for ; Fri, 26 Jul 2024 13:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1722024003; x=1722628803; 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=vE8wLO46tz42t4+EsgXj+WRE4wNMAzeRXioKCIhmj+m/AiV3tN3sLLwv84HFS1+HM/ kMoguvHy4wsBHXuGaxgFnH9TwN5JzbqUcYcG09nuxFCQHPI0dt1Rr56yCiQZKkIl57Fe F38W+bZg2IuT6eXoRhTQkOYCp4QleVN4TpiYzjr5jrLN7WyU1/lv9RRAet9EPo6kb00t dpBZWeidfzzi7vGPOGPYkUthyQJlGpar+eJxmjYvnqzEGwdfOM+JDUYwR6XuOrX20Swl inSB/U5ESurF9zn6DOG+aHUv7Buwfqjcz1Irta7IOBORcDIN3IIJ6IbzCbbJqdew4kB5 gRzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722024003; x=1722628803; 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=mL4onmgdDH5b3ryBAbzr5C/AWsfa176PvbenmBM/C3dX0Sm8Z8pfNUka6aFq9y6Hyi d/6BSmnmF4TWbSB6ZxL8HVRppJJs7cCBGnNlLdbi7M1rhP1idtz8i2uaMtdCgFrcqY2G ecuscWivRLchOzbJXc7RZcUB93kmdMLhd7d5BtX6QoMYLYFF2fvZ6VEh1Nm/mAdpGYno aQLAQYE5hrUxQCxKmuEOo32+qVf/6cgbb/VdQrKi3YlRP5XfpLN3qxYhrq5G7jd/VQgz R44tMyvxz9sI2vzQLFLubLaE4Mj95chXaW8RcF2A77qv6CZo6q22fHe2Gsiz7PU9xoeb KGXw== X-Forwarded-Encrypted: i=1; AJvYcCWIOSBJBv//EMFpxZr06NNP7xgIgS9UrJFO3gIQEo/Jo/RRkVd/mP5HMwlq9ViVp+ql2cspCf1KcUTCYoHuEiRxPASCddwJ X-Gm-Message-State: AOJu0YwMR1twJnY6An7RPENVBK3qm4Oo2b2J2FpzvCo4VruwHmcBDPYo ppp7PJy+oCRjboO1ThGY7t0Qt7Ky0UQR5+7B9PZY4keWqQpKgd9qNefR5PlKauYawnpqV3mH8PX K X-Google-Smtp-Source: AGHT+IFTEGZPICz8oxt3K4AgX4DGGbn/vDQD5wGVMFK8bcxJxs67PXzAxqfUJbBP4LD3EEqv+kU6xA== X-Received: by 2002:a17:907:2da7:b0:a7a:ab1a:2d65 with SMTP id a640c23a62f3a-a7d40160769mr43935566b.67.1722024003367; Fri, 26 Jul 2024 13:00:03 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4091:a245:8609:c1c4:a4f8:94c8:31f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7acad90e1esm209999166b.151.2024.07.26.13.00.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 13:00:02 -0700 (PDT) From: Markus Schneider-Pargmann To: Chandrasekar Ramakrishnan , Marc Kleine-Budde , Vincent Mailhol , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Markus Schneider-Pargmann , =?utf-8?q?Martin_Hundeb=C3=B8?= =?utf-8?q?ll?= , Michal Kubiak , Simon Horman , Tony Lindgren , Judith Mendez Cc: Matthias Schiffer , Linux regression tracking , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/7] can: m_can: Remove m_can_rx_peripheral indirection Date: Fri, 26 Jul 2024 21:59:40 +0200 Message-ID: <20240726195944.2414812-4-msp@baylibre.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240726195944.2414812-1-msp@baylibre.com> References: <20240726195944.2414812-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 Fri Jul 26 19:59:41 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: 13743136 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) (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 1A87C14EC62 for ; Fri, 26 Jul 2024 20:00:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722024009; cv=none; b=P/xRUNUNPxcCR5li0/IEdaGP1I7yyMRkEdbjAg7l6obUCSA0fn1KtKvzYUWIWq1LPKm5b6MJ0MHLCUtqnw1RpFdMfJFHnMzF6Jkc5HpjchHj4ZGBxX74usUT/0/TLsH1jWNDv5LMRWeUdG9Iap8mannvDUV0F/sXW+/eXNjDCD4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722024009; c=relaxed/simple; bh=J14Wge9LcsEa7FQuC1M+/lsG9UZ/eoPKBj1txE0yej8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jTAqnYL9lISGIfMWoKxkUv5YdFtsCA+WCZ/uJz6P37IlIDMGJVpY/U4TvJken5fsvIA94W0bReG2vtbPVGPk4B937gMP0l3xRpqXNltx2QfUrPF7m9tjzZHKqXD5pOQWjTGkWySjBGGNVECHPvrLNibCLOFjg4/LYFIEWJJlMD4= 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=yUFpBD0v; arc=none smtp.client-ip=209.85.208.44 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="yUFpBD0v" Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-5a309d1a788so2838646a12.3 for ; Fri, 26 Jul 2024 13:00:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1722024005; x=1722628805; 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=CvEzDkwz6VWUUds2tie0+9vVLaqnWTgyheAACKxwxaM=; b=yUFpBD0v/GYuTjQmepxGGNxZrGzoRuOL+oz4PzCVuJwCRpzuwkErlQy/xZXsjTg0ny GtLcy/wbqJvxrm5+38f7bdGDJgI2dQEi+c/9WtZV5aqSWZwwMOzZhxKWtCnrSfj51bIs XnkY+o1XFWKzYOOxDf+Jtb+vF4ngbj7qyPykc8Bax9F1Qw1KXGe+7oh5S9sXXlINtmo8 +wgggMjsCcSRHKso1+U7U06nyHr0jvMSMccZOF/tbh5J1cYCO8wFBqtBraObjc2o6jWZ N91H/0FVb0YV4fuRoHJBjDMS5+roRiNZXdqYJ4wqHYp3wnCCerZi4O5OIYa+stLCBzeh CqNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722024005; x=1722628805; 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=CvEzDkwz6VWUUds2tie0+9vVLaqnWTgyheAACKxwxaM=; b=ckhOQvMVAU1YRdS27KBE6c+73jK6TxQlIbw5p18Rb5PQNKPdUPPEqD8Ii+M6qWwb73 A3J8NnGyX5dqysKZpbpyU6xzNRCTYI2uJ4K0s/KmxS71P4YGGMXeu1DO3FYnPlhbJyie oD6yi7KE5lhL22j3KsZrYkMa3D3Q8/U+/I27+9xY7k+Wcql7MjsR2+vHowR8dXLT7P7x jgfB8qD0PhUIiRWch9AtIxGctXJ0f3O5qCuX5g/XELShRpqoZD3sVVQ78U+o2Ywzun8o /n/oZ8KcaE9e6t9rCJ4ucDkdo5/AIX3Y+N0iM+6cAVphMvEYPIpVeGL+hZI8KnGUrUc/ 065A== X-Forwarded-Encrypted: i=1; AJvYcCWUlznr5Zt+n7ic97Prr5TYQLXwwzOR3EopwiY35Yb5+rwiK0GZCFyKZsK132Eu0N+85wFRf0jM+BQkRSg3doXd2ba+OirN X-Gm-Message-State: AOJu0Ywef3UF4xKYlPlPr7x10aXma3MZ2ZqqP1c7m9bRqoiFVTOoKaBU o/px39xasYL0bfbitqxysK6F1xVqLBU8FrLu/0YF3KM+G0WpDrmB/X6KSybJoR8= X-Google-Smtp-Source: AGHT+IEoDGkSOlQQ1HqCH1hfBsQQjAOrogps53xCogk84g3vmjMcSvrVqFKhcBtYalOd4BgYXx9pIg== X-Received: by 2002:a17:907:9409:b0:a7a:b1a5:21a6 with SMTP id a640c23a62f3a-a7d400a037amr42049766b.33.1722024005422; Fri, 26 Jul 2024 13:00:05 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4091:a245:8609:c1c4:a4f8:94c8:31f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7acad90e1esm209999166b.151.2024.07.26.13.00.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 13:00:05 -0700 (PDT) From: Markus Schneider-Pargmann To: Chandrasekar Ramakrishnan , Marc Kleine-Budde , Vincent Mailhol , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Markus Schneider-Pargmann , =?utf-8?q?Martin_Hundeb=C3=B8?= =?utf-8?q?ll?= , Michal Kubiak , Simon Horman , Tony Lindgren , Judith Mendez Cc: Matthias Schiffer , Linux regression tracking , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/7] can: m_can: Do not cancel timer from within timer Date: Fri, 26 Jul 2024 21:59:41 +0200 Message-ID: <20240726195944.2414812-5-msp@baylibre.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240726195944.2414812-1-msp@baylibre.com> References: <20240726195944.2414812-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 | 58 ++++++++++++++++++++++++++--------- 1 file changed, 43 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..e70c7100a3c9 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,16 @@ 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 +1237,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 +1257,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 +1267,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 +1992,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 Fri Jul 26 19:59: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: 13743138 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (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 9DB7615099D for ; Fri, 26 Jul 2024 20:00:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722024011; cv=none; b=B8oJHN7s8sLPTkP1EH/xnxTPK57IVO09W2H1tVP+XD9QIzgrG0l/pbTjHy5nTb/V+3aPseQyETnLr4pzGqtrefDeAo94hsfwWoTmTEGt/3lZg1KQ3T6Fo9Z4so+aW/8hTyZdnyUX/S51QNHetYO/NTgYG36yjVF6QZIkffmY2fM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722024011; c=relaxed/simple; bh=t6EwZ6i4na0n8NMTSrZB1GIshA5X1Zsp8851eUofPjM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RQ6cEUIW2Zgd9r0Ep2Q42uQ07HoVXhwZfEvhKCxtceEwB4Rn5GYIXN5IjaTIyXRSN6SXmiR86ADU5WPU/pjQTpOJ3KcruyGE12wTCKAZhyTv11vL5ysfhFB8CYLx+3KRoTqV/ShV5659fw9w3aIbhzoKTyCDfZZg5gaR6ETKd80= 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=EDh3v0EF; arc=none smtp.client-ip=209.85.218.52 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="EDh3v0EF" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a7a8e73b29cso167681266b.3 for ; Fri, 26 Jul 2024 13:00:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1722024007; x=1722628807; 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=n6vACS09qfMp/6TXOWUchSNtennyGoJCWfR5pa4HeUA=; b=EDh3v0EFWYqQmztkws5YnVxrv1SuxKZ8kmQRNhuc5bTBh/bYHU37tPzY8fKgRtfVyN 2xIylUEHb2cLXibbi1af4e9HjV+A8jnEhnwBXncpSIdYUxnJl5R6d0R/RDpPnKTJoeEX Rd223ZHVWOSba2uKp2XM1rpY4/Ghxp6E/P7t2uQFjwHX/X7JeAznwy4wXkvm7ORml0p9 pCSmBNAx1QoywM+k3EhxU2QAFLVHiU8zkkvcBKkrKZCL4zZQ/crpYlM4RVj/0t8SDADP RXhh2gl+8gpoVAD6qfu2aiGdZ/2DLMRLrWJe6EQKC7otVZ/jWcBcFR10yCCt+SeLp8OP I8IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722024007; x=1722628807; 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=n6vACS09qfMp/6TXOWUchSNtennyGoJCWfR5pa4HeUA=; b=OERvcVwCtuXIOw5aKd95COU1RyzbbBdIgqvtBqsK8nih+I3aTbyLy9UAFdGjJixded YQLnM0ipksuvYv4bpXlT1lHfyUlS4AtkuGFJGmgl8NkkQcXYvhXbB23/f7sm9/QmN4ea 3p+M1i1xv5GUY7fGSuSZxPLqH/ipVar46MT09AvjEJmvae/YGxue+VD3P8WR7QNOFra5 P7ydZnCZZqA/RT3tOinGmuM27JvZ12PEwXPku6r5K/mJnpSmDCF4/sZvnH5QK+PAP1Lg EmNhfZXI9Vx8X3a/384ksssRWV3aX3xFnDt64FpiHbP4bqaxh20Acl2rFA8JsZY6am/E kfHg== X-Forwarded-Encrypted: i=1; AJvYcCXnJnDg1alW2WGSD8irEuA558GCwChDbCaeAwQJCWu20sMfEpzulzhNh1IYGrxln2d+GfyQ/rcDRHMnnN85zPirUoZCGHtK X-Gm-Message-State: AOJu0YzM668+/wysQRmuWJmmCMJbQiud+iwR+hz7b9LyfliwqUSZBoHs HRPRwN3ttSpvw3gAX5YzFE4L1J4Kxpj4Tsc134Hmx75knrrYQ9bt+jUnsrZPjMs= X-Google-Smtp-Source: AGHT+IEvy1txv1WUQfzxlMFCu8wRQC6RbvPsAnRENjxXb+mowGIzRFW6VNoCJbR9EDAeoYQ9pEjbew== X-Received: by 2002:a17:907:7e92:b0:a7d:33f0:4d58 with SMTP id a640c23a62f3a-a7d40128730mr45428566b.48.1722024007043; Fri, 26 Jul 2024 13:00:07 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4091:a245:8609:c1c4:a4f8:94c8:31f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7acad90e1esm209999166b.151.2024.07.26.13.00.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 13:00:06 -0700 (PDT) From: Markus Schneider-Pargmann To: Chandrasekar Ramakrishnan , Marc Kleine-Budde , Vincent Mailhol , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Markus Schneider-Pargmann , =?utf-8?q?Martin_Hundeb=C3=B8?= =?utf-8?q?ll?= , Michal Kubiak , Simon Horman , Tony Lindgren , Judith Mendez Cc: Matthias Schiffer , Linux regression tracking , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/7] can: m_can: disable_all_interrupts, not clear active_interrupts Date: Fri, 26 Jul 2024 21:59:42 +0200 Message-ID: <20240726195944.2414812-6-msp@baylibre.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240726195944.2414812-1-msp@baylibre.com> References: <20240726195944.2414812-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 e70c7100a3c9..bf4a9ae76db9 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 Fri Jul 26 19:59: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: 13743137 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) (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 E854215351B for ; Fri, 26 Jul 2024 20:00:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722024011; cv=none; b=mm3/u2Ptp3tDXXzmdn311Etb0+F8lZ6oCf+NBJQYMOORQMtSXNEDex+Pqo+RH/uaR235stfE2HNKb+IT7dPhwddTNvAvCjqbV+AZjy1U1fqTv2Iw3TN/9jDI9NDlwHw1CFpWh4Ne4V0BTod0xaN3OQWinPl4bFA743pVIxu8QA0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722024011; c=relaxed/simple; bh=kgU2ysUlTalRtPMUoLD7OgezubN/PKKaPGTiUiaW48Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aBu5ow+0fn0OB8Ex/XMuyw6GuyTXi1j+NDqCb5aJpvpqQMou5LXmCUSlJUs1e/s0liS7XVxZiEElsmp738Nf/S0tCv5M0OO9T8YbY3IBw17CJ51WWxch8azhnw57rgmcw3oUfmXGQEU/5L2xAGurrUo9cj2K5LLZ95N/NHMUohw= 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=NlYD3o0Z; arc=none smtp.client-ip=209.85.208.45 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="NlYD3o0Z" Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-5a1c49632deso2909331a12.2 for ; Fri, 26 Jul 2024 13:00:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1722024008; x=1722628808; 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=QclbSBAyJmUNV1FmC5rcCovTowLRmYkjOf848LBChQs=; b=NlYD3o0Z+f+qqZo503CsGvzWfjqwbQffSLp7v4bVtDGEAqtbj5HSGNxxXIQ3EYT0D3 R93FAtVr02vR4SDdn0EOiveR4Ib4JikpmrGQJ4Ss4avFzBJknzUfUNMuEShCSbJ3+b8t x1xxzR1ZvJ2D4GiIHsLwDnJG3IsyDRscLBQRp5qRGOjhpkycUFaHBgu8kulP16AM4WD4 hDH+kzrwCReG6tXU1B3qsA9XP/l55cPv3BWV9kjpBYIIc7mpm/eQjqjDqm73UU0HY4a4 YcgQOK2hbACT2YemAX1E5i1FJKkX8e2R9lLYPzkWl6I2kT5AfI1z6s+bWkXlcQnHPho6 XcEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722024008; x=1722628808; 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=QclbSBAyJmUNV1FmC5rcCovTowLRmYkjOf848LBChQs=; b=funvyYHZNSgk7MwPU010bAxIo1lCjVohoiI1u65IVn8GMyFIuJmx5O2U4b8SdnQSwE 9qsRDhK4lp+9lxdzvirQOO4xaswknXohFb7EXtn7082X2hwbDgi1vrEZyHV8lY3dVynM Xz72siNe+WZhUgEpREMpL+OCNIicX8wdPodN/l7C9R5qn5IeUfBgRfLHB5/VIuQM9kTb v4+MkcmTYrQuObjhWkFXeEpISasXPNrOExQlR3G88LGS1hcNQRRKc2m21d7tAwp66was xdEds2k9QOlxzkOmE1LT6PcgiGnCuHTL7KkMCw/6GDUSSXKawBRc+0ijxChXS23VA817 ECiQ== X-Forwarded-Encrypted: i=1; AJvYcCWniXAKgNlwaSlOeP88durQ4e+Un3+D2eWuMWv+CbPC7/f6Vm3NO9eDH6RCG4SrJEp/G1s0cp1gy+e1rBBvAC5fpBWGf3RL X-Gm-Message-State: AOJu0YwRh3QEy4YUV0AYsf9/7bJgvUxcY988Nn5/nCDN8HXBf8/t4R55 DY4nUqdDxyYl6n8Y51WdGeDVm4c625BAn+DvNcDgxhhgLO5MwkdnkV9Bdu6Nfwg= X-Google-Smtp-Source: AGHT+IGBz2/F4chosPYowE/GtxDK8/p2E686h0ildr36QYwqG2G1z5tpS2ZWzxOnfdGhbz9kV6ILlg== X-Received: by 2002:a17:907:2da8:b0:a77:c824:b4c5 with SMTP id a640c23a62f3a-a7d4004414bmr37367666b.18.1722024008110; Fri, 26 Jul 2024 13:00:08 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4091:a245:8609:c1c4:a4f8:94c8:31f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7acad90e1esm209999166b.151.2024.07.26.13.00.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 13:00:07 -0700 (PDT) From: Markus Schneider-Pargmann To: Chandrasekar Ramakrishnan , Marc Kleine-Budde , Vincent Mailhol , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Markus Schneider-Pargmann , =?utf-8?q?Martin_Hundeb=C3=B8?= =?utf-8?q?ll?= , Michal Kubiak , Simon Horman , Tony Lindgren , Judith Mendez Cc: Matthias Schiffer , Linux regression tracking , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/7] can: m_can: Reset cached active_interrupts on start Date: Fri, 26 Jul 2024 21:59:43 +0200 Message-ID: <20240726195944.2414812-7-msp@baylibre.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240726195944.2414812-1-msp@baylibre.com> References: <20240726195944.2414812-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 bf4a9ae76db9..7c9ad9f7174e 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1542,6 +1542,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 Fri Jul 26 19:59: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: 13743139 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (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 B3E3913C9A2 for ; Fri, 26 Jul 2024 20:00:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722024013; cv=none; b=qTQZmsTb9FGLuqjJq2b4G4zsDkIES6E8ZL2/FTagKYskYP6ESYynZIla5Crx12qhZ4C1cuMOdOXGezzAoDhEx3sTw4KlmDCSIaUYFAPJyl6XRdCiDA3LZgJHTT3HeowDBQwAS637U/MG5iI7j02KfdUTq1IULbaAuRR9LF3KZhU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722024013; c=relaxed/simple; bh=PqLeQmAqctIEHugxsI29m+1Hl3ds83kYxxQINp0RkQA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aiVR/4sq4+uJDPcY3JDIEogUIkdbjuTI6W9fGLWJMKOzf/B0MIH53EVB4keAH9KB9Rhblpv+sZrRptXgmD7/lrGzSQVpemNPrr/TUK9HuFKmh1xRFZW8W1NKtSyENasCWZxKQcGHJNgIlPim/WphowoEE+Txsg1Yq5xPyrJTtHQ= 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=lz5sOQO9; arc=none smtp.client-ip=209.85.208.53 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="lz5sOQO9" Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-5a2a90243c9so2581863a12.0 for ; Fri, 26 Jul 2024 13:00:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1722024009; x=1722628809; 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=aAD0QrgAhMaN+Loo56/InWrP52EhZGGkh8jgEKYZ7JE=; b=lz5sOQO9FnX+k5p+LKcHqWXL5IYMPYuBBD6uBS5Ib3dS1vBt04gBPJ7/lfOXl4sZBe 1EkHWpU5sDg24xifWfon3ziO9KH8czZeav8gOZ7CcAYOnTmF0DY+okwRwVjLOkC03Dok WpSe1sE848qkJsJ5qDkCWJ2f6g2HqLxpCGNLpuMIJhynCav23SPxVd4lOhvFGcAytdtd ab/VQoSX5AunENzwUI3oLQqEe8ZssLv3DozW29aLmnZ1D/QVDbvhAcVriSdET0b6kUQZ DdFhsu++v4udXngApgfY4xf+v+VRyC3/VwEPZgaLdyfv9XFF4WE3UboQPzFg8lDUnsnn VuXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722024009; x=1722628809; 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=aAD0QrgAhMaN+Loo56/InWrP52EhZGGkh8jgEKYZ7JE=; b=R5fjp/bavGYiDD8pKzjg/lZRJKvQnGUEXuNCmLjr9I8+zfEQ9MPS6HLFXfZ1QSLeCE HZEP/4hSGpm+fWajpjGccr97oAMIzqXtHXLzj0pDukaPwsGOK7VNEeXkps+rF5PRfJXF DqKhvtGhb7S5is0wQI0s2bLS8r4kcM8dSHSiC80a+11ox68VRc+pq9i6atEwQEDx+/4v C10gF71gmXmgC0So0at2rpvEoEtbgNtLT+YjoOycqBttf1O75kSCIH+mJllT8wEaOAdm VkKTJsAbm/y7BW7d/WnP/Nkh7SyrNHHK1RydpLGtIA3PWmvPUA0i/VQKRhSGDmXnxsPE 5J6w== X-Forwarded-Encrypted: i=1; AJvYcCU/r8ae1gGCN4tfKhvZ+iOscI8R4itDv0Z+qRclSUBPi1fSNOjgdtlFeKifKdhbLFWWwkcVnZMvyyQnfI+rMyCmILLHvMSC X-Gm-Message-State: AOJu0YxTlvIZujg3yG/HugLmXwgexd8Bw7MRNTi1vmpNYe5dnZlxDnQp n5i2GLU/fN2E1WK6KXDP8Qsg1pXqXKOZbHCb5pcpbw+ve/EKHet2ofIJMifHqdU= X-Google-Smtp-Source: AGHT+IEEzUyGNvBusd6G8ilz3PdSiFX7wBdFiW9IWqA0E01M8aJkR571/CYCOKrUufcdbTMsQmFD1w== X-Received: by 2002:a17:907:1c19:b0:a7a:a7b8:adae with SMTP id a640c23a62f3a-a7d3fdb7dc9mr45197666b.4.1722024009219; Fri, 26 Jul 2024 13:00:09 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4091:a245:8609:c1c4:a4f8:94c8:31f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7acad90e1esm209999166b.151.2024.07.26.13.00.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 13:00:08 -0700 (PDT) From: Markus Schneider-Pargmann To: Chandrasekar Ramakrishnan , Marc Kleine-Budde , Vincent Mailhol , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Markus Schneider-Pargmann , =?utf-8?q?Martin_Hundeb=C3=B8?= =?utf-8?q?ll?= , Michal Kubiak , Simon Horman , Tony Lindgren , Judith Mendez Cc: Matthias Schiffer , Linux regression tracking , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 7/7] can: m_can: Limit coalescing to peripheral instances Date: Fri, 26 Jul 2024 21:59:44 +0200 Message-ID: <20240726195944.2414812-8-msp@baylibre.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240726195944.2414812-1-msp@baylibre.com> References: <20240726195944.2414812-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 7c9ad9f7174e..663eb4247029 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -2182,7 +2182,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 | @@ -2193,18 +2193,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); } @@ -2390,7 +2392,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);