* Re: [PATCH v3 0/5] powerpc: apm82181: adding customer devices
From: Andy Shevchenko @ 2021-07-23 19:19 UTC (permalink / raw)
To: Christian Lamparter
Cc: devicetree, Chris Blake, Rob Herring, Paul Mackerras,
linuxppc-dev
In-Reply-To: <cover.1599343429.git.chunkeey@gmail.com>
On Sun, Sep 06, 2020 at 12:06:10AM +0200, Christian Lamparter wrote:
> Hello,
>
> I've been holding on to these devices dts' for a while now.
> But ever since the recent purge of the PPC405, I'm feeling
> the urge to move forward.
>
> The devices in question have been running with OpenWrt since
> around 2016/2017. Back then it was linux v4.4 and required
> many out-of-tree patches (for WIFI, SATA, CRYPTO...), that
> since have been integrated. So, there's nothing else in the
> way I think.
>
> A patch that adds the Meraki vendor-prefix has been sent
> separately, as there's also the Meraki MR32 that I'm working
> on as well. Here's the link to the patch:
> <https://lore.kernel.org/linuxppc-dev/20200822154045.16036-1-chunkeey@gmail.com/>
>
> Now, I've looked around in the arch/powerpc for recent .dts
> and device submissions to get an understanding of what is
> required.
> >From the looks of it, it seems like every device gets a
> skeleton defconfig and a CONFIG_$DEVICE symbol (Like:
> CONFIG_MERAKI_MR24, CONFIG_WD_MYBOOKLIVE).
>
> Will this be the case? Or would it make sense to further
> unite the Bluestone, MR24 and MBL under a common CONFIG_APM82181
> and integrate the BLUESTONE device's defconfig into it as well?
> (I've stumbled across the special machine compatible
> handling of ppc in the Documentation/devicetree/usage-model.rst
> already.)
I haven't found any traces of this to be applied. What is the status of this
patch series? And what is the general state of affairs for the PPC44x?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply
* [Bug 213837] New: "Kernel panic - not syncing: corrupted stack end detected inside scheduler" at building via distcc on a G5
From: bugzilla-daemon @ 2021-07-23 20:00 UTC (permalink / raw)
To: linuxppc-dev
https://bugzilla.kernel.org/show_bug.cgi?id=213837
Bug ID: 213837
Summary: "Kernel panic - not syncing: corrupted stack end
detected inside scheduler" at building via distcc on a
G5
Product: Memory Management
Version: 2.5
Kernel Version: 5.13.4
Hardware: All
OS: Linux
Tree: Mainline
Status: NEW
Severity: normal
Priority: P1
Component: Other
Assignee: akpm@linux-foundation.org
Reporter: erhard_f@mailbox.org
CC: platform_ppc-64@kernel-bugs.osdl.org
Regression: No
Created attachment 298017
--> https://bugzilla.kernel.org/attachment.cgi?id=298017&action=edit
dmesg (5.13.4, PowerMac G5 11,2)
Happens when building larger projects on my G5 via distcc. Time to failure is
about 3-10 minutes. Kernel 5.10.x does not show this problem. Probably
connected to bug #213079.
[..]
Call Trace:
Kernel panic - not syncing: corrupted stack end detected inside scheduler
CPU: 1 PID: 11467 Comm: powerpc64-unkno Tainted: G W
5.13.4-PowerMacG5+ #2
[c00000003e79ea80] [c000000000541c90] .dump_stack+0xe0/0x13c (unreliable)
[c00000003e79eb20] [c00000000006813c] .panic+0x168/0x430
[c00000003e79ebd0] [c00000000080a4b0] .__schedule+0x80/0x840
[c00000003e79ecb0] [c00000000080adbc] .preempt_schedule_common+0x28/0x48
[c00000003e79ed30] [c00000000080ae0c] .__cond_resched+0x30/0x4c
[c00000003e79edb0] [c0000000001c6d80] .mempool_alloc+0x38/0x198
[c00000003e79ee90] [c00000000049a444] .bio_alloc_bioset+0x94/0x174
[c00000003e79ef40] [c00000000049a544] .bio_clone_fast+0x20/0x7c
[c00000003e79efd0] [c00000000049a60c] .bio_split+0x6c/0xc4
[c00000003e79f060] [c0000000004a7018] .__blk_queue_split+0x120/0x474
[c00000003e79f160] [c0000000004adc30] .blk_mq_submit_bio+0x88/0x524
[c00000003e79f250] [c0000000004a0e30] .submit_bio_noacct+0xc4/0x26c
[c00000003e79f340] [c000000000355bec] .ext4_io_submit+0x5c/0x70
[c00000003e79f3c0] [c000000000355f08] .ext4_bio_write_page+0x2f4/0x480
[c00000003e79f480] [c000000000334b84] .mpage_submit_page+0x70/0xa0
[c00000003e79f500] [c00000000033b09c] .ext4_writepages+0xcc4/0xe5c
[c00000003e79f7b0] [c0000000001cf214] .do_writepages+0x54/0xa0
[c00000003e79f830] [c0000000001c3ab8] .__filemap_fdatawrite_range+0xc0/0xfc
[c00000003e79f930] [c000000000337f34] .ext4_alloc_da_blocks+0xf4/0x100
[c00000003e79f9b0] [c000000000328594] .ext4_release_file+0x24/0xd8
[c00000003e79fa40] [c00000000026ea5c] .__fput+0x12c/0x270
[c00000003e79fae0] [c00000000008eb40] .task_work_run+0xa0/0xc0
[c00000003e79fb70] [c00000000006e284] .do_exit+0x55c/0xa6c
[c00000003e79fc60] [c00000000006e824] .do_group_exit+0x50/0xb0
[c00000003e79fcf0] [c00000000006e898] .__wake_up_parent+0x0/0x34
[c00000003e79fd60] [c000000000021540] .system_call_exception+0x1b4/0x1ec
[c00000003e79fe10] [c00000000000b9c4] system_call_common+0xe4/0x214
--- interrupt: c00 at 0x3fffadc46aa8
NIP: 00003fffadc46aa8 LR: 00003fffadba6d04 CTR: 0000000000000000
REGS: c00000003e79fe80 TRAP: 0c00 Tainted: G W
(5.13.4-PowerMacG5+)
MSR: 900000000200f032 <SF,HV,VEC,EE,PR,FP,ME,IR,DR,RI> CR: 22000482 XER:
00000000
IRQMASK: 0
GPR00: 00000000000000ea 00003ffff3f1ae50 00003fffadd65300 0000000000000000
GPR04: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR08: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR12: 0000000000000000 00003fffadeddc30 000000014af075a0 000000012379b0f0
GPR16: 000000012947ec38 00003fffd7d95cd8 000000012947eb28 000000000000002f
GPR20: 0000000000000000 00003fffadd5fff8 0000000000000001 00003fffadd5ea58
GPR24: 0000000000000000 0000000000000000 0000000000000003 0000000000000001
GPR28: 0000000000000000 00003fffaded6c50 fffffffffffff000 0000000000000000
NIP [00003fffadc46aa8] 0x3fffadc46aa8
LR [00003fffadba6d04] 0x3fffadba6d04
--- interrupt: c00
Rebooting in 40 seconds..
--
You may reply to this email to add a comment.
You are receiving this mail because:
You are watching someone on the CC list of the bug.
^ permalink raw reply
* [Bug 213837] "Kernel panic - not syncing: corrupted stack end detected inside scheduler" at building via distcc on a G5
From: bugzilla-daemon @ 2021-07-23 20:01 UTC (permalink / raw)
To: linuxppc-dev
In-Reply-To: <bug-213837-206035@https.bugzilla.kernel.org/>
https://bugzilla.kernel.org/show_bug.cgi?id=213837
--- Comment #1 from Erhard F. (erhard_f@mailbox.org) ---
Created attachment 298019
--> https://bugzilla.kernel.org/attachment.cgi?id=298019&action=edit
kernel .config (5.13.4, PowerMac G5 11,2)
--
You may reply to this email to add a comment.
You are receiving this mail because:
You are watching someone on the CC list of the bug.
^ permalink raw reply
* [PATCH v4 05/10] net/ps3_gelic: Add vlan_id structure
From: Geoff Levand @ 2021-07-23 20:31 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski; +Cc: netdev, linuxppc-dev
In-Reply-To: <cover.1627068552.git.geoff@infradead.org>
In an effort to make the PS3 gelic driver easier to maintain, add
a definition for the vlan_id structure.
Signed-off-by: Geoff Levand <geoff@infradead.org>
---
drivers/net/ethernet/toshiba/ps3_gelic_net.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_net.c b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
index 946e9bfa071b..54e50ad9e629 100644
--- a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
+++ b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
@@ -1614,13 +1614,14 @@ static struct gelic_card *gelic_alloc_card_net(struct net_device **netdev)
static void gelic_card_get_vlan_info(struct gelic_card *card)
{
struct device *dev = ctodev(card);
+ unsigned int i;
u64 v1, v2;
int status;
- unsigned int i;
- struct {
+ struct vlan_id {
int tx;
int rx;
- } vlan_id_ix[2] = {
+ };
+ struct vlan_id vlan_id_ix[2] = {
[GELIC_PORT_ETHERNET_0] = {
.tx = GELIC_LV1_VLAN_TX_ETHERNET_0,
.rx = GELIC_LV1_VLAN_RX_ETHERNET_0
--
2.25.1
^ permalink raw reply related
* [PATCH v4 06/10] net/ps3_gelic: Cleanup debug code
From: Geoff Levand @ 2021-07-23 20:31 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski; +Cc: netdev, linuxppc-dev
In-Reply-To: <cover.1627068552.git.geoff@infradead.org>
In an effort to make the PS3 gelic driver easier to maintain, change the
gelic_card_enable_rxdmac routine to use the optimizer to remove
debug code.
Signed-off-by: Geoff Levand <geoff@infradead.org>
---
drivers/net/ethernet/toshiba/ps3_gelic_net.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_net.c b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
index 54e50ad9e629..85fc1915c8be 100644
--- a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
+++ b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
@@ -162,17 +162,16 @@ static void gelic_card_enable_rxdmac(struct gelic_card *card)
struct device *dev = ctodev(card);
int status;
-#ifdef DEBUG
- if (gelic_descr_get_status(card->rx_chain.head) !=
- GELIC_DESCR_DMA_CARDOWNED) {
- printk(KERN_ERR "%s: status=%x\n", __func__,
- be32_to_cpu(card->rx_chain.head->dmac_cmd_status));
- printk(KERN_ERR "%s: nextphy=%x\n", __func__,
- be32_to_cpu(card->rx_chain.head->hw_regs.next_descr_addr));
- printk(KERN_ERR "%s: head=%p\n", __func__,
- card->rx_chain.head);
+ if (__is_defined(DEBUG) && (gelic_descr_get_status(card->rx_chain.head)
+ != GELIC_DESCR_DMA_CARDOWNED)) {
+ dev_err(dev, "%s:%d: status=%x\n", __func__, __LINE__,
+ be32_to_cpu(card->rx_chain.head->hw_regs.dmac_cmd_status));
+ dev_err(dev, "%s:%d: nextphy=%x\n", __func__, __LINE__,
+ be32_to_cpu(card->rx_chain.head->hw_regs.next_descr_addr));
+ dev_err(dev, "%s:%d: head=%px\n", __func__, __LINE__,
+ card->rx_chain.head);
}
-#endif
+
status = lv1_net_start_rx_dma(bus_id(card), dev_id(card),
card->rx_chain.head->link.cpu_addr, 0);
--
2.25.1
^ permalink raw reply related
* [PATCH v4 00/10] DMA fixes for PS3 gelic network driver
From: Geoff Levand @ 2021-07-23 20:31 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski; +Cc: netdev, linuxppc-dev
Hi Dave, Jakub,
This set of patches fixes various DMA related problems in the PS3 gelic
network driver and adds better error checking and improved message logging.
Please consider.
Changes from v3:
Rebase to latest net-next.
Split 2 patches into 10 patches.
Fix checkpatch error.
Changes from v2:
Rebase to latest net-next.
Changes from v1:
Split the v1 series into two, one series with powerpc changes, and one series
with gelic network driver changes.
-Geoff
The following changes since commit 94a994d2b2b74420c6fff5100220c2b636317242:
net: phy: Remove unused including <linux/version.h> (2021-07-23 17:54:53 +0100)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/geoff/ps3-linux.git for-merge-dma-net-v4
for you to fetch changes up to 7aa1d9b1b4ffadcbdc6f88e4f8d4a323da307595:
net/ps3_gelic: Fix DMA mapping problems (2021-07-24 13:02:14 -0700)
----------------------------------------------------------------
Geoff Levand (10):
net/ps3_gelic: Add gelic_descr structures
net/ps3_gelic: Use local dev variable
net/ps3_gelic: Format cleanups
net/ps3_gelic: Add new macro BUG_ON_DEBUG
net/ps3_gelic: Add vlan_id structure
net/ps3_gelic: Cleanup debug code
net/ps3_gelic: Add new routine gelic_unmap_link
net/ps3_gelic: Rename no to descr_count
net/ps3_gelic: Add new routine gelic_work_to_card
net/ps3_gelic: Fix DMA mapping problems
drivers/net/ethernet/toshiba/ps3_gelic_net.c | 983 +++++++++++++++------------
drivers/net/ethernet/toshiba/ps3_gelic_net.h | 24 +-
2 files changed, 559 insertions(+), 448 deletions(-)
--
2.25.1
^ permalink raw reply
* [PATCH v4 04/10] net/ps3_gelic: Add new macro BUG_ON_DEBUG
From: Geoff Levand @ 2021-07-23 20:31 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski; +Cc: netdev, linuxppc-dev
In-Reply-To: <cover.1627068552.git.geoff@infradead.org>
Add a new preprocessor macro BUG_ON_DEBUG, that expands to BUG_ON when
the preprocessor macro DEBUG is defined, or to WARN_ON when DEBUG is not
defined. Also, replace all occurrences of BUG_ON with BUG_ON_DEBUG.
Signed-off-by: Geoff Levand <geoff@infradead.org>
---
drivers/net/ethernet/toshiba/ps3_gelic_net.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_net.c b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
index ded467d81f36..946e9bfa071b 100644
--- a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
+++ b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
@@ -44,6 +44,13 @@ MODULE_AUTHOR("SCE Inc.");
MODULE_DESCRIPTION("Gelic Network driver");
MODULE_LICENSE("GPL");
+#define BUG_ON_DEBUG(_cond) do { \
+ if (__is_defined(DEBUG)) \
+ BUG_ON(_cond); \
+ else \
+ WARN_ON(_cond); \
+} while (0)
+
int gelic_card_set_irq_mask(struct gelic_card *card, u64 mask)
{
struct device *dev = ctodev(card);
@@ -505,7 +512,7 @@ static void gelic_descr_release_tx(struct gelic_card *card,
struct sk_buff *skb = descr->skb;
struct device *dev = ctodev(card);
- BUG_ON(!(be32_to_cpu(descr->hw_regs.data_status) &
+ BUG_ON_DEBUG(!(be32_to_cpu(descr->hw_regs.data_status) &
GELIC_DESCR_TX_TAIL));
dma_unmap_single(dev, be32_to_cpu(descr->hw_regs.payload.dev_addr),
@@ -1667,7 +1674,7 @@ static void gelic_card_get_vlan_info(struct gelic_card *card)
}
if (card->vlan[GELIC_PORT_ETHERNET_0].tx) {
- BUG_ON(!card->vlan[GELIC_PORT_WIRELESS].tx);
+ BUG_ON_DEBUG(!card->vlan[GELIC_PORT_WIRELESS].tx);
card->vlan_required = 1;
} else
card->vlan_required = 0;
@@ -1709,7 +1716,7 @@ static int ps3_gelic_driver_probe(struct ps3_system_bus_device *sb_dev)
if (result) {
dev_err(dev, "%s:%d: ps3_dma_region_create failed: %d\n",
__func__, __LINE__, result);
- BUG_ON("check region type");
+ BUG_ON_DEBUG("check region type");
goto fail_dma_region;
}
--
2.25.1
^ permalink raw reply related
* [PATCH v4 01/10] net/ps3_gelic: Add gelic_descr structures
From: Geoff Levand @ 2021-07-23 20:31 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski; +Cc: netdev, linuxppc-dev
In-Reply-To: <cover.1627068552.git.geoff@infradead.org>
In an effort to make the PS3 gelic driver easier to maintain, create two
new structures, struct gelic_hw_regs and struct gelic_chain_link, and
replace the corresponding members of struct gelic_descr with the new
structures.
struct gelic_hw_regs holds the register variables used by the gelic
hardware device. struct gelic_chain_link holds variables used to manage
the driver's linked list of gelic descr structures.
Signed-off-by: Geoff Levand <geoff@infradead.org>
---
drivers/net/ethernet/toshiba/ps3_gelic_net.c | 133 ++++++++++---------
drivers/net/ethernet/toshiba/ps3_gelic_net.h | 24 ++--
2 files changed, 82 insertions(+), 75 deletions(-)
diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_net.c b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
index 55e652624bd7..cb45571573d7 100644
--- a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
+++ b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
@@ -98,7 +98,7 @@ static void gelic_card_get_ether_port_status(struct gelic_card *card,
static enum gelic_descr_dma_status
gelic_descr_get_status(struct gelic_descr *descr)
{
- return be32_to_cpu(descr->dmac_cmd_status) & GELIC_DESCR_DMA_STAT_MASK;
+ return be32_to_cpu(descr->hw_regs.dmac_cmd_status) & GELIC_DESCR_DMA_STAT_MASK;
}
static int gelic_card_set_link_mode(struct gelic_card *card, int mode)
@@ -154,13 +154,13 @@ static void gelic_card_enable_rxdmac(struct gelic_card *card)
printk(KERN_ERR "%s: status=%x\n", __func__,
be32_to_cpu(card->rx_chain.head->dmac_cmd_status));
printk(KERN_ERR "%s: nextphy=%x\n", __func__,
- be32_to_cpu(card->rx_chain.head->next_descr_addr));
+ be32_to_cpu(card->rx_chain.head->hw_regs.next_descr_addr));
printk(KERN_ERR "%s: head=%p\n", __func__,
card->rx_chain.head);
}
#endif
status = lv1_net_start_rx_dma(bus_id(card), dev_id(card),
- card->rx_chain.head->bus_addr, 0);
+ card->rx_chain.head->link.cpu_addr, 0);
if (status)
dev_info(ctodev(card),
"lv1_net_start_rx_dma failed, status=%d\n", status);
@@ -195,8 +195,8 @@ static void gelic_card_disable_rxdmac(struct gelic_card *card)
static void gelic_descr_set_status(struct gelic_descr *descr,
enum gelic_descr_dma_status status)
{
- descr->dmac_cmd_status = cpu_to_be32(status |
- (be32_to_cpu(descr->dmac_cmd_status) &
+ descr->hw_regs.dmac_cmd_status = cpu_to_be32(status |
+ (be32_to_cpu(descr->hw_regs.dmac_cmd_status) &
~GELIC_DESCR_DMA_STAT_MASK));
/*
* dma_cmd_status field is used to indicate whether the descriptor
@@ -224,13 +224,13 @@ static void gelic_card_reset_chain(struct gelic_card *card,
for (descr = start_descr; start_descr != descr->next; descr++) {
gelic_descr_set_status(descr, GELIC_DESCR_DMA_CARDOWNED);
- descr->next_descr_addr = cpu_to_be32(descr->next->bus_addr);
+ descr->hw_regs.next_descr_addr = cpu_to_be32(descr->next->link.cpu_addr);
}
chain->head = start_descr;
chain->tail = (descr - 1);
- (descr - 1)->next_descr_addr = 0;
+ (descr - 1)->hw_regs.next_descr_addr = 0;
}
void gelic_card_up(struct gelic_card *card)
@@ -286,10 +286,10 @@ static void gelic_card_free_chain(struct gelic_card *card,
{
struct gelic_descr *descr;
- for (descr = descr_in; descr && descr->bus_addr; descr = descr->next) {
- dma_unmap_single(ctodev(card), descr->bus_addr,
- GELIC_DESCR_SIZE, DMA_BIDIRECTIONAL);
- descr->bus_addr = 0;
+ for (descr = descr_in; descr && descr->link.cpu_addr; descr = descr->next) {
+ dma_unmap_single(ctodev(card), descr->link.cpu_addr,
+ descr->link.size, DMA_BIDIRECTIONAL);
+ descr->link.cpu_addr = 0;
}
}
@@ -317,13 +317,14 @@ static int gelic_card_init_chain(struct gelic_card *card,
/* set up the hardware pointers in each descriptor */
for (i = 0; i < no; i++, descr++) {
+ descr->link.size = sizeof(struct gelic_hw_regs);
gelic_descr_set_status(descr, GELIC_DESCR_DMA_NOT_IN_USE);
- descr->bus_addr =
+ descr->link.cpu_addr =
dma_map_single(ctodev(card), descr,
- GELIC_DESCR_SIZE,
+ descr->link.size,
DMA_BIDIRECTIONAL);
- if (!descr->bus_addr)
+ if (!descr->link.cpu_addr)
goto iommu_error;
descr->next = descr + 1;
@@ -336,22 +337,22 @@ static int gelic_card_init_chain(struct gelic_card *card,
/* chain bus addr of hw descriptor */
descr = start_descr;
for (i = 0; i < no; i++, descr++) {
- descr->next_descr_addr = cpu_to_be32(descr->next->bus_addr);
+ descr->hw_regs.next_descr_addr = cpu_to_be32(descr->next->link.cpu_addr);
}
chain->head = start_descr;
chain->tail = start_descr;
/* do not chain last hw descriptor */
- (descr - 1)->next_descr_addr = 0;
+ (descr - 1)->hw_regs.next_descr_addr = 0;
return 0;
iommu_error:
for (i--, descr--; 0 <= i; i--, descr--)
- if (descr->bus_addr)
- dma_unmap_single(ctodev(card), descr->bus_addr,
- GELIC_DESCR_SIZE,
+ if (descr->link.cpu_addr)
+ dma_unmap_single(ctodev(card), descr->link.cpu_addr,
+ descr->link.size,
DMA_BIDIRECTIONAL);
return -ENOMEM;
}
@@ -381,25 +382,25 @@ static int gelic_descr_prepare_rx(struct gelic_card *card,
* bit more */
descr->skb = dev_alloc_skb(bufsize + GELIC_NET_RXBUF_ALIGN - 1);
if (!descr->skb) {
- descr->buf_addr = 0; /* tell DMAC don't touch memory */
+ descr->hw_regs.payload.dev_addr = 0; /* tell DMAC don't touch memory */
return -ENOMEM;
}
- descr->buf_size = cpu_to_be32(bufsize);
- descr->dmac_cmd_status = 0;
- descr->result_size = 0;
- descr->valid_size = 0;
- descr->data_error = 0;
+ descr->hw_regs.payload.size = cpu_to_be32(bufsize);
+ descr->hw_regs.dmac_cmd_status = 0;
+ descr->hw_regs.result_size = 0;
+ descr->hw_regs.valid_size = 0;
+ descr->hw_regs.data_error = 0;
offset = ((unsigned long)descr->skb->data) &
(GELIC_NET_RXBUF_ALIGN - 1);
if (offset)
skb_reserve(descr->skb, GELIC_NET_RXBUF_ALIGN - offset);
/* io-mmu-map the skb */
- descr->buf_addr = cpu_to_be32(dma_map_single(ctodev(card),
+ descr->hw_regs.payload.dev_addr = cpu_to_be32(dma_map_single(ctodev(card),
descr->skb->data,
GELIC_NET_MAX_MTU,
DMA_FROM_DEVICE));
- if (!descr->buf_addr) {
+ if (!descr->hw_regs.payload.dev_addr) {
dev_kfree_skb_any(descr->skb);
descr->skb = NULL;
dev_info(ctodev(card),
@@ -424,10 +425,10 @@ static void gelic_card_release_rx_chain(struct gelic_card *card)
do {
if (descr->skb) {
dma_unmap_single(ctodev(card),
- be32_to_cpu(descr->buf_addr),
+ be32_to_cpu(descr->hw_regs.payload.dev_addr),
descr->skb->len,
DMA_FROM_DEVICE);
- descr->buf_addr = 0;
+ descr->hw_regs.payload.dev_addr = 0;
dev_kfree_skb_any(descr->skb);
descr->skb = NULL;
gelic_descr_set_status(descr,
@@ -493,19 +494,19 @@ static void gelic_descr_release_tx(struct gelic_card *card,
{
struct sk_buff *skb = descr->skb;
- BUG_ON(!(be32_to_cpu(descr->data_status) & GELIC_DESCR_TX_TAIL));
+ BUG_ON(!(be32_to_cpu(descr->hw_regs.data_status) & GELIC_DESCR_TX_TAIL));
- dma_unmap_single(ctodev(card), be32_to_cpu(descr->buf_addr), skb->len,
+ dma_unmap_single(ctodev(card), be32_to_cpu(descr->hw_regs.payload.dev_addr), skb->len,
DMA_TO_DEVICE);
dev_kfree_skb_any(skb);
- descr->buf_addr = 0;
- descr->buf_size = 0;
- descr->next_descr_addr = 0;
- descr->result_size = 0;
- descr->valid_size = 0;
- descr->data_status = 0;
- descr->data_error = 0;
+ descr->hw_regs.payload.dev_addr = 0;
+ descr->hw_regs.payload.size = 0;
+ descr->hw_regs.next_descr_addr = 0;
+ descr->hw_regs.result_size = 0;
+ descr->hw_regs.valid_size = 0;
+ descr->hw_regs.data_status = 0;
+ descr->hw_regs.data_error = 0;
descr->skb = NULL;
/* set descr status */
@@ -698,7 +699,7 @@ static void gelic_descr_set_tx_cmdstat(struct gelic_descr *descr,
struct sk_buff *skb)
{
if (skb->ip_summed != CHECKSUM_PARTIAL)
- descr->dmac_cmd_status =
+ descr->hw_regs.dmac_cmd_status =
cpu_to_be32(GELIC_DESCR_DMA_CMD_NO_CHKSUM |
GELIC_DESCR_TX_DMA_FRAME_TAIL);
else {
@@ -706,19 +707,19 @@ static void gelic_descr_set_tx_cmdstat(struct gelic_descr *descr,
* if yes: tcp? udp? */
if (skb->protocol == htons(ETH_P_IP)) {
if (ip_hdr(skb)->protocol == IPPROTO_TCP)
- descr->dmac_cmd_status =
+ descr->hw_regs.dmac_cmd_status =
cpu_to_be32(GELIC_DESCR_DMA_CMD_TCP_CHKSUM |
GELIC_DESCR_TX_DMA_FRAME_TAIL);
else if (ip_hdr(skb)->protocol == IPPROTO_UDP)
- descr->dmac_cmd_status =
+ descr->hw_regs.dmac_cmd_status =
cpu_to_be32(GELIC_DESCR_DMA_CMD_UDP_CHKSUM |
GELIC_DESCR_TX_DMA_FRAME_TAIL);
else /*
* the stack should checksum non-tcp and non-udp
* packets on his own: NETIF_F_IP_CSUM
*/
- descr->dmac_cmd_status =
+ descr->hw_regs.dmac_cmd_status =
cpu_to_be32(GELIC_DESCR_DMA_CMD_NO_CHKSUM |
GELIC_DESCR_TX_DMA_FRAME_TAIL);
}
@@ -763,7 +764,7 @@ static int gelic_descr_prepare_tx(struct gelic_card *card,
struct gelic_descr *descr,
struct sk_buff *skb)
{
- dma_addr_t buf;
+ dma_addr_t cpu_addr;
if (card->vlan_required) {
struct sk_buff *skb_tmp;
@@ -777,20 +778,20 @@ static int gelic_descr_prepare_tx(struct gelic_card *card,
skb = skb_tmp;
}
- buf = dma_map_single(ctodev(card), skb->data, skb->len, DMA_TO_DEVICE);
+ cpu_addr = dma_map_single(ctodev(card), skb->data, skb->len, DMA_TO_DEVICE);
- if (!buf) {
+ if (!cpu_addr) {
dev_err(ctodev(card),
"dma map 2 failed (%p, %i). Dropping packet\n",
skb->data, skb->len);
return -ENOMEM;
}
- descr->buf_addr = cpu_to_be32(buf);
- descr->buf_size = cpu_to_be32(skb->len);
+ descr->hw_regs.payload.dev_addr = cpu_to_be32(cpu_addr);
+ descr->hw_regs.payload.size = cpu_to_be32(skb->len);
descr->skb = skb;
- descr->data_status = 0;
- descr->next_descr_addr = 0; /* terminate hw descr */
+ descr->hw_regs.data_status = 0;
+ descr->hw_regs.next_descr_addr = 0; /* terminate hw descr */
gelic_descr_set_tx_cmdstat(descr, skb);
/* bump free descriptor pointer */
@@ -815,7 +816,7 @@ static int gelic_card_kick_txdma(struct gelic_card *card,
if (gelic_descr_get_status(descr) == GELIC_DESCR_DMA_CARDOWNED) {
card->tx_dma_progress = 1;
status = lv1_net_start_tx_dma(bus_id(card), dev_id(card),
- descr->bus_addr, 0);
+ descr->link.cpu_addr, 0);
if (status) {
card->tx_dma_progress = 0;
dev_info(ctodev(card), "lv1_net_start_txdma failed," \
@@ -868,7 +869,7 @@ netdev_tx_t gelic_net_xmit(struct sk_buff *skb, struct net_device *netdev)
* link this prepared descriptor to previous one
* to achieve high performance
*/
- descr->prev->next_descr_addr = cpu_to_be32(descr->bus_addr);
+ descr->prev->hw_regs.next_descr_addr = cpu_to_be32(descr->link.cpu_addr);
/*
* as hardware descriptor is modified in the above lines,
* ensure that the hardware sees it
@@ -881,12 +882,12 @@ netdev_tx_t gelic_net_xmit(struct sk_buff *skb, struct net_device *netdev)
*/
netdev->stats.tx_dropped++;
/* don't trigger BUG_ON() in gelic_descr_release_tx */
- descr->data_status = cpu_to_be32(GELIC_DESCR_TX_TAIL);
+ descr->hw_regs.data_status = cpu_to_be32(GELIC_DESCR_TX_TAIL);
gelic_descr_release_tx(card, descr);
/* reset head */
card->tx_chain.head = descr;
/* reset hw termination */
- descr->prev->next_descr_addr = 0;
+ descr->prev->hw_regs.next_descr_addr = 0;
dev_info(ctodev(card), "%s: kick failure\n", __func__);
}
@@ -911,21 +912,21 @@ static void gelic_net_pass_skb_up(struct gelic_descr *descr,
struct sk_buff *skb = descr->skb;
u32 data_status, data_error;
- data_status = be32_to_cpu(descr->data_status);
- data_error = be32_to_cpu(descr->data_error);
+ data_status = be32_to_cpu(descr->hw_regs.data_status);
+ data_error = be32_to_cpu(descr->hw_regs.data_error);
/* unmap skb buffer */
- dma_unmap_single(ctodev(card), be32_to_cpu(descr->buf_addr),
+ dma_unmap_single(ctodev(card), be32_to_cpu(descr->hw_regs.payload.dev_addr),
GELIC_NET_MAX_MTU,
DMA_FROM_DEVICE);
- skb_put(skb, be32_to_cpu(descr->valid_size)?
- be32_to_cpu(descr->valid_size) :
- be32_to_cpu(descr->result_size));
- if (!descr->valid_size)
+ skb_put(skb, be32_to_cpu(descr->hw_regs.valid_size)?
+ be32_to_cpu(descr->hw_regs.valid_size) :
+ be32_to_cpu(descr->hw_regs.result_size));
+ if (!descr->hw_regs.valid_size)
dev_info(ctodev(card), "buffer full %x %x %x\n",
- be32_to_cpu(descr->result_size),
- be32_to_cpu(descr->buf_size),
- be32_to_cpu(descr->dmac_cmd_status));
+ be32_to_cpu(descr->hw_regs.result_size),
+ be32_to_cpu(descr->hw_regs.payload.size),
+ be32_to_cpu(descr->hw_regs.dmac_cmd_status));
descr->skb = NULL;
/*
@@ -1036,14 +1037,14 @@ static int gelic_card_decode_one_descr(struct gelic_card *card)
/* is the current descriptor terminated with next_descr == NULL? */
dmac_chain_ended =
- be32_to_cpu(descr->dmac_cmd_status) &
+ be32_to_cpu(descr->hw_regs.dmac_cmd_status) &
GELIC_DESCR_RX_DMA_CHAIN_END;
/*
* So that always DMAC can see the end
* of the descriptor chain to avoid
* from unwanted DMAC overrun.
*/
- descr->next_descr_addr = 0;
+ descr->hw_regs.next_descr_addr = 0;
/* change the descriptor state: */
gelic_descr_set_status(descr, GELIC_DESCR_DMA_NOT_IN_USE);
@@ -1060,7 +1061,7 @@ static int gelic_card_decode_one_descr(struct gelic_card *card)
/*
* Set this descriptor the end of the chain.
*/
- descr->prev->next_descr_addr = cpu_to_be32(descr->bus_addr);
+ descr->prev->hw_regs.next_descr_addr = cpu_to_be32(descr->link.cpu_addr);
/*
* If dmac chain was met, DMAC stopped.
diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_net.h b/drivers/net/ethernet/toshiba/ps3_gelic_net.h
index 68f324ed4eaf..569f691021d9 100644
--- a/drivers/net/ethernet/toshiba/ps3_gelic_net.h
+++ b/drivers/net/ethernet/toshiba/ps3_gelic_net.h
@@ -220,29 +220,35 @@ enum gelic_lv1_phy {
GELIC_LV1_PHY_ETHERNET_0 = 0x0000000000000002L,
};
-/* size of hardware part of gelic descriptor */
-#define GELIC_DESCR_SIZE (32)
-
enum gelic_port_type {
GELIC_PORT_ETHERNET_0 = 0,
GELIC_PORT_WIRELESS = 1,
GELIC_PORT_MAX
};
-struct gelic_descr {
- /* as defined by the hardware */
- __be32 buf_addr;
- __be32 buf_size;
+/* as defined by the hardware */
+struct gelic_hw_regs {
+ struct {
+ __be32 dev_addr;
+ __be32 size;
+ } __packed payload;
__be32 next_descr_addr;
__be32 dmac_cmd_status;
__be32 result_size;
__be32 valid_size; /* all zeroes for tx */
__be32 data_status;
__be32 data_error; /* all zeroes for tx */
+} __packed;
- /* used in the driver */
+struct gelic_chain_link {
+ dma_addr_t cpu_addr;
+ unsigned int size;
+};
+
+struct gelic_descr {
+ struct gelic_hw_regs hw_regs;
+ struct gelic_chain_link link;
struct sk_buff *skb;
- dma_addr_t bus_addr;
struct gelic_descr *next;
struct gelic_descr *prev;
} __attribute__((aligned(32)));
--
2.25.1
^ permalink raw reply related
* [PATCH v4 10/10] net/ps3_gelic: Fix DMA mapping problems
From: Geoff Levand @ 2021-07-23 20:31 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski; +Cc: netdev, linuxppc-dev
In-Reply-To: <cover.1627068552.git.geoff@infradead.org>
Fixes several DMA mapping problems with the PS3's gelic network driver:
* Change from checking the return value of dma_map_single to using the
dma_mapping_error routine.
* Use the correct buffer length when mapping the RX skb.
* Improved error checking and debug logging.
Fixes runtime errors like these, and also other randomly occurring errors:
IP-Config: Complete:
DMA-API: ps3_gelic_driver sb_05: device driver failed to check map error
WARNING: CPU: 0 PID: 0 at kernel/dma/debug.c:1027 .check_unmap+0x888/0x8dc
Signed-off-by: Geoff Levand <geoff@infradead.org>
---
drivers/net/ethernet/toshiba/ps3_gelic_net.c | 183 +++++++++++--------
1 file changed, 108 insertions(+), 75 deletions(-)
diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_net.c b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
index 42f4de9ad5fe..11ddeacb1159 100644
--- a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
+++ b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
@@ -336,22 +336,31 @@ static int gelic_card_init_chain(struct gelic_card *card,
struct gelic_descr_chain *chain, struct gelic_descr *start_descr,
int descr_count)
{
- int i;
- struct gelic_descr *descr;
+ struct gelic_descr *descr = start_descr;
struct device *dev = ctodev(card);
+ unsigned int index;
- descr = start_descr;
- memset(descr, 0, sizeof(*descr) *descr_count);
+ memset(start_descr, 0, descr_count * sizeof(*start_descr));
- for (i = 0; i < descr_count; i++, descr++) {
- descr->link.size = sizeof(struct gelic_hw_regs);
+ for (index = 0, descr = start_descr; index < descr_count;
+ index++, descr++) {
gelic_descr_set_status(descr, GELIC_DESCR_DMA_NOT_IN_USE);
- descr->link.cpu_addr =
- dma_map_single(dev, descr, descr->link.size,
- DMA_BIDIRECTIONAL);
- if (!descr->link.cpu_addr)
- goto iommu_error;
+ descr->link.size = sizeof(struct gelic_hw_regs);
+ descr->link.cpu_addr = dma_map_single(dev, descr,
+ descr->link.size, DMA_BIDIRECTIONAL);
+
+ if (unlikely(dma_mapping_error(dev, descr->link.cpu_addr))) {
+ dev_err(dev, "%s:%d: dma_mapping_error\n", __func__,
+ __LINE__);
+
+ for (index--, descr--; index > 0; index--, descr--) {
+ if (descr->link.cpu_addr) {
+ gelic_unmap_link(dev, descr);
+ }
+ }
+ return -ENOMEM;
+ }
descr->next = descr + 1;
descr->prev = descr - 1;
@@ -360,8 +369,9 @@ static int gelic_card_init_chain(struct gelic_card *card,
(descr - 1)->next = start_descr;
start_descr->prev = (descr - 1);
- descr = start_descr;
- for (i = 0; i < descr_count; i++, descr++) {
+ /* chain bus addr of hw descriptor */
+ for (index = 0, descr = start_descr; index < descr_count;
+ index++, descr++) {
descr->hw_regs.next_descr_addr =
cpu_to_be32(descr->next->link.cpu_addr);
}
@@ -373,12 +383,6 @@ static int gelic_card_init_chain(struct gelic_card *card,
(descr - 1)->hw_regs.next_descr_addr = 0;
return 0;
-
-iommu_error:
- for (i--, descr--; 0 <= i; i--, descr--)
- if (descr->link.cpu_addr)
- gelic_unmap_link(dev, descr);
- return -ENOMEM;
}
/**
@@ -395,49 +399,63 @@ static int gelic_descr_prepare_rx(struct gelic_card *card,
struct gelic_descr *descr)
{
struct device *dev = ctodev(card);
- int offset;
- unsigned int bufsize;
+ struct aligned_buff {
+ unsigned int total_bytes;
+ unsigned int offset;
+ };
+ struct aligned_buff a_buf;
+ dma_addr_t cpu_addr;
if (gelic_descr_get_status(descr) != GELIC_DESCR_DMA_NOT_IN_USE) {
dev_err(dev, "%s:%d: ERROR status\n", __func__, __LINE__);
}
- /* we need to round up the buffer size to a multiple of 128 */
- bufsize = ALIGN(GELIC_NET_MAX_MTU, GELIC_NET_RXBUF_ALIGN);
+ a_buf.total_bytes = ALIGN(GELIC_NET_MAX_MTU, GELIC_NET_RXBUF_ALIGN)
+ + GELIC_NET_RXBUF_ALIGN;
+
+ descr->skb = dev_alloc_skb(a_buf.total_bytes);
- /* and we need to have it 128 byte aligned, therefore we allocate a
- * bit more */
- descr->skb = dev_alloc_skb(bufsize + GELIC_NET_RXBUF_ALIGN - 1);
if (!descr->skb) {
- descr->hw_regs.payload.dev_addr = 0; /* tell DMAC don't touch memory */
+ descr->hw_regs.payload.dev_addr = 0;
+ descr->hw_regs.payload.size = 0;
return -ENOMEM;
}
- descr->hw_regs.payload.size = cpu_to_be32(bufsize);
+
+ a_buf.offset = PTR_ALIGN(descr->skb->data, GELIC_NET_RXBUF_ALIGN)
+ - descr->skb->data;
+
+ if (a_buf.offset) {
+ dev_dbg(dev, "%s:%d: offset=%u\n", __func__, __LINE__,
+ a_buf.offset);
+ skb_reserve(descr->skb, a_buf.offset);
+ }
+
descr->hw_regs.dmac_cmd_status = 0;
descr->hw_regs.result_size = 0;
descr->hw_regs.valid_size = 0;
descr->hw_regs.data_error = 0;
- offset = ((unsigned long)descr->skb->data) &
- (GELIC_NET_RXBUF_ALIGN - 1);
- if (offset)
- skb_reserve(descr->skb, GELIC_NET_RXBUF_ALIGN - offset);
- /* io-mmu-map the skb */
- descr->hw_regs.payload.dev_addr = cpu_to_be32(dma_map_single(dev,
- descr->skb->data,
- GELIC_NET_MAX_MTU,
- DMA_FROM_DEVICE));
- if (!descr->hw_regs.payload.dev_addr) {
+ descr->hw_regs.payload.size = a_buf.total_bytes - a_buf.offset;
+ cpu_addr = dma_map_single(dev, descr->skb->data,
+ descr->hw_regs.payload.size, DMA_FROM_DEVICE);
+ descr->hw_regs.payload.dev_addr = cpu_to_be32(cpu_addr);
+
+ if (unlikely(dma_mapping_error(dev, cpu_addr))) {
+ dev_err(dev, "%s:%d: dma_mapping_error\n", __func__, __LINE__);
+
+ descr->hw_regs.payload.dev_addr = 0;
+ descr->hw_regs.payload.size = 0;
+
dev_kfree_skb_any(descr->skb);
descr->skb = NULL;
- dev_info(dev,
- "%s:Could not iommu-map rx buffer\n", __func__);
+
gelic_descr_set_status(descr, GELIC_DESCR_DMA_NOT_IN_USE);
+
return -ENOMEM;
- } else {
- gelic_descr_set_status(descr, GELIC_DESCR_DMA_CARDOWNED);
- return 0;
}
+
+ gelic_descr_set_status(descr, GELIC_DESCR_DMA_CARDOWNED);
+ return 0;
}
/**
@@ -454,13 +472,18 @@ static void gelic_card_release_rx_chain(struct gelic_card *card)
if (descr->skb) {
dma_unmap_single(dev,
be32_to_cpu(descr->hw_regs.payload.dev_addr),
- descr->skb->len, DMA_FROM_DEVICE);
- descr->hw_regs.payload.dev_addr = 0;
+ descr->hw_regs.payload.size, DMA_FROM_DEVICE);
+
dev_kfree_skb_any(descr->skb);
descr->skb = NULL;
+
gelic_descr_set_status(descr,
GELIC_DESCR_DMA_NOT_IN_USE);
}
+
+ descr->hw_regs.payload.dev_addr = 0;
+ descr->hw_regs.payload.size = 0;
+
descr = descr->next;
} while (descr != card->rx_chain.head);
}
@@ -526,17 +549,19 @@ static void gelic_descr_release_tx(struct gelic_card *card,
GELIC_DESCR_TX_TAIL));
dma_unmap_single(dev, be32_to_cpu(descr->hw_regs.payload.dev_addr),
- skb->len, DMA_TO_DEVICE);
- dev_kfree_skb_any(skb);
+ descr->hw_regs.payload.size, DMA_TO_DEVICE);
descr->hw_regs.payload.dev_addr = 0;
descr->hw_regs.payload.size = 0;
+
+ dev_kfree_skb_any(skb);
+ descr->skb = NULL;
+
descr->hw_regs.next_descr_addr = 0;
descr->hw_regs.result_size = 0;
descr->hw_regs.valid_size = 0;
descr->hw_regs.data_status = 0;
descr->hw_regs.data_error = 0;
- descr->skb = NULL;
gelic_descr_set_status(descr, GELIC_DESCR_DMA_NOT_IN_USE);
}
@@ -565,31 +590,34 @@ static void gelic_card_wake_queues(struct gelic_card *card)
static void gelic_card_release_tx_chain(struct gelic_card *card, int stop)
{
struct gelic_descr_chain *tx_chain;
- enum gelic_descr_dma_status status;
struct device *dev = ctodev(card);
- struct net_device *netdev;
- int release = 0;
+ int release;
+
+ for (release = 0, tx_chain = &card->tx_chain;
+ tx_chain->head != tx_chain->tail && tx_chain->tail;
+ tx_chain->tail = tx_chain->tail->next) {
+ enum gelic_descr_dma_status status;
+ struct gelic_descr *descr;
+ struct net_device *netdev;
+
+ descr = tx_chain->tail;
+ status = gelic_descr_get_status(descr);
+ netdev = descr->skb->dev;
- for (tx_chain = &card->tx_chain;
- tx_chain->head != tx_chain->tail && tx_chain->tail;
- tx_chain->tail = tx_chain->tail->next) {
- status = gelic_descr_get_status(tx_chain->tail);
- netdev = tx_chain->tail->skb->dev;
switch (status) {
case GELIC_DESCR_DMA_RESPONSE_ERROR:
case GELIC_DESCR_DMA_PROTECTION_ERROR:
case GELIC_DESCR_DMA_FORCE_END:
- dev_info_ratelimited(dev,
- "%s:%d: forcing end of tx descriptor with status %x\n",
- __func__, __LINE__, status);
+ dev_info_ratelimited(dev,
+ "%s:%d: forcing end of tx descriptor with status %x\n",
+ __func__, __LINE__, status);
netdev->stats.tx_dropped++;
break;
case GELIC_DESCR_DMA_COMPLETE:
- if (tx_chain->tail->skb) {
+ if (descr->skb) {
netdev->stats.tx_packets++;
- netdev->stats.tx_bytes +=
- tx_chain->tail->skb->len;
+ netdev->stats.tx_bytes += descr->skb->len;
}
break;
@@ -599,7 +627,7 @@ static void gelic_card_release_tx_chain(struct gelic_card *card, int stop)
}
}
- gelic_descr_release_tx(card, tx_chain->tail);
+ gelic_descr_release_tx(card, descr);
release++;
}
out:
@@ -703,19 +731,19 @@ int gelic_net_stop(struct net_device *netdev)
*
* returns the address of the next descriptor, or NULL if not available.
*/
-static struct gelic_descr *
-gelic_card_get_next_tx_descr(struct gelic_card *card)
+static struct gelic_descr *gelic_card_get_next_tx_descr(struct gelic_card *card)
{
if (!card->tx_chain.head)
return NULL;
+
/* see if the next descriptor is free */
if (card->tx_chain.tail != card->tx_chain.head->next &&
- gelic_descr_get_status(card->tx_chain.head) ==
- GELIC_DESCR_DMA_NOT_IN_USE)
+ (gelic_descr_get_status(card->tx_chain.head) ==
+ GELIC_DESCR_DMA_NOT_IN_USE)) {
return card->tx_chain.head;
- else
- return NULL;
+ }
+ return NULL;
}
/**
@@ -809,18 +837,23 @@ static int gelic_descr_prepare_tx(struct gelic_card *card,
if (!skb_tmp) {
return -ENOMEM;
}
+
skb = skb_tmp;
}
- cpu_addr = dma_map_single(dev, skb->data, skb->len, DMA_TO_DEVICE);
+ descr->hw_regs.payload.size = skb->len;
+ cpu_addr = dma_map_single(dev, skb->data, descr->hw_regs.payload.size,
+ DMA_TO_DEVICE);
+ descr->hw_regs.payload.dev_addr = cpu_to_be32(cpu_addr);
- if (!cpu_addr) {
+ if (unlikely(dma_mapping_error(dev, cpu_addr))) {
dev_err(dev, "%s:%d: dma_mapping_error\n", __func__, __LINE__);
+
+ descr->hw_regs.payload.dev_addr = 0;
+ descr->hw_regs.payload.size = 0;
return -ENOMEM;
}
- descr->hw_regs.payload.dev_addr = cpu_to_be32(cpu_addr);
- descr->hw_regs.payload.size = cpu_to_be32(skb->len);
descr->skb = skb;
descr->hw_regs.data_status = 0;
descr->hw_regs.next_descr_addr = 0; /* terminate hw descr */
@@ -948,9 +981,9 @@ static void gelic_net_pass_skb_up(struct gelic_descr *descr,
data_status = be32_to_cpu(descr->hw_regs.data_status);
data_error = be32_to_cpu(descr->hw_regs.data_error);
- /* unmap skb buffer */
+
dma_unmap_single(dev, be32_to_cpu(descr->hw_regs.payload.dev_addr),
- GELIC_NET_MAX_MTU, DMA_FROM_DEVICE);
+ descr->hw_regs.payload.size, DMA_FROM_DEVICE);
skb_put(skb, be32_to_cpu(descr->hw_regs.valid_size) ?
be32_to_cpu(descr->hw_regs.valid_size) :
--
2.25.1
^ permalink raw reply related
* [PATCH v4 03/10] net/ps3_gelic: Format cleanups
From: Geoff Levand @ 2021-07-23 20:31 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski; +Cc: netdev, linuxppc-dev
In-Reply-To: <cover.1627068552.git.geoff@infradead.org>
In an effort to make the PS3 gelic driver easier to maintain, cleanup the
the driver source file formatting to be more consistent.
Signed-off-by: Geoff Levand <geoff@infradead.org>
---
drivers/net/ethernet/toshiba/ps3_gelic_net.c | 379 ++++++++++---------
1 file changed, 193 insertions(+), 186 deletions(-)
diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_net.c b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
index ba008a98928a..ded467d81f36 100644
--- a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
+++ b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
@@ -44,8 +44,6 @@ MODULE_AUTHOR("SCE Inc.");
MODULE_DESCRIPTION("Gelic Network driver");
MODULE_LICENSE("GPL");
-
-/* set irq_mask */
int gelic_card_set_irq_mask(struct gelic_card *card, u64 mask)
{
struct device *dev = ctodev(card);
@@ -65,6 +63,7 @@ static void gelic_card_rx_irq_on(struct gelic_card *card)
card->irq_mask |= GELIC_CARD_RXINT;
gelic_card_set_irq_mask(card, card->irq_mask);
}
+
static void gelic_card_rx_irq_off(struct gelic_card *card)
{
card->irq_mask &= ~GELIC_CARD_RXINT;
@@ -72,15 +71,14 @@ static void gelic_card_rx_irq_off(struct gelic_card *card)
}
static void gelic_card_get_ether_port_status(struct gelic_card *card,
- int inform)
+ int inform)
{
u64 v2;
struct net_device *ether_netdev;
lv1_net_control(bus_id(card), dev_id(card),
- GELIC_LV1_GET_ETH_PORT_STATUS,
- GELIC_LV1_VLAN_TX_ETHERNET_0, 0, 0,
- &card->ether_port_status, &v2);
+ GELIC_LV1_GET_ETH_PORT_STATUS, GELIC_LV1_VLAN_TX_ETHERNET_0, 0,
+ 0, &card->ether_port_status, &v2);
if (inform) {
ether_netdev = card->netdev[GELIC_PORT_ETHERNET_0];
@@ -100,7 +98,8 @@ static void gelic_card_get_ether_port_status(struct gelic_card *card,
static enum gelic_descr_dma_status
gelic_descr_get_status(struct gelic_descr *descr)
{
- return be32_to_cpu(descr->hw_regs.dmac_cmd_status) & GELIC_DESCR_DMA_STAT_MASK;
+ return be32_to_cpu(descr->hw_regs.dmac_cmd_status) &
+ GELIC_DESCR_DMA_STAT_MASK;
}
static int gelic_card_set_link_mode(struct gelic_card *card, int mode)
@@ -110,8 +109,9 @@ static int gelic_card_set_link_mode(struct gelic_card *card, int mode)
u64 v1, v2;
status = lv1_net_control(bus_id(card), dev_id(card),
- GELIC_LV1_SET_NEGOTIATION_MODE,
- GELIC_LV1_PHY_ETHERNET_0, mode, 0, &v1, &v2);
+ GELIC_LV1_SET_NEGOTIATION_MODE, GELIC_LV1_PHY_ETHERNET_0, mode,
+ 0, &v1, &v2);
+
if (status) {
dev_err(dev, "%s:%d: Failed setting negotiation mode: %d\n",
__func__, __LINE__, status);
@@ -138,7 +138,8 @@ static void gelic_card_disable_txdmac(struct gelic_card *card)
status = lv1_net_stop_tx_dma(bus_id(card), dev_id(card));
if (status) {
- dev_err(dev, "lv1_net_stop_tx_dma failed, status=%d\n", status);
+ dev_err(dev, "%s:%d: lv1_net_stop_tx_dma failed: %d\n",
+ __func__, __LINE__, status);
}
}
@@ -166,10 +167,11 @@ static void gelic_card_enable_rxdmac(struct gelic_card *card)
}
#endif
status = lv1_net_start_rx_dma(bus_id(card), dev_id(card),
- card->rx_chain.head->link.cpu_addr, 0);
+ card->rx_chain.head->link.cpu_addr, 0);
+
if (status) {
- dev_err(dev, "lv1_net_start_rx_dma failed, status=%d\n",
- status);
+ dev_err(dev, "%s:%d: lv1_net_start_rx_dma failed: %d\n",
+ __func__, __LINE__, status);
}
}
@@ -189,7 +191,8 @@ static void gelic_card_disable_rxdmac(struct gelic_card *card)
status = lv1_net_stop_rx_dma(bus_id(card), dev_id(card));
if (status) {
- dev_err(dev, "lv1_net_stop_rx_dma failed, %d\n", status);
+ dev_err(dev, "%s:%d: lv1_net_stop_rx_dma failed: %d\n",
+ __func__, __LINE__, status);
}
}
@@ -202,11 +205,11 @@ static void gelic_card_disable_rxdmac(struct gelic_card *card)
* in the status
*/
static void gelic_descr_set_status(struct gelic_descr *descr,
- enum gelic_descr_dma_status status)
+ enum gelic_descr_dma_status status)
{
descr->hw_regs.dmac_cmd_status = cpu_to_be32(status |
- (be32_to_cpu(descr->hw_regs.dmac_cmd_status) &
- ~GELIC_DESCR_DMA_STAT_MASK));
+ (be32_to_cpu(descr->hw_regs.dmac_cmd_status) &
+ ~GELIC_DESCR_DMA_STAT_MASK));
/*
* dma_cmd_status field is used to indicate whether the descriptor
* is valid or not.
@@ -226,14 +229,14 @@ static void gelic_descr_set_status(struct gelic_descr *descr,
* and re-initialize the hardware chain for later use
*/
static void gelic_card_reset_chain(struct gelic_card *card,
- struct gelic_descr_chain *chain,
- struct gelic_descr *start_descr)
+ struct gelic_descr_chain *chain, struct gelic_descr *start_descr)
{
struct gelic_descr *descr;
for (descr = start_descr; start_descr != descr->next; descr++) {
gelic_descr_set_status(descr, GELIC_DESCR_DMA_CARDOWNED);
- descr->hw_regs.next_descr_addr = cpu_to_be32(descr->next->link.cpu_addr);
+ descr->hw_regs.next_descr_addr =
+ cpu_to_be32(descr->next->link.cpu_addr);
}
chain->head = start_descr;
@@ -249,11 +252,8 @@ void gelic_card_up(struct gelic_card *card)
mutex_lock(&card->updown_lock);
if (atomic_inc_return(&card->users) == 1) {
dev_dbg(dev, "%s:%d: Starting...\n", __func__, __LINE__);
- /* enable irq */
gelic_card_set_irq_mask(card, card->irq_mask);
- /* start rx */
gelic_card_enable_rxdmac(card);
-
napi_enable(&card->napi);
}
mutex_unlock(&card->updown_lock);
@@ -269,17 +269,14 @@ void gelic_card_down(struct gelic_card *card)
dev_dbg(dev, "%s:%d: Stopping...\n", __func__, __LINE__);
napi_disable(&card->napi);
/*
- * Disable irq. Wireless interrupts will
- * be disabled later if any
+ * Disable irq. Wireless interrupts will be disabled later.
*/
mask = card->irq_mask & (GELIC_CARD_WLAN_EVENT_RECEIVED |
- GELIC_CARD_WLAN_COMMAND_COMPLETED);
+ GELIC_CARD_WLAN_COMMAND_COMPLETED);
gelic_card_set_irq_mask(card, mask);
- /* stop rx */
gelic_card_disable_rxdmac(card);
gelic_card_reset_chain(card, &card->rx_chain,
- card->descr + GELIC_NET_TX_DESCRIPTORS);
- /* stop tx */
+ card->descr + GELIC_NET_TX_DESCRIPTORS);
gelic_card_disable_txdmac(card);
}
mutex_unlock(&card->updown_lock);
@@ -291,12 +288,13 @@ void gelic_card_down(struct gelic_card *card)
* @descr_in: address of desc
*/
static void gelic_card_free_chain(struct gelic_card *card,
- struct gelic_descr *descr_in)
+ struct gelic_descr *descr_in)
{
struct device *dev = ctodev(card);
struct gelic_descr *descr;
- for (descr = descr_in; descr && descr->link.cpu_addr; descr = descr->next) {
+ for (descr = descr_in; descr && descr->link.cpu_addr;
+ descr = descr->next) {
dma_unmap_single(dev, descr->link.cpu_addr, descr->link.size,
DMA_BIDIRECTIONAL);
descr->link.cpu_addr = 0;
@@ -316,8 +314,8 @@ static void gelic_card_free_chain(struct gelic_card *card,
* returns 0 on success, <0 on failure
*/
static int gelic_card_init_chain(struct gelic_card *card,
- struct gelic_descr_chain *chain,
- struct gelic_descr *start_descr, int no)
+ struct gelic_descr_chain *chain, struct gelic_descr *start_descr,
+ int no)
{
int i;
struct gelic_descr *descr;
@@ -326,7 +324,6 @@ static int gelic_card_init_chain(struct gelic_card *card,
descr = start_descr;
memset(descr, 0, sizeof(*descr) * no);
- /* set up the hardware pointers in each descriptor */
for (i = 0; i < no; i++, descr++) {
descr->link.size = sizeof(struct gelic_hw_regs);
gelic_descr_set_status(descr, GELIC_DESCR_DMA_NOT_IN_USE);
@@ -340,14 +337,14 @@ static int gelic_card_init_chain(struct gelic_card *card,
descr->next = descr + 1;
descr->prev = descr - 1;
}
- /* make them as ring */
+
(descr - 1)->next = start_descr;
start_descr->prev = (descr - 1);
- /* chain bus addr of hw descriptor */
descr = start_descr;
for (i = 0; i < no; i++, descr++) {
- descr->hw_regs.next_descr_addr = cpu_to_be32(descr->next->link.cpu_addr);
+ descr->hw_regs.next_descr_addr =
+ cpu_to_be32(descr->next->link.cpu_addr);
}
chain->head = start_descr;
@@ -378,7 +375,7 @@ static int gelic_card_init_chain(struct gelic_card *card,
* Activate the descriptor state-wise
*/
static int gelic_descr_prepare_rx(struct gelic_card *card,
- struct gelic_descr *descr)
+ struct gelic_descr *descr)
{
struct device *dev = ctodev(card);
int offset;
@@ -439,14 +436,13 @@ static void gelic_card_release_rx_chain(struct gelic_card *card)
do {
if (descr->skb) {
dma_unmap_single(dev,
- be32_to_cpu(descr->hw_regs.payload.dev_addr),
- descr->skb->len,
- DMA_FROM_DEVICE);
+ be32_to_cpu(descr->hw_regs.payload.dev_addr),
+ descr->skb->len, DMA_FROM_DEVICE);
descr->hw_regs.payload.dev_addr = 0;
dev_kfree_skb_any(descr->skb);
descr->skb = NULL;
gelic_descr_set_status(descr,
- GELIC_DESCR_DMA_NOT_IN_USE);
+ GELIC_DESCR_DMA_NOT_IN_USE);
}
descr = descr->next;
} while (descr != card->rx_chain.head);
@@ -504,15 +500,16 @@ static int gelic_card_alloc_rx_skbs(struct gelic_card *card)
* releases a used tx descriptor (unmapping, freeing of skb)
*/
static void gelic_descr_release_tx(struct gelic_card *card,
- struct gelic_descr *descr)
+ struct gelic_descr *descr)
{
struct sk_buff *skb = descr->skb;
struct device *dev = ctodev(card);
- BUG_ON(!(be32_to_cpu(descr->hw_regs.data_status) & GELIC_DESCR_TX_TAIL));
+ BUG_ON(!(be32_to_cpu(descr->hw_regs.data_status) &
+ GELIC_DESCR_TX_TAIL));
- dma_unmap_single(dev, be32_to_cpu(descr->hw_regs.payload.dev_addr), skb->len,
- DMA_TO_DEVICE);
+ dma_unmap_single(dev, be32_to_cpu(descr->hw_regs.payload.dev_addr),
+ skb->len, DMA_TO_DEVICE);
dev_kfree_skb_any(skb);
descr->hw_regs.payload.dev_addr = 0;
@@ -524,7 +521,6 @@ static void gelic_descr_release_tx(struct gelic_card *card,
descr->hw_regs.data_error = 0;
descr->skb = NULL;
- /* set descr status */
gelic_descr_set_status(descr, GELIC_DESCR_DMA_NOT_IN_USE);
}
@@ -580,19 +576,19 @@ static void gelic_card_release_tx_chain(struct gelic_card *card, int stop)
}
break;
- case GELIC_DESCR_DMA_CARDOWNED:
- /* pending tx request */
default:
- /* any other value (== GELIC_DESCR_DMA_NOT_IN_USE) */
- if (!stop)
+ if (!stop) {
goto out;
+ }
}
+
gelic_descr_release_tx(card, tx_chain->tail);
- release ++;
+ release++;
}
out:
- if (!stop && release)
+ if (!stop && release) {
gelic_card_wake_queues(card);
+ }
}
/**
@@ -613,18 +609,18 @@ void gelic_net_set_multi(struct net_device *netdev)
u64 addr;
int status;
- /* clear all multicast address */
status = lv1_net_remove_multicast_address(bus_id(card), dev_id(card),
- 0, 1);
+ 0, 1);
+
if (status) {
dev_err(dev,
"%s:%d: lv1_net_remove_multicast_address failed %d\n",
__func__, __LINE__, status);
}
- /* set broadcast address */
status = lv1_net_add_multicast_address(bus_id(card), dev_id(card),
- GELIC_NET_BROADCAST_ADDR, 0);
+ GELIC_NET_BROADCAST_ADDR, 0);
+
if (status) {
dev_err(dev,
"%s:%d: lv1_net_add_multicast_address failed, %d\n",
@@ -634,8 +630,8 @@ void gelic_net_set_multi(struct net_device *netdev)
if ((netdev->flags & IFF_ALLMULTI) ||
(netdev_mc_count(netdev) > GELIC_NET_MC_COUNT_MAX)) {
status = lv1_net_add_multicast_address(bus_id(card),
- dev_id(card),
- 0, 1);
+ dev_id(card), 0, 1);
+
if (status) {
dev_err(dev,
"%s:%d: lv1_net_add_multicast_address failed, %d\n",
@@ -644,7 +640,6 @@ void gelic_net_set_multi(struct net_device *netdev)
return;
}
- /* set multicast addresses */
netdev_for_each_mc_addr(ha, netdev) {
addr = 0;
p = ha->addr;
@@ -653,8 +648,8 @@ void gelic_net_set_multi(struct net_device *netdev)
addr |= *p++;
}
status = lv1_net_add_multicast_address(bus_id(card),
- dev_id(card),
- addr, 0);
+ dev_id(card), addr, 0);
+
if (status) {
dev_err(dev,
"%s:%d: lv1_net_add_multicast_address failed, %d\n",
@@ -698,8 +693,8 @@ gelic_card_get_next_tx_descr(struct gelic_card *card)
return NULL;
/* see if the next descriptor is free */
if (card->tx_chain.tail != card->tx_chain.head->next &&
- gelic_descr_get_status(card->tx_chain.head) ==
- GELIC_DESCR_DMA_NOT_IN_USE)
+ gelic_descr_get_status(card->tx_chain.head) ==
+ GELIC_DESCR_DMA_NOT_IN_USE)
return card->tx_chain.head;
else
return NULL;
@@ -716,12 +711,12 @@ gelic_card_get_next_tx_descr(struct gelic_card *card)
* has executed before.
*/
static void gelic_descr_set_tx_cmdstat(struct gelic_descr *descr,
- struct sk_buff *skb)
+ struct sk_buff *skb)
{
if (skb->ip_summed != CHECKSUM_PARTIAL)
descr->hw_regs.dmac_cmd_status =
cpu_to_be32(GELIC_DESCR_DMA_CMD_NO_CHKSUM |
- GELIC_DESCR_TX_DMA_FRAME_TAIL);
+ GELIC_DESCR_TX_DMA_FRAME_TAIL);
else {
/* is packet ip?
* if yes: tcp? udp? */
@@ -747,14 +742,15 @@ static void gelic_descr_set_tx_cmdstat(struct gelic_descr *descr,
}
static struct sk_buff *gelic_put_vlan_tag(struct sk_buff *skb,
- unsigned short tag)
+ unsigned short tag)
{
struct vlan_ethhdr *veth;
static unsigned int c;
if (skb_headroom(skb) < VLAN_HLEN) {
struct sk_buff *sk_tmp = skb;
- pr_debug("%s: hd=%d c=%ud\n", __func__, skb_headroom(skb), c);
+ pr_debug("%s:%d: hd=%d c=%ud\n", __func__, __LINE__,
+ skb_headroom(skb), c);
skb = skb_realloc_headroom(sk_tmp, VLAN_HLEN);
if (!skb)
return NULL;
@@ -781,8 +777,7 @@ static struct sk_buff *gelic_put_vlan_tag(struct sk_buff *skb,
*
*/
static int gelic_descr_prepare_tx(struct gelic_card *card,
- struct gelic_descr *descr,
- struct sk_buff *skb)
+ struct gelic_descr *descr, struct sk_buff *skb)
{
struct device *dev = ctodev(card);
dma_addr_t cpu_addr;
@@ -792,10 +787,11 @@ static int gelic_descr_prepare_tx(struct gelic_card *card,
enum gelic_port_type type;
type = netdev_port(skb->dev)->type;
- skb_tmp = gelic_put_vlan_tag(skb,
- card->vlan[type].tx);
- if (!skb_tmp)
+ skb_tmp = gelic_put_vlan_tag(skb, card->vlan[type].tx);
+
+ if (!skb_tmp) {
return -ENOMEM;
+ }
skb = skb_tmp;
}
@@ -890,7 +886,8 @@ netdev_tx_t gelic_net_xmit(struct sk_buff *skb, struct net_device *netdev)
* link this prepared descriptor to previous one
* to achieve high performance
*/
- descr->prev->hw_regs.next_descr_addr = cpu_to_be32(descr->link.cpu_addr);
+ descr->prev->hw_regs.next_descr_addr =
+ cpu_to_be32(descr->link.cpu_addr);
/*
* as hardware descriptor is modified in the above lines,
* ensure that the hardware sees it
@@ -926,9 +923,7 @@ netdev_tx_t gelic_net_xmit(struct sk_buff *skb, struct net_device *netdev)
* stack. The descriptor state is not changed.
*/
static void gelic_net_pass_skb_up(struct gelic_descr *descr,
- struct gelic_card *card,
- struct net_device *netdev)
-
+ struct gelic_card *card, struct net_device *netdev)
{
struct device *dev = ctodev(card);
struct sk_buff *skb = descr->skb;
@@ -938,19 +933,18 @@ static void gelic_net_pass_skb_up(struct gelic_descr *descr,
data_error = be32_to_cpu(descr->hw_regs.data_error);
/* unmap skb buffer */
dma_unmap_single(dev, be32_to_cpu(descr->hw_regs.payload.dev_addr),
- GELIC_NET_MAX_MTU,
- DMA_FROM_DEVICE);
+ GELIC_NET_MAX_MTU, DMA_FROM_DEVICE);
- skb_put(skb, be32_to_cpu(descr->hw_regs.valid_size)?
+ skb_put(skb, be32_to_cpu(descr->hw_regs.valid_size) ?
be32_to_cpu(descr->hw_regs.valid_size) :
be32_to_cpu(descr->hw_regs.result_size));
if (!descr->hw_regs.valid_size) {
dev_err(dev, "%s:%d: buffer full %x %x %x\n", __func__,
__LINE__,
- be32_to_cpu(descr->hw_regs.result_size),
- be32_to_cpu(descr->hw_regs.payload.size),
- be32_to_cpu(descr->hw_regs.dmac_cmd_status));
+ be32_to_cpu(descr->hw_regs.result_size),
+ be32_to_cpu(descr->hw_regs.payload.size),
+ be32_to_cpu(descr->hw_regs.dmac_cmd_status));
}
descr->skb = NULL;
@@ -1028,8 +1022,8 @@ static int gelic_card_decode_one_descr(struct gelic_card *card)
netdev = card->netdev[GELIC_PORT_ETHERNET_0];
if ((status == GELIC_DESCR_DMA_RESPONSE_ERROR) ||
- (status == GELIC_DESCR_DMA_PROTECTION_ERROR) ||
- (status == GELIC_DESCR_DMA_FORCE_END)) {
+ (status == GELIC_DESCR_DMA_PROTECTION_ERROR) ||
+ (status == GELIC_DESCR_DMA_FORCE_END)) {
dev_info(dev, "%s:%d: dropping RX descriptor with state %x\n",
__func__, __LINE__, status);
netdev->stats.rx_dropped++;
@@ -1064,8 +1058,7 @@ static int gelic_card_decode_one_descr(struct gelic_card *card)
refill:
/* is the current descriptor terminated with next_descr == NULL? */
- dmac_chain_ended =
- be32_to_cpu(descr->hw_regs.dmac_cmd_status) &
+ dmac_chain_ended = be32_to_cpu(descr->hw_regs.dmac_cmd_status) &
GELIC_DESCR_RX_DMA_CHAIN_END;
/*
* So that always DMAC can see the end
@@ -1089,15 +1082,17 @@ static int gelic_card_decode_one_descr(struct gelic_card *card)
/*
* Set this descriptor the end of the chain.
*/
- descr->prev->hw_regs.next_descr_addr = cpu_to_be32(descr->link.cpu_addr);
+ descr->prev->hw_regs.next_descr_addr =
+ cpu_to_be32(descr->link.cpu_addr);
/*
* If dmac chain was met, DMAC stopped.
* thus re-enable it
*/
- if (dmac_chain_ended)
+ if (dmac_chain_ended) {
gelic_card_enable_rxdmac(card);
+ }
return 1;
}
@@ -1116,9 +1111,9 @@ static int gelic_net_poll(struct napi_struct *napi, int budget)
int packets_done = 0;
while (packets_done < budget) {
- if (!gelic_card_decode_one_descr(card))
+ if (!gelic_card_decode_one_descr(card)) {
break;
-
+ }
packets_done++;
}
@@ -1126,6 +1121,7 @@ static int gelic_net_poll(struct napi_struct *napi, int budget)
napi_complete_done(napi, packets_done);
gelic_card_rx_irq_on(card);
}
+
return packets_done;
}
@@ -1140,8 +1136,9 @@ static irqreturn_t gelic_card_interrupt(int irq, void *ptr)
status = card->irq_status;
- if (!status)
+ if (!status) {
return IRQ_NONE;
+ }
status &= card->irq_mask;
@@ -1160,13 +1157,15 @@ static irqreturn_t gelic_card_interrupt(int irq, void *ptr)
}
/* ether port status changed */
- if (status & GELIC_CARD_PORT_STATUS_CHANGED)
+ if (status & GELIC_CARD_PORT_STATUS_CHANGED) {
gelic_card_get_ether_port_status(card, 1);
+ }
#ifdef CONFIG_GELIC_WIRELESS
if (status & (GELIC_CARD_WLAN_EVENT_RECEIVED |
- GELIC_CARD_WLAN_COMMAND_COMPLETED))
+ GELIC_CARD_WLAN_COMMAND_COMPLETED)) {
gelic_wl_interrupt(card->netdev[GELIC_PORT_WIRELESS], status);
+ }
#endif
return IRQ_HANDLED;
@@ -1211,14 +1210,14 @@ int gelic_net_open(struct net_device *netdev)
}
void gelic_net_get_drvinfo(struct net_device *netdev,
- struct ethtool_drvinfo *info)
+ struct ethtool_drvinfo *info)
{
strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
strlcpy(info->version, DRV_VERSION, sizeof(info->version));
}
static int gelic_ether_get_link_ksettings(struct net_device *netdev,
- struct ethtool_link_ksettings *cmd)
+ struct ethtool_link_ksettings *cmd)
{
struct gelic_card *card = netdev_card(netdev);
struct device *dev = ctodev(card);
@@ -1248,10 +1247,12 @@ static int gelic_ether_get_link_ksettings(struct net_device *netdev,
}
supported = SUPPORTED_TP | SUPPORTED_Autoneg |
- SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full |
- SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full |
- SUPPORTED_1000baseT_Full;
+ SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full |
+ SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full |
+ SUPPORTED_1000baseT_Full;
+
advertising = supported;
+
if (card->link_mode & GELIC_LV1_ETHER_AUTO_NEG) {
cmd->base.autoneg = AUTONEG_ENABLE;
} else {
@@ -1261,16 +1262,15 @@ static int gelic_ether_get_link_ksettings(struct net_device *netdev,
cmd->base.port = PORT_TP;
ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
- supported);
+ supported);
ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising,
- advertising);
+ advertising);
return 0;
}
-static int
-gelic_ether_set_link_ksettings(struct net_device *netdev,
- const struct ethtool_link_ksettings *cmd)
+static int gelic_ether_set_link_ksettings(struct net_device *netdev,
+ const struct ethtool_link_ksettings *cmd)
{
struct gelic_card *card = netdev_card(netdev);
struct device *dev = ctodev(card);
@@ -1293,6 +1293,7 @@ gelic_ether_set_link_ksettings(struct net_device *netdev,
default:
return -EINVAL;
}
+
if (cmd->base.duplex == DUPLEX_FULL) {
mode |= GELIC_LV1_ETHER_FULL_DUPLEX;
} else if (cmd->base.speed == SPEED_1000) {
@@ -1305,25 +1306,28 @@ gelic_ether_set_link_ksettings(struct net_device *netdev,
ret = gelic_card_set_link_mode(card, mode);
- if (ret)
+ if (ret) {
return ret;
+ }
return 0;
}
static void gelic_net_get_wol(struct net_device *netdev,
- struct ethtool_wolinfo *wol)
+ struct ethtool_wolinfo *wol)
{
- if (0 <= ps3_compare_firmware_version(2, 2, 0))
+ if (ps3_compare_firmware_version(2, 2, 0) >= 0) {
wol->supported = WAKE_MAGIC;
- else
+ } else {
wol->supported = 0;
+ }
wol->wolopts = ps3_sys_manager_get_wol() ? wol->supported : 0;
memset(&wol->sopass, 0, sizeof(wol->sopass));
}
+
static int gelic_net_set_wol(struct net_device *netdev,
- struct ethtool_wolinfo *wol)
+ struct ethtool_wolinfo *wol)
{
struct gelic_card *card = netdev_card(netdev);
struct device *dev = ctodev(card);
@@ -1331,56 +1335,56 @@ static int gelic_net_set_wol(struct net_device *netdev,
u64 v1, v2;
if (ps3_compare_firmware_version(2, 2, 0) < 0 ||
- !capable(CAP_NET_ADMIN))
+ !capable(CAP_NET_ADMIN)) {
return -EPERM;
+ }
- if (wol->wolopts & ~WAKE_MAGIC)
+ if (wol->wolopts & ~WAKE_MAGIC) {
return -EINVAL;
+ }
if (wol->wolopts & WAKE_MAGIC) {
status = lv1_net_control(bus_id(card), dev_id(card),
- GELIC_LV1_SET_WOL,
- GELIC_LV1_WOL_MAGIC_PACKET,
- 0, GELIC_LV1_WOL_MP_ENABLE,
- &v1, &v2);
+ GELIC_LV1_SET_WOL, GELIC_LV1_WOL_MAGIC_PACKET, 0,
+ GELIC_LV1_WOL_MP_ENABLE, &v1, &v2);
+
if (status) {
dev_dbg(dev, "%s:%d: Enabling WOL failed: %d\n",
__func__, __LINE__, status);
status = -EIO;
goto done;
}
+
status = lv1_net_control(bus_id(card), dev_id(card),
- GELIC_LV1_SET_WOL,
- GELIC_LV1_WOL_ADD_MATCH_ADDR,
- 0, GELIC_LV1_WOL_MATCH_ALL,
- &v1, &v2);
- if (!status)
+ GELIC_LV1_SET_WOL, GELIC_LV1_WOL_ADD_MATCH_ADDR, 0,
+ GELIC_LV1_WOL_MATCH_ALL, &v1, &v2);
+
+ if (!status) {
ps3_sys_manager_set_wol(1);
- else {
+ } else {
dev_dbg(dev, "%s:%d: Enabling WOL filter failed: %d\n",
__func__, __LINE__, status);
status = -EIO;
}
} else {
status = lv1_net_control(bus_id(card), dev_id(card),
- GELIC_LV1_SET_WOL,
- GELIC_LV1_WOL_MAGIC_PACKET,
- 0, GELIC_LV1_WOL_MP_DISABLE,
- &v1, &v2);
+ GELIC_LV1_SET_WOL, GELIC_LV1_WOL_MAGIC_PACKET,
+ 0, GELIC_LV1_WOL_MP_DISABLE, &v1, &v2);
+
if (status) {
dev_dbg(dev, "%s:%d: Disabling WOL failed: %d\n",
__func__, __LINE__, status);
status = -EIO;
goto done;
}
+
status = lv1_net_control(bus_id(card), dev_id(card),
- GELIC_LV1_SET_WOL,
- GELIC_LV1_WOL_DELETE_MATCH_ADDR,
- 0, GELIC_LV1_WOL_MATCH_ALL,
- &v1, &v2);
- if (!status)
+ GELIC_LV1_SET_WOL, GELIC_LV1_WOL_DELETE_MATCH_ADDR,
+ 0, GELIC_LV1_WOL_MATCH_ALL, &v1, &v2);
+
+ if (!status) {
ps3_sys_manager_set_wol(0);
- else {
+ } else {
dev_dbg(dev, "%s:%d: Removing WOL filter failed: %d\n",
__func__, __LINE__, status);
status = -EIO;
@@ -1415,8 +1419,9 @@ static void gelic_net_tx_timeout_task(struct work_struct *work)
dev_info(dev, "%s:%d: Timed out. Restarting...\n", __func__, __LINE__);
- if (!(netdev->flags & IFF_UP))
+ if (!(netdev->flags & IFF_UP)) {
goto out;
+ }
netif_device_detach(netdev);
gelic_net_stop(netdev);
@@ -1441,10 +1446,12 @@ void gelic_net_tx_timeout(struct net_device *netdev, unsigned int txqueue)
card = netdev_card(netdev);
atomic_inc(&card->tx_timeout_task_counter);
- if (netdev->flags & IFF_UP)
+
+ if (netdev->flags & IFF_UP) {
schedule_work(&card->tx_timeout_task);
- else
+ } else {
atomic_dec(&card->tx_timeout_task_counter);
+ }
}
static const struct net_device_ops gelic_netdevice_ops = {
@@ -1468,7 +1475,7 @@ static const struct net_device_ops gelic_netdevice_ops = {
* fills out function pointers in the net_device structure
*/
static void gelic_ether_setup_netdev_ops(struct net_device *netdev,
- struct napi_struct *napi)
+ struct napi_struct *napi)
{
netdev->watchdog_timeo = GELIC_NET_WATCHDOG_TIMEOUT;
/* NAPI */
@@ -1494,20 +1501,23 @@ int gelic_net_setup_netdev(struct net_device *netdev, struct gelic_card *card)
u64 v1, v2;
netdev->hw_features = NETIF_F_IP_CSUM | NETIF_F_RXCSUM;
-
netdev->features = NETIF_F_IP_CSUM;
- if (GELIC_CARD_RX_CSUM_DEFAULT)
+
+ if (GELIC_CARD_RX_CSUM_DEFAULT) {
netdev->features |= NETIF_F_RXCSUM;
+ }
status = lv1_net_control(bus_id(card), dev_id(card),
- GELIC_LV1_GET_MAC_ADDRESS,
- 0, 0, 0, &v1, &v2);
+ GELIC_LV1_GET_MAC_ADDRESS, 0, 0, 0, &v1, &v2);
+
v1 <<= 16;
+
if (status || !is_valid_ether_addr((u8 *)&v1)) {
dev_dbg(dev, "%s:%d: lv1_net_control GET_MAC_ADDR failed: %d\n",
__func__, __LINE__, status);
return -EINVAL;
}
+
memcpy(netdev->dev_addr, &v1, ETH_ALEN);
if (card->vlan_required) {
@@ -1557,34 +1567,32 @@ static struct gelic_card *gelic_alloc_card_net(struct net_device **netdev)
*/
BUILD_BUG_ON(offsetof(struct gelic_card, irq_status) % 8);
BUILD_BUG_ON(offsetof(struct gelic_card, descr) % 32);
- alloc_size =
- sizeof(struct gelic_card) +
+ alloc_size = sizeof(struct gelic_card) +
sizeof(struct gelic_descr) * GELIC_NET_RX_DESCRIPTORS +
sizeof(struct gelic_descr) * GELIC_NET_TX_DESCRIPTORS +
GELIC_ALIGN - 1;
p = kzalloc(alloc_size, GFP_KERNEL);
- if (!p)
+
+ if (!p) {
return NULL;
+ }
+
card = PTR_ALIGN(p, GELIC_ALIGN);
card->unalign = p;
- /*
- * alloc netdev
- */
*netdev = alloc_etherdev(sizeof(struct gelic_port));
+
if (!*netdev) {
kfree(card->unalign);
return NULL;
}
port = netdev_priv(*netdev);
- /* gelic_port */
port->netdev = *netdev;
port->card = card;
port->type = GELIC_PORT_ETHERNET_0;
- /* gelic_card */
card->netdev[GELIC_PORT_ETHERNET_0] = *netdev;
INIT_WORK(&card->tx_timeout_task, gelic_net_tx_timeout_task);
@@ -1619,9 +1627,9 @@ static void gelic_card_get_vlan_info(struct gelic_card *card)
for (i = 0; i < ARRAY_SIZE(vlan_id_ix); i++) {
/* tx tag */
status = lv1_net_control(bus_id(card), dev_id(card),
- GELIC_LV1_GET_VLAN_ID,
- vlan_id_ix[i].tx,
- 0, 0, &v1, &v2);
+ GELIC_LV1_GET_VLAN_ID, vlan_id_ix[i].tx, 0, 0, &v1,
+ &v2);
+
if (status || !v1) {
if (status != LV1_NO_ENTRY) {
dev_dbg(dev,
@@ -1637,9 +1645,9 @@ static void gelic_card_get_vlan_info(struct gelic_card *card)
/* rx tag */
status = lv1_net_control(bus_id(card), dev_id(card),
- GELIC_LV1_GET_VLAN_ID,
- vlan_id_ix[i].rx,
- 0, 0, &v1, &v2);
+ GELIC_LV1_GET_VLAN_ID, vlan_id_ix[i].rx, 0, 0, &v1,
+ &v2);
+
if (status || !v1) {
if (status != LV1_NO_ENTRY) {
dev_dbg(dev,
@@ -1651,6 +1659,7 @@ static void gelic_card_get_vlan_info(struct gelic_card *card)
card->vlan[i].rx = 0;
continue;
}
+
card->vlan[i].rx = (u16)v1;
dev_dbg(dev, "%s:%d: vlan_id[%d] tx=%02x rx=%02x\n", __func__,
@@ -1672,6 +1681,7 @@ static void gelic_card_get_vlan_info(struct gelic_card *card)
dev_dbg(dev, "%s:%d: internal vlan %s\n", __func__, __LINE__,
card->vlan_required ? "enabled" : "disabled");
}
+
/*
* ps3_gelic_driver_probe - add a device to the control of this driver
*/
@@ -1703,27 +1713,24 @@ static int ps3_gelic_driver_probe(struct ps3_system_bus_device *sb_dev)
goto fail_dma_region;
}
- /* alloc card/netdevice */
card = gelic_alloc_card_net(&netdev);
+
if (!card) {
dev_info(dev, "%s:%d: gelic_net_alloc_card failed.\n", __func__,
__LINE__);
result = -ENOMEM;
goto fail_alloc_card;
}
+
ps3_system_bus_set_drvdata(sb_dev, card);
card->dev = sb_dev;
- /* get internal vlan info */
gelic_card_get_vlan_info(card);
card->link_mode = GELIC_LV1_ETHER_AUTO_NEG;
- /* setup interrupt */
result = lv1_net_set_interrupt_status_indicator(bus_id(card),
- dev_id(card),
- ps3_mm_phys_to_lpar(__pa(&card->irq_status)),
- 0);
+ dev_id(card), ps3_mm_phys_to_lpar(__pa(&card->irq_status)), 0);
if (result) {
dev_dbg(dev,
@@ -1742,8 +1749,9 @@ static int ps3_gelic_driver_probe(struct ps3_system_bus_device *sb_dev)
result = -EPERM;
goto fail_alloc_irq;
}
- result = request_irq(card->irq, gelic_card_interrupt,
- 0, netdev->name, card);
+
+ result = request_irq(card->irq, gelic_card_interrupt, 0, netdev->name,
+ card);
if (result) {
dev_dbg(dev, "%s:%d: request_irq failed: %d\n",
@@ -1751,22 +1759,24 @@ static int ps3_gelic_driver_probe(struct ps3_system_bus_device *sb_dev)
goto fail_request_irq;
}
- /* setup card structure */
card->irq_mask = GELIC_CARD_RXINT | GELIC_CARD_TXINT |
GELIC_CARD_PORT_STATUS_CHANGED;
+ result = gelic_card_init_chain(card, &card->tx_chain, card->descr,
+ GELIC_NET_TX_DESCRIPTORS);
- result = gelic_card_init_chain(card, &card->tx_chain,
- card->descr, GELIC_NET_TX_DESCRIPTORS);
- if (result)
+ if (result) {
goto fail_alloc_tx;
+ }
+
result = gelic_card_init_chain(card, &card->rx_chain,
- card->descr + GELIC_NET_TX_DESCRIPTORS,
- GELIC_NET_RX_DESCRIPTORS);
- if (result)
+ card->descr + GELIC_NET_TX_DESCRIPTORS,
+ GELIC_NET_RX_DESCRIPTORS);
+
+ if (result) {
goto fail_alloc_rx;
+ }
- /* head of chain */
card->tx_top = card->tx_chain.head;
card->rx_top = card->rx_chain.head;
@@ -1774,19 +1784,21 @@ static int ps3_gelic_driver_probe(struct ps3_system_bus_device *sb_dev)
__func__, __LINE__, card->rx_top, card->tx_top,
sizeof(struct gelic_descr), GELIC_NET_RX_DESCRIPTORS);
- /* allocate rx skbs */
result = gelic_card_alloc_rx_skbs(card);
- if (result)
+
+ if (result) {
goto fail_alloc_skbs;
+ }
spin_lock_init(&card->tx_lock);
card->tx_dma_progress = 0;
- /* setup net_device structure */
netdev->irq = card->irq;
SET_NETDEV_DEV(netdev, dev);
gelic_ether_setup_netdev_ops(netdev, &card->napi);
+
result = gelic_net_setup_netdev(netdev, card);
+
if (result) {
dev_err(dev, "%s:%d: setup_netdev failed: %d\n", __func__,
__LINE__, result);
@@ -1795,6 +1807,7 @@ static int ps3_gelic_driver_probe(struct ps3_system_bus_device *sb_dev)
#ifdef CONFIG_GELIC_WIRELESS
result = gelic_wl_driver_probe(card);
+
if (result) {
dev_dbg(dev, "%s:%d: WL init failed\n", __func__, __LINE__);
goto fail_setup_netdev;
@@ -1814,9 +1827,8 @@ static int ps3_gelic_driver_probe(struct ps3_system_bus_device *sb_dev)
fail_request_irq:
ps3_sb_event_receive_port_destroy(sb_dev, card->irq);
fail_alloc_irq:
- lv1_net_set_interrupt_status_indicator(bus_id(card),
- bus_id(card),
- 0, 0);
+ lv1_net_set_interrupt_status_indicator(bus_id(card), bus_id(card), 0,
+ 0);
fail_status_indicator:
ps3_system_bus_set_drvdata(sb_dev, NULL);
kfree(netdev_card(netdev)->unalign);
@@ -1842,20 +1854,16 @@ static void ps3_gelic_driver_remove(struct ps3_system_bus_device *sb_dev)
dev_dbg(dev, "%s:%d: >\n", __func__, __LINE__);
- /* set auto-negotiation */
gelic_card_set_link_mode(card, GELIC_LV1_ETHER_AUTO_NEG);
#ifdef CONFIG_GELIC_WIRELESS
gelic_wl_driver_remove(card);
#endif
- /* stop interrupt */
gelic_card_set_irq_mask(card, 0);
- /* turn off DMA, force end */
gelic_card_disable_rxdmac(card);
gelic_card_disable_txdmac(card);
- /* release chains */
gelic_card_release_tx_chain(card, 1);
gelic_card_release_rx_chain(card);
@@ -1863,16 +1871,16 @@ static void ps3_gelic_driver_remove(struct ps3_system_bus_device *sb_dev)
gelic_card_free_chain(card, card->rx_top);
netdev0 = card->netdev[GELIC_PORT_ETHERNET_0];
- /* disconnect event port */
+
free_irq(card->irq, card);
netdev0->irq = 0;
ps3_sb_event_receive_port_destroy(card->dev, card->irq);
wait_event(card->waitq,
- atomic_read(&card->tx_timeout_task_counter) == 0);
+ atomic_read(&card->tx_timeout_task_counter) == 0);
- lv1_net_set_interrupt_status_indicator(bus_id(card), dev_id(card),
- 0 , 0);
+ lv1_net_set_interrupt_status_indicator(bus_id(card), dev_id(card), 0,
+ 0);
unregister_netdev(netdev0);
kfree(netdev_card(netdev0)->unalign);
@@ -1896,14 +1904,14 @@ static struct ps3_system_bus_driver ps3_gelic_driver = {
.core.owner = THIS_MODULE,
};
-static int __init ps3_gelic_driver_init (void)
+static int __init ps3_gelic_driver_init(void)
{
return firmware_has_feature(FW_FEATURE_PS3_LV1)
? ps3_system_bus_driver_register(&ps3_gelic_driver)
: -ENODEV;
}
-static void __exit ps3_gelic_driver_exit (void)
+static void __exit ps3_gelic_driver_exit(void)
{
ps3_system_bus_driver_unregister(&ps3_gelic_driver);
}
@@ -1912,4 +1920,3 @@ module_init(ps3_gelic_driver_init);
module_exit(ps3_gelic_driver_exit);
MODULE_ALIAS(PS3_MODULE_ALIAS_GELIC);
-
--
2.25.1
^ permalink raw reply related
* [PATCH v4 07/10] net/ps3_gelic: Add new routine gelic_unmap_link
From: Geoff Levand @ 2021-07-23 20:31 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski; +Cc: netdev, linuxppc-dev
In-Reply-To: <cover.1627068552.git.geoff@infradead.org>
Put the common code for unmaping a link into its own routine,
gelic_unmap_link, and add some debugging checks.
Signed-off-by: Geoff Levand <geoff@infradead.org>
---
drivers/net/ethernet/toshiba/ps3_gelic_net.c | 23 +++++++++++++++-----
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_net.c b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
index 85fc1915c8be..e55aa9fecfeb 100644
--- a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
+++ b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
@@ -288,6 +288,21 @@ void gelic_card_down(struct gelic_card *card)
mutex_unlock(&card->updown_lock);
}
+static void gelic_unmap_link(struct device *dev, struct gelic_descr *descr)
+{
+ BUG_ON_DEBUG(descr->hw_regs.payload.dev_addr);
+ BUG_ON_DEBUG(descr->hw_regs.payload.size);
+
+ BUG_ON_DEBUG(!descr->link.cpu_addr);
+ BUG_ON_DEBUG(!descr->link.size);
+
+ dma_unmap_single(dev, descr->link.cpu_addr, descr->link.size,
+ DMA_BIDIRECTIONAL);
+
+ descr->link.cpu_addr = 0;
+ descr->link.size = 0;
+}
+
/**
* gelic_card_free_chain - free descriptor chain
* @card: card structure
@@ -301,9 +316,7 @@ static void gelic_card_free_chain(struct gelic_card *card,
for (descr = descr_in; descr && descr->link.cpu_addr;
descr = descr->next) {
- dma_unmap_single(dev, descr->link.cpu_addr, descr->link.size,
- DMA_BIDIRECTIONAL);
- descr->link.cpu_addr = 0;
+ gelic_unmap_link(dev, descr);
}
}
@@ -364,9 +377,7 @@ static int gelic_card_init_chain(struct gelic_card *card,
iommu_error:
for (i--, descr--; 0 <= i; i--, descr--)
if (descr->link.cpu_addr)
- dma_unmap_single(dev, descr->link.cpu_addr,
- descr->link.size,
- DMA_BIDIRECTIONAL);
+ gelic_unmap_link(dev, descr);
return -ENOMEM;
}
--
2.25.1
^ permalink raw reply related
* [PATCH v4 08/10] net/ps3_gelic: Rename no to descr_count
From: Geoff Levand @ 2021-07-23 20:31 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski; +Cc: netdev, linuxppc-dev
In-Reply-To: <cover.1627068552.git.geoff@infradead.org>
In an effort to make the PS3 gelic driver easier to maintain, rename
the gelic_card_init_chain parameter 'no' to 'descr_count'.
Signed-off-by: Geoff Levand <geoff@infradead.org>
---
drivers/net/ethernet/toshiba/ps3_gelic_net.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_net.c b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
index e55aa9fecfeb..60fcca5d20dd 100644
--- a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
+++ b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
@@ -325,7 +325,7 @@ static void gelic_card_free_chain(struct gelic_card *card,
* @card: card structure
* @chain: address of chain
* @start_descr: address of descriptor array
- * @no: number of descriptors
+ * @descr_count: number of descriptors
*
* we manage a circular list that mirrors the hardware structure,
* except that the hardware uses bus addresses.
@@ -334,16 +334,16 @@ static void gelic_card_free_chain(struct gelic_card *card,
*/
static int gelic_card_init_chain(struct gelic_card *card,
struct gelic_descr_chain *chain, struct gelic_descr *start_descr,
- int no)
+ int descr_count)
{
int i;
struct gelic_descr *descr;
struct device *dev = ctodev(card);
descr = start_descr;
- memset(descr, 0, sizeof(*descr) * no);
+ memset(descr, 0, sizeof(*descr) *descr_count);
- for (i = 0; i < no; i++, descr++) {
+ for (i = 0; i < descr_count; i++, descr++) {
descr->link.size = sizeof(struct gelic_hw_regs);
gelic_descr_set_status(descr, GELIC_DESCR_DMA_NOT_IN_USE);
descr->link.cpu_addr =
@@ -361,7 +361,7 @@ static int gelic_card_init_chain(struct gelic_card *card,
start_descr->prev = (descr - 1);
descr = start_descr;
- for (i = 0; i < no; i++, descr++) {
+ for (i = 0; i < descr_count; i++, descr++) {
descr->hw_regs.next_descr_addr =
cpu_to_be32(descr->next->link.cpu_addr);
}
--
2.25.1
^ permalink raw reply related
* [PATCH v4 09/10] net/ps3_gelic: Add new routine gelic_work_to_card
From: Geoff Levand @ 2021-07-23 20:31 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski; +Cc: netdev, linuxppc-dev
In-Reply-To: <cover.1627068552.git.geoff@infradead.org>
Add new helper routine gelic_work_to_card that converts a work_struct
to a gelic_card.
Signed-off-by: Geoff Levand <geoff@infradead.org>
---
drivers/net/ethernet/toshiba/ps3_gelic_net.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_net.c b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
index 60fcca5d20dd..42f4de9ad5fe 100644
--- a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
+++ b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
@@ -1420,6 +1420,11 @@ static const struct ethtool_ops gelic_ether_ethtool_ops = {
.set_link_ksettings = gelic_ether_set_link_ksettings,
};
+static struct gelic_card *gelic_work_to_card(struct work_struct *work)
+{
+ return container_of(work, struct gelic_card, tx_timeout_task);
+}
+
/**
* gelic_net_tx_timeout_task - task scheduled by the watchdog timeout
* function (to be called not under interrupt status)
@@ -1429,8 +1434,7 @@ static const struct ethtool_ops gelic_ether_ethtool_ops = {
*/
static void gelic_net_tx_timeout_task(struct work_struct *work)
{
- struct gelic_card *card =
- container_of(work, struct gelic_card, tx_timeout_task);
+ struct gelic_card *card = gelic_work_to_card(work);
struct net_device *netdev = card->netdev[GELIC_PORT_ETHERNET_0];
struct device *dev = ctodev(card);
--
2.25.1
^ permalink raw reply related
* [PATCH v4 02/10] net/ps3_gelic: Use local dev variable
From: Geoff Levand @ 2021-07-23 20:31 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski; +Cc: netdev, linuxppc-dev
In-Reply-To: <cover.1627068552.git.geoff@infradead.org>
In an effort to make the PS3 gelic driver easier to maintain, add a
local variable dev to those routines that use the device structure that
makes the use the device structure more consistent.
Signed-off-by: Geoff Levand <geoff@infradead.org>
---
drivers/net/ethernet/toshiba/ps3_gelic_net.c | 340 +++++++++++--------
1 file changed, 191 insertions(+), 149 deletions(-)
diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_net.c b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
index cb45571573d7..ba008a98928a 100644
--- a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
+++ b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
@@ -48,13 +48,15 @@ MODULE_LICENSE("GPL");
/* set irq_mask */
int gelic_card_set_irq_mask(struct gelic_card *card, u64 mask)
{
+ struct device *dev = ctodev(card);
int status;
status = lv1_net_set_interrupt_mask(bus_id(card), dev_id(card),
mask, 0);
- if (status)
- dev_info(ctodev(card),
- "%s failed %d\n", __func__, status);
+ if (status) {
+ dev_err(dev, "%s:%d failed: %d\n", __func__, __LINE__, status);
+ }
+
return status;
}
@@ -103,6 +105,7 @@ gelic_descr_get_status(struct gelic_descr *descr)
static int gelic_card_set_link_mode(struct gelic_card *card, int mode)
{
+ struct device *dev = ctodev(card);
int status;
u64 v1, v2;
@@ -110,8 +113,8 @@ static int gelic_card_set_link_mode(struct gelic_card *card, int mode)
GELIC_LV1_SET_NEGOTIATION_MODE,
GELIC_LV1_PHY_ETHERNET_0, mode, 0, &v1, &v2);
if (status) {
- pr_info("%s: failed setting negotiation mode %d\n", __func__,
- status);
+ dev_err(dev, "%s:%d: Failed setting negotiation mode: %d\n",
+ __func__, __LINE__, status);
return -EBUSY;
}
@@ -128,13 +131,15 @@ static int gelic_card_set_link_mode(struct gelic_card *card, int mode)
*/
static void gelic_card_disable_txdmac(struct gelic_card *card)
{
+ struct device *dev = ctodev(card);
int status;
/* this hvc blocks until the DMA in progress really stopped */
status = lv1_net_stop_tx_dma(bus_id(card), dev_id(card));
- if (status)
- dev_err(ctodev(card),
- "lv1_net_stop_tx_dma failed, status=%d\n", status);
+
+ if (status) {
+ dev_err(dev, "lv1_net_stop_tx_dma failed, status=%d\n", status);
+ }
}
/**
@@ -146,6 +151,7 @@ static void gelic_card_disable_txdmac(struct gelic_card *card)
*/
static void gelic_card_enable_rxdmac(struct gelic_card *card)
{
+ struct device *dev = ctodev(card);
int status;
#ifdef DEBUG
@@ -161,9 +167,10 @@ static void gelic_card_enable_rxdmac(struct gelic_card *card)
#endif
status = lv1_net_start_rx_dma(bus_id(card), dev_id(card),
card->rx_chain.head->link.cpu_addr, 0);
- if (status)
- dev_info(ctodev(card),
- "lv1_net_start_rx_dma failed, status=%d\n", status);
+ if (status) {
+ dev_err(dev, "lv1_net_start_rx_dma failed, status=%d\n",
+ status);
+ }
}
/**
@@ -175,13 +182,15 @@ static void gelic_card_enable_rxdmac(struct gelic_card *card)
*/
static void gelic_card_disable_rxdmac(struct gelic_card *card)
{
+ struct device *dev = ctodev(card);
int status;
/* this hvc blocks until the DMA in progress really stopped */
status = lv1_net_stop_rx_dma(bus_id(card), dev_id(card));
- if (status)
- dev_err(ctodev(card),
- "lv1_net_stop_rx_dma failed, %d\n", status);
+
+ if (status) {
+ dev_err(dev, "lv1_net_stop_rx_dma failed, %d\n", status);
+ }
}
/**
@@ -235,10 +244,11 @@ static void gelic_card_reset_chain(struct gelic_card *card,
void gelic_card_up(struct gelic_card *card)
{
- pr_debug("%s: called\n", __func__);
+ struct device *dev = ctodev(card);
+
mutex_lock(&card->updown_lock);
if (atomic_inc_return(&card->users) == 1) {
- pr_debug("%s: real do\n", __func__);
+ dev_dbg(dev, "%s:%d: Starting...\n", __func__, __LINE__);
/* enable irq */
gelic_card_set_irq_mask(card, card->irq_mask);
/* start rx */
@@ -247,16 +257,16 @@ void gelic_card_up(struct gelic_card *card)
napi_enable(&card->napi);
}
mutex_unlock(&card->updown_lock);
- pr_debug("%s: done\n", __func__);
}
void gelic_card_down(struct gelic_card *card)
{
+ struct device *dev = ctodev(card);
u64 mask;
- pr_debug("%s: called\n", __func__);
+
mutex_lock(&card->updown_lock);
if (atomic_dec_if_positive(&card->users) == 0) {
- pr_debug("%s: real do\n", __func__);
+ dev_dbg(dev, "%s:%d: Stopping...\n", __func__, __LINE__);
napi_disable(&card->napi);
/*
* Disable irq. Wireless interrupts will
@@ -273,7 +283,6 @@ void gelic_card_down(struct gelic_card *card)
gelic_card_disable_txdmac(card);
}
mutex_unlock(&card->updown_lock);
- pr_debug("%s: done\n", __func__);
}
/**
@@ -284,11 +293,12 @@ void gelic_card_down(struct gelic_card *card)
static void gelic_card_free_chain(struct gelic_card *card,
struct gelic_descr *descr_in)
{
+ struct device *dev = ctodev(card);
struct gelic_descr *descr;
for (descr = descr_in; descr && descr->link.cpu_addr; descr = descr->next) {
- dma_unmap_single(ctodev(card), descr->link.cpu_addr,
- descr->link.size, DMA_BIDIRECTIONAL);
+ dma_unmap_single(dev, descr->link.cpu_addr, descr->link.size,
+ DMA_BIDIRECTIONAL);
descr->link.cpu_addr = 0;
}
}
@@ -311,6 +321,7 @@ static int gelic_card_init_chain(struct gelic_card *card,
{
int i;
struct gelic_descr *descr;
+ struct device *dev = ctodev(card);
descr = start_descr;
memset(descr, 0, sizeof(*descr) * no);
@@ -320,9 +331,8 @@ static int gelic_card_init_chain(struct gelic_card *card,
descr->link.size = sizeof(struct gelic_hw_regs);
gelic_descr_set_status(descr, GELIC_DESCR_DMA_NOT_IN_USE);
descr->link.cpu_addr =
- dma_map_single(ctodev(card), descr,
- descr->link.size,
- DMA_BIDIRECTIONAL);
+ dma_map_single(dev, descr, descr->link.size,
+ DMA_BIDIRECTIONAL);
if (!descr->link.cpu_addr)
goto iommu_error;
@@ -351,7 +361,7 @@ static int gelic_card_init_chain(struct gelic_card *card,
iommu_error:
for (i--, descr--; 0 <= i; i--, descr--)
if (descr->link.cpu_addr)
- dma_unmap_single(ctodev(card), descr->link.cpu_addr,
+ dma_unmap_single(dev, descr->link.cpu_addr,
descr->link.size,
DMA_BIDIRECTIONAL);
return -ENOMEM;
@@ -370,11 +380,14 @@ static int gelic_card_init_chain(struct gelic_card *card,
static int gelic_descr_prepare_rx(struct gelic_card *card,
struct gelic_descr *descr)
{
+ struct device *dev = ctodev(card);
int offset;
unsigned int bufsize;
- if (gelic_descr_get_status(descr) != GELIC_DESCR_DMA_NOT_IN_USE)
- dev_info(ctodev(card), "%s: ERROR status\n", __func__);
+ if (gelic_descr_get_status(descr) != GELIC_DESCR_DMA_NOT_IN_USE) {
+ dev_err(dev, "%s:%d: ERROR status\n", __func__, __LINE__);
+ }
+
/* we need to round up the buffer size to a multiple of 128 */
bufsize = ALIGN(GELIC_NET_MAX_MTU, GELIC_NET_RXBUF_ALIGN);
@@ -396,14 +409,14 @@ static int gelic_descr_prepare_rx(struct gelic_card *card,
if (offset)
skb_reserve(descr->skb, GELIC_NET_RXBUF_ALIGN - offset);
/* io-mmu-map the skb */
- descr->hw_regs.payload.dev_addr = cpu_to_be32(dma_map_single(ctodev(card),
+ descr->hw_regs.payload.dev_addr = cpu_to_be32(dma_map_single(dev,
descr->skb->data,
GELIC_NET_MAX_MTU,
DMA_FROM_DEVICE));
if (!descr->hw_regs.payload.dev_addr) {
dev_kfree_skb_any(descr->skb);
descr->skb = NULL;
- dev_info(ctodev(card),
+ dev_info(dev,
"%s:Could not iommu-map rx buffer\n", __func__);
gelic_descr_set_status(descr, GELIC_DESCR_DMA_NOT_IN_USE);
return -ENOMEM;
@@ -421,10 +434,11 @@ static int gelic_descr_prepare_rx(struct gelic_card *card,
static void gelic_card_release_rx_chain(struct gelic_card *card)
{
struct gelic_descr *descr = card->rx_chain.head;
+ struct device *dev = ctodev(card);
do {
if (descr->skb) {
- dma_unmap_single(ctodev(card),
+ dma_unmap_single(dev,
be32_to_cpu(descr->hw_regs.payload.dev_addr),
descr->skb->len,
DMA_FROM_DEVICE);
@@ -493,10 +507,11 @@ static void gelic_descr_release_tx(struct gelic_card *card,
struct gelic_descr *descr)
{
struct sk_buff *skb = descr->skb;
+ struct device *dev = ctodev(card);
BUG_ON(!(be32_to_cpu(descr->hw_regs.data_status) & GELIC_DESCR_TX_TAIL));
- dma_unmap_single(ctodev(card), be32_to_cpu(descr->hw_regs.payload.dev_addr), skb->len,
+ dma_unmap_single(dev, be32_to_cpu(descr->hw_regs.payload.dev_addr), skb->len,
DMA_TO_DEVICE);
dev_kfree_skb_any(skb);
@@ -538,6 +553,7 @@ static void gelic_card_release_tx_chain(struct gelic_card *card, int stop)
{
struct gelic_descr_chain *tx_chain;
enum gelic_descr_dma_status status;
+ struct device *dev = ctodev(card);
struct net_device *netdev;
int release = 0;
@@ -550,11 +566,9 @@ static void gelic_card_release_tx_chain(struct gelic_card *card, int stop)
case GELIC_DESCR_DMA_RESPONSE_ERROR:
case GELIC_DESCR_DMA_PROTECTION_ERROR:
case GELIC_DESCR_DMA_FORCE_END:
- if (printk_ratelimit())
- dev_info(ctodev(card),
- "%s: forcing end of tx descriptor " \
- "with status %x\n",
- __func__, status);
+ dev_info_ratelimited(dev,
+ "%s:%d: forcing end of tx descriptor with status %x\n",
+ __func__, __LINE__, status);
netdev->stats.tx_dropped++;
break;
@@ -592,6 +606,7 @@ static void gelic_card_release_tx_chain(struct gelic_card *card, int stop)
void gelic_net_set_multi(struct net_device *netdev)
{
struct gelic_card *card = netdev_card(netdev);
+ struct device *dev = ctodev(card);
struct netdev_hw_addr *ha;
unsigned int i;
uint8_t *p;
@@ -601,27 +616,31 @@ void gelic_net_set_multi(struct net_device *netdev)
/* clear all multicast address */
status = lv1_net_remove_multicast_address(bus_id(card), dev_id(card),
0, 1);
- if (status)
- dev_err(ctodev(card),
- "lv1_net_remove_multicast_address failed %d\n",
- status);
+ if (status) {
+ dev_err(dev,
+ "%s:%d: lv1_net_remove_multicast_address failed %d\n",
+ __func__, __LINE__, status);
+ }
+
/* set broadcast address */
status = lv1_net_add_multicast_address(bus_id(card), dev_id(card),
GELIC_NET_BROADCAST_ADDR, 0);
- if (status)
- dev_err(ctodev(card),
- "lv1_net_add_multicast_address failed, %d\n",
- status);
+ if (status) {
+ dev_err(dev,
+ "%s:%d: lv1_net_add_multicast_address failed, %d\n",
+ __func__, __LINE__, status);
+ }
if ((netdev->flags & IFF_ALLMULTI) ||
(netdev_mc_count(netdev) > GELIC_NET_MC_COUNT_MAX)) {
status = lv1_net_add_multicast_address(bus_id(card),
dev_id(card),
0, 1);
- if (status)
- dev_err(ctodev(card),
- "lv1_net_add_multicast_address failed, %d\n",
- status);
+ if (status) {
+ dev_err(dev,
+ "%s:%d: lv1_net_add_multicast_address failed, %d\n",
+ __func__, __LINE__, status);
+ }
return;
}
@@ -636,10 +655,11 @@ void gelic_net_set_multi(struct net_device *netdev)
status = lv1_net_add_multicast_address(bus_id(card),
dev_id(card),
addr, 0);
- if (status)
- dev_err(ctodev(card),
- "lv1_net_add_multicast_address failed, %d\n",
- status);
+ if (status) {
+ dev_err(dev,
+ "%s:%d: lv1_net_add_multicast_address failed, %d\n",
+ __func__, __LINE__, status);
+ }
}
}
@@ -651,17 +671,17 @@ void gelic_net_set_multi(struct net_device *netdev)
*/
int gelic_net_stop(struct net_device *netdev)
{
- struct gelic_card *card;
+ struct gelic_card *card = netdev_card(netdev);
+ struct device *dev = ctodev(card);
- pr_debug("%s: start\n", __func__);
+ dev_dbg(dev, "%s:%d: >\n", __func__, __LINE__);
netif_stop_queue(netdev);
netif_carrier_off(netdev);
- card = netdev_card(netdev);
gelic_card_down(card);
- pr_debug("%s: done\n", __func__);
+ dev_dbg(dev, "%s:%d: <\n", __func__, __LINE__);
return 0;
}
@@ -764,6 +784,7 @@ static int gelic_descr_prepare_tx(struct gelic_card *card,
struct gelic_descr *descr,
struct sk_buff *skb)
{
+ struct device *dev = ctodev(card);
dma_addr_t cpu_addr;
if (card->vlan_required) {
@@ -778,12 +799,10 @@ static int gelic_descr_prepare_tx(struct gelic_card *card,
skb = skb_tmp;
}
- cpu_addr = dma_map_single(ctodev(card), skb->data, skb->len, DMA_TO_DEVICE);
+ cpu_addr = dma_map_single(dev, skb->data, skb->len, DMA_TO_DEVICE);
if (!cpu_addr) {
- dev_err(ctodev(card),
- "dma map 2 failed (%p, %i). Dropping packet\n",
- skb->data, skb->len);
+ dev_err(dev, "%s:%d: dma_mapping_error\n", __func__, __LINE__);
return -ENOMEM;
}
@@ -808,6 +827,7 @@ static int gelic_descr_prepare_tx(struct gelic_card *card,
static int gelic_card_kick_txdma(struct gelic_card *card,
struct gelic_descr *descr)
{
+ struct device *dev = ctodev(card);
int status = 0;
if (card->tx_dma_progress)
@@ -819,8 +839,8 @@ static int gelic_card_kick_txdma(struct gelic_card *card,
descr->link.cpu_addr, 0);
if (status) {
card->tx_dma_progress = 0;
- dev_info(ctodev(card), "lv1_net_start_txdma failed," \
- "status=%d\n", status);
+ dev_info(dev, "%s:%d: lv1_net_start_txdma failed: %d\n",
+ __func__, __LINE__, status);
}
}
return status;
@@ -836,6 +856,7 @@ static int gelic_card_kick_txdma(struct gelic_card *card,
netdev_tx_t gelic_net_xmit(struct sk_buff *skb, struct net_device *netdev)
{
struct gelic_card *card = netdev_card(netdev);
+ struct device *dev = ctodev(card);
struct gelic_descr *descr;
int result;
unsigned long flags;
@@ -888,7 +909,7 @@ netdev_tx_t gelic_net_xmit(struct sk_buff *skb, struct net_device *netdev)
card->tx_chain.head = descr;
/* reset hw termination */
descr->prev->hw_regs.next_descr_addr = 0;
- dev_info(ctodev(card), "%s: kick failure\n", __func__);
+ dev_info(dev, "%s:%d: kick failure\n", __func__, __LINE__);
}
spin_unlock_irqrestore(&card->tx_lock, flags);
@@ -909,24 +930,28 @@ static void gelic_net_pass_skb_up(struct gelic_descr *descr,
struct net_device *netdev)
{
+ struct device *dev = ctodev(card);
struct sk_buff *skb = descr->skb;
u32 data_status, data_error;
data_status = be32_to_cpu(descr->hw_regs.data_status);
data_error = be32_to_cpu(descr->hw_regs.data_error);
/* unmap skb buffer */
- dma_unmap_single(ctodev(card), be32_to_cpu(descr->hw_regs.payload.dev_addr),
+ dma_unmap_single(dev, be32_to_cpu(descr->hw_regs.payload.dev_addr),
GELIC_NET_MAX_MTU,
DMA_FROM_DEVICE);
skb_put(skb, be32_to_cpu(descr->hw_regs.valid_size)?
be32_to_cpu(descr->hw_regs.valid_size) :
be32_to_cpu(descr->hw_regs.result_size));
- if (!descr->hw_regs.valid_size)
- dev_info(ctodev(card), "buffer full %x %x %x\n",
+
+ if (!descr->hw_regs.valid_size) {
+ dev_err(dev, "%s:%d: buffer full %x %x %x\n", __func__,
+ __LINE__,
be32_to_cpu(descr->hw_regs.result_size),
be32_to_cpu(descr->hw_regs.payload.size),
be32_to_cpu(descr->hw_regs.dmac_cmd_status));
+ }
descr->skb = NULL;
/*
@@ -968,6 +993,7 @@ static int gelic_card_decode_one_descr(struct gelic_card *card)
enum gelic_descr_dma_status status;
struct gelic_descr_chain *chain = &card->rx_chain;
struct gelic_descr *descr = chain->head;
+ struct device *dev = ctodev(card);
struct net_device *netdev = NULL;
int dmac_chain_ended;
@@ -977,7 +1003,8 @@ static int gelic_card_decode_one_descr(struct gelic_card *card)
return 0;
if (status == GELIC_DESCR_DMA_NOT_IN_USE) {
- dev_dbg(ctodev(card), "dormant descr? %p\n", descr);
+ dev_dbg(dev, "%s:%d: dormant descr? %px\n", __func__, __LINE__,
+ descr);
return 0;
}
@@ -993,7 +1020,8 @@ static int gelic_card_decode_one_descr(struct gelic_card *card)
}
}
if (GELIC_PORT_MAX <= i) {
- pr_info("%s: unknown packet vid=%x\n", __func__, vid);
+ dev_info(dev, "%s:%d: unknown packet vid=%x\n",
+ __func__, __LINE__, vid);
goto refill;
}
} else
@@ -1002,8 +1030,8 @@ static int gelic_card_decode_one_descr(struct gelic_card *card)
if ((status == GELIC_DESCR_DMA_RESPONSE_ERROR) ||
(status == GELIC_DESCR_DMA_PROTECTION_ERROR) ||
(status == GELIC_DESCR_DMA_FORCE_END)) {
- dev_info(ctodev(card), "dropping RX descriptor with state %x\n",
- status);
+ dev_info(dev, "%s:%d: dropping RX descriptor with state %x\n",
+ __func__, __LINE__, status);
netdev->stats.rx_dropped++;
goto refill;
}
@@ -1018,7 +1046,7 @@ static int gelic_card_decode_one_descr(struct gelic_card *card)
* Anyway this frame was longer than the MTU,
* just drop it.
*/
- dev_info(ctodev(card), "overlength frame\n");
+ dev_info(dev, "%s:%d: overlength frame\n", __func__, __LINE__);
goto refill;
}
/*
@@ -1026,8 +1054,8 @@ static int gelic_card_decode_one_descr(struct gelic_card *card)
* be treated as error.
*/
if (status != GELIC_DESCR_DMA_FRAME_END) {
- dev_dbg(ctodev(card), "RX descriptor with state %x\n",
- status);
+ dev_dbg(dev, "%s:%d: RX descriptor with state %x\n", __func__,
+ __LINE__, status);
goto refill;
}
@@ -1174,14 +1202,11 @@ int gelic_net_open(struct net_device *netdev)
{
struct gelic_card *card = netdev_card(netdev);
- dev_dbg(ctodev(card), " -> %s %p\n", __func__, netdev);
-
gelic_card_up(card);
netif_start_queue(netdev);
gelic_card_get_ether_port_status(card, 1);
- dev_dbg(ctodev(card), " <- %s\n", __func__);
return 0;
}
@@ -1196,6 +1221,7 @@ static int gelic_ether_get_link_ksettings(struct net_device *netdev,
struct ethtool_link_ksettings *cmd)
{
struct gelic_card *card = netdev_card(netdev);
+ struct device *dev = ctodev(card);
u32 supported, advertising;
gelic_card_get_ether_port_status(card, 0);
@@ -1216,7 +1242,7 @@ static int gelic_ether_get_link_ksettings(struct net_device *netdev,
cmd->base.speed = SPEED_1000;
break;
default:
- pr_info("%s: speed unknown\n", __func__);
+ dev_dbg(dev, "%s:%d: speed unknown\n", __func__, __LINE__);
cmd->base.speed = SPEED_10;
break;
}
@@ -1247,6 +1273,7 @@ gelic_ether_set_link_ksettings(struct net_device *netdev,
const struct ethtool_link_ksettings *cmd)
{
struct gelic_card *card = netdev_card(netdev);
+ struct device *dev = ctodev(card);
u64 mode;
int ret;
@@ -1269,7 +1296,9 @@ gelic_ether_set_link_ksettings(struct net_device *netdev,
if (cmd->base.duplex == DUPLEX_FULL) {
mode |= GELIC_LV1_ETHER_FULL_DUPLEX;
} else if (cmd->base.speed == SPEED_1000) {
- pr_info("1000 half duplex is not supported.\n");
+ dev_dbg(dev,
+ "%s:%d: 1000 half duplex is not supported.\n",
+ __func__, __LINE__);
return -EINVAL;
}
}
@@ -1296,8 +1325,9 @@ static void gelic_net_get_wol(struct net_device *netdev,
static int gelic_net_set_wol(struct net_device *netdev,
struct ethtool_wolinfo *wol)
{
+ struct gelic_card *card = netdev_card(netdev);
+ struct device *dev = ctodev(card);
int status;
- struct gelic_card *card;
u64 v1, v2;
if (ps3_compare_firmware_version(2, 2, 0) < 0 ||
@@ -1307,7 +1337,6 @@ static int gelic_net_set_wol(struct net_device *netdev,
if (wol->wolopts & ~WAKE_MAGIC)
return -EINVAL;
- card = netdev_card(netdev);
if (wol->wolopts & WAKE_MAGIC) {
status = lv1_net_control(bus_id(card), dev_id(card),
GELIC_LV1_SET_WOL,
@@ -1315,8 +1344,8 @@ static int gelic_net_set_wol(struct net_device *netdev,
0, GELIC_LV1_WOL_MP_ENABLE,
&v1, &v2);
if (status) {
- pr_info("%s: enabling WOL failed %d\n", __func__,
- status);
+ dev_dbg(dev, "%s:%d: Enabling WOL failed: %d\n",
+ __func__, __LINE__, status);
status = -EIO;
goto done;
}
@@ -1328,8 +1357,8 @@ static int gelic_net_set_wol(struct net_device *netdev,
if (!status)
ps3_sys_manager_set_wol(1);
else {
- pr_info("%s: enabling WOL filter failed %d\n",
- __func__, status);
+ dev_dbg(dev, "%s:%d: Enabling WOL filter failed: %d\n",
+ __func__, __LINE__, status);
status = -EIO;
}
} else {
@@ -1339,8 +1368,8 @@ static int gelic_net_set_wol(struct net_device *netdev,
0, GELIC_LV1_WOL_MP_DISABLE,
&v1, &v2);
if (status) {
- pr_info("%s: disabling WOL failed %d\n", __func__,
- status);
+ dev_dbg(dev, "%s:%d: Disabling WOL failed: %d\n",
+ __func__, __LINE__, status);
status = -EIO;
goto done;
}
@@ -1352,8 +1381,8 @@ static int gelic_net_set_wol(struct net_device *netdev,
if (!status)
ps3_sys_manager_set_wol(0);
else {
- pr_info("%s: removing WOL filter failed %d\n",
- __func__, status);
+ dev_dbg(dev, "%s:%d: Removing WOL filter failed: %d\n",
+ __func__, __LINE__, status);
status = -EIO;
}
}
@@ -1382,8 +1411,9 @@ static void gelic_net_tx_timeout_task(struct work_struct *work)
struct gelic_card *card =
container_of(work, struct gelic_card, tx_timeout_task);
struct net_device *netdev = card->netdev[GELIC_PORT_ETHERNET_0];
+ struct device *dev = ctodev(card);
- dev_info(ctodev(card), "%s:Timed out. Restarting...\n", __func__);
+ dev_info(dev, "%s:%d: Timed out. Restarting...\n", __func__, __LINE__);
if (!(netdev->flags & IFF_UP))
goto out;
@@ -1459,6 +1489,7 @@ static void gelic_ether_setup_netdev_ops(struct net_device *netdev,
**/
int gelic_net_setup_netdev(struct net_device *netdev, struct gelic_card *card)
{
+ struct device *dev = ctodev(card);
int status;
u64 v1, v2;
@@ -1473,9 +1504,8 @@ int gelic_net_setup_netdev(struct net_device *netdev, struct gelic_card *card)
0, 0, 0, &v1, &v2);
v1 <<= 16;
if (status || !is_valid_ether_addr((u8 *)&v1)) {
- dev_info(ctodev(card),
- "%s:lv1_net_control GET_MAC_ADDR failed %d\n",
- __func__, status);
+ dev_dbg(dev, "%s:%d: lv1_net_control GET_MAC_ADDR failed: %d\n",
+ __func__, __LINE__, status);
return -EINVAL;
}
memcpy(netdev->dev_addr, &v1, ETH_ALEN);
@@ -1494,13 +1524,15 @@ int gelic_net_setup_netdev(struct net_device *netdev, struct gelic_card *card)
netdev->max_mtu = GELIC_NET_MAX_MTU;
status = register_netdev(netdev);
+
if (status) {
- dev_err(ctodev(card), "%s:Couldn't register %s %d\n",
- __func__, netdev->name, status);
+ dev_err(dev, "%s:%d: Couldn't register %s: %d\n", __func__,
+ __LINE__, netdev->name, status);
return status;
}
- dev_info(ctodev(card), "%s: MAC addr %pM\n",
- netdev->name, netdev->dev_addr);
+
+ dev_info(dev, "%s:%d: %s MAC addr %pxM\n", __func__, __LINE__,
+ netdev->name, netdev->dev_addr);
return 0;
}
@@ -1566,6 +1598,7 @@ static struct gelic_card *gelic_alloc_card_net(struct net_device **netdev)
static void gelic_card_get_vlan_info(struct gelic_card *card)
{
+ struct device *dev = ctodev(card);
u64 v1, v2;
int status;
unsigned int i;
@@ -1590,10 +1623,12 @@ static void gelic_card_get_vlan_info(struct gelic_card *card)
vlan_id_ix[i].tx,
0, 0, &v1, &v2);
if (status || !v1) {
- if (status != LV1_NO_ENTRY)
- dev_dbg(ctodev(card),
- "get vlan id for tx(%d) failed(%d)\n",
- vlan_id_ix[i].tx, status);
+ if (status != LV1_NO_ENTRY) {
+ dev_dbg(dev,
+ "%s:%d: Get vlan id for tx(%d) failed: %d\n",
+ __func__, __LINE__, vlan_id_ix[i].tx,
+ status);
+ }
card->vlan[i].tx = 0;
card->vlan[i].rx = 0;
continue;
@@ -1606,18 +1641,20 @@ static void gelic_card_get_vlan_info(struct gelic_card *card)
vlan_id_ix[i].rx,
0, 0, &v1, &v2);
if (status || !v1) {
- if (status != LV1_NO_ENTRY)
- dev_info(ctodev(card),
- "get vlan id for rx(%d) failed(%d)\n",
- vlan_id_ix[i].rx, status);
+ if (status != LV1_NO_ENTRY) {
+ dev_dbg(dev,
+ "%s:%d: Get vlan id for rx(%d) failed: %d\n",
+ __func__, __LINE__, vlan_id_ix[i].rx,
+ status);
+ }
card->vlan[i].tx = 0;
card->vlan[i].rx = 0;
continue;
}
card->vlan[i].rx = (u16)v1;
- dev_dbg(ctodev(card), "vlan_id[%d] tx=%02x rx=%02x\n",
- i, card->vlan[i].tx, card->vlan[i].rx);
+ dev_dbg(dev, "%s:%d: vlan_id[%d] tx=%02x rx=%02x\n", __func__,
+ __LINE__, i, card->vlan[i].tx, card->vlan[i].rx);
}
if (card->vlan[GELIC_PORT_ETHERNET_0].tx) {
@@ -1632,35 +1669,36 @@ static void gelic_card_get_vlan_info(struct gelic_card *card)
card->vlan[GELIC_PORT_WIRELESS].rx = 0;
}
- dev_info(ctodev(card), "internal vlan %s\n",
- card->vlan_required? "enabled" : "disabled");
+ dev_dbg(dev, "%s:%d: internal vlan %s\n", __func__, __LINE__,
+ card->vlan_required ? "enabled" : "disabled");
}
/*
* ps3_gelic_driver_probe - add a device to the control of this driver
*/
-static int ps3_gelic_driver_probe(struct ps3_system_bus_device *dev)
+static int ps3_gelic_driver_probe(struct ps3_system_bus_device *sb_dev)
{
+ struct device *dev = &sb_dev->core;
struct gelic_card *card;
struct net_device *netdev;
int result;
- pr_debug("%s: called\n", __func__);
+ dev_dbg(dev, "%s:%d: >\n", __func__, __LINE__);
udbg_shutdown_ps3gelic();
- result = ps3_open_hv_device(dev);
+ result = ps3_open_hv_device(sb_dev);
if (result) {
- dev_dbg(&dev->core, "%s:ps3_open_hv_device failed\n",
- __func__);
+ dev_err(dev, "%s:%d: ps3_open_hv_device failed: %d\n",
+ __func__, __LINE__, result);
goto fail_open;
}
- result = ps3_dma_region_create(dev->d_region);
+ result = ps3_dma_region_create(sb_dev->d_region);
if (result) {
- dev_dbg(&dev->core, "%s:ps3_dma_region_create failed(%d)\n",
- __func__, result);
+ dev_err(dev, "%s:%d: ps3_dma_region_create failed: %d\n",
+ __func__, __LINE__, result);
BUG_ON("check region type");
goto fail_dma_region;
}
@@ -1668,13 +1706,13 @@ static int ps3_gelic_driver_probe(struct ps3_system_bus_device *dev)
/* alloc card/netdevice */
card = gelic_alloc_card_net(&netdev);
if (!card) {
- dev_info(&dev->core, "%s:gelic_net_alloc_card failed\n",
- __func__);
+ dev_info(dev, "%s:%d: gelic_net_alloc_card failed.\n", __func__,
+ __LINE__);
result = -ENOMEM;
goto fail_alloc_card;
}
- ps3_system_bus_set_drvdata(dev, card);
- card->dev = dev;
+ ps3_system_bus_set_drvdata(sb_dev, card);
+ card->dev = sb_dev;
/* get internal vlan info */
gelic_card_get_vlan_info(card);
@@ -1688,20 +1726,19 @@ static int ps3_gelic_driver_probe(struct ps3_system_bus_device *dev)
0);
if (result) {
- dev_dbg(&dev->core,
- "%s:set_interrupt_status_indicator failed: %s\n",
- __func__, ps3_result(result));
+ dev_dbg(dev,
+ "%s:%d: set_interrupt_status_indicator failed: %s\n",
+ __func__, __LINE__, ps3_result(result));
result = -EIO;
goto fail_status_indicator;
}
- result = ps3_sb_event_receive_port_setup(dev, PS3_BINDING_CPU_ANY,
+ result = ps3_sb_event_receive_port_setup(sb_dev, PS3_BINDING_CPU_ANY,
&card->irq);
if (result) {
- dev_info(ctodev(card),
- "%s:gelic_net_open_device failed (%d)\n",
- __func__, result);
+ dev_dbg(dev, "%s:%d: gelic_net_open_device failed: %d\n",
+ __func__, __LINE__, result);
result = -EPERM;
goto fail_alloc_irq;
}
@@ -1709,8 +1746,8 @@ static int ps3_gelic_driver_probe(struct ps3_system_bus_device *dev)
0, netdev->name, card);
if (result) {
- dev_info(ctodev(card), "%s:request_irq failed (%d)\n",
- __func__, result);
+ dev_dbg(dev, "%s:%d: request_irq failed: %d\n",
+ __func__, __LINE__, result);
goto fail_request_irq;
}
@@ -1732,9 +1769,11 @@ static int ps3_gelic_driver_probe(struct ps3_system_bus_device *dev)
/* head of chain */
card->tx_top = card->tx_chain.head;
card->rx_top = card->rx_chain.head;
- dev_dbg(ctodev(card), "descr rx %p, tx %p, size %#lx, num %#x\n",
- card->rx_top, card->tx_top, sizeof(struct gelic_descr),
- GELIC_NET_RX_DESCRIPTORS);
+
+ dev_dbg(dev, "%s:%d: descr rx %px, tx %px, size %#lx, num %#x\n",
+ __func__, __LINE__, card->rx_top, card->tx_top,
+ sizeof(struct gelic_descr), GELIC_NET_RX_DESCRIPTORS);
+
/* allocate rx skbs */
result = gelic_card_alloc_rx_skbs(card);
if (result)
@@ -1745,23 +1784,23 @@ static int ps3_gelic_driver_probe(struct ps3_system_bus_device *dev)
/* setup net_device structure */
netdev->irq = card->irq;
- SET_NETDEV_DEV(netdev, &card->dev->core);
+ SET_NETDEV_DEV(netdev, dev);
gelic_ether_setup_netdev_ops(netdev, &card->napi);
result = gelic_net_setup_netdev(netdev, card);
if (result) {
- dev_dbg(&dev->core, "%s: setup_netdev failed %d\n",
- __func__, result);
+ dev_err(dev, "%s:%d: setup_netdev failed: %d\n", __func__,
+ __LINE__, result);
goto fail_setup_netdev;
}
#ifdef CONFIG_GELIC_WIRELESS
result = gelic_wl_driver_probe(card);
if (result) {
- dev_dbg(&dev->core, "%s: WL init failed\n", __func__);
+ dev_dbg(dev, "%s:%d: WL init failed\n", __func__, __LINE__);
goto fail_setup_netdev;
}
#endif
- pr_debug("%s: done\n", __func__);
+ dev_dbg(dev, "%s:%d: < OK\n", __func__, __LINE__);
return 0;
fail_setup_netdev:
@@ -1773,20 +1812,21 @@ static int ps3_gelic_driver_probe(struct ps3_system_bus_device *dev)
free_irq(card->irq, card);
netdev->irq = 0;
fail_request_irq:
- ps3_sb_event_receive_port_destroy(dev, card->irq);
+ ps3_sb_event_receive_port_destroy(sb_dev, card->irq);
fail_alloc_irq:
lv1_net_set_interrupt_status_indicator(bus_id(card),
bus_id(card),
0, 0);
fail_status_indicator:
- ps3_system_bus_set_drvdata(dev, NULL);
+ ps3_system_bus_set_drvdata(sb_dev, NULL);
kfree(netdev_card(netdev)->unalign);
free_netdev(netdev);
fail_alloc_card:
- ps3_dma_region_free(dev->d_region);
+ ps3_dma_region_free(sb_dev->d_region);
fail_dma_region:
- ps3_close_hv_device(dev);
+ ps3_close_hv_device(sb_dev);
fail_open:
+ dev_dbg(dev, "%s:%d: < error\n", __func__, __LINE__);
return result;
}
@@ -1794,11 +1834,13 @@ static int ps3_gelic_driver_probe(struct ps3_system_bus_device *dev)
* ps3_gelic_driver_remove - remove a device from the control of this driver
*/
-static void ps3_gelic_driver_remove(struct ps3_system_bus_device *dev)
+static void ps3_gelic_driver_remove(struct ps3_system_bus_device *sb_dev)
{
- struct gelic_card *card = ps3_system_bus_get_drvdata(dev);
+ struct gelic_card *card = ps3_system_bus_get_drvdata(sb_dev);
+ struct device *dev = &sb_dev->core;
struct net_device *netdev0;
- pr_debug("%s: called\n", __func__);
+
+ dev_dbg(dev, "%s:%d: >\n", __func__, __LINE__);
/* set auto-negotiation */
gelic_card_set_link_mode(card, GELIC_LV1_ETHER_AUTO_NEG);
@@ -1836,13 +1878,13 @@ static void ps3_gelic_driver_remove(struct ps3_system_bus_device *dev)
kfree(netdev_card(netdev0)->unalign);
free_netdev(netdev0);
- ps3_system_bus_set_drvdata(dev, NULL);
+ ps3_system_bus_set_drvdata(sb_dev, NULL);
- ps3_dma_region_free(dev->d_region);
+ ps3_dma_region_free(sb_dev->d_region);
- ps3_close_hv_device(dev);
+ ps3_close_hv_device(sb_dev);
- pr_debug("%s: done\n", __func__);
+ dev_dbg(dev, "%s:%d: <\n", __func__, __LINE__);
}
static struct ps3_system_bus_driver ps3_gelic_driver = {
--
2.25.1
^ permalink raw reply related
* Re: [PATCH v3 0/5] powerpc: apm82181: adding customer devices
From: Christian Lamparter @ 2021-07-23 22:08 UTC (permalink / raw)
To: Andy Shevchenko
Cc: devicetree, Chris Blake, Rob Herring, Paul Mackerras,
linuxppc-dev
In-Reply-To: <YPsWMRLWQoxHFub6@smile.fi.intel.com>
Hi Andy!
On 23/07/2021 21:19, Andy Shevchenko wrote:
> On Sun, Sep 06, 2020 at 12:06:10AM +0200, Christian Lamparter wrote:
>> I've been holding on to these devices dts' for a while now.
>> But ever since the recent purge of the PPC405, I'm feeling
>> the urge to move forward.
>>
>> The devices in question have been running with OpenWrt since
>> around 2016/2017. Back then it was linux v4.4 and required
>> many out-of-tree patches (for WIFI, SATA, CRYPTO...), that
>> since have been integrated. So, there's nothing else in the
>> way I think.
>>
>> A patch that adds the Meraki vendor-prefix has been sent
>> separately, as there's also the Meraki MR32 that I'm working
>> on as well. Here's the link to the patch:
>> <https://lore.kernel.org/linuxppc-dev/20200822154045.16036-1-chunkeey@gmail.com/>
>>
>> Now, I've looked around in the arch/powerpc for recent .dts
>> and device submissions to get an understanding of what is
>> required.
>> >From the looks of it, it seems like every device gets a
>> skeleton defconfig and a CONFIG_$DEVICE symbol (Like:
>> CONFIG_MERAKI_MR24, CONFIG_WD_MYBOOKLIVE).
>>
>> Will this be the case? Or would it make sense to further
>> unite the Bluestone, MR24 and MBL under a common CONFIG_APM82181
>> and integrate the BLUESTONE device's defconfig into it as well?
>> (I've stumbled across the special machine compatible
>> handling of ppc in the Documentation/devicetree/usage-model.rst
>> already.)
>
> I haven't found any traces of this to be applied. What is the status of this
> patch series? And what is the general state of affairs for the PPC44x?
My best guess is: It's complicated. While there was a recent big
UPSET EVENT regarding the My Book Live (MBL) that affected "hundreds"
and "thousands": "An unpleasant surprise for My Book Live owners"
(<https://lwn.net/Articles/861235/>). Sadly this wasn't getting any
traction.
I can tell that the mentioned Cisco Meraki MR32 (Broadcom ARM SoC)
got merged. So this is off the plate 😌.
But APM821xx sadly went nowhere 😕. One reason being that I haven't
yet posted a V4, V5 and so on...
In theory, for v4 I would have liked to know how to handle the
kConfig aspect of the series: Would it be "OK" to have a
single CONFIG_APM82181/CONFIG_APM821XX symbol or should there
be a CONFIG_MBL the CONFIG_MR24 (CONFIG_WNDR4700 and CONFIG_MX60W
in the future)?
As for the MBL: Well, If you (or any one else) is interested in
having a more up-to-date Debian. Then I have something:
A while back, I made a "build.sh". This will build a
"out-of-the-box" Debian unstable/SID powerpc system image.
This includes sensible NAS defaults + programs as well as
a Cockpit Web-GUI. But also makes it easily possible to do
the DTBs development on the latest vanilla (5.14-rc2 as of
the time of writing this) kernel for the
MyBook Live Single and Duo:
<https://github.com/chunkeey/mbl-debian>
I can't really make one for the MR24 though. Its 32MiB NAND
makes it difficult to install anything else than OpenWrt
(and get some use out of the device).
So, how to proceed?
Cheers,
Christian
PS.: As for PPC44x health regarding APM82181: It works!
This is with a My Book Live (MBL) and the 5.14.0-rc2(+) kernel.
[ 0.000000] printk: bootconsole [udbg0] enabled
[ 0.000000] Activating Kernel Userspace Execution Prevention
[ 0.000000] Linux version 5.14.0-rc2+ (root@debian64) (powerpc-linux-gnu-gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2) #1 Fri Jul 23 22:59:56 CEST 2021
[ 0.000000] Found initrd at 0xcf000000:0xcfe73b70
[ 0.000000] Using PowerPC 44x Platform machine description
[ 0.000000] -----------------------------------------------------
[ 0.000000] phys_mem_size = 0x10000000
[ 0.000000] dcache_bsize = 0x20
[ 0.000000] icache_bsize = 0x20
[ 0.000000] cpu_features = 0x0000000000000100
[ 0.000000] possible = 0x0000000040000100
[ 0.000000] always = 0x0000000000000100
[ 0.000000] cpu_user_features = 0x8c008000 0x00000000
[ 0.000000] mmu_features = 0x00000008
[ 0.000000] -----------------------------------------------------
[ 0.000000] Top of RAM: 0x10000000, Total RAM: 0x10000000
[ 0.000000] Memory hole size: 0MB
[ 0.000000] Zone ranges:
[ 0.000000] Normal [mem 0x0000000000000000-0x000000000fffffff]
[ 0.000000] Movable zone start for each node
[ 0.000000] Early memory node ranges
[ 0.000000] node 0: [mem 0x0000000000000000-0x000000000fffffff]
[ 0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x000000000fffffff]
[ 0.000000] MMU: Allocated 1088 bytes of context maps for 255 contexts
[ 0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[ 0.000000] pcpu-alloc: [0] 0
[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 16352
[ 0.000000] Kernel command line: root=UUID=ef4e8942-768b-4d2e-ba57-486397c97081 console=ttyS0,115200
[ 0.000000] Dentry cache hash table entries: 32768 (order: 3, 131072 bytes, linear)
[ 0.000000] Inode-cache hash table entries: 16384 (order: 2, 65536 bytes, linear)
[ 0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[ 0.000000] Kernel virtual memory layout:
[ 0.000000] * 0xffbdc000..0xffffc000 : fixmap
[ 0.000000] * 0xd1000000..0xffbdc000 : vmalloc & ioremap
[ 0.000000] Memory: 237088K/262144K available (6096K kernel code, 832K rwdata, 1888K rodata, 256K init, 338K bss, 25056K reserved, 0K cma-reserved)
[ 0.000000] random: get_random_u32 called from cache_random_seq_create+0x68/0x148 with crng_init=0
[ 0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[ 0.000000] NR_IRQS: 512, nr_irqs: 512, preallocated irqs: 16
[ 0.000000] UIC0 (32 IRQ sources) at DCR 0xc0
[ 0.000000] UIC1 (32 IRQ sources) at DCR 0xd0
[ 0.000000] UIC2 (32 IRQ sources) at DCR 0xe0
[ 0.000000] UIC3 (32 IRQ sources) at DCR 0xf0
[ 0.000000] time_init: decrementer frequency = 800.000008 MHz
[ 0.000000] time_init: processor frequency = 800.000008 MHz
[ 0.000008] clocksource: timebase: mask: 0xffffffffffffffff max_cycles: 0xb881274fa3, max_idle_ns: 440795210636 ns
[ 0.008985] clocksource: timebase mult[1400000] shift[24] registered
[ 0.014006] clockevent: decrementer mult[ccccccef] shift[32] cpu[0]
[ 0.019181] Console: colour dummy device 80x25
[ 0.022289] pid_max: default: 32768 minimum: 301
[ 0.025979] Mount-cache hash table entries: 4096 (order: 0, 16384 bytes, linear)
[ 0.032024] Mountpoint-cache hash table entries: 4096 (order: 0, 16384 bytes, linear)
[ 0.041291] devtmpfs: initialized
...
The "+" Patch is:
<https://github.com/chunkeey/mbl-debian/blob/master/patches/kernel/9999-powerpc-apm82181-add-WD-MyBook-Live-NAS.patch>
(which adds the "wd,mybooklive" to the list of
supported devices to ppc44x_simple.c)
^ permalink raw reply
* Re: [PATCH v4 03/10] net/ps3_gelic: Format cleanups
From: Christophe Leroy @ 2021-07-24 15:44 UTC (permalink / raw)
To: Geoff Levand; +Cc: netdev, linuxppc-dev, David S. Miller, Jakub Kicinski
In-Reply-To: <56efff53fcf563a1741904ea0f078d50c378b6cc.1627068552.git.geoff@infradead.org>
Geoff Levand <geoff@infradead.org> a écrit :
> In an effort to make the PS3 gelic driver easier to maintain, cleanup the
> the driver source file formatting to be more consistent.
Many of your changes in this patch go in the wrong direction.
For instance, you shall not use { } in an if/else sequence with single
lines in both the if and the else. See
https://www.kernel.org/doc/html/latest/process/coding-style.html#placing-braces-and-spaces
In a multiline operation, the argument of the second line must be
aligned to the matching parenthesis.
Christophe
^ permalink raw reply
* Re: [PATCH v4 02/10] net/ps3_gelic: Use local dev variable
From: Christophe Leroy @ 2021-07-24 15:51 UTC (permalink / raw)
To: Geoff Levand; +Cc: netdev, linuxppc-dev, David S. Miller, Jakub Kicinski
In-Reply-To: <26f56a1c8332d227156cd33586b176a329570117.1627068552.git.geoff@infradead.org>
Geoff Levand <geoff@infradead.org> a écrit :
> In an effort to make the PS3 gelic driver easier to maintain, add a
> local variable dev to those routines that use the device structure that
> makes the use the device structure more consistent.
>
> Signed-off-by: Geoff Levand <geoff@infradead.org>
> ---
> drivers/net/ethernet/toshiba/ps3_gelic_net.c | 340 +++++++++++--------
> 1 file changed, 191 insertions(+), 149 deletions(-)
>
> diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
> b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
> index cb45571573d7..ba008a98928a 100644
> --- a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
> +++ b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
> @@ -48,13 +48,15 @@ MODULE_LICENSE("GPL");
> /* set irq_mask */
> int gelic_card_set_irq_mask(struct gelic_card *card, u64 mask)
> {
> + struct device *dev = ctodev(card);
> int status;
>
> status = lv1_net_set_interrupt_mask(bus_id(card), dev_id(card),
> mask, 0);
> - if (status)
> - dev_info(ctodev(card),
> - "%s failed %d\n", __func__, status);
> + if (status) {
There shall be no { } for single line statements. And anyway this
change is not part of this patch as it is unrelated to the use of
local dev variable.
> + dev_err(dev, "%s:%d failed: %d\n", __func__, __LINE__, status);
> + }
> +
> return status;
> }
>
> @@ -103,6 +105,7 @@ gelic_descr_get_status(struct gelic_descr *descr)
>
> static int gelic_card_set_link_mode(struct gelic_card *card, int mode)
> {
> + struct device *dev = ctodev(card);
> int status;
> u64 v1, v2;
>
> @@ -110,8 +113,8 @@ static int gelic_card_set_link_mode(struct
> gelic_card *card, int mode)
> GELIC_LV1_SET_NEGOTIATION_MODE,
> GELIC_LV1_PHY_ETHERNET_0, mode, 0, &v1, &v2);
> if (status) {
> - pr_info("%s: failed setting negotiation mode %d\n", __func__,
> - status);
> + dev_err(dev, "%s:%d: Failed setting negotiation mode: %d\n",
> + __func__, __LINE__, status);
Changing from pr_info to dev_err is unrelated to the use of a dev local var
> return -EBUSY;
> }
>
> @@ -128,13 +131,15 @@ static int gelic_card_set_link_mode(struct
> gelic_card *card, int mode)
> */
> static void gelic_card_disable_txdmac(struct gelic_card *card)
> {
> + struct device *dev = ctodev(card);
> int status;
>
> /* this hvc blocks until the DMA in progress really stopped */
> status = lv1_net_stop_tx_dma(bus_id(card), dev_id(card));
> - if (status)
> - dev_err(ctodev(card),
> - "lv1_net_stop_tx_dma failed, status=%d\n", status);
> +
> + if (status) {
> + dev_err(dev, "lv1_net_stop_tx_dma failed, status=%d\n", status);
> + }
> }
>
> /**
> @@ -146,6 +151,7 @@ static void gelic_card_disable_txdmac(struct
> gelic_card *card)
> */
> static void gelic_card_enable_rxdmac(struct gelic_card *card)
> {
> + struct device *dev = ctodev(card);
> int status;
>
> #ifdef DEBUG
> @@ -161,9 +167,10 @@ static void gelic_card_enable_rxdmac(struct
> gelic_card *card)
> #endif
> status = lv1_net_start_rx_dma(bus_id(card), dev_id(card),
> card->rx_chain.head->link.cpu_addr, 0);
> - if (status)
> - dev_info(ctodev(card),
> - "lv1_net_start_rx_dma failed, status=%d\n", status);
> + if (status) {
> + dev_err(dev, "lv1_net_start_rx_dma failed, status=%d\n",
> + status);
> + }
> }
>
> /**
> @@ -175,13 +182,15 @@ static void gelic_card_enable_rxdmac(struct
> gelic_card *card)
> */
> static void gelic_card_disable_rxdmac(struct gelic_card *card)
> {
> + struct device *dev = ctodev(card);
> int status;
>
> /* this hvc blocks until the DMA in progress really stopped */
> status = lv1_net_stop_rx_dma(bus_id(card), dev_id(card));
> - if (status)
> - dev_err(ctodev(card),
> - "lv1_net_stop_rx_dma failed, %d\n", status);
> +
> + if (status) {
> + dev_err(dev, "lv1_net_stop_rx_dma failed, %d\n", status);
> + }
> }
>
> /**
> @@ -235,10 +244,11 @@ static void gelic_card_reset_chain(struct
> gelic_card *card,
>
> void gelic_card_up(struct gelic_card *card)
> {
> - pr_debug("%s: called\n", __func__);
> + struct device *dev = ctodev(card);
> +
> mutex_lock(&card->updown_lock);
> if (atomic_inc_return(&card->users) == 1) {
> - pr_debug("%s: real do\n", __func__);
> + dev_dbg(dev, "%s:%d: Starting...\n", __func__, __LINE__);
> /* enable irq */
> gelic_card_set_irq_mask(card, card->irq_mask);
> /* start rx */
> @@ -247,16 +257,16 @@ void gelic_card_up(struct gelic_card *card)
> napi_enable(&card->napi);
> }
> mutex_unlock(&card->updown_lock);
> - pr_debug("%s: done\n", __func__);
> }
>
> void gelic_card_down(struct gelic_card *card)
> {
> + struct device *dev = ctodev(card);
> u64 mask;
> - pr_debug("%s: called\n", __func__);
> +
> mutex_lock(&card->updown_lock);
> if (atomic_dec_if_positive(&card->users) == 0) {
> - pr_debug("%s: real do\n", __func__);
> + dev_dbg(dev, "%s:%d: Stopping...\n", __func__, __LINE__);
> napi_disable(&card->napi);
> /*
> * Disable irq. Wireless interrupts will
> @@ -273,7 +283,6 @@ void gelic_card_down(struct gelic_card *card)
> gelic_card_disable_txdmac(card);
> }
> mutex_unlock(&card->updown_lock);
> - pr_debug("%s: done\n", __func__);
> }
>
> /**
> @@ -284,11 +293,12 @@ void gelic_card_down(struct gelic_card *card)
> static void gelic_card_free_chain(struct gelic_card *card,
> struct gelic_descr *descr_in)
> {
> + struct device *dev = ctodev(card);
> struct gelic_descr *descr;
>
> for (descr = descr_in; descr && descr->link.cpu_addr; descr =
> descr->next) {
> - dma_unmap_single(ctodev(card), descr->link.cpu_addr,
> - descr->link.size, DMA_BIDIRECTIONAL);
> + dma_unmap_single(dev, descr->link.cpu_addr, descr->link.size,
> + DMA_BIDIRECTIONAL);
> descr->link.cpu_addr = 0;
> }
> }
> @@ -311,6 +321,7 @@ static int gelic_card_init_chain(struct gelic_card *card,
> {
> int i;
> struct gelic_descr *descr;
> + struct device *dev = ctodev(card);
>
> descr = start_descr;
> memset(descr, 0, sizeof(*descr) * no);
> @@ -320,9 +331,8 @@ static int gelic_card_init_chain(struct gelic_card *card,
> descr->link.size = sizeof(struct gelic_hw_regs);
> gelic_descr_set_status(descr, GELIC_DESCR_DMA_NOT_IN_USE);
> descr->link.cpu_addr =
> - dma_map_single(ctodev(card), descr,
> - descr->link.size,
> - DMA_BIDIRECTIONAL);
> + dma_map_single(dev, descr, descr->link.size,
> + DMA_BIDIRECTIONAL);
>
> if (!descr->link.cpu_addr)
> goto iommu_error;
> @@ -351,7 +361,7 @@ static int gelic_card_init_chain(struct gelic_card *card,
> iommu_error:
> for (i--, descr--; 0 <= i; i--, descr--)
> if (descr->link.cpu_addr)
> - dma_unmap_single(ctodev(card), descr->link.cpu_addr,
> + dma_unmap_single(dev, descr->link.cpu_addr,
> descr->link.size,
> DMA_BIDIRECTIONAL);
> return -ENOMEM;
> @@ -370,11 +380,14 @@ static int gelic_card_init_chain(struct
> gelic_card *card,
> static int gelic_descr_prepare_rx(struct gelic_card *card,
> struct gelic_descr *descr)
> {
> + struct device *dev = ctodev(card);
> int offset;
> unsigned int bufsize;
>
> - if (gelic_descr_get_status(descr) != GELIC_DESCR_DMA_NOT_IN_USE)
> - dev_info(ctodev(card), "%s: ERROR status\n", __func__);
> + if (gelic_descr_get_status(descr) != GELIC_DESCR_DMA_NOT_IN_USE) {
> + dev_err(dev, "%s:%d: ERROR status\n", __func__, __LINE__);
> + }
> +
> /* we need to round up the buffer size to a multiple of 128 */
> bufsize = ALIGN(GELIC_NET_MAX_MTU, GELIC_NET_RXBUF_ALIGN);
>
> @@ -396,14 +409,14 @@ static int gelic_descr_prepare_rx(struct
> gelic_card *card,
> if (offset)
> skb_reserve(descr->skb, GELIC_NET_RXBUF_ALIGN - offset);
> /* io-mmu-map the skb */
> - descr->hw_regs.payload.dev_addr = cpu_to_be32(dma_map_single(ctodev(card),
> + descr->hw_regs.payload.dev_addr = cpu_to_be32(dma_map_single(dev,
> descr->skb->data,
> GELIC_NET_MAX_MTU,
> DMA_FROM_DEVICE));
> if (!descr->hw_regs.payload.dev_addr) {
> dev_kfree_skb_any(descr->skb);
> descr->skb = NULL;
> - dev_info(ctodev(card),
> + dev_info(dev,
> "%s:Could not iommu-map rx buffer\n", __func__);
> gelic_descr_set_status(descr, GELIC_DESCR_DMA_NOT_IN_USE);
> return -ENOMEM;
> @@ -421,10 +434,11 @@ static int gelic_descr_prepare_rx(struct
> gelic_card *card,
> static void gelic_card_release_rx_chain(struct gelic_card *card)
> {
> struct gelic_descr *descr = card->rx_chain.head;
> + struct device *dev = ctodev(card);
>
> do {
> if (descr->skb) {
> - dma_unmap_single(ctodev(card),
> + dma_unmap_single(dev,
> be32_to_cpu(descr->hw_regs.payload.dev_addr),
> descr->skb->len,
> DMA_FROM_DEVICE);
> @@ -493,10 +507,11 @@ static void gelic_descr_release_tx(struct
> gelic_card *card,
> struct gelic_descr *descr)
> {
> struct sk_buff *skb = descr->skb;
> + struct device *dev = ctodev(card);
>
> BUG_ON(!(be32_to_cpu(descr->hw_regs.data_status) & GELIC_DESCR_TX_TAIL));
>
> - dma_unmap_single(ctodev(card),
> be32_to_cpu(descr->hw_regs.payload.dev_addr), skb->len,
> + dma_unmap_single(dev,
> be32_to_cpu(descr->hw_regs.payload.dev_addr), skb->len,
> DMA_TO_DEVICE);
> dev_kfree_skb_any(skb);
>
> @@ -538,6 +553,7 @@ static void gelic_card_release_tx_chain(struct
> gelic_card *card, int stop)
> {
> struct gelic_descr_chain *tx_chain;
> enum gelic_descr_dma_status status;
> + struct device *dev = ctodev(card);
> struct net_device *netdev;
> int release = 0;
>
> @@ -550,11 +566,9 @@ static void gelic_card_release_tx_chain(struct
> gelic_card *card, int stop)
> case GELIC_DESCR_DMA_RESPONSE_ERROR:
> case GELIC_DESCR_DMA_PROTECTION_ERROR:
> case GELIC_DESCR_DMA_FORCE_END:
> - if (printk_ratelimit())
> - dev_info(ctodev(card),
> - "%s: forcing end of tx descriptor " \
> - "with status %x\n",
> - __func__, status);
> + dev_info_ratelimited(dev,
Unrelated change
> + "%s:%d: forcing end of tx descriptor with status %x\n",
> + __func__, __LINE__, status);
> netdev->stats.tx_dropped++;
> break;
>
> @@ -592,6 +606,7 @@ static void gelic_card_release_tx_chain(struct
> gelic_card *card, int stop)
> void gelic_net_set_multi(struct net_device *netdev)
> {
> struct gelic_card *card = netdev_card(netdev);
> + struct device *dev = ctodev(card);
> struct netdev_hw_addr *ha;
> unsigned int i;
> uint8_t *p;
> @@ -601,27 +616,31 @@ void gelic_net_set_multi(struct net_device *netdev)
> /* clear all multicast address */
> status = lv1_net_remove_multicast_address(bus_id(card), dev_id(card),
> 0, 1);
> - if (status)
> - dev_err(ctodev(card),
> - "lv1_net_remove_multicast_address failed %d\n",
> - status);
> + if (status) {
> + dev_err(dev,
> + "%s:%d: lv1_net_remove_multicast_address failed %d\n",
> + __func__, __LINE__, status);
> + }
> +
> /* set broadcast address */
> status = lv1_net_add_multicast_address(bus_id(card), dev_id(card),
> GELIC_NET_BROADCAST_ADDR, 0);
> - if (status)
> - dev_err(ctodev(card),
> - "lv1_net_add_multicast_address failed, %d\n",
> - status);
> + if (status) {
> + dev_err(dev,
> + "%s:%d: lv1_net_add_multicast_address failed, %d\n",
> + __func__, __LINE__, status);
> + }
>
> if ((netdev->flags & IFF_ALLMULTI) ||
> (netdev_mc_count(netdev) > GELIC_NET_MC_COUNT_MAX)) {
> status = lv1_net_add_multicast_address(bus_id(card),
> dev_id(card),
> 0, 1);
> - if (status)
> - dev_err(ctodev(card),
> - "lv1_net_add_multicast_address failed, %d\n",
> - status);
> + if (status) {
> + dev_err(dev,
> + "%s:%d: lv1_net_add_multicast_address failed, %d\n",
> + __func__, __LINE__, status);
> + }
> return;
> }
>
> @@ -636,10 +655,11 @@ void gelic_net_set_multi(struct net_device *netdev)
> status = lv1_net_add_multicast_address(bus_id(card),
> dev_id(card),
> addr, 0);
> - if (status)
> - dev_err(ctodev(card),
> - "lv1_net_add_multicast_address failed, %d\n",
> - status);
> + if (status) {
> + dev_err(dev,
> + "%s:%d: lv1_net_add_multicast_address failed, %d\n",
> + __func__, __LINE__, status);
> + }
> }
> }
>
> @@ -651,17 +671,17 @@ void gelic_net_set_multi(struct net_device *netdev)
> */
> int gelic_net_stop(struct net_device *netdev)
> {
> - struct gelic_card *card;
> + struct gelic_card *card = netdev_card(netdev);
> + struct device *dev = ctodev(card);
>
> - pr_debug("%s: start\n", __func__);
> + dev_dbg(dev, "%s:%d: >\n", __func__, __LINE__);
>
> netif_stop_queue(netdev);
> netif_carrier_off(netdev);
>
> - card = netdev_card(netdev);
> gelic_card_down(card);
>
> - pr_debug("%s: done\n", __func__);
> + dev_dbg(dev, "%s:%d: <\n", __func__, __LINE__);
> return 0;
> }
>
> @@ -764,6 +784,7 @@ static int gelic_descr_prepare_tx(struct
> gelic_card *card,
> struct gelic_descr *descr,
> struct sk_buff *skb)
> {
> + struct device *dev = ctodev(card);
> dma_addr_t cpu_addr;
>
> if (card->vlan_required) {
> @@ -778,12 +799,10 @@ static int gelic_descr_prepare_tx(struct
> gelic_card *card,
> skb = skb_tmp;
> }
>
> - cpu_addr = dma_map_single(ctodev(card), skb->data, skb->len,
> DMA_TO_DEVICE);
> + cpu_addr = dma_map_single(dev, skb->data, skb->len, DMA_TO_DEVICE);
>
> if (!cpu_addr) {
> - dev_err(ctodev(card),
> - "dma map 2 failed (%p, %i). Dropping packet\n",
> - skb->data, skb->len);
> + dev_err(dev, "%s:%d: dma_mapping_error\n", __func__, __LINE__);
> return -ENOMEM;
> }
>
> @@ -808,6 +827,7 @@ static int gelic_descr_prepare_tx(struct
> gelic_card *card,
> static int gelic_card_kick_txdma(struct gelic_card *card,
> struct gelic_descr *descr)
> {
> + struct device *dev = ctodev(card);
> int status = 0;
>
> if (card->tx_dma_progress)
> @@ -819,8 +839,8 @@ static int gelic_card_kick_txdma(struct gelic_card *card,
> descr->link.cpu_addr, 0);
> if (status) {
> card->tx_dma_progress = 0;
> - dev_info(ctodev(card), "lv1_net_start_txdma failed," \
> - "status=%d\n", status);
> + dev_info(dev, "%s:%d: lv1_net_start_txdma failed: %d\n",
> + __func__, __LINE__, status);
> }
> }
> return status;
> @@ -836,6 +856,7 @@ static int gelic_card_kick_txdma(struct gelic_card *card,
> netdev_tx_t gelic_net_xmit(struct sk_buff *skb, struct net_device *netdev)
> {
> struct gelic_card *card = netdev_card(netdev);
> + struct device *dev = ctodev(card);
> struct gelic_descr *descr;
> int result;
> unsigned long flags;
> @@ -888,7 +909,7 @@ netdev_tx_t gelic_net_xmit(struct sk_buff *skb,
> struct net_device *netdev)
> card->tx_chain.head = descr;
> /* reset hw termination */
> descr->prev->hw_regs.next_descr_addr = 0;
> - dev_info(ctodev(card), "%s: kick failure\n", __func__);
> + dev_info(dev, "%s:%d: kick failure\n", __func__, __LINE__);
> }
>
> spin_unlock_irqrestore(&card->tx_lock, flags);
> @@ -909,24 +930,28 @@ static void gelic_net_pass_skb_up(struct
> gelic_descr *descr,
> struct net_device *netdev)
>
> {
> + struct device *dev = ctodev(card);
> struct sk_buff *skb = descr->skb;
> u32 data_status, data_error;
>
> data_status = be32_to_cpu(descr->hw_regs.data_status);
> data_error = be32_to_cpu(descr->hw_regs.data_error);
> /* unmap skb buffer */
> - dma_unmap_single(ctodev(card),
> be32_to_cpu(descr->hw_regs.payload.dev_addr),
> + dma_unmap_single(dev, be32_to_cpu(descr->hw_regs.payload.dev_addr),
> GELIC_NET_MAX_MTU,
> DMA_FROM_DEVICE);
>
> skb_put(skb, be32_to_cpu(descr->hw_regs.valid_size)?
> be32_to_cpu(descr->hw_regs.valid_size) :
> be32_to_cpu(descr->hw_regs.result_size));
> - if (!descr->hw_regs.valid_size)
> - dev_info(ctodev(card), "buffer full %x %x %x\n",
> +
> + if (!descr->hw_regs.valid_size) {
> + dev_err(dev, "%s:%d: buffer full %x %x %x\n", __func__,
> + __LINE__,
> be32_to_cpu(descr->hw_regs.result_size),
> be32_to_cpu(descr->hw_regs.payload.size),
> be32_to_cpu(descr->hw_regs.dmac_cmd_status));
> + }
>
> descr->skb = NULL;
> /*
> @@ -968,6 +993,7 @@ static int gelic_card_decode_one_descr(struct
> gelic_card *card)
> enum gelic_descr_dma_status status;
> struct gelic_descr_chain *chain = &card->rx_chain;
> struct gelic_descr *descr = chain->head;
> + struct device *dev = ctodev(card);
> struct net_device *netdev = NULL;
> int dmac_chain_ended;
>
> @@ -977,7 +1003,8 @@ static int gelic_card_decode_one_descr(struct
> gelic_card *card)
> return 0;
>
> if (status == GELIC_DESCR_DMA_NOT_IN_USE) {
> - dev_dbg(ctodev(card), "dormant descr? %p\n", descr);
> + dev_dbg(dev, "%s:%d: dormant descr? %px\n", __func__, __LINE__,
> + descr);
> return 0;
> }
>
> @@ -993,7 +1020,8 @@ static int gelic_card_decode_one_descr(struct
> gelic_card *card)
> }
> }
> if (GELIC_PORT_MAX <= i) {
> - pr_info("%s: unknown packet vid=%x\n", __func__, vid);
> + dev_info(dev, "%s:%d: unknown packet vid=%x\n",
> + __func__, __LINE__, vid);
> goto refill;
> }
> } else
> @@ -1002,8 +1030,8 @@ static int gelic_card_decode_one_descr(struct
> gelic_card *card)
> if ((status == GELIC_DESCR_DMA_RESPONSE_ERROR) ||
> (status == GELIC_DESCR_DMA_PROTECTION_ERROR) ||
> (status == GELIC_DESCR_DMA_FORCE_END)) {
> - dev_info(ctodev(card), "dropping RX descriptor with state %x\n",
> - status);
> + dev_info(dev, "%s:%d: dropping RX descriptor with state %x\n",
> + __func__, __LINE__, status);
> netdev->stats.rx_dropped++;
> goto refill;
> }
> @@ -1018,7 +1046,7 @@ static int gelic_card_decode_one_descr(struct
> gelic_card *card)
> * Anyway this frame was longer than the MTU,
> * just drop it.
> */
> - dev_info(ctodev(card), "overlength frame\n");
> + dev_info(dev, "%s:%d: overlength frame\n", __func__, __LINE__);
> goto refill;
> }
> /*
> @@ -1026,8 +1054,8 @@ static int gelic_card_decode_one_descr(struct
> gelic_card *card)
> * be treated as error.
> */
> if (status != GELIC_DESCR_DMA_FRAME_END) {
> - dev_dbg(ctodev(card), "RX descriptor with state %x\n",
> - status);
> + dev_dbg(dev, "%s:%d: RX descriptor with state %x\n", __func__,
> + __LINE__, status);
> goto refill;
> }
>
> @@ -1174,14 +1202,11 @@ int gelic_net_open(struct net_device *netdev)
> {
> struct gelic_card *card = netdev_card(netdev);
>
> - dev_dbg(ctodev(card), " -> %s %p\n", __func__, netdev);
> -
> gelic_card_up(card);
>
> netif_start_queue(netdev);
> gelic_card_get_ether_port_status(card, 1);
>
> - dev_dbg(ctodev(card), " <- %s\n", __func__);
> return 0;
> }
>
> @@ -1196,6 +1221,7 @@ static int
> gelic_ether_get_link_ksettings(struct net_device *netdev,
> struct ethtool_link_ksettings *cmd)
> {
> struct gelic_card *card = netdev_card(netdev);
> + struct device *dev = ctodev(card);
> u32 supported, advertising;
>
> gelic_card_get_ether_port_status(card, 0);
> @@ -1216,7 +1242,7 @@ static int
> gelic_ether_get_link_ksettings(struct net_device *netdev,
> cmd->base.speed = SPEED_1000;
> break;
> default:
> - pr_info("%s: speed unknown\n", __func__);
> + dev_dbg(dev, "%s:%d: speed unknown\n", __func__, __LINE__);
> cmd->base.speed = SPEED_10;
> break;
> }
> @@ -1247,6 +1273,7 @@ gelic_ether_set_link_ksettings(struct
> net_device *netdev,
> const struct ethtool_link_ksettings *cmd)
> {
> struct gelic_card *card = netdev_card(netdev);
> + struct device *dev = ctodev(card);
> u64 mode;
> int ret;
>
> @@ -1269,7 +1296,9 @@ gelic_ether_set_link_ksettings(struct
> net_device *netdev,
> if (cmd->base.duplex == DUPLEX_FULL) {
> mode |= GELIC_LV1_ETHER_FULL_DUPLEX;
> } else if (cmd->base.speed == SPEED_1000) {
> - pr_info("1000 half duplex is not supported.\n");
> + dev_dbg(dev,
> + "%s:%d: 1000 half duplex is not supported.\n",
> + __func__, __LINE__);
> return -EINVAL;
> }
> }
> @@ -1296,8 +1325,9 @@ static void gelic_net_get_wol(struct
> net_device *netdev,
> static int gelic_net_set_wol(struct net_device *netdev,
> struct ethtool_wolinfo *wol)
> {
> + struct gelic_card *card = netdev_card(netdev);
> + struct device *dev = ctodev(card);
> int status;
> - struct gelic_card *card;
> u64 v1, v2;
>
> if (ps3_compare_firmware_version(2, 2, 0) < 0 ||
> @@ -1307,7 +1337,6 @@ static int gelic_net_set_wol(struct net_device *netdev,
> if (wol->wolopts & ~WAKE_MAGIC)
> return -EINVAL;
>
> - card = netdev_card(netdev);
> if (wol->wolopts & WAKE_MAGIC) {
> status = lv1_net_control(bus_id(card), dev_id(card),
> GELIC_LV1_SET_WOL,
> @@ -1315,8 +1344,8 @@ static int gelic_net_set_wol(struct net_device *netdev,
> 0, GELIC_LV1_WOL_MP_ENABLE,
> &v1, &v2);
> if (status) {
> - pr_info("%s: enabling WOL failed %d\n", __func__,
> - status);
> + dev_dbg(dev, "%s:%d: Enabling WOL failed: %d\n",
> + __func__, __LINE__, status);
> status = -EIO;
> goto done;
> }
> @@ -1328,8 +1357,8 @@ static int gelic_net_set_wol(struct net_device *netdev,
> if (!status)
> ps3_sys_manager_set_wol(1);
> else {
> - pr_info("%s: enabling WOL filter failed %d\n",
> - __func__, status);
> + dev_dbg(dev, "%s:%d: Enabling WOL filter failed: %d\n",
> + __func__, __LINE__, status);
> status = -EIO;
> }
> } else {
> @@ -1339,8 +1368,8 @@ static int gelic_net_set_wol(struct net_device *netdev,
> 0, GELIC_LV1_WOL_MP_DISABLE,
> &v1, &v2);
> if (status) {
> - pr_info("%s: disabling WOL failed %d\n", __func__,
> - status);
> + dev_dbg(dev, "%s:%d: Disabling WOL failed: %d\n",
> + __func__, __LINE__, status);
> status = -EIO;
> goto done;
> }
> @@ -1352,8 +1381,8 @@ static int gelic_net_set_wol(struct net_device *netdev,
> if (!status)
> ps3_sys_manager_set_wol(0);
> else {
> - pr_info("%s: removing WOL filter failed %d\n",
> - __func__, status);
> + dev_dbg(dev, "%s:%d: Removing WOL filter failed: %d\n",
> + __func__, __LINE__, status);
> status = -EIO;
> }
> }
> @@ -1382,8 +1411,9 @@ static void gelic_net_tx_timeout_task(struct
> work_struct *work)
> struct gelic_card *card =
> container_of(work, struct gelic_card, tx_timeout_task);
> struct net_device *netdev = card->netdev[GELIC_PORT_ETHERNET_0];
> + struct device *dev = ctodev(card);
>
> - dev_info(ctodev(card), "%s:Timed out. Restarting...\n", __func__);
> + dev_info(dev, "%s:%d: Timed out. Restarting...\n", __func__, __LINE__);
>
> if (!(netdev->flags & IFF_UP))
> goto out;
> @@ -1459,6 +1489,7 @@ static void
> gelic_ether_setup_netdev_ops(struct net_device *netdev,
> **/
> int gelic_net_setup_netdev(struct net_device *netdev, struct
> gelic_card *card)
> {
> + struct device *dev = ctodev(card);
> int status;
> u64 v1, v2;
>
> @@ -1473,9 +1504,8 @@ int gelic_net_setup_netdev(struct net_device
> *netdev, struct gelic_card *card)
> 0, 0, 0, &v1, &v2);
> v1 <<= 16;
> if (status || !is_valid_ether_addr((u8 *)&v1)) {
> - dev_info(ctodev(card),
> - "%s:lv1_net_control GET_MAC_ADDR failed %d\n",
> - __func__, status);
> + dev_dbg(dev, "%s:%d: lv1_net_control GET_MAC_ADDR failed: %d\n",
> + __func__, __LINE__, status);
> return -EINVAL;
> }
> memcpy(netdev->dev_addr, &v1, ETH_ALEN);
> @@ -1494,13 +1524,15 @@ int gelic_net_setup_netdev(struct net_device
> *netdev, struct gelic_card *card)
> netdev->max_mtu = GELIC_NET_MAX_MTU;
>
> status = register_netdev(netdev);
> +
> if (status) {
> - dev_err(ctodev(card), "%s:Couldn't register %s %d\n",
> - __func__, netdev->name, status);
> + dev_err(dev, "%s:%d: Couldn't register %s: %d\n", __func__,
> + __LINE__, netdev->name, status);
> return status;
> }
> - dev_info(ctodev(card), "%s: MAC addr %pM\n",
> - netdev->name, netdev->dev_addr);
> +
> + dev_info(dev, "%s:%d: %s MAC addr %pxM\n", __func__, __LINE__,
> + netdev->name, netdev->dev_addr);
>
> return 0;
> }
> @@ -1566,6 +1598,7 @@ static struct gelic_card
> *gelic_alloc_card_net(struct net_device **netdev)
>
> static void gelic_card_get_vlan_info(struct gelic_card *card)
> {
> + struct device *dev = ctodev(card);
> u64 v1, v2;
> int status;
> unsigned int i;
> @@ -1590,10 +1623,12 @@ static void gelic_card_get_vlan_info(struct
> gelic_card *card)
> vlan_id_ix[i].tx,
> 0, 0, &v1, &v2);
> if (status || !v1) {
> - if (status != LV1_NO_ENTRY)
> - dev_dbg(ctodev(card),
> - "get vlan id for tx(%d) failed(%d)\n",
> - vlan_id_ix[i].tx, status);
> + if (status != LV1_NO_ENTRY) {
> + dev_dbg(dev,
> + "%s:%d: Get vlan id for tx(%d) failed: %d\n",
> + __func__, __LINE__, vlan_id_ix[i].tx,
> + status);
> + }
> card->vlan[i].tx = 0;
> card->vlan[i].rx = 0;
> continue;
> @@ -1606,18 +1641,20 @@ static void gelic_card_get_vlan_info(struct
> gelic_card *card)
> vlan_id_ix[i].rx,
> 0, 0, &v1, &v2);
> if (status || !v1) {
> - if (status != LV1_NO_ENTRY)
> - dev_info(ctodev(card),
> - "get vlan id for rx(%d) failed(%d)\n",
> - vlan_id_ix[i].rx, status);
> + if (status != LV1_NO_ENTRY) {
> + dev_dbg(dev,
> + "%s:%d: Get vlan id for rx(%d) failed: %d\n",
> + __func__, __LINE__, vlan_id_ix[i].rx,
> + status);
> + }
> card->vlan[i].tx = 0;
> card->vlan[i].rx = 0;
> continue;
> }
> card->vlan[i].rx = (u16)v1;
>
> - dev_dbg(ctodev(card), "vlan_id[%d] tx=%02x rx=%02x\n",
> - i, card->vlan[i].tx, card->vlan[i].rx);
> + dev_dbg(dev, "%s:%d: vlan_id[%d] tx=%02x rx=%02x\n", __func__,
> + __LINE__, i, card->vlan[i].tx, card->vlan[i].rx);
> }
>
> if (card->vlan[GELIC_PORT_ETHERNET_0].tx) {
> @@ -1632,35 +1669,36 @@ static void gelic_card_get_vlan_info(struct
> gelic_card *card)
> card->vlan[GELIC_PORT_WIRELESS].rx = 0;
> }
>
> - dev_info(ctodev(card), "internal vlan %s\n",
> - card->vlan_required? "enabled" : "disabled");
> + dev_dbg(dev, "%s:%d: internal vlan %s\n", __func__, __LINE__,
> + card->vlan_required ? "enabled" : "disabled");
> }
> /*
> * ps3_gelic_driver_probe - add a device to the control of this driver
> */
> -static int ps3_gelic_driver_probe(struct ps3_system_bus_device *dev)
> +static int ps3_gelic_driver_probe(struct ps3_system_bus_device *sb_dev)
> {
> + struct device *dev = &sb_dev->core;
> struct gelic_card *card;
> struct net_device *netdev;
> int result;
>
> - pr_debug("%s: called\n", __func__);
> + dev_dbg(dev, "%s:%d: >\n", __func__, __LINE__);
>
> udbg_shutdown_ps3gelic();
>
> - result = ps3_open_hv_device(dev);
> + result = ps3_open_hv_device(sb_dev);
>
> if (result) {
> - dev_dbg(&dev->core, "%s:ps3_open_hv_device failed\n",
> - __func__);
> + dev_err(dev, "%s:%d: ps3_open_hv_device failed: %d\n",
> + __func__, __LINE__, result);
> goto fail_open;
> }
>
> - result = ps3_dma_region_create(dev->d_region);
> + result = ps3_dma_region_create(sb_dev->d_region);
>
> if (result) {
> - dev_dbg(&dev->core, "%s:ps3_dma_region_create failed(%d)\n",
> - __func__, result);
> + dev_err(dev, "%s:%d: ps3_dma_region_create failed: %d\n",
> + __func__, __LINE__, result);
> BUG_ON("check region type");
> goto fail_dma_region;
> }
> @@ -1668,13 +1706,13 @@ static int ps3_gelic_driver_probe(struct
> ps3_system_bus_device *dev)
> /* alloc card/netdevice */
> card = gelic_alloc_card_net(&netdev);
> if (!card) {
> - dev_info(&dev->core, "%s:gelic_net_alloc_card failed\n",
> - __func__);
> + dev_info(dev, "%s:%d: gelic_net_alloc_card failed.\n", __func__,
> + __LINE__);
> result = -ENOMEM;
> goto fail_alloc_card;
> }
> - ps3_system_bus_set_drvdata(dev, card);
> - card->dev = dev;
> + ps3_system_bus_set_drvdata(sb_dev, card);
> + card->dev = sb_dev;
>
> /* get internal vlan info */
> gelic_card_get_vlan_info(card);
> @@ -1688,20 +1726,19 @@ static int ps3_gelic_driver_probe(struct
> ps3_system_bus_device *dev)
> 0);
>
> if (result) {
> - dev_dbg(&dev->core,
> - "%s:set_interrupt_status_indicator failed: %s\n",
> - __func__, ps3_result(result));
> + dev_dbg(dev,
> + "%s:%d: set_interrupt_status_indicator failed: %s\n",
> + __func__, __LINE__, ps3_result(result));
> result = -EIO;
> goto fail_status_indicator;
> }
>
> - result = ps3_sb_event_receive_port_setup(dev, PS3_BINDING_CPU_ANY,
> + result = ps3_sb_event_receive_port_setup(sb_dev, PS3_BINDING_CPU_ANY,
> &card->irq);
>
> if (result) {
> - dev_info(ctodev(card),
> - "%s:gelic_net_open_device failed (%d)\n",
> - __func__, result);
> + dev_dbg(dev, "%s:%d: gelic_net_open_device failed: %d\n",
> + __func__, __LINE__, result);
> result = -EPERM;
> goto fail_alloc_irq;
> }
> @@ -1709,8 +1746,8 @@ static int ps3_gelic_driver_probe(struct
> ps3_system_bus_device *dev)
> 0, netdev->name, card);
>
> if (result) {
> - dev_info(ctodev(card), "%s:request_irq failed (%d)\n",
> - __func__, result);
> + dev_dbg(dev, "%s:%d: request_irq failed: %d\n",
> + __func__, __LINE__, result);
> goto fail_request_irq;
> }
>
> @@ -1732,9 +1769,11 @@ static int ps3_gelic_driver_probe(struct
> ps3_system_bus_device *dev)
> /* head of chain */
> card->tx_top = card->tx_chain.head;
> card->rx_top = card->rx_chain.head;
> - dev_dbg(ctodev(card), "descr rx %p, tx %p, size %#lx, num %#x\n",
> - card->rx_top, card->tx_top, sizeof(struct gelic_descr),
> - GELIC_NET_RX_DESCRIPTORS);
> +
> + dev_dbg(dev, "%s:%d: descr rx %px, tx %px, size %#lx, num %#x\n",
> + __func__, __LINE__, card->rx_top, card->tx_top,
> + sizeof(struct gelic_descr), GELIC_NET_RX_DESCRIPTORS);
> +
> /* allocate rx skbs */
> result = gelic_card_alloc_rx_skbs(card);
> if (result)
> @@ -1745,23 +1784,23 @@ static int ps3_gelic_driver_probe(struct
> ps3_system_bus_device *dev)
>
> /* setup net_device structure */
> netdev->irq = card->irq;
> - SET_NETDEV_DEV(netdev, &card->dev->core);
> + SET_NETDEV_DEV(netdev, dev);
> gelic_ether_setup_netdev_ops(netdev, &card->napi);
> result = gelic_net_setup_netdev(netdev, card);
> if (result) {
> - dev_dbg(&dev->core, "%s: setup_netdev failed %d\n",
> - __func__, result);
> + dev_err(dev, "%s:%d: setup_netdev failed: %d\n", __func__,
> + __LINE__, result);
> goto fail_setup_netdev;
> }
>
> #ifdef CONFIG_GELIC_WIRELESS
> result = gelic_wl_driver_probe(card);
> if (result) {
> - dev_dbg(&dev->core, "%s: WL init failed\n", __func__);
> + dev_dbg(dev, "%s:%d: WL init failed\n", __func__, __LINE__);
> goto fail_setup_netdev;
> }
> #endif
> - pr_debug("%s: done\n", __func__);
> + dev_dbg(dev, "%s:%d: < OK\n", __func__, __LINE__);
> return 0;
>
> fail_setup_netdev:
> @@ -1773,20 +1812,21 @@ static int ps3_gelic_driver_probe(struct
> ps3_system_bus_device *dev)
> free_irq(card->irq, card);
> netdev->irq = 0;
> fail_request_irq:
> - ps3_sb_event_receive_port_destroy(dev, card->irq);
> + ps3_sb_event_receive_port_destroy(sb_dev, card->irq);
> fail_alloc_irq:
> lv1_net_set_interrupt_status_indicator(bus_id(card),
> bus_id(card),
> 0, 0);
> fail_status_indicator:
> - ps3_system_bus_set_drvdata(dev, NULL);
> + ps3_system_bus_set_drvdata(sb_dev, NULL);
> kfree(netdev_card(netdev)->unalign);
> free_netdev(netdev);
> fail_alloc_card:
> - ps3_dma_region_free(dev->d_region);
> + ps3_dma_region_free(sb_dev->d_region);
> fail_dma_region:
> - ps3_close_hv_device(dev);
> + ps3_close_hv_device(sb_dev);
> fail_open:
> + dev_dbg(dev, "%s:%d: < error\n", __func__, __LINE__);
> return result;
> }
>
> @@ -1794,11 +1834,13 @@ static int ps3_gelic_driver_probe(struct
> ps3_system_bus_device *dev)
> * ps3_gelic_driver_remove - remove a device from the control of this driver
> */
>
> -static void ps3_gelic_driver_remove(struct ps3_system_bus_device *dev)
> +static void ps3_gelic_driver_remove(struct ps3_system_bus_device *sb_dev)
> {
> - struct gelic_card *card = ps3_system_bus_get_drvdata(dev);
> + struct gelic_card *card = ps3_system_bus_get_drvdata(sb_dev);
> + struct device *dev = &sb_dev->core;
> struct net_device *netdev0;
> - pr_debug("%s: called\n", __func__);
> +
> + dev_dbg(dev, "%s:%d: >\n", __func__, __LINE__);
>
> /* set auto-negotiation */
> gelic_card_set_link_mode(card, GELIC_LV1_ETHER_AUTO_NEG);
> @@ -1836,13 +1878,13 @@ static void ps3_gelic_driver_remove(struct
> ps3_system_bus_device *dev)
> kfree(netdev_card(netdev0)->unalign);
> free_netdev(netdev0);
>
> - ps3_system_bus_set_drvdata(dev, NULL);
> + ps3_system_bus_set_drvdata(sb_dev, NULL);
>
> - ps3_dma_region_free(dev->d_region);
> + ps3_dma_region_free(sb_dev->d_region);
>
> - ps3_close_hv_device(dev);
> + ps3_close_hv_device(sb_dev);
>
> - pr_debug("%s: done\n", __func__);
> + dev_dbg(dev, "%s:%d: <\n", __func__, __LINE__);
> }
>
> static struct ps3_system_bus_driver ps3_gelic_driver = {
> --
> 2.25.1
^ permalink raw reply
* Re: [PATCH v2 01/21] dma-mapping: Allow map_sg() ops to return negative error codes
From: Christoph Hellwig @ 2021-07-25 6:07 UTC (permalink / raw)
To: Logan Gunthorpe
Cc: linux-s390, linux-ia64, linux-parisc, Robin Murphy,
Martin Oliveira, linux-mips, linux-kernel, iommu, linux-alpha,
sparclinux, xen-devel, Stephen Bates, linuxppc-dev,
Christoph Hellwig, linux-arm-kernel, Marek Szyprowski
In-Reply-To: <20210723175008.22410-2-logang@deltatee.com>
> +int dma_map_sgtable(struct device *dev, struct sg_table *sgt,
> + enum dma_data_direction dir, unsigned long attrs)
> +{
> + int nents;
> +
> + nents = __dma_map_sg_attrs(dev, sgt->sgl, sgt->orig_nents, dir, attrs);
> + if (nents == 0)
> + return -EIO;
> + else if (nents < 0) {
> + if (WARN_ON_ONCE(nents != -EINVAL && nents != -ENOMEM &&
> + nents != -EIO))
> + return -EIO;
I think this validation of the errnos needs to go into __dma_map_sg_attrs,
so that we catch it for the classic dma_map_sg callers as well.
^ permalink raw reply
* [GIT PULL] Please pull powerpc/linux.git powerpc-5.14-3 tag
From: Michael Ellerman @ 2021-07-25 14:20 UTC (permalink / raw)
To: Linus Torvalds; +Cc: mikey, linuxppc-dev, linux-kernel, npiggin
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Hi Linus,
Please pull some more powerpc fixes for 5.14:
The following changes since commit e73f0f0ee7541171d89f2e2491130c7771ba58d3:
Linux 5.14-rc1 (2021-07-11 15:07:40 -0700)
are available in the git repository at:
https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git tags/powerpc-5.14-3
for you to fetch changes up to d9c57d3ed52a92536f5fa59dc5ccdd58b4875076:
KVM: PPC: Book3S HV Nested: Sanitise H_ENTER_NESTED TM state (2021-07-23 16:19:38 +1000)
- ------------------------------------------------------------------
powerpc fixes for 5.14 #3
- Fix guest to host memory corruption in H_RTAS due to missing nargs check.
- Fix guest triggerable host crashes due to bad handling of nested guest TM state.
- Fix possible crashes due to incorrect reference counting in kvm_arch_vcpu_ioctl().
- Two commits fixing some regressions in KVM transactional memory handling introduced by
the recent rework of the KVM code.
Thanks to: Nicholas Piggin, Alexey Kardashevskiy, Michael Neuling.
- ------------------------------------------------------------------
Nicholas Piggin (5):
KVM: PPC: Book3S HV P9: Fix guest TM support
KVM: PPC: Book3S: Fix CONFIG_TRANSACTIONAL_MEM=n crash
KVM: PPC: Fix kvm_arch_vcpu_ioctl vcpu_load leak
KVM: PPC: Book3S: Fix H_RTAS rets buffer overflow
KVM: PPC: Book3S HV Nested: Sanitise H_ENTER_NESTED TM state
arch/powerpc/kvm/book3s_hv.c | 2 ++
arch/powerpc/kvm/book3s_hv_nested.c | 20 ++++++++++++++++
arch/powerpc/kvm/book3s_hv_p9_entry.c | 25 +++++++++++++++++---
arch/powerpc/kvm/book3s_rtas.c | 25 +++++++++++++++++---
arch/powerpc/kvm/powerpc.c | 4 ++--
5 files changed, 68 insertions(+), 8 deletions(-)
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCAAdFiEEJFGtCPCthwEv2Y/bUevqPMjhpYAFAmD9bJEACgkQUevqPMjh
pYCFLBAAoD0a0fLmoh/LZBvvzD1LNDfoMcxtTF1mVPjv5zfLIDvj+M3+UsMHKBCV
ajDYuz0nd3TBPPBxMBXmQG4r5eYgilgkQ968uXIpQu2wkyAWIFu4hxKzUapLdddy
CN1TuSU9mWjviMsacjCU4zlEgmWpj7TtH+gBmhRKrQlAUMszmXlb5giRS+P6oAyN
OI+3ODlMkj+2CNwhQy7uaPrM13FnarUV0pliItAez4ka+1oWtlkKjXG8DG4k5TZf
7E/7qvxy7yOVXcULBeISJmLfBFttv3nUEAUjtxaA28d7YPZOUgfanSQUVhHl9nv5
KMJlOPAxEjZCF0j6TIEYgqC+DP0eBGDnvvfmGsxoTkYfMI5ykGYxsIEnTUBMZW4+
xi3OMx3cIlGhP0/3e1JFA9O4/zDzM7HxdONW/Wd9xDpLkjucNLZqvE5yP3ct/ATG
W4JmimhXIPFtnNrN0pgfyiU3l9Vodw/UD25AVYAQuamQ9kRtoPh0PtTarttVlw3o
JvZibyMwlds96n78PLThhpyC/SG030RO4oJAQBUpxt5PdAzyRTo4lCy10GQYN/kp
EG7rS7eizU38C379LJT7tkQzrfCgI1aJJ3PsoxggeT78AdybKogN3fHANHbFgOdn
k/SUo/6BF3lVO7C/SFdvPLuldltuYqjddDu24MHXHvtzhJ/pzQo=
=R0jy
-----END PGP SIGNATURE-----
^ permalink raw reply
* [PATCH] powerpc/xmon: use ARRAY_SIZE
From: Jason Wang @ 2021-07-25 15:01 UTC (permalink / raw)
To: mpe; +Cc: paulus, linuxppc-dev, Jason Wang, linux-kernel
The ARRAY_SIZE is the macro definition of sizeof(a)/sizeof(a[0]) and
it is more compact and formal to get a array size.
Signed-off-by: Jason Wang <wangborong@cdjrlc.com>
---
arch/powerpc/xmon/ppc-opc.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/arch/powerpc/xmon/ppc-opc.c b/arch/powerpc/xmon/ppc-opc.c
index dfb80810b16c..6ca4cd26caef 100644
--- a/arch/powerpc/xmon/ppc-opc.c
+++ b/arch/powerpc/xmon/ppc-opc.c
@@ -954,8 +954,7 @@ const struct powerpc_operand powerpc_operands[] =
{ 0xff, 11, NULL, NULL, PPC_OPERAND_SIGNOPT },
};
-const unsigned int num_powerpc_operands = (sizeof (powerpc_operands)
- / sizeof (powerpc_operands[0]));
+const unsigned int num_powerpc_operands = ARRAY_SIZE(powerpc_operands);
/* The functions used to insert and extract complicated operands. */
@@ -6968,8 +6967,7 @@ const struct powerpc_opcode powerpc_opcodes[] = {
{"fcfidu.", XRC(63,974,1), XRA_MASK, POWER7|PPCA2, PPCVLE, {FRT, FRB}},
};
-const int powerpc_num_opcodes =
- sizeof (powerpc_opcodes) / sizeof (powerpc_opcodes[0]);
+const int powerpc_num_opcodes = ARRAY_SIZE(powerpc_opcodes);
\f
/* The VLE opcode table.
@@ -7207,8 +7205,7 @@ const struct powerpc_opcode vle_opcodes[] = {
{"se_bl", BD8(58,0,1), BD8_MASK, PPCVLE, 0, {B8}},
};
-const int vle_num_opcodes =
- sizeof (vle_opcodes) / sizeof (vle_opcodes[0]);
+const int vle_num_opcodes = ARRAY_SIZE(vle_opcodes);
\f
/* The macro table. This is only used by the assembler. */
@@ -7276,5 +7273,4 @@ const struct powerpc_macro powerpc_macros[] = {
{"e_clrlslwi",4, PPCVLE, "e_rlwinm %0,%1,%3,(%2)-(%3),31-(%3)"},
};
-const int powerpc_num_macros =
- sizeof (powerpc_macros) / sizeof (powerpc_macros[0]);
+const int powerpc_num_macros = ARRAY_SIZE(powerpc_macros);
--
2.32.0
^ permalink raw reply related
* Re: [GIT PULL] Please pull powerpc/linux.git powerpc-5.14-3 tag
From: pr-tracker-bot @ 2021-07-25 17:49 UTC (permalink / raw)
To: Michael Ellerman
Cc: linuxppc-dev, mikey, Linus Torvalds, linux-kernel, npiggin
In-Reply-To: <87lf5u1nls.fsf@mpe.ellerman.id.au>
The pull request you sent on Mon, 26 Jul 2021 00:20:47 +1000:
> https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git tags/powerpc-5.14-3
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/3c0ce1497a449b0d150b455628947152c5f6216a
Thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html
^ permalink raw reply
* Re: [PATCH v4 04/10] net/ps3_gelic: Add new macro BUG_ON_DEBUG
From: Christophe Leroy @ 2021-07-25 18:20 UTC (permalink / raw)
To: Geoff Levand; +Cc: netdev, linuxppc-dev, David S. Miller, Jakub Kicinski
In-Reply-To: <bc659850d4eec3b2358c1ccb0e00952ceaa6012f.1627068552.git.geoff@infradead.org>
Geoff Levand <geoff@infradead.org> a écrit :
> Add a new preprocessor macro BUG_ON_DEBUG, that expands to BUG_ON when
> the preprocessor macro DEBUG is defined, or to WARN_ON when DEBUG is not
> defined. Also, replace all occurrences of BUG_ON with BUG_ON_DEBUG.
Why is BUG_ON() needed at all if WARN_ON() is enough ?
You just have to set panic_on_warn to get the system to stop at first
warning.
BUG_ON() should be avoided unless vital.
Please read
https://www.kernel.org/doc/html/latest/process/deprecated.html#bug-and-bug-on
Christophe
>
> Signed-off-by: Geoff Levand <geoff@infradead.org>
> ---
> drivers/net/ethernet/toshiba/ps3_gelic_net.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
> b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
> index ded467d81f36..946e9bfa071b 100644
> --- a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
> +++ b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
> @@ -44,6 +44,13 @@ MODULE_AUTHOR("SCE Inc.");
> MODULE_DESCRIPTION("Gelic Network driver");
> MODULE_LICENSE("GPL");
>
> +#define BUG_ON_DEBUG(_cond) do { \
> + if (__is_defined(DEBUG)) \
> + BUG_ON(_cond); \
> + else \
> + WARN_ON(_cond); \
> +} while (0)
> +
> int gelic_card_set_irq_mask(struct gelic_card *card, u64 mask)
> {
> struct device *dev = ctodev(card);
> @@ -505,7 +512,7 @@ static void gelic_descr_release_tx(struct
> gelic_card *card,
> struct sk_buff *skb = descr->skb;
> struct device *dev = ctodev(card);
>
> - BUG_ON(!(be32_to_cpu(descr->hw_regs.data_status) &
> + BUG_ON_DEBUG(!(be32_to_cpu(descr->hw_regs.data_status) &
> GELIC_DESCR_TX_TAIL));
>
> dma_unmap_single(dev, be32_to_cpu(descr->hw_regs.payload.dev_addr),
> @@ -1667,7 +1674,7 @@ static void gelic_card_get_vlan_info(struct
> gelic_card *card)
> }
>
> if (card->vlan[GELIC_PORT_ETHERNET_0].tx) {
> - BUG_ON(!card->vlan[GELIC_PORT_WIRELESS].tx);
> + BUG_ON_DEBUG(!card->vlan[GELIC_PORT_WIRELESS].tx);
> card->vlan_required = 1;
> } else
> card->vlan_required = 0;
> @@ -1709,7 +1716,7 @@ static int ps3_gelic_driver_probe(struct
> ps3_system_bus_device *sb_dev)
> if (result) {
> dev_err(dev, "%s:%d: ps3_dma_region_create failed: %d\n",
> __func__, __LINE__, result);
> - BUG_ON("check region type");
> + BUG_ON_DEBUG("check region type");
> goto fail_dma_region;
> }
>
> --
> 2.25.1
^ permalink raw reply
* Re: [PATCH v4 08/10] net/ps3_gelic: Rename no to descr_count
From: Christophe Leroy @ 2021-07-25 18:27 UTC (permalink / raw)
To: Geoff Levand; +Cc: netdev, linuxppc-dev, David S. Miller, Jakub Kicinski
In-Reply-To: <07e42ec30037d514c1d63f33efe4642364d89802.1627068552.git.geoff@infradead.org>
Geoff Levand <geoff@infradead.org> a écrit :
> In an effort to make the PS3 gelic driver easier to maintain, rename
> the gelic_card_init_chain parameter 'no' to 'descr_count'.
Not sure you really need a so long name. 'count' should be good enough.
Read https://www.kernel.org/doc/html/latest/process/coding-style.html#naming
>
> Signed-off-by: Geoff Levand <geoff@infradead.org>
> ---
> drivers/net/ethernet/toshiba/ps3_gelic_net.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
> b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
> index e55aa9fecfeb..60fcca5d20dd 100644
> --- a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
> +++ b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
> @@ -325,7 +325,7 @@ static void gelic_card_free_chain(struct
> gelic_card *card,
> * @card: card structure
> * @chain: address of chain
> * @start_descr: address of descriptor array
> - * @no: number of descriptors
> + * @descr_count: number of descriptors
> *
> * we manage a circular list that mirrors the hardware structure,
> * except that the hardware uses bus addresses.
> @@ -334,16 +334,16 @@ static void gelic_card_free_chain(struct
> gelic_card *card,
> */
> static int gelic_card_init_chain(struct gelic_card *card,
> struct gelic_descr_chain *chain, struct gelic_descr *start_descr,
> - int no)
> + int descr_count)
> {
> int i;
> struct gelic_descr *descr;
> struct device *dev = ctodev(card);
>
> descr = start_descr;
> - memset(descr, 0, sizeof(*descr) * no);
> + memset(descr, 0, sizeof(*descr) *descr_count);
You forgot the space after the *
Christophe
>
> - for (i = 0; i < no; i++, descr++) {
> + for (i = 0; i < descr_count; i++, descr++) {
> descr->link.size = sizeof(struct gelic_hw_regs);
> gelic_descr_set_status(descr, GELIC_DESCR_DMA_NOT_IN_USE);
> descr->link.cpu_addr =
> @@ -361,7 +361,7 @@ static int gelic_card_init_chain(struct gelic_card *card,
> start_descr->prev = (descr - 1);
>
> descr = start_descr;
> - for (i = 0; i < no; i++, descr++) {
> + for (i = 0; i < descr_count; i++, descr++) {
> descr->hw_regs.next_descr_addr =
> cpu_to_be32(descr->next->link.cpu_addr);
> }
> --
> 2.25.1
^ permalink raw reply
* Re: [PATCH v4 09/10] net/ps3_gelic: Add new routine gelic_work_to_card
From: Christophe Leroy @ 2021-07-25 18:29 UTC (permalink / raw)
To: Geoff Levand; +Cc: netdev, linuxppc-dev, David S. Miller, Jakub Kicinski
In-Reply-To: <5634f7c76a67345c9735e05b68228ea899a8bf9d.1627068552.git.geoff@infradead.org>
Geoff Levand <geoff@infradead.org> a écrit :
> Add new helper routine gelic_work_to_card that converts a work_struct
> to a gelic_card.
Adding a function is it really needed as it is used only once ?
Christophe
>
> Signed-off-by: Geoff Levand <geoff@infradead.org>
> ---
> drivers/net/ethernet/toshiba/ps3_gelic_net.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
> b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
> index 60fcca5d20dd..42f4de9ad5fe 100644
> --- a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
> +++ b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
> @@ -1420,6 +1420,11 @@ static const struct ethtool_ops
> gelic_ether_ethtool_ops = {
> .set_link_ksettings = gelic_ether_set_link_ksettings,
> };
>
> +static struct gelic_card *gelic_work_to_card(struct work_struct *work)
> +{
> + return container_of(work, struct gelic_card, tx_timeout_task);
> +}
> +
> /**
> * gelic_net_tx_timeout_task - task scheduled by the watchdog timeout
> * function (to be called not under interrupt status)
> @@ -1429,8 +1434,7 @@ static const struct ethtool_ops
> gelic_ether_ethtool_ops = {
> */
> static void gelic_net_tx_timeout_task(struct work_struct *work)
> {
> - struct gelic_card *card =
> - container_of(work, struct gelic_card, tx_timeout_task);
> + struct gelic_card *card = gelic_work_to_card(work);
> struct net_device *netdev = card->netdev[GELIC_PORT_ETHERNET_0];
> struct device *dev = ctodev(card);
>
> --
> 2.25.1
^ permalink raw reply
* Re: [PATCH v4 10/10] net/ps3_gelic: Fix DMA mapping problems
From: Christophe Leroy @ 2021-07-25 18:38 UTC (permalink / raw)
To: Geoff Levand; +Cc: netdev, linuxppc-dev, David S. Miller, Jakub Kicinski
In-Reply-To: <7aa1d9b1b4ffadcbdc6f88e4f8d4a323da307595.1627068552.git.geoff@infradead.org>
Geoff Levand <geoff@infradead.org> a écrit :
> Fixes several DMA mapping problems with the PS3's gelic network driver:
>
> * Change from checking the return value of dma_map_single to using the
> dma_mapping_error routine.
> * Use the correct buffer length when mapping the RX skb.
> * Improved error checking and debug logging.
The patch is quite big and probably deserves more explanation. For
instance, explain why the buffer length is not correct today.
Also as it is a bug fixing patch, it should include a 'fixes' tag, and
a Cc: to stable@vger.kernel.org. Also, when possible, bug fixes should
be one of the first patches in a series like that so that they can be
applied to stable without applying the whole series.
Christophe
>
> Fixes runtime errors like these, and also other randomly occurring errors:
>
> IP-Config: Complete:
> DMA-API: ps3_gelic_driver sb_05: device driver failed to check map error
> WARNING: CPU: 0 PID: 0 at kernel/dma/debug.c:1027 .check_unmap+0x888/0x8dc
>
> Signed-off-by: Geoff Levand <geoff@infradead.org>
> ---
> drivers/net/ethernet/toshiba/ps3_gelic_net.c | 183 +++++++++++--------
> 1 file changed, 108 insertions(+), 75 deletions(-)
>
> diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
> b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
> index 42f4de9ad5fe..11ddeacb1159 100644
> --- a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
> +++ b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
> @@ -336,22 +336,31 @@ static int gelic_card_init_chain(struct
> gelic_card *card,
> struct gelic_descr_chain *chain, struct gelic_descr *start_descr,
> int descr_count)
> {
> - int i;
> - struct gelic_descr *descr;
> + struct gelic_descr *descr = start_descr;
> struct device *dev = ctodev(card);
> + unsigned int index;
>
> - descr = start_descr;
> - memset(descr, 0, sizeof(*descr) *descr_count);
> + memset(start_descr, 0, descr_count * sizeof(*start_descr));
>
> - for (i = 0; i < descr_count; i++, descr++) {
> - descr->link.size = sizeof(struct gelic_hw_regs);
> + for (index = 0, descr = start_descr; index < descr_count;
> + index++, descr++) {
> gelic_descr_set_status(descr, GELIC_DESCR_DMA_NOT_IN_USE);
> - descr->link.cpu_addr =
> - dma_map_single(dev, descr, descr->link.size,
> - DMA_BIDIRECTIONAL);
>
> - if (!descr->link.cpu_addr)
> - goto iommu_error;
> + descr->link.size = sizeof(struct gelic_hw_regs);
> + descr->link.cpu_addr = dma_map_single(dev, descr,
> + descr->link.size, DMA_BIDIRECTIONAL);
> +
> + if (unlikely(dma_mapping_error(dev, descr->link.cpu_addr))) {
> + dev_err(dev, "%s:%d: dma_mapping_error\n", __func__,
> + __LINE__);
> +
> + for (index--, descr--; index > 0; index--, descr--) {
> + if (descr->link.cpu_addr) {
> + gelic_unmap_link(dev, descr);
> + }
> + }
> + return -ENOMEM;
> + }
>
> descr->next = descr + 1;
> descr->prev = descr - 1;
> @@ -360,8 +369,9 @@ static int gelic_card_init_chain(struct gelic_card *card,
> (descr - 1)->next = start_descr;
> start_descr->prev = (descr - 1);
>
> - descr = start_descr;
> - for (i = 0; i < descr_count; i++, descr++) {
> + /* chain bus addr of hw descriptor */
> + for (index = 0, descr = start_descr; index < descr_count;
> + index++, descr++) {
> descr->hw_regs.next_descr_addr =
> cpu_to_be32(descr->next->link.cpu_addr);
> }
> @@ -373,12 +383,6 @@ static int gelic_card_init_chain(struct
> gelic_card *card,
> (descr - 1)->hw_regs.next_descr_addr = 0;
>
> return 0;
> -
> -iommu_error:
> - for (i--, descr--; 0 <= i; i--, descr--)
> - if (descr->link.cpu_addr)
> - gelic_unmap_link(dev, descr);
> - return -ENOMEM;
> }
>
> /**
> @@ -395,49 +399,63 @@ static int gelic_descr_prepare_rx(struct
> gelic_card *card,
> struct gelic_descr *descr)
> {
> struct device *dev = ctodev(card);
> - int offset;
> - unsigned int bufsize;
> + struct aligned_buff {
> + unsigned int total_bytes;
> + unsigned int offset;
> + };
> + struct aligned_buff a_buf;
> + dma_addr_t cpu_addr;
>
> if (gelic_descr_get_status(descr) != GELIC_DESCR_DMA_NOT_IN_USE) {
> dev_err(dev, "%s:%d: ERROR status\n", __func__, __LINE__);
> }
>
> - /* we need to round up the buffer size to a multiple of 128 */
> - bufsize = ALIGN(GELIC_NET_MAX_MTU, GELIC_NET_RXBUF_ALIGN);
> + a_buf.total_bytes = ALIGN(GELIC_NET_MAX_MTU, GELIC_NET_RXBUF_ALIGN)
> + + GELIC_NET_RXBUF_ALIGN;
> +
> + descr->skb = dev_alloc_skb(a_buf.total_bytes);
>
> - /* and we need to have it 128 byte aligned, therefore we allocate a
> - * bit more */
> - descr->skb = dev_alloc_skb(bufsize + GELIC_NET_RXBUF_ALIGN - 1);
> if (!descr->skb) {
> - descr->hw_regs.payload.dev_addr = 0; /* tell DMAC don't touch memory */
> + descr->hw_regs.payload.dev_addr = 0;
> + descr->hw_regs.payload.size = 0;
> return -ENOMEM;
> }
> - descr->hw_regs.payload.size = cpu_to_be32(bufsize);
> +
> + a_buf.offset = PTR_ALIGN(descr->skb->data, GELIC_NET_RXBUF_ALIGN)
> + - descr->skb->data;
> +
> + if (a_buf.offset) {
> + dev_dbg(dev, "%s:%d: offset=%u\n", __func__, __LINE__,
> + a_buf.offset);
> + skb_reserve(descr->skb, a_buf.offset);
> + }
> +
> descr->hw_regs.dmac_cmd_status = 0;
> descr->hw_regs.result_size = 0;
> descr->hw_regs.valid_size = 0;
> descr->hw_regs.data_error = 0;
>
> - offset = ((unsigned long)descr->skb->data) &
> - (GELIC_NET_RXBUF_ALIGN - 1);
> - if (offset)
> - skb_reserve(descr->skb, GELIC_NET_RXBUF_ALIGN - offset);
> - /* io-mmu-map the skb */
> - descr->hw_regs.payload.dev_addr = cpu_to_be32(dma_map_single(dev,
> - descr->skb->data,
> - GELIC_NET_MAX_MTU,
> - DMA_FROM_DEVICE));
> - if (!descr->hw_regs.payload.dev_addr) {
> + descr->hw_regs.payload.size = a_buf.total_bytes - a_buf.offset;
> + cpu_addr = dma_map_single(dev, descr->skb->data,
> + descr->hw_regs.payload.size, DMA_FROM_DEVICE);
> + descr->hw_regs.payload.dev_addr = cpu_to_be32(cpu_addr);
> +
> + if (unlikely(dma_mapping_error(dev, cpu_addr))) {
> + dev_err(dev, "%s:%d: dma_mapping_error\n", __func__, __LINE__);
> +
> + descr->hw_regs.payload.dev_addr = 0;
> + descr->hw_regs.payload.size = 0;
> +
> dev_kfree_skb_any(descr->skb);
> descr->skb = NULL;
> - dev_info(dev,
> - "%s:Could not iommu-map rx buffer\n", __func__);
> +
> gelic_descr_set_status(descr, GELIC_DESCR_DMA_NOT_IN_USE);
> +
> return -ENOMEM;
> - } else {
> - gelic_descr_set_status(descr, GELIC_DESCR_DMA_CARDOWNED);
> - return 0;
> }
> +
> + gelic_descr_set_status(descr, GELIC_DESCR_DMA_CARDOWNED);
> + return 0;
> }
>
> /**
> @@ -454,13 +472,18 @@ static void gelic_card_release_rx_chain(struct
> gelic_card *card)
> if (descr->skb) {
> dma_unmap_single(dev,
> be32_to_cpu(descr->hw_regs.payload.dev_addr),
> - descr->skb->len, DMA_FROM_DEVICE);
> - descr->hw_regs.payload.dev_addr = 0;
> + descr->hw_regs.payload.size, DMA_FROM_DEVICE);
> +
> dev_kfree_skb_any(descr->skb);
> descr->skb = NULL;
> +
> gelic_descr_set_status(descr,
> GELIC_DESCR_DMA_NOT_IN_USE);
> }
> +
> + descr->hw_regs.payload.dev_addr = 0;
> + descr->hw_regs.payload.size = 0;
> +
> descr = descr->next;
> } while (descr != card->rx_chain.head);
> }
> @@ -526,17 +549,19 @@ static void gelic_descr_release_tx(struct
> gelic_card *card,
> GELIC_DESCR_TX_TAIL));
>
> dma_unmap_single(dev, be32_to_cpu(descr->hw_regs.payload.dev_addr),
> - skb->len, DMA_TO_DEVICE);
> - dev_kfree_skb_any(skb);
> + descr->hw_regs.payload.size, DMA_TO_DEVICE);
>
> descr->hw_regs.payload.dev_addr = 0;
> descr->hw_regs.payload.size = 0;
> +
> + dev_kfree_skb_any(skb);
> + descr->skb = NULL;
> +
> descr->hw_regs.next_descr_addr = 0;
> descr->hw_regs.result_size = 0;
> descr->hw_regs.valid_size = 0;
> descr->hw_regs.data_status = 0;
> descr->hw_regs.data_error = 0;
> - descr->skb = NULL;
>
> gelic_descr_set_status(descr, GELIC_DESCR_DMA_NOT_IN_USE);
> }
> @@ -565,31 +590,34 @@ static void gelic_card_wake_queues(struct
> gelic_card *card)
> static void gelic_card_release_tx_chain(struct gelic_card *card, int stop)
> {
> struct gelic_descr_chain *tx_chain;
> - enum gelic_descr_dma_status status;
> struct device *dev = ctodev(card);
> - struct net_device *netdev;
> - int release = 0;
> + int release;
> +
> + for (release = 0, tx_chain = &card->tx_chain;
> + tx_chain->head != tx_chain->tail && tx_chain->tail;
> + tx_chain->tail = tx_chain->tail->next) {
> + enum gelic_descr_dma_status status;
> + struct gelic_descr *descr;
> + struct net_device *netdev;
> +
> + descr = tx_chain->tail;
> + status = gelic_descr_get_status(descr);
> + netdev = descr->skb->dev;
>
> - for (tx_chain = &card->tx_chain;
> - tx_chain->head != tx_chain->tail && tx_chain->tail;
> - tx_chain->tail = tx_chain->tail->next) {
> - status = gelic_descr_get_status(tx_chain->tail);
> - netdev = tx_chain->tail->skb->dev;
> switch (status) {
> case GELIC_DESCR_DMA_RESPONSE_ERROR:
> case GELIC_DESCR_DMA_PROTECTION_ERROR:
> case GELIC_DESCR_DMA_FORCE_END:
> - dev_info_ratelimited(dev,
> - "%s:%d: forcing end of tx descriptor with status %x\n",
> - __func__, __LINE__, status);
> + dev_info_ratelimited(dev,
> + "%s:%d: forcing end of tx descriptor with status %x\n",
> + __func__, __LINE__, status);
> netdev->stats.tx_dropped++;
> break;
>
> case GELIC_DESCR_DMA_COMPLETE:
> - if (tx_chain->tail->skb) {
> + if (descr->skb) {
> netdev->stats.tx_packets++;
> - netdev->stats.tx_bytes +=
> - tx_chain->tail->skb->len;
> + netdev->stats.tx_bytes += descr->skb->len;
> }
> break;
>
> @@ -599,7 +627,7 @@ static void gelic_card_release_tx_chain(struct
> gelic_card *card, int stop)
> }
> }
>
> - gelic_descr_release_tx(card, tx_chain->tail);
> + gelic_descr_release_tx(card, descr);
> release++;
> }
> out:
> @@ -703,19 +731,19 @@ int gelic_net_stop(struct net_device *netdev)
> *
> * returns the address of the next descriptor, or NULL if not available.
> */
> -static struct gelic_descr *
> -gelic_card_get_next_tx_descr(struct gelic_card *card)
> +static struct gelic_descr *gelic_card_get_next_tx_descr(struct
> gelic_card *card)
> {
> if (!card->tx_chain.head)
> return NULL;
> +
> /* see if the next descriptor is free */
> if (card->tx_chain.tail != card->tx_chain.head->next &&
> - gelic_descr_get_status(card->tx_chain.head) ==
> - GELIC_DESCR_DMA_NOT_IN_USE)
> + (gelic_descr_get_status(card->tx_chain.head) ==
> + GELIC_DESCR_DMA_NOT_IN_USE)) {
> return card->tx_chain.head;
> - else
> - return NULL;
> + }
>
> + return NULL;
> }
>
> /**
> @@ -809,18 +837,23 @@ static int gelic_descr_prepare_tx(struct
> gelic_card *card,
> if (!skb_tmp) {
> return -ENOMEM;
> }
> +
> skb = skb_tmp;
> }
>
> - cpu_addr = dma_map_single(dev, skb->data, skb->len, DMA_TO_DEVICE);
> + descr->hw_regs.payload.size = skb->len;
> + cpu_addr = dma_map_single(dev, skb->data, descr->hw_regs.payload.size,
> + DMA_TO_DEVICE);
> + descr->hw_regs.payload.dev_addr = cpu_to_be32(cpu_addr);
>
> - if (!cpu_addr) {
> + if (unlikely(dma_mapping_error(dev, cpu_addr))) {
> dev_err(dev, "%s:%d: dma_mapping_error\n", __func__, __LINE__);
> +
> + descr->hw_regs.payload.dev_addr = 0;
> + descr->hw_regs.payload.size = 0;
> return -ENOMEM;
> }
>
> - descr->hw_regs.payload.dev_addr = cpu_to_be32(cpu_addr);
> - descr->hw_regs.payload.size = cpu_to_be32(skb->len);
> descr->skb = skb;
> descr->hw_regs.data_status = 0;
> descr->hw_regs.next_descr_addr = 0; /* terminate hw descr */
> @@ -948,9 +981,9 @@ static void gelic_net_pass_skb_up(struct
> gelic_descr *descr,
>
> data_status = be32_to_cpu(descr->hw_regs.data_status);
> data_error = be32_to_cpu(descr->hw_regs.data_error);
> - /* unmap skb buffer */
> +
> dma_unmap_single(dev, be32_to_cpu(descr->hw_regs.payload.dev_addr),
> - GELIC_NET_MAX_MTU, DMA_FROM_DEVICE);
> + descr->hw_regs.payload.size, DMA_FROM_DEVICE);
>
> skb_put(skb, be32_to_cpu(descr->hw_regs.valid_size) ?
> be32_to_cpu(descr->hw_regs.valid_size) :
> --
> 2.25.1
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox