Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4171069rwd; Tue, 23 May 2023 04:20:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4t2Pp12MDRiPpEARbYsC9+85e4oCRifO8DGezbRKJXIK9P+KuJTcQDM15Fu8PnrI1gVadB X-Received: by 2002:a05:6a20:c701:b0:103:b073:7a57 with SMTP id hi1-20020a056a20c70100b00103b0737a57mr13617120pzb.23.1684840844257; Tue, 23 May 2023 04:20:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1684840844; cv=pass; d=google.com; s=arc-20160816; b=IR04s1jgTK4jZ+BqzsBWiQo1hQXLyfTD/1V4eAiTZYGzRjsVLGhiPLnFA35hhdSSww SwiTYlMgPcutvPDWGqaaZgmpUjCegNaMxWiLxirKJUvffPtm4IYetUPehcX2nWGnTzsE xmhcixZY1tFn8KTtBQ+J1jvH6KCJy4NF5q/8pDP6UzRGUecnPZj2Hg8cRfJ8fg4jFGMj B8hZjnTbQAXjKSBrmodBByzoGJ/xrRoIINjaJmX4goQbfXuHw30MIFldlmZQSVMD2W9F ZwN/TZtUoP9+pES2hO3NyUKgZmL+OSVC2EAkao3YRMsvzn590X++WKNkJqcEg8Dog52Y MTww== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to:content-disposition :references:message-id:subject:cc:to:from:date:dkim-signature; bh=t6s59GjltAUYNnWRiiEGGwpv+KFqtRweCmaR9ZVAD5M=; b=mPClyG23rl1wsf0PARBFcRx1mhOxWvm0XpD+KxIv4VcOjL354aqKOpo/hPrY1pAu9z cRX4Y63qmxXuhwHZoVYTBWQyDnLHx8QpmcLs48MimE6YjxY+BWranQddLaQS6ymABoPA yD4tWZND/+PQpiSkWOnfI9mWjYKYsHicCSTA6AElSieHBg4hAaHh79c5wYJuPiLqMQwg EMn6N0tR/i/gXVSOFWr2iWTbAKn8ApcEVwTXpiwzfHIe3i7aaqb8PUPk1Kezs2b81b8y a4GxkuGcFRdukfhWMbb1MWwgDDVhG53n5FarMlvV4KYbMSoYdXaecR+xlOTFkE62dUl2 Ckow== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@corigine.onmicrosoft.com header.s=selector2-corigine-onmicrosoft-com header.b=JNdGKb+v; arc=pass (i=1 spf=pass spfdomain=corigine.com dkim=pass dkdomain=corigine.com dmarc=pass fromdomain=corigine.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=corigine.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v5-20020a63b945000000b005346b8dae84si680464pgo.787.2023.05.23.04.20.27; Tue, 23 May 2023 04:20:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@corigine.onmicrosoft.com header.s=selector2-corigine-onmicrosoft-com header.b=JNdGKb+v; arc=pass (i=1 spf=pass spfdomain=corigine.com dkim=pass dkdomain=corigine.com dmarc=pass fromdomain=corigine.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=corigine.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236635AbjEWLKL (ORCPT + 99 others); Tue, 23 May 2023 07:10:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236633AbjEWLKJ (ORCPT ); Tue, 23 May 2023 07:10:09 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2104.outbound.protection.outlook.com [40.107.244.104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6B40119; Tue, 23 May 2023 04:10:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ihwEkkJJNlD8j+hq9Ugb5kFEjiQlOH5x65EaMpIDUMstwTg0W8Y2d/4ZUYGezCXeFf+IOQ2qcRdk7soi3snlwjUrjBzb7nuuq0wZPP5anzZ+3yJa4JNRefegeviLfxg7xL4W6/zJdBKCYcBEmQjMecARi4bVGLiG2ADxaTro/NGOjW2EgkY60EdBAH3av5lGihYFY8Hpeg4w8ch+naiGxnaYLqMLqo6p6iRBH8T3ecGOGKYMpvKOtpBVIppvogYUF84NJN1RZTh+wV8INc9bzdJ5VykzdaBDaQCP3P3Ui+GHqL2zUYyteObZSADZWLW06U5lth9Xweg87tnT17dgpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=t6s59GjltAUYNnWRiiEGGwpv+KFqtRweCmaR9ZVAD5M=; b=nCc6J2D2QjcoQve4yHX7c8NBe/CLqGGCOMUbs80KxmyP+PexxHYV4Hrj7/WbnzKPY1wXpXzOR0YwMHzsU+RQxXG2pdV1FHQ+TLdLFIJriIqL+idIu/rDg5cZnDYjYogc0quEXIlgb+URiNjtZtV1liyo2mQNxUM0MfK/yBoen4e9iulzZjQBCI/U6K3UWMqnqHqVcbIJcxF7GXTj+cih73/gpcKm1J3U04WYFfup3A9KCeNtHfIZiBwYyJt051pe1UY6uDgBDvAbzXyKh+F9q/OrNN/P6afaWdGNlqZdtIC3LRPueMxkJUupC4QN1I5mnl/Hml7CAEij+2naOlggWA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=t6s59GjltAUYNnWRiiEGGwpv+KFqtRweCmaR9ZVAD5M=; b=JNdGKb+v9wqRIEewvJ6ioAjD8kJR7yg2EqiqD4hov2QWMXs7jaMz06ldchQzhRnJP2dGYv8GRNIrVMKfUiVFYzjXcIMiqlmhvxNDeUa1QQlv/1RN7YCQK66UcRvQZQZXkC1FnxrY6lmDYHyaDcNHLzOh2b+L/uLtB3mLWEb8BYo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by MW3PR13MB4011.namprd13.prod.outlook.com (2603:10b6:303:2c::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28; Tue, 23 May 2023 11:10:02 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::f416:544d:18b7:bb34]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::f416:544d:18b7:bb34%5]) with mapi id 15.20.6411.029; Tue, 23 May 2023 11:10:01 +0000 Date: Tue, 23 May 2023 13:09:54 +0200 From: Simon Horman To: Judith Mendez Cc: Chandrasekar Ramakrishnan , linux-can@vger.kernel.org, Wolfgang Grandegger , Marc Kleine-Budde , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Schuyler Patton , Tero Kristo , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, Oliver Hartkopp , Tony Lindgren Subject: Re: [PATCH v7 2/2] can: m_can: Add hrtimer to generate software interrupt Message-ID: References: <20230523023749.4526-1-jm@ti.com> <20230523023749.4526-3-jm@ti.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230523023749.4526-3-jm@ti.com> X-ClientProxiedBy: AM0PR03CA0074.eurprd03.prod.outlook.com (2603:10a6:208:69::15) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR13MB4842:EE_|MW3PR13MB4011:EE_ X-MS-Office365-Filtering-Correlation-Id: 8f333b16-cf49-43d0-508f-08db5b7e40d3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: H6jyhQ08yBTl4wcEckTx4zSBYD0KEdCdie1n9ZPzJvUQog0+2ALSDbW7XOwU86+w5ysphJ4IWMIdXkWL5ea/PGzn2stBiKukoJmPkxS5vTpp6KvvC2TqT2p/3uMgH+IySilSGZvu9RkWoTb5CmLwsbtsSLb0ccjkjiVzP1tad5Utapz/mc9PsRKflnhiDAlaELmNkHDpUoutrvnLot4DZl4Oi8NzYu8rnsfIc9DpXZSoHbK83XiW15NPz+aFGzsfBghRp9kBPn8n+LfWCO3u1PSBPcNXzZ/VxlGYLjdDEUDAMMJn3tznMXwHjGzZHE6I8q1wv99X2t2q/ZhbTbdqZvy6PNOqhoqEJOq+r57Ns1G3Z1RprVAWg640MT+PpmaBhjOw/QUPs8EYjlvlzIM6pMv3zZlLMvO+Z8u42ErBQfbvjqECYjMVu7tsxNzGGx/4DMJFGbN27bDVX+oTGLWO7dXoTdUh46FsiRuawdf8ggCXWVCXry5uSOHcZyAqpSPHZHS5Hh2JcL0DqZdbfRM2x4JmIX+Ya+Lj8vThsWS5PJPnux3dy3LU2ZW1clqqQ3fLM3aFnXJRbC5FB6RaUDwd8RY7414dLwW+XRz+v+7E1dE= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR13MB4842.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(346002)(396003)(39840400004)(136003)(366004)(451199021)(86362001)(66946007)(66556008)(66476007)(6916009)(4326008)(478600001)(6486002)(41300700001)(54906003)(6666004)(966005)(316002)(5660300002)(8676002)(8936002)(38100700002)(44832011)(6506007)(6512007)(186003)(7416002)(83380400001)(2906002)(2616005)(36756003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?9vyS+DoBsLWf1yo1qVo1BJwimKqRaMzo877Mj0sBJVABa1fKISgkGsCNAMke?= =?us-ascii?Q?dBeuHUrbNItQjl4s5JXh4xd/3cyFlAPDO7qY30fqjxYBZ3+QQRG3isxsoGkl?= =?us-ascii?Q?m0yv3YZIRNxcQr3vVf2Y+5ccqX3Jgk32nhEab1LiWioRym7OyK9EVBvVgIrr?= =?us-ascii?Q?2OvvCidi2EduYzoImWJehJRNyeEi6FQVJU+QP9FM7XwUby/VpTmlaFBwrXoQ?= =?us-ascii?Q?ZnApNv/WRHFI1TnvU34yOK87z66oEFWezh2A4A5dUBX6eG6AYQEEiG004jGo?= =?us-ascii?Q?VcoUGMYyXUtqOpbi6XYZAukpw9GCMdVwAahCEv4Tt7Wm1x7MmXmZi9MoKqNB?= =?us-ascii?Q?u0MzxLb/1kWLAZxGh9RpxJCjAj+0kJUMEKG0n3GnRVFKK+x3N/OkgeJ3yg/z?= =?us-ascii?Q?jeHyS9GdoOh2LYywHezfw4YJVV+VSIgYHTR0OSzmEDbLmtXWhhYfB7PgwuAH?= =?us-ascii?Q?6RUD3nvl+xRCcZrY4NVVkfJn+6PTsJZPs1JBScosy064HsKLd+VafF+xxGgB?= =?us-ascii?Q?QxJxjo/xTv7XqkA0MJQ3mYnWJ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fJgwym?= =?us-ascii?Q?AffhoO+ifKgbkE4ZzfAzN/K4kw8iXwezt9QYu0gVmgtr/RpxQK4u6Er4tQIM?= =?us-ascii?Q?YuWQrTwwxfebJz0/oIiw+Y8574ankaCMOF1A10k43HFRY7Hluqf5XE7fx5RD?= =?us-ascii?Q?2mxhfQ1d8nQB77BssG/p5if1htn9BdChLDXq/tcCXKxLbaCPez5Ohv2q1qYf?= =?us-ascii?Q?Ph/8v5k6DLa1U7cjf44cDPs+PzR8MzOiMvn1vbD1Tt2ffDoFzXidn7v9WARc?= =?us-ascii?Q?STrdWw=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8f333b16-cf49-43d0-508f-08db5b7e40d3 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2023 11:10:01.7195 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: e1pLhXC1KjF168qqKZjrImcjgwzgW5oSkeEoTHGcdjUQFDEwyuR2c9ZKrtp9FFoSOeY4/3XqFAzS8v4b4DxMn18mB4DwatO6/yZ2d5pB6kA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR13MB4011 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 22, 2023 at 09:37:49PM -0500, Judith Mendez wrote: > Add an hrtimer to MCAN class device. Each MCAN will have its own > hrtimer instantiated if there is no hardware interrupt found in > device tree M_CAN node. > > The hrtimer will generate a software interrupt every 1 ms. In > hrtimer callback, we check if there is a transaction pending by > reading a register, then process by calling the isr if there is. > > Signed-off-by: Judith Mendez ... > diff --git a/drivers/net/can/m_can/m_can_platform.c b/drivers/net/can/m_can/m_can_platform.c > index 94dc82644113..b639c9e645d3 100644 > --- a/drivers/net/can/m_can/m_can_platform.c > +++ b/drivers/net/can/m_can/m_can_platform.c > @@ -5,6 +5,7 @@ > // > // Copyright (C) 2018-19 Texas Instruments Incorporated - http://www.ti.com/ > > +#include > #include > #include > > @@ -96,12 +97,30 @@ static int m_can_plat_probe(struct platform_device *pdev) > goto probe_fail; > > addr = devm_platform_ioremap_resource_byname(pdev, "m_can"); > - irq = platform_get_irq_byname(pdev, "int0"); > - if (IS_ERR(addr) || irq < 0) { > - ret = -EINVAL; > + if (IS_ERR(addr)) { > + ret = PTR_ERR(addr); > goto probe_fail; > } > > + if (device_property_present(mcan_class->dev, "interrupts") || > + device_property_present(mcan_class->dev, "interrupt-names")) { > + irq = platform_get_irq_byname(pdev, "int0"); > + mcan_class->polling = false; > + if (irq == -EPROBE_DEFER) { > + ret = -EPROBE_DEFER; > + goto probe_fail; > + } > + if (irq < 0) { > + ret = -ENXIO; > + goto probe_fail; > + } > + } else { > + mcan_class->polling = true; > + dev_dbg(mcan_class->dev, "Polling enabled, initialize hrtimer"); > + hrtimer_init(&mcan_class->hrtimer, CLOCK_MONOTONIC, > + HRTIMER_MODE_REL_PINNED); > + } Hi Judith, it seems that with this change irq is only set in the first arm of the above conditional. But later on it is used unconditionally. That is, it may be used uninitialised. Reported by gcc-12 as: drivers/net/can/m_can/m_can_platform.c: In function 'm_can_plat_probe': drivers/net/can/m_can/m_can_platform.c:150:30: warning: 'irq' may be used uninitialized [-Wmaybe-uninitialized] 150 | mcan_class->net->irq = irq; | ~~~~~~~~~~~~~~~~~~~~~^~~~~ drivers/net/can/m_can/m_can_platform.c:86:13: note: 'irq' was declared here 86 | int irq, ret = 0; | ^~~ > + > /* message ram could be shared */ > res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "message_ram"); > if (!res) { > -- > 2.17.1 > >