Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2021994pxa; Mon, 3 Aug 2020 05:36:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9ra75JTPKZ5rZrb1HsqucEbZycPrSU40VRTxUkBfZOydfUbWy8Qwl9NVzzNeX4H99M/bv X-Received: by 2002:aa7:c915:: with SMTP id b21mr16075644edt.17.1596458207759; Mon, 03 Aug 2020 05:36:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596458207; cv=none; d=google.com; s=arc-20160816; b=kkdDheq7iYgxdT+Tvfmf0w+4XAaUdvBEu39yDFQuriRTmDOUXfIs5dkzB5t5Bp5j/u owdy8SoKznOpgLX/u3uPDJq1EWLmUEtRThum85OO7E3kYKXx1Olu6JpP7Wna8X1RweNc 2oVT6d5TyjvfJt44M1axtpSZfQWqW9wRRm3O8PuV/CMA7sYZ+9cmIT4JwiGTMe3mEBsX Hj7msBrd4NCQxiD4EAEo7DKeCzpJ+KrazBj02Rvgq4rTWW7dQ+jUsjDagzLv/UvarZUo r3WoAPQl8hI6ykyaauxOs5OP3gFXUGfl77lhGSvwjA0CY/b0B7VNTlM7Y1asqOJ/09rm dpfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=s1B8lDgm4xY+yTvURH1hkeNIxs3U5aM7Y66Vqo/Imy0=; b=wcJgkNi8h4VPrnw9UCol8GuJpwe1aq6Ii+zmHMwG1F1YXuVeVmHmHxFjDK2oxY+qQH kdMk4ZJw9ISm7zJEpe+G8Q4y1rCCvXi+qRgVBLMjycAB5nv1eJ9fZi8KRLNvt7jcVS5z MveDLJU+4RdXCUYFAY/kUWxyS/Tc5vjZvA9jWg84LBe2ITin8I1LhncvVvc6gQar1wVc CKoFs4XOJ9ctFQBRd80rWx0lhA2QgXLTqOJiQgU2YFzweJAiUpq+X+eelTPWgjAVRYL/ qNqelI83PT+RZbYLW1Fc8z0SaZAOKdB+JzcLu86o2scmMYl9aS8sHNxmy9YtwGP7w0kX JGMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qy7jgukR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g1si3333214edy.259.2020.08.03.05.36.25; Mon, 03 Aug 2020 05:36:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qy7jgukR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729453AbgHCMdc (ORCPT + 99 others); Mon, 3 Aug 2020 08:33:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:33380 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729435AbgHCMd2 (ORCPT ); Mon, 3 Aug 2020 08:33:28 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B9D7A204EC; Mon, 3 Aug 2020 12:33:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596458007; bh=jWGFztSlPZ2Ee/FF2hv8UCt06rAB2GbADoQoBX0DGEM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qy7jgukRHLVI1QPdzOGsTSZjep42qJuRDBAslHO60gN1aoeeigx6Wx5lNVfiaiefU aZxAKUp9kJnEhbOIuhG+cmEQoaJydBu+zD9/ocNRN0ceyi+f8y8YjoEuSx0wqaeGjH bDyzc5M9lezLKnvyDwQH+p5l80urdSyyMrpmd8hk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eran Ben Elisha , Ariel Levkovich , Saeed Mahameed , Sasha Levin Subject: [PATCH 4.19 31/56] net/mlx5: Verify Hardware supports requested ptp function on a given pin Date: Mon, 3 Aug 2020 14:19:46 +0200 Message-Id: <20200803121851.847496622@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200803121850.306734207@linuxfoundation.org> References: <20200803121850.306734207@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eran Ben Elisha [ Upstream commit 071995c877a8646209d55ff8edddd2b054e7424c ] Fix a bug where driver did not verify Hardware pin capabilities for PTP functions. Fixes: ee7f12205abc ("net/mlx5e: Implement 1PPS support") Signed-off-by: Eran Ben Elisha Reviewed-by: Ariel Levkovich Signed-off-by: Saeed Mahameed Signed-off-by: Sasha Levin --- .../ethernet/mellanox/mlx5/core/lib/clock.c | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c index 54f1a40a68edd..d359e850dbf07 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c @@ -366,10 +366,31 @@ static int mlx5_ptp_enable(struct ptp_clock_info *ptp, return 0; } +enum { + MLX5_MTPPS_REG_CAP_PIN_X_MODE_SUPPORT_PPS_IN = BIT(0), + MLX5_MTPPS_REG_CAP_PIN_X_MODE_SUPPORT_PPS_OUT = BIT(1), +}; + static int mlx5_ptp_verify(struct ptp_clock_info *ptp, unsigned int pin, enum ptp_pin_function func, unsigned int chan) { - return (func == PTP_PF_PHYSYNC) ? -EOPNOTSUPP : 0; + struct mlx5_clock *clock = container_of(ptp, struct mlx5_clock, + ptp_info); + + switch (func) { + case PTP_PF_NONE: + return 0; + case PTP_PF_EXTTS: + return !(clock->pps_info.pin_caps[pin] & + MLX5_MTPPS_REG_CAP_PIN_X_MODE_SUPPORT_PPS_IN); + case PTP_PF_PEROUT: + return !(clock->pps_info.pin_caps[pin] & + MLX5_MTPPS_REG_CAP_PIN_X_MODE_SUPPORT_PPS_OUT); + default: + return -EOPNOTSUPP; + } + + return -EOPNOTSUPP; } static const struct ptp_clock_info mlx5_ptp_clock_info = { -- 2.25.1