From patchwork Mon Feb 12 05:15:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 127921 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp2878531ljc; Sun, 11 Feb 2018 21:16:35 -0800 (PST) X-Google-Smtp-Source: AH8x226qg9M5BQLhFtQ/4Aukav0is1oQpOiJp//VpZ44o6gihwqpynfV2Xaqy9BzCCgivbsiDlJH X-Received: by 10.101.80.202 with SMTP id s10mr8382873pgp.226.1518412595792; Sun, 11 Feb 2018 21:16:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518412595; cv=none; d=google.com; s=arc-20160816; b=BI4jSjaC/WqTuiT0YTghIi4TDcAsLyi0+cfWgrMFzsF2b78JStIs9gK995dXNbWB6D nKxQgOozAr6JLKeqTwXNwAUvt0mH8igKzfgol7AEP8UVxTYFeQR5G4vIhUm/Ph8JJOmv lykb/JDU9bUOvtsB+jPbT6IimGOEskWK170Pc+Su6SOD44IXZxS+7KalVJM/lnQoLGh5 TaBdjIFq9HOgTGHt5xUt07kUxaQ4Bw1/kmSyRO72WCLpEigPI5I7aVhzhJ8MqzGpQ84R QR+Qp2FjQGFDvn2U/KGW0cTn5/6SpmJ7NK28CEP5/d/eihFLbfsverPyiLpBN7dO7DFm h+Qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=0YPgz20WbaJ8Kb2Eg5km6ffNOOB9VrrQBKR2xwjRQkM=; b=JcK8NZ01cgp8ZgBsrWbqcVSI20yJv3XDXVWdAZPPaNnvAhCKFFWYn/b1SxCulPpBxB PdpoBzRJCXXy1zcrhx5G2JkQjc1jmEZKX6o/9nPgixX5l/Abq8+GZsB+GO9UJUah8IA/ HG5XAiwI8BXIq0yDGPhjjMK2IjlkR+0Cig12Sh1/hjnrP2VcHalyEMlZwjzg7WLtA8o6 yF/yUUlNhB7kPZMRqa72dOjeDBEgA8LfjDcnH446B0O8AAcccTurb1ZcJS20lbsd19Go z0sKtRk5tKXGBF1Zt1dPE0M72KdW8nCAz65fx5AdQEjIxKR6OtdCS0ulmopbP9ZATCm8 0T4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=h3/EOd54; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b89-v6si3047528plb.809.2018.02.11.21.16.35; Sun, 11 Feb 2018 21:16:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=h3/EOd54; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751459AbeBLFQb (ORCPT + 13 others); Mon, 12 Feb 2018 00:16:31 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:46482 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751263AbeBLFQY (ORCPT ); Mon, 12 Feb 2018 00:16:24 -0500 Received: by mail-pg0-f68.google.com with SMTP id a11so6810568pgu.13; Sun, 11 Feb 2018 21:16:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=0YPgz20WbaJ8Kb2Eg5km6ffNOOB9VrrQBKR2xwjRQkM=; b=h3/EOd54qprjwopgxH2ghm/58hyKPyNeCH/8lREjHOHNykZvsoEW8aN8BFkB7WUuEK l+z33bxCVN9v2Rfs86DBLfwobX4i1F9UgUHqPFG24vlp1ENw1N5MXoKAjXxdCfgLxHe3 zYOJM7yGm1LpSn4PQamLi4Ffz6hd6xIH8vl8PE+MfMR6KBma4wUd0uABMWSVTd/sNzod UMJG4C2gk+NXMdv0nLLNd/TQTb1SEI9T0LUDFzIjpVgND0v6wMUAmk1X1CaagslLHOoR 54WJawhKUxj3UsV9s0mx0TP6evjV2j/7/bxX1cr6UrXXM6jydpqGs/DypshlBVi6pU8H WLVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=0YPgz20WbaJ8Kb2Eg5km6ffNOOB9VrrQBKR2xwjRQkM=; b=evU3s+94IKLYcefSoCYwJFl8cEbnKk1kqof5iTZQmKJWE0kaQzq7hPndXiVDRXdAC/ eE0HBRHFZ0kzs088Veuj9zcrpYuQpFYvvu8GdbW155K76Q7vO2bw8N7OgYLNsA9vLMLQ YaGMAW/mpswrept79MlgzqugaZ6UbtXvvJ7VDxabO/ABblMkd3HyHfv5xqYj6v7DC9KB VZf/++GvAfdb8Cd3qgX72onDXj2p/DDkGFlWq9O4A526aOR6ZkvBte45/rfdUREgyq7O uf+e0BEc8nUJTlEDBSu2YSL71mOnH0QA58b2UJmCUtijspp2ULTh/XokxcuUbYbmr2ul 4TUQ== X-Gm-Message-State: APf1xPBEEontAB+/yzb5Omi/Nh2Fn1JOPkGM64oqYPJ02FysM+cjGv// K/yyV1H3mcOK0B8Djhmgyf8= X-Received: by 10.98.63.15 with SMTP id m15mr10338014pfa.221.1518412583759; Sun, 11 Feb 2018 21:16:23 -0800 (PST) Received: from aurora.jms.id.au ([203.0.153.9]) by smtp.gmail.com with ESMTPSA id e88sm27660643pfl.80.2018.02.11.21.16.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 11 Feb 2018 21:16:23 -0800 (PST) Received: by aurora.jms.id.au (sSMTP sendmail emulation); Mon, 12 Feb 2018 15:46:15 +1030 From: Joel Stanley To: Greg Kroah-Hartman , Rob Herring , Mark Rutland Cc: Jeremy Kerr , Christopher Bostic , Brad Bishop , Edward James , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 01/10] fsi: Add fsi_master_rescan() Date: Mon, 12 Feb 2018 15:45:40 +1030 Message-Id: <20180212051549.8575-2-joel@jms.id.au> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180212051549.8575-1-joel@jms.id.au> References: <20180212051549.8575-1-joel@jms.id.au> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jeremy Kerr We'll want non-core fsi code to trigger a rescan, so introduce a non-static fsi_master_rescan() function. Use this for the existing unscan/scan behaviour too. Signed-off-by: Jeremy Kerr Reviewed-by: Joel Stanley Reviewed-by: Christopher Bostic Signed-off-by: Joel Stanley --- drivers/fsi/fsi-core.c | 10 ++++++++-- drivers/fsi/fsi-master.h | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) -- 2.15.1 diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index e318bf8c623c..6e5aa9b26665 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -762,14 +762,20 @@ static void fsi_master_unscan(struct fsi_master *master) device_for_each_child(&master->dev, NULL, fsi_master_remove_slave); } +int fsi_master_rescan(struct fsi_master *master) +{ + fsi_master_unscan(master); + return fsi_master_scan(master); +} +EXPORT_SYMBOL_GPL(fsi_master_rescan); + static ssize_t master_rescan_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct fsi_master *master = to_fsi_master(dev); int rc; - fsi_master_unscan(master); - rc = fsi_master_scan(master); + rc = fsi_master_rescan(master); if (rc < 0) return rc; diff --git a/drivers/fsi/fsi-master.h b/drivers/fsi/fsi-master.h index 12f7b119567d..18bd4ad79356 100644 --- a/drivers/fsi/fsi-master.h +++ b/drivers/fsi/fsi-master.h @@ -40,4 +40,6 @@ struct fsi_master { extern int fsi_master_register(struct fsi_master *master); extern void fsi_master_unregister(struct fsi_master *master); +extern int fsi_master_rescan(struct fsi_master *master); + #endif /* DRIVERS_FSI_MASTER_H */ From patchwork Mon Feb 12 05:15:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 127922 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp2878609ljc; Sun, 11 Feb 2018 21:16:44 -0800 (PST) X-Google-Smtp-Source: AH8x2270gtQNwtxfmKmxMNJsziId3uQqC6I52hirvpb2pp9iMtDtSaUinwE3gvefYVpz+c2ZcUXc X-Received: by 2002:a17:902:526d:: with SMTP id z100-v6mr9698753plh.396.1518412604590; Sun, 11 Feb 2018 21:16:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518412604; cv=none; d=google.com; s=arc-20160816; b=wKa3DgLZwqfpIdb5C2iNR0QPWarO7W1zBD6q272+YJRxcnvIREr5EpKpyArf4PWFdZ 3IL8/1SbqA6fbQ/gETYZYEvmSF0WKIaWup0y+08KoBROGBK3CoqvfCS6u5/tmo0XO/pX 5UtWT2Jm/bFmihip6UtLOi3iNLW/sheqmUL3nlxJTEf+nNSOc/ba/eMEZZ3vLc9IdndI X58zZzCbO12zbao77WcVSiqCSd6PIkUdHdvZjmO087GNfwY42978Hu7DKcS6eAS2ONps 3ILAu0XVxIpJ9fBV2jlfyVnXotMN8WzaMj2N5TQc8aTe1foOPKRrVq8mP85/e7Pec0ej PhUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=WeHkgg3H/JtN5Wm7yZmgOXs2vSIF2qixWKeOZ1QdahA=; b=HO/fRU3oLK7Rj8OmsnyzRUOTRCA4IuQTYJOoxeLt5wu2XauKpOr4S9UT0e0LUQ6VAp vY3jGOM5yHc+lcwtY6VN3hTF7FtZlqW0SZ0os2eCWjGrA5cM42rEBYRaZ9wN+bcid0Uj HARBHwo+xgxCCCLyQysr6136bZX0ioaDr8LRQf7F+s2ZgrFwJ1YPZAA2DCqq1L5W+80x bkb3Q+KP1ilKXk9PUQV8kJweh8UTAErRpYeLMSKmMCi90D1jg4gVYEnn9wL9clSXyt/k tX0RUaVtpEby3yhlq2tLz7pqGoOa1hqxipUuGARRzhb9AUGglr0Re+t3lhe4qwrN3LYy k/sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=N2xsOWQ0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q75si5779712pfq.220.2018.02.11.21.16.44; Sun, 11 Feb 2018 21:16:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=N2xsOWQ0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751633AbeBLFQi (ORCPT + 13 others); Mon, 12 Feb 2018 00:16:38 -0500 Received: from mail-pl0-f66.google.com ([209.85.160.66]:34760 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751263AbeBLFQc (ORCPT ); Mon, 12 Feb 2018 00:16:32 -0500 Received: by mail-pl0-f66.google.com with SMTP id q17so4551887pll.1; Sun, 11 Feb 2018 21:16:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=WeHkgg3H/JtN5Wm7yZmgOXs2vSIF2qixWKeOZ1QdahA=; b=N2xsOWQ0lklHQPBR1iyac4QtlCSxIVPXfPRhunY69TuVEF9ipADCpXL2RJgir+dygV 0jdlt6Dd2H6wKBr9Fq8uugKAwd+eDYL1wRx4wDTLFLpXwG5mIRznniv5MAsqnoNRi/BW 3Rsbvf2VMqvUAJT48wweUkoQ7XlsKSmYCDm8WVtHTTavw/dMtg5ALHCh03u+y712d9TI n/1msCONxVCxOxkhaiPpReM4dcBbqZ22CM+2vXy8aVdYNnkl2052AQQLRZ+asIAflVbd WES4hG1VUZXRIAmnffGzIiQ0vbmRaHsgRsn8fxMciSoSUsEnSXJoDLbJWb9sui4cBRiA tlrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=WeHkgg3H/JtN5Wm7yZmgOXs2vSIF2qixWKeOZ1QdahA=; b=EBA47GXL/O120mP6ZPgsODn4kK9McstZn4mwU8AmyWkFPHIvmupDC22awYgi3wqHRl iGhatbKh2W8bModxjcDjEHyOfLGvi8uyTvS9MM9fQSFIpJ8IIZJe0J1fwbkxUrg8QPbo G4clJTfKj5Fao3OQy+ghQxGTXX2YMnoARWVv0nlzxyZnpSUFNUy0P/VzsJ+qJ4UiWfbo ybxdjKpaG5jFk0sP1NMJEq31Ejkv/ZlZvoR02+W+2GLXKSo/v8HWxpl5EGoP9DiRVovn WZ4w3dRdwRg5pR1dokzKyAtRUkyshyut5GLXU7RLu5YrZ7ET9+Yx55EKPTgf97C/DHGh eoYA== X-Gm-Message-State: APf1xPBq1qAO8Uel0u6bwjoFYiUU5qKLH1KxC7eAxAxHGE1pbv5Nv2pl jRWazSf/w2lN+ERoye6l4oI= X-Received: by 2002:a17:902:347:: with SMTP id 65-v6mr1742517pld.0.1518412591510; Sun, 11 Feb 2018 21:16:31 -0800 (PST) Received: from aurora.jms.id.au ([203.0.153.9]) by smtp.gmail.com with ESMTPSA id e88sm27661254pfl.80.2018.02.11.21.16.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 11 Feb 2018 21:16:30 -0800 (PST) Received: by aurora.jms.id.au (sSMTP sendmail emulation); Mon, 12 Feb 2018 15:46:24 +1030 From: Joel Stanley To: Greg Kroah-Hartman , Rob Herring , Mark Rutland Cc: Jeremy Kerr , Christopher Bostic , Brad Bishop , Edward James , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 02/10] fsi: master-gpio: Add locking during break and link enable Date: Mon, 12 Feb 2018 15:45:41 +1030 Message-Id: <20180212051549.8575-3-joel@jms.id.au> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180212051549.8575-1-joel@jms.id.au> References: <20180212051549.8575-1-joel@jms.id.au> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jeremy Kerr Currently, we perform GPIO accesses in fsi_master_gpio_break and fsi_master_link_enable, without holding cmd_lock. This change adds the appropriate locking. Signed-off-by: Jeremy Kerr Reviewed-by: Joel Stanley Reviewed-by: Christopher Bostic Signed-off-by: Joel Stanley --- drivers/fsi/fsi-master-gpio.c | 7 +++++++ 1 file changed, 7 insertions(+) -- 2.15.1 diff --git a/drivers/fsi/fsi-master-gpio.c b/drivers/fsi/fsi-master-gpio.c index ae2618768508..a6d602e89c11 100644 --- a/drivers/fsi/fsi-master-gpio.c +++ b/drivers/fsi/fsi-master-gpio.c @@ -461,12 +461,14 @@ static int fsi_master_gpio_term(struct fsi_master *_master, static int fsi_master_gpio_break(struct fsi_master *_master, int link) { struct fsi_master_gpio *master = to_fsi_master_gpio(_master); + unsigned long flags; if (link != 0) return -ENODEV; trace_fsi_master_gpio_break(master); + spin_lock_irqsave(&master->cmd_lock, flags); set_sda_output(master, 1); sda_out(master, 1); clock_toggle(master, FSI_PRE_BREAK_CLOCKS); @@ -475,6 +477,7 @@ static int fsi_master_gpio_break(struct fsi_master *_master, int link) echo_delay(master); sda_out(master, 1); clock_toggle(master, FSI_POST_BREAK_CLOCKS); + spin_unlock_irqrestore(&master->cmd_lock, flags); /* Wait for logic reset to take effect */ udelay(200); @@ -497,10 +500,14 @@ static void fsi_master_gpio_init(struct fsi_master_gpio *master) static int fsi_master_gpio_link_enable(struct fsi_master *_master, int link) { struct fsi_master_gpio *master = to_fsi_master_gpio(_master); + unsigned long flags; if (link != 0) return -ENODEV; + + spin_lock_irqsave(&master->cmd_lock, flags); gpiod_set_value(master->gpio_enable, 1); + spin_unlock_irqrestore(&master->cmd_lock, flags); return 0; } From patchwork Mon Feb 12 05:15:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 127923 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp2878685ljc; Sun, 11 Feb 2018 21:16:52 -0800 (PST) X-Google-Smtp-Source: AH8x226XdBwsPF/5YeI1GKCXpVXsfctAuC7FrwovoPDeCC9aAvGMxzmrzsrRhhgObT6mXcRO5cg0 X-Received: by 10.99.97.211 with SMTP id v202mr8368041pgb.193.1518412612610; Sun, 11 Feb 2018 21:16:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518412612; cv=none; d=google.com; s=arc-20160816; b=R+fb9AzPbbcduM16BU09xLOmjoP/1G3q+Q7VTvqYhI38tDQfF80LyngGjOaBu6lCBL yLMaw61Dva/wVE2C/bp0M4aKxxlPw47iXWrxvkJQxB5S2+rx17K0zG6Lq7qK+S7324Z1 UMkxAMdtiJwYky/XKLvGuYQEA7wEFDjzcMlNDj00JwYQcLhk1n6SfUxVPjI3kkmiLD9k gMVpPrBlsOM9ViGqBISL2SFpDbZiOITd/HtJtrTV34CNIGMnw3C8e50duHFwyzzz8RHw pL8oO+dCo2LbpdKzHZr2DpHoeNPdQx7zDBT938qUyk5+96EpYO0PW17hr2s0issVzbhz TSUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=uYtq4eCpeJZw90RqiXOLUxaA9pm0b4nxqHFXVsUEChE=; b=lmpfjxJGq+eo5DB3UzCRTIBdGBdLXF/pu+TAfBoRIay0oRu8erXrISx8aihABxnNJO cVhN6LJ6PGS3dcnk0SmXvVmgcl0oFopi0YXCp8AtUzu2jlYMpJfUNw1547fv1K4ev28K 7sSNIDxoeRloT8g+94t6h20nU4PcISnBCc+jd8+kLsJZEyAl3S10r/Wm04JjMCwWUQ4G Nsk5vib5GPLby++tlnrnBHKwfUEEIqaUOwgIQ5phBXzONCiiUBH3+VoG5gjVtz4I0j74 BZJVD2XZ8r47HserlX0YwJnWSdhKQ4qe0OBN6SZ8NhE/KXDzCzKO3SdbHo5XvXhHtiNE hslw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=t9QAqrAi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q75si5779712pfq.220.2018.02.11.21.16.52; Sun, 11 Feb 2018 21:16:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=t9QAqrAi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753825AbeBLFQr (ORCPT + 13 others); Mon, 12 Feb 2018 00:16:47 -0500 Received: from mail-pl0-f65.google.com ([209.85.160.65]:45251 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751263AbeBLFQk (ORCPT ); Mon, 12 Feb 2018 00:16:40 -0500 Received: by mail-pl0-f65.google.com with SMTP id p5so4533586plo.12; Sun, 11 Feb 2018 21:16:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=uYtq4eCpeJZw90RqiXOLUxaA9pm0b4nxqHFXVsUEChE=; b=t9QAqrAiL9pQBEcT2y3Nq9X03ZS4xtJivZ+fRmG2JfBGwAd4EOnYpfxCBwV354wxpB PYro+T8Utkhy0P/+ncjEzyFDfD5zgoy58uYJSRzi2z8qQo2ZKKUbEGDIWLddHIWyssvy WXAdP/32RI1LHWZ95iE3IK1dKWDF6LKD7/ZAMRECCTezUb9TSVA2gkP76JX41cEZacwh VyxNfyvSL5FAMvfrKMBcQnBrglEH+JWOcw9IciyztQgk66Z3JaPc+nirGxg7Ezl/sy+K L0VcJy+NNKKh9BygN6PKtL43vqBcZI7zzFRl6M8KbCI1u9nGffS4gCSkMV5JUDCV3lkq yJIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=uYtq4eCpeJZw90RqiXOLUxaA9pm0b4nxqHFXVsUEChE=; b=l8EsRJt18ff0yoMEwDafmak7CFT2WOoYvhXAUfh+JMtIRw8reB1W24CxI4hmIJo3WO nabpjlanuJfaZZznsLD9RsfHc4//eNN/sLjt/y2mJGMdEKkgoxpldO/8PsrUGsCaD97N avnjjwTBy7aKC6Bg5JLkF1/ST+0irrF0r87B3HmtchFckYIluVdiv0HM+7M0ipBsd6j2 fAUEiKyI0dyb63PwwtHG9p8IdP8+mGKTy6uHUyvBND1QT7b++QgAqrdJq/KWSBD/fHc0 tqIdzSx+GvA7J5DpqJtVEdcEB1rlgaW7YzgtUEGGUzupvp7KKaZhDkjIbtU5rvf+joYw 7ZQA== X-Gm-Message-State: APf1xPAPRRVfssnfa5ivPlxLd0cLnhbaC6bxjbGaZ8xNZqO5lKrs5ZZT zYcMiK8dFXFhoC9kg/SJFNQ= X-Received: by 2002:a17:902:14b:: with SMTP id 69-v6mr9891282plb.209.1518412599950; Sun, 11 Feb 2018 21:16:39 -0800 (PST) Received: from aurora.jms.id.au ([203.0.153.9]) by smtp.gmail.com with ESMTPSA id e12sm21661068pgu.48.2018.02.11.21.16.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 11 Feb 2018 21:16:39 -0800 (PST) Received: by aurora.jms.id.au (sSMTP sendmail emulation); Mon, 12 Feb 2018 15:46:31 +1030 From: Joel Stanley To: Greg Kroah-Hartman , Rob Herring , Mark Rutland Cc: Jeremy Kerr , Christopher Bostic , Brad Bishop , Edward James , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 03/10] fsi: master-gpio: Add external mode Date: Mon, 12 Feb 2018 15:45:42 +1030 Message-Id: <20180212051549.8575-4-joel@jms.id.au> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180212051549.8575-1-joel@jms.id.au> References: <20180212051549.8575-1-joel@jms.id.au> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jeremy Kerr This change introduces an 'external mode' for GPIO-based FSI masters, allowing the clock and data lines to be driven by an external source. For example, external mode is selected by a user when an external debug device is attached to the FSI pins. To do this, we need to set specific states for the trans, mux and enable GPIOs, and prevent access to clk & data from the FSI core code (by returning EBUSY). External mode is controlled by a sysfs attribute, so add the relevant information to Documentation/ABI/ Signed-off-by: Jeremy Kerr Reviewed-by: Joel Stanley Signed-off-by: Joel Stanley --- .../ABI/testing/sysfs-driver-fsi-master-gpio | 10 +++ drivers/fsi/fsi-master-gpio.c | 78 +++++++++++++++++++++- 2 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-driver-fsi-master-gpio -- 2.15.1 diff --git a/Documentation/ABI/testing/sysfs-driver-fsi-master-gpio b/Documentation/ABI/testing/sysfs-driver-fsi-master-gpio new file mode 100644 index 000000000000..1f29c8843cfd --- /dev/null +++ b/Documentation/ABI/testing/sysfs-driver-fsi-master-gpio @@ -0,0 +1,10 @@ +What: /sys/bus/platform/devices/[..]/fsi-master-gpio/external_mode +Date: Feb 2018 +KernelVersion: 4.17 +Contact: jk@ozlabs.org +Description: + Controls access arbitration for GPIO-based FSI master. A + value of 0 (the default) sets normal mode, where the + driver performs FSI bus transactions, 1 sets external mode, + where the FSI bus is driven externally (for example, by + a debug device). diff --git a/drivers/fsi/fsi-master-gpio.c b/drivers/fsi/fsi-master-gpio.c index a6d602e89c11..b54c213f3dcb 100644 --- a/drivers/fsi/fsi-master-gpio.c +++ b/drivers/fsi/fsi-master-gpio.c @@ -59,6 +59,7 @@ struct fsi_master_gpio { struct gpio_desc *gpio_trans; /* Voltage translator */ struct gpio_desc *gpio_enable; /* FSI enable */ struct gpio_desc *gpio_mux; /* Mux control */ + bool external_mode; }; #define CREATE_TRACE_POINTS @@ -411,6 +412,12 @@ static int fsi_master_gpio_xfer(struct fsi_master_gpio *master, uint8_t slave, int rc; spin_lock_irqsave(&master->cmd_lock, flags); + + if (master->external_mode) { + spin_unlock_irqrestore(&master->cmd_lock, flags); + return -EBUSY; + } + serial_out(master, cmd); echo_delay(master); rc = poll_for_response(master, slave, resp_len, resp); @@ -469,6 +476,10 @@ static int fsi_master_gpio_break(struct fsi_master *_master, int link) trace_fsi_master_gpio_break(master); spin_lock_irqsave(&master->cmd_lock, flags); + if (master->external_mode) { + spin_unlock_irqrestore(&master->cmd_lock, flags); + return -EBUSY; + } set_sda_output(master, 1); sda_out(master, 1); clock_toggle(master, FSI_PRE_BREAK_CLOCKS); @@ -497,25 +508,84 @@ static void fsi_master_gpio_init(struct fsi_master_gpio *master) clock_zeros(master, FSI_INIT_CLOCKS); } +static void fsi_master_gpio_init_external(struct fsi_master_gpio *master) +{ + gpiod_direction_output(master->gpio_mux, 0); + gpiod_direction_output(master->gpio_trans, 0); + gpiod_direction_output(master->gpio_enable, 1); + gpiod_direction_input(master->gpio_clk); + gpiod_direction_input(master->gpio_data); +} + static int fsi_master_gpio_link_enable(struct fsi_master *_master, int link) { struct fsi_master_gpio *master = to_fsi_master_gpio(_master); unsigned long flags; + int rc = -EBUSY; if (link != 0) return -ENODEV; spin_lock_irqsave(&master->cmd_lock, flags); - gpiod_set_value(master->gpio_enable, 1); + if (!master->external_mode) { + gpiod_set_value(master->gpio_enable, 1); + rc = 0; + } spin_unlock_irqrestore(&master->cmd_lock, flags); - return 0; + return rc; +} + +static ssize_t external_mode_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct fsi_master_gpio *master = dev_get_drvdata(dev); + + return snprintf(buf, PAGE_SIZE - 1, "%u\n", + master->external_mode ? 1 : 0); +} + +static ssize_t external_mode_store(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + struct fsi_master_gpio *master = dev_get_drvdata(dev); + unsigned long flags, val; + bool external_mode; + int err; + + err = kstrtoul(buf, 0, &val); + if (err) + return err; + + external_mode = !!val; + + spin_lock_irqsave(&master->cmd_lock, flags); + + if (external_mode == master->external_mode) { + spin_unlock_irqrestore(&master->cmd_lock, flags); + return count; + } + + master->external_mode = external_mode; + if (master->external_mode) + fsi_master_gpio_init_external(master); + else + fsi_master_gpio_init(master); + spin_unlock_irqrestore(&master->cmd_lock, flags); + + fsi_master_rescan(&master->master); + + return count; } +static DEVICE_ATTR(external_mode, 0664, + external_mode_show, external_mode_store); + static int fsi_master_gpio_probe(struct platform_device *pdev) { struct fsi_master_gpio *master; struct gpio_desc *gpio; + int rc; master = devm_kzalloc(&pdev->dev, sizeof(*master), GFP_KERNEL); if (!master) @@ -572,6 +642,10 @@ static int fsi_master_gpio_probe(struct platform_device *pdev) fsi_master_gpio_init(master); + rc = device_create_file(&pdev->dev, &dev_attr_external_mode); + if (rc) + return rc; + return fsi_master_register(&master->master); } From patchwork Mon Feb 12 05:15:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 127925 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp2878860ljc; Sun, 11 Feb 2018 21:17:12 -0800 (PST) X-Google-Smtp-Source: AH8x224BtddsnAvtC50k0WdpmFzDWCTteipdP5rxu3fF9hddsdwoRmSS86SjKO4ekbPF0svNrOaJ X-Received: by 10.101.80.69 with SMTP id k5mr8530120pgo.431.1518412632313; Sun, 11 Feb 2018 21:17:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518412632; cv=none; d=google.com; s=arc-20160816; b=p5uLKamv9TzVRNFhT4gPnkNPx+FCib9AuUdUKIEEvxylc0m0AWMcEZCyL84zKNA0bq f/Mhp9/mOpTFDPVHuS811Zjgy81dd8+k3NN/qMGquHkvvo+RB7su8qlo+dKXJSU89KIv wQoX66+3q0xVzhqJ7Af2WHFRj9+mw3RrBXBN2qr+G6QQG2c7Ep5IP0/H7GVm7WcwAn0P 27bYI6RxO9a1yN6cYZIrq0j4BQ4svlJcBKUFv6rjzcELOg8XbCEntOdE+LQpD9HJjfRN mbcxkpJ3niT9juyHKFNt0hjWn4JlUj7F3rNbRt1L/ZfQgYanPNl1kqKop6xkNmvVtc3Z J9PQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=rNzHqYsvJJiXVpH19xWBuCpdAEWoaA62sThTAClHcLk=; b=JM6avKEITzE+EufF3dvFoF9WwVwHkBYKi9aMI04C21kjhfe07HW6FSzZ76eIOvFzCT bjc0YaJEvF9HSb7t7uQqUax9SBpHEfQ4MmKgKrrzzbgVwpLqg72ZL3EW/S9Ho0BEvT2X fNHBLIGYHkSl+kToO4qR8ho44v5KwllDihiI8aK9RJYppi+0wmF18tiIzfm7ijaT3X4u Wkx2EDYvDS2GZYHjzmKX2qfvTfm6EOiTX0sF1XKuc+VBQZEhCPwVyxTSN0CMTnT31RVb v/PZmpAb6VuYqoyyo9F8AXFRzHRZHU2zQmAQg0YMRRp1hmVOw/BHt6uctUjDqeD7q7Ph 18+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=t8oX1eG8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q75si5779712pfq.220.2018.02.11.21.17.12; Sun, 11 Feb 2018 21:17:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=t8oX1eG8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932559AbeBLFRD (ORCPT + 13 others); Mon, 12 Feb 2018 00:17:03 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:39735 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932467AbeBLFQ4 (ORCPT ); Mon, 12 Feb 2018 00:16:56 -0500 Received: by mail-pg0-f66.google.com with SMTP id w17so6817733pgv.6; Sun, 11 Feb 2018 21:16:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=rNzHqYsvJJiXVpH19xWBuCpdAEWoaA62sThTAClHcLk=; b=t8oX1eG82SL8dNu8ePVbTuXvHxHAZBDlPuXY72vvPDd1hmCqMBzRHWI8EYU9CUlm1g Qu4LU8ve/cE3w0YL/oPVqgQUuKJE92tXIQv1tWPxL2eD0xyhup9vGh09gbcuuBpy3sWW if7SdrtpcqbGVUtkqdrW6/FMPBiLA2IjSVE5/4NJefsYnRgJYrcI2S3hPwDTA3JL16b3 csZdzg5HrJDx2W6zZGYkZzJ2dxBvqQrVSEyMtGpPKFDOtMi9Jua2WLWK9Iyuhf9qpEpL JBmI4/XsysvEUVYMy9tHan36jpV384Y97W4w70O/jhZP4gzmB9YbCVRqcLqdK01L7uc+ L/hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=rNzHqYsvJJiXVpH19xWBuCpdAEWoaA62sThTAClHcLk=; b=PChkOCc/wmLaZQ8yGCExYmk7ZYa5aXZ12VfqkQWf+YBrK9C3llHttvxklbsg399ScF MSae8GUrR/8mF0J5XlQFvAiOKzZtnGOfcMyuUThKSTzRS48IN5poAY+oGzDUduvZOlOL GDkQSD4Ar6HrNEz0qbl45fmLk6nD6Scjf2SE+/HhSihEp2ac2qZznmM5BvM/e18E/b3K +Kb4hWIX8CkbkWvZaYrJvScH8WQfFTC/g3FtJ7vXubv8vWpp415DY6fY/KVR2mk0RPwj M1B+sflZP3HV4QB68QgvJ1cxh2gK6uTHCiuQP4QYboknicmLIFPNFseKtKmBozbAC+v7 CvwQ== X-Gm-Message-State: APf1xPD5GsJl/xKTUU9jozJszHn+m5BX/yZf2dx/8oXl3kL2ET4BJKci w131UGcxkCPa+S2q7RBkpWo= X-Received: by 10.99.137.195 with SMTP id v186mr7816810pgd.90.1518412615535; Sun, 11 Feb 2018 21:16:55 -0800 (PST) Received: from aurora.jms.id.au ([203.0.153.9]) by smtp.gmail.com with ESMTPSA id u13sm23646448pfd.169.2018.02.11.21.16.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 11 Feb 2018 21:16:54 -0800 (PST) Received: by aurora.jms.id.au (sSMTP sendmail emulation); Mon, 12 Feb 2018 15:46:48 +1030 From: Joel Stanley To: Greg Kroah-Hartman , Rob Herring , Mark Rutland Cc: Jeremy Kerr , Christopher Bostic , Brad Bishop , Edward James , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 05/10] dt-bindings: fsi: Add specification for FSI busses Date: Mon, 12 Feb 2018 15:45:44 +1030 Message-Id: <20180212051549.8575-6-joel@jms.id.au> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180212051549.8575-1-joel@jms.id.au> References: <20180212051549.8575-1-joel@jms.id.au> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jeremy Kerr This change introduces a proposed layout for describing FSI busses in the device tree. While the bus is probe-able, we'd still like a method of describing subordinate (eg i2c) busses that are behind FSI devices. The FSI core will be responsible for matching probed slaves & engines to their device tree nodes, so the FSI device drivers' probe() functions will be passed a struct device with the appropriate of_node populated where a matching DT node is found. Signed-off-by: Jeremy Kerr Acked-by: Joel Stanley Acked-by: Brad Bishop Acked-by: Eddie James Acked-by: Rob Herring Signed-off-by: Joel Stanley --- Documentation/devicetree/bindings/fsi/fsi.txt | 144 ++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 Documentation/devicetree/bindings/fsi/fsi.txt -- 2.15.1 diff --git a/Documentation/devicetree/bindings/fsi/fsi.txt b/Documentation/devicetree/bindings/fsi/fsi.txt new file mode 100644 index 000000000000..4eaf488d4015 --- /dev/null +++ b/Documentation/devicetree/bindings/fsi/fsi.txt @@ -0,0 +1,144 @@ +FSI bus & engine generic device tree bindings +============================================= + +The FSI bus is probe-able, so the OS is able to enumerate FSI slaves, and +engines within those slaves. However, we have a facility to match devicetree +nodes to probed engines. This allows for fsi engines to expose non-probeable +busses, which are then exposed by the device tree. For example, an FSI engine +that is an I2C master - the I2C bus can be described by the device tree under +the engine's device tree node. + +FSI masters may require their own DT nodes (to describe the master HW itself); +that requirement is defined by the master's implementation, and is described by +the fsi-master-* binding specifications. + +Under the masters' nodes, we can describe the bus topology using nodes to +represent the FSI slaves and their slave engines. As a basic outline: + + fsi-master { + /* top-level of FSI bus topology, bound to an FSI master driver and + * exposes an FSI bus */ + + fsi-slave@ { + /* this node defines the FSI slave device, and is handled + * entirely with FSI core code */ + + fsi-slave-engine@ { + /* this node defines the engine endpoint & address range, which + * is bound to the relevant fsi device driver */ + ... + }; + + fsi-slave-engine@ { + ... + }; + + }; + }; + +Note that since the bus is probe-able, some (or all) of the topology may +not be described; this binding only provides an optional facility for +adding subordinate device tree nodes as children of FSI engines. + +FSI masters +----------- + +FSI master nodes declare themselves as such with the "fsi-master" compatible +value. It's likely that an implementation-specific compatible value will +be needed as well, for example: + + compatible = "fsi-master-gpio", "fsi-master"; + +Since the master nodes describe the top-level of the FSI topology, they also +need to declare the FSI-standard addressing scheme. This requires two cells for +addresses (link index and slave ID), and no size: + + #address-cells = <2>; + #size-cells = <0>; + +FSI slaves +---------- + +Slaves are identified by a (link-index, slave-id) pair, so require two cells +for an address identifier. Since these are not a range, no size cells are +required. For an example, a slave on link 1, with ID 2, could be represented +as: + + cfam@1,2 { + reg = <1 2>; + [...]; + } + +Each slave provides an address-space, under which the engines are accessible. +That address space has a maximum of 23 bits, so we use one cell to represent +addresses and sizes in the slave address space: + + #address-cells = <1>; + #size-cells = <1>; + + +FSI engines (devices) +--------------------- + +Engines are identified by their address under the slaves' address spaces. We +use a single cell for address and size. Engine nodes represent the endpoint +FSI device, and are passed to those FSI device drivers' ->probe() functions. + +For example, for a slave using a single 0x400-byte page starting at address +0xc00: + + engine@c00 { + reg = <0xc00 0x400>; + }; + + +Full example +------------ + +Here's an example that illustrates: + - an FSI master + - connected to an FSI slave + - that contains an engine that is an I2C master + - connected to an I2C EEPROM + +The FSI master may be connected to additional slaves, and slaves may have +additional engines, but they don't necessarily need to be describe in the +device tree if no extra platform information is required. + + /* The GPIO-based FSI master node, describing the top level of the + * FSI bus + */ + gpio-fsi { + compatible = "fsi-master-gpio", "fsi-master"; + #address-cells = <2>; + #size-cells = <0>; + + /* A FSI slave (aka. CFAM) at link 0, ID 0. */ + cfam@0,0 { + reg = <0 0>; + #address-cells = <1>; + #size-cells = <1>; + + /* FSI engine at 0xc00, using a single page. In this example, + * it's an I2C master controller, so subnodes describe the + * I2C bus. + */ + i2c-controller@c00 { + reg = <0xc00 0x400>; + + /* Engine-specific data. In this case, we're describing an + * I2C bus, so we're conforming to the generic I2C binding + */ + compatible = "some-vendor,fsi-i2c-controller"; + #address-cells = <1>; + #size-cells = <1>; + + /* I2C endpoint device: an Atmel EEPROM */ + eeprom@50 { + compatible = "atmel,24c256"; + reg = <0x50>; + pagesize = <64>; + }; + }; + }; + }; From patchwork Mon Feb 12 05:15:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 127926 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp2878903ljc; Sun, 11 Feb 2018 21:17:17 -0800 (PST) X-Google-Smtp-Source: AH8x225dHBRjsDaTsYFTOOd3uHevxKcS1jO16O7sCIGCWqHDnh0HAsweFf3ab6duQtwb3kfvDrSw X-Received: by 10.101.92.138 with SMTP id a10mr8459359pgt.191.1518412637653; Sun, 11 Feb 2018 21:17:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518412637; cv=none; d=google.com; s=arc-20160816; b=rcdtZpebk35ETfXuzaV2EnVXnPlFFwwmFZ56JY/dkxcCk4SVsZrBD269qdhkqtQDW9 DaalEmYi3luSLFCqEIt7ZZzSd6zlHFtDmCQDAi4iJov8E4sFP/49lVgf7WcWjBDplC11 jBqYV4OWIKN/AD+G6NowIdBt4K8MRFDbbN+7xDdlHgu8htLW0/Ir3NQavsDIqpx7HtXQ 6D8iEpd5aTYzUYv0FrVBgfIdlu1hOSwib4z3kxXv1OM6YeZqpXvvz4PoescbSv/rtmPN eQyrjSVyVoG0vsVwHB3MdGeWy2lrRUpQLtIzGometwaAHvfw0i+RAS2oxSCHxmoup0/u v74g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=of7diKi7tfMKvmwg2tF9YoG6ES7Rx3p5XxA+LNA5Ox4=; b=iczWMZLgPY4MOlg0H7DNRZU10frHqEym76oh8EFYilZ/qwLAK86sYic0p60BDTdjix JVdAsN1CBCfhZsXL1hw5VeDkul9rxdd94skIiolaCtAStr4RCOKFPmLwoZXHArb7MnW5 KWHj+8o7JBfj7/eX54mH4RsgKqtk5XFjWKOU08RPvg5UUiMep7wz1gE6+23o/Rldwzcz y8vxEeKlthfC95Egt8TKbIjXukxGZiAlQzGECfKqLthOhWXSTRUrDpnhrqj+51BsI4fS EXdCnZA7Q6xi5MmGNYS7UiVai7yPXM4gSyFSIJ3KMnfnMZQKfcRMmfqY89p7hF7Q8/Ez 4Dfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=VUFwgm43; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g5si4781952pgp.433.2018.02.11.21.17.17; Sun, 11 Feb 2018 21:17:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=VUFwgm43; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932635AbeBLFRK (ORCPT + 13 others); Mon, 12 Feb 2018 00:17:10 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:38018 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932467AbeBLFRE (ORCPT ); Mon, 12 Feb 2018 00:17:04 -0500 Received: by mail-pg0-f68.google.com with SMTP id l24so783578pgc.5; Sun, 11 Feb 2018 21:17:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=of7diKi7tfMKvmwg2tF9YoG6ES7Rx3p5XxA+LNA5Ox4=; b=VUFwgm43TyNdBWv1nkJlt8U48bZpkt9M1ETvLMbh6IcKCFqLnVSmBYVnhQFRGp3Mva NhIp0ty4JIRC7irTWi4XuJ7dQ79BkRyE0V3JaPQHLzw0lZrRn9Sc3jhB1YQNnutXHj/8 IqD+IW1e+KIRuURhf+VU6O+aYoIs15yU6h1XkEiTBBGvAdJmMIGhJbaaPQ4l/ArT6BFh Wyybm5PpfaVqaYqhR8LU8x4wwkZz96N6yPzNGC3FYu2oMFFGpRIxmCngJIBPGjdaIje5 6jpMm3JUBgF/FcxzY44/SigRc4AQvRJfX4dGpde5UCHcbPqJey2YzUvFILXiIPv/cKWv FSEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=of7diKi7tfMKvmwg2tF9YoG6ES7Rx3p5XxA+LNA5Ox4=; b=MElAp6AcGpfBoIYvdsP7vnqXIOUcbDXiTHnvP/uzpLikJ6hA7btYFn+ypu08j0BYuF +Ha9QxmJ7h+pja20zO+URjXHLqgP/sxMMvSRdZWiYvOKlVBJ4AvuIOVR6/0XBq8EJe7O r3fdPS2jclUR8xJunpFHJJHtZGVlS+/owCUTeoBwST/WhfuSWCWPYqChu8z3OoZNr58Y 1rh3xL82E771rWq7TSmddP2Uj6XxYewAcpduaUe3lqgjdz/ZHbrf/oP3wSxtCmbiinWL fNciEH7GNi09c6szcdDvgFunu22WWLqX+laW2xZ69Jvy2Ijz8aLylwk2uz1+WQ/NkVsk be3g== X-Gm-Message-State: APf1xPA+8k9QcxbdPAOIOp48THGgNf+y7lgGnlEk49wt2JeawHwWp7F1 Fg5NahEeOdtgNzAsrnLujrM= X-Received: by 10.98.117.133 with SMTP id q127mr9447627pfc.225.1518412623322; Sun, 11 Feb 2018 21:17:03 -0800 (PST) Received: from aurora.jms.id.au ([203.0.153.9]) by smtp.gmail.com with ESMTPSA id s89sm23149511pfk.35.2018.02.11.21.16.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 11 Feb 2018 21:17:02 -0800 (PST) Received: by aurora.jms.id.au (sSMTP sendmail emulation); Mon, 12 Feb 2018 15:46:55 +1030 From: Joel Stanley To: Greg Kroah-Hartman , Rob Herring , Mark Rutland Cc: Jeremy Kerr , Christopher Bostic , Brad Bishop , Edward James , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 06/10] fsi: Match fsi slaves and engines to available dt nodes Date: Mon, 12 Feb 2018 15:45:45 +1030 Message-Id: <20180212051549.8575-7-joel@jms.id.au> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180212051549.8575-1-joel@jms.id.au> References: <20180212051549.8575-1-joel@jms.id.au> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jeremy Kerr This change populates device tree nodes for scanned FSI slaves and engines. If the master populates ->of_node of the FSI master device, we'll look for matching slaves, and under those slaves we'll look for matching engines. This means that FSI drivers will have their ->of_node pointer populated if there's a corresponding DT node, which they can use for further device discover. Presence of device tree nodes is optional, and only required for fsi device drivers that need extra properties, or subordinate devices, to be enumerated. Signed-off-by: Jeremy Kerr Signed-off-by: Joel Stanley --- drivers/fsi/Kconfig | 1 + drivers/fsi/fsi-core.c | 99 +++++++++++++++++++++++++++++++++++++++++++ drivers/fsi/fsi-master-gpio.c | 4 ++ drivers/fsi/fsi-master-hub.c | 4 ++ 4 files changed, 108 insertions(+) -- 2.15.1 diff --git a/drivers/fsi/Kconfig b/drivers/fsi/Kconfig index 513e35173aaa..a326ed663d3c 100644 --- a/drivers/fsi/Kconfig +++ b/drivers/fsi/Kconfig @@ -4,6 +4,7 @@ menuconfig FSI tristate "FSI support" + depends on OF select CRC4 ---help--- FSI - the FRU Support Interface - is a simple bus for low-level diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index e5dfece248a5..1069cb402bd3 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -142,6 +143,7 @@ static void fsi_device_release(struct device *_device) { struct fsi_device *device = to_fsi_dev(_device); + of_node_put(device->dev.of_node); kfree(device); } @@ -334,6 +336,57 @@ extern void fsi_slave_release_range(struct fsi_slave *slave, } EXPORT_SYMBOL_GPL(fsi_slave_release_range); +static bool fsi_device_node_matches(struct device *dev, struct device_node *np, + uint32_t addr, uint32_t size) +{ + unsigned int len, na, ns; + const __be32 *prop; + uint32_t psize; + + na = of_n_addr_cells(np); + ns = of_n_size_cells(np); + + if (na != 1 || ns != 1) + return false; + + prop = of_get_property(np, "reg", &len); + if (!prop || len != 8) + return false; + + if (of_read_number(prop, 1) != addr) + return false; + + psize = of_read_number(prop + 1, 1); + if (psize != size) { + dev_warn(dev, + "node %s matches probed address, but not size (got 0x%x, expected 0x%x)", + of_node_full_name(np), psize, size); + } + + return true; +} + +/* Find a matching node for the slave engine at @address, using @size bytes + * of space. Returns NULL if not found, or a matching node with refcount + * already incremented. + */ +static struct device_node *fsi_device_find_of_node(struct fsi_device *dev) +{ + struct device_node *parent, *np; + + parent = dev_of_node(&dev->slave->dev); + if (!parent) + return NULL; + + for_each_child_of_node(parent, np) { + if (fsi_device_node_matches(&dev->dev, np, + dev->addr, dev->size)) + return np; + } + + return NULL; +} + static int fsi_slave_scan(struct fsi_slave *slave) { uint32_t engine_addr; @@ -402,6 +455,7 @@ static int fsi_slave_scan(struct fsi_slave *slave) dev_set_name(&dev->dev, "%02x:%02x:%02x:%02x", slave->master->idx, slave->link, slave->id, i - 2); + dev->dev.of_node = fsi_device_find_of_node(dev); rc = device_register(&dev->dev); if (rc) { @@ -558,9 +612,53 @@ static void fsi_slave_release(struct device *dev) { struct fsi_slave *slave = to_fsi_slave(dev); + of_node_put(dev->of_node); kfree(slave); } +static bool fsi_slave_node_matches(struct device_node *np, + int link, uint8_t id) +{ + unsigned int len, na, ns; + const __be32 *prop; + + na = of_n_addr_cells(np); + ns = of_n_size_cells(np); + + /* Ensure we have the correct format for addresses and sizes in + * reg properties + */ + if (na != 2 || ns != 0) + return false; + + prop = of_get_property(np, "reg", &len); + if (!prop || len != 8) + return false; + + return (of_read_number(prop, 1) == link) && + (of_read_number(prop + 1, 1) == id); +} + +/* Find a matching node for the slave at (link, id). Returns NULL if none + * found, or a matching node with refcount already incremented. + */ +static struct device_node *fsi_slave_find_of_node(struct fsi_master *master, + int link, uint8_t id) +{ + struct device_node *parent, *np; + + parent = dev_of_node(&master->dev); + if (!parent) + return NULL; + + for_each_child_of_node(parent, np) { + if (fsi_slave_node_matches(np, link, id)) + return np; + } + + return NULL; +} + static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id) { uint32_t chip_id, llmode; @@ -623,6 +721,7 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id) slave->master = master; slave->dev.parent = &master->dev; + slave->dev.of_node = fsi_slave_find_of_node(master, link, id); slave->dev.release = fsi_slave_release; slave->link = link; slave->id = id; diff --git a/drivers/fsi/fsi-master-gpio.c b/drivers/fsi/fsi-master-gpio.c index b54c213f3dcb..3f487449a277 100644 --- a/drivers/fsi/fsi-master-gpio.c +++ b/drivers/fsi/fsi-master-gpio.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -593,6 +594,7 @@ static int fsi_master_gpio_probe(struct platform_device *pdev) master->dev = &pdev->dev; master->master.dev.parent = master->dev; + master->master.dev.of_node = of_node_get(dev_of_node(master->dev)); gpio = devm_gpiod_get(&pdev->dev, "clock", 0); if (IS_ERR(gpio)) { @@ -664,6 +666,8 @@ static int fsi_master_gpio_remove(struct platform_device *pdev) devm_gpiod_put(&pdev->dev, master->gpio_mux); fsi_master_unregister(&master->master); + of_node_put(master->master.dev.of_node); + return 0; } diff --git a/drivers/fsi/fsi-master-hub.c b/drivers/fsi/fsi-master-hub.c index 133b9bff1d65..3223a671a0ef 100644 --- a/drivers/fsi/fsi-master-hub.c +++ b/drivers/fsi/fsi-master-hub.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include "fsi-master.h" @@ -274,6 +275,7 @@ static int hub_master_probe(struct device *dev) hub->master.dev.parent = dev; hub->master.dev.release = hub_master_release; + hub->master.dev.of_node = of_node_get(dev_of_node(dev)); hub->master.n_links = links; hub->master.read = hub_master_read; @@ -302,6 +304,8 @@ static int hub_master_remove(struct device *dev) fsi_master_unregister(&hub->master); fsi_slave_release_range(hub->upstream->slave, hub->addr, hub->size); + of_node_put(hub->master.dev.of_node); + return 0; } From patchwork Mon Feb 12 05:15:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 127927 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp2878983ljc; Sun, 11 Feb 2018 21:17:24 -0800 (PST) X-Google-Smtp-Source: AH8x226hm8hdMEBDLitctLpIjK9qrWfY9zs+YxsSFKxF2DD0Y5bqxBgSV8t6imFd6qxb8JzyTda2 X-Received: by 10.98.31.198 with SMTP id l67mr10576310pfj.30.1518412644088; Sun, 11 Feb 2018 21:17:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518412644; cv=none; d=google.com; s=arc-20160816; b=t59L86/T8hdFu7sn2UsVm/S7KEbKSPEorgYEv1YN1Ta2gWZ291yVHHkhlQ4V/pZTWp Ap8qFi/r/9JsjhwBTfVqi2TuZqIRtKQ5A9qzNbMoa6nFaijCU3tRHZU0zlsvxzlSRyTz Plah9+nrS9bOA31ZwYjbegNczPLlMXUqRQrkdaxKx0AoPD7rT1CTaTPL/CiT+W7pe2nV sh/f1MV4awb3G1AeLAQrfL7lt2M7ytMOH/rvbvaI0EBesCLkAtDoPPUPGtQA6rI2ab7q DbLYKCRYlEwvyW/bqFxeHRgWgjXt/WvnkFnLKD1H9N32Mbzu7CSYe3uhPhPDe9AsflI8 YHgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=/pe7gC4457snTkdizIdjllMLQxQZAy76GlQWszn3i6Q=; b=QIB+g9K2myUtQuvUV2IFKe4BqbCY+czs2AyQpAcw7RZmryZTcBNK3+ebB6S9HBHI+d +W2HlYfBbiO5fC3I9U3/scTPhO5uPCVYQTQPV+i7zIjBspBj0XzXld3VQEKpCzm2GEeS zvFOz2Xy297OZZTyG409NS2v1lcJWE7A5/RgZaLdQSuVHXP26/9Axj7aQFpCqL1AjtfE p2tSAEMntfHvmXTincZOfPej52C7A7QN1/85fM3pXlzrjOIEiyHtaUBp3ootHmqL4oX4 ytxeA8Uw2VmyurcG+rVoZsXfpbvaR9SMQzWXRchY+nFdUQKGvDY1IT8Iow1YwMf0/vhi YTfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=vIwOvjHb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g5si4781952pgp.433.2018.02.11.21.17.23; Sun, 11 Feb 2018 21:17:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=vIwOvjHb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932682AbeBLFRV (ORCPT + 13 others); Mon, 12 Feb 2018 00:17:21 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:39759 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932467AbeBLFRL (ORCPT ); Mon, 12 Feb 2018 00:17:11 -0500 Received: by mail-pg0-f68.google.com with SMTP id w17so6818033pgv.6; Sun, 11 Feb 2018 21:17:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=/pe7gC4457snTkdizIdjllMLQxQZAy76GlQWszn3i6Q=; b=vIwOvjHbEG6uGE9L7oMitSthBIbAVxI9Voo0eByVjgTBhuanR4tmbaxaTmeFOHl0bO g2RFj1PUZtYJpP0WHXS/1bBYf8/ZppjLGia3ZcX7l3Nb+F70/C+YtSHgsOC5EV4UjDco r7xJyoGnWzYk2uJZTbfCMsmchocmPOlj+yj0WmZL1/7PRRGxto/jra4QFBkrfe4fe+iL JZDkPwf6kWqHU3zDXGmQZyYAXTjq16q/x4eCm2xAQmN7l/z3DQPeuabYzkwNK4QcwV3M +MabPGyWCT8acw7yQiGU/bmweNOElHR+Gt/uvQuy85ssKElJL1Myrftw/q12VZzGHMrM Biag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=/pe7gC4457snTkdizIdjllMLQxQZAy76GlQWszn3i6Q=; b=lB8xwtw2l7fVgjI3jo4f8Zb++PDBVrBGTkeVI3fwB2lu6AKCbmJf5TZLrEpmVll5ag 7ZYm0muyI7KpWUme8+up2d3jYnql32gtf3t96RvClVEU+2C9THXcrDIt9k4uGAowpu3w n5sH9YNggRw1y26FFkrQygq3KQKD6OIOzwlTXJMaAG5zJBXbSl7ClmdxIU2ydwkLTndg MjrMzX9ARmToJH19Te8Qhn9FEbn0go3+MkoPEeOAgi7OauhoCZYYHcE0iWDe2SWjrBdr nOThbvs1JoNAO0tfKPvrD+ZY2tY4LS4IS0f5/Ph+7Y++JMfKrmixTO5moDFqpbB6d4Sz q7RQ== X-Gm-Message-State: APf1xPCtiO/M3CKyz5iNeYWHnLRJSl72Gbts+We4ZF30sSv1gh00KjzM ShXdzoMTomI7xOnaLhkokd0= X-Received: by 10.101.77.144 with SMTP id p16mr8659972pgq.106.1518412631197; Sun, 11 Feb 2018 21:17:11 -0800 (PST) Received: from aurora.jms.id.au ([203.0.153.9]) by smtp.gmail.com with ESMTPSA id i11sm19566928pgq.34.2018.02.11.21.17.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 11 Feb 2018 21:17:10 -0800 (PST) Received: by aurora.jms.id.au (sSMTP sendmail emulation); Mon, 12 Feb 2018 15:47:03 +1030 From: Joel Stanley To: Greg Kroah-Hartman , Rob Herring , Mark Rutland Cc: Christopher Bostic , Jeremy Kerr , Brad Bishop , Edward James , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 07/10] fsi: core: Reduce console output during normal scan Date: Mon, 12 Feb 2018 15:45:46 +1030 Message-Id: <20180212051549.8575-8-joel@jms.id.au> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180212051549.8575-1-joel@jms.id.au> References: <20180212051549.8575-1-joel@jms.id.au> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christopher Bostic To reduce amount of console output during boot / power up make all normal path scan related messages debug type. Signed-off-by: Christopher Bostic Acked-by: Jeremy Kerr Signed-off-by: Joel Stanley --- drivers/fsi/fsi-core.c | 4 ++-- drivers/fsi/fsi-master-hub.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) -- 2.15.1 diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index 1069cb402bd3..8d8b25809452 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -207,7 +207,7 @@ static int fsi_slave_report_and_clear_errors(struct fsi_slave *slave) if (rc) return rc; - dev_info(&slave->dev, "status: 0x%08x, sisc: 0x%08x\n", + dev_dbg(&slave->dev, "status: 0x%08x, sisc: 0x%08x\n", be32_to_cpu(stat), be32_to_cpu(irq)); /* clear interrupts */ @@ -687,7 +687,7 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id) return -EIO; } - dev_info(&master->dev, "fsi: found chip %08x at %02x:%02x:%02x\n", + dev_dbg(&master->dev, "fsi: found chip %08x at %02x:%02x:%02x\n", chip_id, master->idx, link, id); rc = fsi_slave_set_smode(master, link, id); diff --git a/drivers/fsi/fsi-master-hub.c b/drivers/fsi/fsi-master-hub.c index 3223a671a0ef..5e4cd3134bc0 100644 --- a/drivers/fsi/fsi-master-hub.c +++ b/drivers/fsi/fsi-master-hub.c @@ -254,7 +254,7 @@ static int hub_master_probe(struct device *dev) reg = be32_to_cpu(__reg); links = (reg >> 8) & 0xff; - dev_info(dev, "hub version %08x (%d links)\n", reg, links); + dev_dbg(dev, "hub version %08x (%d links)\n", reg, links); rc = fsi_slave_claim_range(fsi_dev->slave, FSI_HUB_LINK_OFFSET, FSI_HUB_LINK_SIZE * links); From patchwork Mon Feb 12 05:15:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 127930 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp2879477ljc; Sun, 11 Feb 2018 21:18:21 -0800 (PST) X-Google-Smtp-Source: AH8x225sN0KEuioP5MJcqUvv5CUiYgSdtIvgPLQF2PfR9ec4gxFA05DRSt6f1Vna2d/Rsny5Y2SN X-Received: by 2002:a17:902:fa2:: with SMTP id 31-v6mr10046338plz.346.1518412701478; Sun, 11 Feb 2018 21:18:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518412701; cv=none; d=google.com; s=arc-20160816; b=q8gMyGQXjdsIQiiTckR+RX/7Qy/ZckXghgOljR4OwdcJ6vZHxMDSaUUmnRWvbwCSPh gCv+4YVQnMkXvB80DbnIyiSkciXCU5fUSqZg3Hyrv+ehggHKu53PzA7+R1/RJQuVZkpR Bd1qZO4gYSqZjyDeDObswr2pfsfYwhx4uLLh7JRpNmTb/YZqNioKqEZyLhK/vb/SSFwo MhfCUEP23UiK83+QSEBKo7XU3ukDBsoUW9691Z7up9c6S7SKzUgl9spmt2z7i2tul2w+ TQQrlRcITLlX4ZWHM9zNMkdu68jy3wxSIaR8Eb01qYK5/gHA4JO1A3x30C2V0nj4VCJf 8KIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=B7eddgQ2fGlz7MNVOtGON1OIZLIyyZdsrEn1FPOB0qQ=; b=DtcQ+FqGuRMXxJOFP5Bq0XEDpN6H1XSKCvdvH+NHOldC6fHs9wq5EqJQdsuWur2TPx thMDMAVIc6TtaI1i+D8teRnBo7CF8AwXeIarfr8v6PFKRpRoI5mPuokvn1qgzm2nesop zMqPZjBo4QpF5Ekl4DXG0XowCObMzIHLuyDBspmT1soR0alnDq/ogeakIZHiUrvbxC0D VhexbCU2EiAAOodQrgRBl+cLgJ74rMwCPpvUoHvaUZFhhQu9+mAJbrfaY3DhmjmT8+Nv s+tzOgf+o2eH1U7cVA1cGAkL0fUGIBYgSeqX18o1P3/p/CWNktWl/Per/rk1xXXr4BMm j9rQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=pJ+Oa51r; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 62-v6si5382074ple.267.2018.02.11.21.18.21; Sun, 11 Feb 2018 21:18:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=pJ+Oa51r; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932788AbeBLFSR (ORCPT + 13 others); Mon, 12 Feb 2018 00:18:17 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:42924 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932648AbeBLFRT (ORCPT ); Mon, 12 Feb 2018 00:17:19 -0500 Received: by mail-pg0-f65.google.com with SMTP id m28so6816161pgc.9; Sun, 11 Feb 2018 21:17:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=B7eddgQ2fGlz7MNVOtGON1OIZLIyyZdsrEn1FPOB0qQ=; b=pJ+Oa51rZ4gmrw/mYkqIIgEAtQ1h0HsE05QKKDqAwhc1YSQgx45wBzJsBY4DKFFl3S CjobH4aXBS6BZuhaZNJtOLaX4LTBRTJYaOBP6yriN/3ahlx5wBv/wF4MiuAcgwu0mOgw mGdJIrGMT4dc23SMur9OHPhFMwzRBAUldu/P7fW6nJ/FjzRE526sUNFyT/KZ6mqoJyVd /iSMT9mntGsDMwT3JdzS0eVl6YkO2hDxkGbibf3F6J6zx11CzI3PAx9kFmpIwHwX2Dda 9pU+J1MgI0wZJ5Ca2nhSvUjeW0ra6AYCE4SKJd5p2Z7Rh6VQwms5U7F4ChFuNXeUyc5o Z8uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=B7eddgQ2fGlz7MNVOtGON1OIZLIyyZdsrEn1FPOB0qQ=; b=HXG8U7BXThamwtvDQFY6592fTIsE37BKKmMxntrhwJ6IXmiawEUCTVc6eLz78Owb1V RzV7sTtEGTt8PfcCoStJRq7txmcx1rAK9Djo9Vnun1NH32/GSze4VTq5EYNpn9VJeH0l DhPv++6VHH9K35apPkBVEqi/Fd0gRiYY1YGBMjeQ/kASst0rGAKUyUrFijaOJfslw9qu EZuy1Go45OdeN9i7DDASJv57w+ziHux+SyfRE9ZwPAVTuzraaqudOPHAyeLgkeMgfPVr qqDOylmiZLOmKeZM3lb6r60XDsKXqKJiFmm857tbWRQI6vVZUQF5ND0vXl6xBlxZzwu6 Hkag== X-Gm-Message-State: APf1xPDmaMhaMH+qJbvhB0ney61624vhibUqbH6hOUVZR7Yxwt5rjRtp 01OsVsTSLEld+hmNnjmxLk2t6fR2 X-Received: by 10.101.81.197 with SMTP id i5mr8537431pgq.220.1518412638944; Sun, 11 Feb 2018 21:17:18 -0800 (PST) Received: from aurora.jms.id.au ([203.0.153.9]) by smtp.gmail.com with ESMTPSA id g15sm20444426pgu.52.2018.02.11.21.17.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 11 Feb 2018 21:17:18 -0800 (PST) Received: by aurora.jms.id.au (sSMTP sendmail emulation); Mon, 12 Feb 2018 15:47:11 +1030 From: Joel Stanley To: Greg Kroah-Hartman , Rob Herring , Mark Rutland Cc: Jeremy Kerr , Christopher Bostic , Brad Bishop , Edward James , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 08/10] fsi: master: Clarify master lifetimes & fix use-after-free in hub master Date: Mon, 12 Feb 2018 15:45:47 +1030 Message-Id: <20180212051549.8575-9-joel@jms.id.au> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180212051549.8575-1-joel@jms.id.au> References: <20180212051549.8575-1-joel@jms.id.au> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jeremy Kerr Once we call fsi_master_unregister, the core will put_device, potentially freeing the hub master. This change adds a comment explaining the lifetime of an allocated fsi_master. We then add a reference from the driver to the hub master, so it stays around until we've finished ->remove(). Signed-off-by: Jeremy Kerr Tested-by: Christopher Bostic Signed-off-by: Joel Stanley --- drivers/fsi/fsi-master-hub.c | 21 ++++++++++++++++++--- drivers/fsi/fsi-master.h | 15 +++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) -- 2.15.1 diff --git a/drivers/fsi/fsi-master-hub.c b/drivers/fsi/fsi-master-hub.c index 5e4cd3134bc0..5885fc4a1ef0 100644 --- a/drivers/fsi/fsi-master-hub.c +++ b/drivers/fsi/fsi-master-hub.c @@ -288,10 +288,19 @@ static int hub_master_probe(struct device *dev) hub_master_init(hub); rc = fsi_master_register(&hub->master); - if (!rc) - return 0; + if (rc) + goto err_release; + + /* At this point, fsi_master_register performs the device_initialize(), + * and holds the sole reference on master.dev. This means the device + * will be freed (via ->release) during any subsequent call to + * fsi_master_unregister. We add our own reference to it here, so we + * can perform cleanup (in _remove()) without it being freed before + * we're ready. + */ + get_device(&hub->master.dev); + return 0; - kfree(hub); err_release: fsi_slave_release_range(fsi_dev->slave, FSI_HUB_LINK_OFFSET, FSI_HUB_LINK_SIZE * links); @@ -306,6 +315,12 @@ static int hub_master_remove(struct device *dev) fsi_slave_release_range(hub->upstream->slave, hub->addr, hub->size); of_node_put(hub->master.dev.of_node); + /* + * master.dev will likely be ->release()ed after this, which free()s + * the hub + */ + put_device(&hub->master.dev); + return 0; } diff --git a/drivers/fsi/fsi-master.h b/drivers/fsi/fsi-master.h index 18bd4ad79356..ee0b46086026 100644 --- a/drivers/fsi/fsi-master.h +++ b/drivers/fsi/fsi-master.h @@ -37,6 +37,21 @@ struct fsi_master { #define dev_to_fsi_master(d) container_of(d, struct fsi_master, dev) +/** + * fsi_master registration & lifetime: the fsi_master_register() and + * fsi_master_unregister() functions will take ownership of the master, and + * ->dev in particular. The registration path performs a get_device(), which + * takes the first reference on the device. Similarly, the unregistration path + * performs a put_device(), which may well drop the last reference. + * + * This means that master implementations *may* need to hold their own + * reference (via get_device()) on master->dev. In particular, if the device's + * ->release callback frees the fsi_master, then fsi_master_unregister will + * invoke this free if no other reference is held. + * + * The same applies for the error path of fsi_master_register; if the call + * fails, dev->release will have been invoked. + */ extern int fsi_master_register(struct fsi_master *master); extern void fsi_master_unregister(struct fsi_master *master); From patchwork Mon Feb 12 05:15:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 127929 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp2879207ljc; Sun, 11 Feb 2018 21:17:48 -0800 (PST) X-Google-Smtp-Source: AH8x227qpQDyPEjXZ+eZfBCyKMnqNPbqv7JvoXWUFKXngXLZlVPQ1NgvlVLRXHEw3QWH/eaA9YKu X-Received: by 2002:a17:902:788b:: with SMTP id q11-v6mr9600847pll.378.1518412668431; Sun, 11 Feb 2018 21:17:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518412668; cv=none; d=google.com; s=arc-20160816; b=gKCHqngzUraYN/dR8ZIFqGdvFjlmDsecBitysgu76juDaO85PPrX2tZQvFG87ArzqA zXkAw11c+D/ERHBjfJjOhNlaI+eJx2BcGxOFRChfae3YO7CcTeQ1dmBIPBxQBhve1rEV iWTcJNyI+2u/ZEJiOUu7DO7AKYFJ8RG1sNlXU4USc+fY9pnWALEsDdZm33oXCPNcF9Ik PxKAJEFb4hLsZBR/33K64dhfVInMEjV0wgXiL1rDEEJisjj/rIo59OTcxHtFD8N5L2dc dZbddSKCyW0tX11vgJQRFYUwnYGNq/R7KJcRg7cSGOOcEZBQIegkjJs8270GvmEfum1Q CLdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=9HLKuK1/pBm+NbqrvAiLkuHp7HO92Uh28VXRPfqgPIM=; b=jjzt1wdDLgWTxCJURbKCN+hDid7HYeL9mTRMdRugZ/AYoB2v8vOFR2WjzOTfc8qr3I kbGyp3VeyzdYLJGNAUvWemsvp3cv7C88AS0IL/pqyXXBnZwxpgs3KW+1FAsQJiCNlVGJ Lpi6jTMhkWOUuNMDZORBvNGN2/MNifV3q5+LAz1YoN0ZWINhaSDUbFAG+bI/w3job9fK AWGEIUbJRnXPHo+Exn/50AoI7VPU7WG1gcb9s7t2wxK/GHPREyzUy7MB6qk5UvajF4Zy ZjVOlTVpd+8XZLmeFqlgLPJCKQm7HZoxdfbjCX9MebccLuo1mc5iFx2B7EfEhlnjd5zI /p7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=aRtIP4uI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l5-v6si1901551plk.390.2018.02.11.21.17.48; Sun, 11 Feb 2018 21:17:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=aRtIP4uI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932769AbeBLFRm (ORCPT + 13 others); Mon, 12 Feb 2018 00:17:42 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:38063 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932467AbeBLFRf (ORCPT ); Mon, 12 Feb 2018 00:17:35 -0500 Received: by mail-pg0-f68.google.com with SMTP id l24so784208pgc.5; Sun, 11 Feb 2018 21:17:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=9HLKuK1/pBm+NbqrvAiLkuHp7HO92Uh28VXRPfqgPIM=; b=aRtIP4uIZrLnr6fGINFm0CSBIzU75xWidNI88+tNtehktHxd61wn39aKE7IcFjMF2y GkRH61SRueE2b3Nos+3pJQyo6vIaQVAeozIJ92YajIDY6BZAE25GIC9AoD+sp5p1MFxi suwa9rQu7XWhHAWwuR38ghm9wopdTBPCpYZ5mw+P6Wwqz8dpqtKIQsEFg6NwJE/OJTCY 75r68Zj73QSk0ak+S82clPzvXIdHF5AypTXVdhS37l2r+bh0i7eS+U0ZARR11+XhTHsO /s0903V5maZf+L71vWFabvCf2MkbnAKykUtkLMd7+Rip0uFJms2Pw6E4f1jrFbk4Gih5 3AAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=9HLKuK1/pBm+NbqrvAiLkuHp7HO92Uh28VXRPfqgPIM=; b=seI6wvAv51HbdfoLMIZ9i7qF7LAJi/Ri7PMkimE4HqLwmB0e4/oL4hAS+Kl9IIgHEK ey/UoQxCp8Ztbb5oCi8Kxf0SX932Rwm7Bl1XuWqISN/a4EvfZO/AxW4Iln6uD3995Jaq KbKWNIz37Fu+NKMuk1aT/Y6mViooiC9Jyeq6/hLRzBubJTTC7+xiJggjlwyxub5gc4dx b2aTRoSqDUNg7nYlrRb/1M5FTNxliNUDOlOHd8zxe+cZtTGBoeCkU8DwcN2kZFyqoPiS E6w4rCwzNCwvVomEoBmRibW5dYd/zuQhqTpCBeLqviuYGu+jOPqAdUo3K0NKbIjQ/bQi D2OA== X-Gm-Message-State: APf1xPCMjdfVV6yNXFds41k1X3DBnGEtp3tlwTEvhqBFgezWNwiF+7T5 9n8TvbygPnzTaXFU0XOcdWI= X-Received: by 10.99.168.8 with SMTP id o8mr8619231pgf.42.1518412654888; Sun, 11 Feb 2018 21:17:34 -0800 (PST) Received: from aurora.jms.id.au ([203.0.153.9]) by smtp.gmail.com with ESMTPSA id c185sm25064114pfb.146.2018.02.11.21.17.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 11 Feb 2018 21:17:34 -0800 (PST) Received: by aurora.jms.id.au (sSMTP sendmail emulation); Mon, 12 Feb 2018 15:47:27 +1030 From: Joel Stanley To: Greg Kroah-Hartman , Rob Herring , Mark Rutland Cc: Christopher Bostic , Jeremy Kerr , Brad Bishop , Edward James , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 10/10] fsi: core: Add check for master property no-scan-on-init Date: Mon, 12 Feb 2018 15:45:49 +1030 Message-Id: <20180212051549.8575-11-joel@jms.id.au> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180212051549.8575-1-joel@jms.id.au> References: <20180212051549.8575-1-joel@jms.id.au> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christopher Bostic Prior to scanning a master check if the optional property no-scan-on-init is present. If it is then avoid scanning. This is necessary in cases where a master scan could interfere with another FSI master on the same bus. Signed-off-by: Christopher Bostic Acked-by: Jeremy Kerr Signed-off-by: Joel Stanley --- drivers/fsi/fsi-core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) -- 2.15.1 diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index 8d8b25809452..4c03d6933646 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -901,6 +901,7 @@ static DEVICE_ATTR(break, 0200, NULL, master_break_store); int fsi_master_register(struct fsi_master *master) { int rc; + struct device_node *np; if (!master) return -EINVAL; @@ -928,7 +929,9 @@ int fsi_master_register(struct fsi_master *master) return rc; } - fsi_master_scan(master); + np = dev_of_node(&master->dev); + if (!of_property_read_bool(np, "no-scan-on-init")) + fsi_master_scan(master); return 0; }