From patchwork Mon May 16 13:55:35 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Or Gerlitz X-Patchwork-Id: 788072 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4GDxvUN010422 for ; Mon, 16 May 2011 14:01:02 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755305Ab1EPOA6 (ORCPT ); Mon, 16 May 2011 10:00:58 -0400 Received: from mail.mellanox.co.il ([194.90.237.43]:38226 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755165Ab1EPOA6 (ORCPT ); Mon, 16 May 2011 10:00:58 -0400 Received: from Internal Mail-Server by MTLPINE2 (envelope-from ogerlitz@mellanox.com) with SMTP; 16 May 2011 17:00:54 +0300 Received: from MTRCASDAG01.mtl.com (172.25.0.174) by MTLCAS02.mtl.com (10.0.8.72) with Microsoft SMTP Server (TLS) id 14.1.270.1; Mon, 16 May 2011 17:00:54 +0300 Received: from host217 (172.25.5.217) by MTRCASDAG01.mtl.com (172.25.0.174) with Microsoft SMTP Server (TLS) id 14.1.270.1; Mon, 16 May 2011 17:00:54 +0300 Date: Mon, 16 May 2011 16:55:35 +0300 From: Or Gerlitz X-X-Sender: ogerlitz@ogerlitz.voltaire.com To: Jack Morgenstein CC: linux-rdma , Yevgeny Petrilin Subject: Re: mlx4 port trigger entry (was: root owned writable files) Message-ID: User-Agent: Alpine 2.00 (LRH 1167 2008-08-23) MIME-Version: 1.0 X-Originating-IP: [172.25.5.217] Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 16 May 2011 14:01:06 +0000 (UTC) Jack Morgenstein wrote: > actually introduced in commit 7ff93f8b7ecbc36e7ffc5c11a61643821c1bfee5 > Which patches in ofed but not upstream are you referring to? Hi Jack, I came across this again, 7ff93f8b7ecbc36e7ffc5c11a61643821c1bfee5 doesn't contain the "port_trigger" entry added by the patch mlx4_1190_sense_port_trigger.patch which is used by ofed (below) I tend to think that as a result, the upstream kernel lacks the ability for setting port1 to IB and port2 to Eth, with ofed this is done by echo all > /sys/bus/pci/drivers/mlx4_core/0000:07:00.0/port_trigger echo ib > /sys/bus/pci/drivers/mlx4_core/0000:07:00.0/mlx4_port1 echo eth > /sys/bus/pci/drivers/mlx4_core/0000:07:00.0/mlx4_port2 without the port_trigger entry I can do the latter two commands but can't get to running ethernet on port2 Or. From 6813ad8636aca1291e146adcc2459f7be2f0f377 Mon Sep 17 00:00:00 2001 From: Yevgeny Petrilin Date: Sun, 25 Oct 2009 15:05:27 +0200 Subject: [PATCH] mlx4: Added a trigger to change all port types If user wishes to modify both ports, set the trigger and then modify both ports. It prevents unneccessary registration iterations. Signed-off-by: Yevgeny Petrilin --- drivers/net/mlx4/main.c | 36 ++++++++++++++++++++++++++++++++++++ drivers/net/mlx4/mlx4.h | 3 +++ 2 files changed, 39 insertions(+), 0 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: ofed_kernel-fixes/drivers/net/mlx4/main.c =================================================================== --- ofed_kernel-fixes.orig/drivers/net/mlx4/main.c 2009-12-09 16:54:29.000000000 +0200 +++ ofed_kernel-fixes/drivers/net/mlx4/main.c 2009-12-09 17:06:03.000000000 +0200 @@ -423,6 +423,13 @@ static ssize_t set_port_type(struct devi types[i] = mdev->caps.port_type[i+1]; } + if (priv->trig) { + if (++priv->changed_ports < mdev->caps.num_ports) + goto out; + else + priv->trig = priv->changed_ports = 0; + } + if (!(mdev->caps.flags & MLX4_DEV_CAP_FLAG_DPDP)) { for (i = 1; i <= mdev->caps.num_ports; i++) { if (mdev->caps.possible_type[i] == MLX4_PORT_TYPE_AUTO) { @@ -458,6 +465,23 @@ out: return err ? err : count; } +static ssize_t trigger_port(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct pci_dev *pdev = to_pci_dev(dev); + struct mlx4_dev *mdev = pci_get_drvdata(pdev); + struct mlx4_priv *priv = container_of(mdev, struct mlx4_priv, dev); + + if (!priv) + return -ENODEV; + + mutex_lock(&priv->port_mutex); + priv->trig = 1; + mutex_unlock(&priv->port_mutex); + return count; +} +DEVICE_ATTR(port_trigger, S_IWUGO, NULL, trigger_port); + static int mlx4_load_fw(struct mlx4_dev *dev) { struct mlx4_priv *priv = mlx4_priv(dev); @@ -1110,6 +1134,13 @@ static void mlx4_cleanup_port_info(struc device_remove_file(&info->dev->pdev->dev, &info->port_attr); } +static int mlx4_init_trigger(struct mlx4_priv *priv) +{ + memcpy(&priv->trigger_attr, &dev_attr_port_trigger, + sizeof(struct device_attribute)); + return device_create_file(&priv->dev.pdev->dev, &priv->trigger_attr); +} + static int __mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id) { struct mlx4_priv *priv; @@ -1241,6 +1272,10 @@ static int __mlx4_init_one(struct pci_de if (err) goto err_port; + err = mlx4_init_trigger(priv); + if (err) + goto err_register; + mlx4_sense_init(dev); mlx4_start_sense(dev); @@ -1248,6 +1283,8 @@ static int __mlx4_init_one(struct pci_de return 0; +err_register: + mlx4_unregister_device(dev); err_port: for (port = 1; port <= dev->caps.num_ports; port++) mlx4_cleanup_port_info(&priv->port[port]); @@ -1312,6 +1349,7 @@ static void mlx4_remove_one(struct pci_d if (dev) { mlx4_stop_sense(dev); mlx4_unregister_device(dev); + device_remove_file(&dev->pdev->dev, &priv->trigger_attr); for (p = 1; p <= dev->caps.num_ports; p++) { mlx4_cleanup_port_info(&priv->port[p]); Index: ofed_kernel-fixes/drivers/net/mlx4/mlx4.h =================================================================== --- ofed_kernel-fixes.orig/drivers/net/mlx4/mlx4.h 2009-12-09 16:54:28.000000000 +0200 +++ ofed_kernel-fixes/drivers/net/mlx4/mlx4.h 2009-12-09 17:05:23.000000000 +0200 @@ -317,6 +317,9 @@ struct mlx4_priv { struct mlx4_uar driver_uar; void __iomem *kar; struct mlx4_port_info port[MLX4_MAX_PORTS + 1]; + struct device_attribute trigger_attr; + int trig; + int changed_ports; struct mlx4_sense sense; struct mutex port_mutex; };