From patchwork Sat Mar 26 07:00:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Ricard X-Patchwork-Id: 8674251 Return-Path: X-Original-To: patchwork-tpmdd-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C36889F44D for ; Sat, 26 Mar 2016 07:00:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7C93220268 for ; Sat, 26 Mar 2016 07:00:39 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D50AA20260 for ; Sat, 26 Mar 2016 07:00:37 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1ajiD6-0007uf-Me; Sat, 26 Mar 2016 07:00:36 +0000 Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1ajiD5-0007uQ-2p for tpmdd-devel@lists.sourceforge.net; Sat, 26 Mar 2016 07:00:35 +0000 Received-SPF: pass (sog-mx-1.v43.ch3.sourceforge.com: domain of gmail.com designates 74.125.82.68 as permitted sender) client-ip=74.125.82.68; envelope-from=christophe.ricard@gmail.com; helo=mail-wm0-f68.google.com; Received: from mail-wm0-f68.google.com ([74.125.82.68]) by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1ajiD3-00057C-Kg for tpmdd-devel@lists.sourceforge.net; Sat, 26 Mar 2016 07:00:35 +0000 Received: by mail-wm0-f68.google.com with SMTP id p65so8211051wmp.1 for ; Sat, 26 Mar 2016 00:00:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IfkgxLSkh1gK5EOOAFBzUrQ6gND5MF1hw9SCgtErARE=; b=TczZeHIPnUbyP+1tKyHs/Cq7u2h4Xc1wtSvo4ZO5Zqtn8cbc0SxTQo8eHpbIElbUux Kb6ehUOA59sWT0kSy5k/80in6ADwWYF7Jmf10nUxro1rPVu3bsMgHPQn6wEUF+XxSsOe l1YMGEB6Kbdgx3pml1aHRtG+UirwZFgk5+gQgma0ItvDmj2a3f/sS9BCjZqVo7zeBPSd 4xrUbbIuXuEin0QIZmd0iyAg6CjZgC2ROmUi4f+6gdJHsjLvKts4hnq3BuCeoxYFdr/w VwavuP85nBukfvwui/m6zwbTDztPlszgxbIW73c+WjEWYYgqiQ4oiSTFj1SjrlXlsMk4 IwEQ== X-Gm-Message-State: AD7BkJJC8dlkeHlO6A0rL3Gfw4WLesMFtD9dpQbPY45qf5TM3VP/kBf1BLL13BTuqtKfHw== X-Received: by 10.28.88.15 with SMTP id m15mr477239wmb.60.1458975627642; Sat, 26 Mar 2016 00:00:27 -0700 (PDT) Received: from localhost.localdomain (ax113-6-78-236-204-66.fbx.proxad.net. [78.236.204.66]) by smtp.gmail.com with ESMTPSA id lz5sm14978102wjb.5.2016.03.26.00.00.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 26 Mar 2016 00:00:26 -0700 (PDT) From: Christophe Ricard X-Google-Original-From: Christophe Ricard To: jarkko.sakkinen@linux.intel.com Date: Sat, 26 Mar 2016 08:00:13 +0100 Message-Id: <1458975615-8095-6-git-send-email-christophe-h.ricard@st.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1458975615-8095-1-git-send-email-christophe-h.ricard@st.com> References: <1458975615-8095-1-git-send-email-christophe-h.ricard@st.com> X-Spam-Score: -1.6 (-) X-Headers-End: 1ajiD3-00057C-Kg Cc: jean-luc.blanc@st.com, ashley@ashleylai.com, tpmdd-devel@lists.sourceforge.net, christophe-h.ricard@st.com, benoit.houyere@st.com Subject: [tpmdd-devel] [PATCH v2 5/7] tpm: drop 'irq' from struct tpm_vendor_specific X-BeenThere: tpmdd-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Tpm Device Driver maintainance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: tpmdd-devel-bounces@lists.sourceforge.net X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,HK_RANDOM_ENVFROM,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Dropped the field 'irq' from struct tpm_vendor_specific and make it available to the various private structures in the drivers using irqs. A dedicated flag TPM_CHIP_FLAG_USES_IRQ is added for the upper layers. Signed-off-by: Christophe Ricard --- drivers/char/tpm/st33zp24/st33zp24.c | 15 ++++++++------- drivers/char/tpm/st33zp24/st33zp24.h | 1 + drivers/char/tpm/tpm-interface.c | 4 ++-- drivers/char/tpm/tpm.h | 3 +-- drivers/char/tpm/tpm_i2c_atmel.c | 1 - drivers/char/tpm/tpm_i2c_infineon.c | 3 --- drivers/char/tpm/tpm_i2c_nuvoton.c | 21 ++++++++++++--------- drivers/char/tpm/tpm_tis.c | 30 +++++++++++++++++------------- drivers/char/tpm/xen-tpmfront.c | 7 ++++--- 9 files changed, 45 insertions(+), 40 deletions(-) diff --git a/drivers/char/tpm/st33zp24/st33zp24.c b/drivers/char/tpm/st33zp24/st33zp24.c index 3c0625c..7a5de0e 100644 --- a/drivers/char/tpm/st33zp24/st33zp24.c +++ b/drivers/char/tpm/st33zp24/st33zp24.c @@ -268,10 +268,10 @@ static int wait_for_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout, stop = jiffies + timeout; - if (chip->vendor.irq) { + if (chip->flags & TPM_CHIP_FLAG_USES_IRQ) { cur_intrs = tpm_dev->intrs; clear_interruption(tpm_dev); - enable_irq(chip->vendor.irq); + enable_irq(tpm_dev->irq); do { if (ret == -ERESTARTSYS && freezing(current)) @@ -294,7 +294,7 @@ static int wait_for_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout, } } while (ret == -ERESTARTSYS && freezing(current)); - disable_irq_nosync(chip->vendor.irq); + disable_irq_nosync(tpm_dev->irq); } else { do { @@ -352,7 +352,7 @@ static irqreturn_t tpm_ioserirq_handler(int irq, void *dev_id) tpm_dev->intrs++; wake_up_interruptible(&chip->vendor.read_queue); - disable_irq_nosync(chip->vendor.irq); + disable_irq_nosync(tpm_dev->irq); return IRQ_HANDLED; } /* tpm_ioserirq_handler() */ @@ -430,7 +430,7 @@ static int st33zp24_send(struct tpm_chip *chip, unsigned char *buf, if (ret < 0) goto out_err; - if (chip->vendor.irq) { + if (chip->flags & TPM_CHIP_FLAG_USES_IRQ) { ordinal = be32_to_cpu(*((__be32 *) (buf + 6))); ret = wait_for_stat(chip, TPM_STS_DATA_AVAIL | TPM_STS_VALID, @@ -585,9 +585,10 @@ int st33zp24_probe(void *phy_id, const struct st33zp24_phy_ops *ops, if (ret < 0) goto _tpm_clean_answer; - chip->vendor.irq = irq; + tpm_dev->irq = irq; + chip->flags |= TPM_CHIP_FLAG_USES_IRQ; - disable_irq_nosync(chip->vendor.irq); + disable_irq_nosync(tpm_dev->irq); tpm_gen_interrupt(chip); } diff --git a/drivers/char/tpm/st33zp24/st33zp24.h b/drivers/char/tpm/st33zp24/st33zp24.h index b242263..b139a8d 100644 --- a/drivers/char/tpm/st33zp24/st33zp24.h +++ b/drivers/char/tpm/st33zp24/st33zp24.h @@ -24,6 +24,7 @@ struct st33zp24_dev { void *phy_id; const struct st33zp24_phy_ops *ops; + int irq; u32 intrs; int io_lpcpd; }; diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c index 5397b64..0bdd25b 100644 --- a/drivers/char/tpm/tpm-interface.c +++ b/drivers/char/tpm/tpm-interface.c @@ -359,7 +359,7 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf, goto out; } - if (chip->vendor.irq) + if (chip->flags & TPM_CHIP_FLAG_USES_IRQ) goto out_recv; if (chip->flags & TPM_CHIP_FLAG_TPM2) @@ -890,7 +890,7 @@ int wait_for_tpm_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout, stop = jiffies + timeout; - if (chip->vendor.irq) { + if (chip->flags & TPM_CHIP_FLAG_USES_IRQ) { again: timeout = stop - jiffies; if ((long)timeout <= 0) diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h index c4d3f41..26c8d62 100644 --- a/drivers/char/tpm/tpm.h +++ b/drivers/char/tpm/tpm.h @@ -131,8 +131,6 @@ enum tpm2_startup_types { struct tpm_chip; struct tpm_vendor_specific { - int irq; - int locality; unsigned long timeout_a, timeout_b, timeout_c, timeout_d; /* jiffies */ bool timeout_adjusted; @@ -151,6 +149,7 @@ struct tpm_vendor_specific { enum tpm_chip_flags { TPM_CHIP_FLAG_REGISTERED = BIT(0), TPM_CHIP_FLAG_TPM2 = BIT(1), + TPM_CHIP_FLAG_USES_IRQ = BIT(2), }; struct tpm_chip { diff --git a/drivers/char/tpm/tpm_i2c_atmel.c b/drivers/char/tpm/tpm_i2c_atmel.c index d357065..fe06885 100644 --- a/drivers/char/tpm/tpm_i2c_atmel.c +++ b/drivers/char/tpm/tpm_i2c_atmel.c @@ -172,7 +172,6 @@ static int i2c_atmel_probe(struct i2c_client *client, chip->vendor.timeout_b = msecs_to_jiffies(TPM_I2C_LONG_TIMEOUT); chip->vendor.timeout_c = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT); chip->vendor.timeout_d = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT); - chip->vendor.irq = 0; dev_set_drvdata(&chip->dev, priv); diff --git a/drivers/char/tpm/tpm_i2c_infineon.c b/drivers/char/tpm/tpm_i2c_infineon.c index e74f1c1..093daf9 100644 --- a/drivers/char/tpm/tpm_i2c_infineon.c +++ b/drivers/char/tpm/tpm_i2c_infineon.c @@ -585,9 +585,6 @@ static int tpm_tis_i2c_init(struct device *dev) if (IS_ERR(chip)) return PTR_ERR(chip); - /* Disable interrupts */ - chip->vendor.irq = 0; - /* Default timeouts */ chip->vendor.timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT); chip->vendor.timeout_b = msecs_to_jiffies(TIS_LONG_TIMEOUT); diff --git a/drivers/char/tpm/tpm_i2c_nuvoton.c b/drivers/char/tpm/tpm_i2c_nuvoton.c index 76ac21d..bf3ba18 100644 --- a/drivers/char/tpm/tpm_i2c_nuvoton.c +++ b/drivers/char/tpm/tpm_i2c_nuvoton.c @@ -55,6 +55,7 @@ #define I2C_DRIVER_NAME "tpm_i2c_nuvoton" struct priv_data { + int irq; unsigned int intrs; }; @@ -176,12 +177,12 @@ static bool i2c_nuvoton_check_status(struct tpm_chip *chip, u8 mask, u8 value) static int i2c_nuvoton_wait_for_stat(struct tpm_chip *chip, u8 mask, u8 value, u32 timeout, wait_queue_head_t *queue) { - if (chip->vendor.irq && queue) { + if (chip->flags & TPM_CHIP_FLAG_USES_IRQ && queue) { s32 rc; struct priv_data *priv = dev_get_drvdata(&chip->dev); unsigned int cur_intrs = priv->intrs; - enable_irq(chip->vendor.irq); + enable_irq(priv->irq); rc = wait_event_interruptible_timeout(*queue, cur_intrs != priv->intrs, timeout); @@ -477,7 +478,7 @@ static irqreturn_t i2c_nuvoton_int_handler(int dummy, void *dev_id) priv->intrs++; wake_up(&chip->vendor.read_queue); - disable_irq_nosync(chip->vendor.irq); + disable_irq_nosync(priv->irq); return IRQ_HANDLED; } @@ -554,19 +555,21 @@ static int i2c_nuvoton_probe(struct i2c_client *client, * TPM_INTF_INT_LEVEL_LOW | TPM_INTF_DATA_AVAIL_INT * The IRQ should be set in the i2c_board_info (which is done * automatically in of_i2c_register_devices, for device tree users */ - chip->vendor.irq = client->irq; + chip->flags |= TPM_CHIP_FLAG_USES_IRQ; + priv->irq = client->irq; - if (chip->vendor.irq) { - dev_dbg(dev, "%s() chip-vendor.irq\n", __func__); - rc = devm_request_irq(dev, chip->vendor.irq, + if (chip->flags & TPM_CHIP_FLAG_USES_IRQ) { + dev_dbg(dev, "%s() priv->irq\n", __func__); + rc = devm_request_irq(dev, client->irq, i2c_nuvoton_int_handler, IRQF_TRIGGER_LOW, dev_name(&chip->dev), chip); if (rc) { dev_err(dev, "%s() Unable to request irq: %d for use\n", - __func__, chip->vendor.irq); - chip->vendor.irq = 0; + __func__, priv->irq); + chip->flags &= ~TPM_CHIP_FLAG_USES_IRQ; + priv->irq = 0; } else { /* Clear any pending interrupt */ i2c_nuvoton_ready(chip); diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c index bf333cf..79edfc3 100644 --- a/drivers/char/tpm/tpm_tis.c +++ b/drivers/char/tpm/tpm_tis.c @@ -96,6 +96,7 @@ struct tpm_info { struct priv_data { void __iomem *iobase; u16 manufacturer_id; + int irq; bool irq_tested; wait_queue_head_t int_queue; }; @@ -178,7 +179,7 @@ static int request_locality(struct tpm_chip *chip, int l) stop = jiffies + chip->vendor.timeout_a; - if (chip->vendor.irq) { + if (chip->flags & TPM_CHIP_FLAG_USES_IRQ) { again: timeout = stop - jiffies; if ((long)timeout <= 0) @@ -386,8 +387,9 @@ static void disable_interrupts(struct tpm_chip *chip) intmask &= ~TPM_GLOBAL_INT_ENABLE; iowrite32(intmask, priv->iobase + TPM_INT_ENABLE(chip->vendor.locality)); - devm_free_irq(&chip->dev, chip->vendor.irq, chip); - chip->vendor.irq = 0; + devm_free_irq(&chip->dev, priv->irq, chip); + priv->irq = 0; + chip->flags &= ~TPM_CHIP_FLAG_USES_IRQ; } /* @@ -410,7 +412,7 @@ static int tpm_tis_send_main(struct tpm_chip *chip, u8 *buf, size_t len) iowrite8(TPM_STS_GO, priv->iobase + TPM_STS(chip->vendor.locality)); - if (chip->vendor.irq) { + if (chip->flags & TPM_CHIP_FLAG_USES_IRQ) { ordinal = be32_to_cpu(*((__be32 *) (buf + 6))); if (chip->flags & TPM_CHIP_FLAG_TPM2) @@ -437,14 +439,16 @@ static int tpm_tis_send(struct tpm_chip *chip, u8 *buf, size_t len) int rc, irq; struct priv_data *priv = dev_get_drvdata(&chip->dev); - if (!chip->vendor.irq || priv->irq_tested) + if (!(chip->flags & TPM_CHIP_FLAG_USES_IRQ) || priv->irq_tested) return tpm_tis_send_main(chip, buf, len); /* Verify receipt of the expected IRQ */ - irq = chip->vendor.irq; - chip->vendor.irq = 0; + irq = priv->irq; + priv->irq = 0; + chip->flags &= ~TPM_CHIP_FLAG_USES_IRQ; rc = tpm_tis_send_main(chip, buf, len); - chip->vendor.irq = irq; + priv->irq = irq; + chip->flags |= TPM_CHIP_FLAG_USES_IRQ; if (!priv->irq_tested) msleep(1); if (!priv->irq_tested) @@ -606,7 +610,7 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask, irq); return -1; } - chip->vendor.irq = irq; + priv->irq = irq; original_int_vec = ioread8(priv->iobase + TPM_INT_VECTOR(chip->vendor.locality)); @@ -635,7 +639,7 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask, /* tpm_tis_send will either confirm the interrupt is working or it * will call disable_irq which undoes all of the above. */ - if (!chip->vendor.irq) { + if (!(chip->flags & TPM_CHIP_FLAG_USES_IRQ)) { iowrite8(original_int_vec, priv->iobase + TPM_INT_VECTOR(chip->vendor.locality)); return 1; @@ -804,7 +808,7 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info, if (tpm_info->irq) { tpm_tis_probe_irq_single(chip, intmask, IRQF_SHARED, tpm_info->irq); - if (!chip->vendor.irq) + if (!(chip->flags & TPM_CHIP_FLAG_USES_IRQ)) dev_err(&chip->dev, FW_BUG "TPM interrupt not working, polling instead\n"); } else @@ -848,7 +852,7 @@ static void tpm_tis_reenable_interrupts(struct tpm_chip *chip) /* reenable interrupts that device may have lost or BIOS/firmware may have disabled */ - iowrite8(chip->vendor.irq, priv->iobase + + iowrite8(priv->irq, priv->iobase + TPM_INT_VECTOR(chip->vendor.locality)); intmask = @@ -867,7 +871,7 @@ static int tpm_tis_resume(struct device *dev) struct tpm_chip *chip = dev_get_drvdata(dev); int ret; - if (chip->vendor.irq) + if (chip->flags & TPM_CHIP_FLAG_USES_IRQ) tpm_tis_reenable_interrupts(chip); ret = tpm_pm_resume(dev); diff --git a/drivers/char/tpm/xen-tpmfront.c b/drivers/char/tpm/xen-tpmfront.c index efd7d99..a903f86 100644 --- a/drivers/char/tpm/xen-tpmfront.c +++ b/drivers/char/tpm/xen-tpmfront.c @@ -28,6 +28,7 @@ struct tpm_private { unsigned int evtchn; int ring_ref; domid_t backend_id; + int irq; }; enum status_bits { @@ -217,7 +218,7 @@ static int setup_ring(struct xenbus_device *dev, struct tpm_private *priv) xenbus_dev_fatal(dev, rv, "allocating TPM irq"); return rv; } - priv->chip->vendor.irq = rv; + priv->irq = rv; again: rv = xenbus_transaction_start(&xbt); @@ -277,8 +278,8 @@ static void ring_free(struct tpm_private *priv) else free_page((unsigned long)priv->shr); - if (priv->chip && priv->chip->vendor.irq) - unbind_from_irqhandler(priv->chip->vendor.irq, priv); + if (priv->irq) + unbind_from_irqhandler(priv->irq, priv); kfree(priv); }