From mboxrd@z Thu Jan 1 00:00:00 1970 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 32729C43334 for ; Sun, 26 Jun 2022 19:27:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231754AbiFZT1X (ORCPT ); Sun, 26 Jun 2022 15:27:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230490AbiFZT1V (ORCPT ); Sun, 26 Jun 2022 15:27:21 -0400 Received: from novek.ru (unknown [213.148.174.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27E8521BC for ; Sun, 26 Jun 2022 12:27:21 -0700 (PDT) Received: from [192.168.0.18] (unknown [37.228.234.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by novek.ru (Postfix) with ESMTPSA id 1977B50060D; Sun, 26 Jun 2022 22:25:44 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 novek.ru 1977B50060D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=novek.ru; s=mail; t=1656271545; bh=52jAeGPi6+97vtA4CQUacVdo8hdC4ewih6Lj0kVN0kE=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=FQ8dpo8riCQUYwbS0jXzyRKiq+JPO1vk3ti4xPXOLlNFsPW4SISL2QPC2AaXFCmym DoV7OHUMzJ9icVuX1iTP0ybiyGT8dQiJffnCiBmEAQKu+2YOLt+KZqY//lEhYn27M4 3gKC2mdTyfEUuWG8SMmpRMFcCeqbgIkEK6Rzz/CM= Message-ID: <80568c10-2d73-2a68-aed6-a553ae2410f8@novek.ru> Date: Sun, 26 Jun 2022 20:27:17 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [RFC PATCH v1 3/3] ptp_ocp: implement DPLL ops Content-Language: en-US To: Jonathan Lemon Cc: Jakub Kicinski , Vadim Fedorenko , Aya Levin , Arkadiusz Kubalewski , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <20220623005717.31040-1-vfedorenko@novek.ru> <20220623005717.31040-4-vfedorenko@novek.ru> <20220623182813.safjhwvu67i4vu3b@bsd-mbp.dhcp.thefacebook.com> From: Vadim Fedorenko In-Reply-To: <20220623182813.safjhwvu67i4vu3b@bsd-mbp.dhcp.thefacebook.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 23.06.2022 19:28, Jonathan Lemon wrote: > On Thu, Jun 23, 2022 at 03:57:17AM +0300, Vadim Fedorenko wrote: >> From: Vadim Fedorenko >> >> +static int ptp_ocp_dpll_get_status(struct dpll_device *dpll) >> +{ >> + struct ptp_ocp *bp = (struct ptp_ocp *)dpll_priv(dpll); >> + int sync; >> + >> + sync = ioread32(&bp->reg->status) & OCP_STATUS_IN_SYNC; >> + return sync; >> +} > > Please match existing code style. > Didn't get this point. The same code is used through out the driver. Could you please explain? > >> +static int ptp_ocp_dpll_get_source_type(struct dpll_device *dpll, int sma) >> +{ >> + struct ptp_ocp *bp = (struct ptp_ocp *)dpll_priv(dpll); >> + int ret; >> + >> + if (bp->sma[sma].mode != SMA_MODE_IN) >> + return -1; >> + >> + switch (ptp_ocp_sma_get(bp, sma)) { >> + case 0: >> + ret = DPLL_TYPE_EXT_10MHZ; >> + break; >> + case 1: >> + case 2: >> + ret = DPLL_TYPE_EXT_1PPS; >> + break; >> + default: >> + ret = DPLL_TYPE_INT_OSCILLATOR; >> + } >> + >> + return ret; >> +} > > These case statements switch on private bits. This needs to match > on the selector name instead. > Addressed this in v2 > >> +static int ptp_ocp_dpll_get_output_type(struct dpll_device *dpll, int sma) >> +{ >> + struct ptp_ocp *bp = (struct ptp_ocp *)dpll_priv(dpll); >> + int ret; >> + >> + if (bp->sma[sma].mode != SMA_MODE_OUT) >> + return -1; >> + >> + switch (ptp_ocp_sma_get(bp, sma)) { >> + case 0: >> + ret = DPLL_TYPE_EXT_10MHZ; >> + break; >> + case 1: >> + case 2: >> + ret = DPLL_TYPE_INT_OSCILLATOR; >> + break; >> + case 4: >> + case 8: >> + ret = DPLL_TYPE_GNSS; >> + break; >> + default: >> + ret = DPLL_TYPE_INT_OSCILLATOR; > > Missing break; > > >> + } >> + >> + return ret; >> +} >> + >> +static struct dpll_device_ops dpll_ops = { >> + .get_status = ptp_ocp_dpll_get_status, >> + .get_lock_status = ptp_ocp_dpll_get_lock_status, >> + .get_source_type = ptp_ocp_dpll_get_source_type, >> + .get_output_type = ptp_ocp_dpll_get_output_type, >> +}; > > No 'set' statements here? Also, what happens if there is more than > one GNSS receiver, how is this differentiated? >> static int >> ptp_ocp_probe(struct pci_dev *pdev, const struct pci_device_id *id) >> { >> @@ -3768,6 +3846,14 @@ ptp_ocp_probe(struct pci_dev *pdev, const struct pci_device_id *id) >> >> ptp_ocp_info(bp); >> devlink_register(devlink); >> + >> + bp->dpll = dpll_device_alloc(&dpll_ops, ARRAY_SIZE(bp->sma), ARRAY_SIZE(bp->sma), bp); >> + if (!bp->dpll) { >> + dev_err(&pdev->dev, "dpll_device_alloc failed\n"); >> + return 0; >> + } >> + dpll_device_register(bp->dpll); >> + > > How is the release/unregister path called when the module is unloaded? I re-implemented unregister/free in v2. Hope it fixes questions. From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BCAFAC433EF for ; Sun, 26 Jun 2022 19:28:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=zr6rBgM796zWk7ugy5tYgr3iGR031sHSJAY7WbUjiEY=; b=Ws9j0E6jcVTzr/ YKMc8TK0ekPqlCK6aevrCEynrFIP2ClVAj/WepxwBaNQHfMniMlMbEZxdgowC6i9mKntCWDNluCan KlNdodK14B+NCxn30iVv831mzfsmh+9QwhkCWeLx+uwwn2WNhDpa7AIW5yVT+U927g6pq76eSZ8CX d2o0+Uuxtd84d1R7j4sI82T6uOb9LeIVVduQxMRbtsEV2uSLDVSa/YOOz4zCfqt+Ao/ERjn/UhO2d S4YmG6SUz1EE41GzF5skv7v2LnmAx4hrTW8UHeEDFnZklgVjuU7MLuNaGnPe91v2bO4dWNgXZ2Vrw yDwaaHWM8m576J1Rf3vA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o5Xun-00DEc1-1E; Sun, 26 Jun 2022 19:27:25 +0000 Received: from [213.148.174.62] (helo=novek.ru) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o5Xuj-00DEaS-5n for linux-arm-kernel@lists.infradead.org; Sun, 26 Jun 2022 19:27:22 +0000 Received: from [192.168.0.18] (unknown [37.228.234.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by novek.ru (Postfix) with ESMTPSA id 1977B50060D; Sun, 26 Jun 2022 22:25:44 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 novek.ru 1977B50060D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=novek.ru; s=mail; t=1656271545; bh=52jAeGPi6+97vtA4CQUacVdo8hdC4ewih6Lj0kVN0kE=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=FQ8dpo8riCQUYwbS0jXzyRKiq+JPO1vk3ti4xPXOLlNFsPW4SISL2QPC2AaXFCmym DoV7OHUMzJ9icVuX1iTP0ybiyGT8dQiJffnCiBmEAQKu+2YOLt+KZqY//lEhYn27M4 3gKC2mdTyfEUuWG8SMmpRMFcCeqbgIkEK6Rzz/CM= Message-ID: <80568c10-2d73-2a68-aed6-a553ae2410f8@novek.ru> Date: Sun, 26 Jun 2022 20:27:17 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [RFC PATCH v1 3/3] ptp_ocp: implement DPLL ops Content-Language: en-US To: Jonathan Lemon Cc: Jakub Kicinski , Vadim Fedorenko , Aya Levin , Arkadiusz Kubalewski , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <20220623005717.31040-1-vfedorenko@novek.ru> <20220623005717.31040-4-vfedorenko@novek.ru> <20220623182813.safjhwvu67i4vu3b@bsd-mbp.dhcp.thefacebook.com> From: Vadim Fedorenko In-Reply-To: <20220623182813.safjhwvu67i4vu3b@bsd-mbp.dhcp.thefacebook.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220626_122721_440442_0EA79410 X-CRM114-Status: GOOD ( 19.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 23.06.2022 19:28, Jonathan Lemon wrote: > On Thu, Jun 23, 2022 at 03:57:17AM +0300, Vadim Fedorenko wrote: >> From: Vadim Fedorenko >> >> +static int ptp_ocp_dpll_get_status(struct dpll_device *dpll) >> +{ >> + struct ptp_ocp *bp = (struct ptp_ocp *)dpll_priv(dpll); >> + int sync; >> + >> + sync = ioread32(&bp->reg->status) & OCP_STATUS_IN_SYNC; >> + return sync; >> +} > > Please match existing code style. > Didn't get this point. The same code is used through out the driver. Could you please explain? > >> +static int ptp_ocp_dpll_get_source_type(struct dpll_device *dpll, int sma) >> +{ >> + struct ptp_ocp *bp = (struct ptp_ocp *)dpll_priv(dpll); >> + int ret; >> + >> + if (bp->sma[sma].mode != SMA_MODE_IN) >> + return -1; >> + >> + switch (ptp_ocp_sma_get(bp, sma)) { >> + case 0: >> + ret = DPLL_TYPE_EXT_10MHZ; >> + break; >> + case 1: >> + case 2: >> + ret = DPLL_TYPE_EXT_1PPS; >> + break; >> + default: >> + ret = DPLL_TYPE_INT_OSCILLATOR; >> + } >> + >> + return ret; >> +} > > These case statements switch on private bits. This needs to match > on the selector name instead. > Addressed this in v2 > >> +static int ptp_ocp_dpll_get_output_type(struct dpll_device *dpll, int sma) >> +{ >> + struct ptp_ocp *bp = (struct ptp_ocp *)dpll_priv(dpll); >> + int ret; >> + >> + if (bp->sma[sma].mode != SMA_MODE_OUT) >> + return -1; >> + >> + switch (ptp_ocp_sma_get(bp, sma)) { >> + case 0: >> + ret = DPLL_TYPE_EXT_10MHZ; >> + break; >> + case 1: >> + case 2: >> + ret = DPLL_TYPE_INT_OSCILLATOR; >> + break; >> + case 4: >> + case 8: >> + ret = DPLL_TYPE_GNSS; >> + break; >> + default: >> + ret = DPLL_TYPE_INT_OSCILLATOR; > > Missing break; > > >> + } >> + >> + return ret; >> +} >> + >> +static struct dpll_device_ops dpll_ops = { >> + .get_status = ptp_ocp_dpll_get_status, >> + .get_lock_status = ptp_ocp_dpll_get_lock_status, >> + .get_source_type = ptp_ocp_dpll_get_source_type, >> + .get_output_type = ptp_ocp_dpll_get_output_type, >> +}; > > No 'set' statements here? Also, what happens if there is more than > one GNSS receiver, how is this differentiated? >> static int >> ptp_ocp_probe(struct pci_dev *pdev, const struct pci_device_id *id) >> { >> @@ -3768,6 +3846,14 @@ ptp_ocp_probe(struct pci_dev *pdev, const struct pci_device_id *id) >> >> ptp_ocp_info(bp); >> devlink_register(devlink); >> + >> + bp->dpll = dpll_device_alloc(&dpll_ops, ARRAY_SIZE(bp->sma), ARRAY_SIZE(bp->sma), bp); >> + if (!bp->dpll) { >> + dev_err(&pdev->dev, "dpll_device_alloc failed\n"); >> + return 0; >> + } >> + dpll_device_register(bp->dpll); >> + > > How is the release/unregister path called when the module is unloaded? I re-implemented unregister/free in v2. Hope it fixes questions. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel