.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Serial Attached SCSI (SAS) Transport Layer initialization |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2005 Adaptec, Inc. All rights reserved. |
---|
5 | 6 | * Copyright (C) 2005 Luben Tuikov <luben_tuikov@adaptec.com> |
---|
6 | | - * |
---|
7 | | - * This file is licensed under GPLv2. |
---|
8 | | - * |
---|
9 | | - * This program is free software; you can redistribute it and/or |
---|
10 | | - * modify it under the terms of the GNU General Public License as |
---|
11 | | - * published by the Free Software Foundation; either version 2 of the |
---|
12 | | - * License, or (at your option) any later version. |
---|
13 | | - * |
---|
14 | | - * This program is distributed in the hope that it will be useful, but |
---|
15 | | - * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
17 | | - * General Public License for more details. |
---|
18 | | - * |
---|
19 | | - * You should have received a copy of the GNU General Public License |
---|
20 | | - * along with this program; if not, write to the Free Software |
---|
21 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
---|
22 | | - * USA |
---|
23 | | - * |
---|
24 | 7 | */ |
---|
25 | 8 | |
---|
26 | 9 | #include <linux/module.h> |
---|
.. | .. |
---|
87 | 70 | /*------------ SAS addr hash -----------*/ |
---|
88 | 71 | void sas_hash_addr(u8 *hashed, const u8 *sas_addr) |
---|
89 | 72 | { |
---|
90 | | - const u32 poly = 0x00DB2777; |
---|
91 | | - u32 r = 0; |
---|
92 | | - int i; |
---|
| 73 | + const u32 poly = 0x00DB2777; |
---|
| 74 | + u32 r = 0; |
---|
| 75 | + int i; |
---|
93 | 76 | |
---|
94 | | - for (i = 0; i < 8; i++) { |
---|
95 | | - int b; |
---|
96 | | - for (b = 7; b >= 0; b--) { |
---|
97 | | - r <<= 1; |
---|
98 | | - if ((1 << b) & sas_addr[i]) { |
---|
99 | | - if (!(r & 0x01000000)) |
---|
100 | | - r ^= poly; |
---|
101 | | - } else if (r & 0x01000000) |
---|
102 | | - r ^= poly; |
---|
103 | | - } |
---|
104 | | - } |
---|
| 77 | + for (i = 0; i < SAS_ADDR_SIZE; i++) { |
---|
| 78 | + int b; |
---|
105 | 79 | |
---|
106 | | - hashed[0] = (r >> 16) & 0xFF; |
---|
107 | | - hashed[1] = (r >> 8) & 0xFF ; |
---|
108 | | - hashed[2] = r & 0xFF; |
---|
| 80 | + for (b = (SAS_ADDR_SIZE - 1); b >= 0; b--) { |
---|
| 81 | + r <<= 1; |
---|
| 82 | + if ((1 << b) & sas_addr[i]) { |
---|
| 83 | + if (!(r & 0x01000000)) |
---|
| 84 | + r ^= poly; |
---|
| 85 | + } else if (r & 0x01000000) { |
---|
| 86 | + r ^= poly; |
---|
| 87 | + } |
---|
| 88 | + } |
---|
| 89 | + } |
---|
| 90 | + |
---|
| 91 | + hashed[0] = (r >> 16) & 0xFF; |
---|
| 92 | + hashed[1] = (r >> 8) & 0xFF; |
---|
| 93 | + hashed[2] = r & 0xFF; |
---|
109 | 94 | } |
---|
110 | 95 | |
---|
111 | 96 | int sas_register_ha(struct sas_ha_struct *sas_ha) |
---|
.. | .. |
---|
128 | 113 | |
---|
129 | 114 | error = sas_register_phys(sas_ha); |
---|
130 | 115 | if (error) { |
---|
131 | | - printk(KERN_NOTICE "couldn't register sas phys:%d\n", error); |
---|
| 116 | + pr_notice("couldn't register sas phys:%d\n", error); |
---|
132 | 117 | return error; |
---|
133 | 118 | } |
---|
134 | 119 | |
---|
135 | 120 | error = sas_register_ports(sas_ha); |
---|
136 | 121 | if (error) { |
---|
137 | | - printk(KERN_NOTICE "couldn't register sas ports:%d\n", error); |
---|
| 122 | + pr_notice("couldn't register sas ports:%d\n", error); |
---|
138 | 123 | goto Undo_phys; |
---|
139 | | - } |
---|
140 | | - |
---|
141 | | - error = sas_init_events(sas_ha); |
---|
142 | | - if (error) { |
---|
143 | | - printk(KERN_NOTICE "couldn't start event thread:%d\n", error); |
---|
144 | | - goto Undo_ports; |
---|
145 | 124 | } |
---|
146 | 125 | |
---|
147 | 126 | error = -ENOMEM; |
---|
.. | .. |
---|
605 | 584 | } |
---|
606 | 585 | EXPORT_SYMBOL_GPL(sas_domain_attach_transport); |
---|
607 | 586 | |
---|
608 | | - |
---|
609 | | -struct asd_sas_event *sas_alloc_event(struct asd_sas_phy *phy) |
---|
| 587 | +static struct asd_sas_event *__sas_alloc_event(struct asd_sas_phy *phy, |
---|
| 588 | + gfp_t gfp_flags) |
---|
610 | 589 | { |
---|
611 | 590 | struct asd_sas_event *event; |
---|
612 | | - gfp_t flags = in_interrupt() ? GFP_ATOMIC : GFP_KERNEL; |
---|
613 | 591 | struct sas_ha_struct *sas_ha = phy->ha; |
---|
614 | 592 | struct sas_internal *i = |
---|
615 | 593 | to_sas_internal(sas_ha->core.shost->transportt); |
---|
616 | 594 | |
---|
617 | | - event = kmem_cache_zalloc(sas_event_cache, flags); |
---|
| 595 | + event = kmem_cache_zalloc(sas_event_cache, gfp_flags); |
---|
618 | 596 | if (!event) |
---|
619 | 597 | return NULL; |
---|
620 | 598 | |
---|
.. | .. |
---|
623 | 601 | if (atomic_read(&phy->event_nr) > phy->ha->event_thres) { |
---|
624 | 602 | if (i->dft->lldd_control_phy) { |
---|
625 | 603 | if (cmpxchg(&phy->in_shutdown, 0, 1) == 0) { |
---|
626 | | - sas_printk("The phy%02d bursting events, shut it down.\n", |
---|
627 | | - phy->id); |
---|
628 | | - sas_notify_phy_event(phy, PHYE_SHUTDOWN); |
---|
| 604 | + pr_notice("The phy%d bursting events, shut it down.\n", |
---|
| 605 | + phy->id); |
---|
| 606 | + sas_notify_phy_event_gfp(phy, PHYE_SHUTDOWN, |
---|
| 607 | + gfp_flags); |
---|
629 | 608 | } |
---|
630 | 609 | } else { |
---|
631 | 610 | /* Do not support PHY control, stop allocating events */ |
---|
.. | .. |
---|
639 | 618 | return event; |
---|
640 | 619 | } |
---|
641 | 620 | |
---|
| 621 | +struct asd_sas_event *sas_alloc_event(struct asd_sas_phy *phy) |
---|
| 622 | +{ |
---|
| 623 | + return __sas_alloc_event(phy, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); |
---|
| 624 | +} |
---|
| 625 | + |
---|
| 626 | +struct asd_sas_event *sas_alloc_event_gfp(struct asd_sas_phy *phy, |
---|
| 627 | + gfp_t gfp_flags) |
---|
| 628 | +{ |
---|
| 629 | + return __sas_alloc_event(phy, gfp_flags); |
---|
| 630 | +} |
---|
| 631 | + |
---|
642 | 632 | void sas_free_event(struct asd_sas_event *event) |
---|
643 | 633 | { |
---|
644 | 634 | struct asd_sas_phy *phy = event->phy; |
---|