[PATCH v2] powerpc: Fix PS3 allmodconfig warning

2024-04-01 Thread Geoff Levand
The struct ps3_notification_device in the ps3_probe_thread routine
is too large to be on the stack, causing a warning for an
allmodconfig build with clang.

Change the struct ps3_notification_device from a variable on the stack
to a dynamically allocated variable.

Reported-by: Arnd Bergmann 
Signed-off-by: Geoff Levand 

diff --git a/arch/powerpc/platforms/ps3/device-init.c 
b/arch/powerpc/platforms/ps3/device-init.c
index 878bc160246e..b18e1c92e554 100644
--- a/arch/powerpc/platforms/ps3/device-init.c
+++ b/arch/powerpc/platforms/ps3/device-init.c
@@ -770,49 +770,51 @@ static struct task_struct *probe_task;
 
 static int ps3_probe_thread(void *data)
 {
-   struct ps3_notification_device dev;
+   struct {
+   struct ps3_notification_device dev;
+   u8 buf[512];
+   } *local;
+   struct ps3_notify_cmd *notify_cmd;
+   struct ps3_notify_event *notify_event;
int res;
unsigned int irq;
u64 lpar;
-   void *buf;
-   struct ps3_notify_cmd *notify_cmd;
-   struct ps3_notify_event *notify_event;
 
pr_debug(" -> %s:%u: kthread started\n", __func__, __LINE__);
 
-   buf = kzalloc(512, GFP_KERNEL);
-   if (!buf)
+   local = kzalloc(sizeof(*local), GFP_KERNEL);
+   if (!local)
return -ENOMEM;
 
-   lpar = ps3_mm_phys_to_lpar(__pa(buf));
-   notify_cmd = buf;
-   notify_event = buf;
+   lpar = ps3_mm_phys_to_lpar(__pa(>buf));
+   notify_cmd = (struct ps3_notify_cmd *)>buf;
+   notify_event = (struct ps3_notify_event *)>buf;
 
/* dummy system bus device */
-   dev.sbd.bus_id = (u64)data;
-   dev.sbd.dev_id = PS3_NOTIFICATION_DEV_ID;
-   dev.sbd.interrupt_id = PS3_NOTIFICATION_INTERRUPT_ID;
+   local->dev.sbd.bus_id = (u64)data;
+   local->dev.sbd.dev_id = PS3_NOTIFICATION_DEV_ID;
+   local->dev.sbd.interrupt_id = PS3_NOTIFICATION_INTERRUPT_ID;
 
-   res = lv1_open_device(dev.sbd.bus_id, dev.sbd.dev_id, 0);
+   res = lv1_open_device(local->dev.sbd.bus_id, local->dev.sbd.dev_id, 0);
if (res) {
pr_err("%s:%u: lv1_open_device failed %s\n", __func__,
   __LINE__, ps3_result(res));
goto fail_free;
}
 
-   res = ps3_sb_event_receive_port_setup(, PS3_BINDING_CPU_ANY,
- );
+   res = ps3_sb_event_receive_port_setup(>dev.sbd,
+   PS3_BINDING_CPU_ANY, );
if (res) {
pr_err("%s:%u: ps3_sb_event_receive_port_setup failed %d\n",
   __func__, __LINE__, res);
   goto fail_close_device;
}
 
-   spin_lock_init();
-   rcuwait_init();
+   spin_lock_init(>dev.lock);
+   rcuwait_init(>dev.wait);
 
res = request_irq(irq, ps3_notification_interrupt, 0,
- "ps3_notification", );
+ "ps3_notification", >dev);
if (res) {
pr_err("%s:%u: request_irq failed %d\n", __func__, __LINE__,
   res);
@@ -823,7 +825,7 @@ static int ps3_probe_thread(void *data)
notify_cmd->operation_code = 0; /* must be zero */
notify_cmd->event_mask = 1UL << notify_region_probe;
 
-   res = ps3_notification_read_write(, lpar, 1);
+   res = ps3_notification_read_write(>dev, lpar, 1);
if (res)
goto fail_free_irq;
 
@@ -834,36 +836,37 @@ static int ps3_probe_thread(void *data)
 
memset(notify_event, 0, sizeof(*notify_event));
 
-   res = ps3_notification_read_write(, lpar, 0);
+   res = ps3_notification_read_write(>dev, lpar, 0);
if (res)
break;
 
pr_debug("%s:%u: notify event type 0x%llx bus id %llu dev id 
%llu"
 " type %llu port %llu\n", __func__, __LINE__,
-notify_event->event_type, notify_event->bus_id,
-notify_event->dev_id, notify_event->dev_type,
-notify_event->dev_port);
+   notify_event->event_type, notify_event->bus_id,
+   notify_event->dev_id, notify_event->dev_type,
+   notify_event->dev_port);
 
if (notify_event->event_type != notify_region_probe ||
-   notify_event->bus_id != dev.sbd.bus_id) {
+   notify_event->bus_id != local->dev.sbd.bus_id) {
pr_warn("%s:%u: bad notify_event: event %llu, dev_id 
%llu, dev_type %llu\n",
__func__, __LINE__, notify_event->event_type,
notify_event->dev_id, notify_event->dev_type);
continue;

[PATCH] powerpc: Fix PS3 allmodconfig warning

2024-03-23 Thread Geoff Levand
The struct ps3_notification_device in the ps3_probe_thread routine
is too large to be on the stack, causing a warning for an
allmodconfig build with clang.

Change the struct ps3_notification_device from a variable on the stack
to a dynamically allocated variable.

Reported-by: Arnd Bergmann 
Signed-off-by: Geoff Levand 

diff --git a/arch/powerpc/platforms/ps3/device-init.c 
b/arch/powerpc/platforms/ps3/device-init.c
index 878bc160246e..03292869e6a1 100644
--- a/arch/powerpc/platforms/ps3/device-init.c
+++ b/arch/powerpc/platforms/ps3/device-init.c
@@ -770,49 +770,51 @@ static struct task_struct *probe_task;
 
 static int ps3_probe_thread(void *data)
 {
-   struct ps3_notification_device dev;
+   struct {
+   struct ps3_notification_device dev;
+   u8 buf[512];
+   } *local;
+   struct ps3_notify_cmd *notify_cmd;
+   struct ps3_notify_event *notify_event;
int res;
unsigned int irq;
u64 lpar;
-   void *buf;
-   struct ps3_notify_cmd *notify_cmd;
-   struct ps3_notify_event *notify_event;
 
pr_debug(" -> %s:%u: kthread started\n", __func__, __LINE__);
 
-   buf = kzalloc(512, GFP_KERNEL);
-   if (!buf)
+   local = kzalloc(sizeof(local), GFP_KERNEL);
+   if (!local)
return -ENOMEM;
 
-   lpar = ps3_mm_phys_to_lpar(__pa(buf));
-   notify_cmd = buf;
-   notify_event = buf;
+   lpar = ps3_mm_phys_to_lpar(__pa(>buf));
+   notify_cmd = (struct ps3_notify_cmd *)>buf;
+   notify_event = (struct ps3_notify_event *)>buf;
 
/* dummy system bus device */
-   dev.sbd.bus_id = (u64)data;
-   dev.sbd.dev_id = PS3_NOTIFICATION_DEV_ID;
-   dev.sbd.interrupt_id = PS3_NOTIFICATION_INTERRUPT_ID;
+   local->dev.sbd.bus_id = (u64)data;
+   local->dev.sbd.dev_id = PS3_NOTIFICATION_DEV_ID;
+   local->dev.sbd.interrupt_id = PS3_NOTIFICATION_INTERRUPT_ID;
 
-   res = lv1_open_device(dev.sbd.bus_id, dev.sbd.dev_id, 0);
+   res = lv1_open_device(local->dev.sbd.bus_id, local->dev.sbd.dev_id, 0);
if (res) {
pr_err("%s:%u: lv1_open_device failed %s\n", __func__,
   __LINE__, ps3_result(res));
goto fail_free;
}
 
-   res = ps3_sb_event_receive_port_setup(, PS3_BINDING_CPU_ANY,
- );
+   res = ps3_sb_event_receive_port_setup(>dev.sbd,
+   PS3_BINDING_CPU_ANY, );
if (res) {
pr_err("%s:%u: ps3_sb_event_receive_port_setup failed %d\n",
   __func__, __LINE__, res);
   goto fail_close_device;
}
 
-   spin_lock_init();
-   rcuwait_init();
+   spin_lock_init(>dev.lock);
+   rcuwait_init(>dev.wait);
 
res = request_irq(irq, ps3_notification_interrupt, 0,
- "ps3_notification", );
+ "ps3_notification", >dev);
if (res) {
pr_err("%s:%u: request_irq failed %d\n", __func__, __LINE__,
   res);
@@ -823,7 +825,7 @@ static int ps3_probe_thread(void *data)
notify_cmd->operation_code = 0; /* must be zero */
notify_cmd->event_mask = 1UL << notify_region_probe;
 
-   res = ps3_notification_read_write(, lpar, 1);
+   res = ps3_notification_read_write(>dev, lpar, 1);
if (res)
goto fail_free_irq;
 
@@ -834,36 +836,37 @@ static int ps3_probe_thread(void *data)
 
memset(notify_event, 0, sizeof(*notify_event));
 
-   res = ps3_notification_read_write(, lpar, 0);
+   res = ps3_notification_read_write(>dev, lpar, 0);
if (res)
break;
 
pr_debug("%s:%u: notify event type 0x%llx bus id %llu dev id 
%llu"
 " type %llu port %llu\n", __func__, __LINE__,
-notify_event->event_type, notify_event->bus_id,
-notify_event->dev_id, notify_event->dev_type,
-notify_event->dev_port);
+   notify_event->event_type, notify_event->bus_id,
+   notify_event->dev_id, notify_event->dev_type,
+   notify_event->dev_port);
 
if (notify_event->event_type != notify_region_probe ||
-   notify_event->bus_id != dev.sbd.bus_id) {
+   notify_event->bus_id != local->dev.sbd.bus_id) {
pr_warn("%s:%u: bad notify_event: event %llu, dev_id 
%llu, dev_type %llu\n",
__func__, __LINE__, notify_event->event_type,
notify_event->dev_id, notify_event->dev_type);
continue;

Re: [PATCH] powerpc: ps3: mark ps3_notification_device static for stack usage

2024-03-23 Thread Geoff Levand
On 3/23/24 05:24, Arnd Bergmann wrote:
> On Fri, Mar 22, 2024, at 09:34, Geoff Levand wrote:
>> On 3/21/24 17:32, Geert Uytterhoeven wrote:
>>> --- a/arch/powerpc/platforms/ps3/device-init.c
>>>> +++ b/arch/powerpc/platforms/ps3/device-init.c
>>>> @@ -770,7 +770,7 @@ static struct task_struct *probe_task;
>>>>
>>>>  static int ps3_probe_thread(void *data)
>>>>  {
>>>> -   struct ps3_notification_device dev;
>>>> +   static struct ps3_notification_device dev;
>>>> int res;
>>>> unsigned int irq;
>>>> u64 lpar;
>>>
>>> Making it static increases kernel size for everyone.  So I'd rather
>>> allocate it dynamically. The thread already allocates a buffer, which
>>> can be replaced at no cost by allocating a structure containing both
>>> the ps3_notification_device and the buffer.
> 
> I didn't think it mattered much, given that you would rarely
> have a kernel with PS3 support along with other platforms.
> 
> I suppose it does increase the size for a PS3-only kernel
> as well, while your version makes it smaller.
> 
>> Here's what I came up with.  It builds for me without warnings.
>> I haven't tested it yet.  A review would be appreciated.
> 
> It seems a little complicated but looks all correct to
> me and reduces both stack and .data size, so
> 
> Acked-by: Arnd Bergmann 

Thanks Arnd.  I also thought it was a bit too much.  I made a simpler
version that I'll post as a separate message.

-Geoff



Re: [PATCH] powerpc: ps3: mark ps3_notification_device static for stack usage

2024-03-22 Thread Geoff Levand
On 3/21/24 17:32, Geert Uytterhoeven wrote:
> --- a/arch/powerpc/platforms/ps3/device-init.c
>> +++ b/arch/powerpc/platforms/ps3/device-init.c
>> @@ -770,7 +770,7 @@ static struct task_struct *probe_task;
>>
>>  static int ps3_probe_thread(void *data)
>>  {
>> -   struct ps3_notification_device dev;
>> +   static struct ps3_notification_device dev;
>> int res;
>> unsigned int irq;
>> u64 lpar;
> 
> Making it static increases kernel size for everyone.  So I'd rather
> allocate it dynamically. The thread already allocates a buffer, which
> can be replaced at no cost by allocating a structure containing both
> the ps3_notification_device and the buffer.

Here's what I came up with.  It builds for me without warnings.
I haven't tested it yet.  A review would be appreciated.

diff --git a/arch/powerpc/platforms/ps3/device-init.c 
b/arch/powerpc/platforms/ps3/device-init.c
index 878bc160246e..9bb44a6ccdaf 100644
--- a/arch/powerpc/platforms/ps3/device-init.c
+++ b/arch/powerpc/platforms/ps3/device-init.c
@@ -770,37 +770,48 @@ static struct task_struct *probe_task;
 
 static int ps3_probe_thread(void *data)
 {
-   struct ps3_notification_device dev;
+   struct ps3_probe_thread_local {
+   struct ps3_notification_device dev;
+   union {
+   char buf[512];
+   struct ps3_notify_cmd notify_cmd;
+   struct ps3_notify_event notify_event;
+   };
+   };
+   struct ps3_probe_thread_local *local;
+   struct ps3_notification_device *dev;
+   struct ps3_notify_cmd *notify_cmd;
+   struct ps3_notify_event *notify_event;
int res;
unsigned int irq;
u64 lpar;
-   void *buf;
-   struct ps3_notify_cmd *notify_cmd;
-   struct ps3_notify_event *notify_event;
 
pr_debug(" -> %s:%u: kthread started\n", __func__, __LINE__);
 
-   buf = kzalloc(512, GFP_KERNEL);
-   if (!buf)
+   local = kzalloc(sizeof(local), GFP_KERNEL);
+
+   if (!local)
return -ENOMEM;
 
-   lpar = ps3_mm_phys_to_lpar(__pa(buf));
-   notify_cmd = buf;
-   notify_event = buf;
+   dev = >dev;
+   notify_cmd = >notify_cmd;
+   notify_event = >notify_event;
+
+   lpar = ps3_mm_phys_to_lpar(__pa(>notify_cmd));
 
/* dummy system bus device */
-   dev.sbd.bus_id = (u64)data;
-   dev.sbd.dev_id = PS3_NOTIFICATION_DEV_ID;
-   dev.sbd.interrupt_id = PS3_NOTIFICATION_INTERRUPT_ID;
+   dev->sbd.bus_id = (u64)data;
+   dev->sbd.dev_id = PS3_NOTIFICATION_DEV_ID;
+   dev->sbd.interrupt_id = PS3_NOTIFICATION_INTERRUPT_ID;
 
-   res = lv1_open_device(dev.sbd.bus_id, dev.sbd.dev_id, 0);
+   res = lv1_open_device(dev->sbd.bus_id, dev->sbd.dev_id, 0);
if (res) {
pr_err("%s:%u: lv1_open_device failed %s\n", __func__,
   __LINE__, ps3_result(res));
goto fail_free;
}
 
-   res = ps3_sb_event_receive_port_setup(, PS3_BINDING_CPU_ANY,
+   res = ps3_sb_event_receive_port_setup(>sbd, PS3_BINDING_CPU_ANY,
  );
if (res) {
pr_err("%s:%u: ps3_sb_event_receive_port_setup failed %d\n",
@@ -808,11 +819,11 @@ static int ps3_probe_thread(void *data)
   goto fail_close_device;
}
 
-   spin_lock_init();
-   rcuwait_init();
+   spin_lock_init(>lock);
+   rcuwait_init(>wait);
 
res = request_irq(irq, ps3_notification_interrupt, 0,
- "ps3_notification", );
+ "ps3_notification", >dev);
if (res) {
pr_err("%s:%u: request_irq failed %d\n", __func__, __LINE__,
   res);
@@ -823,7 +834,7 @@ static int ps3_probe_thread(void *data)
notify_cmd->operation_code = 0; /* must be zero */
notify_cmd->event_mask = 1UL << notify_region_probe;
 
-   res = ps3_notification_read_write(, lpar, 1);
+   res = ps3_notification_read_write(>dev, lpar, 1);
if (res)
goto fail_free_irq;
 
@@ -834,36 +845,36 @@ static int ps3_probe_thread(void *data)
 
memset(notify_event, 0, sizeof(*notify_event));
 
-   res = ps3_notification_read_write(, lpar, 0);
+   res = ps3_notification_read_write(>dev, lpar, 0);
if (res)
break;
 
pr_debug("%s:%u: notify event type 0x%llx bus id %llu dev id 
%llu"
 " type %llu port %llu\n", __func__, __LINE__,
-notify_event->event_type, notify_event->bus_id,
-notify_event->dev_id, notify_event->dev_type,
-notify_event->dev_port);
+   notify_event->event_type, notify_event->bus_id,
+   notify_event->dev_id, notify_event->dev_type,
+   

Re: [PATCH] powerpc: ps3: mark ps3_notification_device static for stack usage

2024-03-21 Thread Geoff Levand
Hi Geert,

On 3/21/24 17:32, Geert Uytterhoeven wrote:
>>  static int ps3_probe_thread(void *data)
>>  {
>> -   struct ps3_notification_device dev;
>> +   static struct ps3_notification_device dev;
>> int res;
>> unsigned int irq;
>> u64 lpar;
> 
> Making it static increases kernel size for everyone.  So I'd rather
> allocate it dynamically. The thread already allocates a buffer, which
> can be replaced at no cost by allocating a structure containing both
> the ps3_notification_device and the buffer.

This seems like a much better solution.

-Geoff




Re: [PATCH] powerpc: ps3: mark ps3_notification_device static for stack usage

2024-03-20 Thread Geoff Levand
On 3/21/24 03:03, Arnd Bergmann wrote:
> From: Arnd Bergmann 
> 
> The device is way too large to be on the stack, causing a warning for
> an allmodconfig build with clang:
> 
> arch/powerpc/platforms/ps3/device-init.c:771:12: error: stack frame size 
> (2064) exceeds limit (2048) in 'ps3_probe_thread' 
> [-Werror,-Wframe-larger-than]
>   771 | static int ps3_probe_thread(void *data)
> 
> There is only a single thread that ever accesses this, so it's fine to
> make it static, which avoids the warning.
> 
> Fixes: b4cb2941f855 ("[POWERPC] PS3: Use the HVs storage device notification 
> mechanism properly")
> Signed-off-by: Arnd Bergmann 
> ---
>  arch/powerpc/platforms/ps3/device-init.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/platforms/ps3/device-init.c 
> b/arch/powerpc/platforms/ps3/device-init.c
> index 878bc160246e..ce99f06698a9 100644
> --- a/arch/powerpc/platforms/ps3/device-init.c
> +++ b/arch/powerpc/platforms/ps3/device-init.c
> @@ -770,7 +770,7 @@ static struct task_struct *probe_task;
>  
>  static int ps3_probe_thread(void *data)
>  {
> - struct ps3_notification_device dev;
> + static struct ps3_notification_device dev;
>   int res;
>   unsigned int irq;
>   u64 lpar;

Seems fine.

Acked-by: Geoff Levand 



Re: [PATCH RFC net] ps3/gelic: Fix possible NULL pointer dereference

2024-02-21 Thread Geoff Levand
Hi Simon,

On 2/22/24 01:56, Simon Horman wrote:
> Fix possible NULL pointer dereference in gelic_card_release_tx_chain()
> 
> The cited commit introduced a netdev variable to
> gelic_card_release_tx_chain() which is set unconditionally on each
> iteration of a for loop.
> 
> It is set to the value of tx_chain->tail->skb->dev.  However, in some
> cases it is assumed that tx_chain->tail->skb may be NULL. And if that
> occurs, setting netdev will cause a NULl pointer dereference.
> 
> Given the age of this code I do wonder if this can occur in practice.
> But to be on the safe side this patch assumes that it can and aims to
> avoid the dereference in the case where tx_chain->tail->skb may be NULL.

After 17+ years I never hit this, and never heard of anyone hitting it...

> Flagged by Smatch.
> Compile tested only.

Thanks for 'fixing' this.

Acked-by: Geoff Levand 



Re: [PATCH net-next] ps3/gelic: minor Kernel Doc corrections

2024-02-21 Thread Geoff Levand
Hi Simon,

On 2/22/24 02:46, Simon Horman wrote:
> * Update the Kernel Doc for gelic_descr_set_tx_cmdstat()
>   and gelic_net_setup_netdev() so that documented name
>   and the actual name of the function match.
> 
> * Move define of GELIC_ALIGN() so that it is no longer
>   between gelic_alloc_card_net() and it's Kernel Doc.
> 
> * Document netdev parameter of gelic_alloc_card_net()
>   in a way consistent to the documentation of other netdev parameters
>   in this file.
> 
> Addresses the following warnings flagged by ./scripts/kernel-doc -none:
> 
>   .../ps3_gelic_net.c:711: warning: expecting prototype for 
> gelic_net_set_txdescr_cmdstat(). Prototype was for 
> gelic_descr_set_tx_cmdstat() instead
>   .../ps3_gelic_net.c:1474: warning: expecting prototype for 
> gelic_ether_setup_netdev(). Prototype was for gelic_net_setup_netdev() instead
>   .../ps3_gelic_net.c:1528: warning: expecting prototype for 
> gelic_alloc_card_net(). Prototype was for GELIC_ALIGN() instead
>   .../ps3_gelic_net.c:1531: warning: Function parameter or struct member 
> 'netdev' not described in 'gelic_alloc_card_net'
> 
> Signed-off-by: Simon Horman 
> ---
>  drivers/net/ethernet/toshiba/ps3_gelic_net.c | 8 +---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_net.c 
> b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
> index d5b75af163d3..12b96ca66877 100644
> --- a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
> +++ b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
> @@ -698,7 +698,7 @@ gelic_card_get_next_tx_descr(struct gelic_card *card)
>  }
>  
>  /**
> - * gelic_net_set_txdescr_cmdstat - sets the tx descriptor command field
> + * gelic_descr_set_tx_cmdstat - sets the tx descriptor command field
>   * @descr: descriptor structure to fill out
>   * @skb: packet to consider
>   *
> @@ -1461,7 +1461,7 @@ static void gelic_ether_setup_netdev_ops(struct 
> net_device *netdev,
>  }
>  
>  /**
> - * gelic_ether_setup_netdev - initialization of net_device
> + * gelic_net_setup_netdev - initialization of net_device
>   * @netdev: net_device structure
>   * @card: card structure
>   *
> @@ -1518,14 +1518,16 @@ int gelic_net_setup_netdev(struct net_device *netdev, 
> struct gelic_card *card)
>   return 0;
>  }
>  
> +#define GELIC_ALIGN (32)
> +
>  /**
>   * gelic_alloc_card_net - allocates net_device and card structure
> + * @netdev: interface device structure
>   *
>   * returns the card structure or NULL in case of errors
>   *
>   * the card and net_device structures are linked to each other
>   */
> -#define GELIC_ALIGN (32)
>  static struct gelic_card *gelic_alloc_card_net(struct net_device **netdev)
>  {
>   struct gelic_card *card;
> 

Looks good.  Thanks for taking care of it.

Acked-by: Geoff Levand 



Re: [PATCH RFC net] ps3/gelic: Fix possible NULL pointer dereference

2024-02-21 Thread Geoff Levand
On 2/22/24 03:32, Dan Carpenter wrote:
> This driver is PPC so I have never looked at the code before.  I noticed
> another issue that was introduced last December in commit 3ce4f9c3fbb3
> ("net/ps3_gelic_net: Add gelic_descr structures").
> 
> net/ethernet/toshiba/ps3_gelic_net.c
...
>375  static int gelic_descr_prepare_rx(struct gelic_card *card,
>376struct gelic_descr *descr)
>398  descr->skb = NULL;
> ^^
> NULL
> 
>399  
>400  offset = ((unsigned long)descr->skb->data) &
>  
> Dereferenced here.

There is a fix, see '[PATCH v6 net] ps3/gelic: Fix SKB allocation':

  https://lore.kernel.org/netdev/20240221172824.gd722...@kernel.org/T/

-Geoff


Re: [PATCH] drivers/ps3: select VIDEO to provide cmdline functions

2024-02-06 Thread Geoff Levand
Hi,

On 2/7/24 12:37, Randy Dunlap wrote:
> When VIDEO is not set, there is a build error. Fix that by selecting
> VIDEO for PS3_PS3AV.
> 
> ERROR: modpost: ".video_get_options" [drivers/ps3/ps3av_mod.ko] undefined!
> 
> Fixes: dae7fbf43fd0 ("driver/ps3: Include  for mode parsing")
> Signed-off-by: Randy Dunlap 
> Cc: Michael Ellerman 
> Cc: Nicholas Piggin 
> Cc: Christophe Leroy 
> Cc: Aneesh Kumar K.V 
> Cc: Naveen N. Rao 
> Cc: linuxppc-dev@lists.ozlabs.org
> Cc: Thomas Zimmermann 
> Cc: Geoff Levand 
> ---
>  arch/powerpc/platforms/ps3/Kconfig |1 +
>  1 file changed, 1 insertion(+)
> 
> diff -- a/arch/powerpc/platforms/ps3/Kconfig 
> b/arch/powerpc/platforms/ps3/Kconfig
> --- a/arch/powerpc/platforms/ps3/Kconfig
> +++ b/arch/powerpc/platforms/ps3/Kconfig
> @@ -67,6 +67,7 @@ config PS3_VUART
>  config PS3_PS3AV
>   depends on PPC_PS3
>   tristate "PS3 AV settings driver" if PS3_ADVANCED
> + select VIDEO
>   select PS3_VUART
>   default y
>   help

Seems good.

Acked-by: Geoff Levand 




Re: [PATCH 2/4] powerpc: ps3: make ps3_system_bus_type const

2024-02-04 Thread Geoff Levand
On 2/4/24 23:21, Ricardo B. Marliere wrote:
> Now that the driver core can properly handle constant struct bus_type,
> move the ps3_system_bus_type variable to be a constant structure as
> well, placing it into read-only memory which can not be modified at
> runtime.

> -static struct bus_type ps3_system_bus_type = {
> +static const struct bus_type ps3_system_bus_type = {
>   .name = "ps3_system_bus",
>   .match = ps3_system_bus_match,
>   .uevent = ps3_system_bus_uevent,

Seems fine.

Acked-by: Geoff Levand 

 



Re: ps3_gelic_net.c issue (linux kernel 6.8-rc1)

2024-01-24 Thread Geoff Levand
Hi,

On 1/25/24 15:46, Christophe Leroy wrote:
> Hi,
> 
> Le 24/01/2024 à 09:41, sambat goson a écrit :
>>  
>> Hi,
>> I've just test it and find below code not proper in function 
>> "gelic_descr_prepare_rx", line 398.
>> it causes error as my attached file.
>>
>> descr->skb = netdev_alloc_skb(*card->netdev, rx_skb_size);
>> if (!descr->skb) {
>> descr->hw_regs.payload.dev_addr = 0; /* tell DMAC don't touch memory */
>> return -ENOMEM;
>> }
>> 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;
>> descr->hw_regs.payload.dev_addr = 0;
>> descr->hw_regs.payload.size = 0;
>> descr->skb = NULL; >line 398
>>
> 
> Looks like a copy/paste error from gelic_descr_release_tx() in commit 
> 3ce4f9c3fbb3 ("net/ps3_gelic_net: Add gelic_descr structures"), the 
> whole block is wrong I guess, not only the descr->skb = NULL;
> 
> Geoff, can you fix it ?

Thanks for reporting the problem.  I'll look into fixing it.

-Geoff


[PATCH 3/4] powerpc/ps3: Make real stack frames for LV1 hcalls

2024-01-19 Thread Geoff Levand
The PS3 hcall assembly code makes ad-hoc stack frames that don't have
a back-chain pointer or meet other requirements like minimum frame size.
This probably confuses stack unwinders. Give all hcalls a real stack
frame.

Signed-off-by: Nicholas Piggin 
Signed-off-by: Geoff Levand 
---
 arch/powerpc/platforms/ps3/hvcall.S | 152 +---
 1 file changed, 94 insertions(+), 58 deletions(-)

diff --git a/arch/powerpc/platforms/ps3/hvcall.S 
b/arch/powerpc/platforms/ps3/hvcall.S
index b854675f6113..b6454d476962 100644
--- a/arch/powerpc/platforms/ps3/hvcall.S
+++ b/arch/powerpc/platforms/ps3/hvcall.S
@@ -9,6 +9,7 @@
 
 #include 
 #include 
+#include 
 
 #define lv1call .long 0x4422; extsw r3, r3
 
@@ -18,8 +19,10 @@ _GLOBAL(_##API_NAME) \
mflrr0; \
std r0, LRSAVE(r1); \
\
+   stdur1, -STACK_FRAME_MIN_SIZE(r1);  \
li  r11, API_NUMBER;\
lv1call;\
+   addir1, r1, STACK_FRAME_MIN_SIZE;   \
\
ld  r0, LRSAVE(r1); \
mtlrr0; \
@@ -40,12 +43,13 @@ _GLOBAL(_##API_NAME)\
mflrr0; \
std r0, LRSAVE(r1); \
\
-   stdur3, -8(r1); \
+   std r3, -8(r1); \
+   stdur1, -STACK_FRAME_MIN_SIZE-8(r1); \
\
li  r11, API_NUMBER;\
lv1call;\
\
-   addir1, r1, 8;  \
+   addir1, r1, STACK_FRAME_MIN_SIZE+8; \
ld  r11, -8(r1);\
std r4, 0(r11); \
\
@@ -60,12 +64,13 @@ _GLOBAL(_##API_NAME)\
std r0, LRSAVE(r1); \
\
std r3, -8(r1); \
-   stdur4, -16(r1);\
+   std r4, -16(r1);\
+   stdur1, -STACK_FRAME_MIN_SIZE-16(r1); \
\
li  r11, API_NUMBER;\
lv1call;\
\
-   addir1, r1, 16; \
+   addir1, r1, STACK_FRAME_MIN_SIZE+16; \
ld  r11, -8(r1);\
std r4, 0(r11); \
ld  r11, -16(r1);   \
@@ -83,12 +88,13 @@ _GLOBAL(_##API_NAME)\
\
std r3, -8(r1); \
std r4, -16(r1);\
-   stdur5, -24(r1);\
+   std r5, -24(r1);\
+   stdur1, -STACK_FRAME_MIN_SIZE-24(r1); \
\
li  r11, API_NUMBER;\
lv1call;\
\
-   addir1, r1, 24; \
+   addir1, r1, STACK_FRAME_MIN_SIZE+24; \
ld  r11, -8(r1);\
std r4, 0(r11); \
ld  r11, -16(r1);   \
@@ -112,12 +118,13 @@ _GLOBAL(_##API_NAME)  \
std r6, -32(r1);\
std r7, -40(r1);\
std r8, -48(r1);\
-   stdur9, -56(r1);\
+   std r9, -56(r1);\
+   stdur1, -STACK_FRAME_MIN_SIZE-56(r1); \
\
li  r11, API_NUMBER;\
lv1call;\
\
-   addir1, r1, 56; \
+   addir1, r1, STACK_FRAME_MIN_SIZE+56; \
ld  r11, -8(r1);\
std r4, 0(r11); \
ld  r11, -16(r1);   \
@@ -143,12 +150,13 @@ _GLOBAL(_##API_NAME)  \
mflrr0; \
std r0, LRSAVE(r1); \
\
-   stdur4, -8(r1); \
+   std r4, -8(r1); \
+   stdur1, -STACK_FRAME_MIN_SIZE-8(r1

[PATCH 4/4] Revert "powerpc/ps3_defconfig: Disable PPC64_BIG_ENDIAN_ELF_ABI_V2"

2024-01-19 Thread Geoff Levand
Patches provided by Nicholas Piggin enable PS3
support for ELFv2.

Signed-off-by: Geoff Levand 
---
 arch/powerpc/configs/ps3_defconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/powerpc/configs/ps3_defconfig 
b/arch/powerpc/configs/ps3_defconfig
index aa8bb0208bcc..2b175ddf82f0 100644
--- a/arch/powerpc/configs/ps3_defconfig
+++ b/arch/powerpc/configs/ps3_defconfig
@@ -24,7 +24,6 @@ CONFIG_PS3_VRAM=m
 CONFIG_PS3_LPM=m
 # CONFIG_PPC_OF_BOOT_TRAMPOLINE is not set
 CONFIG_KEXEC=y
-# CONFIG_PPC64_BIG_ENDIAN_ELF_ABI_V2 is not set
 CONFIG_PPC_4K_PAGES=y
 CONFIG_SCHED_SMT=y
 CONFIG_PM=y
-- 
2.34.1



[PATCH 1/4] powerpc/ps3: Fix lv1 hcall assembly for ELFv2 calling convention

2024-01-19 Thread Geoff Levand
Stack-passed parameters begin at a different offset in the caller's
stack in the ELFv2 ABI.

Reported-by: Geoff Levand 
Fixes: 8c5fa3b5c4df ("powerpc/64: Make ELFv2 the default for big-endian builds")
Signed-off-by: Nicholas Piggin 
Signed-off-by: Geoff Levand 
---
 arch/powerpc/include/asm/ppc_asm.h  |  6 --
 arch/powerpc/platforms/ps3/hvcall.S | 18 +-
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/include/asm/ppc_asm.h 
b/arch/powerpc/include/asm/ppc_asm.h
index e7792aa13510..041ee2595520 100644
--- a/arch/powerpc/include/asm/ppc_asm.h
+++ b/arch/powerpc/include/asm/ppc_asm.h
@@ -201,11 +201,13 @@
 
 #ifdef CONFIG_PPC64_ELF_ABI_V2
 #define STK_GOT24
-#define __STK_PARAM(i) (32 + ((i)-3)*8)
+#define STK_PARAM_AREA 32
 #else
 #define STK_GOT40
-#define __STK_PARAM(i) (48 + ((i)-3)*8)
+#define STK_PARAM_AREA 48
 #endif
+
+#define __STK_PARAM(i) (STK_PARAM_AREA + ((i)-3)*8)
 #define STK_PARAM(i)   __STK_PARAM(__REG_##i)
 
 #ifdef CONFIG_PPC64_ELF_ABI_V2
diff --git a/arch/powerpc/platforms/ps3/hvcall.S 
b/arch/powerpc/platforms/ps3/hvcall.S
index 509e30ad01bb..59ea569debf4 100644
--- a/arch/powerpc/platforms/ps3/hvcall.S
+++ b/arch/powerpc/platforms/ps3/hvcall.S
@@ -714,7 +714,7 @@ _GLOBAL(_##API_NAME)\
std r4, 0(r11); \
ld  r11, -16(r1);   \
std r5, 0(r11); \
-   ld  r11, 48+8*8(r1);\
+   ld  r11, STK_PARAM_AREA+8*8(r1);\
std r6, 0(r11); \
\
ld  r0, 16(r1); \
@@ -746,22 +746,22 @@ _GLOBAL(_##API_NAME)  \
mflrr0; \
std r0, 16(r1); \
\
-   std r10, 48+8*7(r1);\
+   std r10, STK_PARAM_AREA+8*7(r1);\
\
li  r11, API_NUMBER;\
lv1call;\
\
-   ld  r11, 48+8*7(r1);\
+   ld  r11, STK_PARAM_AREA+8*7(r1);\
std r4, 0(r11); \
-   ld  r11, 48+8*8(r1);\
+   ld  r11, STK_PARAM_AREA+8*8(r1);\
std r5, 0(r11); \
-   ld  r11, 48+8*9(r1);\
+   ld  r11, STK_PARAM_AREA+8*9(r1);\
std r6, 0(r11); \
-   ld  r11, 48+8*10(r1);   \
+   ld  r11, STK_PARAM_AREA+8*10(r1);   \
std r7, 0(r11); \
-   ld  r11, 48+8*11(r1);   \
+   ld  r11, STK_PARAM_AREA+8*11(r1);   \
std r8, 0(r11); \
-   ld  r11, 48+8*12(r1);   \
+   ld  r11, STK_PARAM_AREA+8*12(r1);   \
std r9, 0(r11); \
\
ld  r0, 16(r1); \
@@ -777,7 +777,7 @@ _GLOBAL(_##API_NAME)\
li  r11, API_NUMBER;\
lv1call;\
\
-   ld  r11, 48+8*8(r1);\
+   ld  r11, STK_PARAM_AREA+8*8(r1);\
std r4, 0(r11); \
\
ld  r0, 16(r1); \
-- 
2.34.1




[PATCH 2/4] powerpc/ps3: lv1 hcall code use symbolic constant for LR save offset

2024-01-19 Thread Geoff Levand
The LRSAVE constant is required for assembly compiled for both 32-bit
and 64-bit, because the value differs there. PS3 is 64-bit only so
this is a noop, but it is nice to abstract stack frame offsets.

Signed-off-by: Nicholas Piggin 
Signed-off-by: Geoff Levand 
---
 arch/powerpc/platforms/ps3/hvcall.S | 128 ++--
 1 file changed, 64 insertions(+), 64 deletions(-)

diff --git a/arch/powerpc/platforms/ps3/hvcall.S 
b/arch/powerpc/platforms/ps3/hvcall.S
index 59ea569debf4..b854675f6113 100644
--- a/arch/powerpc/platforms/ps3/hvcall.S
+++ b/arch/powerpc/platforms/ps3/hvcall.S
@@ -16,12 +16,12 @@
 _GLOBAL(_##API_NAME)   \
\
mflrr0; \
-   std r0, 16(r1); \
+   std r0, LRSAVE(r1); \
\
li  r11, API_NUMBER;\
lv1call;\
\
-   ld  r0, 16(r1); \
+   ld  r0, LRSAVE(r1); \
mtlrr0; \
blr
 
@@ -38,7 +38,7 @@ _GLOBAL(_##API_NAME)  \
 _GLOBAL(_##API_NAME)   \
\
mflrr0; \
-   std r0, 16(r1); \
+   std r0, LRSAVE(r1); \
\
stdur3, -8(r1); \
\
@@ -49,7 +49,7 @@ _GLOBAL(_##API_NAME)  \
ld  r11, -8(r1);\
std r4, 0(r11); \
\
-   ld  r0, 16(r1); \
+   ld  r0, LRSAVE(r1); \
mtlrr0; \
blr
 
@@ -57,7 +57,7 @@ _GLOBAL(_##API_NAME)  \
 _GLOBAL(_##API_NAME)   \
\
mflrr0; \
-   std r0, 16(r1); \
+   std r0, LRSAVE(r1); \
\
std r3, -8(r1); \
stdur4, -16(r1);\
@@ -71,7 +71,7 @@ _GLOBAL(_##API_NAME)  \
ld  r11, -16(r1);   \
std r5, 0(r11); \
\
-   ld  r0, 16(r1); \
+   ld  r0, LRSAVE(r1); \
mtlrr0; \
blr
 
@@ -79,7 +79,7 @@ _GLOBAL(_##API_NAME)  \
 _GLOBAL(_##API_NAME)   \
\
mflrr0; \
-   std r0, 16(r1); \
+   std r0, LRSAVE(r1); \
\
std r3, -8(r1); \
std r4, -16(r1);\
@@ -96,7 +96,7 @@ _GLOBAL(_##API_NAME)  \
ld  r11, -24(r1);   \
std r6, 0(r11); \
\
-   ld  r0, 16(r1); \
+   ld  r0, LRSAVE(r1); \
mtlrr0; \
blr
 
@@ -104,7 +104,7 @@ _GLOBAL(_##API_NAME)\
 _GLOBAL(_##API_NAME)   \
\
mflrr0; \
-   std r0, 16(r1); \
+   std r0, LRSAVE(r1); \
\
std r3, -8(r1); \
std r4, -16(r1);\
@@ -133,7 +133,7 @@ _GLOBAL(_##API_NAME)\
ld  r11, -56(r1);   \
std r10, 0(r11);\
\
-   ld  r0, 16(r1); \
+   ld  r0, LRSAVE(r1); \
mtlrr0; \
blr
 
@@ -141,7 +141,7 @@ _GLOBAL(_##API_NAME)\
 _GLOBAL(_##API_NAME)   \
\
mflrr0; \
-   std r0, 16(r1); \
+   std r0, LRSAVE(r1

[PATCH 0/4] powerpc/ps3 Add ELFv2 support

2024-01-19 Thread Geoff Levand
The following changes since commit 44a1aad2fe6c10bfe0589d8047057b10a4c18a19:

  Merge branch 'topic/ppc-kvm' into next (2023-12-29 15:30:45 +1100)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/geoff/ps3-linux.git 
for-merge-elfv2

for you to fetch changes up to 983836405df1b6001a2262972fb32d1aee97d6f5:

  Revert "powerpc/ps3_defconfig: Disable PPC64_BIG_ENDIAN_ELF_ABI_V2" 
(2024-01-19 17:53:48 +0900)

--------
Geoff Levand (1):
  Revert "powerpc/ps3_defconfig: Disable PPC64_BIG_ENDIAN_ELF_ABI_V2"

Nicholas Piggin (3):
  powerpc/ps3: Fix lv1 hcall assembly for ELFv2 calling convention
  powerpc/ps3: lv1 hcall code use symbolic constant for LR save offset
  powerpc/ps3: Make real stack frames for LV1 hcalls

 arch/powerpc/configs/ps3_defconfig  |   1 -
 arch/powerpc/include/asm/ppc_asm.h  |   6 +-
 arch/powerpc/platforms/ps3/hvcall.S | 298 
 3 files changed, 171 insertions(+), 134 deletions(-)

-- 
2.34.1



Re: [PATCH 0/3] powerpc/ps3: Fixes for lv1 hcall assembly

2023-12-29 Thread Geoff Levand
Hi Nick,

On 12/27/23 18:50, Geoff Levand wrote:
>> Nicholas Piggin (3):
>>   powerpc/ps3: Fix lv1 hcall assembly for ELFv2 calling convention
>>   powerpc/ps3: lv1 hcall code use symbolic constant for LR save offset
>>   powerpc/ps3: Make real stack frames for LV1 hcalls

I tested these patches applied to v6.7-rc7 on PS3 with
CONFIG_PPC64_BIG_ENDIAN_ELF_ABI_V2=y, and they seem to be working OK.  I did
not do any extensive testing though.

I tested three configurations:

 - With only the first patch 'Fix lv1 hcall assembly for ELFv2 calling
   convention' applied.

 - With the first two patches, 'Fix lv1 hcall assembly for ELFv2 calling
   convention' and 'lv1 hcall code use symbolic constant for LR save
   offset' applied.

 - And with all three patches applied.

All three configurations worked OK.  Thanks again for working on this.

Michael, I think we can just add these three patches and remove my patch that
disables CONFIG_PPC64_BIG_ENDIAN_ELF_ABI_V2.

Tested-by: Geoff Levand 



Re: [PATCH 0/3] powerpc/ps3: Fixes for lv1 hcall assembly

2023-12-27 Thread Geoff Levand
Hi,

On 12/27/23 16:24, Nicholas Piggin wrote:
> This (hopefully) fixes the ELFv2 bug that Geoff reported, with patch
> 1. And a couple of other possible improvements I noticed.
> 
> I don't have a PS3 setup[*] so I have only compile tested these, I'm
> sorry.
> 
> [*] Is RPCS3 usable for this kind of thing?
> 
> Thanks,
> Nick
> 
> Nicholas Piggin (3):
>   powerpc/ps3: Fix lv1 hcall assembly for ELFv2 calling convention
>   powerpc/ps3: lv1 hcall code use symbolic constant for LR save offset
>   powerpc/ps3: Make real stack frames for LV1 hcalls

A big thanks for working on this.  I'll test on PS3 within the next
few days and report back.

-Geoff



Re: [PATCH] powerpc/ps3_defconfig: Disable PPC64_BIG_ENDIAN_ELF_ABI_V2

2023-12-27 Thread Geoff Levand
Hi Michael,

On 12/27/23 10:27, Michael Ellerman wrote:
> Geoff Levand  writes:
>> Commit 8c5fa3b5c4df3d071dab42b04b971df370d99354 (powerpc/64: Make ELFv2 the
>> default for big-endian builds), merged in Linux-6.5-rc1 changes the calling 
>> ABI
>> in a way that is incompatible with the current code for the PS3's LV1 
>> hypervisor
>> calls.
> 
> I'll take this for now.
> 
> But medium term we would like to switch to only using ELFv2, so it would
> be good if we can work out what the actual problem is.

I've been looking into converting the LV1 hypercalls to v2.

>> This change just adds the line '# CONFIG_PPC64_BIG_ENDIAN_ELF_ABI_V2 is not 
>> set'
>> to the ps3_defconfig file so that the PPC64_ELF_ABI_V1 is used.
>>
>> Fixes run time errors like these:
>>
>>  BUG: Kernel NULL pointer dereference at 0x
>>  Faulting instruction address: 0xc0047cf0
>>  Oops: Kernel access of bad area, sig: 11 [#1]
>>
>>  Call Trace:
>>  [c23039e0] [c100ebfc] ps3_create_spu+0xc4/0x2b0 
>> (unreliable)
>>  [c2303ab0] [c100d4c4] create_spu+0xcc/0x3c4
>>  [c2303b40] [c100eae4] ps3_enumerate_spus+0xa4/0xf8
> 
> That can't be the first hvcall we've done, there's one in
> ps3_setup_arch(). So I guess only some hcalls are failing?

I guess because ps3_create_spu has 7 input parameters and returns
6 parameters, so it hits some difference between V1 and V2 that
the other LV1 calls up to that point have not hit.

-Geoff


[PATCH] powerpc/ps3_defconfig: Disable PPC64_BIG_ENDIAN_ELF_ABI_V2

2023-12-23 Thread Geoff Levand
Commit 8c5fa3b5c4df3d071dab42b04b971df370d99354 (powerpc/64: Make ELFv2 the
default for big-endian builds), merged in Linux-6.5-rc1 changes the calling ABI
in a way that is incompatible with the current code for the PS3's LV1 hypervisor
calls.

This change just adds the line '# CONFIG_PPC64_BIG_ENDIAN_ELF_ABI_V2 is not set'
to the ps3_defconfig file so that the PPC64_ELF_ABI_V1 is used.

Fixes run time errors like these:

BUG: Kernel NULL pointer dereference at 0x
Faulting instruction address: 0xc0047cf0
Oops: Kernel access of bad area, sig: 11 [#1]

Call Trace:
[c23039e0] [c100ebfc] ps3_create_spu+0xc4/0x2b0 
(unreliable)
[c2303ab0] [c100d4c4] create_spu+0xcc/0x3c4
[c2303b40] [c100eae4] ps3_enumerate_spus+0xa4/0xf8

Signed-off-by: Geoff Levand 
---
 arch/powerpc/configs/ps3_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/powerpc/configs/ps3_defconfig 
b/arch/powerpc/configs/ps3_defconfig
index 2b175ddf82f0..aa8bb0208bcc 100644
--- a/arch/powerpc/configs/ps3_defconfig
+++ b/arch/powerpc/configs/ps3_defconfig
@@ -24,6 +24,7 @@ CONFIG_PS3_VRAM=m
 CONFIG_PS3_LPM=m
 # CONFIG_PPC_OF_BOOT_TRAMPOLINE is not set
 CONFIG_KEXEC=y
+# CONFIG_PPC64_BIG_ENDIAN_ELF_ABI_V2 is not set
 CONFIG_PPC_4K_PAGES=y
 CONFIG_SCHED_SMT=y
 CONFIG_PM=y
-- 
2.34.1



Re: [PATCH 3/3] powerpc: ps3: Add missing set_freezable() for ps3_probe_thread()

2023-12-20 Thread Geoff Levand
Hi Kevin,

On 12/21/23 13:45, Kevin Hao wrote:
> The kernel thread function ps3_probe_thread() invokes the try_to_freeze()
> in its loop. But all the kernel threads are non-freezable by default.
> So if we want to make a kernel thread to be freezable, we have to invoke
> set_freezable() explicitly.
> 
> Signed-off-by: Kevin Hao 
> ---
>  arch/powerpc/platforms/ps3/device-init.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/powerpc/platforms/ps3/device-init.c 
> b/arch/powerpc/platforms/ps3/device-init.c
> index e87360a0fb40..878bc160246e 100644
> --- a/arch/powerpc/platforms/ps3/device-init.c
> +++ b/arch/powerpc/platforms/ps3/device-init.c
> @@ -827,6 +827,7 @@ static int ps3_probe_thread(void *data)
>   if (res)
>   goto fail_free_irq;
>  
> + set_freezable();
>   /* Loop here processing the requested notification events. */
>   do {
>   try_to_freeze();

Seems like a reasonable addition.

Signed-off-by: Geoff Levand 



Re: [PATCH 17/22] powerpc: ps3: move udbg_shutdown_ps3gelic prototype

2023-11-08 Thread Geoff Levand
Hi Arnd,

On 11/8/23 12:58, Arnd Bergmann wrote:
> From: Arnd Bergmann 
> 
> Allmodconfig kernels produce a missing-prototypes warning:
> 
> arch/powerpc/platforms/ps3/gelic_udbg.c:239:6: error: no previous prototype 
> for 'udbg_shutdown_ps3gelic' [-Werror=missing-prototypes]
> 
> Move the declaration from a local header to asm/ps3.h where it can be
> seen from both the caller and the definition.
> 
> Signed-off-by: Arnd Bergmann 
> ---
>  arch/powerpc/include/asm/ps3.h   | 6 ++
>  arch/powerpc/platforms/ps3/gelic_udbg.c  | 1 +
>  drivers/net/ethernet/toshiba/ps3_gelic_net.h | 6 --
>  3 files changed, 7 insertions(+), 6 deletions(-)

Seems good to me.  I'll test it next chance I get.

Signed-off-by: Geoff Levand 




Re: [PATCH] [RFC] wireless: move obsolete drivers to staging

2023-10-12 Thread Geoff Levand
On 10/12/23 17:41, Johannes Berg wrote:
> But seriously - is it worth to try to keep a wireless driver for it if
> we don't even know anyone using a PS3 at all?

There is still a considerable user base for the PS3, so we
must keep the ps3-gelic-wireless driver.

-Geoff



Re: [PATCH][next] net: spider_net: Use size_add() in call to struct_size()

2023-09-15 Thread Geoff Levand
On 9/15/23 14:25, Gustavo A. R. Silva wrote:
> If, for any reason, the open-coded arithmetic causes a wraparound,
> the protection that `struct_size()` adds against potential integer
> overflows is defeated. Fix this by hardening call to `struct_size()`
> with `size_add()`.
> 
> Fixes: 3f1071ec39f7 ("net: spider_net: Use struct_size() helper")
> Signed-off-by: Gustavo A. R. Silva 
> ---
>  drivers/net/ethernet/toshiba/spider_net.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/toshiba/spider_net.c 
> b/drivers/net/ethernet/toshiba/spider_net.c
> index 50d7eacfec58..87e67121477c 100644
> --- a/drivers/net/ethernet/toshiba/spider_net.c
> +++ b/drivers/net/ethernet/toshiba/spider_net.c
> @@ -2332,7 +2332,7 @@ spider_net_alloc_card(void)
>   struct spider_net_card *card;
>  
>   netdev = alloc_etherdev(struct_size(card, darray,
> - tx_descriptors + rx_descriptors));
> + size_add(tx_descriptors, 
> rx_descriptors)));
>   if (!netdev)
>       return NULL;
>  

Looks good to me.  Thanks for your fix-up.

Signed-off-by: Geoff Levand 




Re: [PATCH] powerpc/ps3: refactor strncpy usage

2023-08-17 Thread Geoff Levand
On 8/16/23 14:39, Justin Stitt wrote:
> `strncpy` is deprecated for use on NUL-terminated destination strings [1].
> 
> `make_first_field()` should use similar implementation to `make_field()`
> due to memcpy having more obvious behavior here. The end result yields
> the same behavior as the previous `strncpy`-based implementation
> including the NUL-padding.

> diff --git a/arch/powerpc/platforms/ps3/repository.c 
> b/arch/powerpc/platforms/ps3/repository.c
> index 205763061a2d..1abe33fbe529 100644
> --- a/arch/powerpc/platforms/ps3/repository.c
> +++ b/arch/powerpc/platforms/ps3/repository.c
> @@ -73,9 +73,9 @@ static void _dump_node(unsigned int lpar_id, u64 n1, u64 
> n2, u64 n3, u64 n4,

I tested this on PS3 and it seems to be working OK.

Tested-by: Geoff Levand 




Re: [PATCH -next] net/ps3_gelic_net: Use ether_addr_to_u64() to convert ethernet address

2023-08-08 Thread Geoff Levand
Hi,

On 8/8/23 04:40, Li Zetao wrote:
> Use ether_addr_to_u64() to convert an Ethernet address into a u64 value,
> instead of directly calculating, as this is exactly what
> this function does.
> 
> Signed-off-by: Li Zetao 
> ---
>  drivers/net/ethernet/toshiba/ps3_gelic_net.c | 8 +---
>  1 file changed, 1 insertion(+), 7 deletions(-)

I tested this on PS3 and it seems to be working OK.
Thanks for your contribution.

Tested-by: Geoff Levand 



Re: [PATCH 04/11] drivers/ps3: Read video= option with fb_get_option()

2023-02-13 Thread Geoff Levand
Hi,

On 2/13/23 03:29, Thomas Zimmermann wrote:
> Am 12.02.23 um 17:53 schrieb Geoff Levand:
>> On 2/9/23 05:55, Thomas Zimmermann wrote:
>>> Get the kernel's global video= parameter with fb_get_option(). Done
>>> to unexport the internal fbdev state fb_mode_config. No functional
>>> changes.
>>>
>>> Signed-off-by: Thomas Zimmermann 
>>> ---
>>>   drivers/ps3/ps3av.c | 11 +--
>>>   1 file changed, 9 insertions(+), 2 deletions(-)
>>
>> I wanted to test these changes on the PS3, but got this
>> error when trying to apply this patch set to Linux-6.2-rc7:
>>
>>    Applying: fbdev: Handle video= parameter in video/cmdline.c
>>    error: patch failed: drivers/gpu/drm/Kconfig:10
>>    error: drivers/gpu/drm/Kconfig: patch does not apply
>>
>> Is there a Linux kernel revision that these will apply to,
>> or is there a git repository I can pull them from?
> 
> Thanks for testing.  My base version is a recent DRM development tree. The 
> repo is at https://cgit.freedesktop.org/drm/drm-tip/, the branch is drm-tip.

I tested the drm-tip branch at c54b5fcf3e68 on PS3 and it
seemed to work OK.

Tested-by: Geoff Levand 



Re: [PATCH 04/11] drivers/ps3: Read video= option with fb_get_option()

2023-02-12 Thread Geoff Levand
Hi Thomas,

On 2/9/23 05:55, Thomas Zimmermann wrote:
> Get the kernel's global video= parameter with fb_get_option(). Done
> to unexport the internal fbdev state fb_mode_config. No functional
> changes.
> 
> Signed-off-by: Thomas Zimmermann 
> ---
>  drivers/ps3/ps3av.c | 11 +--
>  1 file changed, 9 insertions(+), 2 deletions(-)

I wanted to test these changes on the PS3, but got this
error when trying to apply this patch set to Linux-6.2-rc7:

  Applying: fbdev: Handle video= parameter in video/cmdline.c
  error: patch failed: drivers/gpu/drm/Kconfig:10
  error: drivers/gpu/drm/Kconfig: patch does not apply

Is there a Linux kernel revision that these will apply to,
or is there a git repository I can pull them from?

-Geoff


Re: [PATCH 3/3] ALSA: core: Make snd_card_free() return void

2023-02-07 Thread Geoff Levand
Hi Uwe,

On 2/7/23 11:19, Uwe Kleine-König wrote:
> The function returns 0 unconditionally. Make it return void instead and
> simplify all callers accordingly.
> 
> Signed-off-by: Uwe Kleine-König 
> ---
>  include/sound/core.h  | 2 +-
>  sound/core/init.c | 6 ++
>  sound/pci/hda/hda_tegra.c | 6 ++
>  sound/ppc/snd_ps3.c   | 4 +---
>  4 files changed, 6 insertions(+), 12 deletions(-)

> --- a/sound/ppc/snd_ps3.c
> +++ b/sound/ppc/snd_ps3.c
> @@ -1053,9 +1053,7 @@ static void snd_ps3_driver_remove(struct 
> ps3_system_bus_device *dev)
>* ctl and preallocate buffer will be freed in
>* snd_card_free
>*/
> - ret = snd_card_free(the_card.card);
> - if (ret)
> - pr_info("%s: ctl freecard=%d\n", __func__, ret);
> + snd_card_free(the_card.card);
>  
>   dma_free_coherent(>core,
> PAGE_SIZE,

Looks OK for PS3.

Acked-by: Geoff Levand 



Re: [PATCH v2 1/2] powerpc/ps3: Change updateboltedpp panic to info

2023-01-28 Thread Geoff Levand
On 1/16/23 23:26, Christophe Leroy wrote:
> Le 16/01/2023 à 21:08, Geoff Levand a écrit :
>>
>> As mentioned, I'd really like to keep PS3 included in ppc64_defconfig.  My
>> original patch that basically just ignores the call to
>> mmu_hash_ops.updateboltedpp allows that, and I haven't experienced any 
>> problems
>> with it yet.
> 
> When you say you have not experienced any problems with it, do you mean 
> that STRICT_RWX works for you ? When you select CONFIG_DEBUG_RODATA_TEST 
> it tells you that it works ? Otherwise it looks incorrect to enable 
> something that doesn't work.

What I mean is that the system boots up, and works as expected.
I have not tried with CONFIG_DEBUG_RODATA_TEST set.

>> My preference would be to keep PS3 in ppc64_defconfig, and either apply my
>> original patch, or I keep that patch in my ps3-linux repo on kernel.org. 
>> Then,
>> if we end up adding runtime support for RWX I then fixup PS3 to use that.
>>
> 
> In that case I see two solutions:
> 1/ Implement updateboltedpp for PS3.

I'm now looking into if this is possible.

> 2/ Implement arch_parse_debug_rodata() to always set rodata_enabled = 
> false on PS3, and update free_initmem() to only call mark_initmem_nx() 
> when strict_kernel_rwx_enabled() returns true.

OK, I'll consider this if I cannot get updateboltedp working.

-Geoff



Re: [PATCH] ps3vram: remove bio splitting

2023-01-23 Thread Geoff Levand
Hi Christoph,

On 1/22/23 23:47, Christoph Hellwig wrote:
> ps3vram iterates over the bio one segment, that is page aligned and max
> page sized chunk, a time.  Because of that there is no point in
> calling bio_split_to_limits, or explicitly setting the default limits
> that are only used by bio_split_to_limits.
> 
> Signed-off-by: Christoph Hellwig 
> ---
>  drivers/block/ps3vram.c | 7 ---
>  1 file changed, 7 deletions(-)

I tested this patch applied to the ps3-queue branch (v6.2-rc5 based) of my
kernel.org ps3-linux repo.  I could format the ps3vram device with ext4,
copy files to it, run fsck, etc.

Thanks for your effort.

Tested-by: Geoff Levand 



Re: [PATCH v2 1/2] powerpc/ps3: Change updateboltedpp panic to info

2023-01-16 Thread Geoff Levand
Hi,

On 1/15/23 16:06, Michael Ellerman wrote:
> Geoff Levand  writes:
>> On 1/9/23 09:41, Christophe Leroy wrote:
>>>
>>>
>>> Le 03/01/2023 à 18:51, Geoff Levand a écrit :
>>>> Commit fdacae8a84024474afff234bdd1dbe19ad597a10 (powerpc: Activate
>>>> CONFIG_STRICT_KERNEL_RWX by default) causes ps3_hpte_updateboltedpp()
>>>> to be called.  Change the panic statment in ps3_hpte_updateboltedpp()
>>>> to a pr_info statement so that bootup can continue.
>>>
>>> But if I understand correctly, it means that CONFIG_STRICT_KERNEL_RWX 
>>> won't work then.
>>>
>>> So, shouldn't we keep the panic and forbid CONFIG_STRICT_KERNEL_RWX on PS3 ?
>>
>> mmu_hash_ops.updateboltedpp returns void, so I can't return an error code to
>> indicate the feature is not supported.
> 
> We could change that in the medium term.
> 
>> I could do something like this in arch/powerpc/Kconfig:
>>
>> -   select ARCH_HAS_STRICT_KERNEL_RWX   if (PPC_BOOK3S || PPC_8xx || 
>> 40x) && !HIBERNATION
>> +   select ARCH_HAS_STRICT_KERNEL_RWX   if (PPC_BOOK3S || PPC_8xx || 
>> 40x) && !PPC_PS3 && !HIBERNATION
>>
>> But then the ppc64_defconfig would be built without STRICT_KERNEL_RWX.
> 
> Yeah that would be a pity.
> 
> We could do the above and disable PS3 in ppc64_defconfig, allowing
> ppc64_defconfig to still have STRICT_KERNEL_RWX.

I really want to keep PS3 included in ppc64_defconfig.  Not that I expect
anyone to boot a ppc64_defconfig kernel on PS3, but that is one of the
'standard' configs that is built by some automated builders, and generally by
anyone doing changes to the powerpc arch, and I want to keep getting those
build tests for PS3.

> I assume actual PS3 users would use a ps3_defconfig anyway right?

Yeah, a derivative of it.  They are most likely are using 'Jailbreak' firmware
that allows them to run Linux in the gameos partition.

> Relatedly are there any actual PS3 users left? ;)

It seems there are more users now than a few years ago.  I think they buy PS5s
to play the latest games, and use their old console to mess around with Linux.
I generally get a private inquiry every 3 or 4 weeks.  Usually asking how to
update their kernel, or how to install a modern distro.

>> What other 'clean' way is there?
> 
> If we want to have a multi-platform kernel image that can boot on PS3
> and other platforms, and have strict kernel RWX, then we need some
> runtime logic to deal with that.
> 
> I'd rather not do that though, because it adds complexity to deal with a
> pretty obscure corner case, and I suspect no one really boots a
> ppc64_defconfig on actual PS3 hardware these days.
> 
> So my preference is we disable PS3 in ppc64_defconfig, and make PS3
> incompatible with STRICT_KERNEL_RWX.

As mentioned, I'd really like to keep PS3 included in ppc64_defconfig.  My
original patch that basically just ignores the call to
mmu_hash_ops.updateboltedpp allows that, and I haven't experienced any problems
with it yet.

My preference would be to keep PS3 in ppc64_defconfig, and either apply my
original patch, or I keep that patch in my ps3-linux repo on kernel.org. Then,
if we end up adding runtime support for RWX I then fixup PS3 to use that.

-Geoff




[PATCH v1 1/1] hvc_console: Allow backends to set I/O buffer size

2023-01-15 Thread Geoff Levand
To allow HVC backends to set the I/O buffer sizes to values that are most
efficient for the backend, change the macro definitions where the buffer sizes
are set to be conditional on whether or not the macros are already defined.
Also, rename the macros from N_OUTBUF to HVC_N_OUBUF and from N_INBUF to
HVC_N_INBUF.

Typical usage in the backend source file would be:

  #define HVC_N_OUTBUF 32
  #define HVC_N_INBUF 32
  #include "hvc_console.h"

Signed-off-by: Geoff Levand 
---

Hi,

With this patch the buffer sizes are set by defining preprocessor macros before
including the hvc_console.h header file.  Another way would be to have Kconfig
options for the buffer sizes.  Since the optimal buffer size is so closely tied
to the backend implementation I thought that using these preprocessor macros
would be the better way.

-Geoff

The following changes since commit 5dc4c995db9eb45f6373a956eb1f69460e69e6d4:

  Linux 6.2-rc4 (2023-01-15 09:22:43 -0600)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/geoff/ps3-linux.git 
for-merge-hvc-v1

for you to fetch changes up to 8f3cd1e0589f134380f80a1f551c8232ed0bc1f2:

  hvc_console: Allow backends to set I/O buffer size (2023-01-15 09:36:22 -0800)


 drivers/tty/hvc/hvc_console.c | 19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
index a683e21df19c..f7809d19e2cd 100644
--- a/drivers/tty/hvc/hvc_console.c
+++ b/drivers/tty/hvc/hvc_console.c
@@ -42,12 +42,15 @@
 #define HVC_CLOSE_WAIT (HZ/100) /* 1/10 of a second */
 
 /*
- * These sizes are most efficient for vio, because they are the
- * native transfer size. We could make them selectable in the
- * future to better deal with backends that want other buffer sizes.
+ * These default sizes are most efficient for vio, because they are
+ * the native transfer size.
  */
-#define N_OUTBUF   16
-#define N_INBUF16
+#if !defined(HVC_N_OUTBUF)
+# define HVC_N_OUTBUF  16
+#endif
+#if !defined(HVC_N_INBUF)
+# define HVC_N_INBUF   16
+#endif
 
 #define __ALIGNED__ __attribute__((__aligned__(L1_CACHE_BYTES)))
 
@@ -151,7 +154,7 @@ static uint32_t vtermnos[MAX_NR_HVC_CONSOLES] =
 static void hvc_console_print(struct console *co, const char *b,
  unsigned count)
 {
-   char c[N_OUTBUF] __ALIGNED__;
+   char c[HVC_N_OUTBUF] __ALIGNED__;
unsigned i = 0, n = 0;
int r, donecr = 0, index = co->index;
 
@@ -633,7 +636,7 @@ static int __hvc_poll(struct hvc_struct *hp, bool may_sleep)
 {
struct tty_struct *tty;
int i, n, count, poll_mask = 0;
-   char buf[N_INBUF] __ALIGNED__;
+   char buf[HVC_N_INBUF] __ALIGNED__;
unsigned long flags;
int read_total = 0;
int written_total = 0;
@@ -674,7 +677,7 @@ static int __hvc_poll(struct hvc_struct *hp, bool may_sleep)
 
  read_again:
/* Read data if any */
-   count = tty_buffer_request_room(>port, N_INBUF);
+   count = tty_buffer_request_room(>port, HVC_N_INBUF);
 
/* If flip is full, just reschedule a later read */
if (count == 0) {
-- 
2.34.1



Re: [PATCH v2 1/2] powerpc/ps3: Change updateboltedpp panic to info

2023-01-14 Thread Geoff Levand
Hi Christophe,

On 1/9/23 09:41, Christophe Leroy wrote:
> 
> 
> Le 03/01/2023 à 18:51, Geoff Levand a écrit :
>> Commit fdacae8a84024474afff234bdd1dbe19ad597a10 (powerpc: Activate
>> CONFIG_STRICT_KERNEL_RWX by default) causes ps3_hpte_updateboltedpp()
>> to be called.  Change the panic statment in ps3_hpte_updateboltedpp()
>> to a pr_info statement so that bootup can continue.
> 
> But if I understand correctly, it means that CONFIG_STRICT_KERNEL_RWX 
> won't work then.
> 
> So, shouldn't we keep the panic and forbid CONFIG_STRICT_KERNEL_RWX on PS3 ?

mmu_hash_ops.updateboltedpp returns void, so I can't return an error code to
indicate the feature is not supported.

I could do something like this in arch/powerpc/Kconfig:

-   select ARCH_HAS_STRICT_KERNEL_RWX   if (PPC_BOOK3S || PPC_8xx || 
40x) && !HIBERNATION
+   select ARCH_HAS_STRICT_KERNEL_RWX   if (PPC_BOOK3S || PPC_8xx || 
40x) && !PPC_PS3 && !HIBERNATION

But then the ppc64_defconfig would be built without STRICT_KERNEL_RWX.

I could do this in ps3_defconfig:

+# CONFIG_STRICT_KERNEL_RWX is not set
+# CONFIG_STRICT_MODULE_RWX is not set

But I don't like that way because it seems too easy for users to not add those
into a custom kernel config, and then they need to figure out what to do after
their kernel panics on startup.

What other 'clean' way is there?

-Geoff




[PATCH v2 1/2] powerpc/ps3: Change updateboltedpp panic to info

2023-01-03 Thread Geoff Levand
Commit fdacae8a84024474afff234bdd1dbe19ad597a10 (powerpc: Activate
CONFIG_STRICT_KERNEL_RWX by default) causes ps3_hpte_updateboltedpp()
to be called.  Change the panic statment in ps3_hpte_updateboltedpp()
to a pr_info statement so that bootup can continue.

Signed-off-by: Geoff Levand 
---
 arch/powerpc/platforms/ps3/htab.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/ps3/htab.c 
b/arch/powerpc/platforms/ps3/htab.c
index c27e6cf85272..9de62bd52650 100644
--- a/arch/powerpc/platforms/ps3/htab.c
+++ b/arch/powerpc/platforms/ps3/htab.c
@@ -146,7 +146,7 @@ static long ps3_hpte_updatepp(unsigned long slot, unsigned 
long newpp,
 static void ps3_hpte_updateboltedpp(unsigned long newpp, unsigned long ea,
int psize, int ssize)
 {
-   panic("ps3_hpte_updateboltedpp() not implemented");
+   pr_info("ps3_hpte_updateboltedpp() not implemented");
 }
 
 static void ps3_hpte_invalidate(unsigned long slot, unsigned long vpn,
-- 
2.34.1




[PATCH v2 2/2] powerpc/ps3: Refresh ps3_defconfig

2023-01-03 Thread Geoff Levand
Refresh ps3_defconfig for v6.2.

Signed-off-by: Geoff Levand 
---
 arch/powerpc/configs/ps3_defconfig | 39 +-
 1 file changed, 17 insertions(+), 22 deletions(-)

diff --git a/arch/powerpc/configs/ps3_defconfig 
b/arch/powerpc/configs/ps3_defconfig
index 0a1b42c4f26a..52a8c5450ecb 100644
--- a/arch/powerpc/configs/ps3_defconfig
+++ b/arch/powerpc/configs/ps3_defconfig
@@ -1,8 +1,3 @@
-CONFIG_PPC64=y
-CONFIG_CELL_CPU=y
-CONFIG_ALTIVEC=y
-CONFIG_SMP=y
-CONFIG_NR_CPUS=2
 CONFIG_SYSVIPC=y
 CONFIG_POSIX_MQUEUE=y
 CONFIG_HIGH_RES_TIMERS=y
@@ -10,11 +5,12 @@ CONFIG_BLK_DEV_INITRD=y
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 CONFIG_EMBEDDED=y
 # CONFIG_PERF_EVENTS is not set
-# CONFIG_COMPAT_BRK is not set
-CONFIG_SLAB=y
 CONFIG_PROFILING=y
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
+CONFIG_PPC64=y
+CONFIG_CELL_CPU=y
+CONFIG_ALTIVEC=y
+CONFIG_SMP=y
+CONFIG_NR_CPUS=2
 # CONFIG_PPC_POWERNV is not set
 # CONFIG_PPC_PSERIES is not set
 # CONFIG_PPC_PMAC is not set
@@ -27,17 +23,20 @@ CONFIG_PS3_FLASH=y
 CONFIG_PS3_VRAM=m
 CONFIG_PS3_LPM=m
 # CONFIG_PPC_OF_BOOT_TRAMPOLINE is not set
-# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
-CONFIG_BINFMT_MISC=y
 CONFIG_KEXEC=y
 CONFIG_PPC_4K_PAGES=y
-# CONFIG_SPARSEMEM_VMEMMAP is not set
-# CONFIG_COMPACTION is not set
 CONFIG_SCHED_SMT=y
 CONFIG_PM=y
 CONFIG_PM_DEBUG=y
 # CONFIG_SECCOMP is not set
-# CONFIG_PCI is not set
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
+CONFIG_BINFMT_MISC=y
+CONFIG_SLAB=y
+# CONFIG_COMPAT_BRK is not set
+# CONFIG_SPARSEMEM_VMEMMAP is not set
+# CONFIG_COMPACTION is not set
 CONFIG_NET=y
 CONFIG_PACKET=y
 CONFIG_UNIX=y
@@ -87,7 +86,6 @@ CONFIG_USB_USBNET=m
 # CONFIG_USB_NET_NET1080 is not set
 # CONFIG_USB_NET_CDC_SUBSET is not set
 # CONFIG_USB_NET_ZAURUS is not set
-CONFIG_INPUT_FF_MEMLESS=m
 CONFIG_INPUT_JOYDEV=m
 CONFIG_INPUT_EVDEV=m
 # CONFIG_INPUT_KEYBOARD is not set
@@ -110,13 +108,10 @@ CONFIG_SND=m
 # CONFIG_SND_DRIVERS is not set
 CONFIG_SND_USB_AUDIO=m
 CONFIG_HIDRAW=y
-CONFIG_HID_APPLE=m
 CONFIG_HID_BELKIN=m
 CONFIG_HID_CHERRY=m
 CONFIG_HID_EZKEY=m
 CONFIG_HID_TWINHAN=m
-CONFIG_HID_LOGITECH=m
-CONFIG_HID_LOGITECH_DJ=m
 CONFIG_HID_MICROSOFT=m
 CONFIG_HID_SUNPLUS=m
 CONFIG_HID_SMARTJOYPLUS=m
@@ -151,8 +146,12 @@ CONFIG_CIFS=m
 CONFIG_NLS=y
 CONFIG_NLS_CODEPAGE_437=y
 CONFIG_NLS_ISO8859_1=y
+CONFIG_CRYPTO_PCBC=m
+CONFIG_CRYPTO_MICHAEL_MIC=m
+CONFIG_CRYPTO_LZO=m
 CONFIG_CRC_CCITT=m
 CONFIG_CRC_T10DIF=y
+CONFIG_PRINTK_TIME=y
 CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y
 CONFIG_MAGIC_SYSRQ=y
 CONFIG_DEBUG_MEMORY_INIT=y
@@ -163,7 +162,3 @@ CONFIG_DEBUG_LOCKDEP=y
 CONFIG_DEBUG_LIST=y
 CONFIG_RCU_CPU_STALL_TIMEOUT=60
 # CONFIG_FTRACE is not set
-CONFIG_CRYPTO_PCBC=m
-CONFIG_CRYPTO_MICHAEL_MIC=m
-CONFIG_CRYPTO_LZO=m
-CONFIG_PRINTK_TIME=y
-- 
2.34.1



[PATCH v2 0/2] PS3 patches

2023-01-03 Thread Geoff Levand
Hi Michael,

This v2 series is just the two PS3 specific patches of the v1 series.

-Geoff

The following changes since commit 88603b6dc419445847923fcb7fe5080067a30f98:

  Linux 6.2-rc2 (2023-01-01 13:53:16 -0800)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/geoff/ps3-linux.git 
for-merge-powerpc-2

for you to fetch changes up to 99e87549b17feca3494e9df6f4def04a9ec7c042:

  powerpc/ps3: Refresh ps3_defconfig (2023-01-03 09:42:16 -0800)


Geoff Levand (2):
  powerpc/ps3: Change updateboltedpp panic to info
  powerpc/ps3: Refresh ps3_defconfig

 arch/powerpc/configs/ps3_defconfig | 39 +-
 arch/powerpc/platforms/ps3/htab.c  |  2 +-
 2 files changed, 18 insertions(+), 23 deletions(-)

-- 
2.34.1



Re: [PATCH v1 1/3] powerpc: Fix processing of CONFIG_CMDLINE

2023-01-03 Thread Geoff Levand
Hi Rob,

On 1/2/23 18:03, Rob Herring wrote:
> On Mon, Jan 2, 2023 at 1:41 PM Geoff Levand  wrote:

>> --- a/arch/powerpc/kernel/prom.c
>> +++ b/arch/powerpc/kernel/prom.c
>> @@ -761,7 +761,7 @@ void __init early_init_devtree(void *params)
>> DBG(" -> early_init_devtree(%px)\n", params);
>>
>> /* Too early to BUG_ON(), do it by hand */
>> -   if (!early_init_dt_verify(params))
>> +   if (!early_init_dt_scan(params))
> 
> It would be nice if this could be used instead, but it does other
> things like memory setup which I think will not work for some PPC
> platforms.

It seems like what we need is to pull out the command line processing
code from early_init_dt_scan_nodes and put that into a new function,
say early_init_setup_cmdline, then have both early_init_dt_scan_nodes
and powerpc's early_init_devtree call early_init_setup_cmdline.

I'll split this series into two, one for the PS3 updates, and one
that adds early_init_setup_cmdline.

-Geoff



[PATCH v1 3/3] powerpc/ps3: Refresh ps3_defconfig

2023-01-02 Thread Geoff Levand
Refresh ps3_defconfig for v6.2.

Signed-off-by: Geoff Levand 
---
 arch/powerpc/configs/ps3_defconfig | 39 +-
 1 file changed, 17 insertions(+), 22 deletions(-)

diff --git a/arch/powerpc/configs/ps3_defconfig 
b/arch/powerpc/configs/ps3_defconfig
index 0a1b42c4f26a..52a8c5450ecb 100644
--- a/arch/powerpc/configs/ps3_defconfig
+++ b/arch/powerpc/configs/ps3_defconfig
@@ -1,8 +1,3 @@
-CONFIG_PPC64=y
-CONFIG_CELL_CPU=y
-CONFIG_ALTIVEC=y
-CONFIG_SMP=y
-CONFIG_NR_CPUS=2
 CONFIG_SYSVIPC=y
 CONFIG_POSIX_MQUEUE=y
 CONFIG_HIGH_RES_TIMERS=y
@@ -10,11 +5,12 @@ CONFIG_BLK_DEV_INITRD=y
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 CONFIG_EMBEDDED=y
 # CONFIG_PERF_EVENTS is not set
-# CONFIG_COMPAT_BRK is not set
-CONFIG_SLAB=y
 CONFIG_PROFILING=y
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
+CONFIG_PPC64=y
+CONFIG_CELL_CPU=y
+CONFIG_ALTIVEC=y
+CONFIG_SMP=y
+CONFIG_NR_CPUS=2
 # CONFIG_PPC_POWERNV is not set
 # CONFIG_PPC_PSERIES is not set
 # CONFIG_PPC_PMAC is not set
@@ -27,17 +23,20 @@ CONFIG_PS3_FLASH=y
 CONFIG_PS3_VRAM=m
 CONFIG_PS3_LPM=m
 # CONFIG_PPC_OF_BOOT_TRAMPOLINE is not set
-# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
-CONFIG_BINFMT_MISC=y
 CONFIG_KEXEC=y
 CONFIG_PPC_4K_PAGES=y
-# CONFIG_SPARSEMEM_VMEMMAP is not set
-# CONFIG_COMPACTION is not set
 CONFIG_SCHED_SMT=y
 CONFIG_PM=y
 CONFIG_PM_DEBUG=y
 # CONFIG_SECCOMP is not set
-# CONFIG_PCI is not set
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
+CONFIG_BINFMT_MISC=y
+CONFIG_SLAB=y
+# CONFIG_COMPAT_BRK is not set
+# CONFIG_SPARSEMEM_VMEMMAP is not set
+# CONFIG_COMPACTION is not set
 CONFIG_NET=y
 CONFIG_PACKET=y
 CONFIG_UNIX=y
@@ -87,7 +86,6 @@ CONFIG_USB_USBNET=m
 # CONFIG_USB_NET_NET1080 is not set
 # CONFIG_USB_NET_CDC_SUBSET is not set
 # CONFIG_USB_NET_ZAURUS is not set
-CONFIG_INPUT_FF_MEMLESS=m
 CONFIG_INPUT_JOYDEV=m
 CONFIG_INPUT_EVDEV=m
 # CONFIG_INPUT_KEYBOARD is not set
@@ -110,13 +108,10 @@ CONFIG_SND=m
 # CONFIG_SND_DRIVERS is not set
 CONFIG_SND_USB_AUDIO=m
 CONFIG_HIDRAW=y
-CONFIG_HID_APPLE=m
 CONFIG_HID_BELKIN=m
 CONFIG_HID_CHERRY=m
 CONFIG_HID_EZKEY=m
 CONFIG_HID_TWINHAN=m
-CONFIG_HID_LOGITECH=m
-CONFIG_HID_LOGITECH_DJ=m
 CONFIG_HID_MICROSOFT=m
 CONFIG_HID_SUNPLUS=m
 CONFIG_HID_SMARTJOYPLUS=m
@@ -151,8 +146,12 @@ CONFIG_CIFS=m
 CONFIG_NLS=y
 CONFIG_NLS_CODEPAGE_437=y
 CONFIG_NLS_ISO8859_1=y
+CONFIG_CRYPTO_PCBC=m
+CONFIG_CRYPTO_MICHAEL_MIC=m
+CONFIG_CRYPTO_LZO=m
 CONFIG_CRC_CCITT=m
 CONFIG_CRC_T10DIF=y
+CONFIG_PRINTK_TIME=y
 CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y
 CONFIG_MAGIC_SYSRQ=y
 CONFIG_DEBUG_MEMORY_INIT=y
@@ -163,7 +162,3 @@ CONFIG_DEBUG_LOCKDEP=y
 CONFIG_DEBUG_LIST=y
 CONFIG_RCU_CPU_STALL_TIMEOUT=60
 # CONFIG_FTRACE is not set
-CONFIG_CRYPTO_PCBC=m
-CONFIG_CRYPTO_MICHAEL_MIC=m
-CONFIG_CRYPTO_LZO=m
-CONFIG_PRINTK_TIME=y
-- 
2.34.1



[PATCH v1 0/3] PS3 patches

2023-01-02 Thread Geoff Levand
Hi Michael,

Here are three patches.  One is a general powerpc fix for a change commited in
v6.2-rc1.  I didn't see anything on the mail list related to this.  The other
two patches are updates for PS3.

The following changes since commit 88603b6dc419445847923fcb7fe5080067a30f98:

  Linux 6.2-rc2 (2023-01-01 13:53:16 -0800)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/geoff/ps3-linux.git 
for-merge-powerpc-1

for you to fetch changes up to 760a803c300cb2d10548633fc13ed37a5703b026:

  powerpc/ps3: Refresh ps3_defconfig (2023-01-02 11:24:20 -0800)


Geoff Levand (3):
  powerpc: Fix processing of CONFIG_CMDLINE
  powerpc/ps3: Change updateboltedpp panic to info
  powerpc/ps3: Refresh ps3_defconfig

 arch/powerpc/configs/ps3_defconfig | 39 +-
 arch/powerpc/kernel/prom.c |  2 +-
 arch/powerpc/platforms/ps3/htab.c  |  2 +-
 3 files changed, 19 insertions(+), 24 deletions(-)

-- 
2.34.1



[PATCH v1 2/3] powerpc/ps3: Change updateboltedpp panic to info

2023-01-02 Thread Geoff Levand
Commit fdacae8a84024474afff234bdd1dbe19ad597a10 (powerpc: Activate
CONFIG_STRICT_KERNEL_RWX by default) causes ps3_hpte_updateboltedpp()
to be called.  Change the panic statment in ps3_hpte_updateboltedpp()
to a pr_info statement so that bootup can continue.

Signed-off-by: Geoff Levand 
---
 arch/powerpc/platforms/ps3/htab.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/ps3/htab.c 
b/arch/powerpc/platforms/ps3/htab.c
index c27e6cf85272..9de62bd52650 100644
--- a/arch/powerpc/platforms/ps3/htab.c
+++ b/arch/powerpc/platforms/ps3/htab.c
@@ -146,7 +146,7 @@ static long ps3_hpte_updatepp(unsigned long slot, unsigned 
long newpp,
 static void ps3_hpte_updateboltedpp(unsigned long newpp, unsigned long ea,
int psize, int ssize)
 {
-   panic("ps3_hpte_updateboltedpp() not implemented");
+   pr_info("ps3_hpte_updateboltedpp() not implemented");
 }
 
 static void ps3_hpte_invalidate(unsigned long slot, unsigned long vpn,
-- 
2.34.1




[PATCH v1 1/3] powerpc: Fix processing of CONFIG_CMDLINE

2023-01-02 Thread Geoff Levand
Commit a7d550f82b445cf218b47a2c1a9c56e97ecb8c7a (of: fdt: Honor CONFIG_CMDLINE*
even without /chosen node) moved the processing of the kernel built-in command
line (CONFIG_CMDLINE) from the early_init_dt_scan_chosen routine to the
early_init_dt_scan_nodes routine.

The current powerpc startup code does not call into early_init_dt_scan_nodes, so
processing of CONFIG_CMDLINE never happens, even if CONFIG_CMDLINE_FORCE=y.
The result is an empty kernel command line, and mounting of the root file system
then fails with a kernel panic (not syncing: VFS: Unable to mount root fs).

The early_init_dt_scan routine calls into early_init_dt_verify and then
early_init_dt_scan_nodes.  The powerpc startup routine early_init_devtree
currently has a call to early_init_dt_verify.  This change replaces that
early_init_dt_verify call to a call to early_init_dt_scan.

Signed-off-by: Geoff Levand 
---
 arch/powerpc/kernel/prom.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 4f1c920aa13e..82c9cd3bdbec 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -761,7 +761,7 @@ void __init early_init_devtree(void *params)
DBG(" -> early_init_devtree(%px)\n", params);
 
/* Too early to BUG_ON(), do it by hand */
-   if (!early_init_dt_verify(params))
+   if (!early_init_dt_scan(params))
panic("BUG: Failed verifying flat device tree, bad version?");
 
of_scan_flat_dt(early_init_dt_scan_model, NULL);
-- 
2.34.1




Re: [PATCH] powerpc/ps3: mark ps3_system_bus_type static

2022-11-22 Thread Geoff Levand
Hi Christoph,

On 11/21/22 23:22, Christoph Hellwig wrote:
> ps3_system_bus_type is only used inside of system-bus.c, so remove
> the external declaration and the very outdated comment next to it.
> 
> Signed-off-by: Christoph Hellwig 
> ---
>  arch/powerpc/include/asm/ps3.h  | 4 
>  arch/powerpc/platforms/ps3/system-bus.c | 2 +-
>  2 files changed, 1 insertion(+), 5 deletions(-)

I tested this applied to v6.1-rc6 and it seems to be OK.  Thanks
for submitting.

Acked-by: Geoff Levand 





Re: [PATCH 8/9] powerpc/ps3: remove orphan declarations from ps3av.h

2022-09-14 Thread Geoff Levand
Hi Gaosheng,

On 9/13/22 00:50, Gaosheng Cui wrote:
> Remove the following orphan declarations from ps3av.h:
> 1. ps3av_dev_open()
> 2. ps3av_dev_close()
> 
> They have been removed since commit 13a5e30cf740 ("[POWERPC] PS3:
> Rework AV settings driver"), so remove them.

I did a test build with this patch applied to v6.0-rc5 and had no errors.

Acked-by: Geoff Levand 



Re: [PATCH] net: move from strlcpy with unused retval to strscpy

2022-08-19 Thread Geoff Levand
Hi Wolfram,

On 8/18/22 14:00, Wolfram Sang wrote:
> Follow the advice of the below link and prefer 'strscpy' in this
> subsystem. Conversion is 1:1 because the return value is not used.
> Generated by a coccinelle script.
> 
> Link: 
> https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=v6a6g1ouzcprm...@mail.gmail.com/
> Signed-off-by: Wolfram Sang 

...

> diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_net.c 
> b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
> index 3dbfb1b20649..6e838e8f79d0 100644
> --- a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
> +++ b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
> @@ -1187,8 +1187,8 @@ int gelic_net_open(struct net_device *netdev)
>  void gelic_net_get_drvinfo(struct net_device *netdev,
>  struct ethtool_drvinfo *info)
>  {
> - strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
> - strlcpy(info->version, DRV_VERSION, sizeof(info->version));
> + strscpy(info->driver, DRV_NAME, sizeof(info->driver));
> + strscpy(info->version, DRV_VERSION, sizeof(info->version));
>  }
>  ps3_gelic_net
>  static int gelic_ether_get_link_ksettings(struct net_device *netdev,
> diff --git a/drivers/net/ethernet/toshiba/spider_net_ethtool.c 
> b/drivers/net/ethernet/toshiba/spider_net_ethtool.c
> index 93110dba0bfa..fef9fd127b5e 100644
> --- a/drivers/net/ethernet/toshiba/spider_net_ethtool.c
> +++ b/drivers/net/ethernet/toshiba/spider_net_ethtool.c
> @@ -63,12 +63,12 @@ spider_net_ethtool_get_drvinfo(struct net_device *netdev,
>   card = netdev_priv(netdev);
>  
>   /* clear and fill out info */
> - strlcpy(drvinfo->driver, spider_net_driver_name,
> + strscpy(drvinfo->driver, spider_net_driver_name,
>   sizeof(drvinfo->driver));
> - strlcpy(drvinfo->version, VERSION, sizeof(drvinfo->version));
> - strlcpy(drvinfo->fw_version, "no information",
> + strscpy(drvinfo->version, VERSION, sizeof(drvinfo->version));
> + strscpy(drvinfo->fw_version, "no information",
>   sizeof(drvinfo->fw_version));
> - strlcpy(drvinfo->bus_info, pci_name(card->pdev),
> + strscpy(drvinfo->bus_info, pci_name(card->pdev),
>   sizeof(drvinfo->bus_info));
>  }

Seems OK for both ps3_gelic_net and spider_net_ethtool.

Acked-by: Geoff Levand 


Re: [PATCH] block: move from strlcpy with unused retval to strscpy

2022-08-19 Thread Geoff Levand
On 8/18/22 13:59, Wolfram Sang wrote:
> Follow the advice of the below link and prefer 'strscpy' in this
> subsystem. Conversion is 1:1 because the return value is not used.
> Generated by a coccinelle script.
> 
> Link: 
> https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=v6a6g1ouzcprm...@mail.gmail.com/
> Signed-off-by: Wolfram Sang 
> ---
...
> diff --git a/drivers/block/ps3vram.c b/drivers/block/ps3vram.c
> index e1d080f680ed..c76e0148eada 100644
> --- a/drivers/block/ps3vram.c
> +++ b/drivers/block/ps3vram.c
> @@ -745,7 +745,7 @@ static int ps3vram_probe(struct ps3_system_bus_device 
> *dev)
>   gendisk->flags |= GENHD_FL_NO_PART;
>   gendisk->fops = _fops;
>   gendisk->private_data = dev;
> - strlcpy(gendisk->disk_name, DEVICE_NAME, sizeof(gendisk->disk_name));
> + strscpy(gendisk->disk_name, DEVICE_NAME, sizeof(gendisk->disk_name));
>   set_capacity(gendisk, priv->size >> 9);
>   blk_queue_max_segments(gendisk->queue, BLK_MAX_SEGMENTS);
>   blk_queue_max_segment_size(gendisk->queue, BLK_MAX_SEGMENT_SIZE);

Seems OK for ps3vram.

Acked-by: Geoff Levand 



Re: [PATCH net-next 13/14] eth: spider: remove a copy of the NAPI_POLL_WEIGHT define

2022-04-27 Thread Geoff Levand
Hi Jakub,

On 4/27/22 08:41, Jakub Kicinski wrote:
> Defining local versions of NAPI_POLL_WEIGHT with the same
> values in the drivers just makes refactoring harder.

> --- a/drivers/net/ethernet/toshiba/spider_net.c
> +++ b/drivers/net/ethernet/toshiba/spider_net.c
>  
>   netif_napi_add(netdev, >napi,
> -spider_net_poll, SPIDER_NET_NAPI_WEIGHT);
> +spider_net_poll, NAPI_POLL_WEIGHT);

This seems fine. Both SPIDER_NET_NAPI_WEIGHT and NAPI_POLL_WEIGHT
are defined as 64.  Thanks for your contribution.

Acked-by: Geoff Levand 


Re: [PATCH] powerpc/boot: Add `otheros-too-big.bld` to .gitignore

2022-02-14 Thread Geoff Levand
Hi Paul,

On 2/13/22 22:55, Paul Menzel wrote:
> Currently, `git status` lists the file as untracked by git, so tell git
> to ignore it.

Thanks for your contribution.

Acked-by: Geoff Levand 



Re: [PATCH] net: spider_net: Use non-atomic bitmap API when applicable

2021-12-04 Thread Geoff Levand
Hi Christophe,

On 11/27/21 7:18 AM, Christophe JAILLET wrote:
> No concurrent access is possible when a bitmap is local to a function.
> So prefer the non-atomic functions to save a few cycles.
>- replace a 'for' loop by an equivalent non-atomic 'bitmap_fill()' call
>- use '__set_bit()'
> 
> While at it, clear the 'bitmask' bitmap only when needed.
> 
> Signed-off-by: Christophe JAILLET 
> ---
> This patch is *not* compile tested. I don't have the needed cross compiling
> tool chain.
> ---
>  drivers/net/ethernet/toshiba/spider_net.c | 12 ++--
>  1 file changed, 6 insertions(+), 6 deletions(-)

As I mentioned, my tdd-builder Docker image has a
gcc-powerpc-linux-gnu cross compiler that can be used to build
a ppc64 kernel:

  https://hub.docker.com/r/glevand/tdd-builder

I also have a few helper scripts to run the container and cross
compile a kernel:

  https://github.com/glevand/tdd--docker/blob/master/builder/run-builder.sh
  
https://github.com/glevand/tdd-project/blob/master/scripts/build-linux-kernel.sh


I applied your patch to v5.16-rc3 and no spider_net warnings
or errors were seen when building with ppc64_defconfig. Thanks
for your contribution.

Acked-by: Geoff Levand 


Re: [PATCH 11/13] ps3vram: add error handling support for add_disk()

2021-10-29 Thread Geoff Levand
Hi Luis,

On 10/15/21 4:52 PM, Luis Chamberlain wrote:
> We never checked for errors on add_disk() as this function
> returned void. Now that this is fixed, use the shiny new
> error handling.

I didn't yet test this ps3vram related change, but based
on the ps3disk testing I think this change will be OK.

Acked-by: Geoff Levand 


Re: [PATCH 10/13] ps3disk: add error handling support for add_disk()

2021-10-29 Thread Geoff Levand
Hi Luis,

On 10/15/21 4:52 PM, Luis Chamberlain wrote:
> We never checked for errors on add_disk() as this function
> returned void. Now that this is fixed, use the shiny new
> error handling.
> 
> Signed-off-by: Luis Chamberlain 

I tested your 20211011-for-axboe-add-disk-error-handling branch
on PS3 and the ps3disk changes seem to be working OK.

Tested-by: Geoff Levand 


Re: [PATCH 00/13] block: add_disk() error handling stragglers

2021-10-21 Thread Geoff Levand
Hi Luis,

On 10/18/21 9:15 AM, Luis Chamberlain wrote:
> On Sun, Oct 17, 2021 at 08:26:33AM -0700, Geoff Levand wrote:
>> Hi Luis,
>>
>> On 10/15/21 4:52 PM, Luis Chamberlain wrote:
>>> This patch set consists of al the straggler drivers for which we have
>>> have no patch reviews done for yet. I'd like to ask for folks to please
>>> consider chiming in, specially if you're the maintainer for the driver.
>>> Additionally if you can specify if you'll take the patch in yourself or
>>> if you want Jens to take it, that'd be great too.
>>
>> Do you have a git repo with the patch set applied that I can use to test 
>> with?
> 
> Sure, although the second to last patch is in a state of flux given
> the ataflop driver currently is broken and so we're seeing how to fix
> that first:
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux-next.git/log/?h=20211011-for-axboe-add-disk-error-handling

That branch has so many changes applied on top of the base v5.15-rc4
that the patches I need to apply to test on PS3 with don't apply.

Do you have something closer to say v5.15-rc5?  Preferred would be
just your add_disk() error handling patches plus what they depend
on.

Thanks.

-Geoff


Re: [PATCH 00/13] block: add_disk() error handling stragglers

2021-10-17 Thread Geoff Levand
Hi Luis,

On 10/15/21 4:52 PM, Luis Chamberlain wrote:
> This patch set consists of al the straggler drivers for which we have
> have no patch reviews done for yet. I'd like to ask for folks to please
> consider chiming in, specially if you're the maintainer for the driver.
> Additionally if you can specify if you'll take the patch in yourself or
> if you want Jens to take it, that'd be great too.

Do you have a git repo with the patch set applied that I can use to test with?

Thanks.

-Geoff


Re: [PATCH] net: spider_net: switch from 'pci_' to 'dma_' API

2021-08-28 Thread Geoff Levand
Hi Christophe,

On 8/27/21 6:34 PM, Geoff Levand wrote:
> On 8/27/21 12:56 PM, Christophe JAILLET wrote:
>> It has *not* been compile tested because I don't have the needed
>> configuration or cross-compiler.
> 
> The powerpc ppc64_defconfig has CONFIG_SPIDER_NET set. My
> tdd-builder Docker image has the needed gcc-powerpc-linux-gnu
> cross compiler to build ppc64_defconfig:
> 
>   https://hub.docker.com/r/glevand/tdd-builder

Just to follow up, I applied your patch to v5.14-rc7 and built
ppc64_defconfig. No warnings or errors were seen.

Thanks for your contribution.

Acked-by: Geoff Levand 



Re: [PATCH] net: spider_net: switch from 'pci_' to 'dma_' API

2021-08-27 Thread Geoff Levand
Hi Christophe,

On 8/27/21 12:56 PM, Christophe JAILLET wrote:
> It has *not* been compile tested because I don't have the needed
> configuration or cross-compiler.

The powerpc ppc64_defconfig has CONFIG_SPIDER_NET set. My
tdd-builder Docker image has the needed gcc-powerpc-linux-gnu
cross compiler to build ppc64_defconfig:

  https://hub.docker.com/r/glevand/tdd-builder

-Geoff
 


[PATCH v4 02/10] net/ps3_gelic: Use local dev variable

2021-07-23 Thread Geoff Levand
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 
---
 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, , );
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(>updown_lock);
if (atomic_inc_return(>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(>napi);
}
mutex_unlock(>updown_lock);
-   pr_debug("%s: done\n", __func__);
 }
 
 void gelic_card_down(struct gelic_card *card)
 {
+   struct device *dev = ctodev(card);
u64 mask;
-   pr

[PATCH v4 09/10] net/ps3_gelic: Add new routine gelic_work_to_card

2021-07-23 Thread Geoff Levand
Add new helper routine gelic_work_to_card that converts a work_struct
to a gelic_card.

Signed-off-by: Geoff Levand 
---
 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




[PATCH v4 08/10] net/ps3_gelic: Rename no to descr_count

2021-07-23 Thread Geoff Levand
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 
---
 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




[PATCH v4 07/10] net/ps3_gelic: Add new routine gelic_unmap_link

2021-07-23 Thread Geoff Levand
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 
---
 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(>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




[PATCH v4 03/10] net/ps3_gelic: Format cleanups

2021-07-23 Thread Geoff Levand
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 
---
 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,
-   >ether_port_status, );
+   GELIC_LV1_GET_ETH_PORT_STATUS, GELIC_LV1_VLAN_TX_ETHERNET_0, 0,
+   0, >ether_port_status, );
 
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, , );
+   GELIC_LV1_SET_NEGOTIATION_MODE, GELIC_LV1_PHY_ETHERNET_0, mode,
+   0, , );
+
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

[PATCH v4 10/10] net/ps3_gelic: Fix DMA mapping problems

2021-07-23 Thread Geoff Levand
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 
---
 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;
+   des

[PATCH v4 01/10] net/ps3_gelic: Add gelic_descr structures

2021-07-23 Thread Geoff Levand
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 
---
 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)
+

[PATCH v4 04/10] net/ps3_gelic: Add new macro BUG_ON_DEBUG

2021-07-23 Thread Geoff Levand
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 
---
 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




[PATCH v4 00/10] DMA fixes for PS3 gelic network driver

2021-07-23 Thread Geoff Levand
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  (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



[PATCH v4 06/10] net/ps3_gelic: Cleanup debug code

2021-07-23 Thread Geoff Levand
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 
---
 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




[PATCH v4 05/10] net/ps3_gelic: Add vlan_id structure

2021-07-23 Thread Geoff Levand
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 
---
 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




Re: [PATCH v3 1/2] net/ps3_gelic: Add gelic_descr structures

2021-07-17 Thread Geoff Levand
Hi Christophe,

On 7/11/21 7:03 AM, Christophe Leroy wrote:
> 
> Your patch has a lot of cosmetic changes. Several of them are just wrong. The 
> other ones belong to another patch. This patch should focus only on the 
> changes it targets.
> 
> Your patch is way too big and addresses several different topics. Should be 
> split in several patches.
> 
> I suggest you run checkpatch.pl --strict on your patch
> 

Thanks for the review.  I'll create a follow up patch set with
your comments in mind.

-Geoff


[PATCH v3 1/2] net/ps3_gelic: Add gelic_descr structures

2021-07-10 Thread Geoff Levand
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.

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 
---
 drivers/net/ethernet/toshiba/ps3_gelic_net.c | 573 +++
 drivers/net/ethernet/toshiba/ps3_gelic_net.h |  24 +-
 2 files changed, 341 insertions(+), 256 deletions(-)

diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_net.c 
b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
index 55e652624bd7..e01938128882 100644
--- a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
+++ b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
@@ -96,9 +96,11 @@ static void gelic_card_get_ether_port_status(struct 
gelic_card *card,
  * returns the status as in the dmac_cmd_status field of the descriptor
  */
 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)
@@ -146,24 +148,34 @@ 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;
+#if defined(DEBUG)
+   static const int debug_build = 1;
+#else
+   static const int debug_build = 0;
+#endif
 
-#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->next_descr_addr));
-   printk(KERN_ERR "%s: head=%p\n", __func__,
-  card->rx_chain.head);
+   if (debug_build
+   && (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->bus_addr, 0);
-   if (status)
-   dev_info(ctodev(card),
-"lv1_net_start_rx_dma failed, status=%d\n", status);
+   card->rx_chain.head->link.cpu_addr, 0);
+
+   if (status) {
+   dev_err(dev, "%s:%d: lv1_net_start_rx_dma failed: %d\n",
+   __func__, __LINE__, status);
+   }
 }
 
 /**
@@ -193,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->dmac_cmd_status = cpu_to_be32(status |
-   (be32_to_cpu(descr->dmac_cmd_status) &
-~GELIC_DESCR_DMA_STAT_MASK));
+   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
 * is valid or not.
@@ -224,13 +236,14 @@ static void gelic_card_reset_chain(struct gelic_card 
*card,
 
for (descr = start_descr; start_descr != descr->next; descr++) {
gelic_de

[PATCH v3 2/2] net/ps3_gelic: Cleanups, improve logging

2021-07-10 Thread Geoff Levand
General source cleanups and improved logging messages.

Signed-off-by: Geoff Levand 
---
 drivers/net/ethernet/toshiba/ps3_gelic_net.c | 395 ++-
 1 file changed, 216 insertions(+), 179 deletions(-)

diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_net.c 
b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
index e01938128882..9dbcb7c4ec80 100644
--- a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
+++ b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
@@ -44,17 +44,17 @@ 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);
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;
 }
 
@@ -63,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;
@@ -70,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,
-   >ether_port_status, );
+   GELIC_LV1_GET_ETH_PORT_STATUS, GELIC_LV1_VLAN_TX_ETHERNET_0, 0,
+   0, >ether_port_status, );
 
if (inform) {
ether_netdev = card->netdev[GELIC_PORT_ETHERNET_0];
@@ -105,15 +105,17 @@ 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;
 
status = lv1_net_control(bus_id(card), dev_id(card),
-GELIC_LV1_SET_NEGOTIATION_MODE,
-GELIC_LV1_PHY_ETHERNET_0, mode, 0, , );
+   GELIC_LV1_SET_NEGOTIATION_MODE, GELIC_LV1_PHY_ETHERNET_0, mode,
+   0, , );
+
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;
}
 
@@ -130,13 +132,16 @@ 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, "%s:%d: lv1_net_stop_tx_dma failed: %d\n",
+   __func__, __LINE__, status);
+   }
 }
 
 /**
@@ -187,13 +192,16 @@ 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, "%s:%d: lv1_net_stop_rx_dma failed: %d\n",
+   __func__, __LINE__, status);
+   }
 }
 
 /**
@@ -216,6 +224,7 @@ static void gelic_descr_set_status(struct gelic_descr 
*descr,
 * Usually caller of this function wants to inform that to the
 * hardware, so we assure here the hardware sees the change.
 */
+
wmb();
 }
 
@@ -229,8 +238,7 @@ 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,
-  

[PATCH v3 0/2] DMA fixes for PS3 gelic network driver

2021-07-10 Thread Geoff Levand
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 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 5e437416ff66981d8154687cfdf7de50b1d82bfc:

  Merge branch 'dsa-mv88e6xxx-topaz-fixes' (2021-07-01 11:51:36 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/geoff/ps3-linux.git 
for-merge-dma-net

for you to fetch changes up to ffb7b2f4ac085986f563131e3851e07393cd514f:

  net/ps3_gelic: Cleanups, improve logging (2021-07-10 20:42:42 -0700)


Geoff Levand (2):
  net/ps3_gelic: Add gelic_descr structures
  net/ps3_gelic: Cleanups, improve logging

 drivers/net/ethernet/toshiba/ps3_gelic_net.c | 968 +++
 drivers/net/ethernet/toshiba/ps3_gelic_net.h |  24 +-
 2 files changed, 557 insertions(+), 435 deletions(-)

-- 
2.25.1



Re: [PATCH] bus: Make remove callback return void

2021-07-06 Thread Geoff Levand
On 7/6/21 2:50 AM, Uwe Kleine-König wrote:

> --- a/arch/powerpc/platforms/ps3/system-bus.c
> +++ b/arch/powerpc/platforms/ps3/system-bus.c
> @@ -381,7 +381,7 @@ static int ps3_system_bus_probe(struct device *_dev)
>   return result;
>  }
>  
> -static int ps3_system_bus_remove(struct device *_dev)
> +static void ps3_system_bus_remove(struct device *_dev)
>  {
>   struct ps3_system_bus_device *dev = ps3_dev_to_system_bus_dev(_dev);
>   struct ps3_system_bus_driver *drv;
> @@ -399,7 +399,6 @@ static int ps3_system_bus_remove(struct device *_dev)
>   __func__, __LINE__, drv->core.name);
>  
>   pr_debug(" <- %s:%d: %s\n", __func__, __LINE__, dev_name(>core));
> - return 0;
>  }

PS3 part looks fine.

Acked-by: Geoff Levand 


Re: [PATCH] powerpc: Fix spelling mistake "mesages" -> "messages" in Kconfig

2021-07-04 Thread Geoff Levand
On 7/4/21 2:38 AM, Colin King wrote:
> -   Enables more verbose log mesages for LV1 hypercall results.
> +   Enables more verbose log messages for LV1 hypercall results.

Looks good.  Thanks.

Acked by: Geoff Levand 


Re: [PATCH 11/18] ps3disk: use memcpy_{from,to}_bvec

2021-06-16 Thread Geoff Levand
Hi Christoph,

On 6/15/21 6:24 AM, Christoph Hellwig wrote:
> Use the bvec helpers instead of open coding the copy.
> 
> Signed-off-by: Christoph Hellwig 
> ---
>  drivers/block/ps3disk.c | 19 +++
>  1 file changed, 3 insertions(+), 16 deletions(-)

I tested your patch set applied to v5.13-rc6 on PS3 and it seemed to be
working OK.

I did some rsync's, some dd's, some fsck's, etc.  If you have anything
you could suggest that you think would exercise your changes I could
try that also.

Tested-by: Geoff Levand 


Re: [PATCH 10/30] ps3disk: use blk_mq_alloc_disk

2021-06-06 Thread Geoff Levand
Hi Christoph,

On 6/1/21 11:53 PM, Christoph Hellwig wrote:
> Use the blk_mq_alloc_disk API to simplify the gendisk and request_queue
> allocation.
> 
>  drivers/block/ps3disk.c | 36 ++--
>  1 file changed, 14 insertions(+), 22 deletions(-)

I tested your alloc_disk-part2 branch on PS3, and it seemed to be working OK.

Tested-by: Geoff Levand 


[PATCH v2 1/2] powerpc/ps3: Add firmware version to sysfs

2021-06-04 Thread Geoff Levand
Add a new sysfs entry /sys/firmware/ps3/fw-version that exports
the PS3's firmware version.

The firmware version is available through an LV1 hypercall, and we've
been printing it to the boot log, but haven't provided an easy way for
user utilities to get it.

Signed-off-by: Geoff Levand 
---
 arch/powerpc/platforms/ps3/setup.c | 43 +++---
 1 file changed, 40 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/platforms/ps3/setup.c 
b/arch/powerpc/platforms/ps3/setup.c
index e9ae5dd03593..3de9145c20bc 100644
--- a/arch/powerpc/platforms/ps3/setup.c
+++ b/arch/powerpc/platforms/ps3/setup.c
@@ -36,6 +36,7 @@ DEFINE_MUTEX(ps3_gpu_mutex);
 EXPORT_SYMBOL_GPL(ps3_gpu_mutex);
 
 static union ps3_firmware_version ps3_firmware_version;
+static char ps3_firmware_version_str[16];
 
 void ps3_get_firmware_version(union ps3_firmware_version *v)
 {
@@ -182,6 +183,40 @@ static int ps3_set_dabr(unsigned long dabr, unsigned long 
dabrx)
return lv1_set_dabr(dabr, dabrx) ? -1 : 0;
 }
 
+static ssize_t ps3_fw_version_show(struct kobject *kobj,
+   struct kobj_attribute *attr, char *buf)
+{
+   return sprintf(buf, "%s", ps3_firmware_version_str);
+}
+
+static int __init ps3_setup_sysfs(void)
+{
+   static struct kobj_attribute attr = __ATTR(fw-version, S_IRUGO,
+   ps3_fw_version_show, NULL);
+   static struct kobject *kobj;
+   int result;
+
+   kobj = kobject_create_and_add("ps3", firmware_kobj);
+
+   if (!kobj) {
+   pr_warn("%s:%d: kobject_create_and_add failed.\n", __func__,
+   __LINE__);
+   return -ENOMEM;
+   }
+
+   result = sysfs_create_file(kobj, );
+
+   if (result) {
+   pr_warn("%s:%d: sysfs_create_file failed.\n", __func__,
+   __LINE__);
+   kobject_put(kobj);
+   return -ENOMEM;
+   }
+
+   return 0;
+}
+core_initcall(ps3_setup_sysfs);
+
 static void __init ps3_setup_arch(void)
 {
u64 tmp;
@@ -190,9 +225,11 @@ static void __init ps3_setup_arch(void)
 
lv1_get_version_info(_firmware_version.raw, );
 
-   printk(KERN_INFO "PS3 firmware version %u.%u.%u\n",
-  ps3_firmware_version.major, ps3_firmware_version.minor,
-  ps3_firmware_version.rev);
+   snprintf(ps3_firmware_version_str, sizeof(ps3_firmware_version_str),
+   "%u.%u.%u", ps3_firmware_version.major,
+   ps3_firmware_version.minor, ps3_firmware_version.rev);
+
+   printk(KERN_INFO "PS3 firmware version %s\n", ps3_firmware_version_str);
 
ps3_spu_set_platform();
 
-- 
2.25.1




[PATCH v2 0/2] PS3 Updates

2021-06-04 Thread Geoff Levand
Hi Michael,

I've rebased the V1 patches to v5.13-rc4, and moved the firmware version export
from procfs to sysfs/firmware.

Please consider.

-Geoff

The following changes since commit 8124c8a6b35386f73523d27eacb71b5364a68c4c:

  Linux 5.13-rc4 (2021-05-30 11:58:25 -1000)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/geoff/ps3-linux.git 
for-merge-powerpc

for you to fetch changes up to 245897ed65e402686a4b114ba618e935cb5c6506:

  powerpc/ps3: Re-align DTB in image (2021-06-04 08:35:45 -0700)


Geoff Levand (2):
  powerpc/ps3: Add firmware version to sysfs
  powerpc/ps3: Re-align DTB in image

 arch/powerpc/boot/zImage.ps3.lds.S |  2 +-
 arch/powerpc/platforms/ps3/setup.c | 43 +++---
 2 files changed, 41 insertions(+), 4 deletions(-)

-- 
2.25.1



[PATCH v2 2/2] powerpc/ps3: Re-align DTB in image

2021-06-04 Thread Geoff Levand
Change the PS3 linker script to align the DTB at 8 bytes,
the same alignment as that of the of the 'generic' powerpc
linker script.

Signed-off-by: Geoff Levand 
---
 arch/powerpc/boot/zImage.ps3.lds.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/boot/zImage.ps3.lds.S 
b/arch/powerpc/boot/zImage.ps3.lds.S
index 7b2ff2eaa73a..d0ffb493614d 100644
--- a/arch/powerpc/boot/zImage.ps3.lds.S
+++ b/arch/powerpc/boot/zImage.ps3.lds.S
@@ -8,7 +8,7 @@ SECTIONS
   .kernel:vmlinux.bin : { *(.kernel:vmlinux.bin) }
   _vmlinux_end =  .;
 
-  . = ALIGN(4096);
+  . = ALIGN(8);
   _dtb_start = .;
   .kernel:dtb : { *(.kernel:dtb) }
   _dtb_end = .;
-- 
2.25.1



Re: [PATCH 0/5] DMA fixes for PS3 device drivers

2021-06-03 Thread Geoff Levand
Hi Michael,

On 6/2/21 10:38 PM, Michael Ellerman wrote:
> Geoff Levand  writes:
>> Hi,
>>
>> This is a set of patches that fix various DMA related problems in the PS3
>> device drivers, and add better error checking and improved message logging.
>>
>> The gelic network driver had a number of problems and most of the changes are
>> in it's sources.
>>
>> Please consider.
> 
> Who are you thinking would merge this?
> 
> It's sort of splattered all over the place, but is mostly networking by
> lines changed.
> 
> Maybe patches 3-5 should go via networking and I take 1-2?

As suggested, I split the V1 series into two separate series, one for
powerpc, and one for network.  

I thought it made more sense for patch 3, 'powerpc/ps3: Add dma_mask
to ps3_dma_region' to go with the powerpc series, so put it into that
series.

>> Geoff Levand (5):
>>   powerpc/ps3: Add CONFIG_PS3_VERBOSE_RESULT option
>>   powerpc/ps3: Warn on PS3 device errors
>>   powerpc/ps3: Add dma_mask to ps3_dma_region
>>   net/ps3_gelic: Add gelic_descr structures
>>   net/ps3_gelic: Cleanups, improve logging
>>
>>  arch/powerpc/include/asm/ps3.h   |   4 +-
>>  arch/powerpc/platforms/ps3/Kconfig   |   9 +
>>  arch/powerpc/platforms/ps3/mm.c  |  12 +
>>  arch/powerpc/platforms/ps3/system-bus.c  |   9 +-
>>  drivers/net/ethernet/toshiba/ps3_gelic_net.c | 968 
>> +++
>>  drivers/net/ethernet/toshiba/ps3_gelic_net.h |  24 +-
>>  drivers/ps3/ps3-vuart.c  |   2 +-
>>  drivers/ps3/ps3av.c  |  22 +-
>>  8 files changed, 598 insertions(+), 452 deletions(-)

-Geoff


[PATCH v2 3/3] powerpc/ps3: Add dma_mask to ps3_dma_region

2021-06-03 Thread Geoff Levand
Commit f959dcd6ddfd29235030e8026471ac1b022ad2b0 (dma-direct: Fix
potential NULL pointer dereference) added a null check on the
dma_mask pointer of the kernel's device structure.

Add a dma_mask variable to the ps3_dma_region structure and set
the device structure's dma_mask pointer to point to this new variable.

Fixes runtime errors like these:

  ps3_system_bus_match:349: dev=8.0(sb_01), drv=8.0(ps3flash): match
  WARNING: CPU: 0 PID: 1 at kernel/dma/mapping.c:151 
.dma_map_page_attrs+0x34/0x1e0
  ps3flash sb_01: ps3stor_setup:193: map DMA region failed

Signed-off-by: Geoff Levand 
---
 arch/powerpc/include/asm/ps3.h  |  2 ++
 arch/powerpc/platforms/ps3/mm.c | 12 
 2 files changed, 14 insertions(+)

diff --git a/arch/powerpc/include/asm/ps3.h b/arch/powerpc/include/asm/ps3.h
index 7df145901def..8a0d8fb35328 100644
--- a/arch/powerpc/include/asm/ps3.h
+++ b/arch/powerpc/include/asm/ps3.h
@@ -71,6 +71,7 @@ struct ps3_dma_region_ops;
  * @bus_addr: The 'translated' bus address of the region.
  * @len: The length in bytes of the region.
  * @offset: The offset from the start of memory of the region.
+ * @dma_mask: Device dma_mask.
  * @ioid: The IOID of the device who owns this region
  * @chunk_list: Opaque variable used by the ioc page manager.
  * @region_ops: struct ps3_dma_region_ops - dma region operations
@@ -85,6 +86,7 @@ struct ps3_dma_region {
enum ps3_dma_region_type region_type;
unsigned long len;
unsigned long offset;
+   u64 dma_mask;
 
/* driver variables  (set by ps3_dma_region_create) */
unsigned long bus_addr;
diff --git a/arch/powerpc/platforms/ps3/mm.c b/arch/powerpc/platforms/ps3/mm.c
index d094321964fb..a81eac35d900 100644
--- a/arch/powerpc/platforms/ps3/mm.c
+++ b/arch/powerpc/platforms/ps3/mm.c
@@ -6,6 +6,7 @@
  *  Copyright 2006 Sony Corp.
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -1118,6 +1119,7 @@ int ps3_dma_region_init(struct ps3_system_bus_device *dev,
enum ps3_dma_region_type region_type, void *addr, unsigned long len)
 {
unsigned long lpar_addr;
+   int result;
 
lpar_addr = addr ? ps3_mm_phys_to_lpar(__pa(addr)) : 0;
 
@@ -1129,6 +1131,16 @@ int ps3_dma_region_init(struct ps3_system_bus_device 
*dev,
r->offset -= map.r1.offset;
r->len = len ? len : ALIGN(map.total, 1 << r->page_size);
 
+   dev->core.dma_mask = >dma_mask;
+
+   result = dma_set_mask_and_coherent(>core, DMA_BIT_MASK(32));
+
+   if (result < 0) {
+   dev_err(>core, "%s:%d: dma_set_mask_and_coherent failed: 
%d\n",
+   __func__, __LINE__, result);
+   return result;
+   }
+
switch (dev->dev_type) {
case PS3_DEVICE_TYPE_SB:
r->region_ops =  (USE_DYNAMIC_DMA)
-- 
2.25.1



[PATCH v2 2/3] powerpc/ps3: Warn on PS3 device errors

2021-06-03 Thread Geoff Levand
To aid debugging PS3 boot problems change the log level
of several PS3 device errors from pr_debug to pr_warn.

Signed-off-by: Geoff Levand 
---
 arch/powerpc/platforms/ps3/system-bus.c |  9 +
 drivers/ps3/ps3-vuart.c |  2 +-
 drivers/ps3/ps3av.c | 22 +++---
 3 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/arch/powerpc/platforms/ps3/system-bus.c 
b/arch/powerpc/platforms/ps3/system-bus.c
index b431f41c6cb5..1a5665875165 100644
--- a/arch/powerpc/platforms/ps3/system-bus.c
+++ b/arch/powerpc/platforms/ps3/system-bus.c
@@ -64,9 +64,10 @@ static int ps3_open_hv_device_sb(struct 
ps3_system_bus_device *dev)
result = lv1_open_device(dev->bus_id, dev->dev_id, 0);
 
if (result) {
-   pr_debug("%s:%d: lv1_open_device failed: %s\n", __func__,
-   __LINE__, ps3_result(result));
-   result = -EPERM;
+   pr_warn("%s:%d: lv1_open_device dev=%u.%u(%s) failed: %s\n",
+   __func__, __LINE__, dev->match_id, dev->match_sub_id,
+   dev_name(>core), ps3_result(result));
+   result = -EPERM;
}
 
 done:
@@ -120,7 +121,7 @@ static int ps3_open_hv_device_gpu(struct 
ps3_system_bus_device *dev)
result = lv1_gpu_open(0);
 
if (result) {
-   pr_debug("%s:%d: lv1_gpu_open failed: %s\n", __func__,
+   pr_warn("%s:%d: lv1_gpu_open failed: %s\n", __func__,
__LINE__, ps3_result(result));
result = -EPERM;
}
diff --git a/drivers/ps3/ps3-vuart.c b/drivers/ps3/ps3-vuart.c
index e34ae6a442c7..6328abd51ffa 100644
--- a/drivers/ps3/ps3-vuart.c
+++ b/drivers/ps3/ps3-vuart.c
@@ -358,7 +358,7 @@ static int ps3_vuart_raw_write(struct ps3_system_bus_device 
*dev,
ps3_mm_phys_to_lpar(__pa(buf)), bytes, bytes_written);
 
if (result) {
-   dev_dbg(>core, "%s:%d: lv1_write_virtual_uart failed: "
+   dev_warn(>core, "%s:%d: lv1_write_virtual_uart failed: "
"%s\n", __func__, __LINE__, ps3_result(result));
return result;
}
diff --git a/drivers/ps3/ps3av.c b/drivers/ps3/ps3av.c
index 9d66257e1da5..516e6d14d32e 100644
--- a/drivers/ps3/ps3av.c
+++ b/drivers/ps3/ps3av.c
@@ -217,9 +217,9 @@ static int ps3av_send_cmd_pkt(const struct ps3av_send_hdr 
*send_buf,
/* send pkt */
res = ps3av_vuart_write(ps3av->dev, send_buf, write_len);
if (res < 0) {
-   dev_dbg(>dev->core,
-   "%s: ps3av_vuart_write() failed (result=%d)\n",
-   __func__, res);
+   dev_warn(>dev->core,
+   "%s:%d: ps3av_vuart_write() failed: %s\n", __func__,
+   __LINE__, ps3_result(res));
return res;
}
 
@@ -230,9 +230,9 @@ static int ps3av_send_cmd_pkt(const struct ps3av_send_hdr 
*send_buf,
res = ps3av_vuart_read(ps3av->dev, recv_buf, PS3AV_HDR_SIZE,
   timeout);
if (res != PS3AV_HDR_SIZE) {
-   dev_dbg(>dev->core,
-   "%s: ps3av_vuart_read() failed (result=%d)\n",
-   __func__, res);
+   dev_warn(>dev->core,
+   "%s:%d: ps3av_vuart_read() failed: %s\n", 
__func__,
+   __LINE__, ps3_result(res));
return res;
}
 
@@ -240,9 +240,9 @@ static int ps3av_send_cmd_pkt(const struct ps3av_send_hdr 
*send_buf,
res = ps3av_vuart_read(ps3av->dev, _buf->cid,
   recv_buf->size, timeout);
if (res < 0) {
-   dev_dbg(>dev->core,
-   "%s: ps3av_vuart_read() failed (result=%d)\n",
-   __func__, res);
+   dev_warn(>dev->core,
+   "%s:%d: ps3av_vuart_read() failed: %s\n", 
__func__,
+   __LINE__, ps3_result(res));
return res;
}
res += PS3AV_HDR_SIZE;  /* total len */
@@ -251,8 +251,8 @@ static int ps3av_send_cmd_pkt(const struct ps3av_send_hdr 
*send_buf,
} while (event);
 
if ((cmd | PS3AV_REPLY_BIT) != recv_buf->cid) {
-   dev_dbg(>dev->core, "%s: reply err (result=%x)\n",
-   __func__, recv_buf->cid);
+   dev_warn(>dev->core, "%s:%d: reply err: %x\n", __func__,
+   __LINE__, recv_buf->cid);
return -EINVAL;
}
 
-- 
2.25.1




[PATCH v2 1/3] powerpc/ps3: Add CONFIG_PS3_VERBOSE_RESULT option

2021-06-03 Thread Geoff Levand
To aid debugging, add a new PS3 kernel config option
PS3_VERBOSE_RESULT that, when enabled, will print more
verbose messages for the result of LV1 hypercalls.

Signed-off-by: Geoff Levand 
---
 arch/powerpc/include/asm/ps3.h | 2 +-
 arch/powerpc/platforms/ps3/Kconfig | 9 +
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/ps3.h b/arch/powerpc/include/asm/ps3.h
index e646c7f218bc..7df145901def 100644
--- a/arch/powerpc/include/asm/ps3.h
+++ b/arch/powerpc/include/asm/ps3.h
@@ -232,7 +232,7 @@ enum lv1_result {
 
 static inline const char* ps3_result(int result)
 {
-#if defined(DEBUG) || defined(PS3_VERBOSE_RESULT)
+#if defined(DEBUG) || defined(PS3_VERBOSE_RESULT) || 
defined(CONFIG_PS3_VERBOSE_RESULT)
switch (result) {
case LV1_SUCCESS:
return "LV1_SUCCESS (0)";
diff --git a/arch/powerpc/platforms/ps3/Kconfig 
b/arch/powerpc/platforms/ps3/Kconfig
index e32406e918d0..ebed94942d39 100644
--- a/arch/powerpc/platforms/ps3/Kconfig
+++ b/arch/powerpc/platforms/ps3/Kconfig
@@ -85,6 +85,15 @@ config PS3_SYS_MANAGER
  This support is required for PS3 system control.  In
  general, all users will say Y or M.
 
+config PS3_VERBOSE_RESULT
+   bool "PS3 Verbose LV1 hypercall results" if PS3_ADVANCED
+   depends on PPC_PS3
+   help
+ Enables more verbose log mesages for LV1 hypercall results.
+
+ If in doubt, say N here and reduce the size of the kernel by a
+ small amount.
+
 config PS3_REPOSITORY_WRITE
bool "PS3 Repository write support" if PS3_ADVANCED
depends on PPC_PS3
-- 
2.25.1




[PATCH v2 0/3] DMA fixes for PS3 device drivers

2021-06-03 Thread Geoff Levand
Hi Michael,

This is a set of patches that fix various DMA related problems in the PS3
device drivers, and add better error checking and improved message logging.

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 8124c8a6b35386f73523d27eacb71b5364a68c4c:

  Linux 5.13-rc4 (2021-05-30 11:58:25 -1000)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/geoff/ps3-linux.git 
for-merge-dma-powerpc

for you to fetch changes up to 562d0c9ea0100a30c3b186bcc7adb34b0bbd2cd7:

  powerpc/ps3: Add dma_mask to ps3_dma_region (2021-06-01 12:27:43 -0700)


Geoff Levand (3):
  powerpc/ps3: Add CONFIG_PS3_VERBOSE_RESULT option
  powerpc/ps3: Warn on PS3 device errors
  powerpc/ps3: Add dma_mask to ps3_dma_region

 arch/powerpc/include/asm/ps3.h  |  4 +++-
 arch/powerpc/platforms/ps3/Kconfig  |  9 +
 arch/powerpc/platforms/ps3/mm.c | 12 
 arch/powerpc/platforms/ps3/system-bus.c |  9 +
 drivers/ps3/ps3-vuart.c |  2 +-
 drivers/ps3/ps3av.c | 22 +++---
 6 files changed, 41 insertions(+), 17 deletions(-)

-- 
2.25.1



[PATCH v2 0/2] DMA fixes for PS3 gelic network driver

2021-06-03 Thread Geoff Levand
Hi Dave, Jakub,

This is a set of patches that fix various DMA related problems in the PS3
gelic network driver, and also adds better error checking and improved
message logging.

Please consider.

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 8124c8a6b35386f73523d27eacb71b5364a68c4c:

  Linux 5.13-rc4 (2021-05-30 11:58:25 -1000)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/geoff/ps3-linux.git 
for-merge-dma-net

for you to fetch changes up to c944a7aa07cbe1893a2426cfd6ed506bc6aebbbc:

  net/ps3_gelic: Cleanups, improve logging (2021-06-03 11:47:01 -0700)


Geoff Levand (2):
  net/ps3_gelic: Add gelic_descr structures
  net/ps3_gelic: Cleanups, improve logging

 drivers/net/ethernet/toshiba/ps3_gelic_net.c | 968 +++
 drivers/net/ethernet/toshiba/ps3_gelic_net.h |  24 +-
 2 files changed, 557 insertions(+), 435 deletions(-)

-- 
2.25.1



[PATCH v2 1/2] net/ps3_gelic: Add gelic_descr structures

2021-06-03 Thread Geoff Levand
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.

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 
---
 drivers/net/ethernet/toshiba/ps3_gelic_net.c | 573 +++
 drivers/net/ethernet/toshiba/ps3_gelic_net.h |  24 +-
 2 files changed, 341 insertions(+), 256 deletions(-)

diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_net.c 
b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
index 55e652624bd7..e01938128882 100644
--- a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
+++ b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
@@ -96,9 +96,11 @@ static void gelic_card_get_ether_port_status(struct 
gelic_card *card,
  * returns the status as in the dmac_cmd_status field of the descriptor
  */
 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)
@@ -146,24 +148,34 @@ 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;
+#if defined(DEBUG)
+   static const int debug_build = 1;
+#else
+   static const int debug_build = 0;
+#endif
 
-#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->next_descr_addr));
-   printk(KERN_ERR "%s: head=%p\n", __func__,
-  card->rx_chain.head);
+   if (debug_build
+   && (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->bus_addr, 0);
-   if (status)
-   dev_info(ctodev(card),
-"lv1_net_start_rx_dma failed, status=%d\n", status);
+   card->rx_chain.head->link.cpu_addr, 0);
+
+   if (status) {
+   dev_err(dev, "%s:%d: lv1_net_start_rx_dma failed: %d\n",
+   __func__, __LINE__, status);
+   }
 }
 
 /**
@@ -193,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->dmac_cmd_status = cpu_to_be32(status |
-   (be32_to_cpu(descr->dmac_cmd_status) &
-~GELIC_DESCR_DMA_STAT_MASK));
+   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
 * is valid or not.
@@ -224,13 +236,14 @@ static void gelic_card_reset_chain(struct gelic_card 
*card,
 
for (descr = start_descr; start_descr != descr->next; descr++) {
gelic_de

[PATCH v2 2/2] net/ps3_gelic: Cleanups, improve logging

2021-06-03 Thread Geoff Levand
General source cleanups and improved logging messages.

Signed-off-by: Geoff Levand 
---
 drivers/net/ethernet/toshiba/ps3_gelic_net.c | 395 ++-
 1 file changed, 216 insertions(+), 179 deletions(-)

diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_net.c 
b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
index e01938128882..9dbcb7c4ec80 100644
--- a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
+++ b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
@@ -44,17 +44,17 @@ 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);
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;
 }
 
@@ -63,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;
@@ -70,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,
-   >ether_port_status, );
+   GELIC_LV1_GET_ETH_PORT_STATUS, GELIC_LV1_VLAN_TX_ETHERNET_0, 0,
+   0, >ether_port_status, );
 
if (inform) {
ether_netdev = card->netdev[GELIC_PORT_ETHERNET_0];
@@ -105,15 +105,17 @@ 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;
 
status = lv1_net_control(bus_id(card), dev_id(card),
-GELIC_LV1_SET_NEGOTIATION_MODE,
-GELIC_LV1_PHY_ETHERNET_0, mode, 0, , );
+   GELIC_LV1_SET_NEGOTIATION_MODE, GELIC_LV1_PHY_ETHERNET_0, mode,
+   0, , );
+
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;
}
 
@@ -130,13 +132,16 @@ 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, "%s:%d: lv1_net_stop_tx_dma failed: %d\n",
+   __func__, __LINE__, status);
+   }
 }
 
 /**
@@ -187,13 +192,16 @@ 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, "%s:%d: lv1_net_stop_rx_dma failed: %d\n",
+   __func__, __LINE__, status);
+   }
 }
 
 /**
@@ -216,6 +224,7 @@ static void gelic_descr_set_status(struct gelic_descr 
*descr,
 * Usually caller of this function wants to inform that to the
 * hardware, so we assure here the hardware sees the change.
 */
+
wmb();
 }
 
@@ -229,8 +238,7 @@ 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,
-  

[PATCH 2/5] powerpc/ps3: Warn on PS3 device errors

2021-06-01 Thread Geoff Levand
To aid debugging PS3 boot problems change the log level
of several PS3 device errors from pr_debug to pr_warn.

Signed-off-by: Geoff Levand 
---
 arch/powerpc/platforms/ps3/system-bus.c |  9 +
 drivers/ps3/ps3-vuart.c |  2 +-
 drivers/ps3/ps3av.c | 22 +++---
 3 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/arch/powerpc/platforms/ps3/system-bus.c 
b/arch/powerpc/platforms/ps3/system-bus.c
index b431f41c6cb5..1a5665875165 100644
--- a/arch/powerpc/platforms/ps3/system-bus.c
+++ b/arch/powerpc/platforms/ps3/system-bus.c
@@ -64,9 +64,10 @@ static int ps3_open_hv_device_sb(struct 
ps3_system_bus_device *dev)
result = lv1_open_device(dev->bus_id, dev->dev_id, 0);
 
if (result) {
-   pr_debug("%s:%d: lv1_open_device failed: %s\n", __func__,
-   __LINE__, ps3_result(result));
-   result = -EPERM;
+   pr_warn("%s:%d: lv1_open_device dev=%u.%u(%s) failed: %s\n",
+   __func__, __LINE__, dev->match_id, dev->match_sub_id,
+   dev_name(>core), ps3_result(result));
+   result = -EPERM;
}
 
 done:
@@ -120,7 +121,7 @@ static int ps3_open_hv_device_gpu(struct 
ps3_system_bus_device *dev)
result = lv1_gpu_open(0);
 
if (result) {
-   pr_debug("%s:%d: lv1_gpu_open failed: %s\n", __func__,
+   pr_warn("%s:%d: lv1_gpu_open failed: %s\n", __func__,
__LINE__, ps3_result(result));
result = -EPERM;
}
diff --git a/drivers/ps3/ps3-vuart.c b/drivers/ps3/ps3-vuart.c
index e34ae6a442c7..6328abd51ffa 100644
--- a/drivers/ps3/ps3-vuart.c
+++ b/drivers/ps3/ps3-vuart.c
@@ -358,7 +358,7 @@ static int ps3_vuart_raw_write(struct ps3_system_bus_device 
*dev,
ps3_mm_phys_to_lpar(__pa(buf)), bytes, bytes_written);
 
if (result) {
-   dev_dbg(>core, "%s:%d: lv1_write_virtual_uart failed: "
+   dev_warn(>core, "%s:%d: lv1_write_virtual_uart failed: "
"%s\n", __func__, __LINE__, ps3_result(result));
return result;
}
diff --git a/drivers/ps3/ps3av.c b/drivers/ps3/ps3av.c
index 9d66257e1da5..516e6d14d32e 100644
--- a/drivers/ps3/ps3av.c
+++ b/drivers/ps3/ps3av.c
@@ -217,9 +217,9 @@ static int ps3av_send_cmd_pkt(const struct ps3av_send_hdr 
*send_buf,
/* send pkt */
res = ps3av_vuart_write(ps3av->dev, send_buf, write_len);
if (res < 0) {
-   dev_dbg(>dev->core,
-   "%s: ps3av_vuart_write() failed (result=%d)\n",
-   __func__, res);
+   dev_warn(>dev->core,
+   "%s:%d: ps3av_vuart_write() failed: %s\n", __func__,
+   __LINE__, ps3_result(res));
return res;
}
 
@@ -230,9 +230,9 @@ static int ps3av_send_cmd_pkt(const struct ps3av_send_hdr 
*send_buf,
res = ps3av_vuart_read(ps3av->dev, recv_buf, PS3AV_HDR_SIZE,
   timeout);
if (res != PS3AV_HDR_SIZE) {
-   dev_dbg(>dev->core,
-   "%s: ps3av_vuart_read() failed (result=%d)\n",
-   __func__, res);
+   dev_warn(>dev->core,
+   "%s:%d: ps3av_vuart_read() failed: %s\n", 
__func__,
+   __LINE__, ps3_result(res));
return res;
}
 
@@ -240,9 +240,9 @@ static int ps3av_send_cmd_pkt(const struct ps3av_send_hdr 
*send_buf,
res = ps3av_vuart_read(ps3av->dev, _buf->cid,
   recv_buf->size, timeout);
if (res < 0) {
-   dev_dbg(>dev->core,
-   "%s: ps3av_vuart_read() failed (result=%d)\n",
-   __func__, res);
+   dev_warn(>dev->core,
+   "%s:%d: ps3av_vuart_read() failed: %s\n", 
__func__,
+   __LINE__, ps3_result(res));
return res;
}
res += PS3AV_HDR_SIZE;  /* total len */
@@ -251,8 +251,8 @@ static int ps3av_send_cmd_pkt(const struct ps3av_send_hdr 
*send_buf,
} while (event);
 
if ((cmd | PS3AV_REPLY_BIT) != recv_buf->cid) {
-   dev_dbg(>dev->core, "%s: reply err (result=%x)\n",
-   __func__, recv_buf->cid);
+   dev_warn(>dev->core, "%s:%d: reply err: %x\n", __func__,
+   __LINE__, recv_buf->cid);
return -EINVAL;
}
 
-- 
2.25.1




[PATCH 1/5] powerpc/ps3: Add CONFIG_PS3_VERBOSE_RESULT option

2021-06-01 Thread Geoff Levand
To aid debugging, add a new PS3 kernel config option
PS3_VERBOSE_RESULT that, when enabled, will print more
verbose messages for the result of LV1 hypercalls.

Signed-off-by: Geoff Levand 
---
 arch/powerpc/include/asm/ps3.h | 2 +-
 arch/powerpc/platforms/ps3/Kconfig | 9 +
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/ps3.h b/arch/powerpc/include/asm/ps3.h
index e646c7f218bc..7df145901def 100644
--- a/arch/powerpc/include/asm/ps3.h
+++ b/arch/powerpc/include/asm/ps3.h
@@ -232,7 +232,7 @@ enum lv1_result {
 
 static inline const char* ps3_result(int result)
 {
-#if defined(DEBUG) || defined(PS3_VERBOSE_RESULT)
+#if defined(DEBUG) || defined(PS3_VERBOSE_RESULT) || 
defined(CONFIG_PS3_VERBOSE_RESULT)
switch (result) {
case LV1_SUCCESS:
return "LV1_SUCCESS (0)";
diff --git a/arch/powerpc/platforms/ps3/Kconfig 
b/arch/powerpc/platforms/ps3/Kconfig
index e32406e918d0..ebed94942d39 100644
--- a/arch/powerpc/platforms/ps3/Kconfig
+++ b/arch/powerpc/platforms/ps3/Kconfig
@@ -85,6 +85,15 @@ config PS3_SYS_MANAGER
  This support is required for PS3 system control.  In
  general, all users will say Y or M.
 
+config PS3_VERBOSE_RESULT
+   bool "PS3 Verbose LV1 hypercall results" if PS3_ADVANCED
+   depends on PPC_PS3
+   help
+ Enables more verbose log mesages for LV1 hypercall results.
+
+ If in doubt, say N here and reduce the size of the kernel by a
+ small amount.
+
 config PS3_REPOSITORY_WRITE
bool "PS3 Repository write support" if PS3_ADVANCED
depends on PPC_PS3
-- 
2.25.1




[PATCH 4/5] net/ps3_gelic: Add gelic_descr structures

2021-06-01 Thread Geoff Levand
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.

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 
---
 drivers/net/ethernet/toshiba/ps3_gelic_net.c | 573 +++
 drivers/net/ethernet/toshiba/ps3_gelic_net.h |  24 +-
 2 files changed, 341 insertions(+), 256 deletions(-)

diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_net.c 
b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
index 55e652624bd7..e01938128882 100644
--- a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
+++ b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
@@ -96,9 +96,11 @@ static void gelic_card_get_ether_port_status(struct 
gelic_card *card,
  * returns the status as in the dmac_cmd_status field of the descriptor
  */
 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)
@@ -146,24 +148,34 @@ 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;
+#if defined(DEBUG)
+   static const int debug_build = 1;
+#else
+   static const int debug_build = 0;
+#endif
 
-#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->next_descr_addr));
-   printk(KERN_ERR "%s: head=%p\n", __func__,
-  card->rx_chain.head);
+   if (debug_build
+   && (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->bus_addr, 0);
-   if (status)
-   dev_info(ctodev(card),
-"lv1_net_start_rx_dma failed, status=%d\n", status);
+   card->rx_chain.head->link.cpu_addr, 0);
+
+   if (status) {
+   dev_err(dev, "%s:%d: lv1_net_start_rx_dma failed: %d\n",
+   __func__, __LINE__, status);
+   }
 }
 
 /**
@@ -193,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->dmac_cmd_status = cpu_to_be32(status |
-   (be32_to_cpu(descr->dmac_cmd_status) &
-~GELIC_DESCR_DMA_STAT_MASK));
+   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
 * is valid or not.
@@ -224,13 +236,14 @@ static void gelic_card_reset_chain(struct gelic_card 
*card,
 
for (descr = start_descr; start_descr != descr->next; descr++) {
gelic_de

[PATCH 3/5] powerpc/ps3: Add dma_mask to ps3_dma_region

2021-06-01 Thread Geoff Levand
Commit f959dcd6ddfd29235030e8026471ac1b022ad2b0 (dma-direct: Fix
potential NULL pointer dereference) added a null check on the
dma_mask pointer of the kernel's device structure.

Add a dma_mask variable to the ps3_dma_region structure and set
the device structure's dma_mask pointer to point to this new variable.

Fixes runtime errors like these:

  ps3_system_bus_match:349: dev=8.0(sb_01), drv=8.0(ps3flash): match
  WARNING: CPU: 0 PID: 1 at kernel/dma/mapping.c:151
  ps3flash sb_01: ps3stor_setup:193: map DMA region failed

Signed-off-by: Geoff Levand 
---
 arch/powerpc/include/asm/ps3.h  |  2 ++
 arch/powerpc/platforms/ps3/mm.c | 12 
 2 files changed, 14 insertions(+)

diff --git a/arch/powerpc/include/asm/ps3.h b/arch/powerpc/include/asm/ps3.h
index 7df145901def..8a0d8fb35328 100644
--- a/arch/powerpc/include/asm/ps3.h
+++ b/arch/powerpc/include/asm/ps3.h
@@ -71,6 +71,7 @@ struct ps3_dma_region_ops;
  * @bus_addr: The 'translated' bus address of the region.
  * @len: The length in bytes of the region.
  * @offset: The offset from the start of memory of the region.
+ * @dma_mask: Device dma_mask.
  * @ioid: The IOID of the device who owns this region
  * @chunk_list: Opaque variable used by the ioc page manager.
  * @region_ops: struct ps3_dma_region_ops - dma region operations
@@ -85,6 +86,7 @@ struct ps3_dma_region {
enum ps3_dma_region_type region_type;
unsigned long len;
unsigned long offset;
+   u64 dma_mask;
 
/* driver variables  (set by ps3_dma_region_create) */
unsigned long bus_addr;
diff --git a/arch/powerpc/platforms/ps3/mm.c b/arch/powerpc/platforms/ps3/mm.c
index d094321964fb..a81eac35d900 100644
--- a/arch/powerpc/platforms/ps3/mm.c
+++ b/arch/powerpc/platforms/ps3/mm.c
@@ -6,6 +6,7 @@
  *  Copyright 2006 Sony Corp.
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -1118,6 +1119,7 @@ int ps3_dma_region_init(struct ps3_system_bus_device *dev,
enum ps3_dma_region_type region_type, void *addr, unsigned long len)
 {
unsigned long lpar_addr;
+   int result;
 
lpar_addr = addr ? ps3_mm_phys_to_lpar(__pa(addr)) : 0;
 
@@ -1129,6 +1131,16 @@ int ps3_dma_region_init(struct ps3_system_bus_device 
*dev,
r->offset -= map.r1.offset;
r->len = len ? len : ALIGN(map.total, 1 << r->page_size);
 
+   dev->core.dma_mask = >dma_mask;
+
+   result = dma_set_mask_and_coherent(>core, DMA_BIT_MASK(32));
+
+   if (result < 0) {
+   dev_err(>core, "%s:%d: dma_set_mask_and_coherent failed: 
%d\n",
+   __func__, __LINE__, result);
+   return result;
+   }
+
switch (dev->dev_type) {
case PS3_DEVICE_TYPE_SB:
r->region_ops =  (USE_DYNAMIC_DMA)
-- 
2.25.1




[PATCH 0/5] DMA fixes for PS3 device drivers

2021-06-01 Thread Geoff Levand
Hi,

This is a set of patches that fix various DMA related problems in the PS3
device drivers, and add better error checking and improved message logging.

The gelic network driver had a number of problems and most of the changes are
in it's sources.

Please consider.

-Geoff

The following changes since commit 8124c8a6b35386f73523d27eacb71b5364a68c4c:

  Linux 5.13-rc4 (2021-05-30 11:58:25 -1000)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/geoff/ps3-linux.git 
for-merge-gelic

for you to fetch changes up to 4adcfc9735bf8d1987d2bc82e914be154f2ffad8:

  net/ps3_gelic: Cleanups, improve logging (2021-06-01 12:27:43 -0700)


Geoff Levand (5):
  powerpc/ps3: Add CONFIG_PS3_VERBOSE_RESULT option
  powerpc/ps3: Warn on PS3 device errors
  powerpc/ps3: Add dma_mask to ps3_dma_region
  net/ps3_gelic: Add gelic_descr structures
  net/ps3_gelic: Cleanups, improve logging

 arch/powerpc/include/asm/ps3.h   |   4 +-
 arch/powerpc/platforms/ps3/Kconfig   |   9 +
 arch/powerpc/platforms/ps3/mm.c  |  12 +
 arch/powerpc/platforms/ps3/system-bus.c  |   9 +-
 drivers/net/ethernet/toshiba/ps3_gelic_net.c | 968 +++
 drivers/net/ethernet/toshiba/ps3_gelic_net.h |  24 +-
 drivers/ps3/ps3-vuart.c  |   2 +-
 drivers/ps3/ps3av.c  |  22 +-
 8 files changed, 598 insertions(+), 452 deletions(-)

-- 
2.25.1



[PATCH 5/5] net/ps3_gelic: Cleanups, improve logging

2021-06-01 Thread Geoff Levand
General source cleanups and improved logging messages.

Signed-off-by: Geoff Levand 
---
 drivers/net/ethernet/toshiba/ps3_gelic_net.c | 395 ++-
 1 file changed, 216 insertions(+), 179 deletions(-)

diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_net.c 
b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
index e01938128882..9dbcb7c4ec80 100644
--- a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
+++ b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
@@ -44,17 +44,17 @@ 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);
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;
 }
 
@@ -63,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;
@@ -70,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,
-   >ether_port_status, );
+   GELIC_LV1_GET_ETH_PORT_STATUS, GELIC_LV1_VLAN_TX_ETHERNET_0, 0,
+   0, >ether_port_status, );
 
if (inform) {
ether_netdev = card->netdev[GELIC_PORT_ETHERNET_0];
@@ -105,15 +105,17 @@ 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;
 
status = lv1_net_control(bus_id(card), dev_id(card),
-GELIC_LV1_SET_NEGOTIATION_MODE,
-GELIC_LV1_PHY_ETHERNET_0, mode, 0, , );
+   GELIC_LV1_SET_NEGOTIATION_MODE, GELIC_LV1_PHY_ETHERNET_0, mode,
+   0, , );
+
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;
}
 
@@ -130,13 +132,16 @@ 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, "%s:%d: lv1_net_stop_tx_dma failed: %d\n",
+   __func__, __LINE__, status);
+   }
 }
 
 /**
@@ -187,13 +192,16 @@ 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, "%s:%d: lv1_net_stop_rx_dma failed: %d\n",
+   __func__, __LINE__, status);
+   }
 }
 
 /**
@@ -216,6 +224,7 @@ static void gelic_descr_set_status(struct gelic_descr 
*descr,
 * Usually caller of this function wants to inform that to the
 * hardware, so we assure here the hardware sees the change.
 */
+
wmb();
 }
 
@@ -229,8 +238,7 @@ 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,
-  

Re: [PATCH 1/1] powerpc/ps3: Fix error return code in ps3_register_devices()

2021-05-23 Thread Geoff Levand
Hi,

On 5/20/21 5:20 AM, Michael Ellerman wrote:
> Zhen Lei  writes:
>> When call ps3_start_probe_thread() failed, further initialization should
>> be stopped and the returned error code should be propagated.
...
>> --- a/arch/powerpc/platforms/ps3/device-init.c
>>  
>>  result = ps3_start_probe_thread(PS3_BUS_TYPE_STORAGE);
>> +if (result < 0)
>> +return result;
> 
> If you bail out here you skip:
> 
>>  ps3_register_vuart_devices();
> 
> Which I suspect means there will be no console output?
> 
> Presumably the system won't boot if the probe thread fails, but it might
> at least print an oops, whereas if we return we might get nothing at
> all. Though I'm just guessing, I don't know this code that well.

That probe is for the storage devices (PS3_BUS_TYPE_STORAGE).

There are cases where the system is usable even if the storage
devices are not available, for example, when using an NFS root
filesystem.

ps3_start_probe_thread was made to be quite verbose on error
to make up for it's return value not being checked.

> Anyway please leave this code alone unless you're willing to test your
> changes, or at least provide a more thorough justification for them.

Agreed, this change should not be merged.

-Geoff


Re: [PATCH] sound:ppc: fix spelling typo of values

2021-04-07 Thread Geoff Levand
On 3/23/21 1:55 AM, caizhichao wrote:
> From: caizhichao 
> 
> vaules -> values
> 
> Signed-off-by: caizhichao 
> ---
>  sound/ppc/snd_ps3_reg.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Seems fine. Thanks for your contribution.

Acked-by: Geoff Levand 



[PATCH v1 0/2] PS3 Updates

2021-03-16 Thread Geoff Levand
Hi Michael,

Here are two minor updates for PS3.  The first exports the firmware version to
the proc FS, and the second re-aligns the DTB to save a little space in the
PS3's limited flash memory.

-Geoff

The following changes since commit f40ddce88593482919761f74910f42f4b84c004b:

  Linux 5.11 (2021-02-14 14:32:24 -0800)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/geoff/ps3-linux.git 
for-merge-powerpc

for you to fetch changes up to 7bee1153671a3ec71775246887894eefbfcb4b25:

  powerpc/ps3: Re-align DTB in image (2021-03-13 18:43:16 -0800)


Geoff Levand (2):
  powerpc/ps3: Add firmware version to proc
  powerpc/ps3: Re-align DTB in image

 arch/powerpc/boot/zImage.ps3.lds.S |  2 +-
 arch/powerpc/platforms/ps3/setup.c | 62 --
 2 files changed, 60 insertions(+), 4 deletions(-)

-- 
2.25.1



[PATCH v1 1/2] powerpc/ps3: Add firmware version to proc

2021-03-16 Thread Geoff Levand
Add a new proc FS entry /proc/ps3/firmware-version that exports the
PS3's firmware version.

The firmware version is available through an LV1 hypercall, and we've
been printing it to the boot log, but haven't provided an easy way for
user utilities to get it.

Signed-off-by: Geoff Levand 
---
 arch/powerpc/platforms/ps3/setup.c | 62 --
 1 file changed, 59 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/platforms/ps3/setup.c 
b/arch/powerpc/platforms/ps3/setup.c
index e9ae5dd03593..c3c4cbf16632 100644
--- a/arch/powerpc/platforms/ps3/setup.c
+++ b/arch/powerpc/platforms/ps3/setup.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -36,6 +37,7 @@ DEFINE_MUTEX(ps3_gpu_mutex);
 EXPORT_SYMBOL_GPL(ps3_gpu_mutex);
 
 static union ps3_firmware_version ps3_firmware_version;
+static char ps3_firmware_version_str[16];
 
 void ps3_get_firmware_version(union ps3_firmware_version *v)
 {
@@ -182,6 +184,58 @@ static int ps3_set_dabr(unsigned long dabr, unsigned long 
dabrx)
return lv1_set_dabr(dabr, dabrx) ? -1 : 0;
 }
 
+static ssize_t ps3_fw_ver_read(struct file *file, char __user *buf, size_t 
size,
+   loff_t *ppos)
+{
+   ssize_t bytes = simple_read_from_buffer(buf, size, ppos,
+   ps3_firmware_version_str, strlen(ps3_firmware_version_str));
+
+   pr_debug("%s:%d: %zd bytes '%s'\n", __func__, __LINE__, bytes,
+  ps3_firmware_version_str);
+
+   if (bytes < 0) {
+   pr_err("%s:%d: failed: %zd\n", __func__, __LINE__, bytes);
+   return bytes;
+   }
+
+   buf += bytes;
+   size -= bytes;
+
+   return bytes;
+}
+
+static int __init ps3_setup_proc(void)
+{
+   static const struct proc_ops proc_ops = {
+   .proc_read = ps3_fw_ver_read,
+   .proc_lseek = default_llseek,
+   };
+   struct proc_dir_entry *entry;
+
+   entry = proc_mkdir("ps3", NULL);
+
+   if (!entry) {
+   pr_err("%s:%d: failed.\n", __func__, __LINE__);
+   return 1;
+   }
+
+   entry = proc_create_data("ps3/firmware-version", S_IFREG | 0444, NULL,
+   _ops, NULL);
+
+   if (!entry) {
+   pr_err("%s:%d: failed.\n", __func__, __LINE__);
+   return 1;
+   }
+
+   proc_set_size(entry, strlen(ps3_firmware_version_str));
+
+   pr_debug("%s:%d: '%s' = %zd bytes\n", __func__, __LINE__,
+   ps3_firmware_version_str, strlen(ps3_firmware_version_str));
+
+   return 0;
+}
+core_initcall(ps3_setup_proc);
+
 static void __init ps3_setup_arch(void)
 {
u64 tmp;
@@ -190,9 +244,11 @@ static void __init ps3_setup_arch(void)
 
lv1_get_version_info(_firmware_version.raw, );
 
-   printk(KERN_INFO "PS3 firmware version %u.%u.%u\n",
-  ps3_firmware_version.major, ps3_firmware_version.minor,
-  ps3_firmware_version.rev);
+   snprintf(ps3_firmware_version_str, sizeof(ps3_firmware_version_str),
+   "%u.%u.%u", ps3_firmware_version.major,
+   ps3_firmware_version.minor, ps3_firmware_version.rev);
+
+   printk(KERN_INFO "PS3 firmware version %s\n", ps3_firmware_version_str);
 
ps3_spu_set_platform();
 
-- 
2.25.1




[PATCH v1 2/2] powerpc/ps3: Re-align DTB in image

2021-03-16 Thread Geoff Levand
Change the PS3 linker script to align the DTB at 8 bytes,
the same alignment as that of the of the 'generic' powerpc
linker script.

Signed-off-by: Geoff Levand 
---
 arch/powerpc/boot/zImage.ps3.lds.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/boot/zImage.ps3.lds.S 
b/arch/powerpc/boot/zImage.ps3.lds.S
index 7b2ff2eaa73a..d0ffb493614d 100644
--- a/arch/powerpc/boot/zImage.ps3.lds.S
+++ b/arch/powerpc/boot/zImage.ps3.lds.S
@@ -8,7 +8,7 @@ SECTIONS
   .kernel:vmlinux.bin : { *(.kernel:vmlinux.bin) }
   _vmlinux_end =  .;
 
-  . = ALIGN(4096);
+  . = ALIGN(8);
   _dtb_start = .;
   .kernel:dtb : { *(.kernel:dtb) }
   _dtb_end = .;
-- 
2.25.1



[PATCH] MAINTAINERS: Update Spidernet network driver

2021-03-16 Thread Geoff Levand
Change the Spidernet network driver from supported to
maintained, add the linuxppc-dev ML, and add myself as
a 'maintainer'.

Cc: Ishizaki Kou 
Signed-off-by: Geoff Levand 
---
 MAINTAINERS | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index aa84121c5611..7451cd55af18 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -16887,8 +16887,10 @@ F: tools/spi/
 
 SPIDERNET NETWORK DRIVER for CELL
 M: Ishizaki Kou 
+M: Geoff Levand 
 L: net...@vger.kernel.org
-S: Supported
+L: linuxppc-dev@lists.ozlabs.org
+S: Maintained
 F: Documentation/networking/device_drivers/ethernet/toshiba/spider_net.rst
 F: drivers/net/ethernet/toshiba/spider_net*
 
-- 
2.25.1



Re: [PATCH] dma-mapping: remove unneeded semicolon

2021-02-01 Thread Geoff Levand
On 2/1/21 7:41 PM, Yang Li wrote:
> Eliminate the following coccicheck warning:
> ./arch/powerpc/platforms/ps3/system-bus.c:606:2-3: Unneeded semicolon
> ./arch/powerpc/platforms/ps3/system-bus.c:765:2-3: Unneeded semicolon
> 
> Reported-by: Abaci Robot 
> Signed-off-by: Yang Li 
> ---
>  arch/powerpc/platforms/ps3/system-bus.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Thanks for your patch, it looks good.

Acked-by: Geoff Levand 

-Geoff


Re: [PATCH] powerpc/ps3: use dma_mapping_error()

2020-12-13 Thread Geoff Levand
On 12/13/20 10:26 AM, Vincent Stehlé wrote:
> The DMA address returned by dma_map_single() should be checked with
> dma_mapping_error(). Fix the ps3stor_setup() function accordingly.
> 
> Fixes: 80071802cb9c ("[POWERPC] PS3: Storage Driver Core")
> Signed-off-by: Vincent Stehlé 
> Cc: Geoff Levand 
> Cc: Geert Uytterhoeven 
> ---
>  drivers/ps3/ps3stor_lib.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Looks good.  Thanks for submitting.

Acked by: Geoff Levand 


  1   2   3   4   5   6   >