From patchwork Tue Nov 29 16:13:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13058800 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19406C46467 for ; Tue, 29 Nov 2022 16:14:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235874AbiK2QOh (ORCPT ); Tue, 29 Nov 2022 11:14:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235908AbiK2QOP (ORCPT ); Tue, 29 Nov 2022 11:14:15 -0500 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E299C22; Tue, 29 Nov 2022 08:14:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669738450; x=1701274450; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=3LzeaXthaYLphoE1w4aLAarbQ8ZxUcNuL5nbnHihJTM=; b=hScX4RMdI1ppO8azXuRMyVsV8NIGeiL4Mdr9WFh0ghaBaIoQk4JEp+v6 FLJ/RgphxStfXMrA1JrXsxu9swiG6peW4LcQ5JQmyu5D4j83VEncbivB9 y+M9rY5CbvF0WVA3QTaAARF+sdNMxQvJf22kCxPXRJ3EZ2Fu+HKDYZFS/ 1DT1POdTXt810nrftlX2F8LBAlESEHMeqpvoF1Ng8eDG4hG7luYE5MDN5 Eg7NCivIqntbE8BPmMemFA00MwDrejMnB9pm67PEKd5A9E1oo/wtvaS7v HUcUmqWGp1j9aCIBogwu7e73MYQ6HkGNa2S0V4PLnv6GudB/VKm/k3HIv w==; X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="302740405" X-IronPort-AV: E=Sophos;i="5.96,203,1665471600"; d="scan'208";a="302740405" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2022 08:13:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="768476672" X-IronPort-AV: E=Sophos;i="5.96,203,1665471600"; d="scan'208";a="768476672" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga004.jf.intel.com with ESMTP; 29 Nov 2022 08:13:36 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 8784F10E; Tue, 29 Nov 2022 18:14:02 +0200 (EET) From: Andy Shevchenko To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Michael Jamet , Mika Westerberg , Yehezkel Bernat , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andy Shevchenko Subject: [resend, PATCH net-next v1 1/2] net: thunderbolt: Switch from __maybe_unused to pm_sleep_ptr() etc Date: Tue, 29 Nov 2022 18:13:58 +0200 Message-Id: <20221129161359.75792-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Letting the compiler remove these functions when the kernel is built without CONFIG_PM_SLEEP support is simpler and less heavier for builds than the use of __maybe_unused attributes. Signed-off-by: Andy Shevchenko Acked-by: Mika Westerberg --- drivers/net/thunderbolt.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/net/thunderbolt.c b/drivers/net/thunderbolt.c index a52ee2bf5575..4dbc6c7f2e10 100644 --- a/drivers/net/thunderbolt.c +++ b/drivers/net/thunderbolt.c @@ -1319,7 +1319,7 @@ static void tbnet_shutdown(struct tb_service *svc) tbnet_tear_down(tb_service_get_drvdata(svc), true); } -static int __maybe_unused tbnet_suspend(struct device *dev) +static int tbnet_suspend(struct device *dev) { struct tb_service *svc = tb_to_service(dev); struct tbnet *net = tb_service_get_drvdata(svc); @@ -1334,7 +1334,7 @@ static int __maybe_unused tbnet_suspend(struct device *dev) return 0; } -static int __maybe_unused tbnet_resume(struct device *dev) +static int tbnet_resume(struct device *dev) { struct tb_service *svc = tb_to_service(dev); struct tbnet *net = tb_service_get_drvdata(svc); @@ -1350,9 +1350,7 @@ static int __maybe_unused tbnet_resume(struct device *dev) return 0; } -static const struct dev_pm_ops tbnet_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(tbnet_suspend, tbnet_resume) -}; +static DEFINE_SIMPLE_DEV_PM_OPS(tbnet_pm_ops, tbnet_suspend, tbnet_resume); static const struct tb_service_id tbnet_ids[] = { { TB_SERVICE("network", 1) }, @@ -1364,7 +1362,7 @@ static struct tb_service_driver tbnet_driver = { .driver = { .owner = THIS_MODULE, .name = "thunderbolt-net", - .pm = &tbnet_pm_ops, + .pm = pm_sleep_ptr(&tbnet_pm_ops), }, .probe = tbnet_probe, .remove = tbnet_remove, From patchwork Tue Nov 29 16:13:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13058799 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AFA8C4167B for ; Tue, 29 Nov 2022 16:14:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235647AbiK2QOg (ORCPT ); Tue, 29 Nov 2022 11:14:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235891AbiK2QOO (ORCPT ); Tue, 29 Nov 2022 11:14:14 -0500 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3DBE65E53; Tue, 29 Nov 2022 08:14:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669738447; x=1701274447; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Su0Cw3MyHqpzsKA0PnsNlmYF5H+VQ8b4Iwhnm0qJsZk=; b=gIN9xUrDMmHCizqKmGnS2LVjmiRZd6wlzFkvWYA/UE8zMUz+AF+PvHtU 6ttR8G9v+r6FIgrFzkuBM7M4XsBfj5IsL3ca9bpr+edFMI5FIIvS95tg/ Kke30HvrvzUHNBi2bjHGXKHVoKJXXASryKeonl1/YcD91nE7JJfyNmDyx 7gXQWxGSr6WPu3Fp6yA31jNpbkbNpuohe5zV/komry1ciu7PnvwOTFjfm A3vzuqC3rV4ap8Vs9WR+YD+dwJA476yxagmdaUPgBomy9A57SwzgVyLB/ bFCxtzwNcjJuCdpoVFlZEPysjyCZ9r8mYJUGNrgjuqWcsXCiQP3epAUz1 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="302740399" X-IronPort-AV: E=Sophos;i="5.96,203,1665471600"; d="scan'208";a="302740399" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2022 08:13:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="768476669" X-IronPort-AV: E=Sophos;i="5.96,203,1665471600"; d="scan'208";a="768476669" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga004.jf.intel.com with ESMTP; 29 Nov 2022 08:13:36 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 3868D179; Tue, 29 Nov 2022 18:14:03 +0200 (EET) From: Andy Shevchenko To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Michael Jamet , Mika Westerberg , Yehezkel Bernat , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andy Shevchenko Subject: [resend, PATCH net-next v1 2/2] net: thunderbolt: Use separate header data type for the Rx Date: Tue, 29 Nov 2022 18:13:59 +0200 Message-Id: <20221129161359.75792-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221129161359.75792-1-andriy.shevchenko@linux.intel.com> References: <20221129161359.75792-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The same data type structure is used for bitwise operations and regular ones. It makes sparse unhappy, for example: .../thunderbolt.c:718:23: warning: cast to restricted __le32 .../thunderbolt.c:953:23: warning: incorrect type in initializer (different base types) .../thunderbolt.c:953:23: expected restricted __wsum [usertype] wsum .../thunderbolt.c:953:23: got restricted __be32 [usertype] Split the header to bitwise one and specific for Rx to make sparse happy. Assure the layout by involving static_assert() against size and offsets of the member of the structures. Signed-off-by: Andy Shevchenko --- drivers/net/thunderbolt.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/net/thunderbolt.c b/drivers/net/thunderbolt.c index 4dbc6c7f2e10..f7b3d0d4646c 100644 --- a/drivers/net/thunderbolt.c +++ b/drivers/net/thunderbolt.c @@ -58,12 +58,32 @@ * supported then @frame_id is filled, otherwise it stays %0. */ struct thunderbolt_ip_frame_header { + __le32 frame_size; + __le16 frame_index; + __le16 frame_id; + __le32 frame_count; +}; + +/* Same as &struct thunderbolt_ip_frame_header for Rx */ +struct thunderbolt_ip_frame_rx_hdr { u32 frame_size; u16 frame_index; u16 frame_id; u32 frame_count; }; +static_assert(sizeof(struct thunderbolt_ip_frame_header) == + sizeof(struct thunderbolt_ip_frame_rx_hdr)); + +#define TBIP_FRAME_HDR_MATCH(x) \ + static_assert(offsetof(struct thunderbolt_ip_frame_header, frame_##x) == \ + offsetof(struct thunderbolt_ip_frame_rx_hdr, frame_##x)) +TBIP_FRAME_HDR_MATCH(size); +TBIP_FRAME_HDR_MATCH(index); +TBIP_FRAME_HDR_MATCH(id); +TBIP_FRAME_HDR_MATCH(count); +#undef TBIP_FRAME_HDR_MATCH + enum thunderbolt_ip_frame_pdf { TBIP_PDF_FRAME_START = 1, TBIP_PDF_FRAME_END, @@ -193,7 +213,7 @@ struct tbnet { struct delayed_work login_work; struct work_struct connected_work; struct work_struct disconnect_work; - struct thunderbolt_ip_frame_header rx_hdr; + struct thunderbolt_ip_frame_rx_hdr rx_hdr; struct tbnet_ring rx_ring; atomic_t frame_id; struct tbnet_ring tx_ring;