Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp269695imu; Fri, 25 Jan 2019 01:57:06 -0800 (PST) X-Google-Smtp-Source: ALg8bN5g2tM+jIPW0PSOiPLOFgHdEY7dsWSNzfw2LFWpaiSvDnUvJSnLlgEjFgFTjN9IR4EwYa50 X-Received: by 2002:a63:df13:: with SMTP id u19mr9380688pgg.294.1548410226851; Fri, 25 Jan 2019 01:57:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548410226; cv=none; d=google.com; s=arc-20160816; b=H1Uuj+ccvBD6kKmqKhFa06QMy7ocZfftgMZUVd5FjnoK/wfwmD6zBZFjpR+y46TZbC pzGhoun9WuCzff2tYCxGr+XpwtfnMN/KnSG/ccQ3pLNWznkRNnhXdN7jMFUiEzTMVM6j 1FPFrGwvqYgWbXBL10OZZm17Pl3Bp31AXbJLDbJVJlVTD3BVDM136SPrrabsCCcokS0w jhV+u6Csn24feh6qsW7ufSNhbus9f8io2HudEnK09VTWIw4Zl9S7YUHj+1UT3UtkbVz4 GOmkX1yquIczqBn1kzZXVXGksj2hWhQOqaPCil9tZ1kltlNHzlhG+Tv/bEkxlyGGflf5 8Reg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=j/D408U4r6JFkf4u9QJ6keXYGp2NkYYGUbwVpg38odw=; b=ss/9cSxnYham5b/VO6smH4aEFoBkxeLlxYuKeu5VgX0z/JWpAlNPH/vIWc3iuZIAGj fM19gohl7AvSYtuWQCs+BOPh7EmF7uYZGvofn+0QRwAMZ6i9sfMGOrH0VQLRC/wNn3nU o+FM5yBuzN2Zizj5WHkqCHlbO2xBd2GveNBiRkwVnkyrViwEpZu4Cgnpq2Ws4fz/wJ/G rBz9kARYFjfBn2GBUw9edAk8+CV/JE039wbJk6mRVJI0HlBbfpHGV8nRix1tK6lURPSD 69cjOlSidn74zg8F5NiDRqb8myEloli92Zkhb9XTSzACcF2EAzBJIsn6ElveCGdg75l/ M4gw== ARC-Authentication-Results: i=1; mx.google.com; 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 m78si2810863pfj.48.2019.01.25.01.56.51; Fri, 25 Jan 2019 01:57:06 -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; 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 S1729302AbfAYJzP (ORCPT + 99 others); Fri, 25 Jan 2019 04:55:15 -0500 Received: from mail.bootlin.com ([62.4.15.54]:42768 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728007AbfAYJzN (ORCPT ); Fri, 25 Jan 2019 04:55:13 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id D9D9D207AD; Fri, 25 Jan 2019 10:55:09 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.2 Received: from localhost.localdomain (aaubervilliers-681-1-87-206.w90-88.abo.wanadoo.fr [90.88.29.206]) by mail.bootlin.com (Postfix) with ESMTPSA id 8E6CD20798; Fri, 25 Jan 2019 10:55:09 +0100 (CET) From: Miquel Raynal To: Andrew Lunn , Vivien Didelot , Florian Fainelli , "David S. Miller" Cc: netdev@vger.kernel.org, , Thomas Petazzoni , Gregory Clement , Antoine Tenart , Maxime Chevallier , Nadav Haklai , Miquel Raynal Subject: [PATCH net-next v2 2/2] net: dsa: mv88e6xxx: Add suspend to RAM support Date: Fri, 25 Jan 2019 10:55:07 +0100 Message-Id: <20190125095507.29334-3-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190125095507.29334-1-miquel.raynal@bootlin.com> References: <20190125095507.29334-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Bring S2RAM support to the mv88e6xxx DSA driver. The content of the *_irq_poll() helper is moved in *_do_irq_poll() so that that the function can be called from the ->resume() callback without using the *work pointer. Signed-off-by: Miquel Raynal --- Changes since v1: ================= * Added the logic to replay rules. * Did not add any port_disable/enable() calls as this will be taken care of by Vivien's patches. drivers/net/dsa/mv88e6xxx/chip.c | 89 ++++++++++++++++++++++++++++++-- 1 file changed, 86 insertions(+), 3 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 428177f80abd..e83c02aaca49 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -547,15 +547,21 @@ static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip) return err; } +static void mv88e6xxx_do_irq_poll(struct mv88e6xxx_chip *chip) +{ + mv88e6xxx_g1_irq_thread_work(chip); + + kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work, + msecs_to_jiffies(100)); +} + static void mv88e6xxx_irq_poll(struct kthread_work *work) { struct mv88e6xxx_chip *chip = container_of(work, struct mv88e6xxx_chip, irq_poll_work.work); - mv88e6xxx_g1_irq_thread_work(chip); - kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work, - msecs_to_jiffies(100)); + mv88e6xxx_do_irq_poll(chip); } static int mv88e6xxx_irq_poll_setup(struct mv88e6xxx_chip *chip) @@ -4855,6 +4861,82 @@ static const void *pdata_device_get_match_data(struct device *dev) return NULL; } +static int __maybe_unused mv88e6xxx_suspend(struct device *dev) +{ + struct dsa_switch *ds = dev_get_drvdata(dev); + struct mv88e6xxx_chip *chip = ds->priv; + + kthread_cancel_delayed_work_sync(&chip->irq_poll_work); + + return dsa_switch_suspend(ds); +} + +static int __maybe_unused mv88e6xxx_resume(struct device *dev) +{ + struct dsa_switch *ds = dev_get_drvdata(dev); + struct mv88e6xxx_chip *chip = ds->priv; + struct mv88e6xxx_rule *rule; + int ret; + + mv88e6xxx_phy_init(chip); + + mutex_lock(&chip->reg_lock); + ret = mv88e6xxx_switch_reset(chip); + mutex_unlock(&chip->reg_lock); + if (ret) { + dev_err(dev, "Failed to reset the switch\n"); + return ret; + } + + ret = mv88e6xxx_setup(ds); + if (ret) { + dev_err(dev, "Failed to setup the switch\n"); + return ret; + } + + mv88e6xxx_do_irq_poll(chip); + + list_for_each_entry(rule, &chip->rules, node) { + switch (rule->type) { + case FDB_RULE: + ret = _mv88e6xxx_port_fdb_add(chip, rule->port, + rule->params.db.addr, + rule->params.db.vid); + break; + case MDB_RULE: + ret = _mv88e6xxx_port_mdb_add(chip, rule->port, + rule->params.db.addr, + rule->params.db.vid); + break; + case VLAN_RULE: + ret = _mv88e6xxx_port_vlan_add(chip, rule->port, + &rule->params.vlan); + break; + case BRIDGE_RULE: + ret = _mv88e6xxx_port_bridge_join(chip, rule->port, + rule->params.br); + break; + case CC_BRIDGE_RULE: + ret = _mv88e6xxx_crosschip_bridge_join(chip, + rule->params.crosschip.dev, + rule->port, + rule->params.crosschip.br); + break; + default: + dev_warn(chip->dev, "Unknown rule type (%d)\n", + rule->type); + continue; + } + + if (ret) + dev_warn(chip->dev, "Cannot re-apply rule\n"); + } + + return dsa_switch_resume(ds); +} + +static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume); + static int mv88e6xxx_probe(struct mdio_device *mdiodev) { struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data; @@ -5041,6 +5123,7 @@ static struct mdio_driver mv88e6xxx_driver = { .mdiodrv.driver = { .name = "mv88e6085", .of_match_table = mv88e6xxx_of_match, + .pm = &mv88e6xxx_pm_ops, }, }; -- 2.19.1