IB/hfi1: Use built-in i2c bit-shift bus adapter
Subsystems (2)
PATCH v2 11/18 IB/hfi1: Use built-in i2c bit-shift bus adapter
From: Dean Luick <[email protected]>
Use built-in i2c bit-shift bus adapter to control the i2c busses on the chip.
Cc Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
Reviewed-by Easwar Hariharan <[email protected]>
Reviewed-by Dennis Dalessandro <[email protected]>
Signed-off-by Dean Luick <[email protected]>
Signed-off-by Dennis Dalessandro <[email protected]>
Signed-off-by Mike Marciniszyn <[email protected]>
---
v2 - address conflict issue with rc patches
drivers/infiniband/hw/hfi1/Kconfig | 3 drivers/infiniband/hw/hfi1/chip.c | 5 drivers/infiniband/hw/hfi1/hfi.h | 11 + drivers/infiniband/hw/hfi1/init.c | 27 ++ drivers/infiniband/hw/hfi1/qsfp.c | 407 +++++++++++++++++++++++++++--------- drivers/infiniband/hw/hfi1/qsfp.h | 3 6 files changed, 341 insertions(+), 115 deletions(-)
drivers/infiniband/hw/hfi1/Kconfig +2 -1
@@ -1,8 +1,9 @@ config INFINIBAND_HFI1 tristate "Intel OPA Gen1 support" - depends on X86_64 && INFINIBAND_RDMAVT + depends on X86_64 && INFINIBAND_RDMAVT && I2C select MMU_NOTIFIER select CRC32 + select I2C_ALGOBIT default m ---help--- This is a low-level driver for Intel OPA Gen1 adapter.
drivers/infiniband/hw/hfi1/chip.c +5 -0
@@ -14165,6 +14165,11 @@ static int init_asic_data(struct hfi1_devdata *dd) } dd->asic_data->dds[dd->hfi1_id] = dd;/* self back-pointer */ spin_unlock_irqrestore (&hfi1_devs_lock, flags); + +/* first one through - set up i2c devices */ +if (!peer) + ret =set_up_i2c (dd, dd->asic_data); +return ret; }
drivers/infiniband/hw/hfi1/hfi.h +11 -0
@@ -62,6 +62,8 @@#include <linux/cdev.h> #include <linux/delay.h> #include <linux/kthread.h> +#include <linux/i2c.h> +#include <linux/i2c-algo-bit.h> #include <rdma/rdma_vt.h> #include "chip_registers.h"
@@ -805,10 +807,19 @@ struct hfi1_temp {u8 triggers;/* temperature triggers */ }; +struct hfi1_i2c_bus { +struct hfi1_devdata *controlling_dd;/* current controlling device */ +struct i2c_adapter adapter;/* bus details */ +struct i2c_algo_bit_data algo;/* bus algorithm details */ +int num;/* bus number, 0 or 1 */ +}; +/* common data between shared ASIC HFIs */ struct hfi1_asic_data {struct hfi1_devdata *dds[2 ];/* back pointers */ struct mutex asic_resource_mutex; +struct hfi1_i2c_bus *i2c_bus0; +struct hfi1_i2c_bus *i2c_bus1; };/* device data struct now contains only "general per-device" info.
drivers/infiniband/hw/hfi1/init.c +19 -8
@@ -973,34 +973,45 @@ void hfi1_free_ctxtdata(struct hfi1_devdata *dd, struct hfi1_ctxtdata *rcd)/* * Release our hold on the shared asic data. If we are the last one, -* free the structure. Must be holding hfi1_devs_lock. +* return the structure to be finalized outside the lock. Must be +* holding hfi1_devs_lock. */ -static void release_asic_data (struct hfi1_devdata *dd) +static struct hfi1_asic_data *release_asic_data (struct hfi1_devdata *dd) { +struct hfi1_asic_data *ad;int other;if (!dd->asic_data) -return ; +return NULL ; dd->asic_data->dds[dd->hfi1_id] =NULL ; other = dd->hfi1_id ?0 :1 ; -if (!dd->asic_data->dds[other]) { -/* we are the last holder, free it */ -kfree (dd->asic_data); - } + ad = dd->asic_data; dd->asic_data =NULL ; +/* return NULL if the other dd still has a link */ +return ad->dds[other] ?NULL : ad; +} + +static void finalize_asic_data (struct hfi1_devdata *dd, +struct hfi1_asic_data *ad) +{ +clean_up_i2c (dd, ad); +kfree (ad); }static void __hfi1_free_devdata (struct kobject *kobj) {struct hfi1_devdata *dd = container_of(kobj, struct hfi1_devdata, kobj); +struct hfi1_asic_data *ad;unsigned long flags;spin_lock_irqsave (&hfi1_devs_lock, flags);idr_remove (&hfi1_unit_table, dd->unit);list_del (&dd->list); -release_asic_data (dd); + ad =release_asic_data (dd);spin_unlock_irqrestore (&hfi1_devs_lock, flags); +if (ad) +finalize_asic_data (dd, ad);free_platform_config (dd);rcu_barrier ();/* wait for rcu callbacks to complete */ free_percpu (dd->int_counter);
drivers/infiniband/hw/hfi1/qsfp.c +301 -106
528 lines not on this page · raw message
drivers/infiniband/hw/hfi1/qsfp.h +3 -0
@@ -238,3 +238,6 @@ int one_qsfp_write(struct hfi1_pportdata *ppd, u32 target, int addr, void *bp, int len);int one_qsfp_read (struct hfi1_pportdata *ppd,u32 target,int addr,void *bp,int len); +struct hfi1_asic_data ; +int set_up_i2c (struct hfi1_devdata *dd,struct hfi1_asic_data *ad); +void clean_up_i2c (struct hfi1_devdata *dd,struct hfi1_asic_data *ad);
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html