hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/drivers/scsi/libsas/sas_init.c
....@@ -1,26 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Serial Attached SCSI (SAS) Transport Layer initialization
34 *
45 * Copyright (C) 2005 Adaptec, Inc. All rights reserved.
56 * 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
- *
247 */
258
269 #include <linux/module.h>
....@@ -87,25 +70,27 @@
8770 /*------------ SAS addr hash -----------*/
8871 void sas_hash_addr(u8 *hashed, const u8 *sas_addr)
8972 {
90
- const u32 poly = 0x00DB2777;
91
- u32 r = 0;
92
- int i;
73
+ const u32 poly = 0x00DB2777;
74
+ u32 r = 0;
75
+ int i;
9376
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;
10579
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;
10994 }
11095
11196 int sas_register_ha(struct sas_ha_struct *sas_ha)
....@@ -128,20 +113,14 @@
128113
129114 error = sas_register_phys(sas_ha);
130115 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);
132117 return error;
133118 }
134119
135120 error = sas_register_ports(sas_ha);
136121 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);
138123 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;
145124 }
146125
147126 error = -ENOMEM;
....@@ -605,16 +584,15 @@
605584 }
606585 EXPORT_SYMBOL_GPL(sas_domain_attach_transport);
607586
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)
610589 {
611590 struct asd_sas_event *event;
612
- gfp_t flags = in_interrupt() ? GFP_ATOMIC : GFP_KERNEL;
613591 struct sas_ha_struct *sas_ha = phy->ha;
614592 struct sas_internal *i =
615593 to_sas_internal(sas_ha->core.shost->transportt);
616594
617
- event = kmem_cache_zalloc(sas_event_cache, flags);
595
+ event = kmem_cache_zalloc(sas_event_cache, gfp_flags);
618596 if (!event)
619597 return NULL;
620598
....@@ -623,9 +601,10 @@
623601 if (atomic_read(&phy->event_nr) > phy->ha->event_thres) {
624602 if (i->dft->lldd_control_phy) {
625603 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);
629608 }
630609 } else {
631610 /* Do not support PHY control, stop allocating events */
....@@ -639,6 +618,17 @@
639618 return event;
640619 }
641620
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
+
642632 void sas_free_event(struct asd_sas_event *event)
643633 {
644634 struct asd_sas_phy *phy = event->phy;