From patchwork Fri Apr 12 12:52:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Venkat Kumar Ande X-Patchwork-Id: 139251 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 799CD43E52; Fri, 12 Apr 2024 14:53:12 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 564B3402A2; Fri, 12 Apr 2024 14:53:12 +0200 (CEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2073.outbound.protection.outlook.com [40.107.94.73]) by mails.dpdk.org (Postfix) with ESMTP id 92A6F400D6 for ; Fri, 12 Apr 2024 14:53:11 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LjA1vxsMIPFuTQ/s7RdQo+k8J4Pk0WKAyClo0NPuCEm+8IT0p4NPInH3VOni5WjNxwZxXdYu1O+AdHGqoaCbO2nNcWGh+U0mn8egsbKLQWDlBFoBatZInUmemAHPS04kekc16MTbd1m7UDmpPEyjm8pxQqU90vfXTeYS7U9nUgOgRTKUjgguL+Y2K74muEQRheyC0VmxXGys9PPU0SsUrqPS2AIhFPJNbioyiCMv9N64qiWUGnOIOxx/u4iooAVgRbBKmbwbgdi5CMAshif8TEjgYS5XNyhi7x4Q8p7tWmUF8/G0j2nazCoqEjiqUMQwyrXOp/ug9zvucI3c6UGTjw== 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=+1GJaMWnG8h3jQjXSA7QkuHe69nDENHNwdXOwlSz10g=; b=Y8A6WgqeAjjoCdnu83JFdzYrPPdXlaMTXDs7mIPMe3j3+n6OUYpyt/LQ7X6YxAcyDXbwXCPTRsI17jtLaUT+zD2UI38vccOFwNLL8MjhEH4OTdZhovKKgo2M+FTrBlhOqFvs7vliu0nvpBLZVQ5H5qR8VB63bFLJVhXQxjPX7NxLQmf6KEA1Jx0T382fPJIknQM986P9G/scsjlDofDtkHpcTQZIzvfLmQJwNj0tDH+tkPfEvTw1NOC90NEE0OB1tbraCR0t+SqFG6R04wgBoDZDQhU0+RzuwNVl4YrnAfyUoZbJtwPr+FYt8zqLa/Mj7QIv1rTwdAQHRUUN2e3rxg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=dpdk.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+1GJaMWnG8h3jQjXSA7QkuHe69nDENHNwdXOwlSz10g=; b=YLxkVP+hHh16PZLybkHw3i6cqSV80JO2kehK+pcayCQHMrSjnPXH7CDyeBu05lsP2Uj4oCy1HFrz4b2QCwY32veKH1MFXJJNXQ9iNMslsatGSNKXez0lbPuGlm7AxrQxXoGPUHwfMNZ9uTLiciqXuadmiTDmd2mzvQ3R+w/g9I0= Received: from BL1PR13CA0200.namprd13.prod.outlook.com (2603:10b6:208:2be::25) by DS7PR12MB5840.namprd12.prod.outlook.com (2603:10b6:8:7b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.55; Fri, 12 Apr 2024 12:53:07 +0000 Received: from BL6PEPF00020E62.namprd04.prod.outlook.com (2603:10b6:208:2be:cafe::fd) by BL1PR13CA0200.outlook.office365.com (2603:10b6:208:2be::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.13 via Frontend Transport; Fri, 12 Apr 2024 12:53:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF00020E62.mail.protection.outlook.com (10.167.249.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7452.22 via Frontend Transport; Fri, 12 Apr 2024 12:53:07 +0000 Received: from cae-Lilac-RMB.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 12 Apr 2024 07:53:05 -0500 From: Venkat Kumar Ande To: CC: , Venkat Kumar Ande Subject: [PATCH 01/24] net/axgbe: remove use of comm_owned field Date: Fri, 12 Apr 2024 08:52:26 -0400 Message-ID: <20240412125249.10625-1-VenkatKumar.Ande@amd.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF00020E62:EE_|DS7PR12MB5840:EE_ X-MS-Office365-Filtering-Correlation-Id: e4a2005c-312e-4a9e-0d59-08dc5aef8045 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: l7hmPKY/mGBQNC6hd+E1GUV9ZpXmYOzaIQxSV3O8jp4OWYC0TgG30PWNryXvl0hp5CbKZKWhxxgU4tjBrHG/VmgHgEYQ5JOkARD09KTRFMGy/wpJKpHwe3O8KLoatIt40ouJ/tRvBJ7CO0n+Trj2eZxeFYkZXnGIQFhsU5unWBS0LLOGE0j2ozL9W1wQcsj2Fw7OU6uYDCnQxPWSjivjZmmvFzeEmN37jU6BBMBRhIYL4sBNwTqk5rvhNIhn7a1zfqgRXqpHozQIaRp8fCm/X42+alZRL+c4Qmgc9885pqXVGCMGQt4PQNQOErKJnKP9i32/WBysgK+yN+0/7vSw9tWJY7Hk5ldjhYDZ1uIxpRaPORb0qjp/yGSPuLmIsre3VQQsTKpys5YRGL7tuLcsbkBPboBUIbX/M1LHDHfbsOFghwjFqpDWpI/ZCctqRtoMV8alKqkNndVG9X3VGgrIzor2za4waGYqVCInt7TS9M0wP0PDb/NnQrmqXKojz+7dwR+7cdfeMLtPRRmMc5l7aDkZEUvJQO+he6M7W9YznCpWS/S8QjUTFeOAfSqcR9e1GvcBnYizuRye7rcPRy4ehkvkBUP6NGniJ0sS/YDiudSRVNsKpkaChVvx40/mjZ4OSMeOBHjUQQ4VNh29yhuErKL6YZ5+KZ9rBE2QI6BnFL1QjduZUl8QH2I87Eh7e51kg5PnRkgkJt/X+xxVsAjqMPkqG6uiX0eDTMGTeOmFTqFHb9b18hLISIbPTh3wCeXz X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(376005)(36860700004)(1800799015)(82310400014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2024 12:53:07.4991 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e4a2005c-312e-4a9e-0d59-08dc5aef8045 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF00020E62.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5840 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The comm_owned field can hide logic where double locking is attempted and prevent multiple threads for the same device from accessing the mutex properly. Remove the comm_owned field and use the mutex API exclusively for gaining ownership. Signed-off-by: Venkat Kumar Ande --- drivers/net/axgbe/axgbe_phy_impl.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/drivers/net/axgbe/axgbe_phy_impl.c b/drivers/net/axgbe/axgbe_phy_impl.c index 44ff28517c..70e7c56439 100644 --- a/drivers/net/axgbe/axgbe_phy_impl.c +++ b/drivers/net/axgbe/axgbe_phy_impl.c @@ -205,8 +205,6 @@ struct axgbe_phy_data { unsigned int mdio_addr; - unsigned int comm_owned; - /* SFP Support */ enum axgbe_sfp_comm sfp_comm; unsigned int sfp_mux_address; @@ -254,12 +252,6 @@ static enum axgbe_an_mode axgbe_phy_an_mode(struct axgbe_port *pdata); static int axgbe_phy_i2c_xfer(struct axgbe_port *pdata, struct axgbe_i2c_op *i2c_op) { - struct axgbe_phy_data *phy_data = pdata->phy_data; - - /* Be sure we own the bus */ - if (!phy_data->comm_owned) - return -EIO; - return pdata->i2c_if.i2c_xfer(pdata, i2c_op); } @@ -400,10 +392,6 @@ static int axgbe_phy_sfp_get_mux(struct axgbe_port *pdata) static void axgbe_phy_put_comm_ownership(struct axgbe_port *pdata) { - struct axgbe_phy_data *phy_data = pdata->phy_data; - - phy_data->comm_owned = 0; - pthread_mutex_unlock(&pdata->phy_mutex); } @@ -419,9 +407,6 @@ static int axgbe_phy_get_comm_ownership(struct axgbe_port *pdata) */ pthread_mutex_lock(&pdata->phy_mutex); - if (phy_data->comm_owned) - return 0; - /* Clear the mutexes */ XP_IOWRITE(pdata, XP_I2C_MUTEX, AXGBE_MUTEX_RELEASE); XP_IOWRITE(pdata, XP_MDIO_MUTEX, AXGBE_MUTEX_RELEASE); @@ -444,7 +429,6 @@ static int axgbe_phy_get_comm_ownership(struct axgbe_port *pdata) XP_IOWRITE(pdata, XP_I2C_MUTEX, mutex_id); XP_IOWRITE(pdata, XP_MDIO_MUTEX, mutex_id); - phy_data->comm_owned = 1; return 0; }