From nobody Mon Feb 9 08:50:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C390CC7EE23 for ; Sun, 4 Jun 2023 05:45:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229485AbjFDFpC (ORCPT ); Sun, 4 Jun 2023 01:45:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229971AbjFDFpA (ORCPT ); Sun, 4 Jun 2023 01:45:00 -0400 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BED17CE for ; Sat, 3 Jun 2023 22:44:59 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id E90245C0108; Sun, 4 Jun 2023 01:44:57 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Sun, 04 Jun 2023 01:44:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1685857497; x= 1685943897; bh=JB7K4eidj7H1KpxfnC6amlDwCbgE0URtV74lvVmVyE0=; b=Q kP7H19xJnIgyVj44WdEVh/W48SS/7U4wOy13xD+fw0ipdjZ3Lm44pZK4ZwrSiJQA b6VEyBL9JYFKwNXtOpmpSzEXcFjadgBtOcZTON7R8noC3eMQsYXYnzAa9SijWiDQ GujbnoyreZLoBKxS0B/UejA2fIQn3Td48PZf1dTLvsS64G+wB9pnC5jWw1gb/OL7 29W4zvSEC3rMf4DNa8TEevjHvOyauK4HYcNbVQaD3/Dex8dHA3S9eDtI0ySGBqSJ ZC0DYgZRBK6j/LMCqIIjF5brQsEEiCFORjZaN1fr8xjgh22rBlgtlaBc9srvu6As gZEOzyZR2Kn9Bdi40M40A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1685857497; x=1685943897; bh=J B7K4eidj7H1KpxfnC6amlDwCbgE0URtV74lvVmVyE0=; b=m507attTArW1hSN37 3IFOIT2dhJH/7ohUHGHeD1KsxgIlBbKiEmAukzITKhmgIeJBYxkvhNm25RwEYjXu 5ogvxAvVJfXiy1wRNZeu3WC3g3Nvt11G4i8+nZVjQ+cn6gJvMaJ8nf1/Y9vOqkBN kuhg7EqpbglPeccNeW1aj+2gWaSW69ZL5phn4cxQspx1pX17U6E1dr856DAl/+SC +HZExs++6ocflj5nkSOoePrKZedzosr4115dZ3XKrkXdGLyTAiCLve4m7vSmNSAr rp+oWEgEzqIfSZVMkKaohYp9mP3WvNQN/w/ts73g6j4QIs5LT4g+piZku499Ne0w Hhgwg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeliedguddtudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeevfefffe ektefgveegfeelheffhfeujedtjeevtefhkeevkedtjeejvddtjefhjeenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 4 Jun 2023 01:44:56 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH 1/9] firewire: ohci: use devres for memory object of ohci structure Date: Sun, 4 Jun 2023 14:44:43 +0900 Message-Id: <20230604054451.161076-2-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230604054451.161076-1-o-takashi@sakamocchi.jp> References: <20230604054451.161076-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The managed device resource (devres) framework is convenient to maintain lifetime of allocated memory object for device. This commit utilizes the framework for the object of ohci structure. The extra operation for power management is required in Apple PowerMac based machines, thus release callback is assigned to the object to call the operation. Signed-off-by: Takashi Sakamoto --- drivers/firewire/ohci.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index 06386c3b7f03..2b02cebcb0ae 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c @@ -3557,6 +3557,15 @@ static inline void pmac_ohci_on(struct pci_dev *dev)= {} static inline void pmac_ohci_off(struct pci_dev *dev) {} #endif /* CONFIG_PPC_PMAC */ =20 +static void release_ohci(struct device *dev, void *data) +{ + struct pci_dev *pdev =3D to_pci_dev(dev); + + pmac_ohci_off(pdev); + + dev_notice(dev, "removed fw-ohci device\n"); +} + static int pci_probe(struct pci_dev *dev, const struct pci_device_id *ent) { @@ -3571,25 +3580,22 @@ static int pci_probe(struct pci_dev *dev, return -ENOSYS; } =20 - ohci =3D kzalloc(sizeof(*ohci), GFP_KERNEL); - if (ohci =3D=3D NULL) { - err =3D -ENOMEM; - goto fail; - } - + ohci =3D devres_alloc(release_ohci, sizeof(*ohci), GFP_KERNEL); + if (ohci =3D=3D NULL) + return -ENOMEM; fw_card_initialize(&ohci->card, &ohci_driver, &dev->dev); - + pci_set_drvdata(dev, ohci); pmac_ohci_on(dev); + devres_add(&dev->dev, ohci); =20 err =3D pci_enable_device(dev); if (err) { dev_err(&dev->dev, "failed to enable OHCI hardware\n"); - goto fail_free; + return err; } =20 pci_set_master(dev); pci_write_config_dword(dev, OHCI1394_PCI_HCI_Control, 0); - pci_set_drvdata(dev, ohci); =20 spin_lock_init(&ohci->lock); mutex_init(&ohci->phy_reg_mutex); @@ -3748,10 +3754,7 @@ static int pci_probe(struct pci_dev *dev, pci_release_region(dev, 0); fail_disable: pci_disable_device(dev); - fail_free: - kfree(ohci); - pmac_ohci_off(dev); - fail: + return err; } =20 @@ -3796,10 +3799,8 @@ static void pci_remove(struct pci_dev *dev) pci_iounmap(dev, ohci->registers); pci_release_region(dev, 0); pci_disable_device(dev); - kfree(ohci); - pmac_ohci_off(dev); =20 - dev_notice(&dev->dev, "removed fw-ohci device\n"); + dev_notice(&dev->dev, "removing fw-ohci device\n"); } =20 #ifdef CONFIG_PM --=20 2.39.2 From nobody Mon Feb 9 08:50:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A354C7EE23 for ; Sun, 4 Jun 2023 05:45:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230124AbjFDFpK (ORCPT ); Sun, 4 Jun 2023 01:45:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229974AbjFDFpB (ORCPT ); Sun, 4 Jun 2023 01:45:01 -0400 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C83A9DD for ; Sat, 3 Jun 2023 22:44:59 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 3F7285C010A; Sun, 4 Jun 2023 01:44:59 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 04 Jun 2023 01:44:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1685857499; x= 1685943899; bh=+LOorxHwbHKlpWuigPekygpArmsdgCBfeAYLfsUoUC8=; b=l OO8YIkwmgwBmWa9kBcqjRiJ2ecPa213T8+CB2NHgnS9p7JK8j1IDUeTsHRDTu9x1 lVczR98SkiknFbOWw0R8kRY4AkKhJcoPkbmfW/e6G0zptmYu9frw0gA98ZQY2P0n 1QK4CmYXkDYTz0u/xJ0HDlk7SkJmVuhtedHOo2/rN4N1zCE3TuDSB/046vfJO+7Y U3UUh7kmPjA9VxsUtXtzLjiCiTgoHJOnBwZVY9AuWAcIN6tgTQqsrqHALD/6hWTj PYcY+odWIPyQxDXNldin//bBHo/YcDChH5Y0BLzBark3fnTAQfGIjfQZBLDhB4kP 5leGVUYBl+cjMpsquMoYw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1685857499; x=1685943899; bh=+ LOorxHwbHKlpWuigPekygpArmsdgCBfeAYLfsUoUC8=; b=PktUWT3NW9iRawXCV bMT1gmGk2EY+LKBNGle5fSfAxHzKh17G7TigsLwekjIIZnGh1ZYu+uUWncIRRRcL 46hQUDWcWbjNpzOvg25p4aQIdJaD4I+DBzuSgG9rGAkkArPN7vabC9gTNk2VptPR 8HpN82LXkzaiheJH1DZj7hkfMd4M76Te/QyuTh2n73iN6HUBBe04y2ERNX9QS820 aMvZdZHUHjEclkrOOtdWoydwaNHzlHadhhbhGDZHwpZe98+ZtVXYjUxTF2bCdjCx s+wbuk728LtyZqGcB4ME+WfeyCzinsQH99inq4I7X1/xk3SiYKFRoHDeJJa/gZKV QeZgA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeliedguddtudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeevfefffe ektefgveegfeelheffhfeujedtjeevtefhkeevkedtjeejvddtjefhjeenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 4 Jun 2023 01:44:58 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH 2/9] firewire: ohci: use devres for PCI-related resources Date: Sun, 4 Jun 2023 14:44:44 +0900 Message-Id: <20230604054451.161076-3-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230604054451.161076-1-o-takashi@sakamocchi.jp> References: <20230604054451.161076-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The PCI framework supports managed device resource to maintain the lifetime of PCI specific resources. This commit allows 1394 OHCI driver to utilize it. Signed-off-by: Takashi Sakamoto --- drivers/firewire/ohci.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index 2b02cebcb0ae..f3d0882a876c 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c @@ -3588,7 +3588,7 @@ static int pci_probe(struct pci_dev *dev, pmac_ohci_on(dev); devres_add(&dev->dev, ohci); =20 - err =3D pci_enable_device(dev); + err =3D pcim_enable_device(dev); if (err) { dev_err(&dev->dev, "failed to enable OHCI hardware\n"); return err; @@ -3605,14 +3605,13 @@ static int pci_probe(struct pci_dev *dev, if (!(pci_resource_flags(dev, 0) & IORESOURCE_MEM) || pci_resource_len(dev, 0) < OHCI1394_REGISTER_SIZE) { ohci_err(ohci, "invalid MMIO resource\n"); - err =3D -ENXIO; - goto fail_disable; + return -ENXIO; } =20 err =3D pci_request_region(dev, 0, ohci_driver_name); if (err) { ohci_err(ohci, "MMIO resource unavailable\n"); - goto fail_disable; + return err; } =20 ohci->registers =3D pci_iomap(dev, 0, OHCI1394_REGISTER_SIZE); @@ -3752,8 +3751,6 @@ static int pci_probe(struct pci_dev *dev, pci_iounmap(dev, ohci->registers); fail_iomem: pci_release_region(dev, 0); - fail_disable: - pci_disable_device(dev); =20 return err; } @@ -3798,7 +3795,6 @@ static void pci_remove(struct pci_dev *dev) pci_disable_msi(dev); pci_iounmap(dev, ohci->registers); pci_release_region(dev, 0); - pci_disable_device(dev); =20 dev_notice(&dev->dev, "removing fw-ohci device\n"); } --=20 2.39.2 From nobody Mon Feb 9 08:50:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51DB9C77B73 for ; Sun, 4 Jun 2023 05:45:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230102AbjFDFpN (ORCPT ); Sun, 4 Jun 2023 01:45:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230009AbjFDFpC (ORCPT ); Sun, 4 Jun 2023 01:45:02 -0400 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2316BE0 for ; Sat, 3 Jun 2023 22:45:01 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 8F8FE5C0110; Sun, 4 Jun 2023 01:45:00 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 04 Jun 2023 01:45:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1685857500; x= 1685943900; bh=Sz66tRqOl7u4PP0rtKdaeKmYwO41z2vXEGUTAqF6eOk=; b=o 89WvoV8bluHsnci8TokM/pj5qc/eiLfisRvUK4fZo2RVGYR42fpiC94IYdfd0gU9 W1cG/Pfs1AFMYof5UTMjmfM23YMNEuv6SuHDoaN6n8cY7kJlVzb6AVgjoLuoz7VB lAJNbOpGnJwqTedt4JEJijVZfq+I1j6QCei4Ft1cpYw1qgzmyeg0e0ncLjijkCom Vrl+BXuaPCdD4SdtZWS5xxU4cGYQqnuqCVJyLqXfLDZ2b303lg6ZErlS+04crCvX aRl2yh86C4GiNSxX+pjsBnyM/wYgRhsoJ28oe7qAHGbLylBEk2i1JfzNIJleiFB+ /ol7Ze39MU9wN7HWemtXA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1685857500; x=1685943900; bh=S z66tRqOl7u4PP0rtKdaeKmYwO41z2vXEGUTAqF6eOk=; b=LmCckfrTic7A+wlL1 Zlq2lEBWP4sNyoGKP2exgaS0E1/MIxFteoSDU9q6gqZd+KaTGt/8A+XLehuSvVRr DK7epqbP4oBeaIBpatYiNeyZZwfWl84THx5gXv+yHalBsHILmcfkpOFzZaLbj9JC 6Wgb2BI6Atss+5EfAxhbDHbc/n8ALZHzaKuFo22mYYC6vR/3B0DsfErI9wB997Mw Q5/GSrM0NSsx6PcGCFHlvfxZyyiWDNtq6EBsIQz8ib7fgNfE5axxyjTBcaEoFJJU cOMTouNJPnzRerNSMSA0NpHNvQs4tx67S+4Yy9YEjUTN3hzgG+ptUz95sLT8oVkI QhD3w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeliedguddtudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeevfefffe ektefgveegfeelheffhfeujedtjeevtefhkeevkedtjeejvddtjefhjeenucevlhhushht vghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 4 Jun 2023 01:44:59 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH 3/9] firewire: ohci: use devres for MMIO region mapping Date: Sun, 4 Jun 2023 14:44:45 +0900 Message-Id: <20230604054451.161076-4-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230604054451.161076-1-o-takashi@sakamocchi.jp> References: <20230604054451.161076-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The PCI framework has the convenient helper function to check and map MMIO region with managed device resource. This commit elaborates 1394 OHCI driver to use the function. Signed-off-by: Takashi Sakamoto --- drivers/firewire/ohci.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index f3d0882a876c..26c64b60144d 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c @@ -3608,18 +3608,12 @@ static int pci_probe(struct pci_dev *dev, return -ENXIO; } =20 - err =3D pci_request_region(dev, 0, ohci_driver_name); + err =3D pcim_iomap_regions(dev, 1 << 0, ohci_driver_name); if (err) { - ohci_err(ohci, "MMIO resource unavailable\n"); - return err; - } - - ohci->registers =3D pci_iomap(dev, 0, OHCI1394_REGISTER_SIZE); - if (ohci->registers =3D=3D NULL) { - ohci_err(ohci, "failed to remap registers\n"); - err =3D -ENXIO; - goto fail_iomem; + ohci_err(ohci, "request and map MMIO resource unavailable\n"); + return -ENXIO; } + ohci->registers =3D pcim_iomap_table(dev)[0]; =20 for (i =3D 0; i < ARRAY_SIZE(ohci_quirks); i++) if ((ohci_quirks[i].vendor =3D=3D dev->vendor) && @@ -3644,10 +3638,8 @@ static int pci_probe(struct pci_dev *dev, PAGE_SIZE, &ohci->misc_buffer_bus, GFP_KERNEL); - if (!ohci->misc_buffer) { - err =3D -ENOMEM; - goto fail_iounmap; - } + if (!ohci->misc_buffer) + return -ENOMEM; =20 err =3D ar_context_init(&ohci->ar_request_ctx, ohci, 0, OHCI1394_AsReqRcvContextControlSet); @@ -3747,10 +3739,6 @@ static int pci_probe(struct pci_dev *dev, fail_misc_buf: dma_free_coherent(ohci->card.device, PAGE_SIZE, ohci->misc_buffer, ohci->misc_buffer_bus); - fail_iounmap: - pci_iounmap(dev, ohci->registers); - fail_iomem: - pci_release_region(dev, 0); =20 return err; } @@ -3793,8 +3781,6 @@ static void pci_remove(struct pci_dev *dev) kfree(ohci->it_context_list); kfree(ohci->ir_context_list); pci_disable_msi(dev); - pci_iounmap(dev, ohci->registers); - pci_release_region(dev, 0); =20 dev_notice(&dev->dev, "removing fw-ohci device\n"); } --=20 2.39.2 From nobody Mon Feb 9 08:50:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8813CC77B73 for ; Sun, 4 Jun 2023 05:45:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230211AbjFDFpP (ORCPT ); Sun, 4 Jun 2023 01:45:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230051AbjFDFpD (ORCPT ); Sun, 4 Jun 2023 01:45:03 -0400 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7172ECE for ; Sat, 3 Jun 2023 22:45:02 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id DE92D5C010D; Sun, 4 Jun 2023 01:45:01 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Sun, 04 Jun 2023 01:45:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1685857501; x= 1685943901; bh=7jRIqu3WK9pbTJJNWXwjuu5GtvOIZ4uZ8MriEr/wEx4=; b=k u1d6ors0EbpVI5FlR5rTVFzpqJu6LMsMdlTg77PoSIDlXFHX5O0ItTui1zv1qmmv J12EqYAdnJ1b2xdfEetGnPPC0P42gASKH5SC15VSKU+32lKQ12qM4ZGpf6rKhdEd q/Vk8wNw/ZUqYakRdksyFRuYU7ZHI+XYBi7R19Vt91urwXDjTGHRIBqJJObtnSF1 MTkIY03DfXgNwH8TXE4ta4mSOau8XlXZqkUpUW7W7M52+OIMOv5Eo0LQKSGo3Y8f uJNqo+8S0pVqvh0kYN7VfuayZ7D/5xJ6JfoVz4Hv4l05QSivyClPpQ/At8nDo/CM lod4F2prGnST55PUlQcHg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1685857501; x=1685943901; bh=7 jRIqu3WK9pbTJJNWXwjuu5GtvOIZ4uZ8MriEr/wEx4=; b=C3qj/yvD+wSne5+Hm E/Kvl8ozuJo+inh35UDu1w0/F8r8JCY/HIoEWkZ4iD6D9AusN3qV0JlxyTIb1/1p lH5TrqTQbuXyFRtFC3haYTctLbgOUwpF2Hijfc2SR4mHCHxu0QacTMU04J0QhIcZ VdoIhCCw+U7mRme8w0Awk2+BopYjIqF82iqymS8t49vUwSsycq+77rTkKoALQe4x hwVd5B1BOgcKMDkmP4Mjy8PSc2oDTEL7h+7oFnPNqsQ1dA/InfhVqEuhrYkvW+i7 UxHCZixBeCTcnEkOdJnjnWtJyPBjOoMUXvAgdyH8XLa1O5trBMr4J2wcGK+OYC7U GFT8A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeliedguddtudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeevfefffe ektefgveegfeelheffhfeujedtjeevtefhkeevkedtjeejvddtjefhjeenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 4 Jun 2023 01:45:00 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH 4/9] firewire: ohci: use devres for misc DMA buffer Date: Sun, 4 Jun 2023 14:44:46 +0900 Message-Id: <20230604054451.161076-5-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230604054451.161076-1-o-takashi@sakamocchi.jp> References: <20230604054451.161076-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The 1394 OHCI driver allocates a DMA coherent buffer for multi-purposes. The buffer is split into three region for specific purposes; i.e. 1/4 for context descriptors of AR request and response as well as 1/2 for self ID handling. This commit uses managed device resource to maintain the lifetime of buffer. Signed-off-by: Takashi Sakamoto --- drivers/firewire/ohci.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index 26c64b60144d..3b31d90781fe 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c @@ -3634,17 +3634,15 @@ static int pci_probe(struct pci_dev *dev, */ BUILD_BUG_ON(AR_BUFFERS * sizeof(struct descriptor) > PAGE_SIZE/4); BUILD_BUG_ON(SELF_ID_BUF_SIZE > PAGE_SIZE/2); - ohci->misc_buffer =3D dma_alloc_coherent(ohci->card.device, - PAGE_SIZE, - &ohci->misc_buffer_bus, - GFP_KERNEL); + ohci->misc_buffer =3D dmam_alloc_coherent(&dev->dev, PAGE_SIZE, &ohci->mi= sc_buffer_bus, + GFP_KERNEL); if (!ohci->misc_buffer) return -ENOMEM; =20 err =3D ar_context_init(&ohci->ar_request_ctx, ohci, 0, OHCI1394_AsReqRcvContextControlSet); if (err < 0) - goto fail_misc_buf; + return err; =20 err =3D ar_context_init(&ohci->ar_response_ctx, ohci, PAGE_SIZE/4, OHCI1394_AsRspRcvContextControlSet); @@ -3736,9 +3734,6 @@ static int pci_probe(struct pci_dev *dev, ar_context_release(&ohci->ar_response_ctx); fail_arreq_ctx: ar_context_release(&ohci->ar_request_ctx); - fail_misc_buf: - dma_free_coherent(ohci->card.device, PAGE_SIZE, - ohci->misc_buffer, ohci->misc_buffer_bus); =20 return err; } @@ -3774,8 +3769,6 @@ static void pci_remove(struct pci_dev *dev) ohci->config_rom, ohci->config_rom_bus); ar_context_release(&ohci->ar_request_ctx); ar_context_release(&ohci->ar_response_ctx); - dma_free_coherent(ohci->card.device, PAGE_SIZE, - ohci->misc_buffer, ohci->misc_buffer_bus); context_release(&ohci->at_request_ctx); context_release(&ohci->at_response_ctx); kfree(ohci->it_context_list); --=20 2.39.2 From nobody Mon Feb 9 08:50:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0CAC4C7EE23 for ; Sun, 4 Jun 2023 05:45:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230212AbjFDFpU (ORCPT ); Sun, 4 Jun 2023 01:45:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230079AbjFDFpE (ORCPT ); Sun, 4 Jun 2023 01:45:04 -0400 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0024CE for ; Sat, 3 Jun 2023 22:45:03 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 2CDF75C010B; Sun, 4 Jun 2023 01:45:03 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sun, 04 Jun 2023 01:45:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1685857503; x= 1685943903; bh=+SNfvwUr3HkWtVX9bEAgYqWbf/gfUOCX+tboiD/Fg6E=; b=U BKnq3yjaySl29OZGcuVREvQa7DIsvzGjsohKjledhFIpHuB+S1t0tmGcbSXr5cuT U0BrjF+Ul6dNeuxKnY1NPpFWcDkOd0mfFt65ZYmcWCnIsg6AAjgnmgesb51knJv4 SXP6lmhR3DlSHSJHNng37Fw8vbS5W57BUjifNR4gTfQtSdbM/dvBYLmoNuNFHYzV XeQ50z6xFcLtUZ9wyqsDzqTdwqMq9jJGBkVpOrc8QteyIE1URHXbZXcbrw+kXye7 ZqS71cW8lEMieirU/yTGTYFR1kaiIU+vVpVbE/UMhEY/DTqAlsFHQ3C7DsORiQnV RM1HsbK7ea9dMSEt3xuQg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1685857503; x=1685943903; bh=+ SNfvwUr3HkWtVX9bEAgYqWbf/gfUOCX+tboiD/Fg6E=; b=LNqi2PjRROO7RKxpJ yHd/hNIAkT+GCDHleqUSADoh+fg7o4h5WP74eC3oDRYG6EKfYBYnKZz3AcP//k+n j/0UdvBVPPHmeh4n/DsW+McNVTukQF02fP5CLtcrWNJS/yC0ek3oYgg1roeK3FYI ScXei7pSOIH3aNPynV5xtJtn+/xyMb0oRp4KYJlagg05VcJnymaeC+5AakUjh5YA Cvd6c2STF1wAOwgAlYz9Tq1NxhIkZAvYn3ymlOEl7HmSUXaJNkWZnONR+zq3N+fC 2Z1u0CaGCD/vh+mK8Qn6AgF4F7vhMUGGcxW3VqYGxu30zKFXMITm5boEgiOpTo8c LtcWQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeliedguddttdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeevfefffe ektefgveegfeelheffhfeujedtjeevtefhkeevkedtjeejvddtjefhjeenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 4 Jun 2023 01:45:02 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH 5/9] firewire: ohci: use devres for requested IRQ Date: Sun, 4 Jun 2023 14:44:47 +0900 Message-Id: <20230604054451.161076-6-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230604054451.161076-1-o-takashi@sakamocchi.jp> References: <20230604054451.161076-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The 1394 OHCI controller register handler to single interrupt number. This commit uses managed device resource to maintain the lifetime of requested IRQ. Signed-off-by: Takashi Sakamoto --- drivers/firewire/ohci.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index 3b31d90781fe..cb6b43e3f67e 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c @@ -3697,17 +3697,16 @@ static int pci_probe(struct pci_dev *dev, =20 if (!(ohci->quirks & QUIRK_NO_MSI)) pci_enable_msi(dev); - if (request_irq(dev->irq, irq_handler, - pci_dev_msi_enabled(dev) ? 0 : IRQF_SHARED, - ohci_driver_name, ohci)) { + err =3D devm_request_irq(&dev->dev, dev->irq, irq_handler, + pci_dev_msi_enabled(dev) ? 0 : IRQF_SHARED, ohci_driver_name, oh= ci); + if (err < 0) { ohci_err(ohci, "failed to allocate interrupt %d\n", dev->irq); - err =3D -EIO; goto fail_msi; } =20 err =3D fw_card_add(&ohci->card, max_receive, link_speed, guid); if (err) - goto fail_irq; + goto fail_msi; =20 version =3D reg_read(ohci, OHCI1394_Version) & 0x00ff00ff; ohci_notice(ohci, @@ -3720,8 +3719,6 @@ static int pci_probe(struct pci_dev *dev, =20 return 0; =20 - fail_irq: - free_irq(dev->irq, ohci); fail_msi: pci_disable_msi(dev); fail_contexts: @@ -3759,7 +3756,6 @@ static void pci_remove(struct pci_dev *dev) */ =20 software_reset(ohci); - free_irq(dev->irq, ohci); =20 if (ohci->next_config_rom && ohci->next_config_rom !=3D ohci->config_rom) dma_free_coherent(ohci->card.device, CONFIG_ROM_SIZE, --=20 2.39.2 From nobody Mon Feb 9 08:50:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92D30C7EE23 for ; Sun, 4 Jun 2023 05:45:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230233AbjFDFpX (ORCPT ); Sun, 4 Jun 2023 01:45:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229462AbjFDFpF (ORCPT ); Sun, 4 Jun 2023 01:45:05 -0400 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0312BDD for ; Sat, 3 Jun 2023 22:45:05 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 71AF85C0107; Sun, 4 Jun 2023 01:45:04 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sun, 04 Jun 2023 01:45:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1685857504; x= 1685943904; bh=yKoKikTVQbdJ/GWKBdSJlh//T8Gm6Qtq4ujUJMHiy0s=; b=b zUI2T4MtRqQFE0xkxyHAewvPaapTG9qww6k+9Ol6Sn+o/uxlk/w6ulvDqKRg5uBm B3otPR2jHuc8bomo6SReGWTP6WFHcSdMDI5E8QlT1QotoHuudMhGTcy3vICmsBwf v3Ymx9SGeFaOlwLQYCRoC+JE/12t6AP5VG5DIo9Zf5p/zGvEcRKSHfL7que0ejVu XG+xVM1ddS/pfMi8wOvIPfDYrpp3NFBWKG+F2jGEuFh4Y0FYIdVWBYrgUf7FwbSG kuUG4UXbClC9shjfq12S5JXUJK+dIw1+oAh7unif7+/nbtA4qOS81Ub/bNQQZNV7 N48iqILJEYkyYgGzY6BdQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1685857504; x=1685943904; bh=y KoKikTVQbdJ/GWKBdSJlh//T8Gm6Qtq4ujUJMHiy0s=; b=KRGhQa+sc+UZutBiz ZqDiBiY0L9tMY+geOqh6qC2uvtTAON/b7rIKWWhbuhAFH7bbRVSGZUsQurhXpvC1 7gFqu2VUH+0DgmFK5YZvEpZ5IfJomr/ewolgJ+wdHXDXuRBvbgqtvkxO28TapksD 3rf9+5ca5ucHWJwLN5SUfoZfLHI4vzaS14FOuU6jowkTe7ty6pQIFFEF5BE+UcFE 80qQ1WMm3213THgxP6jwgngFqP1O4a5VDEwi+yL5er29/xWj3BbdbrlRpkzS5C/F NsvWukJ3d0ZuWIQ1XhBpAmIOQ13kyzojp98wSswm9Kj55ic1s4ceQ1Ku80Ppfi0N FAJwA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeliedguddttdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeevfefffe ektefgveegfeelheffhfeujedtjeevtefhkeevkedtjeejvddtjefhjeenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 4 Jun 2023 01:45:03 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH 6/9] firewire: ohci: use devres for list of isochronous contexts Date: Sun, 4 Jun 2023 14:44:48 +0900 Message-Id: <20230604054451.161076-7-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230604054451.161076-1-o-takashi@sakamocchi.jp> References: <20230604054451.161076-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The 1394 OHCI driver allocates the list of isochronous contexts as much as the hardware supports. This commit utilizes managed device resource to maintain the lifetime of list. Signed-off-by: Takashi Sakamoto --- drivers/firewire/ohci.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index cb6b43e3f67e..086505bd1729 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c @@ -3666,7 +3666,11 @@ static int pci_probe(struct pci_dev *dev, ohci->ir_context_mask =3D ohci->ir_context_support; ohci->n_ir =3D hweight32(ohci->ir_context_mask); size =3D sizeof(struct iso_context) * ohci->n_ir; - ohci->ir_context_list =3D kzalloc(size, GFP_KERNEL); + ohci->ir_context_list =3D devm_kzalloc(&dev->dev, size, GFP_KERNEL); + if (!ohci->ir_context_list) { + err =3D -ENOMEM; + goto fail_atresp_ctx; + } =20 reg_write(ohci, OHCI1394_IsoXmitIntMaskSet, ~0); ohci->it_context_support =3D reg_read(ohci, OHCI1394_IsoXmitIntMaskSet); @@ -3679,11 +3683,10 @@ static int pci_probe(struct pci_dev *dev, ohci->it_context_mask =3D ohci->it_context_support; ohci->n_it =3D hweight32(ohci->it_context_mask); size =3D sizeof(struct iso_context) * ohci->n_it; - ohci->it_context_list =3D kzalloc(size, GFP_KERNEL); - - if (ohci->it_context_list =3D=3D NULL || ohci->ir_context_list =3D=3D NUL= L) { + ohci->it_context_list =3D devm_kzalloc(&dev->dev, size, GFP_KERNEL); + if (!ohci->it_context_list) { err =3D -ENOMEM; - goto fail_contexts; + goto fail_atresp_ctx; } =20 ohci->self_id =3D ohci->misc_buffer + PAGE_SIZE/2; @@ -3721,9 +3724,7 @@ static int pci_probe(struct pci_dev *dev, =20 fail_msi: pci_disable_msi(dev); - fail_contexts: - kfree(ohci->ir_context_list); - kfree(ohci->it_context_list); + fail_atresp_ctx: context_release(&ohci->at_response_ctx); fail_atreq_ctx: context_release(&ohci->at_request_ctx); @@ -3767,8 +3768,6 @@ static void pci_remove(struct pci_dev *dev) ar_context_release(&ohci->ar_response_ctx); context_release(&ohci->at_request_ctx); context_release(&ohci->at_response_ctx); - kfree(ohci->it_context_list); - kfree(ohci->ir_context_list); pci_disable_msi(dev); =20 dev_notice(&dev->dev, "removing fw-ohci device\n"); --=20 2.39.2 From nobody Mon Feb 9 08:50:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E50CAC77B73 for ; Sun, 4 Jun 2023 05:45:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230251AbjFDFp0 (ORCPT ); Sun, 4 Jun 2023 01:45:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230108AbjFDFpH (ORCPT ); Sun, 4 Jun 2023 01:45:07 -0400 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53B9AE1 for ; Sat, 3 Jun 2023 22:45:06 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id BEDDC5C0115; Sun, 4 Jun 2023 01:45:05 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sun, 04 Jun 2023 01:45:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1685857505; x= 1685943905; bh=yKzOsoG8xy2knPDZZ291nFvnf2PQCsND9mtXsk0fr2Y=; b=f uFVAxM25bqj3Ds6KmaGZfcKXCBwT8mpA6dp+saiduhBzHF83rSROBQ8CyfecGOjX S96DDx9wJX6tNHZGzduHeHwr/TmWza+CSKoht6pa3WHwg7SfhCZtvk2C+ZmPqkj2 gm/xs1bgWp8M3xFi6DKhKn1v2SrmijDhaEzSphuZAMXixu/FSN1ctNYZe6srm8dX bvuQYXhSNn4gnGx+LA6NfZEwu21nuxRaEafb6QPox2qQ6ja3g+K+ECRD0wrABVOW cdZ8/735DWgg40ypU5RyNWfQdrlQIV/pIo+JP/0xbN6qkz7QKkWi355LgzyuIdp+ atCnUKuGJT1OEfv35tNaQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1685857505; x=1685943905; bh=y KzOsoG8xy2knPDZZ291nFvnf2PQCsND9mtXsk0fr2Y=; b=wFL0zxvE79MqrhgcR GIol5duV+8ZAfStb6QzsH2XqKvAPr2gRFXPiwzQh1fGowYN4OYNs15j8Q0+UGAWg 5+9DEU6pGoGcwo8RL/3wHhSjJHiEGKItul9/u5EYBByBX2gLX5Wi3ev6NKb6Qiec GiTIxeGGf/0fIzdVknxElNsUC3nuib7O75MO9sS+WuNnPP1AoCmZO4eEXaUPsczk 2/pwUuyGBqrnOyvX3ZnlzWSTM2xA6OjgsAnEscnY6WMbIUC5RzrxI3mZzl/I+F4q AFqMFSqar0zzi8mD5uaSMv5RTCIT5P1UKq3YWzpTRcmrxclXiYJ6xvQaJP+WI/dF +pFtA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeliedguddttdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeevfefffe ektefgveegfeelheffhfeujedtjeevtefhkeevkedtjeejvddtjefhjeenucevlhhushht vghrufhiiigvpedvnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 4 Jun 2023 01:45:04 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH 7/9] firewire: ohci: use devres for IT, IR, AT/receive, and AT/request contexts Date: Sun, 4 Jun 2023 14:44:49 +0900 Message-Id: <20230604054451.161076-8-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230604054451.161076-1-o-takashi@sakamocchi.jp> References: <20230604054451.161076-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The 1394 OHCI driver allocates DMA coherent buffer for descriptors of IT, IR, AT receive, and AT request contexts by the same way. This commit utilizes managed device resource to maintain the lifetime of buffers. Signed-off-by: Takashi Sakamoto --- drivers/firewire/ohci.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index 086505bd1729..21eb13ea4dad 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c @@ -1105,8 +1105,7 @@ static int context_add_buffer(struct context *ctx) if (ctx->total_allocation >=3D 16*1024*1024) return -ENOMEM; =20 - desc =3D dma_alloc_coherent(ctx->ohci->card.device, PAGE_SIZE, - &bus_addr, GFP_ATOMIC); + desc =3D dmam_alloc_coherent(ctx->ohci->card.device, PAGE_SIZE, &bus_addr= , GFP_ATOMIC); if (!desc) return -ENOMEM; =20 @@ -1165,10 +1164,10 @@ static void context_release(struct context *ctx) struct fw_card *card =3D &ctx->ohci->card; struct descriptor_buffer *desc, *tmp; =20 - list_for_each_entry_safe(desc, tmp, &ctx->buffer_list, list) - dma_free_coherent(card->device, PAGE_SIZE, desc, - desc->buffer_bus - - ((void *)&desc->buffer - (void *)desc)); + list_for_each_entry_safe(desc, tmp, &ctx->buffer_list, list) { + dmam_free_coherent(card->device, PAGE_SIZE, desc, + desc->buffer_bus - ((void *)&desc->buffer - (void *)desc)); + } } =20 /* Must be called with ohci->lock held */ @@ -3657,7 +3656,7 @@ static int pci_probe(struct pci_dev *dev, err =3D context_init(&ohci->at_response_ctx, ohci, OHCI1394_AsRspTrContextControlSet, handle_at_packet); if (err < 0) - goto fail_atreq_ctx; + goto fail_arrsp_ctx; =20 reg_write(ohci, OHCI1394_IsoRecvIntMaskSet, ~0); ohci->ir_context_channels =3D ~0ULL; @@ -3669,7 +3668,7 @@ static int pci_probe(struct pci_dev *dev, ohci->ir_context_list =3D devm_kzalloc(&dev->dev, size, GFP_KERNEL); if (!ohci->ir_context_list) { err =3D -ENOMEM; - goto fail_atresp_ctx; + goto fail_arrsp_ctx; } =20 reg_write(ohci, OHCI1394_IsoXmitIntMaskSet, ~0); @@ -3686,7 +3685,7 @@ static int pci_probe(struct pci_dev *dev, ohci->it_context_list =3D devm_kzalloc(&dev->dev, size, GFP_KERNEL); if (!ohci->it_context_list) { err =3D -ENOMEM; - goto fail_atresp_ctx; + goto fail_arrsp_ctx; } =20 ohci->self_id =3D ohci->misc_buffer + PAGE_SIZE/2; @@ -3724,10 +3723,6 @@ static int pci_probe(struct pci_dev *dev, =20 fail_msi: pci_disable_msi(dev); - fail_atresp_ctx: - context_release(&ohci->at_response_ctx); - fail_atreq_ctx: - context_release(&ohci->at_request_ctx); fail_arrsp_ctx: ar_context_release(&ohci->ar_response_ctx); fail_arreq_ctx: @@ -3766,8 +3761,6 @@ static void pci_remove(struct pci_dev *dev) ohci->config_rom, ohci->config_rom_bus); ar_context_release(&ohci->ar_request_ctx); ar_context_release(&ohci->ar_response_ctx); - context_release(&ohci->at_request_ctx); - context_release(&ohci->at_response_ctx); pci_disable_msi(dev); =20 dev_notice(&dev->dev, "removing fw-ohci device\n"); --=20 2.39.2 From nobody Mon Feb 9 08:50:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4BAF1C77B73 for ; Sun, 4 Jun 2023 05:45:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230284AbjFDFpg (ORCPT ); Sun, 4 Jun 2023 01:45:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230134AbjFDFpL (ORCPT ); Sun, 4 Jun 2023 01:45:11 -0400 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDC09FD for ; Sat, 3 Jun 2023 22:45:07 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 180145C011C; Sun, 4 Jun 2023 01:45:07 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 04 Jun 2023 01:45:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1685857507; x= 1685943907; bh=JXJ2NslYvRvgyn5YNav5urVf+K2fXWuI2M0Mevtt7tE=; b=I ScD5GIrWiztYox8MM7twV5QDUCP8m7sHLqt9ppAGB3Iirq9eNw7GtczB5aLwpYiM Ny2xTcx9WU3uFsuK/HpX1xKbxKoNA2RoZjhsw6UqNfJgFQwRYgww3scsz2ci5ZD1 1KwlkD8vcDHo6q0dMsR6eiXSeN2EJaWWPQE9KpVGiALasMYokMWlsw/0HhdVvZ+i d9ZCasfLMwM30UwaYaM8jmuxjzZLasISUON6KC/bSO5pcTvmRXWutf60Fer4eZdq gYAi59KstK54vrMg27bfw61PY8WS5LFvy+L2ghvN1Ux6AgGRinkJS6NVC7rNX6JP VZtAzdOlywrPgIWopjbfQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1685857507; x=1685943907; bh=J XJ2NslYvRvgyn5YNav5urVf+K2fXWuI2M0Mevtt7tE=; b=hswlGVHWgKOEG9WNF 19pfyFY2rDxvHhAf/w2EqJmzdl3EAncc8p0SXXw8mCJu79O24N3EgwTnHjSts1CV VW7E5Uv0BlJR2YOv6wZzbboS941eCdypicIV17KXtxWVj6QuikOhRa+357teFSSy 8OjaCU1TNIQGhEo7lfITARLncXDvqF8Y3yvUTkbojZ3gKbr7INu8EbKYgG1HBnzZ JPww3gnssE3ASb2IWwPpqAULqosKvNqSkqgoXZVg1eFrzd6qsl3Z3MKdF9YLlAQ3 csYg6s+l6zMRZZejRkmnhmEWf7XOdyTt2DvUSTxrlv4iyyv+dW+gb7VdCWyJAYNQ oi5zw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeliedguddtudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeevfefffe ektefgveegfeelheffhfeujedtjeevtefhkeevkedtjeejvddtjefhjeenucevlhhushht vghrufhiiigvpedvnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 4 Jun 2023 01:45:05 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH 8/9] firewire: ohci: use devres for content of configuration ROM Date: Sun, 4 Jun 2023 14:44:50 +0900 Message-Id: <20230604054451.161076-9-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230604054451.161076-1-o-takashi@sakamocchi.jp> References: <20230604054451.161076-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The 1394 OHCI driver allocates DMA coherent buffer to transfer content of configuration ROM. This commit utilizes managed device resource to maintain the lifetime of buffer. Signed-off-by: Takashi Sakamoto --- drivers/firewire/ohci.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index 21eb13ea4dad..298667963538 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c @@ -2052,8 +2052,7 @@ static void bus_reset_work(struct work_struct *work) spin_unlock_irq(&ohci->lock); =20 if (free_rom) - dma_free_coherent(ohci->card.device, CONFIG_ROM_SIZE, - free_rom, free_rom_bus); + dmam_free_coherent(ohci->card.device, CONFIG_ROM_SIZE, free_rom, free_ro= m_bus); =20 log_selfids(ohci, generation, self_id_count); =20 @@ -2385,10 +2384,8 @@ static int ohci_enable(struct fw_card *card, */ =20 if (config_rom) { - ohci->next_config_rom =3D - dma_alloc_coherent(ohci->card.device, CONFIG_ROM_SIZE, - &ohci->next_config_rom_bus, - GFP_KERNEL); + ohci->next_config_rom =3D dmam_alloc_coherent(ohci->card.device, CONFIG_= ROM_SIZE, + &ohci->next_config_rom_bus, GFP_KERNEL); if (ohci->next_config_rom =3D=3D NULL) return -ENOMEM; =20 @@ -2480,9 +2477,8 @@ static int ohci_set_config_rom(struct fw_card *card, * ohci->next_config_rom to NULL (see bus_reset_work). */ =20 - next_config_rom =3D - dma_alloc_coherent(ohci->card.device, CONFIG_ROM_SIZE, - &next_config_rom_bus, GFP_KERNEL); + next_config_rom =3D dmam_alloc_coherent(ohci->card.device, CONFIG_ROM_SIZ= E, + &next_config_rom_bus, GFP_KERNEL); if (next_config_rom =3D=3D NULL) return -ENOMEM; =20 @@ -2515,9 +2511,10 @@ static int ohci_set_config_rom(struct fw_card *card, spin_unlock_irq(&ohci->lock); =20 /* If we didn't use the DMA allocation, delete it. */ - if (next_config_rom !=3D NULL) - dma_free_coherent(ohci->card.device, CONFIG_ROM_SIZE, - next_config_rom, next_config_rom_bus); + if (next_config_rom !=3D NULL) { + dmam_free_coherent(ohci->card.device, CONFIG_ROM_SIZE, next_config_rom, + next_config_rom_bus); + } =20 /* * Now initiate a bus reset to have the changes take @@ -3753,12 +3750,6 @@ static void pci_remove(struct pci_dev *dev) =20 software_reset(ohci); =20 - if (ohci->next_config_rom && ohci->next_config_rom !=3D ohci->config_rom) - dma_free_coherent(ohci->card.device, CONFIG_ROM_SIZE, - ohci->next_config_rom, ohci->next_config_rom_bus); - if (ohci->config_rom) - dma_free_coherent(ohci->card.device, CONFIG_ROM_SIZE, - ohci->config_rom, ohci->config_rom_bus); ar_context_release(&ohci->ar_request_ctx); ar_context_release(&ohci->ar_response_ctx); pci_disable_msi(dev); --=20 2.39.2 From nobody Mon Feb 9 08:50:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9A44C7EE23 for ; Sun, 4 Jun 2023 05:45:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230258AbjFDFp3 (ORCPT ); Sun, 4 Jun 2023 01:45:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230097AbjFDFpM (ORCPT ); Sun, 4 Jun 2023 01:45:12 -0400 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05724E3 for ; Sat, 3 Jun 2023 22:45:09 -0700 (PDT) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 68DCE5C0111; Sun, 4 Jun 2023 01:45:08 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Sun, 04 Jun 2023 01:45:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1685857508; x= 1685943908; bh=8Dgw6YabWHeE3yFvx/mYzF63i5Jthx10ANgrdir9jFg=; b=c 8VkNef3khD1nmcuYxU0YMDaeIkjKmM6/dQ1C78y+R1DdGXEVzX6duY9f9yy65bA3 QOUsLgIYTFRK6BeZHtsaGnbIfMrbuj2MTtnYD581VSqcMqWhbWi987VHOObzcj0X HAFs0yNmqKS+PyjNUrFVRImSH7YijYlkhjQxiVfAJdQAIfak+fgTPOld9HvQRslS DrhMip0HfOkbDDxT0yph/t1khcHD1T54Ig/FgB6bEacwYruzxtwg4p7Sm3r/KdlK qHOJVKNf2/f3UeJGcPIwbPre+PowOUphnziy/uP7DUWSKRZrCPYrrIMUrHn7F48P mD9vL4W1riC3oXA1/+qVA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1685857508; x=1685943908; bh=8 Dgw6YabWHeE3yFvx/mYzF63i5Jthx10ANgrdir9jFg=; b=rUWG8i8nOUhPylllv 5T9v78GAfyD+Pt8BFDUwCMaTvVnwD9GghX03WFuysDoa69Ql1KHd7Ogpk18kyWvj az0EUW3TFPzfT9rmS6aFuTmdutWE/nheL9jrAgSkG2ovt9A2X/GGf2bh7Hqr5eVB 7rbm2ogery0tw1DAmmJo1YIl7kFLue2+lq3eNVl0kCvUkX+5JEQvBHHw0dZ3batz BpROmzHieiaSq8v+TX3tgu5WX1qNPGEScG3qOlbgeyG6pIV7ccIbg4C98fBK+1A1 vmkGtFxR4KbTtS1W6jAwTu7ki7yte6te9w8GE6OuaLAu9qhcuIvxcxLQcPAuhQmp qrOcg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeliedguddttdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeevfefffe ektefgveegfeelheffhfeujedtjeevtefhkeevkedtjeejvddtjefhjeenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 4 Jun 2023 01:45:07 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH 9/9] firewire: ohci: release buffer for AR req/resp contexts when managed resource is released Date: Sun, 4 Jun 2023 14:44:51 +0900 Message-Id: <20230604054451.161076-10-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230604054451.161076-1-o-takashi@sakamocchi.jp> References: <20230604054451.161076-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The 1394 OHCI driver allocates several non-coherent DMA buffers for AR request and response contexts. The buffers are mapped to kernel virtual address (VMA) so that the first page locates after the last page. Even when large payload of packet is handled crossing the boundary of buffers, the driver operates continuously on VMA. No kernel API is provided for this kind of mapping, while it is possible to release the buffer when PCI device is going to be released. This commit moves the call of release helper function to the callback function of release resources. Signed-off-by: Takashi Sakamoto --- drivers/firewire/ohci.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index 298667963538..7e88fd489741 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c @@ -677,6 +677,9 @@ static void ar_context_release(struct ar_context *ctx) struct device *dev =3D ctx->ohci->card.device; unsigned int i; =20 + if (!ctx->buffer) + return; + vunmap(ctx->buffer); =20 for (i =3D 0; i < AR_BUFFERS; i++) { @@ -3556,9 +3559,13 @@ static inline void pmac_ohci_off(struct pci_dev *dev= ) {} static void release_ohci(struct device *dev, void *data) { struct pci_dev *pdev =3D to_pci_dev(dev); + struct fw_ohci *ohci =3D pci_get_drvdata(pdev); =20 pmac_ohci_off(pdev); =20 + ar_context_release(&ohci->ar_response_ctx); + ar_context_release(&ohci->ar_request_ctx); + dev_notice(dev, "removed fw-ohci device\n"); } =20 @@ -3643,17 +3650,17 @@ static int pci_probe(struct pci_dev *dev, err =3D ar_context_init(&ohci->ar_response_ctx, ohci, PAGE_SIZE/4, OHCI1394_AsRspRcvContextControlSet); if (err < 0) - goto fail_arreq_ctx; + return err; =20 err =3D context_init(&ohci->at_request_ctx, ohci, OHCI1394_AsReqTrContextControlSet, handle_at_packet); if (err < 0) - goto fail_arrsp_ctx; + return err; =20 err =3D context_init(&ohci->at_response_ctx, ohci, OHCI1394_AsRspTrContextControlSet, handle_at_packet); if (err < 0) - goto fail_arrsp_ctx; + return err; =20 reg_write(ohci, OHCI1394_IsoRecvIntMaskSet, ~0); ohci->ir_context_channels =3D ~0ULL; @@ -3663,10 +3670,8 @@ static int pci_probe(struct pci_dev *dev, ohci->n_ir =3D hweight32(ohci->ir_context_mask); size =3D sizeof(struct iso_context) * ohci->n_ir; ohci->ir_context_list =3D devm_kzalloc(&dev->dev, size, GFP_KERNEL); - if (!ohci->ir_context_list) { - err =3D -ENOMEM; - goto fail_arrsp_ctx; - } + if (!ohci->ir_context_list) + return -ENOMEM; =20 reg_write(ohci, OHCI1394_IsoXmitIntMaskSet, ~0); ohci->it_context_support =3D reg_read(ohci, OHCI1394_IsoXmitIntMaskSet); @@ -3680,10 +3685,8 @@ static int pci_probe(struct pci_dev *dev, ohci->n_it =3D hweight32(ohci->it_context_mask); size =3D sizeof(struct iso_context) * ohci->n_it; ohci->it_context_list =3D devm_kzalloc(&dev->dev, size, GFP_KERNEL); - if (!ohci->it_context_list) { - err =3D -ENOMEM; - goto fail_arrsp_ctx; - } + if (!ohci->it_context_list) + return -ENOMEM; =20 ohci->self_id =3D ohci->misc_buffer + PAGE_SIZE/2; ohci->self_id_bus =3D ohci->misc_buffer_bus + PAGE_SIZE/2; @@ -3720,10 +3723,6 @@ static int pci_probe(struct pci_dev *dev, =20 fail_msi: pci_disable_msi(dev); - fail_arrsp_ctx: - ar_context_release(&ohci->ar_response_ctx); - fail_arreq_ctx: - ar_context_release(&ohci->ar_request_ctx); =20 return err; } @@ -3750,8 +3749,6 @@ static void pci_remove(struct pci_dev *dev) =20 software_reset(ohci); =20 - ar_context_release(&ohci->ar_request_ctx); - ar_context_release(&ohci->ar_response_ctx); pci_disable_msi(dev); =20 dev_notice(&dev->dev, "removing fw-ohci device\n"); --=20 2.39.2