Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp152381imw; Tue, 12 Jul 2022 16:36:02 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sqxBAmYesBftaIzEEs4o0Wbll/H9b3VSDf0/QRlhtNtSI1RBKAFyoexb+8DmuKf9YEp0Lg X-Received: by 2002:a17:907:971a:b0:72b:6bab:abc2 with SMTP id jg26-20020a170907971a00b0072b6bababc2mr549287ejc.551.1657668962260; Tue, 12 Jul 2022 16:36:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1657668962; cv=pass; d=google.com; s=arc-20160816; b=hS1lHi2clenmS7zXCZcoQxX5sG/TkOIfJZJmhEOGZ6CpFGlaM9NH06iA0qixsxto4z EFnflnC5CxcOZv4QiCzPPIKEtG6cMoug1ILliaIAbJEr3Fk75ovPb+FjpqK203Ph8Tga lh4kOULbUO7w8/XoB0C6a0bitcqV3gXYiOAHR6qZZWUxwLIPQGTZCfnqZT1LHwC2S1ns 6tOb053jOJiihjhXdn6Oy5h16Plg+rt0tKL4X4yhWqmSTTJaEg0B2FIuhWApuk6eFV5/ CdcVrSk0VOltnqRCrtvrPIKW2CRh06xn+j521tixAX2gRz0Sz0MJYgxJBoL2u0cBYz0h SvIQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:in-reply-to:user-agent:date:message-id:from :references:cc:to:subject:dkim-signature; bh=AZ2C/abfO8uMRZbebG5QO5fS+O4moWV6+vLQ2yj/bbg=; b=MbabxMVNvhaBAjWzK8ST12ybexeNVztoBDeQ6J8sS/uVMNOa09ubqB9xNLXDr9R3m7 QhAHeghJDRx7mw14fyTmE+EVuWnwRQcUALVQAvIirxKwVZLr7U9d0LUom4byKxVngKSw uFQl2j8J4zofDZBBfhlJy/yX4UkuO7Ero87QOaGBpMHq+JtMbZSU7PwYKCpC/LKR1rxe EafMX5dFwv1PMmdpk9VBopoxnycxrsmopTyjpityagoJLLjhYTSfMA7tvhJvlw4Tiifq PV5tQFyL+K/h0uWYCM4uD76DScAe2sTj2lxWEdIzNvnC6lErEIWoAyKnWSIcAIZQYh48 oKAg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@seco.com header.s=selector1 header.b=otiBMZCd; arc=pass (i=1 spf=pass spfdomain=seco.com dkim=pass dkdomain=seco.com dmarc=pass fromdomain=seco.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=pass (p=REJECT sp=REJECT dis=NONE) header.from=seco.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n8-20020a056402514800b0043a4cff7e3csi14529777edd.423.2022.07.12.16.35.26; Tue, 12 Jul 2022 16:36:02 -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=@seco.com header.s=selector1 header.b=otiBMZCd; arc=pass (i=1 spf=pass spfdomain=seco.com dkim=pass dkdomain=seco.com dmarc=pass fromdomain=seco.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=pass (p=REJECT sp=REJECT dis=NONE) header.from=seco.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233934AbiGLXQT (ORCPT + 99 others); Tue, 12 Jul 2022 19:16:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233899AbiGLXQC (ORCPT ); Tue, 12 Jul 2022 19:16:02 -0400 Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-ve1eur03on0630.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe09::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19BAF2729; Tue, 12 Jul 2022 16:15:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j9aSog6fCknXVM6r5KvD2HHfj8jZNZcvLq2zbQSG1+ZXKXTrLnsW232f4/DtCibeBJIenkpgVtWfyLHd/KgmYi8HlmIgaHT96BbfwDxPC9qycXCrh0d6BsS0Ob9nyBYPElhGYiivcEOxNtUFPnSobu/h9R2vzztvZ/T0Hy9+Dy6LtIYvTclpKCYRrZetLB95mNn7Ps/PbNn0XeaLdeXoijiyskUogjYwEkMq0BTw7qj7lx4/BfVuJ+6Tq1N5aStx1omwksGaJTfuaYlHDFFfI9HqolpaM0pkh+P9VyUzqNbqgMEqHTfL/B0Mz4jfztkBozL1/xeBNxekBtHncXr2cQ== 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=AZ2C/abfO8uMRZbebG5QO5fS+O4moWV6+vLQ2yj/bbg=; b=BwCTfIz4Jzaj/v8rZlGZ/rFxBy1iv9CI5m/VPQImeqQ/rW9HE+bT7FXgLbhtxlm+ckIabMeKPfWFYfrCWwrRlgjxXY7L9pRARm2eU/qHhd26CjuO1QimLg7Ie1dUs1v9SdQ84pTEuS7I8P1ZOBzDjtd9M0rrbS3PhuA0qXTHG8Ft0ouj9pY73AXdaG3d+lYDu/O16sol/OP0J6kG5tZl7upX/2YVq8kN5pVZmLLb7LyXhMFOW2QrXrHgFGAU1fA73pDZDPRu4yGfMtlPPPlEzfIbUCUBg/p3Se6ZZ+ekA0ef1VvzFEKmDXU88pb+Rh6fOr+/qrpNegbKhfuPCOUMiw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seco.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AZ2C/abfO8uMRZbebG5QO5fS+O4moWV6+vLQ2yj/bbg=; b=otiBMZCdKE33ldJEPHgUxJ/8Vp508unFmg+wAkqk6eErdE8Jcg/TKa+ZdIUihgaCPiPih0Ny5OSj508/5CD+zfDTbGaMOCJhqPc1StJHbrg385IUAIKFtdwxFA0CZJ7Sj+CsME59vep6NKbKBAnBAJ4poo3CSjbUVYpBS00IhYx0UFgc2CJU+LxgMRYxzRm+gOEcLdh/CScDQdLSy7IFLNYmGjudUmTsscT7j0Q8o0ThdAVjOYRV3N5v5YF8MVcBuBbRkqXvMwn97t83asSWBZTccbEFzZAooRzv3o7h08e3XYCm/qq9RKbghcAnQv5Fpys7rsNpEMVjpCsYdcg41A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) by HE1PR03MB2954.eurprd03.prod.outlook.com (2603:10a6:7:5a::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.26; Tue, 12 Jul 2022 23:15:18 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::757e:b75f:3449:45b1]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::757e:b75f:3449:45b1%6]) with mapi id 15.20.5417.026; Tue, 12 Jul 2022 23:15:18 +0000 Subject: Re: [RFC PATCH net-next 3/9] net: pcs: Add helpers for registering and finding PCSs To: "Russell King (Oracle)" Cc: Heiner Kallweit , netdev@vger.kernel.org, Jakub Kicinski , Madalin Bucur , "David S . Miller" , Paolo Abeni , Ioana Ciornei , linux-kernel@vger.kernel.org, Eric Dumazet , Andrew Lunn , Frank Rowand , Rob Herring , Saravana Kannan , devicetree@vger.kernel.org References: <20220711160519.741990-1-sean.anderson@seco.com> <20220711160519.741990-4-sean.anderson@seco.com> <3aad4e83-4aee-767e-b36d-e014582be7bd@seco.com> From: Sean Anderson Message-ID: <17579747-34f7-b927-ee1e-b25a216431e0@seco.com> Date: Tue, 12 Jul 2022 19:15:12 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-ClientProxiedBy: CH2PR11CA0012.namprd11.prod.outlook.com (2603:10b6:610:54::22) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: faab3eee-6e14-4974-ff1d-08da645c62ef X-MS-TrafficTypeDiagnostic: HE1PR03MB2954:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2FAfWxftcSulKABvksgQ/tTAXSJJ5Ah12efgT9ATmuc70Q90ZzH+IZ8rqn7l+/YlpVqlLvb+ktRvVZaPpnXZcJHYToB8ZUwWLWxsLefyTgxiF8/P6e9325SSc9q71zbjDNoktWC/P3x5A9+X0kVMGIkvruXoOs4PnEkJFxGfMIXB3n6e7h+Sh0mqTEJUj1HXnqJBbdrudjDh2Dhj89hESGsVdGRtcwYkvlK3ol8CItBkK5U0la12d2Ea1e3+Dq1/nyUUhKTktS9pm9ZJ5KsY3pnBtRRJkMXUStbkNOOcLwP5RS0IztqaSnnSQ/h0zyLugjw62gmh30cjmo8sy8zANywUFXcFBHIn3j33llxYbbzJ03dZqIXZkTsybXd6fPzgpdk2lQac0KoF+KyHjjsKwnz3nU6hVRXDLwYVfGMuXiX0LJkDhXFqOXf73DydkM3aA/SuJurVvQm2TmxtXeXs1/9P453kGKDFH9jREr1fqmrc80wc291eoUhMfMhfQ0TApTKo5yU+jLqt1vFgUUSlowIkkQKUH77IRj9n/HVtvMblFrFs0SSoOPaeGvPN+CZKYAIVB7wAm6heClTHlNodwsyc2sIrWbb2PDEbqAp04r1gtIlZe8B3+kx2lsCsaGP/Ys1468Z0rx5BylrGIVYxPQiBrfEcoqnwqjSA/+YEu/6sx4NBlhzZpw0SUCpmbwksoZ/lJZ9xkB/fnp6i/M1wToF83wBiucOUoQRVzm+ogrEu6A+w3N5m1sBg++LbILuLbUI5g89gl+/RKp25UV12qH/4BcFl5jagwP4hvP3LE4ds57PBZ9pM+I++HSVoOhBa9wwzi5zKqsyIpjDSrsk6Yt5iEIcKx8GEF6u67pVjeF7t1N7EDgWbZfDtpNWuYRo/ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR03MB4972.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(39850400004)(376002)(136003)(396003)(346002)(366004)(52116002)(6666004)(6506007)(478600001)(41300700001)(53546011)(2616005)(26005)(6486002)(31696002)(66476007)(4326008)(66556008)(38350700002)(38100700002)(6512007)(186003)(83380400001)(36756003)(7416002)(66946007)(8936002)(5660300002)(2906002)(44832011)(8676002)(316002)(6916009)(54906003)(86362001)(31686004)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?OCtKRDhiNk12RWcwZ2cwVVNENkdLbWZCaWcxdXpqdFo4U2ZmZURvUDBCMnBk?= =?utf-8?B?VGdhd1N0RTZteEVkQktvZVg1eWtQT0p2VHZhVkZ0RXNsTVZERXpGRTRBb3R4?= =?utf-8?B?UWJJM2U4V2RoWnhoazhZaFpBUFhzWH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SV2lE?= =?utf-8?B?a1Avekg1MWczSXo5U1RJVDlFZHRwamhLbVFWY3FVdEc5Z1RTZXB6anNRcFQw?= =?utf-8?B?QUFNQ0RSUm1ocFJ0Q29FRDh6UktSclA2VEZPRVJQMklBd0tDNy8zTXREU1N3?= =?utf-8?B?MFFOWVg1cGJHWVM1TmZRUzl2OWxHWk1XbkdTZk1qVmhNUSszNk1lK0tLaUQ1?= =?utf-8?B?N1F1a0xSVDBtUmhwL3BNR29jdnNPUzhVQnpUZ3YwK2xlak13TmxGM3UybU9F?= =?utf-8?B?SkE9PQ==?= X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: faab3eee-6e14-4974-ff1d-08da645c62ef X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2022 23:15:18.7104 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: a1Nfj7Ybh5+C/2vXFFxQB0uAU8fwZBjIUaXgS5ZJjg8GfIdU7al5d9iA4tRzgq9TALXZft0xgbYW74pZqORW9A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR03MB2954 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 7/12/22 11:51 AM, Russell King (Oracle) wrote: > On Mon, Jul 11, 2022 at 05:47:26PM -0400, Sean Anderson wrote: >> Hi Russell, >> >> On 7/11/22 4:59 PM, Russell King (Oracle) wrote: >> > Hi Sean, >> > >> > It's a good attempt and may be nice to have, but I'm afraid the >> > implementation has a flaw to do with the lifetime of data structures >> > which always becomes a problem when we have multiple devices being >> > used in aggregate. >> > >> > On Mon, Jul 11, 2022 at 12:05:13PM -0400, Sean Anderson wrote: >> >> +/** >> >> + * pcs_get_tail() - Finish getting a PCS >> >> + * @pcs: The PCS to get, or %NULL if one could not be found >> >> + * >> >> + * This performs common operations necessary when getting a PCS (chiefly >> >> + * incrementing reference counts) >> >> + * >> >> + * Return: @pcs, or an error pointer on failure >> >> + */ >> >> +static struct phylink_pcs *pcs_get_tail(struct phylink_pcs *pcs) >> >> +{ >> >> + if (!pcs) >> >> + return ERR_PTR(-EPROBE_DEFER); >> >> + >> >> + if (!try_module_get(pcs->ops->owner)) >> >> + return ERR_PTR(-ENODEV); >> > >> > What you're trying to prevent here is the PCS going away - but holding a >> > reference to the module doesn't prevent that with the driver model. The >> > driver model design is such that a device can be unbound from its driver >> > at any moment. Taking a reference to the module doesn't prevent that, >> > all it does is ensure that the user can't remove the module. It doesn't >> > mean that the "pcs" structure will remain allocated. >> >> So how do things like (serdes) phys work? Presumably the same hazard >> occurs any time a MAC uses a phy, because the phy can disappear at any time. >> >> As it happens I can easily trigger an Oops by unbinding my serdes driver >> and the plugging in an ethernet cable. Presumably this means that the phy >> subsystem needs the devlink treatment? There are already several in-tree >> MAC drivers using phys... > > It's sadly another example of this kind of thing. When you consider > that the system should operate in a safe manner with as few "gotchas" > as possible, then being able to "easily trigger an Oops" is something > that we should be avoiding. It's not hard to avoid - we have multiple > mechanisms in the kernel now to deal with it. OK, so as mentioned above this exists in several MAC drivers already. How do you propose to fix this? > We have the component > helper. We have devlinks. We can come up with other solutions such > as what I mentioned in my previous reply (which I consider to be the > superior solution in this case - because it doesn't mess up cases > where a single struct device is associated with multiple network > devices (such as on Armada 8040 based systems.) > > It's really about "Quality of Implementation" - and I expect high > quality. I don't want my systems crashing because I've tried to > temporarily unbind some device. > >> > The second issue that this creates is if a MAC driver creates the PCS >> > and then "gets" it through this interface, then the MAC driver module >> > ends up being locked in until the MAC driver devices are all unbound, >> > which isn't friendly at all. >> >> The intention here is not to use this for "internal" PCSs, but only for >> external ones. I suppose you're referring to > > I wish I could say that intentions for use bear the test of time, but > sadly I can not. Well, we can burn that bridge when we come to it. For now, yes if you call pcs_get_by_* from the same device where you call pcs_register then the device will be "locked in". >> > So, anything that proposes to create a new subsystem where we have >> > multiple devices that make up an aggregate device needs to nicely cope >> > with any of those devices going away. For that to happen in this >> > instance, phylink would need to know that its in-use PCS for a >> > particular MAC is going away, then it could force the link down before >> > removing all references to the PCS device. >> > >> > Another solution would be devlinks, but I am really not a fan of that >> > when there may be a single struct device backing multiple network >> > interfaces, where some of them may require PCS and others do not. One >> > wouldn't want the network interface with nfs-root to suddenly go away >> > because a PCS was unbound from its driver! >> >> Well, you can also do >> >> echo "mmc0:0001" > /sys/bus/mmc/drivers/mmcblk/unbind >> >> which will (depending on your system) have the same effect. >> >> If being able to unbind any driver at any time is intended, >> then I don't think we can save userspace from itself. > > If you unbind the device that contains your rootfs, you are absolutely > correct. It's the same as taking down the network interface that gives > you access to your NFS root. > > However, neither of these cause the kernel to crash - they make > userspace unusable. > > So, let's say that it is acceptable that the kernel crashes if one > unbinds a device. Why then bother with try_module_get() - if the user > is silly enough to remove the module containing the PCS code, doesn't > the same argument apply? "Shouldn't have done that then." > > I don't see the logic. > This was in response to your opposition to using devlink to manage the PCS, since it would unbind the MAC as well. So what would happen here is that someone would unbind the PCS, which would in turn unbind the MAC, having the same effect as if the user manually unbound the MAC directly. If you really want to avoid this, we'd need some kind of callback from devlink to allow the MAC to say "well, I wasn't using that PCS anyway," or at the very least "let me clean up this (soon-to-be) dangling pointer." --Sean